evolve_ThemeFrameworkMetaboxes

The evolve evolve ThemeFrameworkMetaboxes class.

Defined (1)

The class is defined in the following location(s).

/library/views/metaboxes/metaboxes.php  
  1. class evolve_ThemeFrameworkMetaboxes { 
  2.  
  3. public function __construct() { 
  4. global $smof_data; 
  5. $this->data = $smof_data; 
  6.  
  7. add_action('add_meta_boxes', array($this, 'evolve_add_meta_boxes')); 
  8. add_action('save_post', array($this, 'evolve_save_meta_boxes')); 
  9. add_action('admin_print_scripts-post.php', array($this, 'evolve_print_metabox_scripts')); 
  10. add_action('admin_print_scripts-post-new.php', array($this, 'evolve_print_metabox_scripts')); 
  11. add_action('admin_enqueue_scripts', array($this, 'evolve_admin_script_loader')); 
  12.  
  13. // Load backend scripts 
  14. function evolve_admin_script_loader() { 
  15. global $pagenow; 
  16. if (is_admin() && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { 
  17. wp_register_script('evolve_upload', get_template_directory_uri() . '/library/media/js/upload.js'); 
  18. wp_enqueue_script('evolve_upload'); 
  19. wp_enqueue_script('media-upload'); 
  20. wp_enqueue_script('thickbox'); 
  21. wp_enqueue_style('thickbox'); 
  22.  
  23. public function evolve_add_meta_boxes() { 
  24. $this->evolve_add_meta_box('evolve_post_options', 'Post Options', 'post'); 
  25. $this->evolve_add_meta_box('evolve_page_options', 'Page Options', 'page'); 
  26.  
  27. public function evolve_add_meta_box($id, $label, $post_type) { 
  28. add_meta_box( 
  29. 'evolve_' . $id, $label, array($this, $id), $post_type 
  30. ); 
  31.  
  32. public function evolve_save_meta_boxes($post_id) { 
  33. if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 
  34. return; 
  35.  
  36. foreach ($_POST as $key => $value) { 
  37. if (strstr($key, 'evolve_')) { 
  38. update_post_meta($post_id, $key, $value); 
  39.  
  40. public function evolve_post_options() { 
  41. get_template_part('library/views/metaboxes/style'); 
  42. $this->evolve_render_option_tabs(array('layout', 'pagetitlebar', 'widget', 'slider')); 
  43.  
  44. public function evolve_page_options() { 
  45. get_template_part('library/views/metaboxes/style'); 
  46. $this->evolve_render_option_tabs(array('layout', 'pagetitlebar', 'widget', 'slider')); 
  47.  
  48. public function evolve_print_metabox_scripts() { 
  49. wp_register_style( 
  50. 'evolve-icomoon', get_template_directory_uri() . '/library/admin/icomoon-admin/style.css', array(), time(), 'all' 
  51. ); 
  52. wp_enqueue_style('evolve-icomoon'); 
  53.  
  54. public function evolve_text($id, $label, $desc = '') { 
  55. global $post; 
  56.  
  57. $html = ''; 
  58. $html .= '<div class="t4p_metabox_field">'; 
  59. $html .= '<label for="evolve_' . $id . '">'; 
  60. $html .= $label; 
  61. $html .= '</label>'; 
  62. $html .= '<div class="field">'; 
  63. $html .= '<input type="text" id="evolve_' . $id . '" name="evolve_' . $id . '" value="' . get_post_meta($post->ID, 'evolve_' . $id, true) . '" />'; 
  64. if ($desc) { 
  65. $html .= '<p>' . $desc . '</p>'; 
  66. $html .= '</div>'; 
  67. $html .= '</div>'; 
  68.  
  69. echo $html; 
  70.  
  71. public function evolve_select($id, $label, $options, $desc = '') { 
  72. global $post; 
  73.  
  74. $html = ''; 
  75. $html .= '<div class="t4p_metabox_field">'; 
  76. $html .= '<label for="evolve_' . $id . '">'; 
  77. $html .= $label; 
  78. $html .= '</label>'; 
  79. $html .= '<div class="field">'; 
  80. $html .= '<select id="evolve_' . $id . '" name="evolve_' . $id . '">'; 
  81. foreach ($options as $key => $option) { 
  82. if (get_post_meta($post->ID, 'evolve_' . $id, true) == $key) { 
  83. $selected = 'selected="selected"'; 
  84. } else { 
  85. $selected = ''; 
  86.  
  87. $html .= '<option ' . $selected . 'value="' . $key . '">' . $option . '</option>'; 
  88. $html .= '</select>'; 
  89. if ($desc) { 
  90. $html .= '<p>' . $desc . '</p>'; 
  91. $html .= '</div>'; 
  92. $html .= '</div>'; 
  93.  
  94. echo $html; 
  95.  
  96. public function evolve_multiple($id, $label, $options, $desc = '') { 
  97. global $post; 
  98.  
  99. $html = ''; 
  100. $html .= '<div class="t4p_metabox_field">'; 
  101. $html .= '<label for="t4p_' . $id . '">'; 
  102. $html .= $label; 
  103. $html .= '</label>'; 
  104. $html .= '<div class="field">'; 
  105. $html .= '<select multiple="multiple" id="t4p_' . $id . '" name="evolve_' . $id . '[]">'; 
  106. foreach ($options as $key => $option) { 
  107. if (is_array(get_post_meta($post->ID, 'evolve_' . $id, true)) && in_array($key, get_post_meta($post->ID, 'evolve_' . $id, true))) { 
  108. $selected = 'selected="selected"'; 
  109. } else { 
  110. $selected = ''; 
  111.  
  112. $html .= '<option ' . $selected . 'value="' . $key . '">' . $option . '</option>'; 
  113. $html .= '</select>'; 
  114. if ($desc) { 
  115. $html .= '<p>' . $desc . '</p>'; 
  116. $html .= '</div>'; 
  117. $html .= '</div>'; 
  118.  
  119. echo $html; 
  120.  
  121. public function evolve_textarea($id, $label, $desc = '', $default = '') { 
  122. global $post; 
  123.  
  124. $db_value = get_post_meta($post->ID, 'evolve_' . $id, true); 
  125.  
  126. if ($db_value) { 
  127. $value = $db_value; 
  128. } else { 
  129. $value = $default; 
  130.  
  131. $html = ''; 
  132. $html = ''; 
  133. $html .= '<div class="t4p_metabox_field">'; 
  134. $html .= '<label for="evolve_' . $id . '">'; 
  135. $html .= $label; 
  136. $html .= '</label>'; 
  137. $html .= '<div class="field">'; 
  138. $html .= '<textarea cols="120" rows="10" id="evolve_' . $id . '" name="evolve_' . $id . '">' . $value . '</textarea>'; 
  139. if ($desc) { 
  140. $html .= '<p>' . $desc . '</p>'; 
  141. $html .= '</div>'; 
  142. $html .= '</div>'; 
  143.  
  144. echo $html; 
  145.  
  146. //added by denzel, image radio button. 
  147. public function evolve_image_radio_button($id, $label, $options, $desc = '', $default = '') { 
  148. global $post; 
  149. $class = ''; 
  150. $checked = ''; 
  151. $javascript_ids = ''; 
  152. foreach ($options as $k => $v) { 
  153. $javascript_ids .= "#image_{$k}, "; 
  154. $javascript_ids = rtrim($javascript_ids, ", "); 
  155.  
  156. $html = ''; 
  157. $html .= '<div class="t4p_metabox_field">'; 
  158. $html .= '<label for="evolve_' . $id . '">'; 
  159. $html .= $label; 
  160. $html .= '</label>'; 
  161. $html .= '<div class="field">'; 
  162. foreach ($options as $key => $option) { 
  163. $html .= '<input type="radio" style="display:none;" id="' . $key . '" name="evolve_' . $id . '" value="' . $key . '" '; 
  164. if (get_post_meta($post->ID, 'evolve_' . $id, true) == $key) { 
  165. $checked = 'checked="checked"'; 
  166. $class = 'evolve_img_border_radio evolve_img_selected'; 
  167. } elseif (get_post_meta($post->ID, 'evolve_' . $id, true) == '' && $key == $default) { 
  168. $checked = 'checked="checked"'; 
  169. $class = 'evolve_img_border_radio evolve_img_selected'; 
  170. } else { 
  171. $checked = ''; 
  172. $class = 'evolve_img_border_radio'; 
  173.  
  174. $html .= $checked . ">"; 
  175. $html .= "<img src='$option' alt='' id='image_$key' class='$class' onclick='document.getElementById(\"$key\").checked=true;jQuery(\"$javascript_ids\").removeClass(\"evolve_img_selected\");jQuery(this).addClass(\"evolve_img_selected\");' />"; 
  176. $html .= '</div>'; 
  177. $html .= '</div>'; 
  178.  
  179. echo $html; 
  180.  
  181. public function evolve_upload($id, $label, $desc = '') { 
  182. global $post; 
  183.  
  184. $evolve_upload_img_id = get_post_meta($post->ID, 'evolve_' . $id, true); 
  185. $evolve_upload_src = wp_get_attachment_image_src($evolve_upload_img_id, 'full'); 
  186. $evolve_upload_have_img = is_array($evolve_upload_src); 
  187.  
  188. $html = ''; 
  189. $html .= '<div class="t4p_metabox_field .redux-main">'; 
  190. $html .= '<label for="evolve_' . $id . '">'; 
  191. $html .= $label; 
  192. $html .= '</label>'; 
  193. $html .= '<div class="field">'; 
  194. $hide1 = ''; 
  195. $hide2 = ''; 
  196. if ($evolve_upload_have_img) { 
  197. $hide1 = 'hidden'; 
  198. if (!$evolve_upload_have_img) { 
  199. $hide2 = 'hidden'; 
  200.  
  201. $html .= '<input type="text" id="evolve-media-remove-extra-' . $id . '" class="upload_field ' . $hide1 . '" value="" /></br>'; 
  202.  
  203. $html .= '<div id="evolve-media-display-' . $id . '">'; 
  204. if ($evolve_upload_have_img) : 
  205. $html .= '<input type="text" class="upload_field" value="' . $evolve_upload_src[0] . '" /></br>'; 
  206. $html .= '<img src="' . $evolve_upload_src[0] . '" class="redux-option-image" style="width:60px; height:60px;" />'; 
  207. endif; 
  208. $html .= '</div>'; 
  209.  
  210. $html .= '<input class="evolve_upload_button button ' . $hide1 . '" id="evolve-media-upload-' . $id . '" data-media-id="' . $id . '" type="button" value="Upload" />'; 
  211. $html .= '<input class="evolve_remove_button button ' . $hide2 . '" id="evolve-media-remove-' . $id . '" data-media-id="' . $id . '" type="button" value="Remove" />'; 
  212. if ($desc) { 
  213. $html .= '<p>' . $desc . '</p>'; 
  214. $html .= '</div>'; 
  215. $html .= '</div>'; 
  216. $html .= '<input type="hidden" id="evolve_' . $id . '" name="evolve_' . $id . '" value="' . get_post_meta($post->ID, 'evolve_' . $id, true) . '" />'; 
  217.  
  218. echo $html; 
  219.  
  220. public function evolve_render_option_tabs($requested_tabs, $post_type = 'default') { 
  221. $tabs_names = array( 
  222. 'layout' => __('Layout', 'evolve'),  
  223. 'pagetitlebar' => __('Page Title / Breadcrumbs / Page Title Bar', 'evolve'),  
  224. 'widget' => __('Widgets', 'evolve'),  
  225. 'slider' => __('Slider', 'evolve'),  
  226. 'sidebars' => __('Sidebar', 'evolve'),  
  227. ); 
  228.  
  229. $tabs_icons = array( 
  230. 'layout' => 't4p-icon-appbartools',  
  231. 'pagetitlebar' => 't4p-icon-file2',  
  232. 'widget' => 't4p-icon-appbarimagebacklight',  
  233. 'slider' => 't4p-icon-appbarmonitor',  
  234. 'sidebars' => 't4p-icon-file',  
  235. ); 
  236.  
  237. echo '<ul class="t4p_metabox_tabs">'; 
  238.  
  239. foreach ($requested_tabs as $key => $tab_name) { 
  240. $class_active = ''; 
  241. if ($key === 0) { 
  242. $class_active = ' class="active"'; 
  243.  
  244. if ($tab_name == 'page' && 
  245. $post_type == 'product' 
  246. ) { 
  247. printf('<li%s><a href="%s">%s</a></li>', $class_active, $tab_name, $tabs_names[$post_type]); 
  248. } else { 
  249. printf('<li%s><a href="%s"><i class="%s"></i>%s</a></li>', $class_active, $tab_name, $tabs_icons[$tab_name], $tabs_names[$tab_name]); 
  250.  
  251. echo '</ul>'; 
  252.  
  253. echo '<div class="t4p_metabox_main">'; 
  254.  
  255. foreach ($requested_tabs as $key => $tab_name) { 
  256. $class_active = ''; 
  257. if ($key === 0) { 
  258. $class_active = 'active'; 
  259. printf('<div class="t4p_metabox_tab %s" id="t4p_tab_%s">', $class_active, $tab_name); 
  260. require_once( sprintf('page_tabs/tab_%s.php', $tab_name) ); 
  261. echo '</div>'; 
  262.  
  263. echo '</div>'; 
  264. echo '<div class="clear"></div>'; 
  265.