当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_suspend_cache_addition函数代码示例

本文整理汇总了PHP中wp_suspend_cache_addition函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_suspend_cache_addition函数的具体用法?PHP wp_suspend_cache_addition怎么用?PHP wp_suspend_cache_addition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_suspend_cache_addition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _wpsc_meta_migrate_anonymous_users

/**
 * starting in 3.8.14 visitors information belongs in the vistor table, not the users table, start
 * the migration.  This migration could take a very long time so it's done as a cron
 *
 * @access private
 * @since 3.8.14
 *
 */
function _wpsc_meta_migrate_anonymous_users()
{
    global $wpdb;
    // get the users table auto increment value, and set the visitor meta auto increment to match.
    // we do this so that new customer cookies don't collide with existing customer cookies after
    // the migration.  Note we can't use max of user id because users may have been deleted.
    $sql = 'SHOW TABLE STATUS WHERE NAME = "' . $wpdb->users . '"';
    $status = $wpdb->get_results($sql);
    $wpdb->query('ALTER TABLE ' . $wpdb->wpsc_visitors . ' AUTO_INCREMENT = ' . $status[0]->Auto_increment);
    wp_suspend_cache_addition(true);
    $role = get_role('wpsc_anonymous');
    if ($role) {
        remove_role('wpsc_anonymous', __('Anonymous', 'wp-e-commerce'));
    }
    wp_schedule_single_event(time() + 5, 'wpsc_migrate_anonymous_user_cron');
}
开发者ID:ashik968,项目名称:digiplot,代码行数:24,代码来源:10.php

示例2: dispatch

 /**
  * Dispatch the actions
  */
 public function dispatch()
 {
     set_time_limit(7200);
     // Timeout = 2 hours
     // Suspend the cache during the migration to avoid exhausted memory problem
     wp_suspend_cache_addition(true);
     wp_suspend_cache_invalidation(true);
     // Default values
     $this->plugin_options = array('automatic_empty' => 0, 'url' => null, 'hostname' => 'localhost', 'port' => 3306, 'database' => null, 'username' => 'root', 'password' => '', 'prefix' => 'jos_', 'introtext' => 'in_content', 'archived_posts' => 'not_imported', 'skip_media' => 0, 'first_image' => 'as_is_and_featured', 'import_external' => 0, 'import_duplicates' => 0, 'force_media_import' => 0, 'meta_keywords_in_tags' => 0, 'import_as_pages' => 0, 'timeout' => 5);
     $options = get_option('fgj2wp_options');
     if (is_array($options)) {
         $this->plugin_options = array_merge($this->plugin_options, $options);
     }
     // Check if the upload directory is writable
     $upload_dir = wp_upload_dir();
     if (!is_writable($upload_dir['basedir'])) {
         $this->display_admin_error(__('The wp-content directory must be writable.', 'fgj2wp'));
     }
     if (isset($_POST['empty'])) {
         // Delete content
         if (check_admin_referer('empty', 'fgj2wp_nonce')) {
             // Security check
             if ($this->empty_database($_POST['empty_action'])) {
                 // Empty WP database
                 $this->display_admin_notice(__('WordPress content removed', 'fgj2wp'));
             } else {
                 $this->display_admin_error(__('Couldn\'t remove content', 'fgj2wp'));
             }
             wp_cache_flush();
         }
     } elseif (isset($_POST['save'])) {
         // Save database options
         $this->save_plugin_options();
         $this->display_admin_notice(__('Settings saved', 'fgj2wp'));
     } elseif (isset($_POST['test'])) {
         // Save database options
         $this->save_plugin_options();
         // Test the database connection
         if (check_admin_referer('parameters_form', 'fgj2wp_nonce')) {
             // Security check
             $this->test_database_connection();
         }
     } elseif (isset($_POST['import'])) {
         // Save database options
         $this->save_plugin_options();
         // Automatic empty
         if ($this->plugin_options['automatic_empty']) {
             if ($this->empty_database('all')) {
                 $this->display_admin_notice(__('WordPress content removed', 'fgj2wp'));
             } else {
                 $this->display_admin_error(__('Couldn\'t remove content', 'fgj2wp'));
             }
             wp_cache_flush();
         }
         // Import content
         if (check_admin_referer('parameters_form', 'fgj2wp_nonce')) {
             // Security check
             $this->import();
         }
     } elseif (isset($_POST['remove_cat_prefix'])) {
         // Remove the prefixes from the categories
         if (check_admin_referer('remove_cat_prefix', 'fgj2wp_nonce')) {
             // Security check
             $result = $this->remove_category_prefix();
             $this->display_admin_notice(__('Prefixes removed from categories', 'fgj2wp'));
         }
     } elseif (isset($_POST['modify_links'])) {
         // Modify internal links
         if (check_admin_referer('modify_links', 'fgj2wp_nonce')) {
             // Security check
             $result = $this->modify_links();
             $this->display_admin_notice(sprintf(_n('%d internal link modified', '%d internal links modified', $result['links_count'], 'fgj2wp'), $result['links_count']));
         }
     }
     $this->display_admin_page();
     // Display the admin page
 }
