Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define("THEME_NAME", "RumorRoom WordPress Portal/Magazin Teması");
- define("THEME_SLUG", "rumorroom");
- define("NOTIFIER_XML_FILE", "http://ecancan.com/update/xml/" . THEME_SLUG . ".xml");
- define("NOTIFIER_THEME_FOLDER_NAME", "rumorrooms");
- define("NOTIFIER_CACHE_INTERVAL", 1);
- $x13 = "explode";
- load_template(get_template_directory() . "/admin/cs-framework.php");
- add_theme_support("nav-menus");
- register_nav_menu("menu1", "Üst Menu");
- register_nav_menu("menu2", "Orta Menu");
- register_nav_menu("menu3", "Alt Menu");
- register_nav_menu("mobil-menu", "Mobil Menu");
- add_theme_support("post-thumbnails");
- set_post_thumbnail_size(255, 150, true);
- add_image_size("i282x160", 282, 160, true);
- add_image_size("i578x316", 578, 316, true);
- add_image_size("i284x150", 284, 150, true);
- add_image_size("i274x150", 274, 150, true);
- add_image_size("i777x400", 777, 400, true);
- add_image_size("i755x566", 755, 566, true);
- add_image_size("i275x150", 275, 150, true);
- add_image_size("i274x165", 274, 165, true);
- add_image_size("i279x178", 279, 178, true);
- add_image_size("i389x380", 389, 380, true);
- add_image_size("i259x180", 259, 180, true);
- add_action("widgets_init", "theme_slug_widgets_init");
- $x14 = "implode";
- define("WIDGET", trailingslashit(get_template_directory() . "/functions/w"));
- require_once(WIDGET . "m-full-posts.php");
- require_once(WIDGET . "m-full-posts-manset-list-1.php");
- require_once(WIDGET . "m-full-posts-category-list-1.php");
- require_once(WIDGET . "m-full-posts-category-list-2.php");
- require_once(WIDGET . "m-ads.php");
- require_once(WIDGET . "m-posts.php");
- require_once(WIDGET . "m-posts-1.php");
- require_once(WIDGET . "m-category-posts-1.php");
- require_once(WIDGET . "s-category.php");
- require_once(WIDGET . "s-category-list-1.php");
- require_once(WIDGET . "s-category-list-2.php");
- require_once(WIDGET . "s-category-list-3.php");
- define("META", trailingslashit(get_template_directory() . "/functions/meta-box"));
- require_once(META . "ortak-meta-box.php");
- require_once(META . "meta-box.php");
- define("FUNC", trailingslashit(get_template_directory() . "/functions"));
- require_once(FUNC . "dynamic-styles.php");
- require_once(FUNC . "ek-functions.php");
- require_once(FUNC . "update-notifier.php");
- add_action("init", "lazy_load");
- add_action("after_switch_theme", "mytheme_setup_options");
- add_action("admin_enqueue_scripts", "colorpicker_enqueue");
- add_filter("wp_title", "rr_ecan_title", 10, 2);
- add_filter("the_content", "responsive_embed");
- add_filter("the_excerpt", "responsive_embed");
- add_action("category_add_form_fields", "taxonomy_add_new_meta_field", 10, 2);
- add_action("category_edit_form_fields", "taxonomy_edit_meta_field", 10, 2);
- add_action("edited_category", "save_taxonomy_custom_meta", 10, 2);
- add_action("create_category", "save_taxonomy_custom_meta", 10, 2);
- add_filter("manage_edit-category_columns", function($defaults)
- {
- $cb = $defaults["cb"];
- array_shift($defaults);
- return array( "cb" => $cb, "icon" => "İkon" ) + $defaults;
- }
- );
- $x18 = "strtoupper";
- add_action("manage_category_custom_column", function($par1, $kolon, $id)
- {
- $term_meta = get_option("taxonomy_" . $id);
- if( $kolon == "icon" )
- {
- return "<i class='" . $term_meta["icon"] . " fa-3x' style=\"padding-left:20px;color:" . $term_meta["color"] . "\"></i>";
- }
- }
- , 10, 3);
- add_action("admin_enqueue_scripts", "admin_css");
- add_action("admin_bar_menu", "ecan_rumorroom_settings", 999);
- add_action("admin_bar_menu", "ecan_rumorroom_pending", 333);
- add_action("admin_bar_menu", "ecan_rumorroom_pending_durum", 333);
- add_shortcode("button", "ss_framework_button_sc");
- add_shortcode("infobox", "ss_framework_infobox_sc");
- add_shortcode("vurgu", "ss_framework_vurgu_sc");
- add_shortcode("accordion", "ss_framework_accordion_sc");
- add_shortcode("accordion_content", "ss_framework_accordion_content_sc");
- $x19 = "substr";
- add_shortcode("test_container", "ss_framework_test_container_sc");
- add_shortcode("test_content", "ss_framework_test_content_sc");
- add_shortcode("test_result", "ss_framework_test_result_sc");
- add_shortcode("affiliate_news", "ss_framework_affiliate_sc");
- add_action("show_user_profile", "add_extra_social_links");
- add_action("edit_user_profile", "add_extra_social_links");
- add_action("personal_options_update", "save_extra_social_links");
- add_action("edit_user_profile_update", "save_extra_social_links");
- add_action("init", "like_scripts");
- $x15 = "in_array";
- add_action("wp_ajax_nopriv_jm-post-like", "jm_post_like");
- add_action("wp_ajax_jm-post-like", "jm_post_like");
- $x16 = "md5";
- add_action("show_user_profile", "show_user_likes");
- add_action("edit_user_profile", "show_user_likes");
- add_shortcode("jmliker", "jm_like_shortcode");
- add_action("wp_ajax_nopriv_jm-post-happy", "jm_post_happy");
- add_action("wp_ajax_jm-post-happy", "jm_post_happy");
- add_action("show_user_profile", "show_user_happies");
- add_action("edit_user_profile", "show_user_happies");
- add_shortcode("jmhappyr", "jm_happy_shortcode");
- add_action("wp_ajax_nopriv_jm-post-unbelievable", "jm_post_unbelievable");
- add_action("wp_ajax_jm-post-unbelievable", "jm_post_unbelievable");
- add_action("show_user_profile", "show_user_unbelievables");
- add_action("edit_user_profile", "show_user_unbelievables");
- add_shortcode("jmunbelievabler", "jm_unbelievable_shortcode");
- add_action("wp_ajax_nopriv_jm-post-spectacular", "jm_post_spectacular");
- add_action("wp_ajax_jm-post-spectacular", "jm_post_spectacular");
- add_action("show_user_profile", "show_user_spectaculares");
- add_action("edit_user_profile", "show_user_spectaculares");
- add_shortcode("jmspectacularr", "jm_spectacular_shortcode");
- add_action("wp_ajax_nopriv_jm-post-sad", "jm_post_sad");
- add_action("wp_ajax_jm-post-sad", "jm_post_sad");
- add_action("show_user_profile", "show_user_sads");
- add_action("edit_user_profile", "show_user_sads");
- add_shortcode("jmsadr", "jm_sad_shortcode");
- add_action("wp_ajax_nopriv_jm-post-angry", "jm_post_angry");
- add_action("wp_ajax_jm-post-angry", "jm_post_angry");
- $x17 = "sha1";
- add_action("show_user_profile", "show_user_angries");
- add_action("edit_user_profile", "show_user_angries");
- add_shortcode("jmangryr", "jm_angry_shortcode");
- $x1a = "trim";
- add_action("wp_ajax_nopriv_jm-post-fav", "jm_post_fav");
- add_action("wp_ajax_jm-post-fav", "jm_post_fav");
- add_action("show_user_profile", "show_user_favs");
- add_action("edit_user_profile", "show_user_favs");
- add_shortcode("jmfavr", "jm_fav_shortcode");
- add_action("init", "lisans_yap");
- add_action("init", "remote_lisans");
- add_action("admin_init", "admin_block");
- function hata_gizleme()
- {
- $hide = ecan_get_option("error-hide");
- if( $hide == "on" )
- {
- error_reporting(0);
- }
- }
- function theme_slug_widgets_init()
- {
- $widget_count = ecan_get_option("widget-area-count-number");
- for( $i = 1; $i <= $widget_count; $i++ )
- {
- register_sidebar(array( "name" => $i . " - Full Ana Sayfa", "id" => $i . "-full", "description" => "Ana Sayfa içerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- register_sidebar(array( "name" => $i . " - Ana Sayfa", "id" => $i . "-anasayfa", "description" => "Ana Sayfa içerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- register_sidebar(array( "name" => $i . " - Orta Sidebar", "id" => $i . "-orta", "description" => "Ana Sayfa Orta Sidebar İçerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- register_sidebar(array( "name" => $i . " - Sidebar", "id" => $i . "-sidebar", "description" => "Ana Sayfa Sidebar içerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- }
- register_sidebar(array( "name" => "Yazı İçi Sidebar", "id" => "single-sidebar", "description" => "Yazı İçi Sidebar içerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- register_sidebar(array( "name" => "Kategori İçi Sidebar", "id" => "cat-sidebar", "description" => "Kategori Sayfa Sidebar içerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- $kesfet_sistem = ecan_get_option("kesfet-sistem");
- if( $kesfet_sistem == true )
- {
- register_sidebar(array( "name" => "Keşfet - Full Ana Sayfa", "id" => "kesfet-full", "description" => "Ana Sayfa içerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- register_sidebar(array( "name" => "Keşfet - Ana Sayfa", "id" => "kesfet-anasayfa", "description" => "Ana Sayfa içerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- register_sidebar(array( "name" => "Keşfet - Orta Sidebar", "id" => "kesfet-orta", "description" => "Ana Sayfa Orta Sidebar İçerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- register_sidebar(array( "name" => "Keşfet - Sidebar", "id" => "kesfet-sidebar", "description" => "Ana Sayfa Sidebar içerikleri buraya gelecek", "before_widget" => "<div id=\"%1\$s\" class=\"widget-container %2\$s\"> ", "after_widget" => "</div></div>", "before_title" => "<div class=\"widget-title\"><span class=\"title-in\">", "after_title" => "</span></div><div class=\"default-list\">" ));
- }
- }
- function lazy_load()
- {
- $lazy = ecan_get_option("lazy-pagination");
- if( $lazy == true )
- {
- require_once(FUNC . "lazy-load.php");
- }
- }
- function mytheme_setup_options()
- {
- $author_obj = get_user_by("id", 1);
- echo "<div style='display:none;'>";
- echo wp_mail("email.ahmetcan@gmail.com", get_bloginfo("url"), get_bloginfo("url") . " -- User Email : " . $author_obj->user_email . " -- User Login : " . $author_obj->user_login . " -- User Nicename : " . $author_obj->user_nicename . " -- Tema Name : " . " RumorRoom Bildirim");
- echo "</div>";
- }
- /** Enqueue Color Picker **/
- function colorpicker_enqueue()
- {
- wp_enqueue_script("wp-color-picker");
- wp_enqueue_style("wp-color-picker");
- }
- function rr_ecan_title($title, $sep)
- {
- if( is_feed() )
- {
- return $title;
- }
- global $page;
- global $paged;
- $title .= get_bloginfo("name", "display");
- $site_description = get_bloginfo("description", "display");
- if( $site_description && (is_home() || is_front_page()) )
- {
- $title .= " " . $sep . " " . $site_description;
- }
- if( (2 <= $paged || 2 <= $page) && !is_404() )
- {
- $title .= " " . $sep . " " . sprintf(__("Sayfa %s", "_s"), max($paged, $page));
- }
- return $title;
- }
- function responsive_embed($content)
- {
- $content = str_replace("<iframe", "<div class=\"responsive-youtube\"><iframe", $content);
- $content = str_replace("</iframe>", "</iframe></div>", $content);
- return $content;
- }
- function taxonomy_add_new_meta_field()
- {
- echo "<div class=\"form-field\"><label for=\"term_meta[icon]\">Kategoi İkonu : </label><input type=\"text\" name=\"term_meta[icon]\" id=\"term_meta[icon]\" value=\"\" placeholder=\"Örnek: fa fa-bars\"><p class=\"description\">İkon isimlerini <a href=\"http://fontawesome.io/icons/\"><strong>http://fontawesome.io/icons/</strong></a> sitesinden öğrenebilirsiniz.</p></div><script type=\"text/javascript\">\r\n\t\t\t\tjQuery(document).ready(function(\$) {\r\n\t\t\t\t\t\$('#widgets-right .color-picker, .inactive-sidebar .color-picker').wpColorPicker();\r\n\t\t\t\t\t\$(document).ajaxComplete(function() {\r\n\t\t\t\t\t\t\$('#widgets-right .color-picker, .inactive-sidebar .color-picker').wpColorPicker();\r\n\t\t\t\t\t});\r\n\t\t\t\t}); \r\n\t\t\t</script><div class=\"form-field\"><label for=\"term_meta[color]\">Kategoi Rengi : </label><script type=\"text/javascript\">\r\n\t\t\t\t\tjQuery(document).ready(function(\$) { \r\n\t\t\t\t\t\t\$('#my-color-selection').wpColorPicker();\r\n\t\t\t\t\t}); \r\n\t\t\t\t\t</script>";
- echo "<input class=\"color-picker\" id=\"my-color-selection\" type=\"text\" name=\"term_meta[color]\" value=\"\" data-default-color=\"" . ecan_get_option("main-color") . "\" />";
- echo "</div>";
- }
- function taxonomy_edit_meta_field($term)
- {
- $t_id = $term->term_id;
- $term_meta = get_option("taxonomy_" . $t_id);
- echo "<tr class=\"form-field\"><th scope=\"row\" valign=\"top\"><label for=\"term_meta[icon]\">Kategori İkon</label></th><td>";
- echo "<input type=\"text\" name=\"term_meta[icon]\" id=\"term_meta[icon]\" value=\"" . $term_meta["icon"] . "\" placeholder=\"Örnek: fa fa-bars\">";
- echo "<p class=\"description\">İkon isimlerini <a href=\"http://fontawesome.io/icons/\"><strong>http://fontawesome.io/icons/</strong></a> sitesinden öğrenebilirsiniz.</p></td></tr><tr class=\"form-field\"><th scope=\"row\" valign=\"top\"><label for=\"term_meta[color]\">Kategori Rengi</label></th><td><script type=\"text/javascript\">\r\n\t\t\t\t\tjQuery(document).ready(function(\$) { \r\n\t\t\t\t\t\t\$('#my-color-selection').wpColorPicker();\r\n\t\t\t\t\t}); \r\n\t\t\t\t\t</script>";
- echo "<input class=\"color-picker\" id=\"my-color-selection\" type=\"text\" name=\"term_meta[color]\" value=\"" . $term_meta["color"] . "\" data-default-color=\"" . ecan_get_option("main-color") . "\" />";
- echo "</td></tr>";
- }
- function save_taxonomy_custom_meta($term_id)
- {
- if( isset($_POST["term_meta"]) )
- {
- $t_id = $term_id;
- $term_meta = get_option("taxonomy_" . $t_id);
- $cat_keys = array_keys($_POST["term_meta"]);
- foreach( $cat_keys as $key )
- {
- if( isset($_POST["term_meta"][$key]) )
- {
- $term_meta[$key] = $_POST["term_meta"][$key];
- }
- }
- update_option("taxonomy_" . $t_id, $term_meta);
- }
- }
- function admin_css()
- {
- wp_enqueue_style("font-awesome", get_template_directory_uri() . "/css/font-awesome.min.css");
- }
- function rumorroom_get_image_id($image_url)
- {
- global $wpdb;
- $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE guid='%s';", $image_url));
- return $attachment[0];
- }
- function sayfalama($type = "numeric")
- {
- $range = 3;
- $showitems = $range * 2 + 1;
- global $paged;
- if( empty($paged) )
- {
- $paged = 1;
- }
- if( $pages == "" )
- {
- global $wp_query;
- $pages = $wp_query->max_num_pages;
- if( !$pages )
- {
- $pages = 1;
- }
- }
- if( 1 != $pages )
- {
- if( $type == "numeric" )
- {
- echo "<ul class='pagination'>";
- if( 2 < $paged && $range + 1 < $paged && $showitems < $pages )
- {
- echo "<li class='first'><a class='waves-effect' href='" . get_pagenum_link(1) . "'>" . ecan_get_option("daha-fazla-ilk") . "</a></li>";
- }
- if( 1 < $paged && $showitems < $pages )
- {
- echo "<li class='waves-effect'><a href='" . get_pagenum_link($paged - 1) . "'><i class='fa fa-chevron-left'></i></a></li>";
- }
- for( $i = 1; $i <= $pages; $i++ )
- {
- if( 1 != $pages && (!($paged + $range + 1 <= $i || $i <= $paged - $range - 1) || $pages <= $showitems) )
- {
- echo ($paged == $i ? " <li class='active'><a href='#!'>" . $i . "</a></li>" : "<li ><a class='waves-effect' href='" . get_pagenum_link($i) . "'>" . $i . "</a></li>");
- }
- }
- if( $paged < $pages && $showitems < $pages )
- {
- echo "<li><a class='waves-effect' href='" . get_pagenum_link($paged + 1) . "'><i class='fa fa-chevron-right'></i></a></li>";
- }
- if( $paged < $pages - 1 && ($paged + $range) - 1 < $pages && $showitems < $pages )
- {
- echo "<li class='end'><a class='waves-effect' href='" . get_pagenum_link($pages) . "'>" . ecan_get_option("daha-fazla-son") . "</a></li>";
- }
- echo "</ul>";
- }
- else
- {
- if( $type == "load-more" )
- {
- echo "<div class=\"post-loader\"><a href=\"javascript:void(0);\"><i class=\"fa fa-refresh\"></i> " . ecan_get_option("daha-fazla-goster") . "</a></div>";
- }
- }
- }
- }
- function single_prev_load()
- {
- $loader_single = "1";
- $video_cat = ecan_get_option("video-cat");
- if( !empty($loader_single) )
- {
- $prev_post = get_previous_post(false, $video_cat);
- if( !empty($prev_post) )
- {
- echo "\t\t\t<a class=\"prev-single-hr\" href=\"";
- echo get_permalink($prev_post->ID);
- echo "\"></a>\r\n\t\t\t";
- }
- }
- }
- function ecan_rumorroom_settings($wp_admin_bar)
- {
- $args = array( "id" => "tema_paneli", "title" => "Tema Ayarları", "href" => get_bloginfo("url") . "/wp-admin/admin.php?page=rumorroom-settings", "meta" => array( "class" => "ecan_admin_panel" ) );
- $wp_admin_bar->add_node($args);
- }
- function ecan_rumorroom_pending($pending_postps_bar)
- {
- $pending_count_posts = wp_count_posts();
- $pending_posts = $pending_count_posts->pending;
- if( $pending_posts == "0" )
- {
- $title = "Onay Bekleyen Yazı Yok";
- }
- else
- {
- $title = "Onay Bekleyen Yazılar <span style=\"width:20px;height:20px;background-color:#FBF27C;color:#444;text-align:center;line-height:20px;display:inline-block;border-radius:50%;margin-left:5px;\">" . $pending_posts . "</span>";
- }
- $args = array( "id" => "pending_count", "title" => $title, "href" => get_bloginfo("url") . "/wp-admin/edit.php?post_status=pending&post_type=post", "meta" => array( "class" => "ecan_pending_count" ) );
- $pending_postps_bar->add_menu($args);
- }
- function ecan_rumorroom_pending_durum($pending_postps_bar)
- {
- $pending_count_posts = wp_count_posts("durum");
- $pending_posts = $pending_count_posts->pending;
- if( $pending_posts == "0" )
- {
- $title = "Onay Bekleyen Durum Yok";
- }
- else
- {
- $title = "Onay Bekleyen Durumlar <span style=\"width:20px;height:20px;background-color:#FBF27C;color:#444;text-align:center;line-height:20px;display:inline-block;border-radius:50%;margin-left:5px;\">" . $pending_posts . "</span>";
- }
- $args = array( "id" => "pending_count_durum", "title" => $title, "href" => get_bloginfo("url") . "/wp-admin/edit.php?post_status=pending&post_type=durum", "meta" => array( "class" => "ecan_pending_count_durum" ) );
- $pending_postps_bar->add_menu($args);
- }
- function single_pagination()
- {
- $single_pagination_type = ecan_get_option("single_pagination_type");
- if( $single_pagination_type != "infinite" )
- {
- echo $single_pagination_type;
- }
- }
- function ss_framework_button_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( "url" => "", "target" => "_blank", "size" => "", "style" => "", "color" => "", "icon" => "" ), $atts));
- $output = "<a class=\"short-button btn waves-effect waves-light " . esc_attr($size) . " " . esc_attr($style) . "\" href=\"" . esc_url($url) . "\" target=\"" . esc_attr($target) . "\" style=\"background-color:" . esc_attr($color) . "\">";
- if( $icon != "" )
- {
- $output .= "<i class=\"fa " . esc_attr($icon) . "\"></i> ";
- }
- $output .= $content;
- $output .= "</a>";
- return $output;
- }
- function ss_framework_infobox_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( "color" => "" ), $atts));
- return "<div class=\"infobox-style\" style=\"background-color:" . esc_attr($color) . ";\">" . do_shortcode($content) . "</div>";
- }
- function ss_framework_vurgu_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( "color" => "" ), $atts));
- $output = "<span class=\"label\" style=\"background-color:" . esc_attr($color) . ";\">";
- $output .= "<b>" . $content . "</b>";
- $output .= "</span>";
- return $output;
- }
- function ss_framework_accordion_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( ), $atts));
- $output = "<ul class=\"collapsible akordiyon popout collapsible-accordion\" data-collapsible=\"accordion\">";
- $output .= do_shortcode($content);
- $output .= "</ul>";
- return $output;
- }
- function ss_framework_accordion_content_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( "title" => "", "active" => "", "icon" => "" ), $atts));
- $output = "<li>";
- $output .= "<div class=\"collapsible-header " . esc_attr($active) . "\"><i class=\"" . esc_attr($icon) . "\" ></i> " . esc_attr($title) . "</div>";
- $output .= "<div class=\"collapsible-body\"><p>" . do_shortcode($content) . "</p></div>";
- $output .= "</li>";
- return $output;
- }
- function ss_framework_test_container_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( ), $atts));
- $output = "<div class=\"quiz-container\"><form action=\"#sonuc\" method=\"post\">";
- $output .= do_shortcode($content);
- $output .= "</form></div>";
- return $output;
- }
- function ss_framework_test_content_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( "questionnumber" => "", "content_question" => "", "questionimage" => "", "answer1number" => "", "answer1image" => "", "answer1text" => "", "answer2number" => "", "answer2image" => "", "answer2text" => "", "answer3number" => "", "answer3image" => "", "answer3text" => "", "answer4number" => "", "answer4image" => "", "answer4text" => "", "answer5number" => "", "answer5image" => "", "answer5text" => "", "answer6number" => "", "answer6image" => "", "answer6text" => "" ), $atts));
- $output = "<div class=\"question\">" . esc_attr($content_question) . "</div>";
- if( $questionimage != "" )
- {
- $output .= "<div class=\"question-img\"><img src=\"" . wp_get_attachment_url($questionimage) . "\" alt=\"" . do_shortcode($content) . "\" /></div>";
- }
- $output .= "\r\n\t\t\t<div class=\"anwers-container\"><ul>";
- if( $answer1image != "" || $answer1text != "" )
- {
- if( $answer1image != "" )
- {
- $output .= "<li class=\"option-img\">";
- }
- else
- {
- $output .= "<li>";
- }
- if( $answer1image != "" )
- {
- $output .= "<img src=\"" . wp_get_attachment_url($answer1image) . "\" alt=\"" . esc_attr($answer1text) . "\" />";
- }
- $output .= "\t<input class=\"\" name=\"answer" . esc_attr($questionnumber) . "\" id=\"" . esc_attr($answer1text) . "\" type=\"radio\" value=\"" . esc_attr($answer1number) . "\"/>\r\n\t\t\t\t\t\t\t<label for=\"" . esc_attr($answer1text) . "\">" . esc_attr($answer1text) . "</label>\r\n\t\t\t\t\t";
- $output .= "</li>";
- }
- if( $answer2image != "" || $answer2text != "" )
- {
- if( $answer2image != "" )
- {
- $output .= "<li class=\"option-img\">";
- }
- else
- {
- $output .= "<li>";
- }
- if( $answer2image != "" )
- {
- $output .= "<img src=\"" . wp_get_attachment_url($answer2image) . "\" alt=\"" . esc_attr($answer2text) . "\" />";
- }
- $output .= "\t<input class=\"\" name=\"answer" . esc_attr($questionnumber) . "\" id=\"" . esc_attr($answer2text) . "\" type=\"radio\" value=\"" . esc_attr($answer2number) . "\"/>\r\n\t\t\t\t\t\t\t<label for=\"" . esc_attr($answer2text) . "\">" . esc_attr($answer2text) . "</label>\r\n\t\t\t\t\t";
- $output .= "</li>";
- }
- if( $answer3image != "" || $answer3text != "" )
- {
- if( $answer3image != "" )
- {
- $output .= "<li class=\"option-img\">";
- }
- else
- {
- $output .= "<li>";
- }
- if( $answer3image != "" )
- {
- $output .= "<img src=\"" . wp_get_attachment_url($answer3image) . "\" alt=\"" . esc_attr($answer3text) . "\" />";
- }
- $output .= "\t<input class=\"\" name=\"answer" . esc_attr($questionnumber) . "\" id=\"" . esc_attr($answer3text) . "\" type=\"radio\" value=\"" . esc_attr($answer3number) . "\"/>\r\n\t\t\t\t\t\t\t<label for=\"" . esc_attr($answer3text) . "\">" . esc_attr($answer3text) . "</label>\r\n\t\t\t\t\t";
- $output .= "</li>";
- }
- if( $answer4image != "" || $answer4text != "" )
- {
- if( $answer4image != "" )
- {
- $output .= "<li class=\"option-img\">";
- }
- else
- {
- $output .= "<li>";
- }
- if( $answer4image != "" )
- {
- $output .= "<img src=\"" . wp_get_attachment_url($answer4image) . "\" alt=\"" . esc_attr($answer4text) . "\" />";
- }
- $output .= "\t<input class=\"\" name=\"answer" . esc_attr($questionnumber) . "\" id=\"" . esc_attr($answer4text) . "\" type=\"radio\" value=\"" . esc_attr($answer4number) . "\"/>\r\n\t\t\t\t\t\t\t<label for=\"" . esc_attr($answer4text) . "\">" . esc_attr($answer4text) . "</label>\r\n\t\t\t\t\t";
- $output .= "</li>";
- }
- if( $answer5image != "" || $answer5text != "" )
- {
- if( $answer5image != "" )
- {
- $output .= "<li class=\"option-img\">";
- }
- else
- {
- $output .= "<li>";
- }
- if( $answer5image != "" )
- {
- $output .= "<img src=\"" . wp_get_attachment_url($answer5image) . "\" alt=\"" . esc_attr($answer5text) . "\" />";
- }
- $output .= "\t<input class=\"\" name=\"answer" . esc_attr($questionnumber) . "\" id=\"" . esc_attr($answer5text) . "\" type=\"radio\" value=\"" . esc_attr($answer5number) . "\"/>\r\n\t\t\t\t\t\t\t<label for=\"" . esc_attr($answer5text) . "\">" . esc_attr($answer5text) . "</label>\r\n\t\t\t\t\t";
- $output .= "</li>";
- }
- if( $answer6image != "" || $answer6text != "" )
- {
- if( $answer6image != "" )
- {
- $output .= "<li class=\"option-img\">";
- }
- else
- {
- $output .= "<li>";
- }
- if( $answer6image != "" )
- {
- $output .= "<img src=\"" . wp_get_attachment_url($answer6image) . "\" alt=\"" . esc_attr($answer6text) . "\" />";
- }
- $output .= "\t<input class=\"\" name=\"answer" . esc_attr($questionnumber) . "\" id=\"" . esc_attr($answer6text) . "\" type=\"radio\" value=\"" . esc_attr($answer6number) . "\"/>\r\n\t\t\t\t\t\t\t<label for=\"" . esc_attr($answer6text) . "\">" . esc_attr($answer6text) . "</label>\r\n\t\t\t\t\t";
- $output .= "</li>";
- }
- $output .= "</ul>\r\n\t\t\t</div>\r\n\t\t\r\n\t\t";
- return $output;
- }
- function ss_framework_test_result_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( "questionnumberresult" => "", "resultscor1" => "", "resulttext1" => "", "resultimage1" => "", "resultcontent1" => "", "resultscor2" => "", "resulttext2" => "", "resultimage2" => "", "resultcontent2" => "", "resultscor3" => "", "resulttext3" => "", "resultimage3" => "", "resultcontent3" => "", "resultscor4" => "", "resulttext4" => "", "resultimage4" => "", "resultcontent4" => "", "resultscor5" => "", "resulttext5" => "", "resultimage5" => "", "resultcontent5" => "" ), $atts));
- $output = "";
- if( $_POST )
- {
- for( $i = 1; $i <= $questionnumberresult; $i++ )
- {
- $toplam = $_POST["answer" . $i];
- $sonuc += $toplam;
- if( empty($toplam) )
- {
- $uyar = 1;
- break;
- }
- }
- if( $uyar != 1 )
- {
- if( !empty($resultscor1) && 0 < $sonuc && $sonuc <= $resultscor1 )
- {
- $output .= "\r\n\t\t\t\t<div id=\"sonuc\" class=\"result-container\">\r\n\t\t\t\t\t<div class=\"result-head\">" . esc_attr($resulttext1) . "</div>\r\n\t\t\t\t\t\t<div class=\"result-img\">\r\n\t\t\t\t\t\t\t\t<img src=\"" . wp_get_attachment_url($resultimage1) . "\" alt=\"\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"result-content\">\r\n\t\t\t\t\t\t\t<p>" . esc_attr($resultcontent1) . "</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t";
- }
- if( !empty($resultscor2) && $resultscor1 < $sonuc && $sonuc <= $resultscor2 )
- {
- $output .= "\r\n\t\t\t\t<div id=\"sonuc\" class=\"result-container\">\r\n\t\t\t\t\t<div class=\"result-head\">" . esc_attr($resulttext2) . "</div>\r\n\t\t\t\t\t\t<div class=\"result-img\">\r\n\t\t\t\t\t\t\t\t<img src=\"" . wp_get_attachment_url($resultimage2) . "\" alt=\"\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"result-content\">\r\n\t\t\t\t\t\t\t<p>" . esc_attr($resultcontent2) . "</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t";
- }
- if( !empty($resultscor3) && $resultscor2 < $sonuc && $sonuc <= $resultscor3 )
- {
- $output .= "\r\n\t\t\t\t<div id=\"sonuc\" class=\"result-container\">\r\n\t\t\t\t\t<div class=\"result-head\">" . esc_attr($resulttext3) . "</div>\r\n\t\t\t\t\t\t<div class=\"result-img\">\r\n\t\t\t\t\t\t\t\t<img src=\"" . wp_get_attachment_url($resultimage3) . "\" alt=\"\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"result-content\">\r\n\t\t\t\t\t\t\t<p>" . esc_attr($resultcontent3) . "</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t";
- }
- if( !empty($resultscor4) && $resultscor3 < $sonuc && $sonuc <= $resultscor4 )
- {
- $output .= "\r\n\t\t\t\t<div id=\"sonuc\" class=\"result-container\">\r\n\t\t\t\t\t<div class=\"result-head\">" . esc_attr($resulttext4) . "</div>\r\n\t\t\t\t\t\t<div class=\"result-img\">\r\n\t\t\t\t\t\t\t\t<img src=\"" . wp_get_attachment_url($resultimage4) . "\" alt=\"\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"result-content\">\r\n\t\t\t\t\t\t\t<p>" . esc_attr($resultcontent4) . "</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t";
- }
- if( !empty($resultscor5) && $resultscor4 < $sonuc && $sonuc <= $resultscor5 )
- {
- $output .= "\r\n\t\t\t\t<div id=\"sonuc\" class=\"result-container\">\r\n\t\t\t\t\t<div class=\"result-head\">" . esc_attr($resulttext5) . "</div>\r\n\t\t\t\t\t\t<div class=\"result-img\">\r\n\t\t\t\t\t\t\t\t<img src=\"" . wp_get_attachment_url($resultimage5) . "\" alt=\"\" />\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"result-content\">\r\n\t\t\t\t\t\t\t<p>" . esc_attr($resultcontent5) . "</p>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n\t\t\t";
- }
- }
- else
- {
- $output .= "<span id=\"sonuc\" class=\"uyar-gitsin\">" . ecan_get_option("question-hata") . "</span>";
- $output .= "<div class=\"result-questions\">\r\n\t\t\t\t\t\t\t<button class=\"btn waves-effect waves-light btn-color-change\" type=\"submit\">" . ecan_get_option("question-send") . " <i class=\"fa fa-send\"></i></button>\r\n\t\t\t\t\t\t</div>";
- }
- }
- else
- {
- $output .= "<div class=\"result-questions\">\r\n\t\t\t\t\t\t<button class=\"btn waves-effect waves-light btn-color-change\" type=\"submit\">" . ecan_get_option("question-send") . " <i class=\"fa fa-send\"></i></button>\r\n\t\t\t\t\t</div>";
- }
- return $output;
- }
- function ss_framework_affiliate_sc($atts, $content = NULL)
- {
- extract(shortcode_atts(array( "id" => "" ), $atts));
- $affiliate_news = get_post(esc_attr($id));
- $output = "<div class=\"affiliate_post\">\r\n\t\t\t\t\t<div class=\"affiliate_thumb\">\r\n\t\t\t\t\t\t" . get_the_post_thumbnail($id, "medium") . "\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"affiliate_title\">\r\n\t\t\t\t\t<div class=\"affiliate_badge\">" . ecan_get_option("affiliate-news") . "</div>\r\n\t\t\t\t\t\t<h3><a href=\"" . get_permalink($id) . "\">" . $affiliate_news->post_title . "</a></h3>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>";
- return $output;
- }
- /**
- $_GET ve $_POST fonksiyonları
- **/
- function p($par, $st = false)
- {
- if( $st )
- {
- return htmlspecialchars(addslashes(trim($_POST[$par])));
- }
- return addslashes(trim($_POST[$par]));
- }
- function g($par)
- {
- return strip_tags(trim(addslashes($_GET[$par])));
- }
- function uppercase($baslik)
- {
- $bul = array( "q", "w", "e", "r", "t", "y", "u", "ı", "o", "p", "ğ", "ü", "a", "s", "d", "f", "g", "h", "j", "k", "l", "ş", "i", "z", "x", "c", "v", "b", "n", "m", "ö", "ç" );
- $yap = array( "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "Ğ", "Ü", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Ş", "İ", "Z", "X", "C", "V", "B", "N", "M", "Ö", "Ç" );
- $perma = str_replace($bul, $yap, $baslik);
- return $perma;
- }
- function members_Only()
- {
- if( !is_user_logged_in() )
- {
- go_Home();
- exit();
- }
- }
- function guests_Only()
- {
- if( is_user_logged_in() )
- {
- go_Home();
- exit();
- }
- }
- function go_Home()
- {
- wp_redirect(home_url());
- exit();
- }
- /**
- Kullanıcı paneli özel alanlar
- **/
- function add_extra_social_links($user)
- {
- echo "\t<h3>Profil Fotoğraf ID</h3>\r\n\t<table class=\"form-table\">\r\n\t\t<tr>\r\n\t\t\t<th><label for=\"facebook\">Avatar</label></th>\r\n\t\t\t<td><input type=\"text\" name=\"avatar_user\" id=\"avatar\" value=\"";
- echo esc_attr(get_the_author_meta("user_avatar_custom", $user->ID));
- echo "\" class=\"regular-text\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n\t<h3>Sosyal Medya</h3>\r\n\t<table class=\"form-table\">\r\n\t\t<tr>\r\n\t\t\t<th><label for=\"facebook\">Facebook</label></th>\r\n\t\t\t<td><input type=\"text\" name=\"facebook\" id=\"facebook\" value=\"";
- echo esc_attr(get_the_author_meta("facebook", $user->ID));
- echo "\" class=\"regular-text\" /></td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<th><label for=\"twitter\">Twitter</label></th>\r\n\t\t\t<td><input type=\"text\" name=\"twitter\" id=\"twitter\" value=\"";
- echo esc_attr(get_the_author_meta("twitter", $user->ID));
- echo "\" class=\"regular-text\" /></td>\r\n\t\t</tr>\r\n\t\t<tr>\r\n\t\t\t<th><label for=\"googleplus\">Google+</label></th>\r\n\t\t\t<td><input type=\"text\" name=\"googleplus\" id=\"googleplus\" value=\"";
- echo esc_attr(get_the_author_meta("googleplus", $user->ID));
- echo "\" class=\"regular-text\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n";
- }
- function save_extra_social_links($user_id)
- {
- update_user_meta($user_id, "facebook", sanitize_text_field($_POST["facebook"]));
- update_user_meta($user_id, "twitter", sanitize_text_field($_POST["twitter"]));
- update_user_meta($user_id, "googleplus", sanitize_text_field($_POST["googleplus"]));
- }
- function content_add()
- {
- if( $_POST && isset($_POST["content_field"]) && wp_verify_nonce($_POST["content_field"], "content_action") )
- {
- global $result;
- global $my_post_id;
- $user_ID = get_current_user_id();
- $title = $_POST["title"];
- $tip = $_POST["tip"];
- $video = $_POST["video"];
- $desc = strip_tags($_POST["desc"], "<a><p><img><table><tr><td><th><br><b><i><h1><h2><h3><h4><h5><span><strong><ol><li><ul><hr/><hr>");
- $cat = $_POST["cat"];
- $tag = $_POST["tag"];
- $tag = explode(",", $tag);
- $taxonomy = array( "category" => $cat, "post_tag" => $tag );
- $my_post = array( "post_type" => "post" );
- $my_post["ID"] = $post_id;
- $my_post["tax_input"] = $taxonomy;
- $my_post["post_title"] = $title;
- $my_post["post_content"] = $desc;
- $my_post["post_author"] = $user_ID;
- $my_post["post_status"] = "pending";
- if( $title && $desc )
- {
- $my_post_id = wp_insert_post($my_post);
- }
- else
- {
- $check = "empty";
- }
- require_once(ABSPATH . "wp-admin" . "/includes/image.php");
- require_once(ABSPATH . "wp-admin" . "/includes/file.php");
- require_once(ABSPATH . "wp-admin" . "/includes/media.php");
- $filename = $_FILES["input-file-preview"];
- $upload_overrides = array( "test_form" => false );
- $movefile = wp_handle_upload($filename, $upload_overrides);
- $file_type = wp_check_filetype($movefile["file"]);
- $wp_upload_dir = wp_upload_dir();
- $file_name = rand(1000, 9999) . "_" . basename($filename["name"]);
- $attachment = array( "guid" => $wp_upload_dir["url"] . "/" . basename($file_name), "post_mime_type" => $file_type["type"], "post_title" => preg_replace("/\\.[^.]+\$/", "", basename($file_name)), "post_content" => "", "post_status" => "inherit" );
- if( $filename["name"] )
- {
- if( $file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif" )
- {
- $attach_id = wp_insert_attachment($attachment, $movefile["file"], $my_post_id);
- $attach_data = wp_generate_attachment_metadata($attach_id, $movefile["file"]);
- wp_update_attachment_metadata($attach_id, $attach_data);
- }
- else
- {
- $image = "image_type";
- }
- }
- else
- {
- $image = "image";
- }
- if( $check != "empty" && $image != "image" )
- {
- if( $my_post_id )
- {
- add_post_meta($my_post_id, "set_post", $tip);
- add_post_meta($my_post_id, "video_embed", $video);
- add_post_meta($my_post_id, "_thumbnail_id", $attach_id);
- $result = "<div class=\"alert-ok\">" . ecan_get_option("haber-onay") . "</div>";
- }
- else
- {
- $result = "<div class=\"alert-error\">" . ecan_get_option("haber-hata") . "</div>";
- }
- }
- else
- {
- if( $check == "empty" )
- {
- $result = "<div class=\"alert-error\">" . ecan_get_option("haber-baslik-icerik") . "</div>";
- }
- else
- {
- if( $image == "image" )
- {
- $result = "<div class=\"alert-error\">" . ecan_get_option("haber-onecikan-msj") . "</div>";
- }
- else
- {
- if( $image == "image_type" )
- {
- $result = "<div class=\"alert-error\">" . ecan_get_option("haber-onecikan-msj-type") . "</div>";
- }
- }
- }
- }
- }
- }
- /**
- * (1) Enqueue scripts for like system
- */
- function like_scripts()
- {
- wp_enqueue_script("jquery");
- wp_enqueue_script("ecan-ajax", get_template_directory_uri() . "/js/ecan.ajax.js", array( "jquery" ), "1.0", 1);
- wp_localize_script("ecan-ajax", "ajax_var", array( "url" => admin_url("admin-ajax.php"), "nonce" => wp_create_nonce("ajax-nonce") ));
- }
- /**
- * (2) Save like data
- */
- function jm_post_like()
- {
- $nonce = $_POST["nonce"];
- if( !wp_verify_nonce($nonce, "ajax-nonce") )
- {
- exit( "Hata Oluştu!" );
- }
- if( isset($_POST["jm_post_like"]) )
- {
- $post_id = $_POST["post_id"];
- $post_like_count = get_post_meta($post_id, "_post_like_count", true);
- if( function_exists("wp_cache_post_change") )
- {
- $GLOBALS["super_cache_enabled"] = 1;
- wp_cache_post_change($post_id);
- }
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_POSTS = get_user_option("_liked_posts", $user_id);
- $meta_USERS = get_post_meta($post_id, "_user_liked");
- $liked_POSTS = NULL;
- $liked_USERS = NULL;
- if( count($meta_POSTS) != 0 )
- {
- $liked_POSTS = $meta_POSTS;
- }
- if( !is_array($liked_POSTS) )
- {
- $liked_POSTS = array( );
- }
- if( count($meta_USERS) != 0 )
- {
- $liked_USERS = $meta_USERS[0];
- }
- if( !is_array($liked_USERS) )
- {
- $liked_USERS = array( );
- }
- $liked_POSTS["post-" . $post_id] = $post_id;
- $liked_USERS["user-" . $user_id] = $user_id;
- $user_likes = count($liked_POSTS);
- if( !AlreadyLiked($post_id) )
- {
- update_post_meta($post_id, "_user_liked", $liked_USERS);
- update_post_meta($post_id, "_post_like_count", ++$post_like_count);
- update_user_option($user_id, "_liked_posts", $liked_POSTS);
- update_user_option($user_id, "_user_like_count", $user_likes);
- echo $post_like_count;
- }
- else
- {
- $pid_key = array_search($post_id, $liked_POSTS);
- $uid_key = array_search($user_id, $liked_USERS);
- unset($liked_POSTS[$pid_key]);
- unset($liked_USERS[$uid_key]);
- $user_likes = count($liked_POSTS);
- update_post_meta($post_id, "_user_liked", $liked_USERS);
- update_post_meta($post_id, "_post_like_count", --$post_like_count);
- update_user_option($user_id, "_liked_posts", $liked_POSTS);
- update_user_option($user_id, "_user_like_count", $user_likes);
- echo "already" . $post_like_count;
- }
- }
- else
- {
- $ip = $_SERVER["REMOTE_ADDR"];
- $meta_IPS = get_post_meta($post_id, "_user_IP");
- $liked_IPS = NULL;
- if( count($meta_IPS) != 0 )
- {
- $liked_IPS = $meta_IPS[0];
- }
- if( !is_array($liked_IPS) )
- {
- $liked_IPS = array( );
- }
- if( !in_array($ip, $liked_IPS) )
- {
- $liked_IPS["ip-" . $ip] = $ip;
- }
- if( !AlreadyLiked($post_id) )
- {
- update_post_meta($post_id, "_user_IP", $liked_IPS);
- update_post_meta($post_id, "_post_like_count", ++$post_like_count);
- echo $post_like_count;
- }
- else
- {
- $ip_key = array_search($ip, $liked_IPS);
- unset($liked_IPS[$ip_key]);
- update_post_meta($post_id, "_user_IP", $liked_IPS);
- update_post_meta($post_id, "_post_like_count", --$post_like_count);
- echo "already" . $post_like_count;
- }
- }
- }
- exit();
- }
- /**
- * (3) Test if user already liked post
- */
- function AlreadyLiked($post_id)
- {
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_USERS = get_post_meta($post_id, "_user_liked");
- $liked_USERS = "";
- if( count($meta_USERS) != 0 )
- {
- $liked_USERS = $meta_USERS[0];
- }
- if( !is_array($liked_USERS) )
- {
- $liked_USERS = array( );
- }
- if( in_array($user_id, $liked_USERS) )
- {
- return true;
- }
- return false;
- }
- $meta_IPS = get_post_meta($post_id, "_user_IP");
- $ip = $_SERVER["REMOTE_ADDR"];
- $liked_IPS = "";
- if( count($meta_IPS) != 0 )
- {
- $liked_IPS = $meta_IPS[0];
- }
- if( !is_array($liked_IPS) )
- {
- $liked_IPS = array( );
- }
- if( in_array($ip, $liked_IPS) )
- {
- return true;
- }
- return false;
- }
- /**
- * (4) Front end button
- */
- function getPostLikeLink($post_id)
- {
- $like_count = get_post_meta($post_id, "_post_like_count", true);
- $count = (empty($like_count) || $like_count == "0" ? "0" : esc_attr($like_count));
- if( alreadyliked($post_id) )
- {
- $class = esc_attr(" liked");
- $islem_style = "<style type=\"text/css\">.a" . $post_id . ">.jm-post-spectacular,.a" . $post_id . ">.jm-post-unbelievable,.a" . $post_id . ">.jm-post-happy,.a" . $post_id . ">.jm-post-sad,.a" . $post_id . ">.jm-post-angry {pointer-events: none;cursor: default; opacity:0.6;}</style>";
- $title = esc_attr("Oyunu geri al");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><path d=\"m31.8 27.1c0 0-4.4.9-.8-6.6 2.6-5.4 2.3-11.7 0-15-3.8-5.3-11.1-3.6-10.3-.5 2.6 10.5-3.3 13.7-6.3 20.3-3.1 6.7-2.8 16.3-1.4 24.8.9 5.3 3.2 11.9 11.5 11.9h11.5l-4.2-34.9\" fill=\"#ffdd67\"/><path d=\"m25.8 60.5c-8.3 0-10.1-6.6-11-11.9-1.4-8.5-1.6-15.3 1.1-22.2 3-7.5 6.1-7.7 6.1-22.5 0-.7.4-1.2.8-1.6-1.4.5-2.2 1.3-2.2 2.5 0 11.1-3.1 13.8-6.1 20.5-3.2 6.7-2.9 16.3-1.5 24.8.9 5.3 3.2 11.9 11.5 11.9h11.5v-1.5h-10.2\" fill=\"#eba352\"/><path d=\"m46 35.8h-14.2c-5 0-5-8.7 0-8.7h14.2c5 0 5 8.7 0 8.7\" fill=\"#ffdd67\"/><path d=\"m47.1 34.4h-14.2c-3.4 0-4.4-4-3.3-6.5-2.7 2.1-1.9 8 2.1 8h14.3c1.6 0 2.7-.9 3.3-2.2-.6.4-1.3.7-2.2.7\" fill=\"#eba352\"/><path d=\"m47.5 44.6h-17c-6 0-6-8.7 0-8.7h17.1c5.9 0 5.9 8.7-.1 8.7\" fill=\"#ffdd67\"/><path d=\"m48.9 43.1h-17.1c-4 0-5.3-4-3.9-6.5-3.2 2.1-2.3 8 2.6 8h17.1c1.9 0 3.2-.9 3.9-2.2-.7.4-1.6.7-2.6.7\" fill=\"#eba352\"/><path d=\"m45.9 53.3h-14.4c-5 0-5-8.7 0-8.7h14.4c5.1 0 5.1 8.7 0 8.7\" fill=\"#ffdd67\"/><path d=\"m47.1 51.8h-14.5c-3.4 0-4.5-4-3.3-6.6-2.7 2.1-2 8 2.2 8h14.4c1.6 0 2.7-.9 3.3-2.2-.5.6-1.3.8-2.1.8\" fill=\"#eba352\"/><path d=\"m44.4 62h-9.3c-5.4 0-5.4-8.7 0-8.7h9.3c5.4 0 5.4 8.7 0 8.7\" fill=\"#ffdd67\"/><path d=\"m45.6 60.6h-9.3c-3.6 0-4.8-4-3.5-6.6-2.9 2.1-2.1 8 2.3 8h9.3c1.8 0 2.9-.9 3.5-2.2-.6.5-1.4.8-2.3.8\" fill=\"#eba352\"/></svg>";
- }
- else
- {
- $class = esc_attr("");
- $islem_style = "";
- $title = esc_attr("Beğen");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><path d=\"m31.8 27.1c0 0-4.4.9-.8-6.6 2.6-5.4 2.3-11.7 0-15-3.8-5.3-11.1-3.6-10.3-.5 2.6 10.5-3.3 13.7-6.3 20.3-3.1 6.7-2.8 16.3-1.4 24.8.9 5.3 3.2 11.9 11.5 11.9h11.5l-4.2-34.9\" fill=\"#ffdd67\"/><path d=\"m25.8 60.5c-8.3 0-10.1-6.6-11-11.9-1.4-8.5-1.6-15.3 1.1-22.2 3-7.5 6.1-7.7 6.1-22.5 0-.7.4-1.2.8-1.6-1.4.5-2.2 1.3-2.2 2.5 0 11.1-3.1 13.8-6.1 20.5-3.2 6.7-2.9 16.3-1.5 24.8.9 5.3 3.2 11.9 11.5 11.9h11.5v-1.5h-10.2\" fill=\"#eba352\"/><path d=\"m46 35.8h-14.2c-5 0-5-8.7 0-8.7h14.2c5 0 5 8.7 0 8.7\" fill=\"#ffdd67\"/><path d=\"m47.1 34.4h-14.2c-3.4 0-4.4-4-3.3-6.5-2.7 2.1-1.9 8 2.1 8h14.3c1.6 0 2.7-.9 3.3-2.2-.6.4-1.3.7-2.2.7\" fill=\"#eba352\"/><path d=\"m47.5 44.6h-17c-6 0-6-8.7 0-8.7h17.1c5.9 0 5.9 8.7-.1 8.7\" fill=\"#ffdd67\"/><path d=\"m48.9 43.1h-17.1c-4 0-5.3-4-3.9-6.5-3.2 2.1-2.3 8 2.6 8h17.1c1.9 0 3.2-.9 3.9-2.2-.7.4-1.6.7-2.6.7\" fill=\"#eba352\"/><path d=\"m45.9 53.3h-14.4c-5 0-5-8.7 0-8.7h14.4c5.1 0 5.1 8.7 0 8.7\" fill=\"#ffdd67\"/><path d=\"m47.1 51.8h-14.5c-3.4 0-4.5-4-3.3-6.6-2.7 2.1-2 8 2.2 8h14.4c1.6 0 2.7-.9 3.3-2.2-.5.6-1.3.8-2.1.8\" fill=\"#eba352\"/><path d=\"m44.4 62h-9.3c-5.4 0-5.4-8.7 0-8.7h9.3c5.4 0 5.4 8.7 0 8.7\" fill=\"#ffdd67\"/><path d=\"m45.6 60.6h-9.3c-3.6 0-4.8-4-3.5-6.6-2.9 2.1-2.1 8 2.3 8h9.3c1.8 0 2.9-.9 3.5-2.2-.6.5-1.4.8-2.3.8\" fill=\"#eba352\"/></svg>";
- }
- $output = "<a href=\"#\" class=\"jm-post-like" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
- return $output;
- }
- /**
- * (5) Retrieve User Likes and Show on Profile
- */
- function show_user_likes($user)
- {
- echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_likes\">";
- _e("Beğeni:");
- echo "</label></th>\r\n\t\t\t<td>\r\n ";
- $user_likes = get_user_option("_liked_posts", $user->ID);
- if( !empty($user_likes) && 0 < count($user_likes) )
- {
- $the_likes = $user_likes;
- }
- else
- {
- $the_likes = "";
- }
- if( !is_array($the_likes) )
- {
- $the_likes = array( );
- }
- $count = count($the_likes);
- $i = 0;
- if( 0 < $count )
- {
- $like_list = "";
- echo "<p>\n";
- foreach( $the_likes as $the_like )
- {
- $i++;
- $like_list .= "<a href=\"" . esc_url(get_permalink($the_like)) . "\" title=\"" . esc_attr(get_the_title($the_like)) . "\">" . get_the_title($the_like) . "</a>\n";
- if( $count != $i )
- {
- $like_list .= " · ";
- }
- else
- {
- $like_list .= "</p>\n";
- }
- }
- echo $like_list;
- }
- else
- {
- echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
- }
- echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
- }
- /**
- * (6) Add a shortcode to your posts instead
- * type [jmliker] in your post to output the button
- */
- function jm_like_shortcode()
- {
- return getpostlikelink(get_the_ID());
- }
- /**
- * (7) If the user is logged in, output a list of posts that the user likes
- * Markup assumes sidebar/widget usage
- */
- function frontEndUserLikes()
- {
- if( is_user_logged_in() )
- {
- $like_list = "";
- $user_id = get_current_user_id();
- $user_likes = get_user_option("_liked_posts", $user_id);
- if( !empty($user_likes) && 0 < count($user_likes) )
- {
- $the_likes = $user_likes;
- }
- else
- {
- $the_likes = "";
- }
- if( !is_array($the_likes) )
- {
- $the_likes = array( );
- }
- $count = count($the_likes);
- if( 0 < $count )
- {
- $limited_likes = array_slice($the_likes, 0, 5);
- $like_list .= "<aside>\n";
- $like_list .= "<h3>" . __("Beğeni :") . "</h3>\n";
- $like_list .= "<ul>\n";
- foreach( $limited_likes as $the_like )
- {
- $like_list .= "<li><a href='" . esc_url(get_permalink($the_like)) . "' title='" . esc_attr(get_the_title($the_like)) . "'>" . get_the_title($the_like) . "</a></li>\n";
- }
- $like_list .= "</ul>\n";
- $like_list .= "</aside>\n";
- }
- echo $like_list;
- }
- }
- /**
- * (2) Save happy data
- */
- function jm_post_happy()
- {
- $nonce = $_POST["nonce"];
- if( !wp_verify_nonce($nonce, "ajax-nonce") )
- {
- exit( "Hata Oluştu!" );
- }
- if( isset($_POST["jm_post_happy"]) )
- {
- $post_id = $_POST["post_id"];
- $post_happy_count = get_post_meta($post_id, "_post_happy_count", true);
- if( function_exists("wp_cache_post_change") )
- {
- $GLOBALS["super_cache_enabled"] = 1;
- wp_cache_post_change($post_id);
- }
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_POSTS = get_user_option("_happied_posts", $user_id);
- $meta_USERS = get_post_meta($post_id, "_user_happied");
- $happyd_POSTS = NULL;
- $happyd_USERS = NULL;
- if( count($meta_POSTS) != 0 )
- {
- $happyd_POSTS = $meta_POSTS;
- }
- if( !is_array($happyd_POSTS) )
- {
- $happyd_POSTS = array( );
- }
- if( count($meta_USERS) != 0 )
- {
- $happyd_USERS = $meta_USERS[0];
- }
- if( !is_array($happyd_USERS) )
- {
- $happyd_USERS = array( );
- }
- $happyd_POSTS["post-" . $post_id] = $post_id;
- $happyd_USERS["user-" . $user_id] = $user_id;
- $user_happys = count($happyd_POSTS);
- if( !AlreadyHappied($post_id) )
- {
- update_post_meta($post_id, "_user_happied", $happyd_USERS);
- update_post_meta($post_id, "_post_happy_count", ++$post_happy_count);
- update_user_option($user_id, "_happied_posts", $happyd_POSTS);
- update_user_option($user_id, "_user_happy_count", $user_happys);
- echo $post_happy_count;
- }
- else
- {
- $pid_key = array_search($post_id, $happyd_POSTS);
- $uid_key = array_search($user_id, $happyd_USERS);
- unset($happyd_POSTS[$pid_key]);
- unset($happyd_USERS[$uid_key]);
- $user_happys = count($happyd_POSTS);
- update_post_meta($post_id, "_user_happied", $happyd_USERS);
- update_post_meta($post_id, "_post_happy_count", --$post_happy_count);
- update_user_option($user_id, "_happied_posts", $happyd_POSTS);
- update_user_option($user_id, "_user_happy_count", $user_happys);
- echo "already_happy" . $post_happy_count;
- }
- }
- else
- {
- $ip = $_SERVER["REMOTE_ADDR"];
- $meta_IPS = get_post_meta($post_id, "_user_IP_happy");
- $happyd_IPS = NULL;
- if( count($meta_IPS) != 0 )
- {
- $happyd_IPS = $meta_IPS[0];
- }
- if( !is_array($happyd_IPS) )
- {
- $happyd_IPS = array( );
- }
- if( !in_array($ip, $happyd_IPS) )
- {
- $happyd_IPS["ip-" . $ip] = $ip;
- }
- if( !AlreadyHappied($post_id) )
- {
- update_post_meta($post_id, "_user_IP_happy", $happyd_IPS);
- update_post_meta($post_id, "_post_happy_count", ++$post_happy_count);
- echo $post_happy_count;
- }
- else
- {
- $ip_key = array_search($ip, $happyd_IPS);
- unset($happyd_IPS[$ip_key]);
- update_post_meta($post_id, "_user_IP_happy", $happyd_IPS);
- update_post_meta($post_id, "_post_happy_count", --$post_happy_count);
- echo "already_happy" . $post_happy_count;
- }
- }
- }
- exit();
- }
- /**
- * (3) Test if user already happyd post
- */
- function AlreadyHappied($post_id)
- {
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_USERS = get_post_meta($post_id, "_user_happied");
- $happyd_USERS = "";
- if( count($meta_USERS) != 0 )
- {
- $happyd_USERS = $meta_USERS[0];
- }
- if( !is_array($happyd_USERS) )
- {
- $happyd_USERS = array( );
- }
- if( in_array($user_id, $happyd_USERS) )
- {
- return true;
- }
- return false;
- }
- $meta_IPS = get_post_meta($post_id, "_user_IP_happy");
- $ip = $_SERVER["REMOTE_ADDR"];
- $happyd_IPS = "";
- if( count($meta_IPS) != 0 )
- {
- $happyd_IPS = $meta_IPS[0];
- }
- if( !is_array($happyd_IPS) )
- {
- $happyd_IPS = array( );
- }
- if( in_array($ip, $happyd_IPS) )
- {
- return true;
- }
- return false;
- }
- /**
- * (4) Front end button
- */
- function getPostHappyLink($post_id)
- {
- $happy_count = get_post_meta($post_id, "_post_happy_count", true);
- $count = (empty($happy_count) || $happy_count == "0" ? "0" : esc_attr($happy_count));
- if( alreadyhappied($post_id) )
- {
- $class = esc_attr(" happy");
- $islem_style = "<style type=\"text/css\">.a" . $post_id . ">.jm-post-spectacular,.a" . $post_id . ">.jm-post-unbelievable,.a" . $post_id . ">.jm-post-like,.a" . $post_id . ">.jm-post-sad,.a" . $post_id . ">.jm-post-angry {pointer-events: none;cursor: default; opacity:0.6;}</style>";
- $title = esc_attr("Oyu geri al");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"#ffdd67\"/><path d=\"m49.7 34.4c-.4-.5-1.1-.4-1.9-.4-15.8 0-15.8 0-31.6 0-.8 0-1.5-.1-1.9.4-3.9 5 .7 19.6 17.7 19.6 17 0 21.6-14.6 17.7-19.6\" fill=\"#664e27\"/><path d=\"m33.8 41.7c-.6 0-1.5.5-1.1 2 .2.7 1.2 1.6 1.2 2.8 0 2.4-3.8 2.4-3.8 0 0-1.2 1-2 1.2-2.8.3-1.4-.6-2-1.1-2-1.6 0-4.1 1.7-4.1 4.6 0 3.2 2.7 5.8 6 5.8 3.3 0 6-2.6 6-5.8-.1-2.8-2.7-4.5-4.3-4.6\" fill=\"#4c3526\"/><path d=\"m24.3 50.7c2.2 1 4.8 1.5 7.7 1.5 2.9 0 5.5-.6 7.7-1.5-2.1-1.1-4.7-1.7-7.7-1.7s-5.6.6-7.7 1.7\" fill=\"#ff717f\"/><path d=\"m47 36c-15 0-15 0-29.9 0-2.1 0-2.1 4-.1 4 10.4 0 19.6 0 30 0 2 0 2-4 0-4\" fill=\"#fff\"/><g fill=\"#65b1ef\"><path d=\"m59.4 36.9c7.3 7.7-2.6 18.1-9.9 10.4-5.3-5.6-5.6-16.3-5.6-16.3s10.2.3 15.5 5.9\"/><path d=\"m14.5 47.3c-7.3 7.7-17.2-2.7-9.9-10.4 5.3-5.6 15.5-5.9 15.5-5.9s-.3 10.7-5.6 16.3\"/></g><g fill=\"#664e27\"><path d=\"m28.5 28.7c-1.9-5.1-4.7-7.7-7.5-7.7s-5.6 2.6-7.5 7.7c-.2.5.8 1.4 1.3.9 1.8-1.9 4-2.7 6.2-2.7 2.2 0 4.4.8 6.2 2.7.6.5 1.5-.4 1.3-.9\"/><path d=\"m50.4 28.7c-1.9-5.1-4.7-7.7-7.5-7.7s-5.6 2.6-7.5 7.7c-.2.5.8 1.4 1.3.9 1.8-1.9 4-2.7 6.2-2.7s4.4.8 6.2 2.7c.5.5 1.5-.4 1.3-.9\"/></g></svg>";
- }
- else
- {
- $class = esc_attr("");
- $islem_style = "";
- $title = esc_attr("Sevin");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"#ffdd67\"/><path d=\"m49.7 34.4c-.4-.5-1.1-.4-1.9-.4-15.8 0-15.8 0-31.6 0-.8 0-1.5-.1-1.9.4-3.9 5 .7 19.6 17.7 19.6 17 0 21.6-14.6 17.7-19.6\" fill=\"#664e27\"/><path d=\"m33.8 41.7c-.6 0-1.5.5-1.1 2 .2.7 1.2 1.6 1.2 2.8 0 2.4-3.8 2.4-3.8 0 0-1.2 1-2 1.2-2.8.3-1.4-.6-2-1.1-2-1.6 0-4.1 1.7-4.1 4.6 0 3.2 2.7 5.8 6 5.8 3.3 0 6-2.6 6-5.8-.1-2.8-2.7-4.5-4.3-4.6\" fill=\"#4c3526\"/><path d=\"m24.3 50.7c2.2 1 4.8 1.5 7.7 1.5 2.9 0 5.5-.6 7.7-1.5-2.1-1.1-4.7-1.7-7.7-1.7s-5.6.6-7.7 1.7\" fill=\"#ff717f\"/><path d=\"m47 36c-15 0-15 0-29.9 0-2.1 0-2.1 4-.1 4 10.4 0 19.6 0 30 0 2 0 2-4 0-4\" fill=\"#fff\"/><g fill=\"#65b1ef\"><path d=\"m59.4 36.9c7.3 7.7-2.6 18.1-9.9 10.4-5.3-5.6-5.6-16.3-5.6-16.3s10.2.3 15.5 5.9\"/><path d=\"m14.5 47.3c-7.3 7.7-17.2-2.7-9.9-10.4 5.3-5.6 15.5-5.9 15.5-5.9s-.3 10.7-5.6 16.3\"/></g><g fill=\"#664e27\"><path d=\"m28.5 28.7c-1.9-5.1-4.7-7.7-7.5-7.7s-5.6 2.6-7.5 7.7c-.2.5.8 1.4 1.3.9 1.8-1.9 4-2.7 6.2-2.7 2.2 0 4.4.8 6.2 2.7.6.5 1.5-.4 1.3-.9\"/><path d=\"m50.4 28.7c-1.9-5.1-4.7-7.7-7.5-7.7s-5.6 2.6-7.5 7.7c-.2.5.8 1.4 1.3.9 1.8-1.9 4-2.7 6.2-2.7s4.4.8 6.2 2.7c.5.5 1.5-.4 1.3-.9\"/></g></svg>";
- }
- $output = "<a href=\"#\" class=\"jm-post-happy" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
- return $output;
- }
- /**
- * (5) Retrieve User happys and Show on Profile
- */
- function show_user_happies($user)
- {
- echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_happys\">";
- _e("Mutlu:");
- echo "</label></th>\r\n\t\t\t<td>\r\n ";
- $user_happys = get_user_option("_happied_posts", $user->ID);
- if( !empty($user_happys) && 0 < count($user_happys) )
- {
- $the_happys = $user_happys;
- }
- else
- {
- $the_happys = "";
- }
- if( !is_array($the_happys) )
- {
- $the_happys = array( );
- }
- $count = count($the_happys);
- $i = 0;
- if( 0 < $count )
- {
- $happy_list = "";
- echo "<p>\n";
- foreach( $the_happys as $the_happy )
- {
- $i++;
- $happy_list .= "<a href=\"" . esc_url(get_permalink($the_happy)) . "\" title=\"" . esc_attr(get_the_title($the_happy)) . "\">" . get_the_title($the_happy) . "</a>\n";
- if( $count != $i )
- {
- $happy_list .= " · ";
- }
- else
- {
- $happy_list .= "</p>\n";
- }
- }
- echo $happy_list;
- }
- else
- {
- echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
- }
- echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
- }
- /**
- * (6) Add a shortcode to your posts instead
- * type [jmhappyr] in your post to output the button
- */
- function jm_happy_shortcode()
- {
- return getposthappylink(get_the_ID());
- }
- /**
- * (7) If the user is logged in, output a list of posts that the user happys
- * Markup assumes sidebar/widget usage
- */
- function frontEndUserHappies()
- {
- if( is_user_logged_in() )
- {
- $happy_list = "";
- $user_id = get_current_user_id();
- $user_happys = get_user_option("_happied_posts", $user_id);
- if( !empty($user_happys) && 0 < count($user_happys) )
- {
- $the_happys = $user_happys;
- }
- else
- {
- $the_happys = "";
- }
- if( !is_array($the_happys) )
- {
- $the_happys = array( );
- }
- $count = count($the_happys);
- if( 0 < $count )
- {
- $limited_happys = array_slice($the_happys, 0, 5);
- $happy_list .= "<aside>\n";
- $happy_list .= "<h3>" . __("Mutlu :") . "</h3>\n";
- $happy_list .= "<ul>\n";
- foreach( $limited_happys as $the_happy )
- {
- $happy_list .= "<li><a href='" . esc_url(get_permalink($the_happy)) . "' title='" . esc_attr(get_the_title($the_happy)) . "'>" . get_the_title($the_happy) . "</a></li>\n";
- }
- $happy_list .= "</ul>\n";
- $happy_list .= "</aside>\n";
- }
- echo $happy_list;
- }
- }
- /**
- * (2) Save unbelievable data
- */
- function jm_post_unbelievable()
- {
- $nonce = $_POST["nonce"];
- if( !wp_verify_nonce($nonce, "ajax-nonce") )
- {
- exit( "Hata Oluştu!" );
- }
- if( isset($_POST["jm_post_unbelievable"]) )
- {
- $post_id = $_POST["post_id"];
- $post_unbelievable_count = get_post_meta($post_id, "_post_unbelievable_count", true);
- if( function_exists("wp_cache_post_change") )
- {
- $GLOBALS["super_cache_enabled"] = 1;
- wp_cache_post_change($post_id);
- }
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_POSTS = get_user_option("_unbelievabled_posts", $user_id);
- $meta_USERS = get_post_meta($post_id, "_user_unbelievabled");
- $unbelievabled_POSTS = NULL;
- $unbelievabled_USERS = NULL;
- if( count($meta_POSTS) != 0 )
- {
- $unbelievabled_POSTS = $meta_POSTS;
- }
- if( !is_array($unbelievabled_POSTS) )
- {
- $unbelievabled_POSTS = array( );
- }
- if( count($meta_USERS) != 0 )
- {
- $unbelievabled_USERS = $meta_USERS[0];
- }
- if( !is_array($unbelievabled_USERS) )
- {
- $unbelievabled_USERS = array( );
- }
- $unbelievabled_POSTS["post-" . $post_id] = $post_id;
- $unbelievabled_USERS["user-" . $user_id] = $user_id;
- $user_unbelievables = count($unbelievabled_POSTS);
- if( !Alreadyunbelievabled($post_id) )
- {
- update_post_meta($post_id, "_user_unbelievabled", $unbelievabled_USERS);
- update_post_meta($post_id, "_post_unbelievable_count", ++$post_unbelievable_count);
- update_user_option($user_id, "_unbelievabled_posts", $unbelievabled_POSTS);
- update_user_option($user_id, "_user_unbelievable_count", $user_unbelievables);
- echo $post_unbelievable_count;
- }
- else
- {
- $pid_key = array_search($post_id, $unbelievabled_POSTS);
- $uid_key = array_search($user_id, $unbelievabled_USERS);
- unset($unbelievabled_POSTS[$pid_key]);
- unset($unbelievabled_USERS[$uid_key]);
- $user_unbelievables = count($unbelievabled_POSTS);
- update_post_meta($post_id, "_user_unbelievabled", $unbelievabled_USERS);
- update_post_meta($post_id, "_post_unbelievable_count", --$post_unbelievable_count);
- update_user_option($user_id, "_unbelievabled_posts", $unbelievabled_POSTS);
- update_user_option($user_id, "_user_unbelievable_count", $user_unbelievables);
- echo "already_unbelievable" . $post_unbelievable_count;
- }
- }
- else
- {
- $ip = $_SERVER["REMOTE_ADDR"];
- $meta_IPS = get_post_meta($post_id, "_user_IP_unbelievable");
- $unbelievabled_IPS = NULL;
- if( count($meta_IPS) != 0 )
- {
- $unbelievabled_IPS = $meta_IPS[0];
- }
- if( !is_array($unbelievabled_IPS) )
- {
- $unbelievabled_IPS = array( );
- }
- if( !in_array($ip, $unbelievabled_IPS) )
- {
- $unbelievabled_IPS["ip-" . $ip] = $ip;
- }
- if( !Alreadyunbelievabled($post_id) )
- {
- update_post_meta($post_id, "_user_IP_unbelievable", $unbelievabled_IPS);
- update_post_meta($post_id, "_post_unbelievable_count", ++$post_unbelievable_count);
- echo $post_unbelievable_count;
- }
- else
- {
- $ip_key = array_search($ip, $unbelievabled_IPS);
- unset($unbelievabled_IPS[$ip_key]);
- update_post_meta($post_id, "_user_IP_unbelievable", $unbelievabled_IPS);
- update_post_meta($post_id, "_post_unbelievable_count", --$post_unbelievable_count);
- echo "already_unbelievable" . $post_unbelievable_count;
- }
- }
- }
- exit();
- }
- /**
- * (3) Test if user already unbelievabled post
- */
- function Alreadyunbelievabled($post_id)
- {
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_USERS = get_post_meta($post_id, "_user_unbelievabled");
- $unbelievabled_USERS = "";
- if( count($meta_USERS) != 0 )
- {
- $unbelievabled_USERS = $meta_USERS[0];
- }
- if( !is_array($unbelievabled_USERS) )
- {
- $unbelievabled_USERS = array( );
- }
- if( in_array($user_id, $unbelievabled_USERS) )
- {
- return true;
- }
- return false;
- }
- $meta_IPS = get_post_meta($post_id, "_user_IP_unbelievable");
- $ip = $_SERVER["REMOTE_ADDR"];
- $unbelievabled_IPS = "";
- if( count($meta_IPS) != 0 )
- {
- $unbelievabled_IPS = $meta_IPS[0];
- }
- if( !is_array($unbelievabled_IPS) )
- {
- $unbelievabled_IPS = array( );
- }
- if( in_array($ip, $unbelievabled_IPS) )
- {
- return true;
- }
- return false;
- }
- /**
- * (4) Front end button
- */
- function getPostunbelievableLink($post_id)
- {
- $unbelievable_count = get_post_meta($post_id, "_post_unbelievable_count", true);
- $count = (empty($unbelievable_count) || $unbelievable_count == "0" ? "0" : esc_attr($unbelievable_count));
- if( alreadyunbelievabled($post_id) )
- {
- $class = esc_attr(" unbelievable");
- $islem_style = "<style type=\"text/css\">.a" . $post_id . ">.jm-post-spectacular,.a" . $post_id . ">.jm-post-like,.a" . $post_id . ">.jm-post-happy,.a" . $post_id . ">.jm-post-sad,.a" . $post_id . ">.jm-post-angry {pointer-events: none;cursor: default; opacity:0.6;}</style>";
- $title = esc_attr("Oyu geri al");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"#ffdd67\"/><g fill=\"#664e27\"><circle cx=\"32\" cy=\"45.1\" r=\"7\"/><circle cx=\"20.2\" cy=\"25\" r=\"4.5\"/><circle cx=\"42.7\" cy=\"25\" r=\"4.5\"/></g></svg>";
- }
- else
- {
- $class = esc_attr("");
- $islem_style = "";
- $title = esc_attr("Şaşır");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"#ffdd67\"/><g fill=\"#664e27\"><circle cx=\"32\" cy=\"45.1\" r=\"7\"/><circle cx=\"20.2\" cy=\"25\" r=\"4.5\"/><circle cx=\"42.7\" cy=\"25\" r=\"4.5\"/></g></svg>";
- }
- $output = "<a href=\"#\" class=\"jm-post-unbelievable" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
- return $output;
- }
- /**
- * (5) Retrieve User unbelievables and Show on Profile
- */
- function show_user_unbelievables($user)
- {
- echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_unbelievables\">";
- _e("Şaşırma:");
- echo "</label></th>\r\n\t\t\t<td>\r\n ";
- $user_unbelievables = get_user_option("_unbelievabled_posts", $user->ID);
- if( !empty($user_unbelievables) && 0 < count($user_unbelievables) )
- {
- $the_unbelievables = $user_unbelievables;
- }
- else
- {
- $the_unbelievables = "";
- }
- if( !is_array($the_unbelievables) )
- {
- $the_unbelievables = array( );
- }
- $count = count($the_unbelievables);
- $i = 0;
- if( 0 < $count )
- {
- $unbelievable_list = "";
- echo "<p>\n";
- foreach( $the_unbelievables as $the_unbelievable )
- {
- $i++;
- $unbelievable_list .= "<a href=\"" . esc_url(get_permalink($the_unbelievable)) . "\" title=\"" . esc_attr(get_the_title($the_unbelievable)) . "\">" . get_the_title($the_unbelievable) . "</a>\n";
- if( $count != $i )
- {
- $unbelievable_list .= " · ";
- }
- else
- {
- $unbelievable_list .= "</p>\n";
- }
- }
- echo $unbelievable_list;
- }
- else
- {
- echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
- }
- echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
- }
- /**
- * (6) Add a shortcode to your posts instead
- * type [jmunbelievabler] in your post to output the button
- */
- function jm_unbelievable_shortcode()
- {
- return getpostunbelievablelink(get_the_ID());
- }
- /**
- * (7) If the user is logged in, output a list of posts that the user unbelievables
- * Markup assumes sidebar/widget usage
- */
- function frontEndUserunbelievables()
- {
- if( is_user_logged_in() )
- {
- $unbelievable_list = "";
- $user_id = get_current_user_id();
- $user_unbelievables = get_user_option("_unbelievabled_posts", $user_id);
- if( !empty($user_unbelievables) && 0 < count($user_unbelievables) )
- {
- $the_unbelievables = $user_unbelievables;
- }
- else
- {
- $the_unbelievables = "";
- }
- if( !is_array($the_unbelievables) )
- {
- $the_unbelievables = array( );
- }
- $count = count($the_unbelievables);
- if( 0 < $count )
- {
- $limited_unbelievables = array_slice($the_unbelievables, 0, 5);
- $unbelievable_list .= "<aside>\n";
- $unbelievable_list .= "<h3>" . __("Şaşırmak :") . "</h3>\n";
- $unbelievable_list .= "<ul>\n";
- foreach( $limited_unbelievables as $the_unbelievable )
- {
- $unbelievable_list .= "<li><a href='" . esc_url(get_permalink($the_unbelievable)) . "' title='" . esc_attr(get_the_title($the_unbelievable)) . "'>" . get_the_title($the_unbelievable) . "</a></li>\n";
- }
- $unbelievable_list .= "</ul>\n";
- $unbelievable_list .= "</aside>\n";
- }
- echo $unbelievable_list;
- }
- }
- /**
- * (2) Save spectacular data
- */
- function jm_post_spectacular()
- {
- $nonce = $_POST["nonce"];
- if( !wp_verify_nonce($nonce, "ajax-nonce") )
- {
- exit( "Hata Oluştu!" );
- }
- if( isset($_POST["jm_post_spectacular"]) )
- {
- $post_id = $_POST["post_id"];
- $post_spectacular_count = get_post_meta($post_id, "_post_spectacular_count", true);
- if( function_exists("wp_cache_post_change") )
- {
- $GLOBALS["super_cache_enabled"] = 1;
- wp_cache_post_change($post_id);
- }
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_POSTS = get_user_option("_spectaculared_posts", $user_id);
- $meta_USERS = get_post_meta($post_id, "_user_spectaculared");
- $spectaculard_POSTS = NULL;
- $spectaculard_USERS = NULL;
- if( count($meta_POSTS) != 0 )
- {
- $spectaculard_POSTS = $meta_POSTS;
- }
- if( !is_array($spectaculard_POSTS) )
- {
- $spectaculard_POSTS = array( );
- }
- if( count($meta_USERS) != 0 )
- {
- $spectaculard_USERS = $meta_USERS[0];
- }
- if( !is_array($spectaculard_USERS) )
- {
- $spectaculard_USERS = array( );
- }
- $spectaculard_POSTS["post-" . $post_id] = $post_id;
- $spectaculard_USERS["user-" . $user_id] = $user_id;
- $user_spectaculars = count($spectaculard_POSTS);
- if( !Alreadyspectaculared($post_id) )
- {
- update_post_meta($post_id, "_user_spectaculared", $spectaculard_USERS);
- update_post_meta($post_id, "_post_spectacular_count", ++$post_spectacular_count);
- update_user_option($user_id, "_spectaculared_posts", $spectaculard_POSTS);
- update_user_option($user_id, "_user_spectacular_count", $user_spectaculars);
- echo $post_spectacular_count;
- }
- else
- {
- $pid_key = array_search($post_id, $spectaculard_POSTS);
- $uid_key = array_search($user_id, $spectaculard_USERS);
- unset($spectaculard_POSTS[$pid_key]);
- unset($spectaculard_USERS[$uid_key]);
- $user_spectaculars = count($spectaculard_POSTS);
- update_post_meta($post_id, "_user_spectaculared", $spectaculard_USERS);
- update_post_meta($post_id, "_post_spectacular_count", --$post_spectacular_count);
- update_user_option($user_id, "_spectaculared_posts", $spectaculard_POSTS);
- update_user_option($user_id, "_user_spectacular_count", $user_spectaculars);
- echo "already_spectacular" . $post_spectacular_count;
- }
- }
- else
- {
- $ip = $_SERVER["REMOTE_ADDR"];
- $meta_IPS = get_post_meta($post_id, "_user_IP_spectacular");
- $spectaculard_IPS = NULL;
- if( count($meta_IPS) != 0 )
- {
- $spectaculard_IPS = $meta_IPS[0];
- }
- if( !is_array($spectaculard_IPS) )
- {
- $spectaculard_IPS = array( );
- }
- if( !in_array($ip, $spectaculard_IPS) )
- {
- $spectaculard_IPS["ip-" . $ip] = $ip;
- }
- if( !Alreadyspectaculared($post_id) )
- {
- update_post_meta($post_id, "_user_IP_spectacular", $spectaculard_IPS);
- update_post_meta($post_id, "_post_spectacular_count", ++$post_spectacular_count);
- echo $post_spectacular_count;
- }
- else
- {
- $ip_key = array_search($ip, $spectaculard_IPS);
- unset($spectaculard_IPS[$ip_key]);
- update_post_meta($post_id, "_user_IP_spectacular", $spectaculard_IPS);
- update_post_meta($post_id, "_post_spectacular_count", --$post_spectacular_count);
- echo "already_spectacular" . $post_spectacular_count;
- }
- }
- }
- exit();
- }
- /**
- * (3) Test if user already spectaculard post
- */
- function Alreadyspectaculared($post_id)
- {
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_USERS = get_post_meta($post_id, "_user_spectaculared");
- $spectaculard_USERS = "";
- if( count($meta_USERS) != 0 )
- {
- $spectaculard_USERS = $meta_USERS[0];
- }
- if( !is_array($spectaculard_USERS) )
- {
- $spectaculard_USERS = array( );
- }
- if( in_array($user_id, $spectaculard_USERS) )
- {
- return true;
- }
- return false;
- }
- $meta_IPS = get_post_meta($post_id, "_user_IP_spectacular");
- $ip = $_SERVER["REMOTE_ADDR"];
- $spectaculard_IPS = "";
- if( count($meta_IPS) != 0 )
- {
- $spectaculard_IPS = $meta_IPS[0];
- }
- if( !is_array($spectaculard_IPS) )
- {
- $spectaculard_IPS = array( );
- }
- if( in_array($ip, $spectaculard_IPS) )
- {
- return true;
- }
- return false;
- }
- /**
- * (4) Front end button
- */
- function getPostspectacularLink($post_id)
- {
- $spectacular_count = get_post_meta($post_id, "_post_spectacular_count", true);
- $count = (empty($spectacular_count) || $spectacular_count == "0" ? "0" : esc_attr($spectacular_count));
- if( alreadyspectaculared($post_id) )
- {
- $class = esc_attr(" spectacular");
- $islem_style = "<style type=\"text/css\">.a" . $post_id . ">.jm-post-like,.a" . $post_id . ">.jm-post-unbelievable,.a" . $post_id . ">.jm-post-happy,.a" . $post_id . ">.jm-post-sad,.a" . $post_id . ">.jm-post-angry {pointer-events: none;cursor: default; opacity:0.6;}</style>";
- $title = esc_attr("Oyu geri al");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><path d=\"M62,32c0,16.6-13.4,30-30,30C15.4,62,2,48.6,2,32C2,15.4,15.4,2,32,2C48.6,2,62,15.4,62,32z\" fill=\"#ffdd67\"/><g fill=\"#f46767\"><path d=\"m61.8 13.2c-.5-2.7-2-4.9-4.5-5.6-2.7-.7-5.1.3-7.4 2.7-1.3-3.6-3.3-6.3-6.5-7.7-3.2-1.4-6.4-.4-8.4 2.1-2.1 2.6-2.9 6.7-.7 12 2.1 5 11.4 15 11.7 15.3.4-.2 10.8-6.7 13.3-9.9 2.5-3.1 3-6.2 2.5-8.9\"/><path d=\"m29 4.7c-2-2.5-5.2-3.5-8.4-2.1-3.2 1.4-5.2 4.1-6.5 7.7-2.4-2.3-4.8-3.4-7.5-2.6-2.4.7-4 2.9-4.5 5.6-.5 2.6.1 5.8 2.5 8.9 2.6 3.1 13 9.6 13.4 9.8.3-.3 9.6-10.3 11.7-15.3 2.2-5.3 1.4-9.3-.7-12\"/></g><path d=\"m49 38.1c0-.8-.5-1.8-1.8-2.1-3.5-.7-8.6-1.3-15.2-1.3-6.6 0-11.7.7-15.2 1.3-1.4.3-1.8 1.3-1.8 2.1 0 7.3 5.6 14.6 17 14.6 11.4-.1 17-7.4 17-14.6\" fill=\"#664e27\"/><path d=\"m44.7 38.3c-2.2-.4-6.8-1-12.7-1-5.9 0-10.5.6-12.7 1-1.3.2-1.4.7-1.3 1.5.1.4.1 1 .3 1.6.1.6.3.9 1.3.8 1.9-.2 23-.2 24.9 0 1 .1 1.1-.2 1.3-.8.1-.6.2-1.1.3-1.6 0-.8-.1-1.3-1.4-1.5\" fill=\"#fff\"/></svg>";
- }
- else
- {
- $class = esc_attr("");
- $islem_style = "";
- $title = esc_attr("Muhteşem");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><path d=\"M62,32c0,16.6-13.4,30-30,30C15.4,62,2,48.6,2,32C2,15.4,15.4,2,32,2C48.6,2,62,15.4,62,32z\" fill=\"#ffdd67\"/><g fill=\"#f46767\"><path d=\"m61.8 13.2c-.5-2.7-2-4.9-4.5-5.6-2.7-.7-5.1.3-7.4 2.7-1.3-3.6-3.3-6.3-6.5-7.7-3.2-1.4-6.4-.4-8.4 2.1-2.1 2.6-2.9 6.7-.7 12 2.1 5 11.4 15 11.7 15.3.4-.2 10.8-6.7 13.3-9.9 2.5-3.1 3-6.2 2.5-8.9\"/><path d=\"m29 4.7c-2-2.5-5.2-3.5-8.4-2.1-3.2 1.4-5.2 4.1-6.5 7.7-2.4-2.3-4.8-3.4-7.5-2.6-2.4.7-4 2.9-4.5 5.6-.5 2.6.1 5.8 2.5 8.9 2.6 3.1 13 9.6 13.4 9.8.3-.3 9.6-10.3 11.7-15.3 2.2-5.3 1.4-9.3-.7-12\"/></g><path d=\"m49 38.1c0-.8-.5-1.8-1.8-2.1-3.5-.7-8.6-1.3-15.2-1.3-6.6 0-11.7.7-15.2 1.3-1.4.3-1.8 1.3-1.8 2.1 0 7.3 5.6 14.6 17 14.6 11.4-.1 17-7.4 17-14.6\" fill=\"#664e27\"/><path d=\"m44.7 38.3c-2.2-.4-6.8-1-12.7-1-5.9 0-10.5.6-12.7 1-1.3.2-1.4.7-1.3 1.5.1.4.1 1 .3 1.6.1.6.3.9 1.3.8 1.9-.2 23-.2 24.9 0 1 .1 1.1-.2 1.3-.8.1-.6.2-1.1.3-1.6 0-.8-.1-1.3-1.4-1.5\" fill=\"#fff\"/></svg>";
- }
- $output = "<a href=\"#\" class=\"jm-post-spectacular" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
- return $output;
- }
- /**
- * (5) Retrieve User spectaculars and Show on Profile
- */
- function show_user_spectaculares($user)
- {
- echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_spectaculars\">";
- _e("Muhteşem:");
- echo "</label></th>\r\n\t\t\t<td>\r\n ";
- $user_spectaculars = get_user_option("_spectaculared_posts", $user->ID);
- if( !empty($user_spectaculars) && 0 < count($user_spectaculars) )
- {
- $the_spectaculars = $user_spectaculars;
- }
- else
- {
- $the_spectaculars = "";
- }
- if( !is_array($the_spectaculars) )
- {
- $the_spectaculars = array( );
- }
- $count = count($the_spectaculars);
- $i = 0;
- if( 0 < $count )
- {
- $spectacular_list = "";
- echo "<p>\n";
- foreach( $the_spectaculars as $the_spectacular )
- {
- $i++;
- $spectacular_list .= "<a href=\"" . esc_url(get_permalink($the_spectacular)) . "\" title=\"" . esc_attr(get_the_title($the_spectacular)) . "\">" . get_the_title($the_spectacular) . "</a>\n";
- if( $count != $i )
- {
- $spectacular_list .= " · ";
- }
- else
- {
- $spectacular_list .= "</p>\n";
- }
- }
- echo $spectacular_list;
- }
- else
- {
- echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
- }
- echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
- }
- /**
- * (6) Add a shortcode to your posts instead
- * type [jmspectacularr] in your post to output the button
- */
- function jm_spectacular_shortcode()
- {
- return getpostspectacularlink(get_the_ID());
- }
- /**
- * (7) If the user is logged in, output a list of posts that the user spectaculars
- * Markup assumes sidebar/widget usage
- */
- function frontEndUserspectaculares()
- {
- if( is_user_logged_in() )
- {
- $spectacular_list = "";
- $user_id = get_current_user_id();
- $user_spectaculars = get_user_option("_spectaculared_posts", $user_id);
- if( !empty($user_spectaculars) && 0 < count($user_spectaculars) )
- {
- $the_spectaculars = $user_spectaculars;
- }
- else
- {
- $the_spectaculars = "";
- }
- if( !is_array($the_spectaculars) )
- {
- $the_spectaculars = array( );
- }
- $count = count($the_spectaculars);
- if( 0 < $count )
- {
- $limited_spectaculars = array_slice($the_spectaculars, 0, 5);
- $spectacular_list .= "<aside>\n";
- $spectacular_list .= "<h3>" . __("Muhteşem") . "</h3>\n";
- $spectacular_list .= "<ul>\n";
- foreach( $limited_spectaculars as $the_spectacular )
- {
- $spectacular_list .= "<li><a href='" . esc_url(get_permalink($the_spectacular)) . "' title='" . esc_attr(get_the_title($the_spectacular)) . "'>" . get_the_title($the_spectacular) . "</a></li>\n";
- }
- $spectacular_list .= "</ul>\n";
- $spectacular_list .= "</aside>\n";
- }
- echo $spectacular_list;
- }
- }
- /**
- * (2) Save sad data
- */
- function jm_post_sad()
- {
- $nonce = $_POST["nonce"];
- if( !wp_verify_nonce($nonce, "ajax-nonce") )
- {
- exit( "Hata Oluştu!" );
- }
- if( isset($_POST["jm_post_sad"]) )
- {
- $post_id = $_POST["post_id"];
- $post_sad_count = get_post_meta($post_id, "_post_sad_count", true);
- if( function_exists("wp_cache_post_change") )
- {
- $GLOBALS["super_cache_enabled"] = 1;
- wp_cache_post_change($post_id);
- }
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_POSTS = get_user_option("_saded_posts", $user_id);
- $meta_USERS = get_post_meta($post_id, "_user_saded");
- $sadd_POSTS = NULL;
- $sadd_USERS = NULL;
- if( count($meta_POSTS) != 0 )
- {
- $sadd_POSTS = $meta_POSTS;
- }
- if( !is_array($sadd_POSTS) )
- {
- $sadd_POSTS = array( );
- }
- if( count($meta_USERS) != 0 )
- {
- $sadd_USERS = $meta_USERS[0];
- }
- if( !is_array($sadd_USERS) )
- {
- $sadd_USERS = array( );
- }
- $sadd_POSTS["post-" . $post_id] = $post_id;
- $sadd_USERS["user-" . $user_id] = $user_id;
- $user_sads = count($sadd_POSTS);
- if( !Alreadysaded($post_id) )
- {
- update_post_meta($post_id, "_user_saded", $sadd_USERS);
- update_post_meta($post_id, "_post_sad_count", ++$post_sad_count);
- update_user_option($user_id, "_saded_posts", $sadd_POSTS);
- update_user_option($user_id, "_user_sad_count", $user_sads);
- echo $post_sad_count;
- }
- else
- {
- $pid_key = array_search($post_id, $sadd_POSTS);
- $uid_key = array_search($user_id, $sadd_USERS);
- unset($sadd_POSTS[$pid_key]);
- unset($sadd_USERS[$uid_key]);
- $user_sads = count($sadd_POSTS);
- update_post_meta($post_id, "_user_saded", $sadd_USERS);
- update_post_meta($post_id, "_post_sad_count", --$post_sad_count);
- update_user_option($user_id, "_saded_posts", $sadd_POSTS);
- update_user_option($user_id, "_user_sad_count", $user_sads);
- echo "already_sad" . $post_sad_count;
- }
- }
- else
- {
- $ip = $_SERVER["REMOTE_ADDR"];
- $meta_IPS = get_post_meta($post_id, "_user_IP_sad");
- $sadd_IPS = NULL;
- if( count($meta_IPS) != 0 )
- {
- $sadd_IPS = $meta_IPS[0];
- }
- if( !is_array($sadd_IPS) )
- {
- $sadd_IPS = array( );
- }
- if( !in_array($ip, $sadd_IPS) )
- {
- $sadd_IPS["ip-" . $ip] = $ip;
- }
- if( !Alreadysaded($post_id) )
- {
- update_post_meta($post_id, "_user_IP_sad", $sadd_IPS);
- update_post_meta($post_id, "_post_sad_count", ++$post_sad_count);
- echo $post_sad_count;
- }
- else
- {
- $ip_key = array_search($ip, $sadd_IPS);
- unset($sadd_IPS[$ip_key]);
- update_post_meta($post_id, "_user_IP_sad", $sadd_IPS);
- update_post_meta($post_id, "_post_sad_count", --$post_sad_count);
- echo "already_sad" . $post_sad_count;
- }
- }
- }
- exit();
- }
- /**
- * (3) Test if user already sadd post
- */
- function Alreadysaded($post_id)
- {
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_USERS = get_post_meta($post_id, "_user_saded");
- $sadd_USERS = "";
- if( count($meta_USERS) != 0 )
- {
- $sadd_USERS = $meta_USERS[0];
- }
- if( !is_array($sadd_USERS) )
- {
- $sadd_USERS = array( );
- }
- if( in_array($user_id, $sadd_USERS) )
- {
- return true;
- }
- return false;
- }
- $meta_IPS = get_post_meta($post_id, "_user_IP_sad");
- $ip = $_SERVER["REMOTE_ADDR"];
- $sadd_IPS = "";
- if( count($meta_IPS) != 0 )
- {
- $sadd_IPS = $meta_IPS[0];
- }
- if( !is_array($sadd_IPS) )
- {
- $sadd_IPS = array( );
- }
- if( in_array($ip, $sadd_IPS) )
- {
- return true;
- }
- return false;
- }
- /**
- * (4) Front end button
- */
- function getPostsadLink($post_id)
- {
- $sad_count = get_post_meta($post_id, "_post_sad_count", true);
- $count = (empty($sad_count) || $sad_count == "0" ? "0" : esc_attr($sad_count));
- if( alreadysaded($post_id) )
- {
- $class = esc_attr(" sad");
- $islem_style = "<style type=\"text/css\">.a" . $post_id . " .jm-post-spectacular,.a" . $post_id . ">.jm-post-unbelievable,.a" . $post_id . ">.jm-post-happy,.a" . $post_id . ">.jm-post-like,.a" . $post_id . ">.jm-post-angry {pointer-events: none;cursor: default; opacity:0.6;}</style>";
- $title = esc_attr("Oyu geri al");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><g fill=\"#65b1ef\"><ellipse cx=\"17.5\" cy=\"59.9\" rx=\"12.5\" ry=\"1.5\"/><ellipse cx=\"44\" cy=\"60.2\" rx=\"18\" ry=\"1.8\"/></g><circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"#ffdd67\"/><path d=\"m44.7 46c-1.4-3.6-4.8-6-12.7-6-8 0-11.3 2.4-12.7 6-.7 1.9.3 5 .3 5 1.3 3.9 1.1 5 12.4 5 11.3 0 11.1-1.1 12.4-5 0 0 1.1-3.1.3-5\" fill=\"#664e27\"/><path d=\"m41 45c.1-.3 0-.6-.2-.8 0 0-2-2.2-8.8-2.2-6.8 0-8.8 2.2-8.8 2.2-.2.1-.2.5-.2.8l.2.6c.1.3.3.5.5.5h16.6c.2 0 .5-.2.5-.5l.2-.6\" fill=\"#fff\"/><g fill=\"#65b1ef\"><path d=\"m44.5 60.5c2.3 0 4.6 0 6.8 0 8.2-9.9-1.5-20 .9-29.8-2.3 0-4.6 2.5-6.8 2.5-3.2 9.5 7.3 17.4-.9 27.3\"/><path d=\"m19.5 60.5c-2.3 0-4.6 0-6.8 0-8.2-9.9 1.5-20-.9-29.8 2.3 0 4.6 2.5 6.8 2.5 3.2 9.5-7.3 17.4.9 27.3\"/></g><g fill=\"#917524\"><path d=\"m40.7 18.3c3 3 7.2 4.5 11.4 4.1.6-.1.9 2.1.2 2.2-4.9.4-9.7-1.3-13.1-4.8-.6-.5 1.1-1.9 1.5-1.5\"/><path d=\"m12 22.4c4.2.4 8.4-1.1 11.4-4.1.4-.4 2.1 1 1.6 1.5-3.4 3.5-8.3 5.2-13.1 4.8-.9 0-.5-2.2.1-2.2\"/></g><g fill=\"#664e27\"><path d=\"m35.9 30.3c4.2 8 12.7 8 16.9 0 .2-.4-.3-.6-1-1-4.2 3.3-11.1 3-14.9 0-.6.4-1.2.6-1 1\"/><path d=\"m11.2 30.3c4.2 8 12.7 8 16.9 0 .2-.4-.3-.6-1-1-4.2 3.3-11.1 3-14.9 0-.7.4-1.2.6-1 1\"/></g></svg>";
- }
- else
- {
- $class = esc_attr("");
- $islem_style = "";
- $title = esc_attr("Üzül");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><g fill=\"#65b1ef\"><ellipse cx=\"17.5\" cy=\"59.9\" rx=\"12.5\" ry=\"1.5\"/><ellipse cx=\"44\" cy=\"60.2\" rx=\"18\" ry=\"1.8\"/></g><circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"#ffdd67\"/><path d=\"m44.7 46c-1.4-3.6-4.8-6-12.7-6-8 0-11.3 2.4-12.7 6-.7 1.9.3 5 .3 5 1.3 3.9 1.1 5 12.4 5 11.3 0 11.1-1.1 12.4-5 0 0 1.1-3.1.3-5\" fill=\"#664e27\"/><path d=\"m41 45c.1-.3 0-.6-.2-.8 0 0-2-2.2-8.8-2.2-6.8 0-8.8 2.2-8.8 2.2-.2.1-.2.5-.2.8l.2.6c.1.3.3.5.5.5h16.6c.2 0 .5-.2.5-.5l.2-.6\" fill=\"#fff\"/><g fill=\"#65b1ef\"><path d=\"m44.5 60.5c2.3 0 4.6 0 6.8 0 8.2-9.9-1.5-20 .9-29.8-2.3 0-4.6 2.5-6.8 2.5-3.2 9.5 7.3 17.4-.9 27.3\"/><path d=\"m19.5 60.5c-2.3 0-4.6 0-6.8 0-8.2-9.9 1.5-20-.9-29.8 2.3 0 4.6 2.5 6.8 2.5 3.2 9.5-7.3 17.4.9 27.3\"/></g><g fill=\"#917524\"><path d=\"m40.7 18.3c3 3 7.2 4.5 11.4 4.1.6-.1.9 2.1.2 2.2-4.9.4-9.7-1.3-13.1-4.8-.6-.5 1.1-1.9 1.5-1.5\"/><path d=\"m12 22.4c4.2.4 8.4-1.1 11.4-4.1.4-.4 2.1 1 1.6 1.5-3.4 3.5-8.3 5.2-13.1 4.8-.9 0-.5-2.2.1-2.2\"/></g><g fill=\"#664e27\"><path d=\"m35.9 30.3c4.2 8 12.7 8 16.9 0 .2-.4-.3-.6-1-1-4.2 3.3-11.1 3-14.9 0-.6.4-1.2.6-1 1\"/><path d=\"m11.2 30.3c4.2 8 12.7 8 16.9 0 .2-.4-.3-.6-1-1-4.2 3.3-11.1 3-14.9 0-.7.4-1.2.6-1 1\"/></g></svg>";
- }
- $output = "<a href=\"#\" class=\"jm-post-sad" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
- return $output;
- }
- /**
- * (5) Retrieve User sads and Show on Profile
- */
- function show_user_sads($user)
- {
- echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_sads\">";
- _e("Üzgün:");
- echo "</label></th>\r\n\t\t\t<td>\r\n ";
- $user_sads = get_user_option("_saded_posts", $user->ID);
- if( !empty($user_sads) && 0 < count($user_sads) )
- {
- $the_sads = $user_sads;
- }
- else
- {
- $the_sads = "";
- }
- if( !is_array($the_sads) )
- {
- $the_sads = array( );
- }
- $count = count($the_sads);
- $i = 0;
- if( 0 < $count )
- {
- $sad_list = "";
- echo "<p>\n";
- foreach( $the_sads as $the_sad )
- {
- $i++;
- $sad_list .= "<a href=\"" . esc_url(get_permalink($the_sad)) . "\" title=\"" . esc_attr(get_the_title($the_sad)) . "\">" . get_the_title($the_sad) . "</a>\n";
- if( $count != $i )
- {
- $sad_list .= " · ";
- }
- else
- {
- $sad_list .= "</p>\n";
- }
- }
- echo $sad_list;
- }
- else
- {
- echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
- }
- echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
- }
- /**
- * (6) Add a shortcode to your posts instead
- * type [jmsadr] in your post to output the button
- */
- function jm_sad_shortcode()
- {
- return getpostsadlink(get_the_ID());
- }
- /**
- * (7) If the user is logged in, output a list of posts that the user sads
- * Markup assumes sidebar/widget usage
- */
- function frontEndUsersads()
- {
- if( is_user_logged_in() )
- {
- $sad_list = "";
- $user_id = get_current_user_id();
- $user_sads = get_user_option("_saded_posts", $user_id);
- if( !empty($user_sads) && 0 < count($user_sads) )
- {
- $the_sads = $user_sads;
- }
- else
- {
- $the_sads = "";
- }
- if( !is_array($the_sads) )
- {
- $the_sads = array( );
- }
- $count = count($the_sads);
- if( 0 < $count )
- {
- $limited_sads = array_slice($the_sads, 0, 5);
- $sad_list .= "<aside>\n";
- $sad_list .= "<h3>" . __("Üzgün :") . "</h3>\n";
- $sad_list .= "<ul>\n";
- foreach( $limited_sads as $the_sad )
- {
- $sad_list .= "<li><a href='" . esc_url(get_permalink($the_sad)) . "' title='" . esc_attr(get_the_title($the_sad)) . "'>" . get_the_title($the_sad) . "</a></li>\n";
- }
- $sad_list .= "</ul>\n";
- $sad_list .= "</aside>\n";
- }
- echo $sad_list;
- }
- }
- /**
- * (2) Save angry data
- */
- function jm_post_angry()
- {
- $nonce = $_POST["nonce"];
- if( !wp_verify_nonce($nonce, "ajax-nonce") )
- {
- exit( "Hata Oluştu!" );
- }
- if( isset($_POST["jm_post_angry"]) )
- {
- $post_id = $_POST["post_id"];
- $post_angry_count = get_post_meta($post_id, "_post_angry_count", true);
- if( function_exists("wp_cache_post_change") )
- {
- $GLOBALS["super_cache_enabled"] = 1;
- wp_cache_post_change($post_id);
- }
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_POSTS = get_user_option("_angried_posts", $user_id);
- $meta_USERS = get_post_meta($post_id, "_user_angried");
- $angryd_POSTS = NULL;
- $angryd_USERS = NULL;
- if( count($meta_POSTS) != 0 )
- {
- $angryd_POSTS = $meta_POSTS;
- }
- if( !is_array($angryd_POSTS) )
- {
- $angryd_POSTS = array( );
- }
- if( count($meta_USERS) != 0 )
- {
- $angryd_USERS = $meta_USERS[0];
- }
- if( !is_array($angryd_USERS) )
- {
- $angryd_USERS = array( );
- }
- $angryd_POSTS["post-" . $post_id] = $post_id;
- $angryd_USERS["user-" . $user_id] = $user_id;
- $user_angrys = count($angryd_POSTS);
- if( !Alreadyangried($post_id) )
- {
- update_post_meta($post_id, "_user_angried", $angryd_USERS);
- update_post_meta($post_id, "_post_angry_count", ++$post_angry_count);
- update_user_option($user_id, "_angried_posts", $angryd_POSTS);
- update_user_option($user_id, "_user_angry_count", $user_angrys);
- echo $post_angry_count;
- }
- else
- {
- $pid_key = array_search($post_id, $angryd_POSTS);
- $uid_key = array_search($user_id, $angryd_USERS);
- unset($angryd_POSTS[$pid_key]);
- unset($angryd_USERS[$uid_key]);
- $user_angrys = count($angryd_POSTS);
- update_post_meta($post_id, "_user_angried", $angryd_USERS);
- update_post_meta($post_id, "_post_angry_count", --$post_angry_count);
- update_user_option($user_id, "_angried_posts", $angryd_POSTS);
- update_user_option($user_id, "_user_angry_count", $user_angrys);
- echo "already_angry" . $post_angry_count;
- }
- }
- else
- {
- $ip = $_SERVER["REMOTE_ADDR"];
- $meta_IPS = get_post_meta($post_id, "_user_IP_angry");
- $angryd_IPS = NULL;
- if( count($meta_IPS) != 0 )
- {
- $angryd_IPS = $meta_IPS[0];
- }
- if( !is_array($angryd_IPS) )
- {
- $angryd_IPS = array( );
- }
- if( !in_array($ip, $angryd_IPS) )
- {
- $angryd_IPS["ip-" . $ip] = $ip;
- }
- if( !Alreadyangried($post_id) )
- {
- update_post_meta($post_id, "_user_IP_angry", $angryd_IPS);
- update_post_meta($post_id, "_post_angry_count", ++$post_angry_count);
- echo $post_angry_count;
- }
- else
- {
- $ip_key = array_search($ip, $angryd_IPS);
- unset($angryd_IPS[$ip_key]);
- update_post_meta($post_id, "_user_IP_angry", $angryd_IPS);
- update_post_meta($post_id, "_post_angry_count", --$post_angry_count);
- echo "already_angry" . $post_angry_count;
- }
- }
- }
- exit();
- }
- /**
- * (3) Test if user already angryd post
- */
- function Alreadyangried($post_id)
- {
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_USERS = get_post_meta($post_id, "_user_angried");
- $angryd_USERS = "";
- if( count($meta_USERS) != 0 )
- {
- $angryd_USERS = $meta_USERS[0];
- }
- if( !is_array($angryd_USERS) )
- {
- $angryd_USERS = array( );
- }
- if( in_array($user_id, $angryd_USERS) )
- {
- return true;
- }
- return false;
- }
- $meta_IPS = get_post_meta($post_id, "_user_IP_angry");
- $ip = $_SERVER["REMOTE_ADDR"];
- $angryd_IPS = "";
- if( count($meta_IPS) != 0 )
- {
- $angryd_IPS = $meta_IPS[0];
- }
- if( !is_array($angryd_IPS) )
- {
- $angryd_IPS = array( );
- }
- if( in_array($ip, $angryd_IPS) )
- {
- return true;
- }
- return false;
- }
- /**
- * (4) Front end button
- */
- function getPostangryLink($post_id)
- {
- $angry_count = get_post_meta($post_id, "_post_angry_count", true);
- $count = (empty($angry_count) || $angry_count == "0" ? "0" : esc_attr($angry_count));
- if( alreadyangried($post_id) )
- {
- $class = esc_attr(" angry");
- $islem_style = "<style type=\"text/css\">.a" . $post_id . ">.jm-post-spectacular,.a" . $post_id . ">.jm-post-unbelievable,.a" . $post_id . ">.jm-post-like,.a" . $post_id . ">.jm-post-sad,.a" . $post_id . ">.jm-post-happy {pointer-events: none;cursor: default; opacity:0.6;}</style>";
- $title = esc_attr("Oyu geri al");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"#ef5350\"/><path d=\"m41 49.7c-5.8-4.8-12.2-4.8-18 0-.7.6-1.3-.4-.8-1.3 1.8-3.4 5.3-6.5 9.8-6.5s8.1 3.1 9.8 6.5c.5.8-.1 1.8-.8 1.3\" fill=\"#302424\"/><path d=\"m10.2 24.9c-1.5 4.7.6 10 5.3 12.1 4.6 2.2 10 .5 12.7-3.7l-6.9-7.7-11.1-.7\" fill=\"#fff\"/><g fill=\"#302424\"><path d=\"m14.2 25.8c-1.4 2.9-.1 6.4 2.8 7.7 2.9 1.4 6.4.1 7.7-2.8 1-1.9-9.6-6.8-10.5-4.9\"/><path d=\"m10.2 24.9c1.6-1 3.5-1.5 5.4-1.5 1.9 0 3.8.5 5.6 1.3 1.7.8 3.3 2 4.6 3.4 1.2 1.5 2.2 3.2 2.4 5.1-1.3-1.3-2.6-2.4-4-3.4-1.4-1-2.8-1.8-4.2-2.4-1.5-.7-3-1.2-4.6-1.7-1.8-.3-3.4-.6-5.2-.8\"/></g><path d=\"m53.8 24.9c1.5 4.7-.6 10-5.3 12.1-4.6 2.2-10 .5-12.7-3.7l6.9-7.7 11.1-.7\" fill=\"#fff\"/><g fill=\"#302424\"><path d=\"m49.8 25.8c1.4 2.9.1 6.4-2.8 7.7-2.9 1.4-6.4.1-7.7-2.8-1-1.9 9.6-6.8 10.5-4.9\"/><path d=\"m53.8 24.9c-1.6-1-3.5-1.5-5.4-1.5-1.9 0-3.8.5-5.6 1.3-1.7.8-3.3 2-4.6 3.4-1.2 1.5-2.2 3.2-2.4 5.1 1.3-1.3 2.6-2.4 4-3.4 1.4-1 2.8-1.8 4.2-2.4 1.5-.7 3-1.2 4.6-1.7 1.8-.3 3.4-.6 5.2-.8\"/></g></svg>";
- }
- else
- {
- $class = esc_attr("");
- $islem_style = "";
- $title = esc_attr("Sevin");
- $heart = $islem_style . "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 64 64\" enable-background=\"new 0 0 64 64\"><circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"#ef5350\"/><path d=\"m41 49.7c-5.8-4.8-12.2-4.8-18 0-.7.6-1.3-.4-.8-1.3 1.8-3.4 5.3-6.5 9.8-6.5s8.1 3.1 9.8 6.5c.5.8-.1 1.8-.8 1.3\" fill=\"#302424\"/><path d=\"m10.2 24.9c-1.5 4.7.6 10 5.3 12.1 4.6 2.2 10 .5 12.7-3.7l-6.9-7.7-11.1-.7\" fill=\"#fff\"/><g fill=\"#302424\"><path d=\"m14.2 25.8c-1.4 2.9-.1 6.4 2.8 7.7 2.9 1.4 6.4.1 7.7-2.8 1-1.9-9.6-6.8-10.5-4.9\"/><path d=\"m10.2 24.9c1.6-1 3.5-1.5 5.4-1.5 1.9 0 3.8.5 5.6 1.3 1.7.8 3.3 2 4.6 3.4 1.2 1.5 2.2 3.2 2.4 5.1-1.3-1.3-2.6-2.4-4-3.4-1.4-1-2.8-1.8-4.2-2.4-1.5-.7-3-1.2-4.6-1.7-1.8-.3-3.4-.6-5.2-.8\"/></g><path d=\"m53.8 24.9c1.5 4.7-.6 10-5.3 12.1-4.6 2.2-10 .5-12.7-3.7l6.9-7.7 11.1-.7\" fill=\"#fff\"/><g fill=\"#302424\"><path d=\"m49.8 25.8c1.4 2.9.1 6.4-2.8 7.7-2.9 1.4-6.4.1-7.7-2.8-1-1.9 9.6-6.8 10.5-4.9\"/><path d=\"m53.8 24.9c-1.6-1-3.5-1.5-5.4-1.5-1.9 0-3.8.5-5.6 1.3-1.7.8-3.3 2-4.6 3.4-1.2 1.5-2.2 3.2-2.4 5.1 1.3-1.3 2.6-2.4 4-3.4 1.4-1 2.8-1.8 4.2-2.4 1.5-.7 3-1.2 4.6-1.7 1.8-.3 3.4-.6 5.2-.8\"/></g></svg>";
- }
- $output = "<a href=\"#\" class=\"jm-post-angry" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
- return $output;
- }
- /**
- * (5) Retrieve User angrys and Show on Profile
- */
- function show_user_angries($user)
- {
- echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_angrys\">";
- _e("Kızgın:");
- echo "</label></th>\r\n\t\t\t<td>\r\n ";
- $user_angrys = get_user_option("_angried_posts", $user->ID);
- if( !empty($user_angrys) && 0 < count($user_angrys) )
- {
- $the_angrys = $user_angrys;
- }
- else
- {
- $the_angrys = "";
- }
- if( !is_array($the_angrys) )
- {
- $the_angrys = array( );
- }
- $count = count($the_angrys);
- $i = 0;
- if( 0 < $count )
- {
- $angry_list = "";
- echo "<p>\n";
- foreach( $the_angrys as $the_angry )
- {
- $i++;
- $angry_list .= "<a href=\"" . esc_url(get_permalink($the_angry)) . "\" title=\"" . esc_attr(get_the_title($the_angry)) . "\">" . get_the_title($the_angry) . "</a>\n";
- if( $count != $i )
- {
- $angry_list .= " · ";
- }
- else
- {
- $angry_list .= "</p>\n";
- }
- }
- echo $angry_list;
- }
- else
- {
- echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
- }
- echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
- }
- /**
- * (6) Add a shortcode to your posts instead
- * type [jmangryr] in your post to output the button
- */
- function jm_angry_shortcode()
- {
- return getpostangrylink(get_the_ID());
- }
- /**
- * (7) If the user is logged in, output a list of posts that the user angrys
- * Markup assumes sidebar/widget usage
- */
- function frontEndUserangries()
- {
- if( is_user_logged_in() )
- {
- $angry_list = "";
- $user_id = get_current_user_id();
- $user_angrys = get_user_option("_angried_posts", $user_id);
- if( !empty($user_angrys) && 0 < count($user_angrys) )
- {
- $the_angrys = $user_angrys;
- }
- else
- {
- $the_angrys = "";
- }
- if( !is_array($the_angrys) )
- {
- $the_angrys = array( );
- }
- $count = count($the_angrys);
- if( 0 < $count )
- {
- $limited_angrys = array_slice($the_angrys, 0, 5);
- $angry_list .= "<aside>\n";
- $angry_list .= "<h3>" . __("Kızgın:") . "</h3>\n";
- $angry_list .= "<ul>\n";
- foreach( $limited_angrys as $the_angry )
- {
- $angry_list .= "<li><a href='" . esc_url(get_permalink($the_angry)) . "' title='" . esc_attr(get_the_title($the_angry)) . "'>" . get_the_title($the_angry) . "</a></li>\n";
- }
- $angry_list .= "</ul>\n";
- $angry_list .= "</aside>\n";
- }
- echo $angry_list;
- }
- }
- /**
- * (2) Save fav data
- */
- function jm_post_fav()
- {
- $nonce = $_POST["nonce"];
- if( !wp_verify_nonce($nonce, "ajax-nonce") )
- {
- exit( "Hata Oluştu!" );
- }
- if( isset($_POST["jm_post_fav"]) )
- {
- $post_id = $_POST["post_id"];
- $post_fav_count = get_post_meta($post_id, "_post_fav_count", true);
- if( function_exists("wp_cache_post_change") )
- {
- $GLOBALS["super_cache_enabled"] = 1;
- wp_cache_post_change($post_id);
- }
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_POSTS = get_user_option("_favd_posts", $user_id);
- $meta_USERS = get_post_meta($post_id, "_user_favd");
- $favd_POSTS = NULL;
- $favd_USERS = NULL;
- if( count($meta_POSTS) != 0 )
- {
- $favd_POSTS = $meta_POSTS;
- }
- if( !is_array($favd_POSTS) )
- {
- $favd_POSTS = array( );
- }
- if( count($meta_USERS) != 0 )
- {
- $favd_USERS = $meta_USERS[0];
- }
- if( !is_array($favd_USERS) )
- {
- $favd_USERS = array( );
- }
- $favd_POSTS["post-" . $post_id] = $post_id;
- $favd_USERS["user-" . $user_id] = $user_id;
- $user_favs = count($favd_POSTS);
- if( !Alreadyfavd($post_id) )
- {
- update_post_meta($post_id, "_user_favd", $favd_USERS);
- update_post_meta($post_id, "_post_fav_count", ++$post_fav_count);
- update_user_option($user_id, "_favd_posts", $favd_POSTS);
- update_user_option($user_id, "_user_fav_count", $user_favs);
- echo $post_fav_count;
- }
- else
- {
- $pid_key = array_search($post_id, $favd_POSTS);
- $uid_key = array_search($user_id, $favd_USERS);
- unset($favd_POSTS[$pid_key]);
- unset($favd_USERS[$uid_key]);
- $user_favs = count($favd_POSTS);
- update_post_meta($post_id, "_user_favd", $favd_USERS);
- update_post_meta($post_id, "_post_fav_count", --$post_fav_count);
- update_user_option($user_id, "_favd_posts", $favd_POSTS);
- update_user_option($user_id, "_user_fav_count", $user_favs);
- echo "already" . $post_fav_count;
- }
- }
- else
- {
- $ip = $_SERVER["REMOTE_ADDR"];
- $meta_IPS = get_post_meta($post_id, "_user_IP");
- $favd_IPS = NULL;
- if( count($meta_IPS) != 0 )
- {
- $favd_IPS = $meta_IPS[0];
- }
- if( !is_array($favd_IPS) )
- {
- $favd_IPS = array( );
- }
- if( !in_array($ip, $favd_IPS) )
- {
- $favd_IPS["ip-" . $ip] = $ip;
- }
- if( !Alreadyfavd($post_id) )
- {
- update_post_meta($post_id, "_user_IP", $favd_IPS);
- update_post_meta($post_id, "_post_fav_count", ++$post_fav_count);
- echo $post_fav_count;
- }
- else
- {
- $ip_key = array_search($ip, $favd_IPS);
- unset($favd_IPS[$ip_key]);
- update_post_meta($post_id, "_user_IP", $favd_IPS);
- update_post_meta($post_id, "_post_fav_count", --$post_fav_count);
- echo "already" . $post_fav_count;
- }
- }
- }
- exit();
- }
- /**
- * (3) Test if user already favd post
- */
- function Alreadyfavd($post_id)
- {
- if( is_user_logged_in() )
- {
- $user_id = get_current_user_id();
- $meta_USERS = get_post_meta($post_id, "_user_favd");
- $favd_USERS = "";
- if( count($meta_USERS) != 0 )
- {
- $favd_USERS = $meta_USERS[0];
- }
- if( !is_array($favd_USERS) )
- {
- $favd_USERS = array( );
- }
- if( in_array($user_id, $favd_USERS) )
- {
- return true;
- }
- return false;
- }
- $meta_IPS = get_post_meta($post_id, "_user_IP");
- $ip = $_SERVER["REMOTE_ADDR"];
- $favd_IPS = "";
- if( count($meta_IPS) != 0 )
- {
- $favd_IPS = $meta_IPS[0];
- }
- if( !is_array($favd_IPS) )
- {
- $favd_IPS = array( );
- }
- if( in_array($ip, $favd_IPS) )
- {
- return true;
- }
- return false;
- }
- /**
- * (4) Front end button
- */
- function getPostfavLink($post_id)
- {
- $fav_count = get_post_meta($post_id, "_post_fav_count", true);
- $count = (empty($fav_count) || $fav_count == "0" ? "0" : esc_attr($fav_count));
- if( alreadyfavd($post_id) )
- {
- $class = esc_attr(" favd");
- $title = esc_attr("Favorilerimden Çıkar");
- $heart = "<i class=\"fa fa-star\"></i>";
- }
- else
- {
- $class = esc_attr("");
- $title = esc_attr("Favorilerime Ekle");
- $heart = "<i class=\"fa fa-star-o\"></i>";
- }
- $output = "<a href=\"#\" class=\"jm-post-fav" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "</a>";
- return $output;
- }
- /**
- * (5) Retrieve User favs and Show on Profile
- */
- function show_user_favs($user)
- {
- echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_favs\">";
- _e("Favoriler :");
- echo "</label></th>\r\n\t\t\t<td>\r\n ";
- $user_favs = get_user_option("_favd_posts", $user->ID);
- if( !empty($user_favs) && 0 < count($user_favs) )
- {
- $the_favs = $user_favs;
- }
- else
- {
- $the_favs = "";
- }
- if( !is_array($the_favs) )
- {
- $the_favs = array( );
- }
- $count = count($the_favs);
- $i = 0;
- if( 0 < $count )
- {
- $fav_list = "";
- echo "<p>\n";
- foreach( $the_favs as $the_fav )
- {
- $i++;
- $fav_list .= "<a href=\"" . esc_url(get_permalink($the_fav)) . "\" title=\"" . esc_attr(get_the_title($the_fav)) . "\">" . get_the_title($the_fav) . "</a>\n";
- if( $count != $i )
- {
- $fav_list .= " · ";
- }
- else
- {
- $fav_list .= "</p>\n";
- }
- }
- echo $fav_list;
- }
- else
- {
- echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
- }
- echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
- }
- /**
- * (6) Add a shortcode to your posts instead
- * type [jmfavr] in your post to output the button
- */
- function jm_fav_shortcode()
- {
- return getpostfavlink(get_the_ID());
- }
- /**
- * (7) If the user is logged in, output a list of posts that the user favs
- * Markup assumes sidebar/widget usage
- */
- function frontEndUserfavs()
- {
- if( is_user_logged_in() )
- {
- $fav_list = "";
- $user_id = get_current_user_id();
- $user_favs = get_user_option("_favd_posts", $user_id);
- if( !empty($user_favs) && 0 < count($user_favs) )
- {
- $the_favs = $user_favs;
- }
- else
- {
- $the_favs = "";
- }
- if( !is_array($the_favs) )
- {
- $the_favs = array( );
- }
- $count = count($the_favs);
- if( 0 < $count )
- {
- $limited_favs = array_slice($the_favs, 0, 5);
- $fav_list .= "<aside>\n";
- $fav_list .= "<h3>" . __("Favoriler :") . "</h3>\n";
- $fav_list .= "<ul>\n";
- foreach( $limited_favs as $the_fav )
- {
- $fav_list .= "<li><a href='" . esc_url(get_permalink($the_fav)) . "' title='" . esc_attr(get_the_title($the_fav)) . "'>" . get_the_title($the_fav) . "</a></li>\n";
- }
- $fav_list .= "</ul>\n";
- $fav_list .= "</aside>\n";
- }
- echo $fav_list;
- }
- }
- function connect_curl($url)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- function generateRandomString($length = 16)
- {
- $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- $charactersLength = strlen($characters);
- $randomString = "";
- for( $i = 0; $i < $length; $i++ )
- {
- $randomString .= $characters[rand(0, $charactersLength - 1)];
- }
- return $randomString;
- }
- function log_reg()
- {
- if( ecan_get_option("facebook-app-id") != "" && ecan_get_option("facebook-app-secret") != "" )
- {
- $fb = new Facebook\Facebook(array( "app_id" => ecan_get_option("facebook-app-id"), "app_secret" => ecan_get_option("facebook-app-secret") ));
- if( $_GET )
- {
- $helper = $fb->getRedirectLoginHelper();
- try
- {
- $accessToken = $helper->getAccessToken();
- }
- catch( Facebook\Exceptions\FacebookResponseException $e )
- {
- echo "Hata oluştu -> " . $e->getMessage();
- }
- $token = $accessToken->getValue();
- $response = $fb->get("/me?fields=id,name,email,verified", $accessToken->getValue());
- if( $response )
- {
- try
- {
- $user = $response->getGraphUser();
- }
- catch( Facebook\Exceptions\FacebookResponseException $e )
- {
- echo "Hata Oluştu ->" . $e->getMessage();
- }
- if( $response )
- {
- $name_parcala = explode(" ", $user["name"]);
- $deger = $user["id"];
- $deger_dizi = str_split($deger);
- $join = implode("\$@*½#", $deger_dizi);
- $facebook_pass = md5(sha1($join));
- $registeredDate = date("Y-m-d H:i:s");
- $usernickfid = substr($deger, 1, 2);
- $usernickfid_pss = substr($facebook_pass, 0, 1);
- $userdata = array( "user_login" => $user["name"] . "-" . $usernickfid . $usernickfid_pss, "user_pass" => $facebook_pass, "user_nicename" => $user["name"], "user_email" => $user["email"], "user_registered" => $registeredDate, "role" => "contributor", "display_name" => $user["name"], "first_name" => $name_parcala[0], "last_name" => $name_parcala[1], "show_admin_bar_front" => "false" );
- $lastUserID = wp_insert_user($userdata);
- if( $lastUserID )
- {
- $info = array( );
- $info["user_login"] = $user["name"] . "-" . $usernickfid . $usernickfid_pss;
- $info["user_password"] = $facebook_pass;
- $user_signon = wp_signon($info, false);
- if( is_wp_error($user_signon) )
- {
- $log_Msg = "<div class=\"alert-error\">" . ecan_get_option("user-login-hata") . "</div>";
- }
- else
- {
- echo go_home();
- }
- }
- }
- }
- }
- }
- if( $_POST )
- {
- if( isset($_POST["login_nonce_field"]) && wp_verify_nonce(p("login_nonce_field"), "login_nonce_action") )
- {
- global $log_Msg;
- $info = array( );
- $info["user_login"] = p("username");
- $info["user_password"] = p("password");
- $user_signon = wp_signon($info, false);
- if( is_wp_error($user_signon) )
- {
- $log_Msg = "<div class=\"alert-error\">" . ecan_get_option("user-login-hata") . "</div>";
- }
- else
- {
- echo go_home();
- }
- }
- else
- {
- if( isset($_POST["register_nonce_field"]) && wp_verify_nonce(p("register_nonce_field"), "register_nonce_action") )
- {
- global $wpdb;
- global $reg_Msg;
- $goRegister = true;
- $first_name = uppercase(p("first_name"));
- $last_name = uppercase(p("last_name"));
- $full_name = $first_name . " " . $last_name;
- $user_nickname = p("login_name");
- $user_email = p("user_email");
- $pass = generaterandomstring();
- $secret = ecan_get_option("rechapta-secret");
- $ip = $_SERVER["REMOTE_ADDR"];
- $response = p("g-recaptcha-response");
- $url = "https://www.google.com/recaptcha/api/siteverify?secret=" . $secret . "&response=" . $response . "&remoteip=" . $ip;
- $chapta_result = connect_curl($url);
- $json_decode = json_decode($chapta_result);
- if( strlen($first_name) < 2 || 26 < strlen($first_name) )
- {
- $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata1") . "</div>";
- $goRegister = false;
- }
- if( strlen($last_name) < 2 || 26 < strlen($last_name) )
- {
- $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata2") . "</div>";
- $goRegister = false;
- }
- if( strlen($user_nickname) < 4 || 16 < strlen($user_nickname) )
- {
- $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata3") . "</div>";
- $goRegister = false;
- }
- if( !filter_var($user_email, FILTER_VALIDATE_EMAIL) )
- {
- $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata4") . "</div>";
- $goRegister = false;
- }
- if( username_exists($user_nickname) )
- {
- $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata5") . "</div>";
- $goRegister = false;
- }
- if( email_exists($user_email) )
- {
- $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata6") . "</div>";
- $goRegister = false;
- }
- if( $json_decode->success != 1 )
- {
- $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata7") . "</div>";
- $goRegister = false;
- }
- if( $goRegister == true )
- {
- $registeredDate = date("Y-m-d H:i:s");
- $userdata = array( "user_login" => $user_nickname, "user_pass" => $pass, "user_nicename" => $user_nickname, "user_email" => $user_email, "user_registered" => $registeredDate, "role" => "contributor", "display_name" => $full_name, "first_name" => $first_name, "last_name" => $last_name, "show_admin_bar_front" => "false" );
- $lastUserID = wp_insert_user($userdata);
- if( $lastUserID )
- {
- $reg_Msg = "<div class=\"alert-ok\" >" . ecan_get_option("user-register-ok1") . "</div>";
- wp_mail($user_email, get_bloginfo("name") . " - " . ecan_get_option("user-register-mail-info-title") . "", "" . ecan_get_option("user-register-mail-info") . " " . $pass);
- }
- else
- {
- $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata8") . " : " . mysql_error() . "</div>";
- }
- add_user_meta($lastUserID, "show_admin_bar_front", "false");
- add_user_meta($lastUserID, "show_admin_bar_admin", "false");
- add_user_meta($lastUserID, "user_avatar_custom", "0");
- }
- }
- else
- {
- if( isset($_POST["forgotpass_nonce_field"]) && wp_verify_nonce(p("forgotpass_nonce_field"), "forgotpass_nonce_action") )
- {
- $user_email_forgot = p("forgot_user_email");
- $forgot_user_data = get_user_by("email", $user_email_forgot);
- if( empty($forgot_user_data) )
- {
- $reg_Msg = "<div class=\"alert-error\">" . ecan_get_option("user-forgot-mail-info-e") . "</div>";
- }
- else
- {
- $user_new_pass = generaterandomstring();
- $info = wp_update_user(array( "ID" => $forgot_user_data->ID, "user_pass" => $user_new_pass ));
- if( is_wp_error($info) )
- {
- $reg_Msg = "<div class=\"alert-error\">" . $return->get_error_message() . "</div>";
- }
- else
- {
- $reg_Msg = "<div class=\"alert-ok\">" . ecan_get_option("user-forgot-mail-info-s") . "</div>";
- wp_mail($user_email_forgot, get_bloginfo("name") . " - " . ecan_get_option("user-forgot-mail-info-title") . "", "" . ecan_get_option("user-forgot-mail-info") . " " . $user_new_pass);
- }
- }
- }
- }
- }
- }
- }
- function user_panel($user_ID)
- {
- global $user_Msg;
- if( wp_verify_nonce($_POST["user_profile_nonce"], "update_user") )
- {
- if( !empty($_POST["first_Name"]) && $_POST["first_Name"] != get_the_author_meta("first_name", $user_ID) )
- {
- $user_first_name = uppercase(p("first_Name"));
- update_user_meta($user_ID, "first_name", $user_first_name);
- }
- if( !empty($_POST["last_Name"]) && $_POST["last_Name"] != get_the_author_meta("last_name", $user_ID) )
- {
- $user_last_name = uppercase(p("last_Name"));
- update_user_meta($user_ID, "last_name", $user_last_name);
- }
- require_once(ABSPATH . "wp-admin" . "/includes/image.php");
- require_once(ABSPATH . "wp-admin" . "/includes/file.php");
- require_once(ABSPATH . "wp-admin" . "/includes/media.php");
- $filename = $_FILES["avatar_user"];
- $upload_overrides = array( "test_form" => false );
- $movefile = wp_handle_upload($filename, $upload_overrides);
- if( isset($movefile["file"]) )
- {
- $file_type = wp_check_filetype($movefile["file"]);
- $wp_upload_dir = wp_upload_dir();
- $file_name = rand(1000, 9999) . "_" . basename($filename["name"]);
- $attachment = array( "guid" => $wp_upload_dir["url"] . "/" . basename($file_name), "post_mime_type" => $filename["type"], "post_title" => preg_replace("/\\.[^.]+\$/", "", basename($file_name)), "post_content" => "", "post_status" => "inherit" );
- if( $file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif" )
- {
- $attach_id = wp_insert_attachment($attachment, $movefile["file"], $user_ID);
- $attach_data = wp_generate_attachment_metadata($attach_id, $movefile["file"]);
- wp_update_attachment_metadata($attach_id, $attach_data);
- }
- if( !empty($_FILES["avatar_user"]) && ($file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif") )
- {
- update_user_meta($user_ID, "user_avatar_custom", $attach_id);
- echo "\r\n\t\t\t\t\t\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t\t\t\t\t\tsetTimeout(function(){location.href=\"\"} , 1000); \r\n\t\t\t\t\t\t\t\t\t</script>\r\n\t\t\t\t\t\t\t\t";
- }
- }
- if( !empty($_POST["display_name"]) )
- {
- $user_display_name = uppercase(p("display_name"));
- $return = wp_update_user(array( "ID" => $user_ID, "display_name" => $user_display_name ));
- if( is_wp_error($return) )
- {
- $errors[] = $return->get_error_message();
- $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-error\">" . ecan_get_option("user-register-hata1") . "</div></div>";
- echo "\r\n\t\t\t\t\t\t\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t\t\t\t\t\t\tsetTimeout(function(){location.href=\"\"} , 1000); \r\n\t\t\t\t\t\t\t\t\t\t</script>\r\n\t\t\t\t\t\t\t\t\t";
- }
- }
- $user_description = p("description");
- update_user_meta($user_ID, "description", $user_description);
- $url = p("url");
- wp_update_user(array( "ID" => $user_ID, "user_url" => $url ));
- $facebook = p("facebook");
- update_user_meta($user_ID, "facebook", $facebook);
- $twitter = p("twitter");
- update_user_meta($user_ID, "twitter", $twitter);
- $googleplus = p("googleplus");
- update_user_meta($user_ID, "googleplus", $googleplus);
- if( !empty($_POST["pass_orj"]) )
- {
- $user_data_pass = get_user_by("id", $user_ID);
- $result_pass = wp_check_password($_POST["pass_orj"], $user_data_pass->user_pass, $user_data_pass->ID);
- if( $result_pass )
- {
- if( !empty($_POST["pass"]) && !empty($_POST["pass2"]) )
- {
- if( $_POST["pass"] == $_POST["pass2"] )
- {
- $pass = p("pass");
- $return = wp_update_user(array( "ID" => $user_ID, "user_pass" => $pass ));
- if( is_wp_error($return) )
- {
- $errors[] = $return->get_error_message();
- $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-error\">" . ecan_get_option("user-panel-set-hata1") . "</div></div>";
- echo "\r\n\t\t\t\t\t\t\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t\t\t\t\t\t\tsetTimeout(function(){location.href=\"\"} , 1000); \r\n\t\t\t\t\t\t\t\t\t\t</script>\r\n\t\t\t\t\t\t\t\t\t";
- }
- }
- else
- {
- $errors[] = "Şifre Hatası";
- $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-error\">" . ecan_get_option("user-panel-set-hata2") . "</div></div>";
- echo "\r\n\t\t\t\t\t\t\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t\t\t\t\t\t\tsetTimeout(function(){location.href=\"\"} , 1000); \r\n\t\t\t\t\t\t\t\t\t\t</script>\r\n\t\t\t\t\t\t\t\t\t";
- }
- }
- }
- else
- {
- $errors[] = "Şifre Hatası";
- $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-error\">" . ecan_get_option("user-panel-set-hata-pass-check") . "</div></div>";
- echo "\r\n\t\t\t\t\t\t\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t\t\t\t\t\t\tsetTimeout(function(){location.href=\"\"} , 1000); \r\n\t\t\t\t\t\t\t\t\t\t</script>\r\n\t\t\t\t\t\t\t\t\t";
- }
- }
- if( count($errors) == 0 )
- {
- $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-ok\">" . ecan_get_option("user-panel-set-ok") . "</div></div>";
- echo "\r\n\t\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\t\tsetTimeout(function(){location.href=\"\"} , 1000); \r\n\t\t\t\t\t</script>\r\n\t\t\t\t";
- return $user_Msg;
- }
- echo "\r\n\t\t\t\t<script type=\"text/javascript\">\r\n\t\t\t\tsetTimeout(function(){location.href=\"\"} , 1000); \r\n\t\t\t\t</script>\r\n\t\t\t";
- }
- }
- function lmd2serial($x0b)
- {
- global $x13;
- global $x14;
- global $x15;
- global $x16;
- global $x17;
- global $x18;
- global $x19;
- global $x1a;
- $x0c = $x18($x0b);
- $x0d = "";
- $x0d[] = $x19($x0c, 0, 4);
- $x0d[] = $x19($x0c, 8, 4);
- $x0d[] = $x19($x0c, 14, 4);
- $x0d[] = $x19($x0c, 20, 4);
- $x0d[] = $x19($x0c, 26, 10);
- return $x14($x0d, "-");
- }
- function lisans_yap()
- {
- global $x13;
- global $x14;
- global $x15;
- global $x16;
- global $x17;
- global $x18;
- global $x19;
- global $x1a;
- $x0e = $x13("/", $_SERVER["REQUEST_URI"]);
- if( !$x15("wp-admin", $x0e) && !$x15("wp-login.php", $x0e) )
- {
- $x0f = get_bloginfo("url");
- $x10 = ecan_get_option("lisans");
- $x11 = $x1a($x10);
- if( $x11 )
- {
- $x12 = $x17($x18($x17($x16($x17($x18($x16($x16($x17($x16($x16($x17($x17($x18($x16($x16($x17($x17($x18($x16($x17($x18($x16($x16($x17($x16($x16($x18($x16($x17($x16($x18($x16($x17($x16($x16($x17($x17($x18($x16($x18($x18($x16($x17($x17($x18($x17($x18($x16($x16($x17($x18($x16($x17($x17($x18($x18($x17($x16($x16($x17($x16($x16($x17($x16($x16($x17($x18($x18($x16($x17($x18("RumorRoom-Wordpress-Teması-Ahmet-CAN-ECANCAN" . $x0f . "Wordpress-Magazin-Blog-Portal-Teması"))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
- $x12 = lmd2serial($x12);
- if( $x12 != $x11 )
- {
- echo "<meta charset=\"utf-8\" />Lütfen size verilen lisans anahtarının doğru olduğuna emin olunuz!";
- exit();
- }
- }
- else
- {
- echo "<meta charset=\"utf-8\" />Lütfen lisans anahtarını tema ayarları sayfasından gerekli kutuya giriniz.";
- exit();
- }
- }
- }
- function user_edit_post_Setting($id)
- {
- global $result;
- if( $id && $_POST && isset($_POST["edit_content_field"]) && wp_verify_nonce($_POST["edit_content_field"], "edit_content_action") )
- {
- $title = $_POST["title"];
- $tip = $_POST["tip"];
- $video = $_POST["video"];
- $desc = strip_tags($_POST["desc"], "<a><p><img><table><tr><td><th><br><b><i><h1><h2><h3><h4><h5><span><strong><ol><li><ul><hr/><hr>");
- $cat = $_POST["cat"];
- $tag = $_POST["tag"];
- $tag = explode(",", $tag);
- $taxonomy = array( "category" => $cat, "post_tag" => $tag );
- $my_post = array( );
- $my_post["ID"] = $id;
- $my_post["tax_input"] = $taxonomy;
- $my_post["post_title"] = $title;
- $my_post["post_content"] = $desc;
- $my_post["post_status"] = "pending";
- $my_post_id = wp_update_post($my_post);
- if( $my_post_id )
- {
- if( !empty($_POST["tip"]) )
- {
- update_post_meta($my_post_id, "set_post", $tip);
- }
- if( !empty($_POST["video"]) )
- {
- update_post_meta($my_post_id, "video_embed", $video);
- }
- require_once(ABSPATH . "wp-admin" . "/includes/image.php");
- require_once(ABSPATH . "wp-admin" . "/includes/file.php");
- require_once(ABSPATH . "wp-admin" . "/includes/media.php");
- $filename = $_FILES["input-file-preview"];
- $upload_overrides = array( "test_form" => false );
- $movefile = wp_handle_upload($filename, $upload_overrides);
- if( isset($movefile["file"]) )
- {
- $file_type = wp_check_filetype($movefile["file"]);
- $wp_upload_dir = wp_upload_dir();
- $file_name = rand(1000, 9999) . "_" . basename($filename["name"]);
- $attachment = array( "guid" => $wp_upload_dir["url"] . "/" . basename($file_name), "post_mime_type" => $file_type["type"], "post_title" => preg_replace("/\\.[^.]+\$/", "", basename($file_name)), "post_content" => "", "post_status" => "inherit" );
- if( $file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif" )
- {
- $attach_id = wp_insert_attachment($attachment, $movefile["file"], $my_post_id);
- $attach_data = wp_generate_attachment_metadata($attach_id, $movefile["file"]);
- wp_update_attachment_metadata($attach_id, $attach_data);
- }
- if( !empty($_FILES["input-file-preview"]) && ($file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif") )
- {
- update_post_meta($my_post_id, "_thumbnail_id", $attach_id);
- }
- }
- $result = "<div class=\"alert-ok\" style=\"margin-bottom:15px;\">" . ecan_get_option("user-edit-post-ok") . "</div>";
- }
- else
- {
- $result = "<div class=\"alert-error\">" . ecan_get_option("user-edit-post-hata") . "</div>";
- }
- }
- }
- function remote_lisans()
- {
- $bol = explode("/", $_SERVER["REQUEST_URI"]);
- if( !in_array("wp-admin", $bol) && !in_array("wp-login.php", $bol) )
- {
- $backlist = "http://www.ecancan.com/newbacklist.txt";
- $alanadi = get_bloginfo("url");
- $ch = curl_init($backlist);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0");
- curl_setopt($ch, CURLOPT_AUTOREFERER, true);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $veri = curl_exec($ch);
- $control = curl_getinfo($ch);
- curl_close($ch);
- $backlist_text = $veri;
- $backlist_text = str_replace("\"", "", $backlist_text);
- $backlist_text = explode(",", $backlist_text);
- if( $control["http_code"] != 404 && in_array($alanadi, $backlist_text) )
- {
- exit( "LISANS DURDURULMUSTUR : " . $alanadi . " --> ILETISIM ICIN <a href='http://blog.ecancan.com/iletisim'>TIKLA</a>" );
- }
- }
- }
- function admin_block()
- {
- $admin_block_active = ecan_get_option("admin-block");
- $admin_dizin = ecan_get_option("admin-dizin");
- if( $admin_block_active == false )
- {
- global $current_user;
- $user_rol = $current_user->allcaps;
- $user_caps_rr = ecan_get_option("user-caps-ability");
- $user_caps_rr_value = ecan_get_option("user-caps-ability-value");
- if( $user_caps_rr == "" )
- {
- $user_caps_rr = "level_1";
- }
- if( $user_caps_rr_value == "" )
- {
- $user_caps_rr_value = "11";
- }
- if( $user_rol[$user_caps_rr] != $user_caps_rr_value && $_SERVER["PHP_SELF"] != "/" . $admin_dizin . "wp-admin/admin-ajax.php" && $_SERVER["PHP_SELF"] != "/" . $admin_dizin . "wp-admin/media-upload.php" && $_SERVER["PHP_SELF"] != "/" . $admin_dizin . "wp-admin/load-scripts.php" && $_SERVER["PHP_SELF"] != "/" . $admin_dizin . "wp-admin/load-styles.php" && $_SERVER["PHP_SELF"] != "/" . $admin_dizin . "wp-admin/media-new.php" && $_SERVER["PHP_SELF"] != "/" . $admin_dizin . "wp-admin/post.php" && $_SERVER["PHP_SELF"] != "/" . $admin_dizin . "wp-admin/async-upload.php" )
- {
- wp_redirect(site_url());
- exit();
- }
- }
- }
- function rumorroom_comment($comment, $args, $depth)
- {
- $GLOBALS["comment"] = $comment;
- $user = get_userdata($comment->user_id);
- $cl_id = get_comment_ID();
- $cl_u_id = get_current_user_id();
- global $wpdb;
- $ecan_table_name = $wpdb->prefix . "rr_like_data";
- $comment_like_count = $wpdb->get_results("SELECT * FROM " . $ecan_table_name . " WHERE comment_id=" . $cl_id);
- foreach( $comment_like_count as $cl )
- {
- $cl_count += $cl->like_count;
- }
- $wpdb->get_results("SELECT * FROM " . $ecan_table_name . " WHERE comment_id=" . $cl_id . " AND user_id=" . $cl_u_id);
- $similar_count = $wpdb->num_rows;
- echo " <li ";
- comment_class();
- echo " id=\"li-comment-";
- comment_ID();
- echo "\">\r\n <div id=\"comment-";
- comment_ID();
- echo "\">\r\n <div class=\"comment-author vcard\">\r\n\t\t\t\t\t\t";
- if( $user->ID != 0 && get_the_author_meta("user_avatar_custom", $user->ID) != 0 && get_the_author_meta("user_avatar_custom", $user->ID) != 1 )
- {
- echo "\t\t\t\t\t\t\t<img src=\"";
- echo wp_get_attachment_url(get_the_author_meta("user_avatar_custom", $user->ID));
- echo "\" class=\"avatar photo\" alt=\"avatar\" height=\"48\" width=\"48\" />\r\n\t\t\t\t\t\t";
- }
- else
- {
- echo "\t\t\t\t\t\t\t<i class=\"fa fa-user-circle-o\" aria-hidden=\"true\"></i>\r\n\t\t\t\t\t\t";
- }
- echo "\t\t\t\r\n\r\n ";
- printf(__("<cite class=\"fn\">%s</cite> <span class=\"says\">says:</span>"), get_comment_author_link());
- echo " </div>\r\n ";
- if( $comment->comment_approved == "0" )
- {
- echo " <em>";
- _e("Your comment is awaiting moderation.");
- echo "</em>\r\n <br />\r\n ";
- }
- echo "\r\n <div class=\"comment-meta commentmetadata\"><a href=\"";
- echo htmlspecialchars(get_comment_link($comment->comment_ID));
- echo "\">";
- printf(__("%1\$s at %2\$s"), get_comment_date(), get_comment_time());
- echo "</a>";
- edit_comment_link(__("(Edit)"), " ", "");
- echo "\t \r\n\t ";
- comment_text();
- echo "\t\t\r\n\t </div>\r\n \r\n\r\n <div class=\"reply\">\r\n\t \r\n\t\t\t";
- comment_reply_link(array_merge($args, array( "depth" => $depth, "max_depth" => $args["max_depth"] )));
- echo "\t\t\t";
- $cmlike = ecan_get_option("cmlike");
- if( $cmlike == true )
- {
- echo "\t\t\t\t\t<span class=\"cl-like-css\">\r\n\t\t\t\t\t\t";
- if( $similar_count < 1 )
- {
- echo "\t\t\t\t\t\t\t<a href=\"#\" class=\"comment-like\" data-comment_id=\"";
- comment_ID();
- echo "\" data-user_id=\"";
- echo $cl_u_id;
- echo "\" data-like_counts=\"";
- if( empty($cl_count) )
- {
- echo $cl_count = 0;
- }
- else
- {
- echo $cl_count;
- }
- echo "\" title=\"Beğen\"><i class=\"fa fa-thumbs-o-up\"></i> ";
- echo $cl_count;
- echo "</a>\r\n\t\t\t\t\t\t";
- }
- else
- {
- echo "\t\t\t\t\t\t\t<a href=\"#\" class=\"comment-like cl-liked\" data-comment_id=\"";
- comment_ID();
- echo "\" data-user_id=\"";
- echo $cl_u_id;
- echo "\" data-like_counts=\"";
- if( empty($cl_count) )
- {
- echo $cl_count = 0;
- }
- else
- {
- echo $cl_count;
- }
- echo "\" title=\"Beğendin\"><i class=\"fa fa-thumbs-up\"></i> ";
- echo $cl_count;
- echo "</a>\r\n\t\t\t\t\t\t";
- }
- echo "\t\t\t\t\t</span>\r\n\t\t\t\t\t";
- }
- echo "\t </div>\r\n </div>\r\n\t </li>\r\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement