function http_link_rel_canonical() { if (headers_sent()) { return; } if ($url = $this->get_canonical_url()) { $url = su_esc_attr($url); header("Link: <{$url}>; rel=\"canonical\"", false); } }
function add_tags($content, $tags, $template, $escape = true) { if ($escape) { $content = su_esc_attr($content); } $tags = array_reverse((array) $tags); foreach ($tags as $tag) { if (sustr::startswith($tag, '<')) { $content = sprintf($tag, $content); } else { $content = sprintf($template, $tag, $content); } } return $content; }
function head_tag_output() { $verify = $this->get_supported_search_engines(); foreach ($verify as $site => $site_data) { $name = $site_data['meta_name']; //Do we have verification tags? If so, output them. if ($value = $this->get_setting($site . '_verify')) { if (current_user_can('unfiltered_html') && sustr::startswith(trim($value), '<meta ') && sustr::endswith(trim($value), '/>')) { echo "\t" . trim($value) . "\n"; } else { $value = su_esc_attr($value); echo "\t<meta name=\"{$name}\" content=\"{$value}\" />\n"; } } } }
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 _autolink_content($id, $content, $links, $limit, &$count, &$link_count, $round = 1, $linked_urls = array(), $context = 'the_content') { $links = array_values($links); $count = 0; if (!is_array($link_count)) { $link_count = array(); } $i = 0; foreach ($links as $data) { if (!isset($link_count[$i])) { $link_count[$i] = 0; } $i++; } if (!$this->get_setting('autolink_posttype_' . get_post_type($id))) { return $content; } if ($this->get_postmeta('disable_autolinks', $id)) { return $content; } $limit_enabled = $this->get_setting('limit_lpp', false); if ($limit_enabled && $limit < 1) { return $content; } $oldlimit = $limit; $lpa_limit_enabled = $this->get_setting('limit_lpa', false); $lpa_limit = $lpa_limit_enabled ? $this->get_setting('limit_lpa_value', 5) : -1; $lpu_limit_enabled = $this->get_setting('limit_lpu', false); $lpu_limit = $lpu_limit_enabled ? $this->get_setting('limit_lpu_value', 1) : -1; $from_post_type = get_post_type(); $dest_limit = $from_post_type ? (bool) $this->get_setting('dest_limit_' . $from_post_type, false) : false; $dest_limit_taxonomies = array(); if ($dest_limit) { $from_post_type_taxonomies = suwp::get_object_taxonomy_names($from_post_type); foreach ($from_post_type_taxonomies as $from_post_type_taxonomy) { if ($this->get_setting('dest_limit_' . $from_post_type . '_within_' . $from_post_type_taxonomy, false)) { $dest_limit_taxonomies[] = $from_post_type_taxonomy; } } } $autolink_class = $this->get_setting('autolink_class', ''); $post = get_post($id); $i = 0; foreach ($links as $data) { $anchor = $data['anchor']; $to_id = su_esc_attr($data['to_id']); if (strlen(trim($anchor)) && $to_id !== 0 && $to_id != 'http://') { //*** Begin sitewide links-per-anchor dampening effect *** //Get the dampening percentage for this link, but only if per-link values are enabled if ($this->get_setting('enable_perlink_dampen_sitewide_lpa', false)) { $link_dswlpa = $data['dampen_sitewide_lpa']; } else { $link_dswlpa = false; } if (false === $link_dswlpa) { //We need the === operator here so we don't match a zero //There's no per-link value, so get the default, if a default value is specified and enabled if ($this->get_setting('dampen_sitewide_lpa', false)) { $link_dswlpa = $this->get_setting('dampen_sitewide_lpa_value', 0); } else { $link_dswlpa = false; } //Indicates there's neither a per-link value or a default value available } if (false !== $link_dswlpa) { $link_dswlpa = absint($link_dswlpa); if ($link_dswlpa == 0) { break; } if ($link_dswlpa > 100) { $link_dswlpa = 100; } //Rather than generating a random number, we use the MD5s of the anchor and the post's ID. //This gives us a quasi-random dampening effect that will turn out the same way for any given post each time the dampener is applied. //We don't want a post's autolinks changing every time the post is viewed. $md5starts = array_slice(array_unique(str_split(md5($anchor))), 0, intval(round(16 * (1 - $link_dswlpa / 100)))); //Only apply this autolink if the MD5 of the post's ID starts with one of the allowed characters if (!in_array(substr(md5($id), 0, 1), $md5starts)) { continue; } //Don't apply autolink; continue to next item in the $links foreach loop } //*** End sitewide LPA dampener *** $type = $data['to_type']; if (sustr::startswith($type, 'posttype_')) { $to_id = intval($to_id); $to_post = get_post($to_id); if (get_post_status($to_id) != 'publish') { continue; } if (count($dest_limit_taxonomies)) { $shares_term = false; foreach ($dest_limit_taxonomies as $dest_limit_taxonomy) { $from_terms = suarr::flatten_values(get_the_terms(null, $dest_limit_taxonomy), 'term_id'); if (is_object_in_taxonomy($to_post, $dest_limit_taxonomy)) { $to_terms = suarr::flatten_values(get_the_terms($to_id, $dest_limit_taxonomy), 'term_id'); } else { $to_terms = array(); } if (count(array_intersect($from_terms, $to_terms))) { $shares_term = true; break; } } if (!$shares_term) { continue; } } $url = get_permalink($to_id); } elseif ($type == 'url') { $url = $to_id; } else { $url = $this->jlsuggest_value_to_url($to_id ? "obj_{$type}/{$to_id}" : "obj_{$type}"); } if (!is_string($url)) { continue; } if (!$this->get_setting('enable_current_url_links', false) && suurl::equal($url, suurl::current())) { continue; } if (!$this->get_setting('enable_self_links', false) && is_singular() && suurl::equal($url, get_permalink())) { continue; } if ($lpu_limit_enabled && isset($linked_urls[$url]) && $linked_urls[$url] >= $lpu_limit) { continue; } $rel = $data['nofollow'] ? ' rel="nofollow"' : ''; $target = $data['target'] == 'blank' ? ' target="_blank"' : ''; $title = strlen($titletext = su_esc_attr($data['title'])) ? " title=\"{$titletext}\"" : ''; $class = $autolink_class ? ' class="' . su_esc_attr($autolink_class) . '"' : ''; $a_url = su_esc_attr($url); $h_anchor = esc_html($anchor); $link = "<a href=\"{$a_url}\"{$title}{$rel}{$target}{$class}>\$1</a>"; $lpa_lpu_limits = array(); if ($lpa_limit_enabled) { $lpa_lpu_limits[] = $lpa_limit; } if ($lpu_limit_enabled) { $lpa_lpu_limits[] = $lpu_limit; } $lpa_lpu_limits = count($lpa_lpu_limits) ? sunum::lowest($lpa_lpu_limits) : -1; $content = sustr::htmlsafe_str_replace($h_anchor, $link, $content, $limit_enabled ? 1 : $lpa_lpu_limits, $new_count, $this->get_linkfree_tags()); $link_count[$i] += $new_count; $count += $new_count; if ($lpu_limit_enabled) { if (isset($linked_urls[$url])) { $linked_urls[$url] += $new_count; } else { $linked_urls[$url] = $new_count; } } if ($limit_enabled) { $limit -= $new_count; if ($limit < 1) { return $content; } } } $i++; } if ($limit_enabled && $limit < $oldlimit && $round < $lpa_limit) { $content = $this->_autolink_content($id, $content, $links, $limit, $count, $link_count, $round + 1, $linked_urls, $context); } return $content; }
function admin_page_contents() { $the404s = $this->get_setting('log'); if (!$this->get_setting('log_enabled', true)) { $this->queue_message('warning', __('New 404 errors will not be recorded because 404 logging is disabled on the Settings tab.', 'seo-ultimate')); } //Are we deleting a 404 entry? if ($this->is_action('delete')) { if (isset($the404s[$_GET['object']])) { unset($the404s[$_GET['object']]); $this->queue_message('success', __('The log entry was successfully deleted.', 'seo-ultimate')); } else { $this->queue_message('error', __('This log entry has already been deleted.', 'seo-ultimate')); } $this->update_setting('log', $the404s); //Are we clearing the whole 404 log? } elseif ($this->is_action('clear')) { $the404s = array(); $this->update_setting('log', array()); $this->queue_message('success', __('The log was successfully cleared.', 'seo-ultimate')); } if (!count($the404s)) { $this->queue_message('success', __('No 404 errors in the log.', 'seo-ultimate')); } $this->print_messages(); if (count($the404s)) { $this->clear_log_button(); echo "<div id='su-404s-log-table'>\n"; $headers = $this->get_admin_table_columns(); $this->admin_wftable_start(); uasort($the404s, array(&$this, 'sort_log_callback')); foreach ($the404s as $url => $data) { $new = $data['is_new'] ? ' su-404s-new-hit' : ''; $a_url = su_esc_attr($url); $ae_url = su_esc_attr(urlencode($url)); $md5url = md5($url); echo "\t<tr id='su-404s-hit-{$md5url}-data' class='su-404s-hit-data{$new}'>\n"; $this->table_cells(array('actions' => "<span class='su-404s-hit-open'><a href='{$a_url}' target='_blank'><img src='{$this->module_dir_url}hit-open.png' title='" . __('Open URL in new window (will not be logged)', 'seo-ultimate') . "' /></a></span>" . "<span class='su-404s-hit-cache'><a href='http://www.google.com/search?q=cache%3A{$ae_url}' target='_blank'><img src='{$this->module_dir_url}hit-cache.png' title='" . __('Query Google for cached version of URL (opens in new window)', 'seo-ultimate') . "' /></a></span>" . "<span class='su-404s-hit-delete'><a href='" . $this->get_nonce_url('delete', $url) . "'><img src='{$this->module_dir_url}hit-delete.png' title='" . __('Remove this URL from the log', 'seo-ultimate') . "' /></a></span>", 'hit-count' => $data['hit_count'], 'url' => "<attr title='{$a_url}'>" . esc_html(sustr::truncate($url, 100)) . '</attr>', 'last-hit-time' => sprintf(__('%s at %s', 'seo-ultimate'), date_i18n(get_option('date_format'), $data['last_hit_time']), date_i18n(get_option('time_format'), $data['last_hit_time'])), 'referers' => number_format_i18n(count($data['referers'])) . (count($data['referers']) ? " <a href='#' class='su_toggle_hide' data-toggle='su-404s-hit-{$md5url}-referers'><img src='{$this->module_dir_url}hit-details.png' title='" . __('View list of referring URLs', 'seo-ultimate') . "' /></a>" : ''), 'user-agents' => number_format_i18n(count($data['user_agents'])) . (count($data['user_agents']) ? " <a href='#' class='su_toggle_hide' data-toggle='su-404s-hit-{$md5url}-user-agents'><img src='{$this->module_dir_url}hit-details.png' title='" . __('View list of user agents', 'seo-ultimate') . "' /></a>" : ''))); echo "\t</tr>\n"; echo "\t<tr class='su-404s-hit-referers{$new}'>\n\t\t<td colspan='" . count($headers) . "'>"; if (count($data['referers'])) { echo "<div id='su-404s-hit-{$md5url}-referers' class='su-404s-hit-referers-list' style='display:none;'>\n"; echo "\t\t\t<div><strong>" . __('Referring URLs', 'seo-ultimate') . "</strong> — "; echo "<a href='#' class='su_toggle_up' data-toggle='su-404s-hit-{$md5url}-referers'>" . __('Hide list', 'seo-ultimate') . "</a>"; echo "</div>\n"; echo "\t\t\t<ul>\n"; foreach ($data['referers'] as $referer) { $referer = su_esc_attr($referer); //Don't let attacks pass through the referer URLs! echo "\t\t\t\t<li><a href='{$referer}' target='_blank'>{$referer}</a></li>\n"; } echo "\t\t\t</ul>\n"; echo "\t\t</div>"; } echo "</td>\n\t</tr>\n"; echo "\t<tr class='su-404s-hit-user-agents{$new}'>\n\t\t<td colspan='" . count($headers) . "'>"; if (count($data['user_agents'])) { echo "<div id='su-404s-hit-{$md5url}-user-agents' class='su-404s-hit-user-agents-list' style='display:none;'>\n"; echo "\t\t\t<div><strong>" . __('User Agents', 'seo-ultimate') . "</strong> — "; echo "<a href='#' class='su_toggle_up' data-toggle='su-404s-hit-{$md5url}-user-agents'>" . __('Hide list', 'seo-ultimate') . "</a>"; echo "</div>\n"; echo "\t\t\t<ul>\n"; foreach ($data['user_agents'] as $useragent) { $useragent = su_esc_html($useragent); //Don't let attacks pass through the user agent strings! echo "\t\t\t\t<li>{$useragent}</li>\n"; } echo "\t\t\t</ul>\n"; echo "</td>\n\t</tr>\n"; } echo "\t\t</div>"; $the404s[$url]['is_new'] = false; } $this->update_setting('log', $the404s); $this->admin_wftable_end(); echo "</div>\n"; $this->clear_log_button(); } }
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"; } }
function postmeta_fields($fields, $screen) { $id = "_su_title"; $value = su_esc_attr($this->get_postmeta('title')); $fields['serp'][10]['title'] = "<div class='form-group su textbox'>\n<label class='col-sm-4 col-md-4 control-label' for='{$id}'>" . __('Title Tag:', 'seo-ultimate') . "</label>\n<div class='col-sm-4 col-md-4'><input name='{$id}' id='{$id}' type='text' value='{$value}' class='form-control input-sm regular-text' tabindex='2'" . " onkeyup=\"javascript:document.getElementById('su_title_charcount').innerHTML = document.getElementById('_su_title').value.length\" />" . "</div>\n<div class='col-sm-4 col-md-4 help-text'>" . sprintf(__('You’ve entered %s characters. Most search engines use up to 70.', 'seo-ultimate'), "<strong id='su_title_charcount'>" . strlen($value) . "</strong>") . "</div>\n</div>\n"; return $fields; }
/** * Returns the HTML code for a JLSuggest textbox * * @since 6.0 * * @param string $name The value of the textbox's name/ID attributes * @param string $value The current database string associated with this textbox */ function get_jlsuggest_box($name, $value, $params = '', $placeholder = '') { list($to_genus, $to_type, $to_id) = $this->jlsuggest_value_explode($value); $text_dest = ''; $disabled = false; switch ($to_genus) { case 'posttype': $selected_post = get_post($to_id); if ($selected_post) { $selected_post_type = get_post_type_object($selected_post->post_type); $text_dest = $selected_post->post_title . '<span class="type"> — ' . $selected_post_type->labels->singular_name . '</span>'; } else { $selected_post_type = get_post_type_object($to_type); if ($selected_post_type) { $text_dest = sprintf(__('A Deleted %s', 'seo-ultimate'), $selected_post_type->labels->singular_name); } else { $text_dest = __('A Deleted Post', 'seo-ultimate'); } $text_dest = '<span class="type">' . $text_dest . '</span>'; $disabled = true; } break; case 'taxonomy': if ($selected_taxonomy = get_taxonomy($to_type)) { if ($selected_term = get_term($to_id, $selected_taxonomy->name)) { $text_dest = $selected_term->name . '<span class="type"> — ' . $selected_taxonomy->labels->singular_name . '</span>'; } else { $text_dest = sprintf(__('A Deleted %s', 'seo-ultimate'), $selected_taxonomy->labels->singular_name); $text_dest = '<span class="type">' . $text_dest . '</span>'; $disabled = true; } } else { $text_dest = __('A Deleted Term', 'seo-ultimate'); $text_dest = '<span class="type">' . $text_dest . '</span>'; $disabled = true; } break; case 'home': $text_dest = __('Blog Homepage', 'seo-ultimate'); break; case 'author': if (is_user_member_of_blog($to_id)) { $selected_author = get_userdata($to_id); $text_dest = $selected_author->user_login . '<span class="type"> — ' . __('Author', 'seo-ultimate') . '</span>'; } else { $text_dest = __('A Deleted User', 'seo-ultimate'); $text_dest = '<span class="type">' . $text_dest . '</span>'; $disabled = true; } break; case 'internal-link-alias': $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'])) { $h_alias_to = su_esc_html($aliases[$to_id]['to']); $text_dest = "/{$alias_dir}/{$h_alias_to}/" . '<span class="type"> — '; if ($this->plugin->module_exists('internal-link-aliases')) { $text_dest .= __('Link Mask', 'seo-ultimate'); } else { $text_dest .= __('Link Mask (Disabled)', 'seo-ultimate'); $disabled = true; } $text_dest .= '</span>'; } else { $text_dest = __('A Deleted Link Mask', 'seo-ultimate'); $text_dest = '<span class="type">' . $text_dest . '</span>'; $disabled = true; } break; } $is_url = 'url' == $to_genus && !$text_dest; $to_genus_type = implode('_', array_filter(array($to_genus, $to_type))); $obj = 'obj_' . implode('/', array_filter(array($to_genus_type, $to_id))); //URL textbox //(hide if object is selected) $html = "<input name='{$name}' id='{$name}' value='"; $html .= su_esc_editable_html($is_url ? $to_id : $obj); $html .= "'"; if ($params) { $e_params = su_esc_attr($params); $html .= " su:params='{$e_params}'"; } if ($placeholder) { $e_placeholder = su_esc_attr($placeholder); $html .= " placeholder='{$e_placeholder}'"; } $html .= " type='text' class='form-control input-sm textbox regular-text jlsuggest'"; $html .= ' title="' . __('Type a URL or start typing the name of an item on your site', 'seo-ultimate') . '"'; $html .= $is_url ? '' : ' style="display:none;" '; $html .= ' />'; //Object box //(hide if URL is entered) $disabled = $disabled ? ' jlsuggest-disabled' : ''; $html .= "<div class='jls_text_dest{$disabled}'"; $html .= $is_url ? ' style="display:none;" ' : ''; $html .= '>'; $html .= '<div class="jls_text_dest_text">'; $html .= $text_dest; $html .= '</div>'; $html .= '<div><a href="#" onclick="javascript:return false;" class="jls_text_dest_close" title="' . __('Remove this location from this textbox', 'seo-ultimate') . '">' . __('X', 'seo-ultimate') . '</a></div>'; $html .= '</div>'; return $html; }
function reinstall_tab() { if (!$this->current_user_can_reinstall()) { $this->print_message('error', __('You do not have sufficient permissions to reinstall plugins on this site.', 'seo-ultimate')); return; } echo "\n<p>"; _e('To download and install a fresh copy of the SEO Ultimate version you are currently using, click the “Reinstall” button below.', 'seo-ultimate'); echo "</p>\n"; $this->admin_form_start(false, false); echo "<input type='hidden' name='version' id='version' value='" . su_esc_attr(SU_VERSION) . "' />\n"; $this->admin_form_end(__('Reinstall', 'seo-ultimate'), false); }
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); }
function postmeta_fields($fields, $screen) { if (!current_user_can('manage_options')) { return $fields; } $post_id = suwp::get_post_id(); $post = get_post($post_id); if (!$post) { return $fields; } $content = $post->post_content; $alias_dir = $this->get_setting('alias_dir', 'go'); if ($content && preg_match_all('@ href=["\']([^#][^"\']+)["\']@', $content, $matches)) { $urls = array_unique($matches[1]); $html = "<tr valign='top'>\n<th scope='row' class='su'>" . __('Link Masks:', 'seo-ultimate') . "</th>\n<td>\n"; $html .= "<table class='widefat'><thead>\n"; $headers = array(__('URL', 'seo-ultimate'), '', __('Mask URL', 'seo-ultimate')); foreach ($headers as $header) { $html .= "<th>{$header}</th>\n"; } $html .= "</thead>\n<tbody>"; $aliases = $this->get_setting('aliases', array()); $post_aliases = array(); foreach ($aliases as $id => $alias) { if (empty($alias['posts']) || in_array($post->ID, $alias['posts'])) { $post_aliases[$alias['from']] = array('id' => $id, 'to' => $alias['to']); } } foreach ($urls as $url) { $a_url = su_esc_attr($url); $un_h_url = htmlspecialchars_decode($url); $ht_url = esc_html(sustr::truncate($url, 30)); if (isset($post_aliases[$url])) { $url_key = $url; } elseif (isset($post_aliases[$un_h_url])) { $url_key = $un_h_url; } else { $url_key = false; } $alias_to = ''; $alias_id = uniqid('', true); if ($url_key) { if (isset($post_aliases[$url_key]['to'])) { $alias_to = $post_aliases[$url_key]['to']; } if (isset($post_aliases[$url_key]['id'])) { $alias_id = $post_aliases[$url_key]['id']; } } $a_alias_to = esc_attr($alias_to); $html .= "<tr><td><a href='{$a_url}' title='{$a_url}' target='_blank'>{$ht_url}</a><input type='hidden' name='_su_aliases[{$alias_id}][from]' value='{$a_url}' /></td>\n<td>⇒</td><td>/{$alias_dir}/<input type='text' name='_su_aliases[{$alias_id}][to]' value='{$a_alias_to}' /></td></tr>\n"; } $html .= "</tbody>\n</table>\n"; $html .= '<p><small>' . __('You can stop search engines from following a link by typing in a mask for its URL.', 'seo-ultimate') . "</small></p>\n"; $html .= "</td>\n</tr>\n"; $fields['links'][100]['aliases'] = $html; } return $fields; }
function postmeta_fields($fields) { $id = "_su_title"; $value = su_esc_attr($this->get_postmeta('title')); $fields['serp'][10]['title'] = "<tr class='su textbox' valign='top'>\n<th scope='row' class='su'><label for='{$id}'>" . __('Title Tag:', 'seo-ultimate') . "</label></th>\n" . "<td class='su'><input name='{$id}' id='{$id}' type='text' value='{$value}' class='regular-text' tabindex='2'" . " onkeyup=\"javascript:document.getElementById('su_title_charcount').innerHTML = document.getElementById('_su_title').value.length\" />" . "<br />" . sprintf(__('You’ve entered %s characters. Most search engines use up to 70.', 'seo-ultimate'), "<strong id='su_title_charcount'>" . strlen($value) . "</strong>") . "</td>\n</tr>\n"; return $fields; }
function output_author_link_tags() { if (is_404()) { return; } $user_id = false; $mode = $this->get_mode(); switch ($mode) { case SU_AUTHORLINKS_MODE_OFF: return; break; case SU_AUTHORLINKS_MODE_SINGLEAUTHOR: $users_with_gp = (array) $this->get_users_with_gp(); $user = reset($users_with_gp); $user_id = $user->ID; break; case SU_AUTHORLINKS_MODE_MULTIAUTHOR: if (is_home()) { $home_author = $this->get_setting('home_author', 'none'); if (is_numeric($home_author)) { $user_id = $home_author; } } elseif (is_singular()) { global $post; if (is_object($post)) { $user_id = $post->post_author; } } elseif (is_author()) { global $wp_query; $user_id = $wp_query->get_queried_object_id(); } elseif (is_archive()) { $archives_author = $this->get_setting('archives_author', 'none'); if (is_numeric($archives_author)) { $user_id = $archives_author; } } break; } if ($user_id !== false) { $url = get_user_meta($user_id, 'googleplus', true); $url = su_esc_attr($url); if ($url) { echo "\t<link rel=\"author\" href=\"{$url}\" />\n"; } } }
function postmeta_fields($fields, $screen) { $id = '_su_description'; $value = su_esc_attr($this->get_postmeta('description')); $fields['serp'][20]['description'] = "<div class='form-group su textarea'>\n<label class='col-sm-4 col-md-4 control-label' for='{$id}'>" . __('Meta Description:', 'seo-ultimate') . "</label>\n<div class='col-sm-4 col-md-4'>" . "<textarea name='{$id}' id='{$id}' class='form-control regular-text' cols='60' rows='3' tabindex='2'" . " onkeyup=\"javascript:document.getElementById('su_meta_description_charcount').innerHTML = document.getElementById('_su_description').value.length\">{$value}</textarea>" . "</div>\n<div class='col-sm-4 col-md-4 help-text'>" . sprintf(__('You’ve entered %s characters. Most search engines use up to 140.', 'seo-ultimate'), "<strong id='su_meta_description_charcount'>" . strlen($value) . "</strong>") . "</div>\n</div>\n"; return $fields; }
function head_tag_output() { global $wp_query; $tags = $twitter_tags = array(); if (is_home()) { //Type $tags['og:type'] = 'blog'; //Twitter Type $twitter_tags['twitter:card'] = 'summary'; //Title if (!($tags['og:title'] = $this->get_setting('home_og_title'))) { $tags['og:title'] = get_bloginfo('name'); } //Description if (!($tags['og:description'] = $this->get_setting('home_og_description'))) { $tags['og:description'] = get_bloginfo('description'); } //URL $tags['og:url'] = suwp::get_blog_home_url(); //Image $tags['og:image'] = $this->get_setting('home_og_image'); } elseif (is_singular()) { $post = $wp_query->get_queried_object(); if (is_object($post)) { //Type if (!($tags['og:type'] = $this->get_postmeta('og_type'))) { $tags['og:type'] = $this->get_setting("default_{$post->post_type}_og_type"); } //Twitter Type if (!($twitter_tags['twitter:card'] = $this->get_postmeta('twitter_card'))) { $twitter_tags['twitter:card'] = $this->get_setting("default_{$post->post_type}_twitter_card"); } //Title if (!($tags['og:title'] = $this->get_postmeta('og_title'))) { $tags['og:title'] = strip_tags(apply_filters('single_post_title', $post->post_title)); } //Description if (!($tags['og:description'] = $this->get_postmeta('og_description'))) { if ($this->plugin->call_module_func('meta-descriptions', 'get_meta_desc', $meta_desc, false) && $meta_desc) { $tags['og:description'] = $meta_desc; } } //URL $tags['og:url'] = get_permalink($post->ID); //Image $tags['og:image'] = $this->jlsuggest_value_to_url($this->get_postmeta('og_image'), true); if (!$tags['og:image']) { if ('attachment' == $post->post_type) { $tags['og:image'] = wp_get_attachment_url(); } elseif (current_theme_supports('post-thumbnails') && ($thumbnail_id = get_post_thumbnail_id($post->ID))) { $tags['og:image'] = wp_get_attachment_url($thumbnail_id); } } //Additional fields switch ($tags['og:type']) { case 'article': $tags['article:published_time'] = get_the_date('Y-m-d'); $tags['article:modified_time'] = get_the_modified_date('Y-m-d'); //Authorship generally doesn't apply to pages if (!is_page() && $this->get_setting('enable_og_article_author', true)) { $tags['article:author'] = get_author_posts_url($post->post_author); } $single_category = count(get_the_category()) == 1; $taxonomy_names = suwp::get_taxonomy_names(); foreach ($taxonomy_names as $taxonomy_name) { if ($terms = get_the_terms(get_the_ID(), $taxonomy_name)) { if ($single_category && 'category' == $taxonomy_name) { $meta_property = 'article:section'; } else { $meta_property = 'article:tag'; } foreach ($terms as $term) { $tags[$meta_property][] = $term->name; } } } break; } //Author's Twitter Handle $handle = get_user_meta($post->post_author, 'twitter', true); $handle = $this->sanitize_twitter_handle($handle); $twitter_tags['twitter:creator'] = $handle; } } elseif (is_author()) { $author = $wp_query->get_queried_object(); if (is_object($author)) { //Type $tags['og:type'] = 'profile'; //Title $tags['og:title'] = $author->display_name; //Description $tags['og:title'] = get_the_author_meta('description', $author->ID); //Image $tags['og:image'] = false; //URL $tags['og:url'] = get_author_posts_url($author->ID, $author->user_nicename); //First Name $tags['profile:first_name'] = get_the_author_meta('first_name', $author->ID); //Last Name $tags['profile:last_name'] = get_the_author_meta('last_name', $author->ID); //Username $tags['profile:username'] = $author->user_login; //Twitter Handle $handle = get_user_meta($author->ID, 'twitter', true); $handle = $this->sanitize_twitter_handle($handle); $twitter_tags['twitter:creator'] = $handle; } } else { return; } if ($tags['og:type'] == 'none') { $tags['og:type'] = ''; } if ((!isset($tags['og:image']) || !$tags['og:image']) && $tags['og:image'] !== false) { $tags['og:image'] = $this->jlsuggest_value_to_url($this->get_setting('default_og_image'), true); } //Site Name if (!($tags['og:site_name'] = $this->get_setting('og_site_name'))) { $tags['og:site_name'] = get_bloginfo('name'); } //FB App ID $tags['fb:app_id'] = $this->get_setting('default_fb_app_id'); //Twitter Site Handle $twitter_tags['twitter:site'] = $this->get_setting('twitter_site_handle'); $twitter_tags['twitter:site:id'] = $this->get_setting('twitter_site_id_handle'); $twitter_tags['twitter:creator'] = $this->get_setting('twitter_creator_handle'); $twitter_tags['twitter:creator:id'] = $this->get_setting('twitter_creator_id_handle'); $twitter_tags['twitter:description'] = $this->get_setting('twitter_description_handle'); $twitter_tags['twitter:title'] = $this->get_setting('twitter_title_handle'); $twitter_tags['twitter:image:src'] = $this->get_setting('twitter_image_src_handle'); $twitter_tags['twitter:image:width'] = $this->get_setting('twitter_image_width_handle'); $twitter_tags['twitter:image:height'] = $this->get_setting('twitter_image_height_handle'); $twitter_tags['twitter:data1'] = $this->get_setting('twitter_data1_handle'); $twitter_tags['twitter:label1'] = $this->get_setting('twitter_label1_handle'); $twitter_tags['twitter:data2'] = $this->get_setting('twitter_data2_handle'); $twitter_tags['twitter:label2'] = $this->get_setting('twitter_label2_handle'); $twitter_tags['twitter:image0:src'] = $this->get_setting('twitter_image0_src_handle'); $twitter_tags['twitter:image1:src'] = $this->get_setting('twitter_image1_src_handle'); $twitter_tags['twitter:image2:src'] = $this->get_setting('twitter_image2_src_handle'); $twitter_tags['twitter:image3:src'] = $this->get_setting('twitter_image3_src_handle'); $twitter_tags['twitter:player'] = $this->get_setting('twitter_player_handle'); $twitter_tags['twitter:player:width'] = $this->get_setting('twitter_player_width_handle'); $twitter_tags['twitter:player:height'] = $this->get_setting('twitter_player_height_handle'); $twitter_tags['twitter:player:stream'] = $this->get_setting('twitter_player_stream_handle'); $twitter_tags['twitter:app:name:iphone'] = $this->get_setting('twitter_app_name_iphone_handle'); $twitter_tags['twitter:app:id:iphone'] = $this->get_setting('twitter_app_id_iphone_handle'); $twitter_tags['twitter:app:url:iphone'] = $this->get_setting('twitter_app_url_iphone_handle'); $twitter_tags['twitter:app:name:iphone'] = $this->get_setting('twitter_app_name_ipad_handle'); $twitter_tags['twitter:app:id:iphone'] = $this->get_setting('twitter_app_id_ipad_handle'); $twitter_tags['twitter:app:url:iphone'] = $this->get_setting('twitter_app_url_ipad_handle'); $twitter_tags['twitter:app:name:googleplay'] = $this->get_setting('twitter_app_name_googleplay_handle'); $twitter_tags['twitter:app:id:googleplay'] = $this->get_setting('twitter_app_id_googleplay_handle'); $twitter_tags['twitter:app:url:googleplay'] = $this->get_setting('twitter_app_url_googleplay_handle'); //Output meta tags $namespace_urls = $this->namespaces_declared ? array() : $this->get_namespace_urls(); $doctype = $this->get_setting('doctype', ''); switch ($doctype) { case 'xhtml': $output_formats = array('<meta%3$s name="%1$s" content="%2$s" />' => array_merge($tags, $twitter_tags)); break; case 'html5': $output_formats = array('<meta%3$s property="%1$s" content="%2$s">' => array_merge($tags, $twitter_tags)); break; default: $output_formats = array('<meta%3$s property="%1$s" content="%2$s" />' => $tags, '<meta%3$s name="%1$s" content="%2$s" />' => $twitter_tags); break; } foreach ($output_formats as $html_format => $format_tags) { foreach ($format_tags as $property => $values) { foreach ((array) $values as $value) { $property = su_esc_attr($property); $value = su_esc_attr($value); if (strlen(trim($property)) && strlen(trim($value))) { $namespace_attr = ''; $namespace = sustr::upto($property, ':'); if (!empty($namespace_urls[$namespace])) { $a_namespace = su_esc_attr($namespace); $a_namespace_url = su_esc_attr($namespace_urls[$namespace]); switch ($doctype) { case 'xhtml': $namespace_attr = " xmlns:{$a_namespace}=\"{$a_namespace_url}\""; break; case 'html5': default: $namespace_attr = " prefix=\"{$a_namespace}: {$a_namespace_url}\""; break; } } echo "\t"; printf($html_format, $property, $value, $namespace_attr); echo "\n"; } } } } }
/** * Outputs code into the template's <head> tag. * * @since 0.1 */ function template_head() { echo "<!------------ Created by Seo Wizard Wordpress Plugin - www.seo.uk.net ----------->"; //Let modules output head code. do_action('su_head'); //Make sure the blog is public. Telling robots what to do is a moot point if they aren't even seeing the blog. if (get_option('blog_public')) { $robots = implode(',', apply_filters('su_meta_robots', array())); $robots = su_esc_attr($robots); if ($robots) { echo "\t<meta name=\"robots\" content=\"{$robots}\" />\n"; } } }
/** * Outputs code into the template's <head> tag. * * @since 0.1 */ function template_head() { if ($markcode = $this->get_setting('mark_code', true, 'settings')) { echo "\n<!-- " . SU_PLUGIN_NAME . " (" . SU_PLUGIN_URI . ") -->\n"; } //Let modules output head code. do_action('su_head'); //Make sure the blog is public. Telling robots what to do is a moot point if they aren't even seeing the blog. if (get_option('blog_public')) { $robots = implode(',', apply_filters('su_meta_robots', array())); $robots = su_esc_attr($robots); if ($robots) { echo "\t<meta name=\"robots\" content=\"{$robots}\" />\n"; } } if ($markcode) { echo "<!-- /" . SU_PLUGIN_NAME . " -->\n\n"; } }
function postmeta_fields($fields) { $id = '_su_description'; $value = su_esc_attr($this->get_postmeta('description')); $fields['serp'][20]['description'] = "<tr class='su textarea' valign='top'>\n<th scope='row' class='su'><label for='{$id}'>" . __('Meta Description:', 'seo-ultimate') . "</label></th>\n" . "<td class='su'><textarea name='{$id}' id='{$id}' class='regular-text' cols='60' rows='3' tabindex='2'" . " onkeyup=\"javascript:document.getElementById('su_meta_description_charcount').innerHTML = document.getElementById('_su_description').value.length\">{$value}</textarea>" . "<br />" . sprintf(__('You’ve entered %s characters. Most search engines use up to 140.', 'seo-ultimate'), "<strong id='su_meta_description_charcount'>" . strlen($value) . "</strong>") . "</td>\n</tr>\n"; return $fields; }