shorthomepage = ""; $frst_post_wordpress=array(); $post_in_array=get_posts( array('posts_per_page' => 1)); if($post_in_array) $frst_post_wordpress=array($post_in_array[0]->ID); else $frst_post_wordpress=array(); unset($post_in_array); $this->options = array( "hide_top_posts" => array( "name" => "hide_top_posts", "title" => __("Top Posts",WDWT_LANG), 'type' => 'checkbox_open', 'show' => array("top_post_cat_name","top_post_categories"), 'hide' => array(), "description" => __("Check the box to display the top posts from the homepage.",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => true, 'customizer' => array() ), "top_post_cat_name" => array( "name" => "top_post_cat_name", "title" => "", 'type' => 'text', "sanitize_type" => "sanitize_text_field", "description" => __("Name of top post category",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => '', 'customizer' => array() ), "top_post_categories" => array( "name" => "top_post_categories", "title" => "", 'type' => 'select', 'multiple' => "true", "valid_options" => $this->get_categories(), "description" => __("Select the categories from which you want the homepage top posts to be selected (the posts are selected automatically).",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => $this->get_categories_ids(), 'customizer' => array() ), "hide_category_tabs_posts" => array( "name" => "hide_category_tabs_posts", "title" => __("Category Tabs",WDWT_LANG), 'type' => 'checkbox_open', 'show' => array("home_page_tabs_exclusive"), 'hide' => array(), "description" => __("Check the box to display the category tabs from the homepage.",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => true, 'customizer' => array() ), "home_page_tabs_exclusive" => array( "name" => "home_page_tabs_exclusive", "title" => "", 'type' => 'select', 'multiple' => "true", "valid_options" => $this->get_categories(true), 'section' => 'homepage', 'tab' => 'homepage', 'default' => array('random'), 'customizer' => array() ), "hide_video_post" => array( "name" => "hide_video_post", "title" => __("Featured Post",WDWT_LANG), 'type' => 'checkbox_open', 'show' => array("video_post_name","home_video_post"), 'hide' => array(), "description" => __("Check the box to display the featured post from the homepage.",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => true, 'customizer' => array() ), "video_post_name" => array( "name" => "video_post_name", "title" => "", 'type' => 'text', "sanitize_type" => "sanitize_text_field", "description" => __("Name of featured post",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' =>'MOST POPULAR', 'customizer' => array() ), "home_video_post" => array( "name" => "home_video_post", "title" => "", 'type' => 'select', "valid_options" => $this->get_posts(), "description" => __("Select post for displaying in featured us page",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => $frst_post_wordpress, 'customizer' => array() ), "hide_content_posts" => array( "name" => "hide_content_posts", "title" => __("Content Top Posts",WDWT_LANG), 'type' => 'checkbox_open', 'show' => array("content_post_cat_name","content_post_categories"), 'hide' => array(), "description" => __("Check the box to select the categories from which top posts will be displayed.",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => true, 'customizer' => array() ), "content_post_cat_name" => array( "name" => "content_post_cat_name", "title" => "", 'type' => 'text', "sanitize_type" => "sanitize_text_field", "description" => __("Name of top post category",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => '', 'customizer' => array() ), "content_post_categories" => array( "name" => "content_post_categories", "title" => "", 'type' => 'select', 'multiple' => "true", "valid_options" => $this->get_categories(), "description" => __("Select the categories.",WDWT_LANG), 'section' => 'homepage', 'tab' => 'homepage', 'default' => $this->get_categories_ids(), 'customizer' => array() ), ); } private function get_posts(){ $args= array( 'posts_per_page' => 3000, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', ); $posts_array_custom=array(); $posts_array = get_posts( $args ); foreach($posts_array as $post){ $key = $post->ID; $posts_array_custom[$key] = $post->post_title; } return $posts_array_custom; } private function get_categories($custom = false){ $args= array( 'hide_empty' => 0, 'orderby' => 'name', 'order' => 'ASC', ); $categories_array_custom=array(); $categories_array = get_categories( $args ); if($custom===true){ $categories_array_custom["random"] = __("Random Posts",WDWT_LANG); $categories_array_custom["popular"] = __("Popular Posts",WDWT_LANG); $categories_array_custom["recent"] = __("Recent Posts",WDWT_LANG); } foreach($categories_array as $category){ $categories_array_custom[$category->term_id] = $category->name; } return $categories_array_custom; } private function get_categories_ids(){ $args= array( 'hide_empty' => 0, 'orderby' => 'name', 'order' => 'ASC', ); $categories_array_custom=array(); $categories_array = get_categories( $args ); foreach($categories_array as $category){ array_push($categories_array_custom,$category->term_id); } return $categories_array_custom; } }