function widget($args, $instance)
 {
     global $post;
     if (!is_singular()) {
         return;
     }
     extract($args);
     $instance['post_type'] = $post->post_type == 'page' ? array('page') : array('post');
     if (yarpp_get_option('cross_relate')) {
         $instance['post_type'] = array('post', 'page');
     }
     $title = apply_filters('widget_title', $instance['title']);
     echo $before_widget;
     if (!$instance['use_template']) {
         echo $before_title;
         if ($title) {
             echo $title;
         } else {
             _e('Related Posts (YARPP)', 'yarpp');
         }
         echo $after_title;
     }
     $instance['domain'] = 'widget';
     echo yarpp_related(null, $instance, false);
     echo $after_widget;
 }
function yarpp_make_optin_classy($classes)
{
    if (!yarpp_get_option('optin')) {
        $classes[] = 'yarpp_attention';
    }
    return $classes;
}
function related_pages_exist($args = array(), $reference_ID = false)
{
    $args['post_type'] = array('page');
    if (yarpp_get_option('cross_relate')) {
        $args['post_type'] = array('post', 'page');
    }
    return yarpp_related_exist($reference_ID, $args);
}
 public function display()
 {
     global $yarpp;
     echo "<div style='overflow:auto'>";
     echo '<div class="yarpp_code_display"';
     if (!$yarpp->get_option('code_display')) {
         echo ' style="display: none;"';
     }
     echo '><strong>' . __("Website display code example", 'yarpp') . '</strong><br /><small>' . __("(Update options to reload.)", 'yarpp') . "</small><br/><div id='display_demo_web'></div></div>";
     echo "<div class='yarpp_form_row yarpp_form_post_types'><div>";
     echo 'Automatically display related content from YARPP Basic on: ';
     echo " <span class='yarpp_help' data-help='" . esc_attr(__("This option automatically displays related posts right after the content on single entry pages. If this option is off, you will need to manually insert <code>related_posts()</code> or variants (<code>related_pages()</code> and <code>related_entries()</code>) into your theme files.", 'yarpp')) . "'>&nbsp;</span>&nbsp;&nbsp;";
     echo "</div><div>";
     $post_types = yarpp_get_option('auto_display_post_types');
     foreach ($yarpp->get_post_types('objects') as $post_type) {
         echo "<label for='yarpp_post_type_{$post_type->name}'><input id='yarpp_post_type_{$post_type->name}' name='auto_display_post_types[{$post_type->name}]' type='checkbox' ";
         checked(in_array($post_type->name, $post_types));
         echo "/> {$post_type->labels->name}</label> ";
     }
     echo "</div></div>";
     $this->checkbox('auto_display_archive', __("Also display in archives", 'yarpp'));
     $this->textbox('limit', __('Maximum number of related posts:', 'yarpp'));
     $this->template_checkbox(false);
     echo "</div>";
     $chosen_template = yarpp_get_option("template");
     $choice = false === $chosen_template ? 'builtin' : ($chosen_template == 'thumbnails' ? 'thumbnails' : 'custom');
     echo "<div class='postbox yarpp_subbox template_options_custom'";
     if ($choice != 'custom') {
         echo ' style="display: none;"';
     }
     echo ">";
     echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
     $this->template_file(false);
     echo "</div>";
     echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
     if ($choice != 'thumbnails') {
         echo ' style="display: none;"';
     }
     echo ">";
     $this->textbox('thumbnails_heading', __('Heading:', 'yarpp'), 40);
     $this->textbox('thumbnails_default', __('Default image (URL):', 'yarpp'), 40);
     $this->textbox('no_results', __('Default display if no results:', 'yarpp'), 40, 'sync_no_results');
     echo "</div>";
     echo "<div class='postbox yarpp_subbox template_options_builtin'";
     if ($choice != 'builtin') {
         echo ' style="display: none;"';
     }
     echo ">";
     $this->beforeafter(array('before_related', 'after_related'), __("Before / after related entries:", 'yarpp'), 15, '', __("For example:", 'yarpp') . ' &lt;ol&gt;&lt;/ol&gt;' . __(' or ', 'yarpp') . '&lt;div&gt;&lt;/div&gt;');
     $this->beforeafter(array('before_title', 'after_title'), __("Before / after each related entry:", 'yarpp'), 15, '', __("For example:", 'yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
     $this->checkbox('show_excerpt', __("Show excerpt?", 'yarpp'), 'show_excerpt');
     $this->textbox('excerpt_length', __('Excerpt length (No. of words):', 'yarpp'), 10, 'excerpted');
     $this->beforeafter(array('before_post', 'after_post'), __("Before / after (excerpt):", 'yarpp'), 10, 'excerpted', __("For example:", 'yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
     $this->textbox('no_results', __('Default display if no results:', 'yarpp'), 40, 'sync_no_results');
     echo "</div>";
     $this->displayorder('order');
     $this->checkbox('promote_yarpp', __("Help promote Yet Another Related Posts Plugin?", 'yarpp') . '<span class="yarpp_help" data-help="' . 'This option will add the line &ldquo;powered by AdBistro&rdquo; beneath the related posts section. ' . 'This link is greatly appreciated."></span>');
 }
示例#5
0
 public function display()
 {
     $output = '<p>' . 'Enable the free <a href="http://www.yarpp.com" target="_blank">YARPP Pro enhancements</a> to add even ' . 'more power to your blog or website!' . '<br/><br/>' . '<a href="' . plugins_url('/', dirname(__FILE__)) . 'includes/yarpp_switch.php" class="yarpp_switch_button button" data-go="pro">Turn them on now</a>&nbsp;&nbsp;' . '<a href="http://www.yarpp.com" target="_blank" style="float:right;text-decoration:underline">Learn more</a>' . '</p>' . '<p>' . 'We can continue to improve the YARPP product for you if we know how it&#39;s used. Please help us by ' . 'allowing usage data to be sent back.' . '<br/>' . '</p>' . '<input
             type="checkbox"
             id="yarpp-optin"
             name="optin"
             value="true" ' . checked(yarpp_get_option('optin') == 1, true, false) . ' ' . '/>' . '<label for="yarpp-optin">Send usage data back.</label>' . '<a href="#" id="yarpp-optin-learnmore" style="float:right;text-decoration:underline">Learn More</a>';
     echo $output;
 }
示例#6
0
function yarpp_ajax_display_demo_rss()
{
    global $wpdb, $post, $userdata, $yarpp_demo_time, $wp_query, $id, $page, $pages, $yarpp_limit;
    header("Content-Type: text/html; charset=utf-8");
    $yarpp_limit = yarpp_get_option('rss_limit');
    $return = yarpp_related(array('post'), array(), false, false, 'demo_rss');
    unset($yarpp_limit);
    echo ereg_replace("[\n\r]", '', nl2br(htmlspecialchars($return)));
    exit;
}
示例#7
0
 function where_filter($arg)
 {
     global $wpdb;
     $threshold = yarpp_get_option('threshold');
     if ($this->yarpp_time) {
         $arg = str_replace("{$wpdb->posts}.ID = ", "yarpp.score >= {$threshold} and yarpp.reference_ID = ", $arg);
         if (yarpp_get_option("recent_only")) {
             $arg .= " and post_date > date_sub(now(), interval " . yarpp_get_option("recent_number") . " " . yarpp_get_option("recent_units") . ") ";
         }
     }
     return $arg;
 }
示例#8
0
    public function displayorder($option, $class = null)
    {
        echo "<div class='yarpp_form_row yarpp_form_select {$class}'><div class='yarpp_form_label'>";
        _e("Order results:", 'yarpp');
        echo "</div><div><select name='{$option}' id='<?php echo {$option}; ?>'>";
        $order = yarpp_get_option($option);
        ?>
                <option value="score DESC" <?php 
        echo $order == 'score DESC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("score (high relevance to low)", 'yarpp');
        ?>
</option>
                <option value="score ASC" <?php 
        echo $order == 'score ASC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("score (low relevance to high)", 'yarpp');
        ?>
</option>
                <option value="post_date DESC" <?php 
        echo $order == 'post_date DESC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("date (new to old)", 'yarpp');
        ?>
</option>
                <option value="post_date ASC" <?php 
        echo $order == 'post_date ASC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("date (old to new)", 'yarpp');
        ?>
</option>
                <option value="post_title ASC" <?php 
        echo $order == 'post_title ASC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("title (alphabetical)", 'yarpp');
        ?>
</option>
                <option value="post_title DESC" <?php 
        echo $order == 'post_title DESC' ? ' selected="selected"' : '';
        ?>
><?php 
        _e("title (reverse alphabetical)", 'yarpp');
        ?>
</option>
                <?php 
        echo "</select></div></div>";
    }
示例#9
0
 public function where_filter($arg)
 {
     global $wpdb;
     $threshold = yarpp_get_option('threshold');
     if ($this->yarpp_time) {
         $arg = str_replace("{$wpdb->posts}.ID = ", "yarpp.score >= {$threshold} and yarpp.reference_ID = ", $arg);
         $recent = yarpp_get_option('recent');
         if (!!$recent) {
             $arg .= " and post_date > date_sub(now(), interval {$recent}) ";
         }
     }
     return $arg;
 }
示例#10
0
function yarpp_ajax_display_distags()
{
    global $wpdb;
    header("HTTP/1.1 200");
    header("Content-Type: text/html; charset=UTF-8");
    $distags = explode(',', yarpp_get_option('distags'));
    array_unshift($distags, ' ');
    foreach ($wpdb->get_results("select {$wpdb->terms}.term_id, name from {$wpdb->terms} natural join {$wpdb->term_taxonomy} where {$wpdb->term_taxonomy}.taxonomy = 'post_tag' order by name") as $tag) {
        echo "<input type='checkbox' name='distags[{$tag->term_id}]' value='true'" . (array_search($tag->term_id, $distags) ? ' checked="checked"' : '') . "  /> <label>{$tag->name}</label> ";
        // for='distags[$tag->term_id]'
    }
    exit;
}
示例#11
0
 /**
  * MAGIC FILTERS
  */
 public function where_filter($arg)
 {
     global $wpdb;
     // modify the where clause to use the related ID list.
     if (!count($this->related_IDs)) {
         $this->related_IDs = array(0);
     }
     $arg = preg_replace("!{$wpdb->posts}.ID = \\d+!", "{$wpdb->posts}.ID in (" . join(',', $this->related_IDs) . ")", $arg);
     // if recent is set, add an additional condition
     $recent = yarpp_get_option('recent');
     if (!!$recent) {
         $arg .= " and post_date > date_sub(now(), interval {$recent}) ";
     }
     return $arg;
 }
 /**
  * MAGIC FILTERS
  */
 public function where_filter($arg)
 {
     global $wpdb;
     $threshold = yarpp_get_option('threshold');
     // modify the where clause to use the related ID list.
     if (!count($this->related_IDs)) {
         $this->related_IDs = array(0);
     }
     $arg = preg_replace("!{$wpdb->posts}.ID = \\d+!", "{$wpdb->posts}.ID in (" . join(',', $this->related_IDs) . ")", $arg);
     // if we have "recent only" set, add an additional condition
     if (yarpp_get_option("recent_only")) {
         $arg .= " and post_date > date_sub(now(), interval " . yarpp_get_option("recent_number") . " " . yarpp_get_option("recent_units") . ") ";
     }
     return $arg;
 }
 public function display()
 {
     global $yarpp;
     echo "<div style='overflow:auto'>";
     echo '<div class="rss_displayed yarpp_code_display"';
     if (!$yarpp->get_option('code_display')) {
         echo ' style="display: none;"';
     }
     echo '><b>' . __("RSS display code example", 'yarpp') . '</b><br /><small>' . __("(Update options to reload.)", 'yarpp') . "</small><br/><div id='display_demo_rss'></div></div>";
     $this->checkbox('rss_display', __("Display related posts in feeds?", 'yarpp') . " <span class='yarpp_help' data-help='" . esc_attr(__("This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.", 'yarpp')) . "'>&nbsp;</span>", '');
     $this->checkbox('rss_excerpt_display', __("Display related posts in the descriptions?", 'yarpp') . " <span class='yarpp_help' data-help='" . esc_attr(__("This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all.", 'yarpp')) . "'>&nbsp;</span>", 'rss_displayed');
     $this->textbox('rss_limit', __('Maximum number of related posts:', 'yarpp'), 2, 'rss_displayed');
     $this->template_checkbox(true, 'rss_displayed');
     echo "</div>";
     $chosen_template = yarpp_get_option("rss_template");
     $choice = false === $chosen_template ? 'builtin' : ($chosen_template == 'thumbnails' ? 'thumbnails' : 'custom');
     echo "<div class='postbox yarpp_subbox template_options_custom rss_displayed'";
     if ($choice != 'custom') {
         echo ' style="display: none;"';
     }
     echo ">";
     echo '<div class="yarpp_form_row"><div>' . $this->template_text . '</div></div>';
     $this->template_file(true);
     echo "</div>";
     echo "<div class='postbox yarpp_subbox template_options_thumbnails'";
     if ($choice != 'thumbnails') {
         echo ' style="display: none;"';
     }
     echo ">";
     $this->textbox('rss_thumbnails_heading', __('Heading:', 'yarpp'), 40);
     $this->textbox('rss_thumbnails_default', __('Default image (URL):', 'yarpp'), 40);
     $this->textbox('rss_no_results', __('Default display if no results:', 'yarpp'), 40, 'sync_rss_no_results');
     echo "</div>";
     echo "<div class='postbox yarpp_subbox template_options_builtin rss_displayed'";
     if ($choice != 'builtin') {
         echo ' style="display: none;"';
     }
     echo ">";
     $this->beforeafter(array('rss_before_related', 'rss_after_related'), __("Before / after related entries:", 'yarpp'), 15, '', __("For example:", 'yarpp') . ' &lt;ol&gt;&lt;/ol&gt;' . __(' or ', 'yarpp') . '&lt;div&gt;&lt;/div&gt;');
     $this->beforeafter(array('rss_before_title', 'rss_after_title'), __("Before / after each related entry:", 'yarpp'), 15, '', __("For example:", 'yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
     $this->checkbox('rss_show_excerpt', __("Show excerpt?", 'yarpp'), 'show_excerpt');
     $this->textbox('rss_excerpt_length', __('Excerpt length (No. of words):', 'yarpp'), 10, 'excerpted');
     $this->beforeafter(array('rss_before_post', 'rss_after_post'), __("Before / after (excerpt):", 'yarpp'), 10, 'excerpted', __("For example:", 'yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
     $this->textbox('rss_no_results', __('Default display if no results:', 'yarpp'), 40, 'sync_rss_no_results');
     echo "</div>";
     $this->displayorder('rss_order', 'rss_displayed');
     $this->checkbox('rss_promote_yarpp', __("Help promote Yet Another Related Posts Plugin?", 'yarpp') . " <span class='yarpp_help' data-help='" . esc_attr(sprintf(__("This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.", 'yarpp'), "<code>" . htmlspecialchars(sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.", 'yarpp'), 'http://www.yarpp.com')) . "</code>")) . "'>&nbsp;</span>", 'rss_displayed');
 }
示例#14
0
 public function exclude($taxonomy, $string)
 {
     global $yarpp;
     echo "<div class='yarpp_form_row yarpp_form_exclude'><div class='yarpp_form_label'>";
     echo $string;
     echo "</div><div class='yarpp_scroll_wrapper'><div class='exclude_terms' id='exclude_{$taxonomy}'>";
     $exclude_tt_ids = wp_parse_id_list(yarpp_get_option('exclude'));
     $exclude_term_ids = $yarpp->admin->get_term_ids_from_tt_ids($taxonomy, $exclude_tt_ids);
     if (count($exclude_term_ids)) {
         $terms = get_terms($taxonomy, array('include' => $exclude_term_ids));
         foreach ($terms as $term) {
             echo "<input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' checked='checked' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html($term->name) . "</label> ";
         }
     }
     echo "</div></div></div>";
 }
function yarpp_related_exist($type, $args)
{
    global $wpdb, $post;
    $options = array('threshold' => 'threshold', 'show_pass_post' => 'show_pass_post', 'past_only' => 'past_only');
    $optvals = array();
    foreach (array_keys($options) as $option) {
        if (isset($args[$option])) {
            $optvals[$option] = stripslashes($args[$option]);
        } else {
            $optvals[$option] = stripslashes(stripslashes(yarpp_get_option($options[$option])));
        }
    }
    extract($optvals);
    $result = $wpdb->get_var(yarpp_sql($type, $args, false, $domain));
    return $result > 0 ? true : false;
}
示例#16
0
 function ajax_display_exclude_terms()
 {
     check_ajax_referer('yarpp_display_exclude_terms');
     if (!isset($_REQUEST['taxonomy'])) {
         return;
     }
     $taxonomy = (string) $_REQUEST['taxonomy'];
     header("HTTP/1.1 200");
     header("Content-Type: text/html; charset=UTF-8");
     $exclude_tt_ids = wp_parse_id_list(yarpp_get_option('exclude'));
     $exclude_term_ids = $this->get_term_ids_from_tt_ids($taxonomy, $exclude_tt_ids);
     //		if ( 'category' == $taxonomy )
     //			$exclude .= ',' . get_option( 'default_category' );
     $terms = get_terms($taxonomy, array('exclude' => $exclude_term_ids, 'hide_empty' => false, 'hierarchical' => false, 'number' => 100, 'offset' => $_REQUEST['offset']));
     if (!count($terms)) {
         echo ':(';
         // no more :(
         exit;
     }
     foreach ($terms as $term) {
         echo "<span><input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html($term->name) . "</label></span> ";
     }
     exit;
 }
示例#17
0
 function upgrade_3_5_2b2()
 {
     // fixing the effects of a previous bug affecting non-MyISAM users
     if (is_null(yarpp_get_option('weight')) || !is_array(yarpp_get_option('weight'))) {
         $weight = $this->default_options['weight'];
         // if we're still not using MyISAM
         if (!yarpp_get_option('myisam_override') && $this->myisam_check() !== true) {
             unset($weight['title']);
             unset($weight['body']);
         }
         yarpp_set_option(array('weight' => $weight));
     }
 }
示例#18
0
            echo '<div class="updated"><p>';
            printf(__("There is a new beta (%s) of Yet Another Related Posts Plugin. You can <a href=\"%s\">download it here</a> at your own risk.", "yarpp"), $yarpp_version_info['beta']['version'], $yarpp_version_info['beta']['url']);
            echo '</p></div>';
        }
    }
}
if (isset($_POST['myisam_override'])) {
    yarpp_set_option('myisam_override', 1);
    echo "<div class='updated'>" . __("The MyISAM check has been overridden. You may now use the \"consider titles\" and \"consider bodies\" relatedness criteria.", 'yarpp') . "</div>";
}
if (!yarpp_get_option('myisam_override')) {
    $yarpp_check_return = $yarpp->myisam_check();
    if ($yarpp_check_return !== true) {
        // if it's not *exactly* true
        echo "<div class='updated'>" . sprintf(__("YARPP's \"consider titles\" and \"consider bodies\" relatedness criteria require your <code>%s</code> table to use the <a href='http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html'>MyISAM storage engine</a>, but the table seems to be using the <code>%s</code> engine. These two options have been disabled.", 'yarpp'), $wpdb->posts, $yarpp_check_return) . "<br />" . sprintf(__("To restore these features, please update your <code>%s</code> table by executing the following SQL directive: <code>ALTER TABLE `%s` ENGINE = MyISAM;</code> . No data will be erased by altering the table's engine, although there are performance implications.", 'yarpp'), $wpdb->posts, $wpdb->posts) . "<br />" . sprintf(__("If, despite this check, you are sure that <code>%s</code> is using the MyISAM engine, press this magic button:", 'yarpp'), $wpdb->posts) . "<br />" . "<form method='post'><input type='submit' class='button' name='myisam_override' value='" . __("Trust me. Let me use MyISAM features.", 'yarpp') . "'></input></form>" . "</div>";
        $weight = yarpp_get_option('weight');
        unset($weight['title']);
        unset($weight['body']);
        yarpp_set_option(array('weight' => $weight));
        $yarpp->myisam = false;
    }
}
if ($yarpp->myisam && !$yarpp->enabled()) {
    echo '<div class="updated">';
    if ($yarpp->activate()) {
        _e('The YARPP database had an error but has been fixed.', 'yarpp');
    } else {
        _e('The YARPP database has an error which could not be fixed.', 'yarpp');
        printf(__('Please try <a href="%s" target="_blank">manual SQL setup</a>.', 'yarpp'), 'http://mitcho.com/code/yarpp/sql.php?prefix=' . urlencode($wpdb->prefix));
    }
    echo '</div>';
<?php

global $wpdb, $wp_version, $yarpp;
/* Enforce YARPP setup: */
$yarpp->enforce();
if (!$yarpp->enabled() && !$yarpp->activate()) {
    echo '<div class="updated">' . __('The YARPP database has an error which could not be fixed.', 'yarpp') . '</div>';
}
/* Check to see that templates are in the right place */
if (!$yarpp->diagnostic_custom_templates()) {
    $template_option = yarpp_get_option('template');
    if ($template_option !== false && $template_option !== 'thumbnails') {
        yarpp_set_option('template', false);
    }
    $template_option = yarpp_get_option('rss_template');
    if ($template_option !== false && $template_option !== 'thumbnails') {
        yarpp_set_option('rss_template', false);
    }
}
/**
 * @since 3.3  Move version checking here, in PHP.
 */
if (current_user_can('update_plugins')) {
    $yarpp_version_info = $yarpp->version_info();
    /*
     * These strings are not localizable, as long as the plugin data on wordpress.org cannot be.
     */
    $slug = 'yet-another-related-posts-plugin';
    $plugin_name = 'Yet Another Related Posts Plugin';
    $file = basename(YARPP_DIR) . '/yarpp.php';
    if ($yarpp_version_info['result'] === 'new') {
    function display()
    {
        global $yarpp;
        ?>
		<table class="form-table" style="margin-top: 0; clear:none;"><tbody>
<?php 
        $this->checkbox('rss_display', __("Display related posts in feeds?", 'yarpp') . " <a href='#' class='info'>" . __('more&gt;', 'yarpp') . "<span>" . __("This option displays related posts at the end of each item in your RSS and Atom feeds. No template changes are needed.", 'yarpp') . "</span></a>", "<tr valign='top'><th colspan='2' style='width:100%'>", ' class="rss_display"', '<td class="rss_displayed" rowspan="4" style="border-left:8px transparent solid;"><b>' . __("RSS display code example", 'yarpp') . '</b><br /><small>' . __("(Update options to reload.)", 'yarpp') . '</small><br/>' . "<div id='display_demo_rss' style='overflow:auto;width:350px;max-height:500px;'></div></td>");
        $this->checkbox('rss_excerpt_display', __("Display related posts in the descriptions?", 'yarpp') . " <a href='#' class='info'>" . __('more&gt;', 'yarpp') . "<span>" . __("This option displays the related posts in the RSS description fields, not just the content. If your feeds are set up to only display excerpts, however, only the description field is used, so this option is required for any display at all.", 'yarpp') . "</span></a>", "<tr class='rss_displayed' valign='top'>\n\t\t\t<th class='th-full' colspan='2' scope='row'>");
        $this->textbox('rss_limit', __('Maximum number of related posts:', 'yarpp'), 2, "<tr valign='top' class='rss_displayed'>\n\t\t\t\t<th scope='row'>");
        $this->checkbox('rss_use_template', __("Display using a custom template file", 'yarpp') . " <!--<span style='color:red;'>" . __('NEW!', 'yarpp') . "</span>--> <a href='#' class='info'>" . __('more&gt;', 'yarpp') . "<span>" . __("This advanced option gives you full power to customize how your related posts are displayed. Templates (stored in your theme folder) are written in PHP.", 'yarpp') . "</span></a>", "<tr valign='top' class='rss_displayed'><th colspan='2'>", ' class="rss_template"' . (!(is_array($yarpp->templates) && count($yarpp->templates)) ? ' disabled="disabled"' : ''));
        ?>
	</tbody></table>
	<table class="form-table rss_displayed" style="clear:none;">
		<tbody>
			<tr valign='top' class='rss_templated'>
				<th><?php 
        _e("Template file:", 'yarpp');
        ?>
</th>
				<td>
					<select name="rss_template_file" id="rss_template_file">
						<?php 
        foreach (glob(STYLESHEETPATH . '/yarpp-template-*.php') as $template) {
            ?>
						<option value='<?php 
            echo htmlspecialchars(basename($template));
            ?>
'<?php 
            echo basename($template) == yarpp_get_option('rss_template_file') ? " selected='selected'" : '';
            ?>
><?php 
            echo htmlspecialchars(basename($template));
            ?>
</option>
						<?php 
        }
        ?>
					</select>
				</td>
			</tr>

	<?php 
        $this->beforeafter(array('rss_before_related', 'rss_after_related'), __("Before / after related entries:", 'yarpp'), 15, "<tr class='rss_not_templated' valign='top'>\r\t\t\t\t<th>", __("For example:", 'yarpp') . ' &lt;ol&gt;&lt;/ol&gt;' . __(' or ', 'yarpp') . '&lt;div&gt;&lt;/div&gt;');
        $this->beforeafter(array('rss_before_title', 'rss_after_title'), __("Before / after each related entry:", 'yarpp'), 15, "<tr class='rss_not_templated' valign='top'>\r\t\t\t\t<th>", __("For example:", 'yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
        $this->checkbox('rss_show_excerpt', __("Show excerpt?", 'yarpp'), "<tr class='rss_not_templated' valign='top'><th colspan='2'>", ' class="rss_show_excerpt"');
        $this->textbox('rss_excerpt_length', __('Excerpt length (No. of words):', 'yarpp'), 10, "<tr class='rss_excerpted' valign='top'>\r\t\t\t\t<th>");
        $this->beforeafter(array('rss_before_post', 'rss_after_post'), __("Before / after (excerpt):", 'yarpp'), 10, "<tr class='rss_excerpted' valign='top'>\r\t\t\t\t<th>", __("For example:", 'yarpp') . ' &lt;li&gt;&lt;/li&gt;' . __(' or ', 'yarpp') . '&lt;dl&gt;&lt;/dl&gt;');
        $this->displayorder('rss_order', 'rss_displayed');
        $this->textbox('rss_no_results', __('Default display if no results:', 'yarpp'), '40', "<tr valign='top' class='rss_not_templated'>\n\t\t\t<th scope='row'>");
        ?>
	<?php 
        $this->checkbox('rss_promote_yarpp', __("Help promote Yet Another Related Posts Plugin?", 'yarpp') . " <a href='#' class='info'>" . __('more&gt;', 'yarpp') . "<span>" . sprintf(__("This option will add the code %s. Try turning it on, updating your options, and see the code in the code example to the right. These links and donations are greatly appreciated.", 'yarpp'), "<code>" . htmlspecialchars(sprintf(__("Related posts brought to you by <a href='%s'>Yet Another Related Posts Plugin</a>.", 'yarpp'), 'http://yarpp.org')) . "</code>") . "</span></a>", "<tr valign='top' class='rss_displayed'>\n\t\t\t<th class='th-full' colspan='2' scope='row'>");
        ?>
		</tbody></table>
<?php 
    }
示例#21
0
function yarpp_cache_enforce($type = array('post'), $reference_ID, $force = false)
{
    global $wpdb, $yarpp_debug;
    if ($reference_ID === '' || $reference_ID === false) {
        return false;
    }
    if (!$force) {
        if ($wpdb->get_var("select count(*) as count from {$wpdb->prefix}yarpp_related_cache where reference_ID = {$reference_ID}")) {
            // 3.1.3: removed the cache timeout
            // and date > date_sub(now(),interval 600 minute)
            if ($yarpp_debug) {
                echo "<!--YARPP is using the cache right now.-->";
            }
            return false;
        }
    }
    yarpp_cache_keywords($reference_ID);
    // clear out the cruft
    yarpp_cache_clear(array($reference_ID));
    // let's update the related posts
    $wpdb->query("insert into {$wpdb->prefix}yarpp_related_cache (reference_ID,ID,score) " . yarpp_sql($type, array(), true, $reference_ID) . " on duplicate key update date = now()");
    $affected = $wpdb->rows_affected;
    if ($affected and $yarpp_debug) {
        echo "<!--YARPP just set the cache for post {$reference_ID}-->";
    }
    // if changes were made, let's find out which ones are new. We'll want to clear their caches
    // so that they will be rebuilt when they're hit next.
    if ($affected && !yarpp_get_option('past_only')) {
        $new_relations = $wpdb->get_col("select ID from {$wpdb->prefix}yarpp_related_cache where reference_ID = {$reference_ID} and ID != 0");
        yarpp_cache_clear($new_relations);
    }
    if (!$affected) {
        $wpdb->query("insert into {$wpdb->prefix}yarpp_related_cache (reference_ID,ID,score) values ({$reference_ID},0,0) on duplicate key update date = now()");
        if (!$wpdb->rows_affected) {
            return false;
        }
    }
    return true;
}
function yarpp_pingback_maybe_block_pingback($url, $post, $leavename) {
	global $yarpp;
	if ( is_feed() ||
		!is_object($yarpp) ||
		!yarpp_get_option('experiment_pingback') ||
		!$yarpp->cache->is_yarpp_time() )
		return $url;

	$home = parse_url( home_url() );
	$replacepart = $home['scheme'] . '://' . $home['host'];
	if ( isset($home['port']) )
		$replacepart .= ':' . $home['port'];
	$url = preg_replace('!^' . preg_quote($replacepart) . '!', '', $url);
	
	return $url;
}
 function display()
 {
     global $yarpp;
     // TODO: fix this text and i18nize it
     echo "<input type='checkbox' id='yarpp-optin' name='optin' value='true'";
     checked(yarpp_get_option('optin') == 1);
     echo " /> ";
     echo '<label for="yarpp-optin">' . __('Send settings and usage data back to YARPP', 'yarpp') . '</label>';
     echo '<p style="overflow:auto;">';
     echo __('This is entirely optional, but will help improve future versions of YARPP.', 'yarpp');
     echo ' <input type="button" value="' . esc_attr(__('Learn More', 'yarpp')) . '" id="yarpp-optin-learnmore" class="button button-small"/></p>';
 }
示例#24
0
function yarpp_related_exist($type, $args, $reference_ID = false)
{
    global $post, $yarpp_cache;
    yarpp_upgrade_check();
    if (is_object($post) and !$reference_ID) {
        $reference_ID = $post->ID;
    }
    if ($yarpp_cache->yarpp_time) {
        // if we're already in a YARPP loop, stop now.
        return false;
    }
    if (yarpp_get_option('cross_relate')) {
        $type = array('post', 'page');
    }
    yarpp_cache_enforce($reference_ID);
    $yarpp_cache->begin_yarpp_time($reference_ID);
    // get ready for YARPP TIME!
    $related_query = new WP_Query();
    // Note: why is this 10000? Should we just make it 1?
    $related_query->query(array('p' => $reference_ID, 'showposts' => 10000, 'post_type' => $type));
    $return = $related_query->have_posts();
    unset($related_query);
    $yarpp_cache->end_yarpp_time();
    // YARPP time is over. :(
    return $return;
}
示例#25
0
//-->
</script>

<div class="wrap">
		<h2>
			<?php 
_e('Yet Another Related Posts Plugin Options', 'yarpp');
?>
 <small><?php 
echo yarpp_get_option('version');
?>
</small>
		</h2>

	<?php 
echo "<div id='yarpp-version' style='display:none;'>" . yarpp_get_option('version') . "</div>";
?>

	<form method="post">

  <div id="yarpp_author_text">
	<small><?php 
printf(__('by <a href="%s" target="_blank">mitcho (Michael 芳貴 Erlewine)</a>', 'yarpp'), 'http://yarpp.org/');
?>
</small>
  </div>

<!--	<div style='border:1px solid #ddd;padding:8px;'>-->

<?php 
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
示例#26
0
function yarpp_rss_excerpt($content)
{
    global $wpdb, $post;
    if (yarpp_get_option('rss_excerpt_display') && yarpp_get_option('rss_display')) {
        return $content . clean_pre(yarpp_related(array('post'), array(), false, false, 'rss'));
    } else {
        return $content;
    }
}
示例#27
0
<?php

/*
YARPP's built-in "template"

This "template" is used when you choose not to use a template.

If you want to create a new template, look at templates/template-example.php as an example.
*/
$options = array('before_title' => "{$domainprefix}before_title", 'after_title' => "{$domainprefix}after_title", 'show_excerpt' => "{$domainprefix}show_excerpt", 'excerpt_length' => "{$domainprefix}excerpt_length", 'before_post' => "{$domainprefix}before_post", 'after_post' => "{$domainprefix}after_post", 'before_related' => "{$domainprefix}before_related", 'after_related' => "{$domainprefix}after_related", 'no_results' => "{$domainprefix}no_results");
$optvals = array();
foreach (array_keys($options) as $option) {
    if (isset($args[$option])) {
        $optvals[$option] = stripslashes($args[$option]);
    } else {
        $optvals[$option] = stripslashes(stripslashes(yarpp_get_option($options[$option])));
    }
}
extract($optvals);
if ($related_query->have_posts()) {
    while ($related_query->have_posts()) {
        $related_query->the_post();
        $output .= "{$before_title}<a href='" . get_permalink() . "' rel='bookmark' title='Permanent Link: " . preg_replace('/\\s*<br[ \\/]*>\\s*/i', ' ', get_the_title()) . "'>" . get_the_title() . "";
        if ($userdata->user_level >= 8 and $domain != 'rss') {
            $output .= ' <abbr title="' . sprintf(__('%f is the YARPP match score between the current entry and this related entry. You are seeing this value because you are logged in to WordPress as an administrator. It is not shown to regular visitors.', 'yarpp'), round(get_the_score(), 3)) . '">(' . round(get_the_score(), 3) . ')</abbr>';
        }
        $output .= '</a>';
        if ($show_excerpt) {
            $output .= $before_post . yarpp_excerpt(get_the_excerpt(), $excerpt_length) . $after_post;
        }
        $output .= $after_title . "\n";
示例#28
0
function yarpp_options_select($option, $desc, $type = 'word', $tr = "<tr valign='top'>\n\t\t\t<th scope='row'>", $inputplus = '')
{
    echo "\t\t{$tr}{$desc}</th>\n\t\t\t<td>\n\t\t\t<input {$inputplus} type='radio' name='{$option}' value='1'" . (yarpp_get_option($option) == 1 ? ' checked="checked"' : '') . "  /> \n\t\t\t" . __("do not consider", 'yarpp') . "\n\t\t\t<input {$inputplus} type='radio' name='{$option}' value='2'" . (yarpp_get_option($option) == 2 ? ' checked="checked"' : '') . "  />\n\t\t\t" . __("consider", 'yarpp') . "\n\t\t\t<input {$inputplus} type='radio' name='{$option}' value='3'" . (yarpp_get_option($option) == 3 ? ' checked="checked"' : '') . "  />\n\t\t\t" . sprintf(__("require at least one %s in common", 'yarpp'), __($type, 'yarpp')) . "\n\t\t\t<input {$inputplus} type='radio' name='{$option}' value='4'" . (yarpp_get_option($option) == 4 ? ' checked="checked"' : '') . "  />\n\t\t\t" . sprintf(__("require more than one %s in common", 'yarpp'), __($type, 'yarpp')) . "\n\t\t\t</td>\n\t\t</tr>";
}
示例#29
0
        $details_url = self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . $slug . '&TB_iframe=true&width=600&height=800');
        printf(__('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">update automatically</a>.'), $plugin_name, esc_url($details_url), esc_attr($plugin_name), $yarpp_version_info['current']['version'], wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file));
        echo '</p></div>';
    } else {
        if ($yarpp_version_info['result'] == 'newbeta') {
            echo '<div class="updated"><p>';
            printf(__("There is a new beta (%s) of Yet Another Related Posts Plugin. You can <a href=\"%s\">download it here</a> at your own risk.", "yarpp"), $yarpp_version_info['beta']['version'], $yarpp_version_info['beta']['url']);
            echo '</p></div>';
        }
    }
}
if (isset($_POST['myisam_override'])) {
    yarpp_set_option('myisam_override', 1);
    echo "<div class='updated'>" . __("The MyISAM check has been overridden. You may now use the \"consider titles\" and \"consider bodies\" relatedness criteria.", 'yarpp') . "</div>";
}
if (!yarpp_get_option('myisam_override')) {
    $yarpp_check_return = $yarpp->myisam_check();
    if ($yarpp_check_return !== true) {
        // if it's not *exactly* true
        echo "<div class='updated'>" . sprintf(__("YARPP's \"consider titles\" and \"consider bodies\" relatedness criteria require your <code>%s</code> table to use the <a href='http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html'>MyISAM storage engine</a>, but the table seems to be using the <code>%s</code> engine. These two options have been disabled.", 'yarpp'), $wpdb->posts, $yarpp_check_return) . "<br />" . sprintf(__("To restore these features, please update your <code>%s</code> table by executing the following SQL directive: <code>ALTER TABLE `%s` ENGINE = MyISAM;</code> . No data will be erased by altering the table's engine, although there are performance implications.", 'yarpp'), $wpdb->posts, $wpdb->posts) . "<br />" . sprintf(__("If, despite this check, you are sure that <code>%s</code> is using the MyISAM engine, press this magic button:", 'yarpp'), $wpdb->posts) . "<br />" . "<form method='post'><input type='submit' class='button' name='myisam_override' value='" . __("Trust me. Let me use MyISAM features.", 'yarpp') . "'></input></form>" . "</div>";
        $weight = yarpp_set_option('weight');
        unset($weight['title']);
        unset($weight['body']);
        yarpp_set_option(array('weight' => $weight));
        $yarpp->myisam = false;
    }
}
if ($yarpp->myisam && !$yarpp->enabled()) {
    echo '<div class="updated">';
    if ($yarpp->activate()) {
        _e('The YARPP database had an error but has been fixed.', 'yarpp');
示例#30
0
            echo '<div class="updated"><p>';
            printf(__("There is a new beta (%s) of Yet Another Related Posts Plugin. You can <a href=\"%s\">download it here</a> at your own risk.", "yarpp"), $yarpp_version_info['beta']['version'], $yarpp_version_info['beta']['url']);
            echo '</p></div>';
        }
    }
}
if (isset($_POST['myisam_override'])) {
    yarpp_set_option('myisam_override', 1);
    echo "<div class='updated'>" . __("The MyISAM check has been overridden. You may now use the \"consider titles\" and \"consider bodies\" relatedness criteria.", 'yarpp') . "</div>";
    $yarpp->enable_fulltext(true);
}
$table_type = $yarpp->diagnostic_myisam_posts();
if ($table_type !== true) {
    $yarpp->disable_fulltext();
}
if (!yarpp_get_option('myisam_override') && $yarpp->diagnostic_fulltext_disabled()) {
    echo "<div class='updated'>" . sprintf(__("YARPP's \"consider titles\" and \"consider bodies\" relatedness criteria require your <code>%s</code> table to use the <a href='http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html'>MyISAM storage engine</a>, but the table seems to be using the <code>%s</code> engine. These two options have been disabled.", 'yarpp'), $wpdb->posts, $table_type) . "<br />" . sprintf(__("To restore these features, please update your <code>%s</code> table by executing the following SQL directive: <code>ALTER TABLE `%s` ENGINE = MyISAM;</code> . No data will be erased by altering the table's engine, although there are performance implications.", 'yarpp'), $wpdb->posts, $wpdb->posts) . "<br />" . sprintf(__("If, despite this check, you are sure that <code>%s</code> is using the MyISAM engine, press this magic button:", 'yarpp'), $wpdb->posts) . "<br />" . "<form method='post'><input type='submit' class='button' name='myisam_override' value='" . __("Trust me. Let me use MyISAM features.", 'yarpp') . "'></input></form>" . "</div>";
}
if (!$yarpp->enabled() && !$yarpp->activate()) {
    echo '<div class="updated">';
    _e('The YARPP database has an error which could not be fixed.', 'yarpp');
    echo ' ';
    printf(__('Please try <a href="%s" target="_blank">manual SQL setup</a>.', 'yarpp'), 'http://mitcho.com/code/yarpp/sql.php?prefix=' . urlencode($wpdb->prefix));
    echo '</div>';
}
if (isset($_POST['update_yarpp'])) {
    $new_options = array();
    foreach ($yarpp->default_options as $option => $default) {
        if (is_bool($default)) {
            $new_options[$option] = isset($_POST[$option]);
        }