daily pastebin goal
70%
SHARE
TWEET

metabox-option.php

jegtheme Oct 14th, 2015 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /********** save review *****************/
  4.  
  5. function jeg_save_post_review() {
  6.     global $post;
  7.     if(isset($post->post_type) && $post->post_type == 'review'){
  8.  
  9.         // rating
  10.         $ratingarray = $_REQUEST['jmagz_review_rating']['rating'];
  11.         $total = 0;
  12.         $numberofrating = 0;
  13.  
  14.         if(is_array($ratingarray)) {
  15.             foreach ($ratingarray as $rating) {
  16.                 if ($rating['rating_number'] != 0) {
  17.                     if (!empty($rating['rating_text'])) {
  18.                         $total += $rating['rating_number'];
  19.                         $numberofrating++;
  20.                     }
  21.                 }
  22.             }
  23.  
  24.             if($numberofrating > 0)
  25.             {
  26.                 $mean = $total / $numberofrating;
  27.                 $mean = round($mean, 1);
  28.                 update_post_meta($post->ID, 'rating_mean', $mean);
  29.             }
  30.         }
  31.  
  32.         // price lowest
  33.         $pricearray = $_REQUEST['jmagz_review_price']['price'];
  34.         $lowest = 9999999999;
  35.         $changed = false;
  36.         foreach($pricearray as $price){
  37.             if($price['price'] != 0) {
  38.                 if($price['price'] < $lowest) {
  39.                     $lowest = $price['price'];
  40.                     $changed = true;
  41.                 }
  42.             }
  43.         }
  44.         if($changed) {
  45.             update_post_meta($post->ID, 'price_lowest', $lowest);
  46.         } else {
  47.             update_post_meta($post->ID, 'price_lowest', 0);
  48.         }
  49.     }
  50.     return true;
  51. }
  52.  
  53. add_action('save_post','jeg_save_post_review', 99);
  54.  
  55.  
  56. /********** review metabox *****************/
  57.  
  58. function jeg_review_metabox_setup ()
  59. {
  60.     new VP_Metabox(get_template_directory() . '/admin/metabox/review-metabox.php');
  61.     new VP_Metabox(get_template_directory() . '/admin/metabox/review-good-bad-metabox.php');
  62.     new VP_Metabox(get_template_directory() . '/admin/metabox/review-rating-metabox.php');
  63.     new VP_Metabox(get_template_directory() . '/admin/metabox/review-price-metabox.php');
  64. }
  65.  
  66. add_action('after_setup_theme', 'jeg_review_metabox_setup');
  67.  
  68. function load_additional_script_for_review() {
  69.     $screen = get_current_screen();
  70.     if($screen->post_type === 'review' && is_admin()) {
  71.         wp_enqueue_script('jquery');
  72.         wp_enqueue_style('jeg-pagebuilder-metabox', get_template_directory_uri() . '/public/css/backend/metabox.css', null, null);
  73.     }
  74. }
  75.  
  76. add_action('current_screen', 'load_additional_script_for_review');
  77.  
  78.  
  79.  
  80.  
  81. /********** page metabox *****************/
  82.  
  83. function jeg_pagemetabox_setup ()
  84. {
  85.     new VP_Metabox(get_template_directory() . '/admin/metabox/dummy-metabox.php');
  86.     new VP_Metabox(get_template_directory() . '/admin/metabox/page-metabox.php');
  87.     new VP_Metabox(get_template_directory() . '/admin/metabox/page-review-metabox.php');
  88.     new VP_Metabox(get_template_directory() . '/admin/metabox/page-index-metabox.php');
  89. }
  90.  
  91. add_action('after_setup_theme', 'jeg_pagemetabox_setup');
  92.  
  93. function load_additional_script_for_page() {
  94.     $screen = get_current_screen();
  95.     if($screen->post_type === 'page' && is_admin()) {
  96.         wp_enqueue_script('jquery');
  97.         wp_enqueue_script('jeg-page-metabox', get_template_directory_uri() . '/public/js/backend/pagemetabox.js', null, null);
  98.         wp_enqueue_style('jeg-pagebuilder-metabox', get_template_directory_uri() . '/public/css/backend/metabox.css', null, null);
  99.     }
  100. }
  101.  
  102. add_action('current_screen', 'load_additional_script_for_page');
  103.  
  104.  
  105. /********** blog metabox *****************/
  106.  
  107. function jeg_blogmetabox_setup ()
  108. {
  109.     new VP_Metabox(get_template_directory() . '/admin/metabox/gallery.php');
  110.     new VP_Metabox(get_template_directory() . '/admin/metabox/video.php');
  111. }
  112.  
  113. add_action('after_setup_theme', 'jeg_blogmetabox_setup');
  114.  
  115.  
  116. function load_additional_script_for_blog() {
  117.     $screen = get_current_screen();
  118.     if( ( $screen->post_type === 'post' || $screen->post_type === 'review' ) && is_admin()) {
  119.         wp_enqueue_script('jquery');
  120.         wp_enqueue_script('jeg-blog-metabox', get_template_directory_uri() . '/public/js/backend/blogmetabox.js', null, null);
  121.         wp_enqueue_style('jeg-blog-metabox', get_template_directory_uri() . '/public/css/backend/metabox.css', null, null);
  122.     }
  123. }
  124.  
  125. add_action('current_screen', 'load_additional_script_for_blog');
  126.  
  127.  
  128. /********** category builder metabox ************/
  129.  
  130.  
  131. function jeg_builder_metabox_setup ()
  132. {
  133.     new VP_Metabox(get_template_directory() . '/admin/metabox/catbuilder.php');
  134. }
  135.  
  136. add_action('after_setup_theme', 'jeg_builder_metabox_setup');
  137.  
  138. function load_additional_script_for_cat_builder() {
  139.     $screen = get_current_screen();
  140.     if($screen->post_type === 'cat_builder' && is_admin()) {
  141.         wp_enqueue_script('jquery');
  142.         wp_enqueue_style('jeg-pagebuilder-metabox', get_template_directory_uri() . '/public/css/backend/metabox.css', null, null);
  143.     }
  144. }
  145.  
  146. add_action('current_screen', 'load_additional_script_for_cat_builder');
  147.  
  148.  
  149.  
  150. /************ global css script ****************/
  151.  
  152. function load_additional_style() {
  153.     if(is_admin()) {
  154.         wp_enqueue_style ('jeg-global-css', get_template_directory_uri() . '/public/css/backend/global.css', null, null);
  155.     }
  156. }
  157.  
  158. add_action('current_screen', 'load_additional_style');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top