Guest User

Untitled

a guest
Jun 8th, 2020
32
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.0
  8. * @ Author : DeZender
  9. * @ Release on : 15.05.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. $sfr_menu_icon = get_post_meta($item_id, '_menu_item_sfr_menu_icon', true);
  68. ob_start();
  69. 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-';
  70. echo $item_id;
  71. 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-';
  72. echo $item_id;
  73. echo '"' . "\n\t\t\t\t\t\t" . 'class="widefat iconTextBox"' . "\n\t\t\t\t\t\t" . 'name="menu_item_sfr_menu_icon[';
  74. echo $item_id;
  75. echo ']" value="';
  76. echo $sfr_menu_icon;
  77. 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";
  78.  
  79. foreach ($safirIcons as $key => $code) {
  80. echo "\t\t\t\t\t\t\t" . '<div class="item ';
  81. echo $key;
  82. echo ' ';
  83.  
  84. if ($key == $sfr_menu_icon) {
  85. echo 'active';
  86. }
  87.  
  88. echo '" data-value="';
  89. echo $key;
  90. 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";
  91. }
  92.  
  93. echo "\t\t\t\t\t" . '</div>' . "\n\n\t\t\t\t\t" . '<style>' . "\n\t\t\t\t\t";
  94.  
  95. foreach ($safirIcons as $key => $code) {
  96. echo "\t\t\t\t\t" . '.safirAdminIconSelector .item.';
  97. echo $key;
  98. echo ' span.icon:before {' . "\n\t\t\t\t\t\t" . 'content:"';
  99. echo $code;
  100. echo '";' . "\n\t\t\t\t\t" . '}' . "\n\t\t\t\t\t";
  101. }
  102.  
  103. echo "\t\t\t\t\t" . '</style>' . "\n\n\t\t\t" . '</div>' . "\n\t\t" . '</div>' . "\n\n\t\t";
  104. $content .= ob_get_clean();
  105. return apply_filters('admin_menu_item_thumbnail_html', $content, $item_id);
  106. }
  107.  
  108. public function menu_item_custom_fields($item_id, $item, $depth, $args)
  109. {
  110. if (!$item_id && isset($item->ID)) {
  111. $item_id = $item->ID;
  112. }
  113.  
  114. echo "\t\t" . '<div class="field-image hide-if-no-js wp-media-buttons">' . "\n\t\t\t";
  115. echo $this->wp_post_thumbnail_html($item_id);
  116. echo "\t\t" . '</div>' . "\n\t";
  117. }
  118.  
  119. public function setUsedAttachments($size, $id)
  120. {
  121. $this->used_attachments[$size][] = $id;
  122. }
  123.  
  124. public function isAttachmentUsed($id, $size = NULL)
  125. {
  126. if (!is_null($size)) {
  127. return is_string($size) && isset($this->used_attachments[$size]) && in_array($id, $this->used_attachments[$size]);
  128. }
  129. else {
  130. foreach ($this->used_attachments as $used_attachment) {
  131. if (in_array($id, $used_attachment)) {
  132. ......................................................................
  133. .................................
  134. ..............
RAW Paste Data