Ejemplo n.º 1
0
 /**
  * add widgets base for the module
  */
 public function add_module_widgets()
 {
     $args = func_get_args();
     $args = hwArray::multi2single($args);
     foreach ($args as $id) {
         $this->get_module()->option('widgets_base', $id, true);
     }
 }
 /**
  * enqueue scripts
  * @example ::enqueue_jquery_libs('jquery-colorbox')
  */
 public static function enqueue_jquery_libs()
 {
     $files = hwArray::multi2single(func_get_args());
     foreach ($files as $file) {
         if (self::get($file)) {
             //enqueue required both of scripts & styles from the lib
             self::get($file)->enqueue();
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Attempt to create a new menu item from import data
  *
  * Fails for draft, orphaned menu items and those without an associated nav_menu
  * or an invalid nav_menu term. If the post type or term object which the menu item
  * represents doesn't exist then the menu item will not be imported (waits until the
  * end of the import to retry again before discarding).
  *
  * @param array $item Menu item details from WXR file
  */
 function _process_menu_item($item)
 {
     // skip draft, orphaned menu items
     if ('draft' == $item['status']) {
         return;
     }
     $menu_slug = false;
     if (isset($item['terms'])) {
         // loop through terms, assume first nav_menu term is correct menu
         foreach ($item['terms'] as $term) {
             if ('nav_menu' == $term['domain']) {
                 $menu_slug = $term['slug'];
                 break;
             }
         }
     }
     // no nav_menu term associated with this menu item
     if (!$menu_slug) {
         _e('Menu item skipped due to missing menu slug', 'wordpress-importer');
         echo '<br />';
         return;
     }
     $menu_id = term_exists($menu_slug, 'nav_menu');
     if (!$menu_id) {
         printf(__('Menu item skipped due to invalid menu slug: %s', 'wordpress-importer'), esc_html($menu_slug));
         echo '<br />';
         return;
     } else {
         $menu_id = is_array($menu_id) ? $menu_id['term_id'] : $menu_id;
     }
     foreach ($item['postmeta'] as $meta) {
         ${$meta}['key'] = $meta['value'];
     }
     //since you know, because we not use import_id feature
     /*if (isset($_menu_item_object_id) && 'taxonomy' == $_menu_item_type && isset( $this->processed_terms[intval($_menu_item_object_id)] ) ) {
           $_menu_item_object_id = $this->processed_terms[intval($_menu_item_object_id)];
       } else if (isset($_menu_item_object_id) && 'post_type' == $_menu_item_type && isset( $this->processed_posts[intval($_menu_item_object_id)] ) ) {
           $_menu_item_object_id = $this->processed_posts[intval($_menu_item_object_id)];
       } else if ( 'custom' != $_menu_item_type ) {
           // associated object is missing or not imported yet, we'll retry later
           $this->missing_menu_items[] = $item;
           return;
       }*/
     if (!empty($_menu_item_menu_item_parent) && isset($this->processed_menu_items[intval($_menu_item_menu_item_parent)])) {
         $_menu_item_menu_item_parent = $this->processed_menu_items[intval($_menu_item_menu_item_parent)];
     } else {
         if (!empty($_menu_item_menu_item_parent) && !empty($item['post_id'])) {
             //for import id
             $this->menu_item_orphans[intval($item['post_id'])] = (int) $_menu_item_menu_item_parent;
             $_menu_item_menu_item_parent = 0;
         } else {
             $_menu_item_menu_item_parent = 0;
         }
     }
     // wp_update_nav_menu_item expects CSS classes as a space separated string
     if (isset($_menu_item_classes)) {
         $_menu_item_classes = maybe_unserialize($_menu_item_classes);
     } else {
         $_menu_item_classes = array();
     }
     if (is_array($_menu_item_classes)) {
         $_menu_item_classes = implode(' ', hwArray::multi2single($_menu_item_classes));
     }
     $args = array('menu-item-object-id' => isset($_menu_item_object_id) ? $_menu_item_object_id : '', 'menu-item-object' => $_menu_item_object, 'menu-item-parent-id' => $_menu_item_menu_item_parent, 'menu-item-position' => intval($item['menu_order']), 'menu-item-type' => $_menu_item_type, 'menu-item-title' => $item['post_title'], 'menu-item-url' => isset($_menu_item_url) ? $_menu_item_url : '', 'menu-item-description' => $item['post_content'], 'menu-item-attr-title' => $item['post_excerpt'], 'menu-item-target' => isset($_menu_item_target) ? $_menu_item_target : '', 'menu-item-classes' => $_menu_item_classes, 'menu-item-xfn' => isset($_menu_item_xfn) ? $_menu_item_xfn : '', 'menu-item-status' => $item['status']);
     $id = wp_update_nav_menu_item($menu_id, 0, $args);
     if ($id && !is_wp_error($id)) {
         $this->tracker->add_import('menu_item', $item, (int) $id);
         $this->processed_menu_items[intval($item['post_id'])] = (int) $id;
     }
 }