Пример #1
0
 /**
  * Function to check for scene and character editing and add the relevant meta boxes.
  * @link : http://codex.wordpress.org/Function_Reference/add_meta_box#Examples
  */
 public static function wpifw_add_cpt_meta()
 {
     global $pagenow, $typenow;
     if (empty($typenow) && !empty($_GET['post'])) {
         $post = get_post($_GET['post']);
         $typenow = $post->post_type;
     }
     if (wpifw_utils::wpifw_isIFEditor()) {
         /**
          * Load media files needed for Uploader
          */
         function load_wp_media_files()
         {
             wp_enqueue_media();
         }
         add_action('admin_enqueue_scripts', 'load_wp_media_files');
         $url = plugins_url();
         wp_enqueue_script('wpifw-media-uploader', $url . '/wp-if-writer/js/wpifw-media-uploader.js', '', '', true);
         wp_enqueue_script('jquery');
         wp_enqueue_script('jquery-ui-draggable');
         wp_enqueue_script('jquery-ui-droppable');
         wp_enqueue_script('jquery-ui-slider');
         wp_enqueue_script('iris');
         if ($pagenow == 'admin.php') {
             wp_enqueue_style('wpifw-navigator-styles', $url . '/wp-if-writer/css/wpifw-scene-navigator.css');
             wp_enqueue_script('wpifw-navigator-scripts', $url . '/wp-if-writer/js/wpifw-scene-navigator.js', '', '', true);
         }
         if ($pagenow == 'index.php') {
             wp_enqueue_style('wpifw-dashboard', $url . '/wp-if-writer/css/wpifw-dashboard.css');
         }
         if (wpifw_utils::wpifw_isAdmin()) {
             wp_enqueue_script('wpifw-site-options', $url . '/wp-if-writer/js/wpifw-site-options.js', '', '', true);
         }
         if ($pagenow == 'post-new.php' or $pagenow == 'post.php') {
             //$url = plugins_url();
             wp_enqueue_script('wpifw', $url . '/wp-if-writer/js/wpifw-admin.js', '', '', true);
             if ($typenow == 'scene') {
                 wp_enqueue_style('wpifw-scene-styles', $url . '/wp-if-writer/css/wpifw-admin.css');
                 wp_enqueue_script('wpifw-admin-tables', $url . '/wp-if-writer/js/wpifw-admin-scene.js', '', '', true);
                 new wpifw_cpt_MetaClass();
                 wpifw_cpt_MetaClass::wpifw_add_meta_box('scene');
             } else {
                 if ($typenow == 'characters') {
                     //Enqueue scripts
                     wp_enqueue_style('wpifw-characters-styles', $url . '/wp-if-writer/css/wpifw-character-options.css');
                     wp_enqueue_script('wpifw-characters-scripts', $url . '/wp-if-writer/js/wpifw-character-options.js', '', '', true);
                     //load Meta Box Class and instantiate
                     new wpifw_cpt_MetaClass();
                     wpifw_cpt_MetaClass::wpifw_add_meta_box('characters');
                 } else {
                     if ($typenow == 'character_defaults') {
                         //Enqueue scripts
                         wp_enqueue_style('wpifw-default-styles', $url . '/wp-if-writer/css/wpifw-character-defaults-options.css');
                         wp_enqueue_script('wpifw-default-scripts', $url . '/wp-if-writer/js/wpifw-character-defaults-options.js', '', '', true);
                         //load Meta Box Class and instantiate
                         new wpifw_cpt_MetaClass();
                         wpifw_cpt_MetaClass::wpifw_add_meta_box('character_defaults');
                     }
                 }
             }
         }
     }
 }