$new_options['require_tax'][$tax] = 2;
            }
        }
    }
    if (isset($_POST['auto_display_post_types'])) {
        $new_options['auto_display_post_types'] = array_keys($_POST['auto_display_post_types']);
    } else {
        $new_options['auto_display_post_types'] = array();
    }
    $new_options['recent'] = isset($_POST['recent_only']) ? $_POST['recent_number'] . ' ' . $_POST['recent_units'] : false;
    if (isset($_POST['exclude'])) {
        $new_options['exclude'] = implode(',', array_keys($_POST['exclude']));
    } else {
        $new_options['exclude'] = '';
    }
    $new_options['template'] = $_POST['use_template'] == 'custom' ? $_POST['template_file'] : ($_POST['use_template'] == 'thumbnails' ? 'thumbnails' : false);
    $new_options['rss_template'] = $_POST['rss_use_template'] == 'custom' ? $_POST['rss_template_file'] : ($_POST['rss_use_template'] == 'thumbnails' ? 'thumbnails' : false);
    $new_options = apply_filters('yarpp_settings_save', $new_options);
    yarpp_set_option($new_options);
    echo '<div class="updated fade"><p>' . __('Options saved!', 'yarpp') . '</p></div>';
}
wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
wp_nonce_field('yarpp_display_demo', 'yarpp_display_demo-nonce', false);
wp_nonce_field('yarpp_display_exclude_terms', 'yarpp_display_exclude_terms-nonce', false);
wp_nonce_field('yarpp_optin_data', 'yarpp_optin_data-nonce', false);
wp_nonce_field('yarpp_set_display_code', 'yarpp_set_display_code-nonce', false);
if (!count($yarpp->admin->get_templates()) && $yarpp->admin->can_copy_templates()) {
    wp_nonce_field('yarpp_copy_templates', 'yarpp_copy_templates-nonce', false);
}
include YARPP_DIR . '/includes/phtmls/yarpp_options.phtml';
function yarpp_experiment_throttle( $cache_status, $ID ) {
	// only mess with things which are not yet cached:
	if ( YARPP_NOT_CACHED != $cache_status )
		return $cache_status;
		
	// Don't throttle computations triggered via ajax.
	if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
		return $cache_status;

	// $raw_throttle must be non-negative. Default value is 0.
	$raw_throttle = (int) yarpp_get_option( 'experiment_throttle' );
	$throttle = max( 0, $raw_throttle );
	
	if ( $throttle !== $raw_throttle )
		yarpp_set_option( 'experiment_throttle', $throttle );
	
	// so, 1 / 10^{throttle/2} of the time, we return YARPP_NOT_CACHED.
	// otherwise, we send the kill signal, YARPP_DONT_RUN, and echo a comment.
	if ( 1 == mt_rand( 1, pow(10, $throttle / 4) ) )
		return YARPP_NOT_CACHED;
	
	if ( headers_sent() )
		echo "<!--You got throttled!-->";
	return YARPP_DONT_RUN;
}
Example #3
0
    }
    if (isset($_POST['discats'])) {
        yarpp_set_option('discats', implode(',', array_keys($_POST['discats'])));
        // discats is different
    } else {
        yarpp_set_option('discats', '');
    }
    if (isset($_POST['distags'])) {
        yarpp_set_option('distags', implode(',', array_keys($_POST['distags'])));
        // distags is also different
    } else {
        yarpp_set_option('distags', '');
    }
    //update_option('yarpp_distags',implode(',',array_map('yarpp_unmapthetag',preg_split('!\s*[;,]\s*!',strtolower($_POST['distags']))))); // distags is even more different
    foreach (array_keys($yarpp_binary_options) as $option) {
        isset($_POST[$option]) ? yarpp_set_option($option, 1) : yarpp_set_option($option, 0);
    }
    echo '<div class="updated fade"><p>' . __('Options saved!', 'yarpp') . '</p></div>';
}
//compute $tagmap
$tagmap = array();
foreach ($wpdb->get_results("select {$wpdb->terms}.term_id, name from {$wpdb->terms} natural join {$wpdb->term_taxonomy} where {$wpdb->term_taxonomy}.taxonomy = 'category'") as $tag) {
    $tagmap[$tag->term_id] = strtolower($tag->name);
}
function yarpp_mapthetag($id)
{
    global $tagmap;
    return $tagmap[$id];
}
function yarpp_unmapthetag($name)
{
    }
    if (isset($_POST['discats'])) {
        yarpp_set_option('discats', implode(',', array_keys($_POST['discats'])));
        // discats is different
    } else {
        yarpp_set_option('discats', '');
    }
    if (isset($_POST['distags'])) {
        yarpp_set_option('distags', implode(',', array_keys($_POST['distags'])));
        // distags is also different
    } else {
        yarpp_set_option('distags', '');
    }
    //update_option('yarpp_distags',implode(',',array_map('yarpp_unmapthetag',preg_split('!\s*[;,]\s*!',strtolower($_POST['distags']))))); // distags is even more different
    foreach (array_keys($yarpp_binary_options) as $option) {
        isset($_POST[$option]) ? yarpp_set_option($option, true) : yarpp_set_option($option, false);
    }
    echo '<div id="message" class="updated fade" style="background-color: rgb(207, 235, 247);"><p>' . __('Options saved!', 'yarpp') . '</p></div>';
}
function checkbox($option, $desc, $tr = "<tr valign='top'>\n\t\t\t<th class='th-full' colspan='2' scope='row'>", $inputplus = '', $thplus = '')
{
    echo "\t\t\t{$tr}<input {$inputplus} type='checkbox' name='{$option}' value='true'" . (yarpp_get_option($option) ? ' checked="checked"' : '') . "  /> {$desc}</th>{$thplus}\n\t\t</tr>";
}
function textbox($option, $desc, $size = 2, $tr = "<tr valign='top'>\n\t\t\t<th scope='row'>")
{
    $value = yarpp_get_option($option, true);
    echo "\t\t\t{$tr}{$desc}</th>\n\t\t\t<td><input name='{$option}' type='text' id='{$option}' value='{$value}' size='{$size}' /></td>\n\t\t</tr>";
}
function importance($option, $desc, $type = 'word', $tr = "<tr valign='top'>\n\t\t\t<th scope='row'>", $inputplus = '')
{
    $value = yarpp_get_option($option);
Example #5
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));
     }
 }
