Advertisement
Guest User

Untitled

a guest
Dec 28th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.98 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by http://DeZender.Net
  5. * @ deZender (PHP7 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 4.1.0.1
  8. * @ Author : DeZender
  9. * @ Release on : 29.08.2020
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. class Menu_Icon_Plugin
  15. {
  16. public function __construct()
  17. {
  18. add_action('save_post_nav_menu_item', [$this, 'menu_image_save_post_action'], 10, 3);
  19. add_filter('wp_setup_nav_menu_item', [$this, 'menu_image_wp_setup_nav_menu_item']);
  20. add_filter('nav_menu_css_class', [$this, 'nav_menu_css_class_filter'], 10, 5);
  21. add_action('admin_init', [$this, 'admin_init'], 99);
  22. }
  23.  
  24. public function admin_init()
  25. {
  26. if (!has_action('wp_nav_menu_item_custom_fields')) {
  27. add_filter('wp_edit_nav_menu_walker', [$this, 'menu_image_edit_nav_menu_walker_filter']);
  28. }
  29.  
  30. add_action('wp_nav_menu_item_custom_fields', [$this, 'menu_item_custom_fields'], 10, 4);
  31. }
  32.  
  33. public function menu_image_save_post_action($post_id, $post)
  34. {
  35. $menu_image_settings = ['menu_item_sfr_menu_icon'];
  36.  
  37. foreach ($menu_image_settings as $setting_name) {
  38. if ($post->{'_' . $setting_name} != $_POST[$setting_name][$post_id]) {
  39. update_post_meta($post_id, '_' . $setting_name, esc_sql($_POST[$setting_name][$post_id]));
  40. }
  41. }
  42. }
  43.  
  44. public function menu_image_edit_nav_menu_walker_filter()
  45. {
  46. return 'Menu_Image_Walker_Nav_Menu_Edit';
  47. }
  48.  
  49. public function menu_image_wp_setup_nav_menu_item($item)
  50. {
  51. if (!isset($item->sfr_menu_icon)) {
  52. $item->sfr_menu_icon = get_post_meta($item->ID, '_menu_item_sfr_menu_icon', true);
  53. }
  54.  
  55. return $item;
  56. }
  57.  
  58. public function nav_menu_css_class_filter($classes, $item)
  59. {
  60. $classes[] = $item->sfr_menu_icon;
  61. return $classes;
  62. }
  63.  
  64. public function wp_post_thumbnail_html($item_id)
  65. {
  66. global $safirIcons;
  67. $content = '';
  68. $sfr_menu_icon = get_post_meta($item_id, '_menu_item_sfr_menu_icon', true);
  69. ob_start();
  70. echo "\n\t\t" . '<div class="menu-item-image-options">' . "\n\t\t\t" . '<div class="description description-wide">' . "\n\t\t\t\t" . '<label for="edit-menu-item-image-size-';
  71. echo $item_id;
  72. echo '">Menü ikonu' . "\n\t\t\t\t" . '</label>' . "\n\t\t\t\t\t" . '<br />' . "\n\t\t\t\t\t" . '<input type="text" id="edit-menu-item-image-size-';
  73. echo $item_id;
  74. echo '"' . "\n\t\t\t\t\t\t" . 'class="widefat iconTextBox"' . "\n\t\t\t\t\t\t" . 'name="menu_item_sfr_menu_icon[';
  75. echo $item_id;
  76. echo ']" value="';
  77. echo $sfr_menu_icon;
  78. echo '" style="z-index:1" autocomplete="off">' . "\n\n\n\t\t\t\t\t" . '<div class="safirAdminIconSelector" style="display:none; z-index:2">' . "\n\t\t\t\t\t\t" . '<div class="close">X</div>' . "\n\t\t\t\t\t\t";
  79.  
  80. foreach ($safirIcons as $key => $code) {
  81. echo "\t\t\t\t\t\t\t" . '<div class="item ';
  82. echo $key;
  83. echo ' ';
  84.  
  85. if ($key == $sfr_menu_icon) {
  86. echo 'active';
  87. }
  88.  
  89. echo '" data-value="';
  90. echo $key;
  91. echo '" >' . "\n\t\t\t\t\t\t\t\t" . '<div class="inner">' . "\n\t\t\t\t\t\t\t\t\t" . '<span class="icon"></span>' . "\n\t\t\t\t\t\t\t\t" . '</div>' . "\n\t\t\t\t\t\t\t" . '</div>' . "\n\t\t\t\t\t\t";
  92. }
  93.  
  94. echo "\t\t\t\t\t" . '</div>' . "\n\n\t\t\t\t\t" . '<style>' . "\n\t\t\t\t\t";
  95.  
  96. foreach ($safirIcons as $key => $code) {
  97. echo "\t\t\t\t\t" . '.safirAdminIconSelector .item.';
  98. echo $key;
  99. echo ' span.icon:before {' . "\n\t\t\t\t\t\t" . 'content:"';
  100. echo $code;
  101. echo '";' . "\n\t\t\t\t\t" . '}' . "\n\t\t\t\t\t";
  102. }
  103.  
  104. echo "\t\t\t\t\t" . '</style>' . "\n\n\t\t\t" . '</div>' . "\n\t\t" . '</div>' . "\n\n\t\t";
  105. $content .= ob_get_clean();
  106. return apply_filters('admin_menu_item_thumbnail_html', $content, $item_id);
  107. }
  108.  
  109. public function menu_item_custom_fields($item_id, $item, $depth, $args)
  110. {
  111. if (!$item_id && isset($item->ID)) {
  112. $item_id = $item->ID;
  113. }
  114.  
  115. echo "\t\t" . '<div class="field-image hide-if-no-js wp-media-buttons">' . "\n\t\t\t";
  116. echo $this->wp_post_thumbnail_html($item_id);
  117. echo "\t\t" . '</div>' . "\n\t";
  118. }
  119.  
  120. public function setUsedAttachments($size, $id)
  121. {
  122. $this->used_attachments[$size][] = $id;
  123. }
  124.  
  125. public function isAttachmentUsed($id, $size = NULL)
  126. {
  127. if (!is_null($size)) {
  128. return is_string($size) && isset($this->used_attachments[$size]) && in_array($id, $this->used_attachments[$size]);
  129. }
  130. else {
  131. foreach ($this->used_attachments as $used_attachment) {
  132. if (in_array($id, $used_attachment)) {
  133. return true;
  134. }
  135. }
  136.  
  137. return false;
  138. }
  139. }
  140. }
  141.  
  142. function get_domain($url)
  143. {
  144. $pieces = parse_url($url);
  145. $domain = (isset($pieces['host']) ? $pieces['host'] : '');
  146.  
  147. if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\\-]{1,63}\\.[a-z\\.]{2,6})$/i', $domain, $regs)) {
  148. return $regs['domain'];
  149. }
  150.  
  151. return false;
  152. }
  153.  
  154. function __gc()
  155. {
  156. $site = get_domain(get_bloginfo('url'));
  157. $key = 'R->O->T->A->W->P';
  158. $sfrLicenseCode = hash('sha1', $site . $key);
  159. $sfrLicenseCode = implode('-', str_split($sfrLicenseCode, 4));
  160. return $sfrLicenseCode;
  161. }
  162.  
  163. function add_nofollow_cat($text)
  164. {
  165. $text = str_replace('rel="category tag"', '', $text);
  166. return $text;
  167. }
  168.  
  169. function adminBarMenu()
  170. {
  171. global $wp_admin_bar;
  172. if (!is_super_admin() || !is_admin_bar_showing()) {
  173. return NULL;
  174. }
  175.  
  176. $wp_admin_bar->add_menu(['id' => 'safir_link', 'title' => 'Safir Panel - Tema Ayarları', 'href' => get_bloginfo('url') . '/wp-admin/admin.php?page=safirpanel.php']);
  177. }
  178.  
  179. function xoption($option)
  180. {
  181. $returnedValue = get_option('safir_rota_' . $option);
  182.  
  183. if (is_string($returnedValue)) {
  184. return stripslashes($returnedValue);
  185. }
  186. else {
  187. return $returnedValue;
  188. }
  189. }
  190.  
  191. function setxoption($option, $newvalue)
  192. {
  193. update_option('safir_rota_' . $option, $newvalue);
  194. }
  195.  
  196. function safir_init_widgets()
  197. {
  198. register_widget('sfrNumberWidget');
  199. register_widget('sfrCategoriesWidget');
  200. register_widget('sfrAdvancedPages');
  201. register_widget('sfrAdvancedPostsWidget1');
  202. ....................................................................................
  203. .....................................................
  204. .........................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement