예제 #1
0
 function widget($args, $instance)
 {
     global $wp_query;
     extract($args);
     $current_taxonomy = $this->_get_current_taxonomy($instance);
     if (!empty($instance['title'])) {
         $title = $instance['title'];
     } else {
         if ('post_tag' == $current_taxonomy) {
             $title = __('Tags');
         } else {
             $tax = get_taxonomy($current_taxonomy);
             $title = $tax->labels->name;
         }
     }
     $use_desc_for_title = isset($instance['use_desc_for_title']) ? $instance['use_desc_for_title'] : true;
     $count = isset($instance['count']) ? $instance['count'] : false;
     $title = apply_filters('widget_title', $title, $instance, $this->id_base);
     $current_term = false;
     $current_term_id = $current_post_id = 0;
     if (suwp::is_tax($current_taxonomy)) {
         $current_term = $wp_query->get_queried_object();
         $current_term_id = $wp_query->get_queried_object_id();
         $title = $current_term->name;
     } elseif (is_singular()) {
         $current_post_id = $wp_query->get_queried_object_id();
         $post_terms = get_the_terms($current_post_id, $current_taxonomy);
         if (is_array($post_terms) && count($post_terms)) {
             $current_term = reset($post_terms);
             $current_term_id = $current_term->term_id;
             $title = $current_term->name;
         }
     }
     $term_args = array('taxonomy' => $current_taxonomy, 'orderby' => 'name', 'show_count' => $count ? '1' : '0', 'hierarchical' => '0', 'title_li' => '', 'parent' => $current_term_id, 'show_option_none' => false, 'use_desc_for_title' => $use_desc_for_title ? '1' : '0', 'echo' => false);
     $category_output = $post_output = '';
     if (!$current_term || is_taxonomy_hierarchical($current_taxonomy)) {
         $category_output = wp_list_categories($term_args);
     }
     if ($current_term) {
         $child_posts = get_posts(array('taxonomy' => $current_taxonomy, 'term' => $current_term->slug, 'numberposts' => 5));
         foreach ($child_posts as $child_post) {
             $css_class = '';
             if ($child_post->ID == $current_post_id) {
                 $css_class = 'current_post_item';
             }
             $post_output .= "\n\t\t\t<li class=\"" . $css_class . '"><a href="' . get_permalink($child_post->ID) . '" title="' . esc_attr(wp_strip_all_tags(apply_filters('the_title', $child_post->post_title, $child_post->ID))) . '">' . apply_filters('the_title', $child_post->post_title, $child_post->ID) . "</a></li>\n";
         }
     }
     if ($category_output || $post_output) {
         echo $before_widget;
         if ($title) {
             echo $before_title . $title . $after_title;
         }
         echo "\n\t\t<ul>\n";
         echo $category_output;
         echo $post_output;
         echo "\n\t\t</ul>\n";
         echo $after_widget;
     }
 }
 function admin_form_end($button = null, $table = true)
 {
     if ($button === null) {
         $button = __('Import Now', 'seo-ultimate');
     }
     parent::admin_form_end($button, $table);
     $this->print_message('warning', sprintf(__('The import cannot be undone. It is your responsibility to <a href="%s" target="_blank">backup your database</a> before proceeding!', 'seo-ultimate'), suwp::get_backup_url()));
 }
예제 #3
0
 function load_blog_rss()
 {
     $rss = suwp::load_rss('http://feeds.seodesignsolutions.com/SeoDesignSolutionsBlog', SU_USER_AGENT);
     if ($rss && $rss->items) {
         $times = array();
         foreach ($rss->items as $item) {
             $times[] = $this->get_feed_item_date($item);
         }
         $this->update_setting('rss_item_times', $times);
     }
 }
예제 #4
0
 function belongs_in_admin($admin_scope = null)
 {
     if ($admin_scope === null) {
         $admin_scope = suwp::get_admin_scope();
     }
     switch ($admin_scope) {
         case 'blog':
             return true;
         case 'network':
             if (!function_exists('is_plugin_active_for_network')) {
                 require_once ABSPATH . '/wp-admin/includes/plugin.php';
             }
             return is_plugin_active_for_network($this->plugin->plugin_basename);
             break;
         default:
             return false;
             break;
     }
 }
예제 #5
0
 function linkbox_filter($content, $id = false)
 {
     //If no ID is provided, get the ID of the current post
     if (!$id) {
         $id = suwp::get_post_id();
     }
     if ($id) {
         //Don't add a linkbox if a "more" link is present (since a linkbox should go at the very bottom of a post)
         $morelink = '<a href="' . get_permalink($id) . '#more-' . $id . '" class="more-link">';
         if (strpos($content, $morelink) !== false) {
             return $content;
         }
         //Load the HTML and replace the variables with the proper values
         $linkbox = $this->get_setting('html');
         $linkbox = str_replace(array('{id}', '{url}', '{title}'), array(intval($id), su_esc_attr(get_permalink($id)), su_esc_attr(get_the_title($id))), $linkbox);
         //Return the content with the linkbox added to the bottom
         return $content . $linkbox;
     }
     return $content;
 }
 function get_meta_desc()
 {
     global $post;
     $desc = false;
     //If we're viewing the homepage, look for homepage meta data.
     if (is_home()) {
         $desc = $this->get_setting('home_description');
         if (!$desc && $this->get_setting('home_description_tagline_default')) {
             $desc = get_bloginfo('description');
         }
         //If we're viewing a post or page, look for its meta data.
     } elseif (is_singular()) {
         $desc = $this->get_postmeta('description');
         if (!trim($desc) && !post_password_required() && ($format = $this->get_setting('description_posttype_' . get_post_type()))) {
             $auto_excerpt = $post->post_content;
             $auto_excerpt = strip_shortcodes($auto_excerpt);
             $auto_excerpt = str_replace(']]>', ']]&gt;', $auto_excerpt);
             $auto_excerpt = strip_tags($auto_excerpt);
             $auto_excerpt = sustr::truncate($auto_excerpt, 150, '', true);
             $desc = str_replace(array('{excerpt::autogen}', '{excerpt}'), array($auto_excerpt, strip_tags($post->post_excerpt)), $format);
         }
         //If we're viewing a term, look for its meta data.
     } elseif (suwp::is_tax()) {
         global $wp_query;
         $tax_descriptions = $this->get_setting('taxonomy_descriptions');
         $term_id = $wp_query->get_queried_object_id();
         $term_obj = $wp_query->get_queried_object();
         $desc = isset($tax_descriptions[$term_id]) ? $tax_descriptions[$term_id] : '';
         if (!trim($desc) && ($format = $this->get_setting('description_taxonomy_' . $term_obj->taxonomy))) {
             $desc = str_replace(array('{description}'), array($term_obj->description), $format);
         }
     }
     $desc = trim($desc);
     if ($desc) {
         $desc = $this->get_desc_paged($desc);
     }
     $desc = trim($desc);
     $desc = su_esc_attr($desc);
     return $desc;
 }
 function admin_page_contents()
 {
     $this->admin_form_table_start();
     $this->checkboxes(suarr::aprintf('autolink_posttype_%s', false, suarr::simplify(get_post_types(array('public' => true), 'objects'), 'name', array('labels', 'name'))), __('Add Autolinks to...', 'seo-wizard'));
     $this->checkboxes(array('enable_self_links' => __('Allow posts to link to themselves', 'seo-wizard'), 'enable_current_url_links' => __('Allow posts to link to the URL by which the visitor is accessing the post', 'seo-wizard')), __('Self-Linking', 'seo-wizard'));
     $this->checkboxes(array('limit_lpp' => __('Don&#8217;t add any more than %d autolinks per post/page/etc.', 'seo-wizard'), 'limit_lpa' => __('Don&#8217;t link the same anchor text any more than %d times per post/page/etc.', 'seo-wizard'), 'limit_lpu' => __('Don&#8217;t link to the same destination any more than %d times per post/page/etc.', 'seo-wizard')), __('Quantity Restrictions', 'seo-wizard'));
     $legacy_sitewide_lpa_in_use = $this->plugin->get_module_var('content-autolinks', 'legacy_sitewide_lpa_in_use', false);
     $this->checkboxes(array('dampen_sitewide_lpa' => __('Globally decrease autolinking frequency by %d%', 'seo-wizard'), 'enable_perlink_dampen_sitewide_lpa' => array('description' => __('Add a &#8220;Dampener&#8221; column to the Content Links editor to let me customize frequency dampening on a per-link basis', 'seo-wizard'), 'disabled' => $legacy_sitewide_lpa_in_use, 'checked' => $legacy_sitewide_lpa_in_use ? true : null)), __('Additional Dampening Effect', 'seo-wizard'));
     $this->textbox('linkfree_tags', __('Tag Restrictions', 'seo-wizard'), $this->get_default_setting('linkfree_tags'), false, array('help_text' => __('Don&#8217;t add autolinks to text within these HTML tags <em>(separate with commas)</em>:', 'seo-wizard')));
     $siloing_checkboxes = array();
     $post_types = get_post_types(array('public' => true), 'objects');
     foreach ($post_types as $post_type) {
         $taxonomies = suwp::get_object_taxonomies($post_type->name);
         if (count($taxonomies)) {
             $siloing_checkboxes['dest_limit_' . $post_type->name] = sprintf(__('%s can only link to internal destinations that share at least one...', 'seo-wizard'), $post_type->labels->name);
             foreach ($taxonomies as $taxonomy) {
                 $siloing_checkboxes['dest_limit_' . $post_type->name . '_within_' . $taxonomy->name] = array('description' => $taxonomy->labels->singular_name, 'indent' => true);
             }
         }
     }
     $this->checkboxes($siloing_checkboxes, __('Siloing', 'seo-wizard'));
     $this->textbox('autolink_class', __('CSS Class for Autolinks', 'seo-wizard'));
     $this->admin_form_table_end();
 }
