示例#1
0
 function more_link_filter($link, $text = false)
 {
     if ($text === false) {
         return $link;
     }
     //Can't do it without $text parameter
     $default = $this->get_setting('default');
     if (strlen($newtext = trim($this->get_postmeta('morelinktext'))) || strlen(trim($newtext = $default))) {
         $newtext = str_replace('{post}', su_esc_html(get_the_title()), $newtext);
         $link = str_replace("{$text}</a>", "{$newtext}</a>", $link);
     }
     return $link;
 }
 /**
  * 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;
 }
 /**
  * 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">&nbsp;&mdash;&nbsp;' . $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">&nbsp;&mdash;&nbsp;' . $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">&nbsp;&mdash;&nbsp;' . __('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">&nbsp;&mdash;&nbsp;';
                 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;
 }
示例#4
0
 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> &mdash; ";
                 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> &mdash; ";
                 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();
     }
 }