/** * @param array $tree */ public static function build_custom_wp_menu($tree) { global $menu, $submenu; $root =& $tree['root']; $root_wf =& $tree['root_widget_features']; $root_hoangweb =& $tree['root_hoangweb']; if (isset($tree['menu'])) { $menu =& $tree['menu']; } if (isset($tree['submenu'])) { $submenu =& $tree['submenu']; } //$modules_submenus = HW_HOANGWEB::get_wp_option('other_modules_submenus', array()); //HW_HOANGWEB::del_wp_option('other_modules_submenus'); do_action('hw_build_custom_wp_menu', $tree); $modules_submenus = array(); //build custom wp menu under hoangweb settings foreach (HW_HOANGWEB_Settings::get_menus_data('menus') as $name => $menu_arg) { #if(isset($data['menus'])) #foreach($data['menus'] as $menu_arg) { $root_hoangweb[] = $menu_arg; #} } //build custom wp menu for widget features page foreach (HW_Widget_Features_Setting::get_menus_data() as $name => $data) { foreach ($data['features_tab_menus'] as $menu_arg) { $menu_arg = HW_Widget_Features_Setting::valid_custom_submenu($menu_arg); $root_wf[] = $menu_arg; } } //for modules settings page foreach (HW_Module_Settings_page::get_menus_data() as $module => $data) { #HW_Module_Settings_page::get_module_data($module, 'menus') //main tab setting page for the module if (!empty($data['modules_tab_menus'])) { foreach ($data['modules_tab_menus'] as $menu_arg) { $menu_arg[0] = ':: ' . $menu_arg[0]; //dishtingish to other $menu_arg = HW_Module_Settings_page::valid_custom_submenu($menu_arg); $root[] = $menu_arg; } } if (!empty($data['other_menus']['menus'])) { foreach ($data['other_menus']['menus'] as $menu_slug) { $slug = is_array($menu_slug) ? $menu_slug['slug'] : $menu_slug; //get menu slug $_menu = new HW_Array_List_items_path($menu, $slug); $moving_menu = $_menu->get_search_item(1); #_print($moving_menu);#exit; if (!$moving_menu) { continue; } //move submenu module under main settings menu $moving_menu = HW_Module_Settings_page::valid_custom_submenu($moving_menu); //delete old menu $_menu->remove_search_item(1, $menu); $root[] = $moving_menu; //find it's submenus $_submenu = new HW_Array_List_items_path($submenu, $slug); $submenus_list = $_submenu->get_search_item(1); if (!$submenus_list) { $submenus_list = $moving_menu; //get parent menu as submenu } if (!hwArray::is_multi($submenus_list)) { //make more menus in list $submenus_list = array($submenus_list); } //adding new data item menu for post type if (!$_submenu->get_search_item(1) && strpos($moving_menu[2], 'edit.php?post_type=') !== false) { $add_new_menuitem = array('Thêm mới', 'edit_posts', str_replace('edit.php?', 'post-new.php?', $moving_menu[2])); $submenus_list[] = HW_Module_Settings_page::valid_custom_submenu($add_new_menuitem); } if (empty($modules_submenus[$module])) { $modules_submenus[$module] = array('sub' => $submenus_list, 'parent' => $moving_menu); } elseif (!empty($modules_submenus[$module]['sub'])) { $modules_submenus[$module]['sub'] = array_merge($modules_submenus[$module]['sub'], $submenus_list); } } } //other menus created by module if (!empty($data['other_menus']['sub_menus'])) { foreach ($data['other_menus']['sub_menus'] as $menu_slug) { $slug = is_array($menu_slug) ? $menu_slug['slug'] : $menu_slug; //get menu slug $_menu = new HW_Array_List_items_path($submenu, $slug); $moving_menu = $_menu->get_search_item(); $moving_menu = HW_Module_Settings_page::valid_custom_submenu($moving_menu); if (!$moving_menu) { continue; } //delete old position $_menu->remove_search_item(0, $submenu); $root[] = $moving_menu; //also add submenu to module boxes menu list $submenus_list = array($moving_menu); if (empty($modules_submenus[$module])) { $modules_submenus[$module] = array('sub' => $submenus_list, 'parent' => $moving_menu); } elseif (!empty($modules_submenus[$module]['sub'])) { $modules_submenus[$module]['sub'] = array_merge($modules_submenus[$module]['sub'], $submenus_list); } } } } //save to db options if (count($modules_submenus)) { HW_HOANGWEB::add_wp_option('other_modules_submenus', $modules_submenus); } if ($menu) { HW_HOANGWEB::add_wp_option('hw_custom_wp_menu', $menu); } if ($submenu) { HW_HOANGWEB::add_wp_option('hw_custom_wp_submenu', $submenu); } }
/** * generate url * @return string */ public static function generate_url() { $paths = func_get_args(); $str = ''; if (class_exists('hwArray') && hwArray::is_multi($paths)) { $paths = $paths[0]; } foreach ($paths as $path) { if (trim($path) === '') { continue; } $str .= ltrim(trim($path), '\\/') . '/'; } //wrong for http schema http:// $str = preg_replace('%[\\\\]+%', '\\', $str); $str = preg_replace('%[/]+%', '/', $str); $str = rtrim($str, '\\/'); //fix for http:// if (strpos($str, 'http:/') === 0 || !strpos($str, 'http://') !== 0) { $str = preg_replace('%^http:/%', 'http://', trim($str)); } if (strpos($str, 'https:/') === 0 || !strpos($str, 'https://') !== 0) { $str = preg_replace('%^https:/%', 'https://', trim($str)); } return $str; }
/** * 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(); } } }
/** * extend from wordpress core * @param string $output * @param object $category * @param int $depth * @param array $args * @param int $id */ public function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { if (!empty($args['mydata']['skin_setting'])) { $skin_setting = $args['mydata']['skin_setting']; } $this->current_cat = new HW_TimberTerm($category); /** This filter is documented in wp-includes/category-template.php */ $cat_name = apply_filters('list_cats', esc_attr($category->name), $category); //valid $options = (object) $args['options']; if (!isset($options->before)) { $options->before = ''; } if (!isset($options->submenu_before)) { $options->submenu_before = ''; } if (!isset($options->after)) { $options->after = ''; } if (!isset($options->submenu_after)) { $options->submenu_after = ''; } if (!isset($options->link_before)) { $options->link_before = ''; } if (!isset($options->submenu_link_before)) { $options->submenu_link_before = ''; } if (!isset($options->link_after)) { $options->link_after = ''; } if (!isset($options->submenu_link_after)) { $options->submenu_link_after = ''; } //whether current menu item has sub menu $item_has_sub = $this->item_has_sub($category); //separator if (!empty($options->ex_separator) && isset($options->show_items_separator)) { $output .= $options->ex_separator; } $data['args'] = hwArray::cloneArray($options); $data['indent'] = $indent = $depth ? str_repeat("\t", $depth) : ''; $data['item_has_sub'] = $item_has_sub; $id = apply_filters('hw_cat_item_id', 'cat-item-' . $category->term_id, $category, $args, $depth); $data['id'] = ' id="cat-' . esc_attr($category->term_id) . '"'; if ($item_has_sub && !empty($options->remove_link_parent)) { $data['remove_link_parent'] = true; } else { $data['remove_link_parent'] = false; } //item class //category item class $classes[] = 'cat-item cat-item-' . $category->term_id; if (!empty($args['current_category'])) { $_current_category = get_term($args['current_category'], $category->taxonomy); if ($category->term_id == $args['current_category']) { $classes[] = 'current-cat'; if (isset($skin_setting['current_item_class'])) { $classes[] = ' ' . $skin_setting['current_item_class']; } } elseif ($category->term_id == $_current_category->parent) { $classes[] = 'current-cat-parent'; } } if ($item_has_sub && !empty($options->menu_item_class_has_submenu)) { //cat item class has submenu $classes[] = $options->menu_item_class_has_submenu; } if ($depth > 0 && !empty($options->menu_item_class_submenu)) { //cat item class in submenu $classes[] = $options->menu_item_class_submenu; } $data['classes'] = $class_names = join(' ', apply_filters('cat_item_css_class', HW_Validation::valid_classes_attr(array_filter($classes)), $category, $args, $depth)); //custom fields $custom_item = get_post_custom($category->term_id); $data['field-01'] = isset($custom_item['menu-item-field-01'][0]) ? $custom_item['menu-item-field-01'][0] : ''; $data['field-02'] = isset($custom_item['menu-item-field-02'][0]) ? $custom_item['menu-item-field-02'][0] : ''; //cat item image if (isset($options->show_icon) && $options->show_icon) { $image_url = HW_ACF_Taxonomy::get_field_image($category); if ($image_url) { $image_img = '<img src="' . $image_url . '" class="hw-cat-item-icon"/>'; } else { $image_img = ''; } } $data['image_url'] = isset($image_url) ? $image_url : ''; $data['image_img'] = isset($image_img) ? $image_img : ''; /** * anchor attributes */ $atts = array(); $atts['href'] = esc_url(get_term_link($category)); $atts['class'] = array(); //anchor classes if ($item_has_sub && isset($options->anchor_class_has_submenu)) { //anchor class has submenu $atts['class'][] = $options->anchor_class_has_submenu; } if ($depth > 0 && !empty($options->anchor_class_submenu)) { //anchor class in submenu $atts['class'][] = $options->anchor_class_submenu; } $atts = apply_filters('hw_cat_link_attributes', $atts, $category, $args, $depth, $this); //validation $atts['class'] = HW_Validation::valid_classes_attr(array_filter($atts['class'])); $atts['class'] = join(' ', $atts['class']); if ($args['use_desc_for_title'] && !empty($category->description)) { $atts['title'] = esc_attr(strip_tags(apply_filters('category_description', $category->description, $category))); } $attributes = HW_UI_Component::generateAttributes($atts); //addition attribute build for item link if ($depth == 0 && !empty($options->anchor_attrs)) { $attributes .= " {$options->anchor_attrs}"; } elseif ($depth != 0 && !empty($options->anchor_attrs_submenu)) { $attributes .= " {$options->anchor_attrs_submenu}"; } //attributes item link for submenu if ($item_has_sub && !empty($options->anchor_attrs_has_submenu)) { $attributes .= " {$options->anchor_attrs_has_submenu}"; } $data['attributes'] = $attributes; $data['title'] = apply_filters('the_title', $category->name, $category->term_id); $link = $options->before; $link .= '<a ' . $attributes . ' >'; $link .= $options->link_before . $cat_name . $options->link_after; $link .= '</a>'; $link .= $options->after; //feed image if (!empty($args['feed_image']) || !empty($args['feed'])) { $link .= ' '; if (empty($args['feed_image'])) { $link .= '('; } $link .= '<a href="' . esc_url(get_term_feed_link($category->term_id, $category->taxonomy, $args['feed_type'])) . '"'; if (empty($args['feed'])) { $alt = ' alt="' . sprintf(__('Feed for all posts filed under %s'), $cat_name) . '"'; } else { $alt = ' alt="' . $args['feed'] . '"'; $name = $args['feed']; $link .= empty($args['title']) ? '' : $args['title']; } $link .= '>'; if (empty($args['feed_image'])) { $link .= $name; } else { $link .= "<img src='" . $args['feed_image'] . "'{$alt}" . ' />'; } $link .= '</a>'; if (empty($args['feed_image'])) { $link .= ')'; } } if (!empty($args['show_count'])) { $link .= ' (' . number_format_i18n($category->count) . ')'; } //render cat item if (isset($args['twig']) && HW_NAVMENU::twig_asset_exists('start_el.twig', $args['twig'])) { $tpl = $args['twig']->loadTemplate('start_el.twig'); $data['term'] = $this->current_cat; $output .= $tpl->render($data); } else { if ('list' == $args['style']) { $output .= $indent . "\t<li"; //class attr $output .= ' class="' . $class_names . '"'; $output .= ">{$link}\n"; } else { $output .= "\t{$link}<br />\n"; } } }
/** * do shortcode * @return string * @example <hw:shortcode type="image" value="images/1.gif"/> */ private function parse_shortcode() { $shortcodes = array('image' => 'hw_image', 'url' => 'hw_url'); $atts = $this->getAttributes(); if (!isset($shortcodes[$atts['type']])) { return; } $sc = $shortcodes[$atts['type']]; unset($atts['type']); //remove shortcode tag from attr //$content = (string)$this->get(); $content = $this->get()->nodeValue; //->textContent if (!$content && isset($atts['value'])) { $content = $atts['value']; } return do_shortcode('[' . $sc . ' ' . hwArray::array_to_attrs($atts) . ']' . $content . '[/' . $sc . ']'); }
/** * print output from command * @param $msg */ public function command_output($msg) { if (is_array($msg)) { hwArray::json_output($msg); } else { print_r($msg); } echo '<br/>'; }
/** * do import for posts * @param $post * @return array */ public function process_post($post) { $post_id = $this->get_tag($post, 'wp:post_id'); $post_title = $this->get_tag($post, 'title'); $post_date = $this->get_tag($post, 'wp:post_date'); $post_date_gmt = $this->get_tag($post, 'wp:post_date_gmt'); $comment_status = $this->get_tag($post, 'wp:comment_status'); $ping_status = $this->get_tag($post, 'wp:ping_status'); $status = $this->get_tag($post, 'wp:status'); $post_name = $this->get_tag($post, 'wp:post_name'); $post_parent = $this->get_tag($post, 'wp:post_parent'); $menu_order = $this->get_tag($post, 'wp:menu_order'); $post_type = $this->get_tag($post, 'wp:post_type'); $post_password = $this->get_tag($post, 'wp:post_password'); $is_sticky = $this->get_tag($post, 'wp:is_sticky'); $guid = $this->get_tag($post, 'guid'); $post_author = $this->get_tag($post, 'dc:creator'); $post_excerpt = $this->get_tag($post, 'excerpt:encoded'); $post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_excerpt); $post_excerpt = str_replace('<br>', '<br />', $post_excerpt); $post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt); $post_content = $this->get_tag($post, 'content:encoded'); $post_content = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_content); $post_content = str_replace('<br>', '<br />', $post_content); $post_content = str_replace('<hr>', '<hr />', $post_content); $post_content = $this->parser->pre_shortcode_tags($post_content); $postdata = compact('post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', 'post_title', 'status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent', 'menu_order', 'post_type', 'post_password', 'is_sticky'); $attachment_url = $this->get_tag($post, 'wp:attachment_url'); if ($attachment_url) { $postdata['attachment_url'] = $attachment_url; } //hw attachment preg_match_all('|<hw:attachment>(.+?)</hw:attachment>|is', $post, $attachments); $attachments = $attachments[1]; if ($attachments) { foreach ($attachments as $p) { $hw_attachment_url = $this->get_tag($p, 'hw:url'); if ($hw_attachment_url) { if (!HW_URL::valid_url($hw_attachment_url)) { $postdata['attachment_url'] = $this->parser->data('import_path') . $hw_attachment_url; } else { $postdata['attachment_url'] = $hw_attachment_url; } //found new attachment in post if ($post_type !== 'attachment') { $_postdata = hwArray::cloneArray($postdata); $_postdata['post_content'] = HW_String::limit($_postdata['post_content'], 50); $_postdata['post_excerpt'] = HW_String::limit($_postdata['post_excerpt'], 50); $_postdata['post_type'] = 'attachment'; $_postdata['_id'] = $this->get_tag($p, 'hw:_id'); $_postdata['thumbnail'] = $this->get_tag($p, 'hw:thumbnail'); if ($_postdata['thumbnail']) { $_postdata['hw_thumbnail_id'] = $this->get_tag($p, 'hw:_id'); } $this->posts[] = $_postdata; } /*else { $postdata['thumbnail'] = $this->get_tag($p, 'hw:thumbnail'); if($postdata['thumbnail']) $postdata['hw_thumbnail_id'] = $this->get_tag($p, 'hw:_id'); }*/ } } } preg_match_all('|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER); foreach ($terms as $t) { $post_terms[] = array('slug' => $t[2], 'domain' => $t[1], 'name' => str_replace(array('<![CDATA[', ']]>'), '', $t[3])); } if (!empty($post_terms)) { $postdata['terms'] = $post_terms; } preg_match_all('|<wp:comment>(.+?)</wp:comment>|is', $post, $comments); $comments = $comments[1]; if ($comments) { foreach ($comments as $comment) { preg_match_all('|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta); $commentmeta = $commentmeta[1]; $c_meta = array(); foreach ($commentmeta as $m) { $c_meta[] = array('key' => $this->get_tag($m, 'wp:meta_key'), 'value' => $this->get_tag($m, 'wp:meta_value')); } $post_comments[] = array('comment_id' => $this->get_tag($comment, 'wp:comment_id'), 'comment_author' => $this->get_tag($comment, 'wp:comment_author'), 'comment_author_email' => $this->get_tag($comment, 'wp:comment_author_email'), 'comment_author_IP' => $this->get_tag($comment, 'wp:comment_author_IP'), 'comment_author_url' => $this->get_tag($comment, 'wp:comment_author_url'), 'comment_date' => $this->get_tag($comment, 'wp:comment_date'), 'comment_date_gmt' => $this->get_tag($comment, 'wp:comment_date_gmt'), 'comment_content' => $this->get_tag($comment, 'wp:comment_content'), 'comment_approved' => $this->get_tag($comment, 'wp:comment_approved'), 'comment_type' => $this->get_tag($comment, 'wp:comment_type'), 'comment_parent' => $this->get_tag($comment, 'wp:comment_parent'), 'comment_user_id' => $this->get_tag($comment, 'wp:comment_user_id'), 'commentmeta' => $c_meta); } } if (!empty($post_comments)) { $postdata['comments'] = $post_comments; } preg_match_all('|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta); $postmeta = $postmeta[1]; if ($postmeta) { foreach ($postmeta as $p) { $post_postmeta[] = array('key' => $this->get_tag($p, 'wp:meta_key'), 'value' => $this->get_tag($p, 'wp:meta_value', true)); } } if (!empty($post_postmeta)) { $postdata['postmeta'] = $post_postmeta; } return $postdata; }
/** * active module by slug * @param $module one or more module data * @param int|string $pos */ function hw_activate_modules($module, $pos = '') { static $actived_modules; $modules = array(); if (!$actived_modules) { $actived_modules = hw_get_modules(true); } $count = count($actived_modules); if (isset($module[0]) && !is_array($module[0])) { $modules[] = $module; } else { $modules = $module; } foreach ($modules as $_module) { if (!isset($actived_modules[$_module[0]]) && HW_TGM_Module_Activation::get_modules($_module[0])) { //get register module meta data $info = HW_TGM_Module_Activation::get_modules($_module[0]); if (empty($info['position'])) { $info['position'] = count($actived_modules); } //$actived_modules[$_module[0]] = $_module; $actived_modules = hwArray::add_item_keyval($actived_modules, $_module[0], $_module, $info['position']); //load new module file for initialize HW_HOANGWEB::load_module($_module[0]); //activation hook for module $activation_hooks = HW_HOANGWEB::register_activation_hook(realpath(HW_HOANGWEB_PLUGINS . '/' . $_module[0])); if (is_array($activation_hooks)) { foreach ($activation_hooks as $activation_hook) { if (is_callable($activation_hook)) { call_user_func($activation_hook); usleep(200); //sleep in miliseconds } } } } } //save option to db if ($count !== count($actived_modules)) { update_option('hw_install_modules', $actived_modules); HW_Cache::reset_wp_menus_caches(); return true; } return false; }
/** * 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; } }
/** * @param $_path * @param $source * @param string $type */ public static function get_skin_realpath($_path, $source, $type = self::SKIN_FILES) { if (!is_array($_path)) { return $_path; } $path = hwArray::cloneArray($_path); //apply skin for plugin? $apply_plugin = ''; if (isset($_path['apply_plugin'])) { $apply_plugin = $_path['apply_plugin']; } if ($type == self::SKIN_FILES) { if ($source == 'plugin') { if (isset($path['path']) && strpos($path['path'], HW_HOANGWEB_PATH) === false) { if (!$apply_plugin) { //get plugin name $apply_plugin = self::get_apply_plugin_from_path($path['path']); } $path['path'] = HW_File_Directory::generate_path(HW_HOANGWEB_PATH, $path['path']); } if (isset($path['url']) && !HW_URL::valid_url($path['url'])) { if (!$apply_plugin) { //get plugin name $apply_plugin = self::get_apply_plugin_from_path($path['url']); } $path['url'] = HW_File_Directory::generate_url(HW_HOANGWEB_URL, $path['url']) . '/'; } } elseif ($source == 'theme') { $theme_source_url = get_stylesheet_directory_uri(); $theme_source_path = get_stylesheet_directory(); /*if($apply_plugin) { //no need because i added in get_skins method $theme_source_url .= '/modules/'. $apply_plugin; $theme_source_path .= '/modules/'. $apply_plugin; }*/ if (isset($path['path']) && strpos($path['path'], get_stylesheet_directory()) === false) { $path['path'] = HW_File_Directory::generate_path($theme_source_path, $path['path']); } if (isset($path['url']) && !HW_URL::valid_url($path['url'])) { $path['url'] = HW_File_Directory::generate_url($theme_source_url, $path['url']) . '/'; } } elseif ($source == 'wp_content') { if (isset($path['path']) && strpos($path['path'], WP_CONTENT_DIR) === false) { $path['path'] = HW_File_Directory::generate_path(WP_CONTENT_DIR, $path['path']); } if (isset($path['url']) && !HW_URL::valid_url($path['url'])) { $path['url'] = HW_File_Directory::generate_url(WP_CONTENT_URL, $path['url']) . '/'; } } } return (object) $path; }