<?php

if (isset($_POST['myisam_override'])) {
    yarpp_set_option('myisam_override', true);
    $enabled = $yarpp->enable_fulltext();
    if ($enabled) {
        update_option('yarpp_fulltext_disabled', 0);
        echo '<div class="updated" style="padding:5px">' . __('The MyISAM check has been overridden. You may now use the "consider titles" and "consider bodies" relatedness criteria.', 'yarpp') . "</div>";
    } else {
        yarpp_set_option('myisam_override', 0);
        echo '<div class="updated" style="padding:5px">' . '<span style="color:red;font-weight:bold">Fulltext Index creation did not work!</span><br/>' . 'Trying to force fulltext indexing on your table resulted in an error. Your posts table does not have fulltext indexing capabilities.<br/>' . 'The "consider titles" and "consider bodies" relatedness criteria will remain disabled.' . '</div>';
    }
}
$table_type = $yarpp->diagnostic_myisam_posts();
if ((bool) $table_type !== true) {
    $yarpp->disable_fulltext();
}
if (!(bool) yarpp_get_option('myisam_override') && (bool) $yarpp->diagnostic_fulltext_disabled()) {
    echo "<div class='updated' style='padding:15px'>" . '<p>' . '<strong>"Consider Titles"</strong> and <strong>"Consider Bodies"</strong> are currently disabled. ' . 'As a result, "Pages" may not display in the "Related Posts" sections.' . '&nbsp;&nbsp;<a href="#" id="yarpp_fulltext_expand">Show Details [+]</a>' . '</p>' . '<div id="yarpp_fulltext_details" class="hidden">' . '<p>' . sprintf('YARPP&#39;s "consider titles" and "consider bodies" relatedness criteria require your <code>%s</code> ' . 'table to use the <code>MyISAM</code> engine' . 'fulltext indexing feature. Unfortunately your table seems to be using the <code>%s</code> engine. ' . 'Because fulltext indexing is not supported by your current table engine, these two options have been disabled.', $wpdb->posts, $table_type) . '</p>' . '<p>' . sprintf('To restore these features, please do the following:<br/>' . '<ol>' . '<li>' . 'Convert your <code>%s</code> table to <code>MyISAM</code> engine by executing the ' . 'following SQL code on your MySQL client or terminal:<br/>' . '<code style="display:inline-block;margin:1.5em 1em">ALTER TABLE `%s` ENGINE = MyISAM;</code>' . '</li>', $wpdb->posts, $wpdb->posts) . sprintf('<li>' . 'Once your <code>%s</code> table has been successfully converted to the <code>MyISAM</code> engine, ' . 'click the button below to create the fulltext indices.<br/>', $wpdb->posts) . '<form method="post" style="display:inline-block;margin:1.5em 1em">' . "<input type='submit' class='button' name='myisam_override' value='Create fulltext indexes'/>" . "</form>" . '</li>' . '</ol>' . "</p>" . '<p>' . 'Note that, although no data should be lost by altering the table&#39;s engine, it is always recommended to perform a ' . 'full backup of the data before attempting to perform changes to your database.<br/>' . 'See MySQL <a href="http://dev.mysql.com/doc/refman/5.0/en/storage-engines.html" target="_blank">storage engines</a> ' . 'documentation for details on MySQL engines.' . '</p>' . '</div>' . "</div>";
}