开发者ID:ryan2407,项目名称:Vision,代码行数:80,代码来源:class-fg-joomla-to-wordpress-admin.php

示例3: relevanssi_populate_array

function relevanssi_populate_array($matches)
{
    global $relevanssi_post_array, $relevanssi_post_types, $wpdb;
    if (function_exists('wp_suspend_cache_addition')) {
        wp_suspend_cache_addition(true);
    }
    $ids = array();
    foreach ($matches as $match) {
        array_push($ids, $match->doc);
    }
    $ids = implode(',', $ids);
    $posts = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE id IN ({$ids})");
    foreach ($posts as $post) {
        $relevanssi_post_array[$post->ID] = $post;
        $relevanssi_post_types[$post->ID] = $post->post_type;
    }
    if (function_exists('wp_suspend_cache_addition')) {
        wp_suspend_cache_addition(false);
    }
}
开发者ID:umbezt,项目名称:Soka-Education-Student-Research-Project,代码行数:20,代码来源:common.php

示例4: get_logs

 /**
  * Gets the log entries for the current view
  *
  * @access public
  * @since  1.0
  * @global object $give_logs Give Logs Object
  * @return array $logs_data Array of all the Log entires
  */
 public function get_logs()
 {
     $give_logs = new Give_Logging();
     // Prevent the queries from getting cached.
     // Without this there are occasional memory issues for some installs.
     wp_suspend_cache_addition(true);
     $logs_data = array();
     $paged = $this->get_paged();
     $log_query = array('log_type' => 'gateway_error', 'paged' => $paged);
     $logs = $give_logs->get_connected_logs($log_query);
     if ($logs) {
         foreach ($logs as $log) {
             $logs_data[] = array('ID' => $log->ID, 'ID_label' => '<span class=\'give-item-label give-item-label-gray\'>' . $log->ID . '</span>', 'payment_id' => $log->post_parent, 'error' => 'error', 'gateway' => give_get_payment_gateway($log->post_parent), 'date' => $log->post_date);
         }
     }
     return $logs_data;
 }
开发者ID:wordimpress,项目名称:give,代码行数:25,代码来源:class-gateway-error-logs-list-table.php

示例5: test_comment_objects_should_be_fetched_from_database_when_suspend_cache_addition

 /**
  * @ticket 34138
  */
 public function test_comment_objects_should_be_fetched_from_database_when_suspend_cache_addition()
 {
     $suspend = wp_suspend_cache_addition();
     wp_suspend_cache_addition(true);
     $c = self::factory()->comment->create(array('comment_post_ID' => self::$post_id));
     $q = new WP_Comment_Query(array('post_id' => self::$post_id));
     wp_suspend_cache_addition($suspend);
     $found = wp_list_pluck($q->comments, 'comment_ID');
     $this->assertEqualSets(array($c), $found);
 }
开发者ID:dd32,项目名称:wordpress.develop,代码行数:13,代码来源:query.php

