/** * * * @since 1.3.1 * @return bool */ private function load_sections($post_type) { $loaded = false; $this->sections = array(new SiteTreeSection('', '', __('Exclude From', 'sitetree'), array())); if ($this->db->html5Enabled() && $this->db->getOption('include', true, $post_type, 'html5')) { $loaded = true; $this->sections[0]->fields[] = new SiteTreeField('exclude', 'Checkbox', 'bool', '', __('Archive Page', 'sitetree'), false, array('context' => 'html5')); } if ($this->db->xmlEnabled() && $this->db->getOption('include', true, $post_type, 'xml')) { $loaded = true; $this->sections[0]->fields[] = new SiteTreeField('xml_exclude', 'Checkbox', 'bool', '', __('Google Sitemap', 'sitetree'), false, array('context' => 'xml')); $this->sections[] = new SiteTreeSection('', '', __('Update Frequency', 'sitetree'), array(new SiteTreeField('changefreq', 'Dropdown', 'options', '', '', 'default', SiteTreeUtilities::frequencies(true)))); $this->sections[] = new SiteTreeSection('', '', __('Priority', 'sitetree'), array(new SiteTreeField('priority', 'Dropdown', 'options', '', '', 'default', SiteTreeUtilities::priorities(1, true)))); } return $loaded; }
/** * @see Walker::start_el() * @since 1.3 * * @param string $output Passed by reference. Used to append additional content. * @param object $category Category data object. * @param int $depth Depth of category in reference to parents. * @param array $args */ function start_el(&$output, $category, $depth = 0, $args = array(), $id = 0) { $output .= '<li><a href="' . esc_url(get_term_link($category)) . '" title="'; if ($category->description) { $output .= esc_attr($category->description); } else { $output .= sprintf(__('View all posts filed under %s', 'sitetree'), SiteTreeUtilities::escTitleAttr($category->name)); } $output .= '">' . esc_attr($category->name) . '</a>'; if ($args['feed']) { $output .= ' (<a href="' . esc_url(get_term_feed_link($category->term_id)) . '" title="' . SiteTreeUtilities::escTitleAttr($args['feed']) . '">' . esc_attr($args['feed']) . '</a>)'; } if ($args['show_count']) { $output .= ' <span class="sitetree-posts-number">(' . (int) $category->count . ')</span>'; } }
/** * * * @since 1.4 */ public function serveGoogleSitemap() { $now = time(); $two_days = 172800; $timestamp = (int) $this->db->getOption('date', $now, 'stats_xml'); // Disallow WP Super Cache from caching the sitemap define('DONOTCACHEPAGE', true); if (!self::DEBUG_MODE && $this->db->isCacheAlive('xml') && isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $timestamp) { header('Cache-Control: max-age=' . $two_days . ', must-revalidate'); header('Expires: ' . gmdate('D, d M Y H:i:s', $now + $two_days) . ' GMT'); header('HTTP/1.1 304 Not Modified'); exit; } if (self::DEBUG_MODE || !($sitemap = SiteTreeUtilities::ksesXML($this->db->getCache('xml')))) { $sitemap = $this->rebuildGoogleSitemap(); $timestamp = (int) $this->db->getOption('date', $now, 'stats_xml'); } $output = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $output .= '<?xml-stylesheet type="text/xsl" href="' . $this->url . 'resources/template.xsl"?>' . "\n"; $output .= '<!-- Sitemap generated by SiteTree ' . self::VERSION . ' on ' . gmdate('Y-m-d @ H:i', $timestamp); $output .= ' GMT - ' . self::WEBSITE . " -->\n" . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"'; if ($this->db->getOption('is_image_sitemap', true)) { $output .= ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"'; } $output .= '>' . $sitemap . '</urlset>'; header('Cache-Control: max-age=' . $two_days . ', must-revalidate'); header('Expires: ' . gmdate('D, d M Y H:i:s', $now + $two_days) . ' GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $timestamp) . ' GMT'); header('Content-type: application/xml; charset=UTF-8'); exit($output); }
/** * * * @since 1.4 */ public function tabbedPageViewTabUrl($pageView, $tab_id) { return SiteTreeUtilities::adminURL($pageView->id(), array('tab' => $tab_id)); }
<?php /** * @package SiteTree * @author Luigi Cavalieri * @license http://opensource.org/licenses/GPL-2.0 GPLv2.0 Public license * -------------------------------------------------------------------------- */ if (!defined('ABSPATH')) { exit; } // -------------------------------------------------------------------------- // Collection of messages used more than once — just a way to cut down on unnecessary function calls. // The elements of type Array contain the title of the field at index 0 and its description/tooltip at index 1. $common_l10n = array('include' => array(__('Include', 'sitetree'), __('Check to include', 'sitetree')), 'priority' => __('Priority', 'sitetree'), 'changefreq' => __('Update frequency', 'sitetree'), 'exclude' => array(__('Exclude', 'sitetree'), __('Type in a comma separated list of IDs.', 'sitetree'))); // Common values. $frequencies = SiteTreeUtilities::frequencies(); $prio_80 = SiteTreeUtilities::priorities(0.8); $prio_90 = SiteTreeUtilities::priorities(0.9); // -------------------------------------------------------------------------- $this->pages[$page_number]->sections['general'] = array(new SiteTreeSection('', '', '', array(new SiteTreeField('home_changefreq', 'Dropdown', 'options', __('Home page update frequency', 'sitetree'), '', 'daily', $frequencies), new SiteTreeField('images', 'Checkbox', 'bool', __('Images', 'sitetree'), __('Include all the images attached to posts and pages.', 'sitetree'), true))), new SiteTreeSection('page', 'posts', __('Pages', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1], true), new SiteTreeField('priority', 'Dropdown', 'options', $common_l10n['priority'], '', '0.8', $prio_90), new SiteTreeField('changefreq', 'Dropdown', 'options', $common_l10n['changefreq'], '', 'weekly', $frequencies))), new SiteTreeSection('post', 'posts', __('Posts', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1], true), new SiteTreeField('priority', 'Dropdown', 'options', $common_l10n['priority'], '', '0.6', $prio_90), new SiteTreeField('changefreq', 'Dropdown', 'options', $common_l10n['changefreq'], '', 'monthly', $frequencies))), new SiteTreeSection('category', 'taxonomies', __('Categories', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1]), new SiteTreeField('priority', 'Dropdown', 'options', $common_l10n['priority'], '', 'none', $prio_80), new SiteTreeField('changefreq', 'Dropdown', 'options', $common_l10n['changefreq'], '', 'none', $frequencies), new SiteTreeField('exclude', 'TextField', 'listOfNum', $common_l10n['exclude'][0], $common_l10n['exclude'][1], ''))), new SiteTreeSection('authors', '', __('Authors', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1]), new SiteTreeField('priority', 'Dropdown', 'options', $common_l10n['priority'], '', 'none', $prio_80), new SiteTreeField('changefreq', 'Dropdown', 'options', $common_l10n['changefreq'], '', 'none', $frequencies))), new SiteTreeSection('archives', '', __('Archives', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1]), new SiteTreeField('priority', 'Dropdown', 'options', $common_l10n['priority'], '', 'none', $prio_80), new SiteTreeField('changefreq', 'Dropdown', 'options', $common_l10n['changefreq'], '', 'none', $frequencies))), new SiteTreeSection('post_tag', 'taxonomies', __('Tags', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1]), new SiteTreeField('priority', 'Dropdown', 'options', $common_l10n['priority'], '', 'none', $prio_80), new SiteTreeField('changefreq', 'Dropdown', 'options', $common_l10n['changefreq'], '', 'none', $frequencies), new SiteTreeField('exclude', 'TextField', 'listOfNum', $common_l10n['exclude'][0], $common_l10n['exclude'][1], '')))); $this->pages[$page_number]->sections['advanced'] = array(new SiteTreeSection('', '', '', array(new SiteTreeField('filename', 'TextField', 'filename', __('Filename', 'sitetree'), __('Whenever you change it, remember to redirect (with a 301 status code) the old permalink to the new one ' . 'and to update your Google and Bing Webmaster Accounts.', 'sitetree'), 'sitemap', array('tooltip_pos' => 'bottom')), new SiteTreeField('ping', 'Checkbox', 'bool', __('Ping search engines', 'sitetree'), __('Notify Google, Bing and Yahoo when a new post/page is added to the Sitemap.', 'sitetree'), true), new SiteTreeField('do_robots', 'Checkbox', 'bool', __('Add excluded content to Robots.txt', 'sitetree'), __('List all the posts and the pages excluded from the Sitemap in the Robots.txt file created by WordPress.', 'sitetree')), new SiteTreeField('permalink_in_robots', 'Checkbox', 'bool', __('Add permalink to Robots.txt', 'sitetree'), __('Append the location of the Sitemap to the Robots.txt file created by WordPress.', 'sitetree')))));
/** * Helper method: it pushes a new status element into the @see $pingInfo['stati'] array. * * @see getPingInfo() * @since 1.5 * * @param string $message * @param int $timestamp * @param bool $can_be_cancelled */ private function enqueueStatus($message, $timestamp = null, $can_be_cancelled = false) { // Checking $timestamp against 'null' forces the date-formatting block // to be executed even if $timestamp is zero. So, if an error occurs, no %s is displayed. if ($timestamp !== null) { if ($can_be_cancelled) { $message = sprintf($message, '<strong>' . SiteTreeUtilities::localDate($timestamp) . '</strong>'); } else { $message = sprintf($message, '<em>' . SiteTreeUtilities::localDate($timestamp) . '</em>'); } } $this->pingInfo['stati'][] = array('can_be_cancelled' => $can_be_cancelled, 'message' => $message); }
/** * Returns the plugin action links ('Settings', 'Deactivate'). * * This method is hooked into the plugin_action_links filter hook. * * @since 1.4 * * @param array $links * @return array */ public function addActionLinks($links) { $links = array('settings' => '<a href="' . SiteTreeUtilities::adminURL($this->menuId) . '">' . __('Settings', 'sitetree') . '</a>', 'deactivate' => $links['deactivate']); return $links; }
<?php /** * @package SiteTree * @author Luigi Cavalieri * @license http://opensource.org/licenses/GPL-2.0 GPLv2.0 Public license * -------------------------------------------------------------------------- */ if (!defined('ABSPATH')) { exit; } // -------------------------------------------------------------------------- // Collection of messages used more than once — just a way to cut down on unnecessary function calls. // The elements of type Array contain the title of the field at index 0 and its description/tooltip at index 1. $common_l10n = array('include' => array(__('Include', 'sitetree'), __('Check to include', 'sitetree')), 'title' => __('List title', 'sitetree'), 'show_count' => __('Posts count', 'sitetree'), 'exclude' => array(__('Exclude', 'sitetree'), __('Type in a comma separated list of IDs.', 'sitetree')), 'orderby' => __('Order by', 'sitetree')); // Common values. $list_style_options = array('1' => __('Hierarchical', 'sitetree'), '0' => __('Flat', 'sitetree')); $orderby_options = array('name' => __('Name', 'sitetree'), 'count' => __('Most used', 'sitetree')); // -------------------------------------------------------------------------- $this->pages[$page_number]->sections['general'] = array(new SiteTreeSection('authors', '', __('Authors', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1]), new SiteTreeField('title', 'TextField', 'text', $common_l10n['title'], '', __('Authors', 'sitetree')), new SiteTreeField('show_count', 'Checkbox', 'bool', $common_l10n['show_count'], __('Show the number of posts published by each author.', 'sitetree'), true), new SiteTreeField('show_avatar', 'Checkbox', 'bool', __('Avatar', 'sitetree'), __("Show the author's avatar.", 'sitetree')), new SiteTreeField('avatar_size', 'NumberField', 'positiveNumber', __('Avatar size', 'sitetree'), __('Choose a value within the range 20px - 512px.', 'sitetree'), 60, array('min_value' => 20, 'max_value' => 512)), new SiteTreeField('show_bio', 'Checkbox', 'bool', __('Biographical info', 'sitetree'), sprintf(__("Show the biographical info set in the author's %sprofile page%s.", 'sitetree'), '<a href="' . admin_url('users.php') . '">', '</a>')), new SiteTreeField('exclude', 'TextField', 'listOfAuthors', $common_l10n['exclude'][0], __('Type in a comma separated list of public names.', 'sitetree'), ''), new SiteTreeField('orderby', 'Dropdown', 'options', $common_l10n['orderby'], '', 'display_name', array('display_name' => __('Name', 'sitetree'), 'posts_count' => __('Published posts', 'sitetree'))))), new SiteTreeSection('page', 'pages', __('Pages', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1], true), new SiteTreeField('title', 'TextField', 'text', $common_l10n['title'], '', __('Pages', 'sitetree')), new SiteTreeField('show_home', 'Checkbox', 'bool', __('Home page', 'sitetree'), __('Show a “Home” link at the top of the list.', 'sitetree')), new SiteTreeField('list_style', 'Dropdown', 'options', __('List style', 'sitetree'), '', '1', $list_style_options), new SiteTreeField('depth', 'Dropdown', 'options', __('Levels to show', 'sitetree'), '', 0, $this->pageDepthOptions()))), new SiteTreeSection('archives', '', __('Archives', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1], true), new SiteTreeField('title', 'TextField', 'text', $common_l10n['title'], '', __('Archives', 'sitetree')), new SiteTreeField('show_count', 'Checkbox', 'bool', $common_l10n['show_count'], __('Show the number of posts each archive stores.', 'sitetree'), true))), new SiteTreeSection('categories', '', __('Categories', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1]), new SiteTreeField('title', 'TextField', 'text', $common_l10n['title'], '', __('Categories', 'sitetree')), new SiteTreeField('exclude', 'TextField', 'listOfNum', $common_l10n['exclude'][0], $common_l10n['exclude'][1], ''), new SiteTreeField('show_count', 'Checkbox', 'bool', $common_l10n['show_count'], __('Show the number of posts published under each category.', 'sitetree'), true), new SiteTreeField('feed_text', 'TextField', 'text', __("Text of the link to each category's RSS feed", 'sitetree'), __('Leave empty to hide the link.', 'sitetree'), 'RSS', 'small-text'), new SiteTreeField('list_style', 'Dropdown', 'options', __('List style', 'sitetree'), '', '1', $list_style_options), new SiteTreeField('orderby', 'Dropdown', 'options', $common_l10n['orderby'], '', 'name', $orderby_options))), new SiteTreeSection('tags', '', __('Tags', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1]), new SiteTreeField('title', 'TextField', 'text', $common_l10n['title'], '', __('Tags', 'sitetree')), new SiteTreeField('exclude', 'TextField', 'listOfNum', $common_l10n['exclude'][0], $common_l10n['exclude'][1], ''), new SiteTreeField('show_count', 'Checkbox', 'bool', $common_l10n['show_count'], __('Show the number of posts published under each tag.', 'sitetree')), new SiteTreeField('orderby', 'Dropdown', 'options', $common_l10n['orderby'], '', 'name', $orderby_options))), new SiteTreeSection('post', 'posts', __('Posts', 'sitetree'), array(new SiteTreeField('include', 'Checkbox', 'bool', $common_l10n['include'][0], $common_l10n['include'][1], true), new SiteTreeField('title', 'TextField', 'text', $common_l10n['title'], '', __('Posts', 'sitetree')), new SiteTreeField('groupby', 'Dropdown', 'options', __('Group by', 'sitetree'), '', 'none', array('none' => '-', 'date' => __('Date', 'sitetree'), 'category' => __('Category', 'sitetree'), 'author' => __('Author', 'sitetree'))), new SiteTreeField('category_label', 'TextField', 'restrictedHtml', __('Category label', 'sitetree'), sprintf(__('Allowed tags: %s, %s, %s.', 'sitetree'), '<code><em></code>', '<code><span></code>', '<code><strong></code>'), '', null, array('strong' => true, 'span' => true, 'em' => true)), new SiteTreeField('orderby', 'Dropdown', 'options', $common_l10n['orderby'], '', 'post_date', array('post_date' => __('Most recent', 'sitetree'), 'comment_count' => __('Most popular', 'sitetree'), 'post_title' => __('Title', 'sitetree'))), new SiteTreeField('show_comments_count', 'Checkbox', 'bool', __('Comments count', 'sitetree'), __('Show—if there are any—the number of comments submitted for each post.', 'sitetree')), new SiteTreeField('show_date', 'Checkbox', 'bool', __('Published date', 'sitetree'), sprintf(__('Show the date of publication for each post (the format is set by the “Date format” ' . 'setting in the %sGeneral Settings%s page).', 'sitetree'), '<a href="' . admin_url('options-general.php') . '">', '</a>')), new SiteTreeField('limit', 'NumberField', 'positiveNumber', __('Max. number of entries', 'sitetree'), sprintf(__('The total limit set in the %sUnder the Hood tab%s takes priority.', 'sitetree'), '<a href="' . SiteTreeUtilities::adminURL($this->page('html5', false)->id, array('tab' => 'hood')) . '">', '</a>'), 200, array('min_value' => 5, 'max_value' => 1000))))); $this->pages[$page_number]->sections['hood'] = array(new SiteTreeSection('', '', '', array(new SiteTreeField('items_limit', 'NumberField', 'positiveNumber', __('Max. number of items', 'sitetree'), __("To keep high the user experience, it's recommended to stay under 300 items.", 'sitetree'), 200, array('min_value' => 50, 'max_value' => 1000)), new SiteTreeField('title_tag', 'Dropdown', 'options', __('Heading tag', 'sitetree'), __('Tag applied to each title—if any has been set.', 'sitetree'), 'h3', array('h2' => 'h2', 'h3' => 'h3', 'h4' => 'h4')), new SiteTreeField('list_wrapper', 'Dropdown', 'options', __('Wrapper tag', 'sitetree'), __('Each list will be enclosed within this tag.', 'sitetree'), '0', array('0' => '-', 'div' => 'div', 'section' => 'section')), new SiteTreeField('trailing_html', 'Textarea', 'html', __('Additional HTML code to put at the end of each list', 'sitetree'), __('You can use all the tags allowed in the post / page content editor.', 'sitetree'), ''), new SiteTreeField('css_code', 'Textarea', 'plainText', __('Type in a few lines of CSS to style your Archive', 'sitetree'), sprintf(__("You don't need to markup the code with the %s tag.", 'sitetree'), '<code><style></code>'), '#sitetree-credits {font-size:90%; text-align:right;}'))));