예제 #8
0
 function init()
 {
     if (is_admin()) {
         if (get_option('blog_public')) {
             $this->results[] = array(SU_RESULT_OK, __('Blog is visible to search engines', 'seo-ultimate'), __('WordPress will allow search engines to visit your site.', 'seo-ultimate'));
         } else {
             $this->results[] = array(SU_RESULT_ERROR, __('Blog is hidden from search engines', 'seo-ultimate'), __('WordPress is configured to discourage search engines. This will nullify your site&#8217;s SEO and should be resolved immediately.', 'seo-ultimate'), 'options-reading.php');
         }
         switch (suwp::permalink_mode()) {
             case SUWP_QUERY_PERMALINKS:
                 $this->results[] = array(SU_RESULT_ERROR, __('Query-string permalinks enabled', 'seo-ultimate'), __('It is highly recommended that you use a non-default and non-numeric permalink structure.', 'seo-ultimate'), 'options-permalink.php');
                 break;
             case SUWP_INDEX_PERMALINKS:
                 $this->results[] = array(SU_RESULT_WARNING, __('Pathinfo permalinks enabled', 'seo-ultimate'), __('Pathinfo permalinks add a keyword-less &#8220;index.php&#8221; prefix. This is not ideal, but it may be beyond your control (since it&#8217;s likely caused by your site&#8217;s web hosting setup).', 'seo-ultimate'), 'options-permalink.php');
             case SUWP_PRETTY_PERMALINKS:
                 if (strpos(get_option('permalink_structure'), '%postname%') !== false) {
                     $this->results[] = array(SU_RESULT_OK, __('Permalinks include the post slug', 'seo-ultimate'), __('Including a version of the post&#8217;s title helps provide keyword-rich URLs.', 'seo-ultimate'));
                 } else {
                     $this->results[] = array(SU_RESULT_ERROR, __('Permalinks do not include the post slug', 'seo-ultimate'), __('It is highly recommended that you include the %postname% variable in the permalink structure.', 'seo-ultimate'), 'options-permalink.php');
                 }
                 break;
         }
     }
 }
 /**
  * Outputs a JSON-encoded list of posts and terms on the blog.
  * 
  * @since 6.0
  */
 function jlsuggest_autocomplete()
 {
     if (!function_exists('json_encode')) {
         die;
     }
     if (!current_user_can('manage_options')) {
         die;
     }
     $items = array();
     $include = empty($_GET['types']) ? array() : explode(',', $_GET['types']);
     if ((!$include || in_array('home', $include)) && sustr::ihas($_GET['q'], 'home')) {
         $items[] = array('text' => __('Home', 'seo-ultimate'), 'isheader' => true);
         $items[] = array('text' => __('Blog Homepage', 'seo-ultimate'), 'value' => 'obj_home', 'selectedtext' => __('Blog Homepage', 'seo-ultimate'));
     }
     $posttypeobjs = get_post_types(array('public' => true), 'objects');
     foreach ($posttypeobjs as $posttypeobj) {
         if ($include && !in_array('posttype', $include) && !in_array('posttype_' . $posttypeobj->name, $include)) {
             continue;
         }
         $stati = get_available_post_statuses($posttypeobj->name);
         suarr::remove_value($stati, 'auto-draft');
         $stati = implode(',', $stati);
         $posts = get_posts(array('orderby' => 'title', 'order' => 'ASC', 'post_status' => $stati, 'numberposts' => -1, 'post_type' => $posttypeobj->name, 'post_mime_type' => isset($_GET['post_mime_type']) ? $_GET['post_mime_type'] : '', 'sentence' => 1, 's' => $_GET['q']));
         if (count($posts)) {
             $items[] = array('text' => $posttypeobj->labels->name, 'isheader' => true);
             foreach ($posts as $post) {
                 $items[] = array('text' => $post->post_title, 'value' => 'obj_posttype_' . $posttypeobj->name . '/' . $post->ID, 'selectedtext' => $post->post_title . '<span class="type">&nbsp;&mdash;&nbsp;' . $posttypeobj->labels->singular_name . '</span>');
             }
         }
     }
     $taxonomyobjs = suwp::get_taxonomies();
     foreach ($taxonomyobjs as $taxonomyobj) {
         if ($include && !in_array('taxonomy', $include) && !in_array('taxonomy_' . $posttypeobj->name, $include)) {
             continue;
         }
         $terms = get_terms($taxonomyobj->name, array('search' => $_GET['q']));
         if (count($terms)) {
             $items[] = array('text' => $taxonomyobj->labels->name, 'isheader' => true);
             foreach ($terms as $term) {
                 $items[] = array('text' => $term->name, 'value' => 'obj_taxonomy_' . $taxonomyobj->name . '/' . $term->term_id, 'selectedtext' => $term->name . '<span class="type"> &mdash; ' . $taxonomyobj->labels->singular_name . '</span>');
             }
         }
     }
     if (!$include || in_array('author', $include)) {
         $authors = get_users(array('search' => $_GET['q'], 'fields' => array('ID', 'user_login')));
         if (count($authors)) {
             $items[] = array('text' => __('Author Archives', 'seo-ultimate'), 'isheader' => true);
             foreach ($authors as $author) {
                 $items[] = array('text' => $author->user_login, 'value' => 'obj_author/' . $author->ID, 'selectedtext' => $author->user_login . '<span class="type"> &mdash; ' . __('Author', 'seo-ultimate') . '</span>');
             }
         }
     }
     if ($this->module_exists('internal-link-aliases') && (!$include || in_array('internal-link-alias', $include))) {
         $aliases = $this->get_setting('aliases', array(), 'internal-link-aliases');
         $alias_dir = $this->get_setting('alias_dir', 'go', 'internal-link-aliases');
         if (is_array($aliases) && count($aliases)) {
             $header_outputted = false;
             foreach ($aliases as $alias_id => $alias) {
                 if ($alias['to']) {
                     $h_alias_to = su_esc_html($alias['to']);
                     $to_rel_url = "/{$alias_dir}/{$h_alias_to}/";
                     if (strpos($alias['from'], $_GET['q']) !== false || strpos($to_rel_url, $_GET['q']) !== false) {
                         if (!$header_outputted) {
                             $items[] = array('text' => __('Link Masks', 'seo-ultimate'), 'isheader' => true);
                             $header_outputted = true;
                         }
                         $items[] = array('text' => $to_rel_url, 'value' => 'obj_internal-link-alias/' . $alias_id, 'selectedtext' => $to_rel_url . '<span class="type"> &mdash; ' . __('Link Mask', 'seo-ultimate') . '</span>');
                     }
                 }
             }
         }
     }
     echo json_encode($items);
     die;
 }
 /**
  * Converts a JLSuggest database string into a URL.
  * 
  * @since 6.0
  * 
  * @param string $value The JLSuggest database string to convert.
  * @param bool $get_src_if_media Whether to get the URL to the actual media item rather than the URL to its WP-powered singular page, if the item is an attachment.
  * @return string The URL of the referenced destination
  */
 function jlsuggest_value_to_url($value, $get_src_if_media = false)
 {
     list($to_genus, $to_type, $to_id) = $this->jlsuggest_value_explode($value);
     switch ($to_genus) {
         case 'url':
             return $to_id;
             break;
         case 'posttype':
             $to_id = (int) $to_id;
             switch (get_post_status($to_id)) {
                 case 'publish':
                     if ($get_src_if_media && 'attachment' == get_post_type($to_id)) {
                         return wp_get_attachment_url($to_id);
                     }
                     return get_permalink($to_id);
                 case false:
                     //Post doesn't exist
                 //Post doesn't exist
                 default:
                     //Post exists but isn't published
                     return false;
             }
             break;
         case 'taxonomy':
             $to_id = (int) $to_id;
             $term_link = get_term_link($to_id, $to_type);
             if ($term_link && !is_wp_error($term_link)) {
                 return $term_link;
             }
             return false;
             break;
         case 'home':
             return suwp::get_blog_home_url();
             break;
         case 'author':
             $to_id = (int) $to_id;
             if (is_user_member_of_blog($to_id)) {
                 return get_author_posts_url($to_id);
             }
             return false;
             break;
         case 'internal-link-alias':
             if ($this->plugin->module_exists('internal-link-aliases')) {
                 $alias_dir = $this->get_setting('alias_dir', 'go', 'internal-link-aliases');
                 $aliases = $this->get_setting('aliases', array(), 'internal-link-aliases');
                 if (isset($aliases[$to_id]['to'])) {
                     $u_alias_to = urlencode($aliases[$to_id]['to']);
                     return get_bloginfo('url') . "/{$alias_dir}/{$u_alias_to}/";
                 }
             }
             return false;
             break;
     }
     return false;
 }
 function nobase_rewrite_rules($rules)
 {
     $rules = array();
     $tax_name = sustr::rtrim_str(current_filter(), '_rewrite_rules');
     $tax_obj = get_taxonomy($tax_name);
     wp_cache_flush();
     //Otherwise get_terms() won't include the term just added
     $terms = get_terms($tax_name);
     if ($terms && !is_wp_error($terms)) {
         foreach ($terms as $term_obj) {
             $term_slug = suwp::get_term_slug($term_obj);
             if ($tax_obj->query_var && is_string($tax_obj->query_var)) {
                 $url_start = "index.php?{$tax_obj->query_var}=";
             } else {
                 $url_start = "index.php?taxonomy={$tax_name}&term=";
             }
             if ($this->get_setting('add_rule_if_conflict', true) || get_page_by_path($term_slug) === null) {
                 $rules['(' . $term_slug . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = $url_start . '$matches[1]&feed=$matches[2]';
                 $rules['(' . $term_slug . ')/page/?([0-9]{1,})/?$'] = $url_start . '$matches[1]&paged=$matches[2]';
                 $rules['(' . $term_slug . ')/?$'] = $url_start . '$matches[1]';
             }
         }
     }
     global $wp_rewrite;
     $old_base = $wp_rewrite->get_extra_permastruct($tax_name);
     $old_base = str_replace("%{$tax_name}%", '(.+)', $old_base);
     $old_base = trim($old_base, '/');
     $rules[$old_base . '$'] = 'index.php?su_term_redirect=$matches[1]';
     return $rules;
 }
예제 #12
0
 function get_postmeta_jlsuggest_boxes($jls_boxes)
 {
     $this->jlsuggest_box_post_id = suwp::get_post_id();
     return parent::get_postmeta_jlsuggest_boxes($jls_boxes);
 }
 function apply_aliases_callback($matches)
 {
     $id = suwp::get_post_id();
     static $aliases = false;
     //Just in case we have duplicate aliases, make sure the most recent ones are applied first
     if ($aliases === false) {
         $aliases = array_reverse($this->get_setting('aliases', array()), true);
     }
     static $alias_dir = false;
     if ($alias_dir === false) {
         $alias_dir = $this->get_setting('alias_dir', 'go');
     }
     $new_url = $old_url = $matches[3];
     foreach ($aliases as $alias) {
         $to = urlencode($alias['to']);
         if ((empty($alias['posts']) || in_array($id, $alias['posts'])) && $to) {
             $from = $alias['from'];
             $h_from = esc_html($from);
             $to = get_bloginfo('url') . "/{$alias_dir}/{$to}/";
             if ($from == $old_url || $h_from == $old_url) {
                 $new_url = $to;
                 break;
             }
         }
     }
     $attrs = "{$matches[1]}href={$matches[2]}{$new_url}{$matches[4]}{$matches[5]}";
     if ($old_url != $new_url && $this->get_setting('nofollow_aliased_links', false) && $this->plugin->module_exists('link-nofollow')) {
         $this->plugin->call_module_func('link-nofollow', 'nofollow_attributes_string', $attrs, $attrs);
     }
     return "<a {$attrs}>";
 }
 function postmeta_fields($fields)
 {
     $id = suwp::get_post_id();
     if ($id) {
         $type = get_post_type($id);
     } elseif (!empty($_GET['post_type'])) {
         $type = $_GET['post_type'];
     } else {
         $type = 'post';
     }
     $fields['links'][10]['autolinks'] = $this->get_postmeta_textarea('autolinks', __('Inbound Autolink Anchors:<br /><em>(one per line)</em>', 'seo-ultimate'));
     if ($this->get_setting("autolink_posttype_{$type}")) {
         $fields['links'][15]['disable_autolinks'] = $this->get_postmeta_checkbox('disable_autolinks', __('Don&#8217;t add autolinks to anchor texts found in this post.', 'seo-ultimate'), __('Autolink Exclusion:', 'seo-ultimate'));
     }
     return $fields;
 }
예제 #15
0
 function head_tag_output()
 {
     global $post;
     $kw = false;
     //If we're viewing the homepage, look for homepage meta data.
     if (is_home()) {
         $kw = $this->get_setting('home_keywords');
         //If we're viewing a post or page...
     } elseif (is_singular()) {
         //...look for its meta data
         $kw = $this->get_postmeta('keywords');
         //...and add default values
         if ($posttypename = get_post_type()) {
             $taxnames = get_object_taxonomies($posttypename);
             foreach ($taxnames as $taxname) {
                 if ($this->get_setting("auto_keywords_posttype_{$posttypename}_tax_{$taxname}", false)) {
                     $terms = get_the_terms(0, $taxname);
                     $terms = suarr::flatten_values($terms, 'name');
                     $terms = implode(',', $terms);
                     $kw .= ',' . $terms;
                 }
             }
             if ($this->get_setting("auto_keywords_posttype_{$posttypename}_words", false)) {
                 $words = preg_split("/[\\s+]/", strip_tags($post->post_content), null, PREG_SPLIT_NO_EMPTY);
                 $words = array_count_values($words);
                 arsort($words);
                 $words = array_filter($words, array(&$this, 'filter_word_counts'));
                 $words = array_keys($words);
                 $stopwords = suarr::explode_lines($this->get_setting('words_to_remove', array(), 'slugs'));
                 $stopwords = array_map(array('sustr', 'tolower'), $stopwords);
                 $words = array_map(array('sustr', 'tolower'), $words);
                 $words = array_diff($words, $stopwords);
                 $words = array_slice($words, 0, $this->get_setting("auto_keywords_posttype_{$posttypename}_words_value"));
                 $words = implode(',', $words);
                 $kw .= ',' . $words;
             }
         }
         //If we're viewing a term, look for its meta data.
     } elseif (suwp::is_tax()) {
         global $wp_query;
         $tax_keywords = $this->get_setting('taxonomy_keywords');
         $term_id = $wp_query->get_queried_object_id();
         if (isset($tax_keywords[$term_id])) {
             $kw = $tax_keywords[$term_id];
         } else {
             $kw = '';
         }
     }
     if ($globals = $this->get_setting('global_keywords')) {
         if (strlen($kw)) {
             $kw .= ',';
         }
         $kw .= $globals;
     }
     $kw = str_replace(array("\r\n", "\n"), ',', $kw);
     $kw = explode(',', $kw);
     $kw = array_map('trim', $kw);
     //Remove extra spaces from beginning/end of keywords
     $kw = array_filter($kw);
     //Remove blank keywords
     $kw = suarr::array_unique_i($kw);
     //Remove duplicate keywords
     $kw = implode(',', $kw);
     //Do we have keywords? If so, output them.
     if ($kw) {
         $kw = su_esc_attr($kw);
         echo "\t<meta name=\"keywords\" content=\"{$kw}\" />\n";
     }
 }
예제 #16
0
 function get_title()
 {
     global $wp_query, $wp_locale;
     //Custom post/page title?
     if ($post_title = $this->get_postmeta('title')) {
         return htmlspecialchars($this->get_title_paged($post_title));
     }
     //Custom taxonomy title?
     if (suwp::is_tax()) {
         $tax_titles = $this->get_setting('taxonomy_titles');
         if ($tax_title = $tax_titles[$wp_query->get_queried_object_id()]) {
             return htmlspecialchars($this->get_title_paged($tax_title));
         }
     }
     //Get format
     if (!$this->should_rewrite_title()) {
         return '';
     }
     if (!($format = $this->get_title_format())) {
         return '';
     }
     //Load post/page titles
     $post_id = 0;
     $post_title = '';
     $parent_title = '';
     if (is_singular()) {
         $post = $wp_query->get_queried_object();
         $post_title = strip_tags(apply_filters('single_post_title', $post->post_title, $post));
         $post_id = $post->ID;
         if ($parent = $post->post_parent) {
             $parent = get_post($parent);
             $parent_title = strip_tags(apply_filters('single_post_title', $parent->post_title, $post));
         }
     }
     //Load date-based archive titles
     if ($m = get_query_var('m')) {
         $year = substr($m, 0, 4);
         $monthnum = intval(substr($m, 4, 2));
         $daynum = intval(substr($m, 6, 2));
     } else {
         $year = get_query_var('year');
         $monthnum = get_query_var('monthnum');
         $daynum = get_query_var('day');
     }
     $month = $wp_locale->get_month($monthnum);
     $monthnum = zeroise($monthnum, 2);
     $day = date('jS', mktime(12, 0, 0, $monthnum, $daynum, $year));
     $daynum = zeroise($daynum, 2);
     //Load category titles
     $cat_title = $cat_titles = $cat_desc = '';
     if (is_category()) {
         $cat_title = single_cat_title('', false);
         $cat_desc = category_description();
     } elseif (count($categories = get_the_category())) {
         $cat_titles = su_lang_implode($categories, 'name');
         usort($categories, '_usort_terms_by_ID');
         $cat_title = $categories[0]->name;
         $cat_desc = category_description($categories[0]->term_id);
     }
     if (strlen($cat_title) && $this->get_setting('terms_ucwords', true)) {
         $cat_title = sustr::tclcwords($cat_title);
     }
     //Load tag titles
     $tag_title = $tag_desc = '';
     if (is_tag()) {
         $tag_title = single_tag_title('', false);
         $tag_desc = tag_description();
         if ($this->get_setting('terms_ucwords', true)) {
             $tag_title = sustr::tclcwords($tag_title);
         }
     }
     //Load author titles
     if (is_author()) {
         $author_obj = $wp_query->get_queried_object();
     } elseif (is_singular()) {
         global $authordata;
         $author_obj = $authordata;
     } else {
         $author_obj = null;
     }
     if ($author_obj) {
         $author = array('username' => $author_obj->user_login, 'name' => $author_obj->display_name, 'firstname' => get_the_author_meta('first_name', $author_obj->ID), 'lastname' => get_the_author_meta('last_name', $author_obj->ID), 'nickname' => get_the_author_meta('nickname', $author_obj->ID));
     } else {
         $author = array('username' => '', 'name' => '', 'firstname' => '', 'lastname' => '', 'nickname' => '');
     }
     $variables = array('{blog}' => get_bloginfo('name'), '{tagline}' => get_bloginfo('description'), '{post}' => $post_title, '{page}' => $post_title, '{page_parent}' => $parent_title, '{category}' => $cat_title, '{categories}' => $cat_titles, '{category_description}' => $cat_desc, '{tag}' => $tag_title, '{tag_description}' => $tag_desc, '{tags}' => su_lang_implode(get_the_tags($post_id), 'name', true), '{daynum}' => $daynum, '{day}' => $day, '{monthnum}' => $monthnum, '{month}' => $month, '{year}' => $year, '{author}' => $author['name'], '{author_name}' => $author['name'], '{author_username}' => $author['username'], '{author_firstname}' => $author['firstname'], '{author_lastname}' => $author['lastname'], '{author_nickname}' => $author['nickname'], '{query}' => su_esc_attr(get_search_query()), '{ucquery}' => su_esc_attr(ucwords(get_search_query())), '{url_words}' => $this->get_url_words($_SERVER['REQUEST_URI']));
     $title = str_replace(array_keys($variables), array_values($variables), htmlspecialchars($format));
     return $this->get_title_paged($title);
 }
예제 #17
0
 /**
  * @return string
  */
 static function add_backup_url($text)
 {
     $anchor = __('backup your database', 'seo-ultimate');
     return str_replace($anchor, '<a href="' . suwp::get_backup_url() . '" target="_blank">' . $anchor . '</a>', $text);
 }
 function autolink_footer($args = array())
 {
     if ($this->already_outputted) {
         return;
     }
     extract(wp_parse_args($args, array('footer_link_section_format' => $this->get_setting('footer_link_section_format', '{links}'), 'footer_link_format' => $this->get_setting('footer_link_format', '{link}'), 'footer_link_sep' => $this->get_setting('footer_link_sep', ' | '))), EXTR_SKIP);
     $links = $this->get_setting('footer_links', array());
     suarr::vksort($links, 'anchor');
     $link_html = array();
     foreach ($links as $link_data) {
         if (isset($link_data['from']) && count($link_data['from'])) {
             $from = $link_data['from'][0];
         } else {
             $from = array('');
         }
         $from_match_children = isset($link_data['from_match_children']) && $link_data['from_match_children'];
         $from_match_negative = isset($link_data['from_match_negative']) && $link_data['from_match_negative'];
         if (!isset($link_data['to'])) {
             $link_data['to'] = '';
         }
         list($from_genus, $from_type, $from_id) = $this->jlsuggest_value_explode($from);
         $is_from = $from_match_negative;
         switch ($from_genus) {
             case 'posttype':
                 $post_ids = array($from_id);
                 if ($from_match_children) {
                     $post_ids[] = wp_get_post_parent_id($from_id);
                 }
                 //Requires WordPress 3.1
                 foreach ($post_ids as $post_id) {
                     if (is_single($post_id) || is_page($post_id)) {
                         $is_from = !$from_match_negative;
                         break;
                     }
                 }
                 break;
             case 'taxonomy':
                 if (suwp::is_tax($from_type, $from_id) || $from_match_children && is_singular() && has_term($from_id, $from_type)) {
                     $is_from = !$from_match_negative;
                 }
                 break;
             case 'home':
                 if (is_home()) {
                     $is_from = !$from_match_negative;
                 }
                 break;
             case 'author':
                 if (is_author($from_id) || $from_match_children && is_singular() && get_the_author_meta('id') == $from_id) {
                     $is_from = !$from_match_negative;
                 }
                 break;
             case 'url':
                 if ($from_id) {
                     if (suurl::equal(suurl::current(), $from_id) || $from_match_children && sustr::startswith(suurl::current(), $from_id)) {
                         $is_from = !$from_match_negative;
                     }
                 } else {
                     $is_from = true;
                 }
                 //No "from" restriction
                 break;
         }
         if (!$is_from) {
             continue;
         }
         $h_anchor = esc_html($link_data['anchor']);
         $rel = $link_data['nofollow'] ? ' rel="nofollow"' : '';
         $target = $link_data['target'] == 'blank' ? ' target="_blank"' : '';
         $title = strlen($a_titletext = su_esc_attr($link_data['title'])) ? " title=\"{$a_titletext}\"" : '';
         $a_url = su_esc_attr($this->jlsuggest_value_to_url($link_data['to']));
         if (strlen(trim($h_anchor)) && strlen(trim((string) $a_url)) && $a_url != 'http://') {
             $link_html[] = str_replace('{link}', "<a href=\"{$a_url}\"{$title}{$rel}{$target}>{$h_anchor}</a>", $footer_link_format);
         }
     }
     echo str_replace('{links}', implode($footer_link_sep, $link_html), $footer_link_section_format);
 }
예제 #19
0
 function downgrade_tab()
 {
     if (!$this->current_user_can_downgrade()) {
         $this->print_message('error', __('You do not have sufficient permissions to downgrade plugins on this site.', 'seo-ultimate'));
         return;
     }
     $radiobuttons = $this->get_version_radiobuttons(SU_DOWNGRADE_LIMIT, SU_VERSION, 5);
     if (is_array($radiobuttons)) {
         if (count($radiobuttons) > 1) {
             $this->print_message('warning', suwp::add_backup_url(__('Downgrading is provided as a convenience only and is not officially supported. Although unlikely, you may lose data in the downgrading process. It is your responsibility to backup your database before proceeding.', 'seo-ultimate')));
             echo "\n<p>";
             _e('From the list below, select the version to which you would like to downgrade. Then click the &#8220;Downgrade&#8221; button at the bottom of the screen.', 'seo-ultimate');
             echo "</p>\n";
             echo "<div class='su-xgrade'>\n";
             $this->admin_form_start();
             $this->radiobuttons('version', $radiobuttons);
             $this->admin_form_end(__('Downgrade', 'seo-ultimate'));
             echo "</div>\n";
         } else {
             $this->print_message('warning', sprintf(__('Downgrading to versions earlier than %s is not supported because doing so will result the loss of some or all of your SEO Ultimate settings.', 'seo-ultimate'), SU_DOWNGRADE_LIMIT));
         }
     } else {
         $this->print_message('error', __('There was an error retrieving the list of available versions. Please try again later.', 'seo-ultimate'));
     }
 }