示例6: get_logs

 /**
  * Gets the log entries for the current view
  *
  * @access public
  * @since 1.4
  * @global object $edd_logs EDD Logs Object
  * @return array $logs_data Array of all the Log entires
  */
 public function get_logs()
 {
     global $edd_logs;
     // Prevent the queries from getting cached. Without this there are occasional memory issues for some installs
     wp_suspend_cache_addition(true);
     $logs_data = array();
     $paged = $this->get_paged();
     $log_query = array('log_type' => 'gateway_error', 'paged' => $paged);
     $logs = $edd_logs->get_connected_logs($log_query);
     if ($logs) {
         foreach ($logs as $log) {
             $logs_data[] = array('ID' => $log->ID, 'payment_id' => $log->post_parent, 'error' => 'error', 'gateway' => edd_get_payment_gateway($log->post_parent), 'date' => $log->post_date);
         }
     }
     return $logs_data;
 }
开发者ID:SelaInc,项目名称:eassignment,代码行数:24,代码来源:class-gateway-error-logs-list-table.php

示例7: w3tc_suspend_cache_addition_post

 /**
  * Prevents W3TC from adding to the cache after modifying data
  *
  * @access public
  * @return void
  */
 function w3tc_suspend_cache_addition_post()
 {
     wp_suspend_cache_addition();
 }
开发者ID:metodiew,项目名称:Easy-Digital-Downloads,代码行数:10,代码来源:class-edd-cache-helper.php

示例8: relevanssi_build_index

function relevanssi_build_index($extend = false)
{
    if (function_exists('wp_suspend_cache_addition')) {
        wp_suspend_cache_addition(true);
    }
    // Thanks to Julien Mession
    global $wpdb, $relevanssi_variables;
    $relevanssi_table = $relevanssi_variables['relevanssi_table'];
    if (!ini_get('safe_mode')) {
        set_time_limit(0);
    }
    $post_types = array();
    $types = get_option("relevanssi_index_post_types");
    if (!is_array($types)) {
        $types = array();
    }
    foreach ($types as $type) {
        array_push($post_types, "'{$type}'");
    }
    if (count($post_types) > 0) {
        $restriction = " AND post.post_type IN (" . implode(', ', $post_types) . ') ';
    } else {
        $restriction = "";
    }
    $valid_status_array = apply_filters('relevanssi_valid_status', array('publish', 'draft', 'private', 'pending', 'future'));
    if (is_array($valid_status_array) && count($valid_status_array) > 0) {
        $valid_status = array();
        foreach ($valid_status_array as $status) {
            $valid_status[] = "'{$status}'";
        }
        $valid_status = implode(',', $valid_status);
    } else {
        // this really should never happen
        $valid_status = "'publish', 'draft', 'private', 'pending', 'future'";
    }
    $n = 0;
    $size = 0;
    if (!$extend) {
        // truncate table first
        $wpdb->query("TRUNCATE TABLE {$relevanssi_table}");
        if (function_exists('relevanssi_index_taxonomies')) {
            if (get_option('relevanssi_index_taxonomies') == 'on') {
                relevanssi_index_taxonomies();
            }
        }
        if (function_exists('relevanssi_index_users')) {
            if (get_option('relevanssi_index_users') == 'on') {
                relevanssi_index_users();
            }
        }
        $q = "SELECT post.ID\n\t\tFROM {$wpdb->posts} post\n\t\tLEFT JOIN {$wpdb->posts} parent ON (post.post_parent=parent.ID)\n\t\tWHERE\n\t\t\t(post.post_status IN ({$valid_status})\n\t\t\tOR\n\t\t\t(post.post_status='inherit'\n\t\t\t\tAND(\n\t\t\t\t\t(parent.ID is not null AND (parent.post_status IN ({$valid_status})))\n\t\t\t\t\tOR (post.post_parent=0)\n\t\t\t\t)\n\t\t\t))\n\t\t{$restriction}";
        update_option('relevanssi_index', '');
    } else {
        // extending, so no truncate and skip the posts already in the index
        $limit = get_option('relevanssi_index_limit', 200);
        if (is_numeric($limit) && $limit > 0) {
            $size = $limit;
            $limit = " LIMIT {$limit}";
        } else {
            $limit = "";
        }
        $q = "SELECT post.ID\n\t\tFROM {$wpdb->posts} post\n\t\tLEFT JOIN {$wpdb->posts} parent ON (post.post_parent=parent.ID)\n\t\tLEFT JOIN {$relevanssi_table} r ON (post.ID=r.doc)\n\t\tWHERE\n\t\tr.doc is null\n\t\tAND\n\t\t\t(post.post_status IN ({$valid_status})\n\t\t\tOR\n\t\t\t(post.post_status='inherit'\n\t\t\t\tAND(\n\t\t\t\t\t(parent.ID is not null AND (parent.post_status IN ({$valid_status})))\n\t\t\t\t\tOR (post.post_parent=0)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t\t{$restriction} {$limit}";
    }
    $custom_fields = relevanssi_get_custom_fields();
    do_action('relevanssi_pre_indexing_query');
    $content = $wpdb->get_results($q);
    foreach ($content as $post) {
        $n += relevanssi_index_doc($post->ID, false, $custom_fields, true);
        // n calculates the number of insert queries
        // $bypassglobalpost set to true, because at this point global $post should be NULL, but in some cases it is not
    }
    $wpdb->query("ANALYZE TABLE {$relevanssi_table}");
    // To prevent empty indices
    echo '<div id="message" class="updated fade"><p>' . __($size == 0 || count($content) < $size ? "Indexing complete!" : "More to index...", "relevanssi") . '</p></div>';
    update_option('relevanssi_indexed', 'done');
    // We always want to run this on init, if the index is finishd building.
    $D = $wpdb->get_var("SELECT COUNT(DISTINCT(relevanssi.doc)) FROM {$relevanssi_table} AS relevanssi");
    update_option('relevanssi_doc_count', $D);
    if (function_exists('wp_suspend_cache_addition')) {
        wp_suspend_cache_addition(false);
    }
    // Thanks to Julien Mession
}
开发者ID:WP-Panda,项目名称:allergenics,代码行数:83,代码来源:indexing.php

示例9: get_logs

 /**
  * Gets the log entries for the current view
  *
  * @access public
  * @since 1.4
  * @global object $edd_logs EDD Logs Object
  * @return array $logs_data Array of all the Log entires
  */
 public function get_logs()
 {
     global $edd_logs;
     // Prevent the queries from getting cached. Without this there are occasional memory issues for some installs
     wp_suspend_cache_addition(true);
     $logs_data = array();
     $paged = $this->get_paged();
     $download = empty($_GET['s']) ? $this->get_filtered_download() : null;
     $log_query = array('post_parent' => $download, 'log_type' => 'sale', 'paged' => $paged, 'meta_query' => $this->get_meta_query());
     $logs = $edd_logs->get_connected_logs($log_query);
     if ($logs) {
         foreach ($logs as $log) {
             $payment_id = get_post_meta($log->ID, '_edd_log_payment_id', true);
             // Make sure this payment hasn't been deleted
             if (get_post($payment_id)) {
                 $user_info = edd_get_payment_meta_user_info($payment_id);
                 $cart_items = edd_get_payment_meta_cart_details($payment_id);
                 $amount = 0;
                 if (is_array($cart_items) && is_array($user_info)) {
                     foreach ($cart_items as $item) {
                         if ($item['id'] == $log->post_parent) {
                             $amount = isset($item['item_price']) ? $item['item_price'] : $item['price'];
                             break;
                         }
                     }
                     $logs_data[] = array('ID' => $log->ID, 'payment_id' => $payment_id, 'download' => $log->post_parent, 'amount' => $amount, 'user_id' => $user_info['id'], 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], 'date' => get_post_field('post_date', $payment_id));
                 }
             }
         }
     }
     return $logs_data;
 }
