Ejemplo n.º 1
0
function wp_auto_spinner_spin_function()
{
    $autospin = get_option('wp_auto_spin', array());
    $lastrun = get_option('wp_auto_spinner_last_run', 1392146043);
    $timenow = time('now');
    $timediff = $timenow - $lastrun;
    if ($timediff < 60) {
        return;
    }
    update_option('wp_auto_spinner_last_run', $timenow);
    if (in_array('OPT_AUTO_SPIN_ACTIVE', $autospin)) {
        // log call
        //wp_auto_spinner_log_new ( 'cron call', 'we should now process one waiting to be spinned article' );
        // get one post deserve spin
        // get execluded cateogries array
        $execl = get_option('wp_auto_spin_execl', array());
        $post_status = array('publish', 'draft');
        if (in_array('OPT_AUTO_SPIN_SCHEDULED', $autospin)) {
            $post_status = array('publish', 'future');
        }
        // The Query
        $the_query = new WP_Query(array('category__not_in' => $execl, 'post_status' => $post_status, 'posts_per_page' => 1, 'ignore_sticky_posts' => true, 'post_type' => 'any', 'meta_query' => array(array('key' => 'wp_auto_spinner_scheduled', 'compare' => 'EXISTS'), array('key' => 'spinned_cnt', 'compare' => 'NOT EXISTS'))));
        // The Loop
        if ($the_query->have_posts()) {
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $newid = get_the_id();
                if (trim($newid) == '') {
                    return;
                }
                wp_auto_spinner_log_new('Cron Call >> top post  ', get_the_id());
                $post_id = get_the_id();
                wp_auto_spinner_post_spin($post_id);
                break;
            }
        } else {
            // no posts found
            //wp_auto_spinner_log_new ( 'Cron >> Cancel', 'No waiting to be spinned posts' );
        }
        /* Restore original Post Data */
        wp_reset_postdata();
    } else {
    }
    // wp_auto_spinner_the_content_filter()
}
Ejemplo n.º 2
0
function wp_automatic_unspin_callback()
{
    //options
    $autospin = get_option('wp_auto_spin', array());
    $itms = $_POST['itms'];
    $itms_arr = explode(',', $itms);
    $itms_arr = array_filter($itms_arr);
    foreach ($itms_arr as $post_id) {
        echo $post_id;
        //delete the schedule
        delete_post_meta($post_id, 'wp_auto_spinner_scheduled');
        //set checked flag so the plugin don't spin it
        update_post_meta($post_id, 'wp_auto_spinner_checked', 'yes');
        //set content to original content and set title to original title
        $original_cnt = get_post_meta($post_id, 'original_cnt', 1);
        if (trim($original_cnt) != '') {
            //found original content let's set it
            $original_title = get_post_meta($post_id, 'original_title', 1);
            $my_post = array();
            $my_post['ID'] = $post_id;
            $my_post['post_content'] = $original_cnt;
            $my_post['post_title'] = $original_title;
            //check if we should updat the slug .
            if (in_array('OPT_AUTO_SPIN_SLUG', $autospin)) {
                $my_post['post_name'] = '';
            }
            wp_auto_spinner_log_new('New Post >> Un-Spin', 'Post with id {' . $post_id . '} Restored .');
            // Update the post into the database
            wp_update_post($my_post);
            //clean fields
            delete_post_meta($post_id, 'original_ttl');
            delete_post_meta($post_id, 'original_cnt');
            delete_post_meta($post_id, 'spinned_ttl');
            delete_post_meta($post_id, 'spinned_cnt');
            delete_post_meta($post_id, 'spintaxed_cnt');
            delete_post_meta($post_id, 'spintaxed_cnt2');
            delete_post_meta($post_id, 'spintaxed_ttl');
        }
    }
    die;
}
Ejemplo n.º 3
0
 /**
  * function spin rewriter : using the spin rewriter api 
  */
 function spin_rewriter()
 {
     //chek if username and passowrd found
     $wp_auto_spinner_email = get_option('wp_auto_spinner_email', '');
     $wp_auto_spinner_password = get_option('wp_auto_spinner_password', '');
     $opt = get_option('wp_auto_spin', array());
     $wp_auto_spinner_quality = get_option('wp_auto_spinner_quality', 'medium');
     $wp_auto_spinner_execlude = get_option('wp_auto_spinner_execlude', '');
     //execlude title words
     if (in_array('OPT_AUTO_SPIN_TITLE_EX', $opt)) {
         $extitle = explode(' ', $this->title);
         $wp_auto_spinner_execlude = explode("\n", $wp_auto_spinner_execlude);
         $wp_auto_spinner_execlude = array_filter(array_merge($wp_auto_spinner_execlude, $extitle));
         $wp_auto_spinner_execlude = implode(",", $wp_auto_spinner_execlude);
     } else {
         $wp_auto_spinner_execlude = array_filter(explode("\n", $wp_auto_spinner_execlude));
         $wp_auto_spinner_execlude = implode(",", $wp_auto_spinner_execlude);
     }
     wp_auto_spinner_log_new('spinning', 'Trying to use spinrewriter api');
     if (trim($wp_auto_spinner_email) != '' && trim($wp_auto_spinner_password) != '') {
         //running a quote call
         require_once "SpinRewriterAPI.php";
         // Authenticate yourself.
         $spinrewriter_api = new SpinRewriterAPI($wp_auto_spinner_email, $wp_auto_spinner_password);
         // Make the actual API request and save response as a native PHP array.
         $api_response = $spinrewriter_api->getQuota();
         //check if response is a valid response i.e is array
         if (isset($api_response['status'])) {
             //check if reponse status is OK or Error
             if ($api_response['status'] == 'OK') {
                 //let's check if quote available
                 if ($api_response['api_requests_available'] > 0) {
                     wp_auto_spinner_log_new('SpinRewriter', 'Quota ' . $api_response['api_requests_available']);
                     $protected_terms = "John, Douglas Adams, then";
                     $spinrewriter_api->setProtectedTerms($wp_auto_spinner_execlude);
                     // (optional) Set whether the One-Click Rewrite process automatically protects Capitalized Words outside the article's title.
                     if (in_array('OPT_AUTO_SPIN_AutoProtectedTerms', $opt)) {
                         $spinrewriter_api->setAutoProtectedTerms(true);
                     } else {
                         $spinrewriter_api->setAutoProtectedTerms(false);
                     }
                     // (optional) Set the confidence level of the One-Click Rewrite process.
                     $spinrewriter_api->setConfidenceLevel($wp_auto_spinner_quality);
                     // (optional) Set whether the One-Click Rewrite process uses nested spinning syntax (multi-level spinning) or not.
                     if (in_array('OPT_AUTO_SPIN_NestedSpintax', $opt)) {
                         $spinrewriter_api->setNestedSpintax(true);
                     } else {
                         $spinrewriter_api->setNestedSpintax(false);
                     }
                     // (optional) Set whether Spin Rewriter rewrites complete sentences on its own.
                     if (in_array('OPT_AUTO_SPIN_AutoSentences', $opt)) {
                         $spinrewriter_api->setAutoSentences(true);
                     } else {
                         $spinrewriter_api->setAutoSentences(false);
                     }
                     // (optional) Set whether Spin Rewriter rewrites entire paragraphs on its own.
                     if (in_array('OPT_AUTO_SPIN_AutoParagraphs', $opt)) {
                         $spinrewriter_api->setAutoParagraphs(true);
                     } else {
                         $spinrewriter_api->setAutoParagraphs(false);
                     }
                     // (optional) Set whether Spin Rewriter writes additional paragraphs on its own.
                     if (in_array('OPT_AUTO_SPIN_AutoNewParagraphs', $opt)) {
                         $spinrewriter_api->setAutoNewParagraphs(true);
                     } else {
                         $spinrewriter_api->setAutoNewParagraphs(false);
                     }
                     // (optional) Set whether Spin Rewriter changes the entire structure of phrases and sentences.
                     if (in_array('OPT_AUTO_SPIN_AutoSentenceTrees', $opt)) {
                         $spinrewriter_api->setAutoSentenceTrees(true);
                     } else {
                         $spinrewriter_api->setAutoSentenceTrees(false);
                     }
                     // (optional) Set the desired spintax format to be used with the returned spun text.
                     $spinrewriter_api->setSpintaxFormat("{|}");
                     // Make the actual API request and save response as a native PHP array.
                     $text = "John will book a room. Then he will read a book by Douglas Adams.";
                     $article = stripslashes($this->title) . ' 911911 ' . stripslashes($this->post);
                     $api_response2 = $spinrewriter_api->getTextWithSpintax($article);
                     //validate reply with OK
                     if (isset($api_response2['status'])) {
                         //status = OK
                         if ($api_response2['status'] == 'OK') {
                             wp_auto_spinner_log_new('SpinRewriter', 'status is ok i.e valid content returned');
                             $article = $api_response2['response'];
                             $this->article = $article;
                             //now article contains the synonyms on the form {test|test2}
                             return $this->update_post();
                         } else {
                             wp_auto_spinner_log_new('SpinRewriter says', $api_response2['response']);
                         }
                     } else {
                         wp_auto_spinner_log_new('SpinRewriter', 'We could not get valid response ');
                     }
                 } else {
                     wp_auto_spinner_log_new('SpinRewriter says', $api_response['response']);
                 }
             } else {
                 wp_auto_spinner_log_new('SpinRewriter says', $api_response['response']);
             }
         } else {
             wp_auto_spinner_log_new('spinning', 'Trying to use spinrewriter api');
         }
     }
     //found email and password
     wp_auto_spinner_log_new('SpinRewriter Skip', 'We will use the internal synonyms database instead');
     return $this->spin();
 }
Ejemplo n.º 4
0
function wp_auto_spinner_save_meta_data($post_id)
{
    //SCHEDULED POSTS TO QUEUE
    if (!wp_is_post_revision($post_id)) {
        $publish = '';
        @($publish = $_POST['post_status']);
        if (trim($publish) == 'publish' && isset($_POST['post_date'])) {
            //this is a scheduled post let's schedule for spin if eligible
            //check if already checked if yes return
            $checked = get_post_meta($post_id, 'wp_auto_spinner_checked', 1);
            if (trim($checked) != '') {
                return;
            }
            //set checked flag to yes
            update_post_meta($post_id, 'wp_auto_spinner_checked', 'yes');
            $autospin = get_option('wp_auto_spin', array());
            //if manual enabled schedule
            if (in_array('OPT_AUTO_SPIN_ACTIVE_MANUAL', $autospin)) {
                //schedule it manual post spinning enable
                //SCHEDULED SPIN
                wp_auto_spinner_log_new('New Post >> Schedule', 'New scheduled post with id {' . $post_id . '}   sent to spin queue');
                //add the scheduled spin meta
                update_post_meta($post_id, 'wp_auto_spinner_scheduled', 'yes');
            }
        }
    }
}