Advertisement
Guest User

Untitled

a guest
Jun 10th, 2018
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 141.93 KB | None | 0 0
  1. <?php
  2. define("THEME_NAME", "RumorRoom WordPress Portal/Magazin Teması");
  3. define("THEME_SLUG", "rumorroom");
  4. define("NOTIFIER_XML_FILE", "http://ecancan.com/update/xml/" . THEME_SLUG . ".xml");
  5. define("NOTIFIER_THEME_FOLDER_NAME", "rumorrooms");
  6. define("NOTIFIER_CACHE_INTERVAL", 1);
  7. $x13 = "explode";
  8. load_template(get_template_directory() . "/admin/cs-framework.php");
  9. add_theme_support("nav-menus");
  10. register_nav_menu("menu1", "Üst Menu");
  11. register_nav_menu("menu2", "Orta Menu");
  12. register_nav_menu("menu3", "Alt Menu");
  13. register_nav_menu("mobil-menu", "Mobil Menu");
  14. add_theme_support("post-thumbnails");
  15. set_post_thumbnail_size(255, 150, true);
  16. add_image_size("i282x160", 282, 160, true);
  17. add_image_size("i578x316", 578, 316, true);
  18. add_image_size("i284x150", 284, 150, true);
  19. add_image_size("i274x150", 274, 150, true);
  20. add_image_size("i777x400", 777, 400, true);
  21. add_image_size("i755x566", 755, 566, true);
  22. add_image_size("i275x150", 275, 150, true);
  23. add_image_size("i274x165", 274, 165, true);
  24. add_image_size("i279x178", 279, 178, true);
  25. add_image_size("i389x380", 389, 380, true);
  26. add_image_size("i259x180", 259, 180, true);
  27. add_action("widgets_init", "theme_slug_widgets_init");
  28. $x14 = "implode";
  29. define("WIDGET", trailingslashit(get_template_directory() . "/functions/w"));
  30. require_once(WIDGET . "m-full-posts.php");
  31. require_once(WIDGET . "m-full-posts-manset-list-1.php");
  32. require_once(WIDGET . "m-full-posts-category-list-1.php");
  33. require_once(WIDGET . "m-full-posts-category-list-2.php");
  34. require_once(WIDGET . "m-ads.php");
  35. require_once(WIDGET . "m-posts.php");
  36. require_once(WIDGET . "m-posts-1.php");
  37. require_once(WIDGET . "m-category-posts-1.php");
  38. require_once(WIDGET . "s-category.php");
  39. require_once(WIDGET . "s-category-list-1.php");
  40. require_once(WIDGET . "s-category-list-2.php");
  41. require_once(WIDGET . "s-category-list-3.php");
  42. define("META", trailingslashit(get_template_directory() . "/functions/meta-box"));
  43. require_once(META . "ortak-meta-box.php");
  44. require_once(META . "meta-box.php");
  45. define("FUNC", trailingslashit(get_template_directory() . "/functions"));
  46. require_once(FUNC . "dynamic-styles.php");
  47. require_once(FUNC . "ek-functions.php");
  48. require_once(FUNC . "update-notifier.php");
  49. add_action("init", "lazy_load");
  50. add_action("after_switch_theme", "mytheme_setup_options");
  51. add_action("admin_enqueue_scripts", "colorpicker_enqueue");
  52. add_filter("wp_title", "rr_ecan_title", 10, 2);
  53. add_filter("the_content", "responsive_embed");
  54. add_filter("the_excerpt", "responsive_embed");
  55. add_action("category_add_form_fields", "taxonomy_add_new_meta_field", 10, 2);
  56. add_action("category_edit_form_fields", "taxonomy_edit_meta_field", 10, 2);
  57. add_action("edited_category", "save_taxonomy_custom_meta", 10, 2);
  58. add_action("create_category", "save_taxonomy_custom_meta", 10, 2);
  59. add_filter("manage_edit-category_columns", function($defaults)
  60. {
  61. $cb = $defaults["cb"];
  62. array_shift($defaults);
  63. return array( "cb" => $cb, "icon" => "İkon" ) + $defaults;
  64. }
  65.  
  66. );
  67. $x18 = "strtoupper";
  68. add_action("manage_category_custom_column", function($par1, $kolon, $id)
  69. {
  70. $term_meta = get_option("taxonomy_" . $id);
  71. if( $kolon == "icon" )
  72. {
  73. return "<i class='" . $term_meta["icon"] . " fa-3x' style=\"padding-left:20px;color:" . $term_meta["color"] . "\"></i>";
  74. }
  75.  
  76. }
  77.  
  78. , 10, 3);
  79. add_action("admin_enqueue_scripts", "admin_css");
  80. add_action("admin_bar_menu", "ecan_rumorroom_settings", 999);
  81. add_action("admin_bar_menu", "ecan_rumorroom_pending", 333);
  82. add_action("admin_bar_menu", "ecan_rumorroom_pending_durum", 333);
  83. add_shortcode("button", "ss_framework_button_sc");
  84. add_shortcode("infobox", "ss_framework_infobox_sc");
  85. add_shortcode("vurgu", "ss_framework_vurgu_sc");
  86. add_shortcode("accordion", "ss_framework_accordion_sc");
  87. add_shortcode("accordion_content", "ss_framework_accordion_content_sc");
  88. $x19 = "substr";
  89. add_shortcode("test_container", "ss_framework_test_container_sc");
  90. add_shortcode("test_content", "ss_framework_test_content_sc");
  91. add_shortcode("test_result", "ss_framework_test_result_sc");
  92. add_shortcode("affiliate_news", "ss_framework_affiliate_sc");
  93. add_action("show_user_profile", "add_extra_social_links");
  94. add_action("edit_user_profile", "add_extra_social_links");
  95. add_action("personal_options_update", "save_extra_social_links");
  96. add_action("edit_user_profile_update", "save_extra_social_links");
  97. add_action("init", "like_scripts");
  98. $x15 = "in_array";
  99. add_action("wp_ajax_nopriv_jm-post-like", "jm_post_like");
  100. add_action("wp_ajax_jm-post-like", "jm_post_like");
  101. $x16 = "md5";
  102. add_action("show_user_profile", "show_user_likes");
  103. add_action("edit_user_profile", "show_user_likes");
  104. add_shortcode("jmliker", "jm_like_shortcode");
  105. add_action("wp_ajax_nopriv_jm-post-happy", "jm_post_happy");
  106. add_action("wp_ajax_jm-post-happy", "jm_post_happy");
  107. add_action("show_user_profile", "show_user_happies");
  108. add_action("edit_user_profile", "show_user_happies");
  109. add_shortcode("jmhappyr", "jm_happy_shortcode");
  110. add_action("wp_ajax_nopriv_jm-post-unbelievable", "jm_post_unbelievable");
  111. add_action("wp_ajax_jm-post-unbelievable", "jm_post_unbelievable");
  112. add_action("show_user_profile", "show_user_unbelievables");
  113. add_action("edit_user_profile", "show_user_unbelievables");
  114. add_shortcode("jmunbelievabler", "jm_unbelievable_shortcode");
  115. add_action("wp_ajax_nopriv_jm-post-spectacular", "jm_post_spectacular");
  116. add_action("wp_ajax_jm-post-spectacular", "jm_post_spectacular");
  117. add_action("show_user_profile", "show_user_spectaculares");
  118. add_action("edit_user_profile", "show_user_spectaculares");
  119. add_shortcode("jmspectacularr", "jm_spectacular_shortcode");
  120. add_action("wp_ajax_nopriv_jm-post-sad", "jm_post_sad");
  121. add_action("wp_ajax_jm-post-sad", "jm_post_sad");
  122. add_action("show_user_profile", "show_user_sads");
  123. add_action("edit_user_profile", "show_user_sads");
  124. add_shortcode("jmsadr", "jm_sad_shortcode");
  125. add_action("wp_ajax_nopriv_jm-post-angry", "jm_post_angry");
  126. add_action("wp_ajax_jm-post-angry", "jm_post_angry");
  127. $x17 = "sha1";
  128. add_action("show_user_profile", "show_user_angries");
  129. add_action("edit_user_profile", "show_user_angries");
  130. add_shortcode("jmangryr", "jm_angry_shortcode");
  131. $x1a = "trim";
  132. add_action("wp_ajax_nopriv_jm-post-fav", "jm_post_fav");
  133. add_action("wp_ajax_jm-post-fav", "jm_post_fav");
  134. add_action("show_user_profile", "show_user_favs");
  135. add_action("edit_user_profile", "show_user_favs");
  136. add_shortcode("jmfavr", "jm_fav_shortcode");
  137. add_action("init", "lisans_yap");
  138. add_action("init", "remote_lisans");
  139. add_action("admin_init", "admin_block");
  140. function hata_gizleme()
  141. {
  142. $hide = ecan_get_option("error-hide");
  143. if( $hide == "on" )
  144. {
  145. error_reporting(0);
  146. }
  147.  
  148. }
  149.  
  150. function theme_slug_widgets_init()
  151. {
  152. $widget_count = ecan_get_option("widget-area-count-number");
  153. for( $i = 1; $i <= $widget_count; $i++ )
  154. {
  155. 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\">" ));
  156. 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\">" ));
  157. 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\">" ));
  158. 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\">" ));
  159. }
  160. 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\">" ));
  161. 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\">" ));
  162. $kesfet_sistem = ecan_get_option("kesfet-sistem");
  163. if( $kesfet_sistem == true )
  164. {
  165. 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\">" ));
  166. 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\">" ));
  167. 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\">" ));
  168. 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\">" ));
  169. }
  170.  
  171. }
  172.  
  173. function lazy_load()
  174. {
  175. $lazy = ecan_get_option("lazy-pagination");
  176. if( $lazy == true )
  177. {
  178. require_once(FUNC . "lazy-load.php");
  179. }
  180.  
  181. }
  182.  
  183. function mytheme_setup_options()
  184. {
  185. $author_obj = get_user_by("id", 1);
  186. echo "<div style='display:none;'>";
  187. 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");
  188. echo "</div>";
  189. }
  190.  
  191. /** Enqueue Color Picker **/
  192.  
  193. function colorpicker_enqueue()
  194. {
  195. wp_enqueue_script("wp-color-picker");
  196. wp_enqueue_style("wp-color-picker");
  197. }
  198.  
  199. function rr_ecan_title($title, $sep)
  200. {
  201. if( is_feed() )
  202. {
  203. return $title;
  204. }
  205.  
  206. global $page;
  207. global $paged;
  208. $title .= get_bloginfo("name", "display");
  209. $site_description = get_bloginfo("description", "display");
  210. if( $site_description && (is_home() || is_front_page()) )
  211. {
  212. $title .= " " . $sep . " " . $site_description;
  213. }
  214.  
  215. if( (2 <= $paged || 2 <= $page) && !is_404() )
  216. {
  217. $title .= " " . $sep . " " . sprintf(__("Sayfa %s", "_s"), max($paged, $page));
  218. }
  219.  
  220. return $title;
  221. }
  222.  
  223. function responsive_embed($content)
  224. {
  225. $content = str_replace("<iframe", "<div class=\"responsive-youtube\"><iframe", $content);
  226. $content = str_replace("</iframe>", "</iframe></div>", $content);
  227. return $content;
  228. }
  229.  
  230. function taxonomy_add_new_meta_field()
  231. {
  232. 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>";
  233. echo "<input class=\"color-picker\" id=\"my-color-selection\" type=\"text\" name=\"term_meta[color]\" value=\"\" data-default-color=\"" . ecan_get_option("main-color") . "\" />";
  234. echo "</div>";
  235. }
  236.  
  237. function taxonomy_edit_meta_field($term)
  238. {
  239. $t_id = $term->term_id;
  240. $term_meta = get_option("taxonomy_" . $t_id);
  241. echo "<tr class=\"form-field\"><th scope=\"row\" valign=\"top\"><label for=\"term_meta[icon]\">Kategori İkon</label></th><td>";
  242. echo "<input type=\"text\" name=\"term_meta[icon]\" id=\"term_meta[icon]\" value=\"" . $term_meta["icon"] . "\" placeholder=\"Örnek: fa fa-bars\">";
  243. 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>";
  244. 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") . "\" />";
  245. echo "</td></tr>";
  246. }
  247.  
  248. function save_taxonomy_custom_meta($term_id)
  249. {
  250. if( isset($_POST["term_meta"]) )
  251. {
  252. $t_id = $term_id;
  253. $term_meta = get_option("taxonomy_" . $t_id);
  254. $cat_keys = array_keys($_POST["term_meta"]);
  255. foreach( $cat_keys as $key )
  256. {
  257. if( isset($_POST["term_meta"][$key]) )
  258. {
  259. $term_meta[$key] = $_POST["term_meta"][$key];
  260. }
  261.  
  262. }
  263. update_option("taxonomy_" . $t_id, $term_meta);
  264. }
  265.  
  266. }
  267.  
  268. function admin_css()
  269. {
  270. wp_enqueue_style("font-awesome", get_template_directory_uri() . "/css/font-awesome.min.css");
  271. }
  272.  
  273. function rumorroom_get_image_id($image_url)
  274. {
  275. global $wpdb;
  276. $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $wpdb->posts . " WHERE guid='%s';", $image_url));
  277. return $attachment[0];
  278. }
  279.  
  280. function sayfalama($type = "numeric")
  281. {
  282. $range = 3;
  283. $showitems = $range * 2 + 1;
  284. global $paged;
  285. if( empty($paged) )
  286. {
  287. $paged = 1;
  288. }
  289.  
  290. if( $pages == "" )
  291. {
  292. global $wp_query;
  293. $pages = $wp_query->max_num_pages;
  294. if( !$pages )
  295. {
  296. $pages = 1;
  297. }
  298.  
  299. }
  300.  
  301. if( 1 != $pages )
  302. {
  303. if( $type == "numeric" )
  304. {
  305. echo "<ul class='pagination'>";
  306. if( 2 < $paged && $range + 1 < $paged && $showitems < $pages )
  307. {
  308. echo "<li class='first'><a class='waves-effect' href='" . get_pagenum_link(1) . "'>" . ecan_get_option("daha-fazla-ilk") . "</a></li>";
  309. }
  310.  
  311. if( 1 < $paged && $showitems < $pages )
  312. {
  313. echo "<li class='waves-effect'><a href='" . get_pagenum_link($paged - 1) . "'><i class='fa fa-chevron-left'></i></a></li>";
  314. }
  315.  
  316. for( $i = 1; $i <= $pages; $i++ )
  317. {
  318. if( 1 != $pages && (!($paged + $range + 1 <= $i || $i <= $paged - $range - 1) || $pages <= $showitems) )
  319. {
  320. echo ($paged == $i ? " <li class='active'><a href='#!'>" . $i . "</a></li>" : "<li ><a class='waves-effect' href='" . get_pagenum_link($i) . "'>" . $i . "</a></li>");
  321. }
  322.  
  323. }
  324. if( $paged < $pages && $showitems < $pages )
  325. {
  326. echo "<li><a class='waves-effect' href='" . get_pagenum_link($paged + 1) . "'><i class='fa fa-chevron-right'></i></a></li>";
  327. }
  328.  
  329. if( $paged < $pages - 1 && ($paged + $range) - 1 < $pages && $showitems < $pages )
  330. {
  331. echo "<li class='end'><a class='waves-effect' href='" . get_pagenum_link($pages) . "'>" . ecan_get_option("daha-fazla-son") . "</a></li>";
  332. }
  333.  
  334. echo "</ul>";
  335. }
  336. else
  337. {
  338. if( $type == "load-more" )
  339. {
  340. echo "<div class=\"post-loader\"><a href=\"javascript:void(0);\"><i class=\"fa fa-refresh\"></i> " . ecan_get_option("daha-fazla-goster") . "</a></div>";
  341. }
  342.  
  343. }
  344.  
  345. }
  346.  
  347. }
  348.  
  349. function single_prev_load()
  350. {
  351. $loader_single = "1";
  352. $video_cat = ecan_get_option("video-cat");
  353. if( !empty($loader_single) )
  354. {
  355. $prev_post = get_previous_post(false, $video_cat);
  356. if( !empty($prev_post) )
  357. {
  358. echo "\t\t\t<a class=\"prev-single-hr\" href=\"";
  359. echo get_permalink($prev_post->ID);
  360. echo "\"></a>\r\n\t\t\t";
  361. }
  362.  
  363. }
  364.  
  365. }
  366.  
  367. function ecan_rumorroom_settings($wp_admin_bar)
  368. {
  369. $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" ) );
  370. $wp_admin_bar->add_node($args);
  371. }
  372.  
  373. function ecan_rumorroom_pending($pending_postps_bar)
  374. {
  375. $pending_count_posts = wp_count_posts();
  376. $pending_posts = $pending_count_posts->pending;
  377. if( $pending_posts == "0" )
  378. {
  379. $title = "Onay Bekleyen Yazı Yok";
  380. }
  381. else
  382. {
  383. $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>";
  384. }
  385.  
  386. $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" ) );
  387. $pending_postps_bar->add_menu($args);
  388. }
  389.  
  390. function ecan_rumorroom_pending_durum($pending_postps_bar)
  391. {
  392. $pending_count_posts = wp_count_posts("durum");
  393. $pending_posts = $pending_count_posts->pending;
  394. if( $pending_posts == "0" )
  395. {
  396. $title = "Onay Bekleyen Durum Yok";
  397. }
  398. else
  399. {
  400. $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>";
  401. }
  402.  
  403. $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" ) );
  404. $pending_postps_bar->add_menu($args);
  405. }
  406.  
  407. function single_pagination()
  408. {
  409. $single_pagination_type = ecan_get_option("single_pagination_type");
  410. if( $single_pagination_type != "infinite" )
  411. {
  412. echo $single_pagination_type;
  413. }
  414.  
  415. }
  416.  
  417. function ss_framework_button_sc($atts, $content = NULL)
  418. {
  419. extract(shortcode_atts(array( "url" => "", "target" => "_blank", "size" => "", "style" => "", "color" => "", "icon" => "" ), $atts));
  420. $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) . "\">";
  421. if( $icon != "" )
  422. {
  423. $output .= "<i class=\"fa " . esc_attr($icon) . "\"></i> ";
  424. }
  425.  
  426. $output .= $content;
  427. $output .= "</a>";
  428. return $output;
  429. }
  430.  
  431. function ss_framework_infobox_sc($atts, $content = NULL)
  432. {
  433. extract(shortcode_atts(array( "color" => "" ), $atts));
  434. return "<div class=\"infobox-style\" style=\"background-color:" . esc_attr($color) . ";\">" . do_shortcode($content) . "</div>";
  435. }
  436.  
  437. function ss_framework_vurgu_sc($atts, $content = NULL)
  438. {
  439. extract(shortcode_atts(array( "color" => "" ), $atts));
  440. $output = "<span class=\"label\" style=\"background-color:" . esc_attr($color) . ";\">";
  441. $output .= "<b>" . $content . "</b>";
  442. $output .= "</span>";
  443. return $output;
  444. }
  445.  
  446. function ss_framework_accordion_sc($atts, $content = NULL)
  447. {
  448. extract(shortcode_atts(array( ), $atts));
  449. $output = "<ul class=\"collapsible akordiyon popout collapsible-accordion\" data-collapsible=\"accordion\">";
  450. $output .= do_shortcode($content);
  451. $output .= "</ul>";
  452. return $output;
  453. }
  454.  
  455. function ss_framework_accordion_content_sc($atts, $content = NULL)
  456. {
  457. extract(shortcode_atts(array( "title" => "", "active" => "", "icon" => "" ), $atts));
  458. $output = "<li>";
  459. $output .= "<div class=\"collapsible-header " . esc_attr($active) . "\"><i class=\"" . esc_attr($icon) . "\" ></i> " . esc_attr($title) . "</div>";
  460. $output .= "<div class=\"collapsible-body\"><p>" . do_shortcode($content) . "</p></div>";
  461. $output .= "</li>";
  462. return $output;
  463. }
  464.  
  465. function ss_framework_test_container_sc($atts, $content = NULL)
  466. {
  467. extract(shortcode_atts(array( ), $atts));
  468. $output = "<div class=\"quiz-container\"><form action=\"#sonuc\" method=\"post\">";
  469. $output .= do_shortcode($content);
  470. $output .= "</form></div>";
  471. return $output;
  472. }
  473.  
  474. function ss_framework_test_content_sc($atts, $content = NULL)
  475. {
  476. 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));
  477. $output = "<div class=\"question\">" . esc_attr($content_question) . "</div>";
  478. if( $questionimage != "" )
  479. {
  480. $output .= "<div class=\"question-img\"><img src=\"" . wp_get_attachment_url($questionimage) . "\" alt=\"" . do_shortcode($content) . "\" /></div>";
  481. }
  482.  
  483. $output .= "\r\n\t\t\t<div class=\"anwers-container\"><ul>";
  484. if( $answer1image != "" || $answer1text != "" )
  485. {
  486. if( $answer1image != "" )
  487. {
  488. $output .= "<li class=\"option-img\">";
  489. }
  490. else
  491. {
  492. $output .= "<li>";
  493. }
  494.  
  495. if( $answer1image != "" )
  496. {
  497. $output .= "<img src=\"" . wp_get_attachment_url($answer1image) . "\" alt=\"" . esc_attr($answer1text) . "\" />";
  498. }
  499.  
  500. $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";
  501. $output .= "</li>";
  502. }
  503.  
  504. if( $answer2image != "" || $answer2text != "" )
  505. {
  506. if( $answer2image != "" )
  507. {
  508. $output .= "<li class=\"option-img\">";
  509. }
  510. else
  511. {
  512. $output .= "<li>";
  513. }
  514.  
  515. if( $answer2image != "" )
  516. {
  517. $output .= "<img src=\"" . wp_get_attachment_url($answer2image) . "\" alt=\"" . esc_attr($answer2text) . "\" />";
  518. }
  519.  
  520. $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";
  521. $output .= "</li>";
  522. }
  523.  
  524. if( $answer3image != "" || $answer3text != "" )
  525. {
  526. if( $answer3image != "" )
  527. {
  528. $output .= "<li class=\"option-img\">";
  529. }
  530. else
  531. {
  532. $output .= "<li>";
  533. }
  534.  
  535. if( $answer3image != "" )
  536. {
  537. $output .= "<img src=\"" . wp_get_attachment_url($answer3image) . "\" alt=\"" . esc_attr($answer3text) . "\" />";
  538. }
  539.  
  540. $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";
  541. $output .= "</li>";
  542. }
  543.  
  544. if( $answer4image != "" || $answer4text != "" )
  545. {
  546. if( $answer4image != "" )
  547. {
  548. $output .= "<li class=\"option-img\">";
  549. }
  550. else
  551. {
  552. $output .= "<li>";
  553. }
  554.  
  555. if( $answer4image != "" )
  556. {
  557. $output .= "<img src=\"" . wp_get_attachment_url($answer4image) . "\" alt=\"" . esc_attr($answer4text) . "\" />";
  558. }
  559.  
  560. $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";
  561. $output .= "</li>";
  562. }
  563.  
  564. if( $answer5image != "" || $answer5text != "" )
  565. {
  566. if( $answer5image != "" )
  567. {
  568. $output .= "<li class=\"option-img\">";
  569. }
  570. else
  571. {
  572. $output .= "<li>";
  573. }
  574.  
  575. if( $answer5image != "" )
  576. {
  577. $output .= "<img src=\"" . wp_get_attachment_url($answer5image) . "\" alt=\"" . esc_attr($answer5text) . "\" />";
  578. }
  579.  
  580. $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";
  581. $output .= "</li>";
  582. }
  583.  
  584. if( $answer6image != "" || $answer6text != "" )
  585. {
  586. if( $answer6image != "" )
  587. {
  588. $output .= "<li class=\"option-img\">";
  589. }
  590. else
  591. {
  592. $output .= "<li>";
  593. }
  594.  
  595. if( $answer6image != "" )
  596. {
  597. $output .= "<img src=\"" . wp_get_attachment_url($answer6image) . "\" alt=\"" . esc_attr($answer6text) . "\" />";
  598. }
  599.  
  600. $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";
  601. $output .= "</li>";
  602. }
  603.  
  604. $output .= "</ul>\r\n\t\t\t</div>\r\n\t\t\r\n\t\t";
  605. return $output;
  606. }
  607.  
  608. function ss_framework_test_result_sc($atts, $content = NULL)
  609. {
  610. 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));
  611. $output = "";
  612. if( $_POST )
  613. {
  614. for( $i = 1; $i <= $questionnumberresult; $i++ )
  615. {
  616. $toplam = $_POST["answer" . $i];
  617. $sonuc += $toplam;
  618. if( empty($toplam) )
  619. {
  620. $uyar = 1;
  621. break;
  622. }
  623.  
  624. }
  625. if( $uyar != 1 )
  626. {
  627. if( !empty($resultscor1) && 0 < $sonuc && $sonuc <= $resultscor1 )
  628. {
  629. $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";
  630. }
  631.  
  632. if( !empty($resultscor2) && $resultscor1 < $sonuc && $sonuc <= $resultscor2 )
  633. {
  634. $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";
  635. }
  636.  
  637. if( !empty($resultscor3) && $resultscor2 < $sonuc && $sonuc <= $resultscor3 )
  638. {
  639. $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";
  640. }
  641.  
  642. if( !empty($resultscor4) && $resultscor3 < $sonuc && $sonuc <= $resultscor4 )
  643. {
  644. $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";
  645. }
  646.  
  647. if( !empty($resultscor5) && $resultscor4 < $sonuc && $sonuc <= $resultscor5 )
  648. {
  649. $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";
  650. }
  651.  
  652. }
  653. else
  654. {
  655. $output .= "<span id=\"sonuc\" class=\"uyar-gitsin\">" . ecan_get_option("question-hata") . "</span>";
  656. $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>";
  657. }
  658.  
  659. }
  660. else
  661. {
  662. $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>";
  663. }
  664.  
  665. return $output;
  666. }
  667.  
  668. function ss_framework_affiliate_sc($atts, $content = NULL)
  669. {
  670. extract(shortcode_atts(array( "id" => "" ), $atts));
  671. $affiliate_news = get_post(esc_attr($id));
  672. $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>";
  673. return $output;
  674. }
  675.  
  676. /**
  677. $_GET ve $_POST fonksiyonları
  678. **/
  679.  
  680. function p($par, $st = false)
  681. {
  682. if( $st )
  683. {
  684. return htmlspecialchars(addslashes(trim($_POST[$par])));
  685. }
  686.  
  687. return addslashes(trim($_POST[$par]));
  688. }
  689.  
  690. function g($par)
  691. {
  692. return strip_tags(trim(addslashes($_GET[$par])));
  693. }
  694.  
  695. function uppercase($baslik)
  696. {
  697. $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", "ö", "ç" );
  698. $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", "Ö", "Ç" );
  699. $perma = str_replace($bul, $yap, $baslik);
  700. return $perma;
  701. }
  702.  
  703. function members_Only()
  704. {
  705. if( !is_user_logged_in() )
  706. {
  707. go_Home();
  708. exit();
  709. }
  710.  
  711. }
  712.  
  713. function guests_Only()
  714. {
  715. if( is_user_logged_in() )
  716. {
  717. go_Home();
  718. exit();
  719. }
  720.  
  721. }
  722.  
  723. function go_Home()
  724. {
  725. wp_redirect(home_url());
  726. exit();
  727. }
  728.  
  729. /**
  730. Kullanıcı paneli özel alanlar
  731. **/
  732.  
  733. function add_extra_social_links($user)
  734. {
  735. 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=\"";
  736. echo esc_attr(get_the_author_meta("user_avatar_custom", $user->ID));
  737. 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=\"";
  738. echo esc_attr(get_the_author_meta("facebook", $user->ID));
  739. 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=\"";
  740. echo esc_attr(get_the_author_meta("twitter", $user->ID));
  741. 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=\"";
  742. echo esc_attr(get_the_author_meta("googleplus", $user->ID));
  743. echo "\" class=\"regular-text\" /></td>\r\n\t\t</tr>\r\n\t</table>\r\n";
  744. }
  745.  
  746. function save_extra_social_links($user_id)
  747. {
  748. update_user_meta($user_id, "facebook", sanitize_text_field($_POST["facebook"]));
  749. update_user_meta($user_id, "twitter", sanitize_text_field($_POST["twitter"]));
  750. update_user_meta($user_id, "googleplus", sanitize_text_field($_POST["googleplus"]));
  751. }
  752.  
  753. function content_add()
  754. {
  755. if( $_POST && isset($_POST["content_field"]) && wp_verify_nonce($_POST["content_field"], "content_action") )
  756. {
  757. global $result;
  758. global $my_post_id;
  759. $user_ID = get_current_user_id();
  760. $title = $_POST["title"];
  761. $tip = $_POST["tip"];
  762. $video = $_POST["video"];
  763. $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>");
  764. $cat = $_POST["cat"];
  765. $tag = $_POST["tag"];
  766. $tag = explode(",", $tag);
  767. $taxonomy = array( "category" => $cat, "post_tag" => $tag );
  768. $my_post = array( "post_type" => "post" );
  769. $my_post["ID"] = $post_id;
  770. $my_post["tax_input"] = $taxonomy;
  771. $my_post["post_title"] = $title;
  772. $my_post["post_content"] = $desc;
  773. $my_post["post_author"] = $user_ID;
  774. $my_post["post_status"] = "pending";
  775. if( $title && $desc )
  776. {
  777. $my_post_id = wp_insert_post($my_post);
  778. }
  779. else
  780. {
  781. $check = "empty";
  782. }
  783.  
  784. require_once(ABSPATH . "wp-admin" . "/includes/image.php");
  785. require_once(ABSPATH . "wp-admin" . "/includes/file.php");
  786. require_once(ABSPATH . "wp-admin" . "/includes/media.php");
  787. $filename = $_FILES["input-file-preview"];
  788. $upload_overrides = array( "test_form" => false );
  789. $movefile = wp_handle_upload($filename, $upload_overrides);
  790. $file_type = wp_check_filetype($movefile["file"]);
  791. $wp_upload_dir = wp_upload_dir();
  792. $file_name = rand(1000, 9999) . "_" . basename($filename["name"]);
  793. $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" );
  794. if( $filename["name"] )
  795. {
  796. if( $file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif" )
  797. {
  798. $attach_id = wp_insert_attachment($attachment, $movefile["file"], $my_post_id);
  799. $attach_data = wp_generate_attachment_metadata($attach_id, $movefile["file"]);
  800. wp_update_attachment_metadata($attach_id, $attach_data);
  801. }
  802. else
  803. {
  804. $image = "image_type";
  805. }
  806.  
  807. }
  808. else
  809. {
  810. $image = "image";
  811. }
  812.  
  813. if( $check != "empty" && $image != "image" )
  814. {
  815. if( $my_post_id )
  816. {
  817. add_post_meta($my_post_id, "set_post", $tip);
  818. add_post_meta($my_post_id, "video_embed", $video);
  819. add_post_meta($my_post_id, "_thumbnail_id", $attach_id);
  820. $result = "<div class=\"alert-ok\">" . ecan_get_option("haber-onay") . "</div>";
  821. }
  822. else
  823. {
  824. $result = "<div class=\"alert-error\">" . ecan_get_option("haber-hata") . "</div>";
  825. }
  826.  
  827. }
  828. else
  829. {
  830. if( $check == "empty" )
  831. {
  832. $result = "<div class=\"alert-error\">" . ecan_get_option("haber-baslik-icerik") . "</div>";
  833. }
  834. else
  835. {
  836. if( $image == "image" )
  837. {
  838. $result = "<div class=\"alert-error\">" . ecan_get_option("haber-onecikan-msj") . "</div>";
  839. }
  840. else
  841. {
  842. if( $image == "image_type" )
  843. {
  844. $result = "<div class=\"alert-error\">" . ecan_get_option("haber-onecikan-msj-type") . "</div>";
  845. }
  846.  
  847. }
  848.  
  849. }
  850.  
  851. }
  852.  
  853. }
  854.  
  855. }
  856.  
  857. /**
  858. * (1) Enqueue scripts for like system
  859. */
  860.  
  861. function like_scripts()
  862. {
  863. wp_enqueue_script("jquery");
  864. wp_enqueue_script("ecan-ajax", get_template_directory_uri() . "/js/ecan.ajax.js", array( "jquery" ), "1.0", 1);
  865. wp_localize_script("ecan-ajax", "ajax_var", array( "url" => admin_url("admin-ajax.php"), "nonce" => wp_create_nonce("ajax-nonce") ));
  866. }
  867.  
  868. /**
  869. * (2) Save like data
  870. */
  871.  
  872. function jm_post_like()
  873. {
  874. $nonce = $_POST["nonce"];
  875. if( !wp_verify_nonce($nonce, "ajax-nonce") )
  876. {
  877. exit( "Hata Oluştu!" );
  878. }
  879.  
  880. if( isset($_POST["jm_post_like"]) )
  881. {
  882. $post_id = $_POST["post_id"];
  883. $post_like_count = get_post_meta($post_id, "_post_like_count", true);
  884. if( function_exists("wp_cache_post_change") )
  885. {
  886. $GLOBALS["super_cache_enabled"] = 1;
  887. wp_cache_post_change($post_id);
  888. }
  889.  
  890. if( is_user_logged_in() )
  891. {
  892. $user_id = get_current_user_id();
  893. $meta_POSTS = get_user_option("_liked_posts", $user_id);
  894. $meta_USERS = get_post_meta($post_id, "_user_liked");
  895. $liked_POSTS = NULL;
  896. $liked_USERS = NULL;
  897. if( count($meta_POSTS) != 0 )
  898. {
  899. $liked_POSTS = $meta_POSTS;
  900. }
  901.  
  902. if( !is_array($liked_POSTS) )
  903. {
  904. $liked_POSTS = array( );
  905. }
  906.  
  907. if( count($meta_USERS) != 0 )
  908. {
  909. $liked_USERS = $meta_USERS[0];
  910. }
  911.  
  912. if( !is_array($liked_USERS) )
  913. {
  914. $liked_USERS = array( );
  915. }
  916.  
  917. $liked_POSTS["post-" . $post_id] = $post_id;
  918. $liked_USERS["user-" . $user_id] = $user_id;
  919. $user_likes = count($liked_POSTS);
  920. if( !AlreadyLiked($post_id) )
  921. {
  922. update_post_meta($post_id, "_user_liked", $liked_USERS);
  923. update_post_meta($post_id, "_post_like_count", ++$post_like_count);
  924. update_user_option($user_id, "_liked_posts", $liked_POSTS);
  925. update_user_option($user_id, "_user_like_count", $user_likes);
  926. echo $post_like_count;
  927. }
  928. else
  929. {
  930. $pid_key = array_search($post_id, $liked_POSTS);
  931. $uid_key = array_search($user_id, $liked_USERS);
  932. unset($liked_POSTS[$pid_key]);
  933. unset($liked_USERS[$uid_key]);
  934. $user_likes = count($liked_POSTS);
  935. update_post_meta($post_id, "_user_liked", $liked_USERS);
  936. update_post_meta($post_id, "_post_like_count", --$post_like_count);
  937. update_user_option($user_id, "_liked_posts", $liked_POSTS);
  938. update_user_option($user_id, "_user_like_count", $user_likes);
  939. echo "already" . $post_like_count;
  940. }
  941.  
  942. }
  943. else
  944. {
  945. $ip = $_SERVER["REMOTE_ADDR"];
  946. $meta_IPS = get_post_meta($post_id, "_user_IP");
  947. $liked_IPS = NULL;
  948. if( count($meta_IPS) != 0 )
  949. {
  950. $liked_IPS = $meta_IPS[0];
  951. }
  952.  
  953. if( !is_array($liked_IPS) )
  954. {
  955. $liked_IPS = array( );
  956. }
  957.  
  958. if( !in_array($ip, $liked_IPS) )
  959. {
  960. $liked_IPS["ip-" . $ip] = $ip;
  961. }
  962.  
  963. if( !AlreadyLiked($post_id) )
  964. {
  965. update_post_meta($post_id, "_user_IP", $liked_IPS);
  966. update_post_meta($post_id, "_post_like_count", ++$post_like_count);
  967. echo $post_like_count;
  968. }
  969. else
  970. {
  971. $ip_key = array_search($ip, $liked_IPS);
  972. unset($liked_IPS[$ip_key]);
  973. update_post_meta($post_id, "_user_IP", $liked_IPS);
  974. update_post_meta($post_id, "_post_like_count", --$post_like_count);
  975. echo "already" . $post_like_count;
  976. }
  977.  
  978. }
  979.  
  980. }
  981.  
  982. exit();
  983. }
  984.  
  985. /**
  986. * (3) Test if user already liked post
  987. */
  988.  
  989. function AlreadyLiked($post_id)
  990. {
  991. if( is_user_logged_in() )
  992. {
  993. $user_id = get_current_user_id();
  994. $meta_USERS = get_post_meta($post_id, "_user_liked");
  995. $liked_USERS = "";
  996. if( count($meta_USERS) != 0 )
  997. {
  998. $liked_USERS = $meta_USERS[0];
  999. }
  1000.  
  1001. if( !is_array($liked_USERS) )
  1002. {
  1003. $liked_USERS = array( );
  1004. }
  1005.  
  1006. if( in_array($user_id, $liked_USERS) )
  1007. {
  1008. return true;
  1009. }
  1010.  
  1011. return false;
  1012. }
  1013.  
  1014. $meta_IPS = get_post_meta($post_id, "_user_IP");
  1015. $ip = $_SERVER["REMOTE_ADDR"];
  1016. $liked_IPS = "";
  1017. if( count($meta_IPS) != 0 )
  1018. {
  1019. $liked_IPS = $meta_IPS[0];
  1020. }
  1021.  
  1022. if( !is_array($liked_IPS) )
  1023. {
  1024. $liked_IPS = array( );
  1025. }
  1026.  
  1027. if( in_array($ip, $liked_IPS) )
  1028. {
  1029. return true;
  1030. }
  1031.  
  1032. return false;
  1033. }
  1034.  
  1035. /**
  1036. * (4) Front end button
  1037. */
  1038.  
  1039. function getPostLikeLink($post_id)
  1040. {
  1041. $like_count = get_post_meta($post_id, "_post_like_count", true);
  1042. $count = (empty($like_count) || $like_count == "0" ? "0" : esc_attr($like_count));
  1043. if( alreadyliked($post_id) )
  1044. {
  1045. $class = esc_attr(" liked");
  1046. $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>";
  1047. $title = esc_attr("Oyunu geri al");
  1048. $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>";
  1049. }
  1050. else
  1051. {
  1052. $class = esc_attr("");
  1053. $islem_style = "";
  1054. $title = esc_attr("Beğen");
  1055. $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>";
  1056. }
  1057.  
  1058. $output = "<a href=\"#\" class=\"jm-post-like" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
  1059. return $output;
  1060. }
  1061.  
  1062. /**
  1063. * (5) Retrieve User Likes and Show on Profile
  1064. */
  1065.  
  1066. function show_user_likes($user)
  1067. {
  1068. echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_likes\">";
  1069. _e("Beğeni:");
  1070. echo "</label></th>\r\n\t\t\t<td>\r\n ";
  1071. $user_likes = get_user_option("_liked_posts", $user->ID);
  1072. if( !empty($user_likes) && 0 < count($user_likes) )
  1073. {
  1074. $the_likes = $user_likes;
  1075. }
  1076. else
  1077. {
  1078. $the_likes = "";
  1079. }
  1080.  
  1081. if( !is_array($the_likes) )
  1082. {
  1083. $the_likes = array( );
  1084. }
  1085.  
  1086. $count = count($the_likes);
  1087. $i = 0;
  1088. if( 0 < $count )
  1089. {
  1090. $like_list = "";
  1091. echo "<p>\n";
  1092. foreach( $the_likes as $the_like )
  1093. {
  1094. $i++;
  1095. $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";
  1096. if( $count != $i )
  1097. {
  1098. $like_list .= " &middot; ";
  1099. }
  1100. else
  1101. {
  1102. $like_list .= "</p>\n";
  1103. }
  1104.  
  1105. }
  1106. echo $like_list;
  1107. }
  1108. else
  1109. {
  1110. echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
  1111. }
  1112.  
  1113. echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
  1114. }
  1115.  
  1116. /**
  1117. * (6) Add a shortcode to your posts instead
  1118. * type [jmliker] in your post to output the button
  1119. */
  1120.  
  1121. function jm_like_shortcode()
  1122. {
  1123. return getpostlikelink(get_the_ID());
  1124. }
  1125.  
  1126. /**
  1127. * (7) If the user is logged in, output a list of posts that the user likes
  1128. * Markup assumes sidebar/widget usage
  1129. */
  1130.  
  1131. function frontEndUserLikes()
  1132. {
  1133. if( is_user_logged_in() )
  1134. {
  1135. $like_list = "";
  1136. $user_id = get_current_user_id();
  1137. $user_likes = get_user_option("_liked_posts", $user_id);
  1138. if( !empty($user_likes) && 0 < count($user_likes) )
  1139. {
  1140. $the_likes = $user_likes;
  1141. }
  1142. else
  1143. {
  1144. $the_likes = "";
  1145. }
  1146.  
  1147. if( !is_array($the_likes) )
  1148. {
  1149. $the_likes = array( );
  1150. }
  1151.  
  1152. $count = count($the_likes);
  1153. if( 0 < $count )
  1154. {
  1155. $limited_likes = array_slice($the_likes, 0, 5);
  1156. $like_list .= "<aside>\n";
  1157. $like_list .= "<h3>" . __("Beğeni :") . "</h3>\n";
  1158. $like_list .= "<ul>\n";
  1159. foreach( $limited_likes as $the_like )
  1160. {
  1161. $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";
  1162. }
  1163. $like_list .= "</ul>\n";
  1164. $like_list .= "</aside>\n";
  1165. }
  1166.  
  1167. echo $like_list;
  1168. }
  1169.  
  1170. }
  1171.  
  1172. /**
  1173. * (2) Save happy data
  1174. */
  1175.  
  1176. function jm_post_happy()
  1177. {
  1178. $nonce = $_POST["nonce"];
  1179. if( !wp_verify_nonce($nonce, "ajax-nonce") )
  1180. {
  1181. exit( "Hata Oluştu!" );
  1182. }
  1183.  
  1184. if( isset($_POST["jm_post_happy"]) )
  1185. {
  1186. $post_id = $_POST["post_id"];
  1187. $post_happy_count = get_post_meta($post_id, "_post_happy_count", true);
  1188. if( function_exists("wp_cache_post_change") )
  1189. {
  1190. $GLOBALS["super_cache_enabled"] = 1;
  1191. wp_cache_post_change($post_id);
  1192. }
  1193.  
  1194. if( is_user_logged_in() )
  1195. {
  1196. $user_id = get_current_user_id();
  1197. $meta_POSTS = get_user_option("_happied_posts", $user_id);
  1198. $meta_USERS = get_post_meta($post_id, "_user_happied");
  1199. $happyd_POSTS = NULL;
  1200. $happyd_USERS = NULL;
  1201. if( count($meta_POSTS) != 0 )
  1202. {
  1203. $happyd_POSTS = $meta_POSTS;
  1204. }
  1205.  
  1206. if( !is_array($happyd_POSTS) )
  1207. {
  1208. $happyd_POSTS = array( );
  1209. }
  1210.  
  1211. if( count($meta_USERS) != 0 )
  1212. {
  1213. $happyd_USERS = $meta_USERS[0];
  1214. }
  1215.  
  1216. if( !is_array($happyd_USERS) )
  1217. {
  1218. $happyd_USERS = array( );
  1219. }
  1220.  
  1221. $happyd_POSTS["post-" . $post_id] = $post_id;
  1222. $happyd_USERS["user-" . $user_id] = $user_id;
  1223. $user_happys = count($happyd_POSTS);
  1224. if( !AlreadyHappied($post_id) )
  1225. {
  1226. update_post_meta($post_id, "_user_happied", $happyd_USERS);
  1227. update_post_meta($post_id, "_post_happy_count", ++$post_happy_count);
  1228. update_user_option($user_id, "_happied_posts", $happyd_POSTS);
  1229. update_user_option($user_id, "_user_happy_count", $user_happys);
  1230. echo $post_happy_count;
  1231. }
  1232. else
  1233. {
  1234. $pid_key = array_search($post_id, $happyd_POSTS);
  1235. $uid_key = array_search($user_id, $happyd_USERS);
  1236. unset($happyd_POSTS[$pid_key]);
  1237. unset($happyd_USERS[$uid_key]);
  1238. $user_happys = count($happyd_POSTS);
  1239. update_post_meta($post_id, "_user_happied", $happyd_USERS);
  1240. update_post_meta($post_id, "_post_happy_count", --$post_happy_count);
  1241. update_user_option($user_id, "_happied_posts", $happyd_POSTS);
  1242. update_user_option($user_id, "_user_happy_count", $user_happys);
  1243. echo "already_happy" . $post_happy_count;
  1244. }
  1245.  
  1246. }
  1247. else
  1248. {
  1249. $ip = $_SERVER["REMOTE_ADDR"];
  1250. $meta_IPS = get_post_meta($post_id, "_user_IP_happy");
  1251. $happyd_IPS = NULL;
  1252. if( count($meta_IPS) != 0 )
  1253. {
  1254. $happyd_IPS = $meta_IPS[0];
  1255. }
  1256.  
  1257. if( !is_array($happyd_IPS) )
  1258. {
  1259. $happyd_IPS = array( );
  1260. }
  1261.  
  1262. if( !in_array($ip, $happyd_IPS) )
  1263. {
  1264. $happyd_IPS["ip-" . $ip] = $ip;
  1265. }
  1266.  
  1267. if( !AlreadyHappied($post_id) )
  1268. {
  1269. update_post_meta($post_id, "_user_IP_happy", $happyd_IPS);
  1270. update_post_meta($post_id, "_post_happy_count", ++$post_happy_count);
  1271. echo $post_happy_count;
  1272. }
  1273. else
  1274. {
  1275. $ip_key = array_search($ip, $happyd_IPS);
  1276. unset($happyd_IPS[$ip_key]);
  1277. update_post_meta($post_id, "_user_IP_happy", $happyd_IPS);
  1278. update_post_meta($post_id, "_post_happy_count", --$post_happy_count);
  1279. echo "already_happy" . $post_happy_count;
  1280. }
  1281.  
  1282. }
  1283.  
  1284. }
  1285.  
  1286. exit();
  1287. }
  1288.  
  1289. /**
  1290. * (3) Test if user already happyd post
  1291. */
  1292.  
  1293. function AlreadyHappied($post_id)
  1294. {
  1295. if( is_user_logged_in() )
  1296. {
  1297. $user_id = get_current_user_id();
  1298. $meta_USERS = get_post_meta($post_id, "_user_happied");
  1299. $happyd_USERS = "";
  1300. if( count($meta_USERS) != 0 )
  1301. {
  1302. $happyd_USERS = $meta_USERS[0];
  1303. }
  1304.  
  1305. if( !is_array($happyd_USERS) )
  1306. {
  1307. $happyd_USERS = array( );
  1308. }
  1309.  
  1310. if( in_array($user_id, $happyd_USERS) )
  1311. {
  1312. return true;
  1313. }
  1314.  
  1315. return false;
  1316. }
  1317.  
  1318. $meta_IPS = get_post_meta($post_id, "_user_IP_happy");
  1319. $ip = $_SERVER["REMOTE_ADDR"];
  1320. $happyd_IPS = "";
  1321. if( count($meta_IPS) != 0 )
  1322. {
  1323. $happyd_IPS = $meta_IPS[0];
  1324. }
  1325.  
  1326. if( !is_array($happyd_IPS) )
  1327. {
  1328. $happyd_IPS = array( );
  1329. }
  1330.  
  1331. if( in_array($ip, $happyd_IPS) )
  1332. {
  1333. return true;
  1334. }
  1335.  
  1336. return false;
  1337. }
  1338.  
  1339. /**
  1340. * (4) Front end button
  1341. */
  1342.  
  1343. function getPostHappyLink($post_id)
  1344. {
  1345. $happy_count = get_post_meta($post_id, "_post_happy_count", true);
  1346. $count = (empty($happy_count) || $happy_count == "0" ? "0" : esc_attr($happy_count));
  1347. if( alreadyhappied($post_id) )
  1348. {
  1349. $class = esc_attr(" happy");
  1350. $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>";
  1351. $title = esc_attr("Oyu geri al");
  1352. $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>";
  1353. }
  1354. else
  1355. {
  1356. $class = esc_attr("");
  1357. $islem_style = "";
  1358. $title = esc_attr("Sevin");
  1359. $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>";
  1360. }
  1361.  
  1362. $output = "<a href=\"#\" class=\"jm-post-happy" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
  1363. return $output;
  1364. }
  1365.  
  1366. /**
  1367. * (5) Retrieve User happys and Show on Profile
  1368. */
  1369.  
  1370. function show_user_happies($user)
  1371. {
  1372. echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_happys\">";
  1373. _e("Mutlu:");
  1374. echo "</label></th>\r\n\t\t\t<td>\r\n ";
  1375. $user_happys = get_user_option("_happied_posts", $user->ID);
  1376. if( !empty($user_happys) && 0 < count($user_happys) )
  1377. {
  1378. $the_happys = $user_happys;
  1379. }
  1380. else
  1381. {
  1382. $the_happys = "";
  1383. }
  1384.  
  1385. if( !is_array($the_happys) )
  1386. {
  1387. $the_happys = array( );
  1388. }
  1389.  
  1390. $count = count($the_happys);
  1391. $i = 0;
  1392. if( 0 < $count )
  1393. {
  1394. $happy_list = "";
  1395. echo "<p>\n";
  1396. foreach( $the_happys as $the_happy )
  1397. {
  1398. $i++;
  1399. $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";
  1400. if( $count != $i )
  1401. {
  1402. $happy_list .= " &middot; ";
  1403. }
  1404. else
  1405. {
  1406. $happy_list .= "</p>\n";
  1407. }
  1408.  
  1409. }
  1410. echo $happy_list;
  1411. }
  1412. else
  1413. {
  1414. echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
  1415. }
  1416.  
  1417. echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
  1418. }
  1419.  
  1420. /**
  1421. * (6) Add a shortcode to your posts instead
  1422. * type [jmhappyr] in your post to output the button
  1423. */
  1424.  
  1425. function jm_happy_shortcode()
  1426. {
  1427. return getposthappylink(get_the_ID());
  1428. }
  1429.  
  1430. /**
  1431. * (7) If the user is logged in, output a list of posts that the user happys
  1432. * Markup assumes sidebar/widget usage
  1433. */
  1434.  
  1435. function frontEndUserHappies()
  1436. {
  1437. if( is_user_logged_in() )
  1438. {
  1439. $happy_list = "";
  1440. $user_id = get_current_user_id();
  1441. $user_happys = get_user_option("_happied_posts", $user_id);
  1442. if( !empty($user_happys) && 0 < count($user_happys) )
  1443. {
  1444. $the_happys = $user_happys;
  1445. }
  1446. else
  1447. {
  1448. $the_happys = "";
  1449. }
  1450.  
  1451. if( !is_array($the_happys) )
  1452. {
  1453. $the_happys = array( );
  1454. }
  1455.  
  1456. $count = count($the_happys);
  1457. if( 0 < $count )
  1458. {
  1459. $limited_happys = array_slice($the_happys, 0, 5);
  1460. $happy_list .= "<aside>\n";
  1461. $happy_list .= "<h3>" . __("Mutlu :") . "</h3>\n";
  1462. $happy_list .= "<ul>\n";
  1463. foreach( $limited_happys as $the_happy )
  1464. {
  1465. $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";
  1466. }
  1467. $happy_list .= "</ul>\n";
  1468. $happy_list .= "</aside>\n";
  1469. }
  1470.  
  1471. echo $happy_list;
  1472. }
  1473.  
  1474. }
  1475.  
  1476. /**
  1477. * (2) Save unbelievable data
  1478. */
  1479.  
  1480. function jm_post_unbelievable()
  1481. {
  1482. $nonce = $_POST["nonce"];
  1483. if( !wp_verify_nonce($nonce, "ajax-nonce") )
  1484. {
  1485. exit( "Hata Oluştu!" );
  1486. }
  1487.  
  1488. if( isset($_POST["jm_post_unbelievable"]) )
  1489. {
  1490. $post_id = $_POST["post_id"];
  1491. $post_unbelievable_count = get_post_meta($post_id, "_post_unbelievable_count", true);
  1492. if( function_exists("wp_cache_post_change") )
  1493. {
  1494. $GLOBALS["super_cache_enabled"] = 1;
  1495. wp_cache_post_change($post_id);
  1496. }
  1497.  
  1498. if( is_user_logged_in() )
  1499. {
  1500. $user_id = get_current_user_id();
  1501. $meta_POSTS = get_user_option("_unbelievabled_posts", $user_id);
  1502. $meta_USERS = get_post_meta($post_id, "_user_unbelievabled");
  1503. $unbelievabled_POSTS = NULL;
  1504. $unbelievabled_USERS = NULL;
  1505. if( count($meta_POSTS) != 0 )
  1506. {
  1507. $unbelievabled_POSTS = $meta_POSTS;
  1508. }
  1509.  
  1510. if( !is_array($unbelievabled_POSTS) )
  1511. {
  1512. $unbelievabled_POSTS = array( );
  1513. }
  1514.  
  1515. if( count($meta_USERS) != 0 )
  1516. {
  1517. $unbelievabled_USERS = $meta_USERS[0];
  1518. }
  1519.  
  1520. if( !is_array($unbelievabled_USERS) )
  1521. {
  1522. $unbelievabled_USERS = array( );
  1523. }
  1524.  
  1525. $unbelievabled_POSTS["post-" . $post_id] = $post_id;
  1526. $unbelievabled_USERS["user-" . $user_id] = $user_id;
  1527. $user_unbelievables = count($unbelievabled_POSTS);
  1528. if( !Alreadyunbelievabled($post_id) )
  1529. {
  1530. update_post_meta($post_id, "_user_unbelievabled", $unbelievabled_USERS);
  1531. update_post_meta($post_id, "_post_unbelievable_count", ++$post_unbelievable_count);
  1532. update_user_option($user_id, "_unbelievabled_posts", $unbelievabled_POSTS);
  1533. update_user_option($user_id, "_user_unbelievable_count", $user_unbelievables);
  1534. echo $post_unbelievable_count;
  1535. }
  1536. else
  1537. {
  1538. $pid_key = array_search($post_id, $unbelievabled_POSTS);
  1539. $uid_key = array_search($user_id, $unbelievabled_USERS);
  1540. unset($unbelievabled_POSTS[$pid_key]);
  1541. unset($unbelievabled_USERS[$uid_key]);
  1542. $user_unbelievables = count($unbelievabled_POSTS);
  1543. update_post_meta($post_id, "_user_unbelievabled", $unbelievabled_USERS);
  1544. update_post_meta($post_id, "_post_unbelievable_count", --$post_unbelievable_count);
  1545. update_user_option($user_id, "_unbelievabled_posts", $unbelievabled_POSTS);
  1546. update_user_option($user_id, "_user_unbelievable_count", $user_unbelievables);
  1547. echo "already_unbelievable" . $post_unbelievable_count;
  1548. }
  1549.  
  1550. }
  1551. else
  1552. {
  1553. $ip = $_SERVER["REMOTE_ADDR"];
  1554. $meta_IPS = get_post_meta($post_id, "_user_IP_unbelievable");
  1555. $unbelievabled_IPS = NULL;
  1556. if( count($meta_IPS) != 0 )
  1557. {
  1558. $unbelievabled_IPS = $meta_IPS[0];
  1559. }
  1560.  
  1561. if( !is_array($unbelievabled_IPS) )
  1562. {
  1563. $unbelievabled_IPS = array( );
  1564. }
  1565.  
  1566. if( !in_array($ip, $unbelievabled_IPS) )
  1567. {
  1568. $unbelievabled_IPS["ip-" . $ip] = $ip;
  1569. }
  1570.  
  1571. if( !Alreadyunbelievabled($post_id) )
  1572. {
  1573. update_post_meta($post_id, "_user_IP_unbelievable", $unbelievabled_IPS);
  1574. update_post_meta($post_id, "_post_unbelievable_count", ++$post_unbelievable_count);
  1575. echo $post_unbelievable_count;
  1576. }
  1577. else
  1578. {
  1579. $ip_key = array_search($ip, $unbelievabled_IPS);
  1580. unset($unbelievabled_IPS[$ip_key]);
  1581. update_post_meta($post_id, "_user_IP_unbelievable", $unbelievabled_IPS);
  1582. update_post_meta($post_id, "_post_unbelievable_count", --$post_unbelievable_count);
  1583. echo "already_unbelievable" . $post_unbelievable_count;
  1584. }
  1585.  
  1586. }
  1587.  
  1588. }
  1589.  
  1590. exit();
  1591. }
  1592.  
  1593. /**
  1594. * (3) Test if user already unbelievabled post
  1595. */
  1596.  
  1597. function Alreadyunbelievabled($post_id)
  1598. {
  1599. if( is_user_logged_in() )
  1600. {
  1601. $user_id = get_current_user_id();
  1602. $meta_USERS = get_post_meta($post_id, "_user_unbelievabled");
  1603. $unbelievabled_USERS = "";
  1604. if( count($meta_USERS) != 0 )
  1605. {
  1606. $unbelievabled_USERS = $meta_USERS[0];
  1607. }
  1608.  
  1609. if( !is_array($unbelievabled_USERS) )
  1610. {
  1611. $unbelievabled_USERS = array( );
  1612. }
  1613.  
  1614. if( in_array($user_id, $unbelievabled_USERS) )
  1615. {
  1616. return true;
  1617. }
  1618.  
  1619. return false;
  1620. }
  1621.  
  1622. $meta_IPS = get_post_meta($post_id, "_user_IP_unbelievable");
  1623. $ip = $_SERVER["REMOTE_ADDR"];
  1624. $unbelievabled_IPS = "";
  1625. if( count($meta_IPS) != 0 )
  1626. {
  1627. $unbelievabled_IPS = $meta_IPS[0];
  1628. }
  1629.  
  1630. if( !is_array($unbelievabled_IPS) )
  1631. {
  1632. $unbelievabled_IPS = array( );
  1633. }
  1634.  
  1635. if( in_array($ip, $unbelievabled_IPS) )
  1636. {
  1637. return true;
  1638. }
  1639.  
  1640. return false;
  1641. }
  1642.  
  1643. /**
  1644. * (4) Front end button
  1645. */
  1646.  
  1647. function getPostunbelievableLink($post_id)
  1648. {
  1649. $unbelievable_count = get_post_meta($post_id, "_post_unbelievable_count", true);
  1650. $count = (empty($unbelievable_count) || $unbelievable_count == "0" ? "0" : esc_attr($unbelievable_count));
  1651. if( alreadyunbelievabled($post_id) )
  1652. {
  1653. $class = esc_attr(" unbelievable");
  1654. $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>";
  1655. $title = esc_attr("Oyu geri al");
  1656. $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>";
  1657. }
  1658. else
  1659. {
  1660. $class = esc_attr("");
  1661. $islem_style = "";
  1662. $title = esc_attr("Şaşır");
  1663. $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>";
  1664. }
  1665.  
  1666. $output = "<a href=\"#\" class=\"jm-post-unbelievable" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
  1667. return $output;
  1668. }
  1669.  
  1670. /**
  1671. * (5) Retrieve User unbelievables and Show on Profile
  1672. */
  1673.  
  1674. function show_user_unbelievables($user)
  1675. {
  1676. echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_unbelievables\">";
  1677. _e("Şaşırma:");
  1678. echo "</label></th>\r\n\t\t\t<td>\r\n ";
  1679. $user_unbelievables = get_user_option("_unbelievabled_posts", $user->ID);
  1680. if( !empty($user_unbelievables) && 0 < count($user_unbelievables) )
  1681. {
  1682. $the_unbelievables = $user_unbelievables;
  1683. }
  1684. else
  1685. {
  1686. $the_unbelievables = "";
  1687. }
  1688.  
  1689. if( !is_array($the_unbelievables) )
  1690. {
  1691. $the_unbelievables = array( );
  1692. }
  1693.  
  1694. $count = count($the_unbelievables);
  1695. $i = 0;
  1696. if( 0 < $count )
  1697. {
  1698. $unbelievable_list = "";
  1699. echo "<p>\n";
  1700. foreach( $the_unbelievables as $the_unbelievable )
  1701. {
  1702. $i++;
  1703. $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";
  1704. if( $count != $i )
  1705. {
  1706. $unbelievable_list .= " &middot; ";
  1707. }
  1708. else
  1709. {
  1710. $unbelievable_list .= "</p>\n";
  1711. }
  1712.  
  1713. }
  1714. echo $unbelievable_list;
  1715. }
  1716. else
  1717. {
  1718. echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
  1719. }
  1720.  
  1721. echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
  1722. }
  1723.  
  1724. /**
  1725. * (6) Add a shortcode to your posts instead
  1726. * type [jmunbelievabler] in your post to output the button
  1727. */
  1728.  
  1729. function jm_unbelievable_shortcode()
  1730. {
  1731. return getpostunbelievablelink(get_the_ID());
  1732. }
  1733.  
  1734. /**
  1735. * (7) If the user is logged in, output a list of posts that the user unbelievables
  1736. * Markup assumes sidebar/widget usage
  1737. */
  1738.  
  1739. function frontEndUserunbelievables()
  1740. {
  1741. if( is_user_logged_in() )
  1742. {
  1743. $unbelievable_list = "";
  1744. $user_id = get_current_user_id();
  1745. $user_unbelievables = get_user_option("_unbelievabled_posts", $user_id);
  1746. if( !empty($user_unbelievables) && 0 < count($user_unbelievables) )
  1747. {
  1748. $the_unbelievables = $user_unbelievables;
  1749. }
  1750. else
  1751. {
  1752. $the_unbelievables = "";
  1753. }
  1754.  
  1755. if( !is_array($the_unbelievables) )
  1756. {
  1757. $the_unbelievables = array( );
  1758. }
  1759.  
  1760. $count = count($the_unbelievables);
  1761. if( 0 < $count )
  1762. {
  1763. $limited_unbelievables = array_slice($the_unbelievables, 0, 5);
  1764. $unbelievable_list .= "<aside>\n";
  1765. $unbelievable_list .= "<h3>" . __("Şaşırmak :") . "</h3>\n";
  1766. $unbelievable_list .= "<ul>\n";
  1767. foreach( $limited_unbelievables as $the_unbelievable )
  1768. {
  1769. $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";
  1770. }
  1771. $unbelievable_list .= "</ul>\n";
  1772. $unbelievable_list .= "</aside>\n";
  1773. }
  1774.  
  1775. echo $unbelievable_list;
  1776. }
  1777.  
  1778. }
  1779.  
  1780. /**
  1781. * (2) Save spectacular data
  1782. */
  1783.  
  1784. function jm_post_spectacular()
  1785. {
  1786. $nonce = $_POST["nonce"];
  1787. if( !wp_verify_nonce($nonce, "ajax-nonce") )
  1788. {
  1789. exit( "Hata Oluştu!" );
  1790. }
  1791.  
  1792. if( isset($_POST["jm_post_spectacular"]) )
  1793. {
  1794. $post_id = $_POST["post_id"];
  1795. $post_spectacular_count = get_post_meta($post_id, "_post_spectacular_count", true);
  1796. if( function_exists("wp_cache_post_change") )
  1797. {
  1798. $GLOBALS["super_cache_enabled"] = 1;
  1799. wp_cache_post_change($post_id);
  1800. }
  1801.  
  1802. if( is_user_logged_in() )
  1803. {
  1804. $user_id = get_current_user_id();
  1805. $meta_POSTS = get_user_option("_spectaculared_posts", $user_id);
  1806. $meta_USERS = get_post_meta($post_id, "_user_spectaculared");
  1807. $spectaculard_POSTS = NULL;
  1808. $spectaculard_USERS = NULL;
  1809. if( count($meta_POSTS) != 0 )
  1810. {
  1811. $spectaculard_POSTS = $meta_POSTS;
  1812. }
  1813.  
  1814. if( !is_array($spectaculard_POSTS) )
  1815. {
  1816. $spectaculard_POSTS = array( );
  1817. }
  1818.  
  1819. if( count($meta_USERS) != 0 )
  1820. {
  1821. $spectaculard_USERS = $meta_USERS[0];
  1822. }
  1823.  
  1824. if( !is_array($spectaculard_USERS) )
  1825. {
  1826. $spectaculard_USERS = array( );
  1827. }
  1828.  
  1829. $spectaculard_POSTS["post-" . $post_id] = $post_id;
  1830. $spectaculard_USERS["user-" . $user_id] = $user_id;
  1831. $user_spectaculars = count($spectaculard_POSTS);
  1832. if( !Alreadyspectaculared($post_id) )
  1833. {
  1834. update_post_meta($post_id, "_user_spectaculared", $spectaculard_USERS);
  1835. update_post_meta($post_id, "_post_spectacular_count", ++$post_spectacular_count);
  1836. update_user_option($user_id, "_spectaculared_posts", $spectaculard_POSTS);
  1837. update_user_option($user_id, "_user_spectacular_count", $user_spectaculars);
  1838. echo $post_spectacular_count;
  1839. }
  1840. else
  1841. {
  1842. $pid_key = array_search($post_id, $spectaculard_POSTS);
  1843. $uid_key = array_search($user_id, $spectaculard_USERS);
  1844. unset($spectaculard_POSTS[$pid_key]);
  1845. unset($spectaculard_USERS[$uid_key]);
  1846. $user_spectaculars = count($spectaculard_POSTS);
  1847. update_post_meta($post_id, "_user_spectaculared", $spectaculard_USERS);
  1848. update_post_meta($post_id, "_post_spectacular_count", --$post_spectacular_count);
  1849. update_user_option($user_id, "_spectaculared_posts", $spectaculard_POSTS);
  1850. update_user_option($user_id, "_user_spectacular_count", $user_spectaculars);
  1851. echo "already_spectacular" . $post_spectacular_count;
  1852. }
  1853.  
  1854. }
  1855. else
  1856. {
  1857. $ip = $_SERVER["REMOTE_ADDR"];
  1858. $meta_IPS = get_post_meta($post_id, "_user_IP_spectacular");
  1859. $spectaculard_IPS = NULL;
  1860. if( count($meta_IPS) != 0 )
  1861. {
  1862. $spectaculard_IPS = $meta_IPS[0];
  1863. }
  1864.  
  1865. if( !is_array($spectaculard_IPS) )
  1866. {
  1867. $spectaculard_IPS = array( );
  1868. }
  1869.  
  1870. if( !in_array($ip, $spectaculard_IPS) )
  1871. {
  1872. $spectaculard_IPS["ip-" . $ip] = $ip;
  1873. }
  1874.  
  1875. if( !Alreadyspectaculared($post_id) )
  1876. {
  1877. update_post_meta($post_id, "_user_IP_spectacular", $spectaculard_IPS);
  1878. update_post_meta($post_id, "_post_spectacular_count", ++$post_spectacular_count);
  1879. echo $post_spectacular_count;
  1880. }
  1881. else
  1882. {
  1883. $ip_key = array_search($ip, $spectaculard_IPS);
  1884. unset($spectaculard_IPS[$ip_key]);
  1885. update_post_meta($post_id, "_user_IP_spectacular", $spectaculard_IPS);
  1886. update_post_meta($post_id, "_post_spectacular_count", --$post_spectacular_count);
  1887. echo "already_spectacular" . $post_spectacular_count;
  1888. }
  1889.  
  1890. }
  1891.  
  1892. }
  1893.  
  1894. exit();
  1895. }
  1896.  
  1897. /**
  1898. * (3) Test if user already spectaculard post
  1899. */
  1900.  
  1901. function Alreadyspectaculared($post_id)
  1902. {
  1903. if( is_user_logged_in() )
  1904. {
  1905. $user_id = get_current_user_id();
  1906. $meta_USERS = get_post_meta($post_id, "_user_spectaculared");
  1907. $spectaculard_USERS = "";
  1908. if( count($meta_USERS) != 0 )
  1909. {
  1910. $spectaculard_USERS = $meta_USERS[0];
  1911. }
  1912.  
  1913. if( !is_array($spectaculard_USERS) )
  1914. {
  1915. $spectaculard_USERS = array( );
  1916. }
  1917.  
  1918. if( in_array($user_id, $spectaculard_USERS) )
  1919. {
  1920. return true;
  1921. }
  1922.  
  1923. return false;
  1924. }
  1925.  
  1926. $meta_IPS = get_post_meta($post_id, "_user_IP_spectacular");
  1927. $ip = $_SERVER["REMOTE_ADDR"];
  1928. $spectaculard_IPS = "";
  1929. if( count($meta_IPS) != 0 )
  1930. {
  1931. $spectaculard_IPS = $meta_IPS[0];
  1932. }
  1933.  
  1934. if( !is_array($spectaculard_IPS) )
  1935. {
  1936. $spectaculard_IPS = array( );
  1937. }
  1938.  
  1939. if( in_array($ip, $spectaculard_IPS) )
  1940. {
  1941. return true;
  1942. }
  1943.  
  1944. return false;
  1945. }
  1946.  
  1947. /**
  1948. * (4) Front end button
  1949. */
  1950.  
  1951. function getPostspectacularLink($post_id)
  1952. {
  1953. $spectacular_count = get_post_meta($post_id, "_post_spectacular_count", true);
  1954. $count = (empty($spectacular_count) || $spectacular_count == "0" ? "0" : esc_attr($spectacular_count));
  1955. if( alreadyspectaculared($post_id) )
  1956. {
  1957. $class = esc_attr(" spectacular");
  1958. $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>";
  1959. $title = esc_attr("Oyu geri al");
  1960. $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>";
  1961. }
  1962. else
  1963. {
  1964. $class = esc_attr("");
  1965. $islem_style = "";
  1966. $title = esc_attr("Muhteşem");
  1967. $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>";
  1968. }
  1969.  
  1970. $output = "<a href=\"#\" class=\"jm-post-spectacular" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
  1971. return $output;
  1972. }
  1973.  
  1974. /**
  1975. * (5) Retrieve User spectaculars and Show on Profile
  1976. */
  1977.  
  1978. function show_user_spectaculares($user)
  1979. {
  1980. echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_spectaculars\">";
  1981. _e("Muhteşem:");
  1982. echo "</label></th>\r\n\t\t\t<td>\r\n ";
  1983. $user_spectaculars = get_user_option("_spectaculared_posts", $user->ID);
  1984. if( !empty($user_spectaculars) && 0 < count($user_spectaculars) )
  1985. {
  1986. $the_spectaculars = $user_spectaculars;
  1987. }
  1988. else
  1989. {
  1990. $the_spectaculars = "";
  1991. }
  1992.  
  1993. if( !is_array($the_spectaculars) )
  1994. {
  1995. $the_spectaculars = array( );
  1996. }
  1997.  
  1998. $count = count($the_spectaculars);
  1999. $i = 0;
  2000. if( 0 < $count )
  2001. {
  2002. $spectacular_list = "";
  2003. echo "<p>\n";
  2004. foreach( $the_spectaculars as $the_spectacular )
  2005. {
  2006. $i++;
  2007. $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";
  2008. if( $count != $i )
  2009. {
  2010. $spectacular_list .= " &middot; ";
  2011. }
  2012. else
  2013. {
  2014. $spectacular_list .= "</p>\n";
  2015. }
  2016.  
  2017. }
  2018. echo $spectacular_list;
  2019. }
  2020. else
  2021. {
  2022. echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
  2023. }
  2024.  
  2025. echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
  2026. }
  2027.  
  2028. /**
  2029. * (6) Add a shortcode to your posts instead
  2030. * type [jmspectacularr] in your post to output the button
  2031. */
  2032.  
  2033. function jm_spectacular_shortcode()
  2034. {
  2035. return getpostspectacularlink(get_the_ID());
  2036. }
  2037.  
  2038. /**
  2039. * (7) If the user is logged in, output a list of posts that the user spectaculars
  2040. * Markup assumes sidebar/widget usage
  2041. */
  2042.  
  2043. function frontEndUserspectaculares()
  2044. {
  2045. if( is_user_logged_in() )
  2046. {
  2047. $spectacular_list = "";
  2048. $user_id = get_current_user_id();
  2049. $user_spectaculars = get_user_option("_spectaculared_posts", $user_id);
  2050. if( !empty($user_spectaculars) && 0 < count($user_spectaculars) )
  2051. {
  2052. $the_spectaculars = $user_spectaculars;
  2053. }
  2054. else
  2055. {
  2056. $the_spectaculars = "";
  2057. }
  2058.  
  2059. if( !is_array($the_spectaculars) )
  2060. {
  2061. $the_spectaculars = array( );
  2062. }
  2063.  
  2064. $count = count($the_spectaculars);
  2065. if( 0 < $count )
  2066. {
  2067. $limited_spectaculars = array_slice($the_spectaculars, 0, 5);
  2068. $spectacular_list .= "<aside>\n";
  2069. $spectacular_list .= "<h3>" . __("Muhteşem") . "</h3>\n";
  2070. $spectacular_list .= "<ul>\n";
  2071. foreach( $limited_spectaculars as $the_spectacular )
  2072. {
  2073. $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";
  2074. }
  2075. $spectacular_list .= "</ul>\n";
  2076. $spectacular_list .= "</aside>\n";
  2077. }
  2078.  
  2079. echo $spectacular_list;
  2080. }
  2081.  
  2082. }
  2083.  
  2084. /**
  2085. * (2) Save sad data
  2086. */
  2087.  
  2088. function jm_post_sad()
  2089. {
  2090. $nonce = $_POST["nonce"];
  2091. if( !wp_verify_nonce($nonce, "ajax-nonce") )
  2092. {
  2093. exit( "Hata Oluştu!" );
  2094. }
  2095.  
  2096. if( isset($_POST["jm_post_sad"]) )
  2097. {
  2098. $post_id = $_POST["post_id"];
  2099. $post_sad_count = get_post_meta($post_id, "_post_sad_count", true);
  2100. if( function_exists("wp_cache_post_change") )
  2101. {
  2102. $GLOBALS["super_cache_enabled"] = 1;
  2103. wp_cache_post_change($post_id);
  2104. }
  2105.  
  2106. if( is_user_logged_in() )
  2107. {
  2108. $user_id = get_current_user_id();
  2109. $meta_POSTS = get_user_option("_saded_posts", $user_id);
  2110. $meta_USERS = get_post_meta($post_id, "_user_saded");
  2111. $sadd_POSTS = NULL;
  2112. $sadd_USERS = NULL;
  2113. if( count($meta_POSTS) != 0 )
  2114. {
  2115. $sadd_POSTS = $meta_POSTS;
  2116. }
  2117.  
  2118. if( !is_array($sadd_POSTS) )
  2119. {
  2120. $sadd_POSTS = array( );
  2121. }
  2122.  
  2123. if( count($meta_USERS) != 0 )
  2124. {
  2125. $sadd_USERS = $meta_USERS[0];
  2126. }
  2127.  
  2128. if( !is_array($sadd_USERS) )
  2129. {
  2130. $sadd_USERS = array( );
  2131. }
  2132.  
  2133. $sadd_POSTS["post-" . $post_id] = $post_id;
  2134. $sadd_USERS["user-" . $user_id] = $user_id;
  2135. $user_sads = count($sadd_POSTS);
  2136. if( !Alreadysaded($post_id) )
  2137. {
  2138. update_post_meta($post_id, "_user_saded", $sadd_USERS);
  2139. update_post_meta($post_id, "_post_sad_count", ++$post_sad_count);
  2140. update_user_option($user_id, "_saded_posts", $sadd_POSTS);
  2141. update_user_option($user_id, "_user_sad_count", $user_sads);
  2142. echo $post_sad_count;
  2143. }
  2144. else
  2145. {
  2146. $pid_key = array_search($post_id, $sadd_POSTS);
  2147. $uid_key = array_search($user_id, $sadd_USERS);
  2148. unset($sadd_POSTS[$pid_key]);
  2149. unset($sadd_USERS[$uid_key]);
  2150. $user_sads = count($sadd_POSTS);
  2151. update_post_meta($post_id, "_user_saded", $sadd_USERS);
  2152. update_post_meta($post_id, "_post_sad_count", --$post_sad_count);
  2153. update_user_option($user_id, "_saded_posts", $sadd_POSTS);
  2154. update_user_option($user_id, "_user_sad_count", $user_sads);
  2155. echo "already_sad" . $post_sad_count;
  2156. }
  2157.  
  2158. }
  2159. else
  2160. {
  2161. $ip = $_SERVER["REMOTE_ADDR"];
  2162. $meta_IPS = get_post_meta($post_id, "_user_IP_sad");
  2163. $sadd_IPS = NULL;
  2164. if( count($meta_IPS) != 0 )
  2165. {
  2166. $sadd_IPS = $meta_IPS[0];
  2167. }
  2168.  
  2169. if( !is_array($sadd_IPS) )
  2170. {
  2171. $sadd_IPS = array( );
  2172. }
  2173.  
  2174. if( !in_array($ip, $sadd_IPS) )
  2175. {
  2176. $sadd_IPS["ip-" . $ip] = $ip;
  2177. }
  2178.  
  2179. if( !Alreadysaded($post_id) )
  2180. {
  2181. update_post_meta($post_id, "_user_IP_sad", $sadd_IPS);
  2182. update_post_meta($post_id, "_post_sad_count", ++$post_sad_count);
  2183. echo $post_sad_count;
  2184. }
  2185. else
  2186. {
  2187. $ip_key = array_search($ip, $sadd_IPS);
  2188. unset($sadd_IPS[$ip_key]);
  2189. update_post_meta($post_id, "_user_IP_sad", $sadd_IPS);
  2190. update_post_meta($post_id, "_post_sad_count", --$post_sad_count);
  2191. echo "already_sad" . $post_sad_count;
  2192. }
  2193.  
  2194. }
  2195.  
  2196. }
  2197.  
  2198. exit();
  2199. }
  2200.  
  2201. /**
  2202. * (3) Test if user already sadd post
  2203. */
  2204.  
  2205. function Alreadysaded($post_id)
  2206. {
  2207. if( is_user_logged_in() )
  2208. {
  2209. $user_id = get_current_user_id();
  2210. $meta_USERS = get_post_meta($post_id, "_user_saded");
  2211. $sadd_USERS = "";
  2212. if( count($meta_USERS) != 0 )
  2213. {
  2214. $sadd_USERS = $meta_USERS[0];
  2215. }
  2216.  
  2217. if( !is_array($sadd_USERS) )
  2218. {
  2219. $sadd_USERS = array( );
  2220. }
  2221.  
  2222. if( in_array($user_id, $sadd_USERS) )
  2223. {
  2224. return true;
  2225. }
  2226.  
  2227. return false;
  2228. }
  2229.  
  2230. $meta_IPS = get_post_meta($post_id, "_user_IP_sad");
  2231. $ip = $_SERVER["REMOTE_ADDR"];
  2232. $sadd_IPS = "";
  2233. if( count($meta_IPS) != 0 )
  2234. {
  2235. $sadd_IPS = $meta_IPS[0];
  2236. }
  2237.  
  2238. if( !is_array($sadd_IPS) )
  2239. {
  2240. $sadd_IPS = array( );
  2241. }
  2242.  
  2243. if( in_array($ip, $sadd_IPS) )
  2244. {
  2245. return true;
  2246. }
  2247.  
  2248. return false;
  2249. }
  2250.  
  2251. /**
  2252. * (4) Front end button
  2253. */
  2254.  
  2255. function getPostsadLink($post_id)
  2256. {
  2257. $sad_count = get_post_meta($post_id, "_post_sad_count", true);
  2258. $count = (empty($sad_count) || $sad_count == "0" ? "0" : esc_attr($sad_count));
  2259. if( alreadysaded($post_id) )
  2260. {
  2261. $class = esc_attr(" sad");
  2262. $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>";
  2263. $title = esc_attr("Oyu geri al");
  2264. $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>";
  2265. }
  2266. else
  2267. {
  2268. $class = esc_attr("");
  2269. $islem_style = "";
  2270. $title = esc_attr("Üzül");
  2271. $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>";
  2272. }
  2273.  
  2274. $output = "<a href=\"#\" class=\"jm-post-sad" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
  2275. return $output;
  2276. }
  2277.  
  2278. /**
  2279. * (5) Retrieve User sads and Show on Profile
  2280. */
  2281.  
  2282. function show_user_sads($user)
  2283. {
  2284. echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_sads\">";
  2285. _e("Üzgün:");
  2286. echo "</label></th>\r\n\t\t\t<td>\r\n ";
  2287. $user_sads = get_user_option("_saded_posts", $user->ID);
  2288. if( !empty($user_sads) && 0 < count($user_sads) )
  2289. {
  2290. $the_sads = $user_sads;
  2291. }
  2292. else
  2293. {
  2294. $the_sads = "";
  2295. }
  2296.  
  2297. if( !is_array($the_sads) )
  2298. {
  2299. $the_sads = array( );
  2300. }
  2301.  
  2302. $count = count($the_sads);
  2303. $i = 0;
  2304. if( 0 < $count )
  2305. {
  2306. $sad_list = "";
  2307. echo "<p>\n";
  2308. foreach( $the_sads as $the_sad )
  2309. {
  2310. $i++;
  2311. $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";
  2312. if( $count != $i )
  2313. {
  2314. $sad_list .= " &middot; ";
  2315. }
  2316. else
  2317. {
  2318. $sad_list .= "</p>\n";
  2319. }
  2320.  
  2321. }
  2322. echo $sad_list;
  2323. }
  2324. else
  2325. {
  2326. echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
  2327. }
  2328.  
  2329. echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
  2330. }
  2331.  
  2332. /**
  2333. * (6) Add a shortcode to your posts instead
  2334. * type [jmsadr] in your post to output the button
  2335. */
  2336.  
  2337. function jm_sad_shortcode()
  2338. {
  2339. return getpostsadlink(get_the_ID());
  2340. }
  2341.  
  2342. /**
  2343. * (7) If the user is logged in, output a list of posts that the user sads
  2344. * Markup assumes sidebar/widget usage
  2345. */
  2346.  
  2347. function frontEndUsersads()
  2348. {
  2349. if( is_user_logged_in() )
  2350. {
  2351. $sad_list = "";
  2352. $user_id = get_current_user_id();
  2353. $user_sads = get_user_option("_saded_posts", $user_id);
  2354. if( !empty($user_sads) && 0 < count($user_sads) )
  2355. {
  2356. $the_sads = $user_sads;
  2357. }
  2358. else
  2359. {
  2360. $the_sads = "";
  2361. }
  2362.  
  2363. if( !is_array($the_sads) )
  2364. {
  2365. $the_sads = array( );
  2366. }
  2367.  
  2368. $count = count($the_sads);
  2369. if( 0 < $count )
  2370. {
  2371. $limited_sads = array_slice($the_sads, 0, 5);
  2372. $sad_list .= "<aside>\n";
  2373. $sad_list .= "<h3>" . __("Üzgün :") . "</h3>\n";
  2374. $sad_list .= "<ul>\n";
  2375. foreach( $limited_sads as $the_sad )
  2376. {
  2377. $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";
  2378. }
  2379. $sad_list .= "</ul>\n";
  2380. $sad_list .= "</aside>\n";
  2381. }
  2382.  
  2383. echo $sad_list;
  2384. }
  2385.  
  2386. }
  2387.  
  2388. /**
  2389. * (2) Save angry data
  2390. */
  2391.  
  2392. function jm_post_angry()
  2393. {
  2394. $nonce = $_POST["nonce"];
  2395. if( !wp_verify_nonce($nonce, "ajax-nonce") )
  2396. {
  2397. exit( "Hata Oluştu!" );
  2398. }
  2399.  
  2400. if( isset($_POST["jm_post_angry"]) )
  2401. {
  2402. $post_id = $_POST["post_id"];
  2403. $post_angry_count = get_post_meta($post_id, "_post_angry_count", true);
  2404. if( function_exists("wp_cache_post_change") )
  2405. {
  2406. $GLOBALS["super_cache_enabled"] = 1;
  2407. wp_cache_post_change($post_id);
  2408. }
  2409.  
  2410. if( is_user_logged_in() )
  2411. {
  2412. $user_id = get_current_user_id();
  2413. $meta_POSTS = get_user_option("_angried_posts", $user_id);
  2414. $meta_USERS = get_post_meta($post_id, "_user_angried");
  2415. $angryd_POSTS = NULL;
  2416. $angryd_USERS = NULL;
  2417. if( count($meta_POSTS) != 0 )
  2418. {
  2419. $angryd_POSTS = $meta_POSTS;
  2420. }
  2421.  
  2422. if( !is_array($angryd_POSTS) )
  2423. {
  2424. $angryd_POSTS = array( );
  2425. }
  2426.  
  2427. if( count($meta_USERS) != 0 )
  2428. {
  2429. $angryd_USERS = $meta_USERS[0];
  2430. }
  2431.  
  2432. if( !is_array($angryd_USERS) )
  2433. {
  2434. $angryd_USERS = array( );
  2435. }
  2436.  
  2437. $angryd_POSTS["post-" . $post_id] = $post_id;
  2438. $angryd_USERS["user-" . $user_id] = $user_id;
  2439. $user_angrys = count($angryd_POSTS);
  2440. if( !Alreadyangried($post_id) )
  2441. {
  2442. update_post_meta($post_id, "_user_angried", $angryd_USERS);
  2443. update_post_meta($post_id, "_post_angry_count", ++$post_angry_count);
  2444. update_user_option($user_id, "_angried_posts", $angryd_POSTS);
  2445. update_user_option($user_id, "_user_angry_count", $user_angrys);
  2446. echo $post_angry_count;
  2447. }
  2448. else
  2449. {
  2450. $pid_key = array_search($post_id, $angryd_POSTS);
  2451. $uid_key = array_search($user_id, $angryd_USERS);
  2452. unset($angryd_POSTS[$pid_key]);
  2453. unset($angryd_USERS[$uid_key]);
  2454. $user_angrys = count($angryd_POSTS);
  2455. update_post_meta($post_id, "_user_angried", $angryd_USERS);
  2456. update_post_meta($post_id, "_post_angry_count", --$post_angry_count);
  2457. update_user_option($user_id, "_angried_posts", $angryd_POSTS);
  2458. update_user_option($user_id, "_user_angry_count", $user_angrys);
  2459. echo "already_angry" . $post_angry_count;
  2460. }
  2461.  
  2462. }
  2463. else
  2464. {
  2465. $ip = $_SERVER["REMOTE_ADDR"];
  2466. $meta_IPS = get_post_meta($post_id, "_user_IP_angry");
  2467. $angryd_IPS = NULL;
  2468. if( count($meta_IPS) != 0 )
  2469. {
  2470. $angryd_IPS = $meta_IPS[0];
  2471. }
  2472.  
  2473. if( !is_array($angryd_IPS) )
  2474. {
  2475. $angryd_IPS = array( );
  2476. }
  2477.  
  2478. if( !in_array($ip, $angryd_IPS) )
  2479. {
  2480. $angryd_IPS["ip-" . $ip] = $ip;
  2481. }
  2482.  
  2483. if( !Alreadyangried($post_id) )
  2484. {
  2485. update_post_meta($post_id, "_user_IP_angry", $angryd_IPS);
  2486. update_post_meta($post_id, "_post_angry_count", ++$post_angry_count);
  2487. echo $post_angry_count;
  2488. }
  2489. else
  2490. {
  2491. $ip_key = array_search($ip, $angryd_IPS);
  2492. unset($angryd_IPS[$ip_key]);
  2493. update_post_meta($post_id, "_user_IP_angry", $angryd_IPS);
  2494. update_post_meta($post_id, "_post_angry_count", --$post_angry_count);
  2495. echo "already_angry" . $post_angry_count;
  2496. }
  2497.  
  2498. }
  2499.  
  2500. }
  2501.  
  2502. exit();
  2503. }
  2504.  
  2505. /**
  2506. * (3) Test if user already angryd post
  2507. */
  2508.  
  2509. function Alreadyangried($post_id)
  2510. {
  2511. if( is_user_logged_in() )
  2512. {
  2513. $user_id = get_current_user_id();
  2514. $meta_USERS = get_post_meta($post_id, "_user_angried");
  2515. $angryd_USERS = "";
  2516. if( count($meta_USERS) != 0 )
  2517. {
  2518. $angryd_USERS = $meta_USERS[0];
  2519. }
  2520.  
  2521. if( !is_array($angryd_USERS) )
  2522. {
  2523. $angryd_USERS = array( );
  2524. }
  2525.  
  2526. if( in_array($user_id, $angryd_USERS) )
  2527. {
  2528. return true;
  2529. }
  2530.  
  2531. return false;
  2532. }
  2533.  
  2534. $meta_IPS = get_post_meta($post_id, "_user_IP_angry");
  2535. $ip = $_SERVER["REMOTE_ADDR"];
  2536. $angryd_IPS = "";
  2537. if( count($meta_IPS) != 0 )
  2538. {
  2539. $angryd_IPS = $meta_IPS[0];
  2540. }
  2541.  
  2542. if( !is_array($angryd_IPS) )
  2543. {
  2544. $angryd_IPS = array( );
  2545. }
  2546.  
  2547. if( in_array($ip, $angryd_IPS) )
  2548. {
  2549. return true;
  2550. }
  2551.  
  2552. return false;
  2553. }
  2554.  
  2555. /**
  2556. * (4) Front end button
  2557. */
  2558.  
  2559. function getPostangryLink($post_id)
  2560. {
  2561. $angry_count = get_post_meta($post_id, "_post_angry_count", true);
  2562. $count = (empty($angry_count) || $angry_count == "0" ? "0" : esc_attr($angry_count));
  2563. if( alreadyangried($post_id) )
  2564. {
  2565. $class = esc_attr(" angry");
  2566. $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>";
  2567. $title = esc_attr("Oyu geri al");
  2568. $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>";
  2569. }
  2570. else
  2571. {
  2572. $class = esc_attr("");
  2573. $islem_style = "";
  2574. $title = esc_attr("Sevin");
  2575. $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>";
  2576. }
  2577.  
  2578. $output = "<a href=\"#\" class=\"jm-post-angry" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "<span class=\"reaction-count-post\">" . $count . "</span></a>";
  2579. return $output;
  2580. }
  2581.  
  2582. /**
  2583. * (5) Retrieve User angrys and Show on Profile
  2584. */
  2585.  
  2586. function show_user_angries($user)
  2587. {
  2588. echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_angrys\">";
  2589. _e("Kızgın:");
  2590. echo "</label></th>\r\n\t\t\t<td>\r\n ";
  2591. $user_angrys = get_user_option("_angried_posts", $user->ID);
  2592. if( !empty($user_angrys) && 0 < count($user_angrys) )
  2593. {
  2594. $the_angrys = $user_angrys;
  2595. }
  2596. else
  2597. {
  2598. $the_angrys = "";
  2599. }
  2600.  
  2601. if( !is_array($the_angrys) )
  2602. {
  2603. $the_angrys = array( );
  2604. }
  2605.  
  2606. $count = count($the_angrys);
  2607. $i = 0;
  2608. if( 0 < $count )
  2609. {
  2610. $angry_list = "";
  2611. echo "<p>\n";
  2612. foreach( $the_angrys as $the_angry )
  2613. {
  2614. $i++;
  2615. $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";
  2616. if( $count != $i )
  2617. {
  2618. $angry_list .= " &middot; ";
  2619. }
  2620. else
  2621. {
  2622. $angry_list .= "</p>\n";
  2623. }
  2624.  
  2625. }
  2626. echo $angry_list;
  2627. }
  2628. else
  2629. {
  2630. echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
  2631. }
  2632.  
  2633. echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
  2634. }
  2635.  
  2636. /**
  2637. * (6) Add a shortcode to your posts instead
  2638. * type [jmangryr] in your post to output the button
  2639. */
  2640.  
  2641. function jm_angry_shortcode()
  2642. {
  2643. return getpostangrylink(get_the_ID());
  2644. }
  2645.  
  2646. /**
  2647. * (7) If the user is logged in, output a list of posts that the user angrys
  2648. * Markup assumes sidebar/widget usage
  2649. */
  2650.  
  2651. function frontEndUserangries()
  2652. {
  2653. if( is_user_logged_in() )
  2654. {
  2655. $angry_list = "";
  2656. $user_id = get_current_user_id();
  2657. $user_angrys = get_user_option("_angried_posts", $user_id);
  2658. if( !empty($user_angrys) && 0 < count($user_angrys) )
  2659. {
  2660. $the_angrys = $user_angrys;
  2661. }
  2662. else
  2663. {
  2664. $the_angrys = "";
  2665. }
  2666.  
  2667. if( !is_array($the_angrys) )
  2668. {
  2669. $the_angrys = array( );
  2670. }
  2671.  
  2672. $count = count($the_angrys);
  2673. if( 0 < $count )
  2674. {
  2675. $limited_angrys = array_slice($the_angrys, 0, 5);
  2676. $angry_list .= "<aside>\n";
  2677. $angry_list .= "<h3>" . __("Kızgın:") . "</h3>\n";
  2678. $angry_list .= "<ul>\n";
  2679. foreach( $limited_angrys as $the_angry )
  2680. {
  2681. $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";
  2682. }
  2683. $angry_list .= "</ul>\n";
  2684. $angry_list .= "</aside>\n";
  2685. }
  2686.  
  2687. echo $angry_list;
  2688. }
  2689.  
  2690. }
  2691.  
  2692. /**
  2693. * (2) Save fav data
  2694. */
  2695.  
  2696. function jm_post_fav()
  2697. {
  2698. $nonce = $_POST["nonce"];
  2699. if( !wp_verify_nonce($nonce, "ajax-nonce") )
  2700. {
  2701. exit( "Hata Oluştu!" );
  2702. }
  2703.  
  2704. if( isset($_POST["jm_post_fav"]) )
  2705. {
  2706. $post_id = $_POST["post_id"];
  2707. $post_fav_count = get_post_meta($post_id, "_post_fav_count", true);
  2708. if( function_exists("wp_cache_post_change") )
  2709. {
  2710. $GLOBALS["super_cache_enabled"] = 1;
  2711. wp_cache_post_change($post_id);
  2712. }
  2713.  
  2714. if( is_user_logged_in() )
  2715. {
  2716. $user_id = get_current_user_id();
  2717. $meta_POSTS = get_user_option("_favd_posts", $user_id);
  2718. $meta_USERS = get_post_meta($post_id, "_user_favd");
  2719. $favd_POSTS = NULL;
  2720. $favd_USERS = NULL;
  2721. if( count($meta_POSTS) != 0 )
  2722. {
  2723. $favd_POSTS = $meta_POSTS;
  2724. }
  2725.  
  2726. if( !is_array($favd_POSTS) )
  2727. {
  2728. $favd_POSTS = array( );
  2729. }
  2730.  
  2731. if( count($meta_USERS) != 0 )
  2732. {
  2733. $favd_USERS = $meta_USERS[0];
  2734. }
  2735.  
  2736. if( !is_array($favd_USERS) )
  2737. {
  2738. $favd_USERS = array( );
  2739. }
  2740.  
  2741. $favd_POSTS["post-" . $post_id] = $post_id;
  2742. $favd_USERS["user-" . $user_id] = $user_id;
  2743. $user_favs = count($favd_POSTS);
  2744. if( !Alreadyfavd($post_id) )
  2745. {
  2746. update_post_meta($post_id, "_user_favd", $favd_USERS);
  2747. update_post_meta($post_id, "_post_fav_count", ++$post_fav_count);
  2748. update_user_option($user_id, "_favd_posts", $favd_POSTS);
  2749. update_user_option($user_id, "_user_fav_count", $user_favs);
  2750. echo $post_fav_count;
  2751. }
  2752. else
  2753. {
  2754. $pid_key = array_search($post_id, $favd_POSTS);
  2755. $uid_key = array_search($user_id, $favd_USERS);
  2756. unset($favd_POSTS[$pid_key]);
  2757. unset($favd_USERS[$uid_key]);
  2758. $user_favs = count($favd_POSTS);
  2759. update_post_meta($post_id, "_user_favd", $favd_USERS);
  2760. update_post_meta($post_id, "_post_fav_count", --$post_fav_count);
  2761. update_user_option($user_id, "_favd_posts", $favd_POSTS);
  2762. update_user_option($user_id, "_user_fav_count", $user_favs);
  2763. echo "already" . $post_fav_count;
  2764. }
  2765.  
  2766. }
  2767. else
  2768. {
  2769. $ip = $_SERVER["REMOTE_ADDR"];
  2770. $meta_IPS = get_post_meta($post_id, "_user_IP");
  2771. $favd_IPS = NULL;
  2772. if( count($meta_IPS) != 0 )
  2773. {
  2774. $favd_IPS = $meta_IPS[0];
  2775. }
  2776.  
  2777. if( !is_array($favd_IPS) )
  2778. {
  2779. $favd_IPS = array( );
  2780. }
  2781.  
  2782. if( !in_array($ip, $favd_IPS) )
  2783. {
  2784. $favd_IPS["ip-" . $ip] = $ip;
  2785. }
  2786.  
  2787. if( !Alreadyfavd($post_id) )
  2788. {
  2789. update_post_meta($post_id, "_user_IP", $favd_IPS);
  2790. update_post_meta($post_id, "_post_fav_count", ++$post_fav_count);
  2791. echo $post_fav_count;
  2792. }
  2793. else
  2794. {
  2795. $ip_key = array_search($ip, $favd_IPS);
  2796. unset($favd_IPS[$ip_key]);
  2797. update_post_meta($post_id, "_user_IP", $favd_IPS);
  2798. update_post_meta($post_id, "_post_fav_count", --$post_fav_count);
  2799. echo "already" . $post_fav_count;
  2800. }
  2801.  
  2802. }
  2803.  
  2804. }
  2805.  
  2806. exit();
  2807. }
  2808.  
  2809. /**
  2810. * (3) Test if user already favd post
  2811. */
  2812.  
  2813. function Alreadyfavd($post_id)
  2814. {
  2815. if( is_user_logged_in() )
  2816. {
  2817. $user_id = get_current_user_id();
  2818. $meta_USERS = get_post_meta($post_id, "_user_favd");
  2819. $favd_USERS = "";
  2820. if( count($meta_USERS) != 0 )
  2821. {
  2822. $favd_USERS = $meta_USERS[0];
  2823. }
  2824.  
  2825. if( !is_array($favd_USERS) )
  2826. {
  2827. $favd_USERS = array( );
  2828. }
  2829.  
  2830. if( in_array($user_id, $favd_USERS) )
  2831. {
  2832. return true;
  2833. }
  2834.  
  2835. return false;
  2836. }
  2837.  
  2838. $meta_IPS = get_post_meta($post_id, "_user_IP");
  2839. $ip = $_SERVER["REMOTE_ADDR"];
  2840. $favd_IPS = "";
  2841. if( count($meta_IPS) != 0 )
  2842. {
  2843. $favd_IPS = $meta_IPS[0];
  2844. }
  2845.  
  2846. if( !is_array($favd_IPS) )
  2847. {
  2848. $favd_IPS = array( );
  2849. }
  2850.  
  2851. if( in_array($ip, $favd_IPS) )
  2852. {
  2853. return true;
  2854. }
  2855.  
  2856. return false;
  2857. }
  2858.  
  2859. /**
  2860. * (4) Front end button
  2861. */
  2862.  
  2863. function getPostfavLink($post_id)
  2864. {
  2865. $fav_count = get_post_meta($post_id, "_post_fav_count", true);
  2866. $count = (empty($fav_count) || $fav_count == "0" ? "0" : esc_attr($fav_count));
  2867. if( alreadyfavd($post_id) )
  2868. {
  2869. $class = esc_attr(" favd");
  2870. $title = esc_attr("Favorilerimden Çıkar");
  2871. $heart = "<i class=\"fa fa-star\"></i>";
  2872. }
  2873. else
  2874. {
  2875. $class = esc_attr("");
  2876. $title = esc_attr("Favorilerime Ekle");
  2877. $heart = "<i class=\"fa fa-star-o\"></i>";
  2878. }
  2879.  
  2880. $output = "<a href=\"#\" class=\"jm-post-fav" . $class . "\" data-post_id=\"" . $post_id . "\" title=\"" . $title . "\">" . $heart . "</a>";
  2881. return $output;
  2882. }
  2883.  
  2884. /**
  2885. * (5) Retrieve User favs and Show on Profile
  2886. */
  2887.  
  2888. function show_user_favs($user)
  2889. {
  2890. echo " \r\n <table class=\"form-table\">\r\n <tr>\r\n\t\t\t<th><label for=\"user_favs\">";
  2891. _e("Favoriler :");
  2892. echo "</label></th>\r\n\t\t\t<td>\r\n ";
  2893. $user_favs = get_user_option("_favd_posts", $user->ID);
  2894. if( !empty($user_favs) && 0 < count($user_favs) )
  2895. {
  2896. $the_favs = $user_favs;
  2897. }
  2898. else
  2899. {
  2900. $the_favs = "";
  2901. }
  2902.  
  2903. if( !is_array($the_favs) )
  2904. {
  2905. $the_favs = array( );
  2906. }
  2907.  
  2908. $count = count($the_favs);
  2909. $i = 0;
  2910. if( 0 < $count )
  2911. {
  2912. $fav_list = "";
  2913. echo "<p>\n";
  2914. foreach( $the_favs as $the_fav )
  2915. {
  2916. $i++;
  2917. $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";
  2918. if( $count != $i )
  2919. {
  2920. $fav_list .= " &middot; ";
  2921. }
  2922. else
  2923. {
  2924. $fav_list .= "</p>\n";
  2925. }
  2926.  
  2927. }
  2928. echo $fav_list;
  2929. }
  2930. else
  2931. {
  2932. echo "<p>" . _e("Maalesef Veri Yok.") . "</p>\n";
  2933. }
  2934.  
  2935. echo " </td>\r\n\t\t</tr>\r\n </table>\r\n";
  2936. }
  2937.  
  2938. /**
  2939. * (6) Add a shortcode to your posts instead
  2940. * type [jmfavr] in your post to output the button
  2941. */
  2942.  
  2943. function jm_fav_shortcode()
  2944. {
  2945. return getpostfavlink(get_the_ID());
  2946. }
  2947.  
  2948. /**
  2949. * (7) If the user is logged in, output a list of posts that the user favs
  2950. * Markup assumes sidebar/widget usage
  2951. */
  2952.  
  2953. function frontEndUserfavs()
  2954. {
  2955. if( is_user_logged_in() )
  2956. {
  2957. $fav_list = "";
  2958. $user_id = get_current_user_id();
  2959. $user_favs = get_user_option("_favd_posts", $user_id);
  2960. if( !empty($user_favs) && 0 < count($user_favs) )
  2961. {
  2962. $the_favs = $user_favs;
  2963. }
  2964. else
  2965. {
  2966. $the_favs = "";
  2967. }
  2968.  
  2969. if( !is_array($the_favs) )
  2970. {
  2971. $the_favs = array( );
  2972. }
  2973.  
  2974. $count = count($the_favs);
  2975. if( 0 < $count )
  2976. {
  2977. $limited_favs = array_slice($the_favs, 0, 5);
  2978. $fav_list .= "<aside>\n";
  2979. $fav_list .= "<h3>" . __("Favoriler :") . "</h3>\n";
  2980. $fav_list .= "<ul>\n";
  2981. foreach( $limited_favs as $the_fav )
  2982. {
  2983. $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";
  2984. }
  2985. $fav_list .= "</ul>\n";
  2986. $fav_list .= "</aside>\n";
  2987. }
  2988.  
  2989. echo $fav_list;
  2990. }
  2991.  
  2992. }
  2993.  
  2994. function connect_curl($url)
  2995. {
  2996. $ch = curl_init();
  2997. curl_setopt($ch, CURLOPT_URL, $url);
  2998. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  2999. curl_setopt($ch, CURLOPT_HEADER, false);
  3000. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  3001. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  3002. $result = curl_exec($ch);
  3003. curl_close($ch);
  3004. return $result;
  3005. }
  3006.  
  3007. function generateRandomString($length = 16)
  3008. {
  3009. $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  3010. $charactersLength = strlen($characters);
  3011. $randomString = "";
  3012. for( $i = 0; $i < $length; $i++ )
  3013. {
  3014. $randomString .= $characters[rand(0, $charactersLength - 1)];
  3015. }
  3016. return $randomString;
  3017. }
  3018.  
  3019. function log_reg()
  3020. {
  3021. if( ecan_get_option("facebook-app-id") != "" && ecan_get_option("facebook-app-secret") != "" )
  3022. {
  3023. $fb = new Facebook\Facebook(array( "app_id" => ecan_get_option("facebook-app-id"), "app_secret" => ecan_get_option("facebook-app-secret") ));
  3024. if( $_GET )
  3025. {
  3026. $helper = $fb->getRedirectLoginHelper();
  3027. try
  3028. {
  3029. $accessToken = $helper->getAccessToken();
  3030. }
  3031. catch( Facebook\Exceptions\FacebookResponseException $e )
  3032. {
  3033. echo "Hata oluştu -> " . $e->getMessage();
  3034. }
  3035. $token = $accessToken->getValue();
  3036. $response = $fb->get("/me?fields=id,name,email,verified", $accessToken->getValue());
  3037. if( $response )
  3038. {
  3039. try
  3040. {
  3041. $user = $response->getGraphUser();
  3042. }
  3043. catch( Facebook\Exceptions\FacebookResponseException $e )
  3044. {
  3045. echo "Hata Oluştu ->" . $e->getMessage();
  3046. }
  3047. if( $response )
  3048. {
  3049. $name_parcala = explode(" ", $user["name"]);
  3050. $deger = $user["id"];
  3051. $deger_dizi = str_split($deger);
  3052. $join = implode("\$@*½#", $deger_dizi);
  3053. $facebook_pass = md5(sha1($join));
  3054. $registeredDate = date("Y-m-d H:i:s");
  3055. $usernickfid = substr($deger, 1, 2);
  3056. $usernickfid_pss = substr($facebook_pass, 0, 1);
  3057. $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" );
  3058. $lastUserID = wp_insert_user($userdata);
  3059. if( $lastUserID )
  3060. {
  3061. $info = array( );
  3062. $info["user_login"] = $user["name"] . "-" . $usernickfid . $usernickfid_pss;
  3063. $info["user_password"] = $facebook_pass;
  3064. $user_signon = wp_signon($info, false);
  3065. if( is_wp_error($user_signon) )
  3066. {
  3067. $log_Msg = "<div class=\"alert-error\">" . ecan_get_option("user-login-hata") . "</div>";
  3068. }
  3069. else
  3070. {
  3071. echo go_home();
  3072. }
  3073.  
  3074. }
  3075.  
  3076. }
  3077.  
  3078. }
  3079.  
  3080. }
  3081.  
  3082. }
  3083.  
  3084. if( $_POST )
  3085. {
  3086. if( isset($_POST["login_nonce_field"]) && wp_verify_nonce(p("login_nonce_field"), "login_nonce_action") )
  3087. {
  3088. global $log_Msg;
  3089. $info = array( );
  3090. $info["user_login"] = p("username");
  3091. $info["user_password"] = p("password");
  3092. $user_signon = wp_signon($info, false);
  3093. if( is_wp_error($user_signon) )
  3094. {
  3095. $log_Msg = "<div class=\"alert-error\">" . ecan_get_option("user-login-hata") . "</div>";
  3096. }
  3097. else
  3098. {
  3099. echo go_home();
  3100. }
  3101.  
  3102. }
  3103. else
  3104. {
  3105. if( isset($_POST["register_nonce_field"]) && wp_verify_nonce(p("register_nonce_field"), "register_nonce_action") )
  3106. {
  3107. global $wpdb;
  3108. global $reg_Msg;
  3109. $goRegister = true;
  3110. $first_name = uppercase(p("first_name"));
  3111. $last_name = uppercase(p("last_name"));
  3112. $full_name = $first_name . " " . $last_name;
  3113. $user_nickname = p("login_name");
  3114. $user_email = p("user_email");
  3115. $pass = generaterandomstring();
  3116. $secret = ecan_get_option("rechapta-secret");
  3117. $ip = $_SERVER["REMOTE_ADDR"];
  3118. $response = p("g-recaptcha-response");
  3119. $url = "https://www.google.com/recaptcha/api/siteverify?secret=" . $secret . "&response=" . $response . "&remoteip=" . $ip;
  3120. $chapta_result = connect_curl($url);
  3121. $json_decode = json_decode($chapta_result);
  3122. if( strlen($first_name) < 2 || 26 < strlen($first_name) )
  3123. {
  3124. $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata1") . "</div>";
  3125. $goRegister = false;
  3126. }
  3127.  
  3128. if( strlen($last_name) < 2 || 26 < strlen($last_name) )
  3129. {
  3130. $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata2") . "</div>";
  3131. $goRegister = false;
  3132. }
  3133.  
  3134. if( strlen($user_nickname) < 4 || 16 < strlen($user_nickname) )
  3135. {
  3136. $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata3") . "</div>";
  3137. $goRegister = false;
  3138. }
  3139.  
  3140. if( !filter_var($user_email, FILTER_VALIDATE_EMAIL) )
  3141. {
  3142. $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata4") . "</div>";
  3143. $goRegister = false;
  3144. }
  3145.  
  3146. if( username_exists($user_nickname) )
  3147. {
  3148. $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata5") . "</div>";
  3149. $goRegister = false;
  3150. }
  3151.  
  3152. if( email_exists($user_email) )
  3153. {
  3154. $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata6") . "</div>";
  3155. $goRegister = false;
  3156. }
  3157.  
  3158. if( $json_decode->success != 1 )
  3159. {
  3160. $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata7") . "</div>";
  3161. $goRegister = false;
  3162. }
  3163.  
  3164. if( $goRegister == true )
  3165. {
  3166. $registeredDate = date("Y-m-d H:i:s");
  3167. $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" );
  3168. $lastUserID = wp_insert_user($userdata);
  3169. if( $lastUserID )
  3170. {
  3171. $reg_Msg = "<div class=\"alert-ok\" >" . ecan_get_option("user-register-ok1") . "</div>";
  3172. wp_mail($user_email, get_bloginfo("name") . " - " . ecan_get_option("user-register-mail-info-title") . "", "" . ecan_get_option("user-register-mail-info") . " " . $pass);
  3173. }
  3174. else
  3175. {
  3176. $reg_Msg = "<div class=\"alert-error\" >" . ecan_get_option("user-register-hata8") . " : " . mysql_error() . "</div>";
  3177. }
  3178.  
  3179. add_user_meta($lastUserID, "show_admin_bar_front", "false");
  3180. add_user_meta($lastUserID, "show_admin_bar_admin", "false");
  3181. add_user_meta($lastUserID, "user_avatar_custom", "0");
  3182. }
  3183.  
  3184. }
  3185. else
  3186. {
  3187. if( isset($_POST["forgotpass_nonce_field"]) && wp_verify_nonce(p("forgotpass_nonce_field"), "forgotpass_nonce_action") )
  3188. {
  3189. $user_email_forgot = p("forgot_user_email");
  3190. $forgot_user_data = get_user_by("email", $user_email_forgot);
  3191. if( empty($forgot_user_data) )
  3192. {
  3193. $reg_Msg = "<div class=\"alert-error\">" . ecan_get_option("user-forgot-mail-info-e") . "</div>";
  3194. }
  3195. else
  3196. {
  3197. $user_new_pass = generaterandomstring();
  3198. $info = wp_update_user(array( "ID" => $forgot_user_data->ID, "user_pass" => $user_new_pass ));
  3199. if( is_wp_error($info) )
  3200. {
  3201. $reg_Msg = "<div class=\"alert-error\">" . $return->get_error_message() . "</div>";
  3202. }
  3203. else
  3204. {
  3205. $reg_Msg = "<div class=\"alert-ok\">" . ecan_get_option("user-forgot-mail-info-s") . "</div>";
  3206. 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);
  3207. }
  3208.  
  3209. }
  3210.  
  3211. }
  3212.  
  3213. }
  3214.  
  3215. }
  3216.  
  3217. }
  3218.  
  3219. }
  3220.  
  3221. function user_panel($user_ID)
  3222. {
  3223. global $user_Msg;
  3224. if( wp_verify_nonce($_POST["user_profile_nonce"], "update_user") )
  3225. {
  3226. if( !empty($_POST["first_Name"]) && $_POST["first_Name"] != get_the_author_meta("first_name", $user_ID) )
  3227. {
  3228. $user_first_name = uppercase(p("first_Name"));
  3229. update_user_meta($user_ID, "first_name", $user_first_name);
  3230. }
  3231.  
  3232. if( !empty($_POST["last_Name"]) && $_POST["last_Name"] != get_the_author_meta("last_name", $user_ID) )
  3233. {
  3234. $user_last_name = uppercase(p("last_Name"));
  3235. update_user_meta($user_ID, "last_name", $user_last_name);
  3236. }
  3237.  
  3238. require_once(ABSPATH . "wp-admin" . "/includes/image.php");
  3239. require_once(ABSPATH . "wp-admin" . "/includes/file.php");
  3240. require_once(ABSPATH . "wp-admin" . "/includes/media.php");
  3241. $filename = $_FILES["avatar_user"];
  3242. $upload_overrides = array( "test_form" => false );
  3243. $movefile = wp_handle_upload($filename, $upload_overrides);
  3244. if( isset($movefile["file"]) )
  3245. {
  3246. $file_type = wp_check_filetype($movefile["file"]);
  3247. $wp_upload_dir = wp_upload_dir();
  3248. $file_name = rand(1000, 9999) . "_" . basename($filename["name"]);
  3249. $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" );
  3250. if( $file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif" )
  3251. {
  3252. $attach_id = wp_insert_attachment($attachment, $movefile["file"], $user_ID);
  3253. $attach_data = wp_generate_attachment_metadata($attach_id, $movefile["file"]);
  3254. wp_update_attachment_metadata($attach_id, $attach_data);
  3255. }
  3256.  
  3257. if( !empty($_FILES["avatar_user"]) && ($file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif") )
  3258. {
  3259. update_user_meta($user_ID, "user_avatar_custom", $attach_id);
  3260. 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";
  3261. }
  3262.  
  3263. }
  3264.  
  3265. if( !empty($_POST["display_name"]) )
  3266. {
  3267. $user_display_name = uppercase(p("display_name"));
  3268. $return = wp_update_user(array( "ID" => $user_ID, "display_name" => $user_display_name ));
  3269. if( is_wp_error($return) )
  3270. {
  3271. $errors[] = $return->get_error_message();
  3272. $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-error\">" . ecan_get_option("user-register-hata1") . "</div></div>";
  3273. 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";
  3274. }
  3275.  
  3276. }
  3277.  
  3278. $user_description = p("description");
  3279. update_user_meta($user_ID, "description", $user_description);
  3280. $url = p("url");
  3281. wp_update_user(array( "ID" => $user_ID, "user_url" => $url ));
  3282. $facebook = p("facebook");
  3283. update_user_meta($user_ID, "facebook", $facebook);
  3284. $twitter = p("twitter");
  3285. update_user_meta($user_ID, "twitter", $twitter);
  3286. $googleplus = p("googleplus");
  3287. update_user_meta($user_ID, "googleplus", $googleplus);
  3288. if( !empty($_POST["pass_orj"]) )
  3289. {
  3290. $user_data_pass = get_user_by("id", $user_ID);
  3291. $result_pass = wp_check_password($_POST["pass_orj"], $user_data_pass->user_pass, $user_data_pass->ID);
  3292. if( $result_pass )
  3293. {
  3294. if( !empty($_POST["pass"]) && !empty($_POST["pass2"]) )
  3295. {
  3296. if( $_POST["pass"] == $_POST["pass2"] )
  3297. {
  3298. $pass = p("pass");
  3299. $return = wp_update_user(array( "ID" => $user_ID, "user_pass" => $pass ));
  3300. if( is_wp_error($return) )
  3301. {
  3302. $errors[] = $return->get_error_message();
  3303. $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-error\">" . ecan_get_option("user-panel-set-hata1") . "</div></div>";
  3304. 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";
  3305. }
  3306.  
  3307. }
  3308. else
  3309. {
  3310. $errors[] = "Şifre Hatası";
  3311. $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-error\">" . ecan_get_option("user-panel-set-hata2") . "</div></div>";
  3312. 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";
  3313. }
  3314.  
  3315. }
  3316.  
  3317. }
  3318. else
  3319. {
  3320. $errors[] = "Şifre Hatası";
  3321. $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-error\">" . ecan_get_option("user-panel-set-hata-pass-check") . "</div></div>";
  3322. 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";
  3323. }
  3324.  
  3325. }
  3326.  
  3327. if( count($errors) == 0 )
  3328. {
  3329. $user_Msg = "<div class=\"alert-up-container\"><div class=\"alert-ok\">" . ecan_get_option("user-panel-set-ok") . "</div></div>";
  3330. 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";
  3331. return $user_Msg;
  3332. }
  3333.  
  3334. 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";
  3335. }
  3336.  
  3337. }
  3338.  
  3339. function lmd2serial($x0b)
  3340. {
  3341. global $x13;
  3342. global $x14;
  3343. global $x15;
  3344. global $x16;
  3345. global $x17;
  3346. global $x18;
  3347. global $x19;
  3348. global $x1a;
  3349. $x0c = $x18($x0b);
  3350. $x0d = "";
  3351. $x0d[] = $x19($x0c, 0, 4);
  3352. $x0d[] = $x19($x0c, 8, 4);
  3353. $x0d[] = $x19($x0c, 14, 4);
  3354. $x0d[] = $x19($x0c, 20, 4);
  3355. $x0d[] = $x19($x0c, 26, 10);
  3356. return $x14($x0d, "-");
  3357. }
  3358.  
  3359. function lisans_yap()
  3360. {
  3361. global $x13;
  3362. global $x14;
  3363. global $x15;
  3364. global $x16;
  3365. global $x17;
  3366. global $x18;
  3367. global $x19;
  3368. global $x1a;
  3369. $x0e = $x13("/", $_SERVER["REQUEST_URI"]);
  3370. if( !$x15("wp-admin", $x0e) && !$x15("wp-login.php", $x0e) )
  3371. {
  3372. $x0f = get_bloginfo("url");
  3373. $x10 = ecan_get_option("lisans");
  3374. $x11 = $x1a($x10);
  3375. if( $x11 )
  3376. {
  3377. $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ı"))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
  3378. $x12 = lmd2serial($x12);
  3379. if( $x12 != $x11 )
  3380. {
  3381. echo "<meta charset=\"utf-8\" />Lütfen size verilen lisans anahtarının doğru olduğuna emin olunuz!";
  3382. exit();
  3383. }
  3384.  
  3385. }
  3386. else
  3387. {
  3388. echo "<meta charset=\"utf-8\" />Lütfen lisans anahtarını tema ayarları sayfasından gerekli kutuya giriniz.";
  3389. exit();
  3390. }
  3391.  
  3392. }
  3393.  
  3394. }
  3395.  
  3396. function user_edit_post_Setting($id)
  3397. {
  3398. global $result;
  3399. if( $id && $_POST && isset($_POST["edit_content_field"]) && wp_verify_nonce($_POST["edit_content_field"], "edit_content_action") )
  3400. {
  3401. $title = $_POST["title"];
  3402. $tip = $_POST["tip"];
  3403. $video = $_POST["video"];
  3404. $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>");
  3405. $cat = $_POST["cat"];
  3406. $tag = $_POST["tag"];
  3407. $tag = explode(",", $tag);
  3408. $taxonomy = array( "category" => $cat, "post_tag" => $tag );
  3409. $my_post = array( );
  3410. $my_post["ID"] = $id;
  3411. $my_post["tax_input"] = $taxonomy;
  3412. $my_post["post_title"] = $title;
  3413. $my_post["post_content"] = $desc;
  3414. $my_post["post_status"] = "pending";
  3415. $my_post_id = wp_update_post($my_post);
  3416. if( $my_post_id )
  3417. {
  3418. if( !empty($_POST["tip"]) )
  3419. {
  3420. update_post_meta($my_post_id, "set_post", $tip);
  3421. }
  3422.  
  3423. if( !empty($_POST["video"]) )
  3424. {
  3425. update_post_meta($my_post_id, "video_embed", $video);
  3426. }
  3427.  
  3428. require_once(ABSPATH . "wp-admin" . "/includes/image.php");
  3429. require_once(ABSPATH . "wp-admin" . "/includes/file.php");
  3430. require_once(ABSPATH . "wp-admin" . "/includes/media.php");
  3431. $filename = $_FILES["input-file-preview"];
  3432. $upload_overrides = array( "test_form" => false );
  3433. $movefile = wp_handle_upload($filename, $upload_overrides);
  3434. if( isset($movefile["file"]) )
  3435. {
  3436. $file_type = wp_check_filetype($movefile["file"]);
  3437. $wp_upload_dir = wp_upload_dir();
  3438. $file_name = rand(1000, 9999) . "_" . basename($filename["name"]);
  3439. $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" );
  3440. if( $file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif" )
  3441. {
  3442. $attach_id = wp_insert_attachment($attachment, $movefile["file"], $my_post_id);
  3443. $attach_data = wp_generate_attachment_metadata($attach_id, $movefile["file"]);
  3444. wp_update_attachment_metadata($attach_id, $attach_data);
  3445. }
  3446.  
  3447. if( !empty($_FILES["input-file-preview"]) && ($file_type["ext"] == "png" || $file_type["ext"] == "jpg" || $file_type["ext"] == "jpg" || $file_type["ext"] == "gif") )
  3448. {
  3449. update_post_meta($my_post_id, "_thumbnail_id", $attach_id);
  3450. }
  3451.  
  3452. }
  3453.  
  3454. $result = "<div class=\"alert-ok\" style=\"margin-bottom:15px;\">" . ecan_get_option("user-edit-post-ok") . "</div>";
  3455. }
  3456. else
  3457. {
  3458. $result = "<div class=\"alert-error\">" . ecan_get_option("user-edit-post-hata") . "</div>";
  3459. }
  3460.  
  3461. }
  3462.  
  3463. }
  3464.  
  3465. function remote_lisans()
  3466. {
  3467. $bol = explode("/", $_SERVER["REQUEST_URI"]);
  3468. if( !in_array("wp-admin", $bol) && !in_array("wp-login.php", $bol) )
  3469. {
  3470. $backlist = "http://www.ecancan.com/newbacklist.txt";
  3471. $alanadi = get_bloginfo("url");
  3472. $ch = curl_init($backlist);
  3473. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0");
  3474. curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  3475. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  3476. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  3477. $veri = curl_exec($ch);
  3478. $control = curl_getinfo($ch);
  3479. curl_close($ch);
  3480. $backlist_text = $veri;
  3481. $backlist_text = str_replace("\"", "", $backlist_text);
  3482. $backlist_text = explode(",", $backlist_text);
  3483. if( $control["http_code"] != 404 && in_array($alanadi, $backlist_text) )
  3484. {
  3485. exit( "LISANS DURDURULMUSTUR : " . $alanadi . " --> ILETISIM ICIN <a href='http://blog.ecancan.com/iletisim'>TIKLA</a>" );
  3486. }
  3487.  
  3488. }
  3489.  
  3490. }
  3491.  
  3492. function admin_block()
  3493. {
  3494. $admin_block_active = ecan_get_option("admin-block");
  3495. $admin_dizin = ecan_get_option("admin-dizin");
  3496. if( $admin_block_active == false )
  3497. {
  3498. global $current_user;
  3499. $user_rol = $current_user->allcaps;
  3500. $user_caps_rr = ecan_get_option("user-caps-ability");
  3501. $user_caps_rr_value = ecan_get_option("user-caps-ability-value");
  3502. if( $user_caps_rr == "" )
  3503. {
  3504. $user_caps_rr = "level_1";
  3505. }
  3506.  
  3507. if( $user_caps_rr_value == "" )
  3508. {
  3509. $user_caps_rr_value = "11";
  3510. }
  3511.  
  3512. 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" )
  3513. {
  3514. wp_redirect(site_url());
  3515. exit();
  3516. }
  3517.  
  3518. }
  3519.  
  3520. }
  3521.  
  3522. function rumorroom_comment($comment, $args, $depth)
  3523. {
  3524. $GLOBALS["comment"] = $comment;
  3525. $user = get_userdata($comment->user_id);
  3526. $cl_id = get_comment_ID();
  3527. $cl_u_id = get_current_user_id();
  3528. global $wpdb;
  3529. $ecan_table_name = $wpdb->prefix . "rr_like_data";
  3530. $comment_like_count = $wpdb->get_results("SELECT * FROM " . $ecan_table_name . " WHERE comment_id=" . $cl_id);
  3531. foreach( $comment_like_count as $cl )
  3532. {
  3533. $cl_count += $cl->like_count;
  3534. }
  3535. $wpdb->get_results("SELECT * FROM " . $ecan_table_name . " WHERE comment_id=" . $cl_id . " AND user_id=" . $cl_u_id);
  3536. $similar_count = $wpdb->num_rows;
  3537. echo " <li ";
  3538. comment_class();
  3539. echo " id=\"li-comment-";
  3540. comment_ID();
  3541. echo "\">\r\n <div id=\"comment-";
  3542. comment_ID();
  3543. echo "\">\r\n <div class=\"comment-author vcard\">\r\n\t\t\t\t\t\t";
  3544. if( $user->ID != 0 && get_the_author_meta("user_avatar_custom", $user->ID) != 0 && get_the_author_meta("user_avatar_custom", $user->ID) != 1 )
  3545. {
  3546. echo "\t\t\t\t\t\t\t<img src=\"";
  3547. echo wp_get_attachment_url(get_the_author_meta("user_avatar_custom", $user->ID));
  3548. echo "\" class=\"avatar photo\" alt=\"avatar\" height=\"48\" width=\"48\" />\r\n\t\t\t\t\t\t";
  3549. }
  3550. else
  3551. {
  3552. 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";
  3553. }
  3554.  
  3555. echo "\t\t\t\r\n\r\n ";
  3556. printf(__("<cite class=\"fn\">%s</cite> <span class=\"says\">says:</span>"), get_comment_author_link());
  3557. echo " </div>\r\n ";
  3558. if( $comment->comment_approved == "0" )
  3559. {
  3560. echo " <em>";
  3561. _e("Your comment is awaiting moderation.");
  3562. echo "</em>\r\n <br />\r\n ";
  3563. }
  3564.  
  3565. echo "\r\n <div class=\"comment-meta commentmetadata\"><a href=\"";
  3566. echo htmlspecialchars(get_comment_link($comment->comment_ID));
  3567. echo "\">";
  3568. printf(__("%1\$s at %2\$s"), get_comment_date(), get_comment_time());
  3569. echo "</a>";
  3570. edit_comment_link(__("(Edit)"), " ", "");
  3571. echo "\t \r\n\t ";
  3572. comment_text();
  3573. echo "\t\t\r\n\t </div>\r\n \r\n\r\n <div class=\"reply\">\r\n\t \r\n\t\t\t";
  3574. comment_reply_link(array_merge($args, array( "depth" => $depth, "max_depth" => $args["max_depth"] )));
  3575. echo "\t\t\t";
  3576. $cmlike = ecan_get_option("cmlike");
  3577. if( $cmlike == true )
  3578. {
  3579. echo "\t\t\t\t\t<span class=\"cl-like-css\">\r\n\t\t\t\t\t\t";
  3580. if( $similar_count < 1 )
  3581. {
  3582. echo "\t\t\t\t\t\t\t<a href=\"#\" class=\"comment-like\" data-comment_id=\"";
  3583. comment_ID();
  3584. echo "\" data-user_id=\"";
  3585. echo $cl_u_id;
  3586. echo "\" data-like_counts=\"";
  3587. if( empty($cl_count) )
  3588. {
  3589. echo $cl_count = 0;
  3590. }
  3591. else
  3592. {
  3593. echo $cl_count;
  3594. }
  3595.  
  3596. echo "\" title=\"Beğen\"><i class=\"fa fa-thumbs-o-up\"></i> ";
  3597. echo $cl_count;
  3598. echo "</a>\r\n\t\t\t\t\t\t";
  3599. }
  3600. else
  3601. {
  3602. echo "\t\t\t\t\t\t\t<a href=\"#\" class=\"comment-like cl-liked\" data-comment_id=\"";
  3603. comment_ID();
  3604. echo "\" data-user_id=\"";
  3605. echo $cl_u_id;
  3606. echo "\" data-like_counts=\"";
  3607. if( empty($cl_count) )
  3608. {
  3609. echo $cl_count = 0;
  3610. }
  3611. else
  3612. {
  3613. echo $cl_count;
  3614. }
  3615.  
  3616. echo "\" title=\"Beğendin\"><i class=\"fa fa-thumbs-up\"></i> ";
  3617. echo $cl_count;
  3618. echo "</a>\r\n\t\t\t\t\t\t";
  3619. }
  3620.  
  3621. echo "\t\t\t\t\t</span>\r\n\t\t\t\t\t";
  3622. }
  3623.  
  3624. echo "\t </div>\r\n </div>\r\n\t </li>\r\n";
  3625. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement