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(']]>', ']]>', $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() { $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 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; }