开发者ID:nitun,项目名称:Easy-Digital-Downloads,代码行数:40,代码来源:class-sales-logs-list-table.php

示例10: wpestate_listing_pins_with_reservation

 function wpestate_listing_pins_with_reservation($args = '', $jump = 0, $book_from, $book_to)
 {
     wp_suspend_cache_addition(true);
     set_time_limit(0);
     $counter = 0;
     $unit = get_option('wp_estate_measure_sys', '');
     $currency = get_option('wp_estate_currency_symbol', '');
     $where_currency = get_option('wp_estate_where_currency_symbol', '');
     $cache = get_option('wp_estate_cache', '');
     $place_markers = array();
     $markers = array();
     if ($cache == 'yes') {
         if (!get_transient('prop_list_cached')) {
             if ($args == '') {
                 $args = array('post_type' => 'estate_property', 'post_status' => 'publish', 'nopaging' => 'true', 'cache_results' => false, 'update_post_meta_cache' => false, 'update_post_term_cache' => false);
             }
             $prop_selection = new WP_Query($args);
             set_transient('prop_list_cached', $prop_selection, 60 * 60 * 3);
             //store data for 3h
         } else {
             $prop_selection = get_transient('prop_list_cached');
             // retrive cached data
         }
         wp_reset_query();
     } else {
         if ($args == '') {
             $args = array('post_type' => 'estate_property', 'post_status' => 'publish', 'nopaging' => 'true', 'cache_results' => false, 'update_post_meta_cache' => false, 'update_post_term_cache' => false);
         }
         $prop_selection = new WP_Query($args);
         wp_reset_query();
     }
     //end cache
     $custom_advanced_search = get_option('wp_estate_custom_advanced_search', '');
     $show_slider_price = get_option('wp_estate_show_slider_price', '');
     $has_slider = 0;
     while ($prop_selection->have_posts()) {
         $prop_selection->the_post();
         $counter++;
         if (wpestate_check_booking_valability($book_from, $book_to, get_the_ID())) {
             $markers[] = wpestate_pin_unit_creation(get_the_ID(), $currency, $where_currency, $counter);
         }
         //    print_r($place_markers)  ;
     }
     wp_reset_query();
     wp_suspend_cache_addition(false);
     if (get_option('wp_estate_readsys', '') == 'yes' && $jump == 0) {
         $path = get_template_directory() . '/pins.txt';
         wpestate_otto_write_tofile($path, json_encode($markers));
     } else {
         return json_encode($markers);
     }
 }
开发者ID:riddya85,项目名称:rentail_upwrk,代码行数:52,代码来源:pin_management.php

示例11: display_callback

 public function display_callback($args, $widget_args = array())
 {
     $widget_args = wp_parse_args($widget_args, array('widget' => null, 'instance' => null));
     $widget = $widget_args['widget'];
     $widget->id = $args['widget_id'];
     /**
      * Filter the settings for a particular widget instance.
      *
      * Returning false will effectively short-circuit display of the widget.
      *
      * @since 2.8.0
      *
      * @param array     $instance The current widget instance's settings.
      * @param WP_Widget $this     The current widget instance.
      * @param array     $args     An array of default widget arguments.
      */
     $instance = apply_filters('widget_display_callback', $widget_args['instance'], $widget, $args);
     if (false === $instance) {
         return;
     }
     $was_cache_addition_suspended = wp_suspend_cache_addition();
     if ($widget->is_preview() && !$was_cache_addition_suspended) {
         wp_suspend_cache_addition(true);
     }
     $widget->widget($args, $instance);
     if ($widget->is_preview()) {
         wp_suspend_cache_addition($was_cache_addition_suspended);
     }
 }
开发者ID:lucasstark,项目名称:acf-field-widget-area,代码行数:29,代码来源:acf-widget_area.php

