/** * * Check the current post or page have a sidebar * * @static * @access public * @return boolean */ public static function isDisplayed() { //fix Ticket #220 if (is_search() && is_home() || is_tag() || is_date() || is_archive()) { $post_id = Option::get_option('page_for_posts'); $post_type = 'page'; } else { $page_object = get_queried_object(); $post_id = get_queried_object_id(); $post_type = isset($page_object->post_type) ? $page_object->post_type : 'posts'; } $sidebar = MetaBox::isSidebar($post_type, $post_id); if ((is_search() || is_author() || is_tag() || is_date() || is_archive()) && Option::get_theme_option('blogposts_sidebar') != '0') { $sidebar = true; } $display = apply_filters('sage/display_sidebar', $sidebar); return $display; }
/** * * Replace default image size based in settings->media * * @param array $image_sizes array with all image size * * @access private * @return void */ private function defaultImageSize(array $image_sizes) { foreach ($image_sizes as $name => $defualt) { Option::update_option($name . '_size_w', $defualt['width']); Option::update_option($name . '_size_h', $defualt['height']); $crop = $defualt['crop'] ? 1 : 0; if ('post-thumbnail' == $name) { //add icon image \set_post_thumbnail_size($defualt['width'], $defualt['height'], $crop); } if (false === Option::get_option($name . '_crop')) { Option::add_option($name . '_crop', $crop); } else { Option::update_option($name . '_crop', $crop); } } }
/** * Get sidebar position * * @param integer $post_id * * @return string * @access public */ public function getSidebarPosition($post_id) { //Fix for tag page and all post type where don't have config from meta box if (is_home() || is_tag() || is_date() || is_archive()) { $post_id = Option::get_option('page_for_posts'); } $sidebar_code = $this->get($post_id, 'sidebar'); switch ($sidebar_code) { case '1': $sidebar_position = 'left'; break; case '2': $sidebar_position = 'right'; break; default: $sidebar_position = 'right'; // default position } return $sidebar_position; }