示例12: override_widget_display

 /**
  * Util: Execute the widget as would normally happen had we not
  * short-circuited the default process.
  *
  * @see WP_Widget::display_callback()
  *
  * @param $instance
  * @param $widget
  * @param $args
  */
 function override_widget_display($instance, $widget, $args)
 {
     $was_cache_addition_suspended = wp_suspend_cache_addition();
     if ($widget->is_preview() && !$was_cache_addition_suspended) {
         wp_suspend_cache_addition(true);
     }
     $widget->widget($args, $instance);
     if ($widget->is_preview()) {
         wp_suspend_cache_addition($was_cache_addition_suspended);
     }
 }
开发者ID:BDaggerhart,项目名称:wp-theme-dev,代码行数:21,代码来源:widget-templates.php

示例13: leyka_update_campaigns_total_funded

 function leyka_update_campaigns_total_funded()
 {
     set_time_limit(3600);
     wp_suspend_cache_addition(true);
     $campaigns = get_posts(array('post_type' => Leyka_Campaign_Management::$post_type, 'nopaging' => true, 'post_status' => 'any'));
     foreach ($campaigns as $campaign) {
         $campaign = new Leyka_Campaign($campaign);
         $campaign->update_total_funded_amount();
     }
     wp_suspend_cache_addition(false);
 }
开发者ID:WarmHouseProject,项目名称:WarmHouse,代码行数:11,代码来源:leyka-core.php

示例14: set_optimisations

 /**
  * Set a number of optimsiations to make sure the plugin is usable on lower end setups.
  *
  * We stop plugins trying to cache, or compress the output since that causes everything to be
  * held in memory and causes memory issues. We also tell WP not to add loaded objects to the
  * cache since on setups without a persistent object store that would result in everything being
  * in memory again.
  */
 private function set_optimisations()
 {
     global $wpdb;
     // Don't cache feed under WP Super-Cache
     define('DONOTCACHEPAGE', true);
     // Cater for large stores
     $wpdb->hide_errors();
     @set_time_limit(0);
     while (ob_get_level()) {
         @ob_end_clean();
     }
     // Suspend cache addition to stop WP trying to hold everything in memory.
     // Note: wp_suspend_cache_addition is buggy prior to WP 3.4.
     if (version_compare(get_bloginfo('version'), '3.4', '>=')) {
         wp_suspend_cache_addition(true);
     }
 }
开发者ID:jmead,项目名称:trucell-cms,代码行数:25,代码来源:woocommerce-gpf-frontend.php

示例15: add_note

 /**
  * Add new history note to user(s)
  * @param string $title Note title
  * @param string $contents Note contents
  * @param integer $type Term ID of primary note type
  * @param integer $subtype Term ID of secondary note type
  * @param array $user_ids List of user IDs to add note to
  * @param boolean $action_required Whether the note should be marked as requiring action
  */
 public static function add_note($title, $contents, $type, $subtype, array $user_ids, array $args = array(), $action_required = false)
 {
     // Some performance changes
     //         global $wpdb;
     //         $wpdb->query('SET autocommit = 0;');
     wp_suspend_cache_addition(true);
     wp_defer_term_counting(true);
     wp_defer_comment_counting(true);
     $data = array('post_type' => 'bb_note', 'post_title' => $title, 'post_content' => $contents, 'post_status' => 'publish', 'tax_input' => array('bb_note_type' => array($type, $subtype)));
     $data = array_merge_recursive($data, $args);
     unset($title, $contents, $type, $subtype, $args);
     foreach ($user_ids as $user_id) {
         $start = microtime(true);
         $data['post_author'] = $user_id;
         $new_post = wp_insert_post($data);
         if ($action_required) {
             add_post_meta($new_post, '_bbc_action_required', 'true');
         }
         unset($new_post);
     }
     // Set performance settings back to defaults
     //         $wpdb->query('COMMIT;');
     //         $wpdb->query('SET autocommit = 1;');
     wp_defer_term_counting(false);
     wp_defer_comment_counting(false);
     return true;
 }
开发者ID:BrownBox,项目名称:bbconnect-quicklinks,代码行数:36,代码来源:abstract.class.php


注:本文中的wp_suspend_cache_addition函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。