• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_suspend_cache_addition函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: validate

 /**
  * Validate data for the widget.
  *
  * @param string $name
  * @return JsonResponse
  */
 public function validate($name)
 {
     $widgetType = $this->getWidgetType($name);
     $old_instance = [];
     $new_instance = $this->request->post->getArray("widget-{$widgetType->id_base}.0");
     // Prevent caching.
     $cache_state = \wp_suspend_cache_addition();
     \wp_suspend_cache_addition(true);
     // Update widget by using its own method.
     $instance = $widgetType->update($new_instance, $old_instance);
     // Restore caching.
     \wp_suspend_cache_addition($cache_state);
     // Apply widget filters.
     // TODO: We might want to add the filters back; for now we just assume that widget works like the_widget().
     //$instance = \apply_filters('widget_update_callback', $instance, $new_instance, $old_instance, $widgetType);
     if ($instance === false) {
         throw new \RuntimeException('Filter prevented widget from being saved.', 403);
     }
     // Create configuration from the defaults.
     $data = new Config(['type' => 'widget', 'widget' => $name, 'title' => $this->request->post['title'] ?: $widgetType->name]);
     $data->set('options.widget', $instance);
     $data->def('options.enabled', 1);
     return new JsonResponse(['item' => $data->toArray()]);
 }
开发者ID:juanmanunez,项目名称:gantry5,代码行数:30,代码来源:Widget.php


示例17: add

 /**
  * Adds data to the cache if it doesn't already exist.
  *
  * @uses WP_Object_Cache::_exists Checks to see if the cache already has data.
  * @uses WP_Object_Cache::set Sets the data after the checking the cache
  *		contents existence.
  *
  * @param int|string $key What to call the contents in the cache
  * @param mixed $data The contents to store in the cache
  * @param string $group Where to group the cache contents
  * @param int $expire When to expire the cache contents
  * @return bool False if cache key and group already exist, true on success
  */
 public function add($key, $data, $group = 'default', $expire = 0)
 {
     if (empty($group)) {
         $group = 'default';
     }
     if (function_exists('wp_suspend_cache_addition') && wp_suspend_cache_addition()) {
         return false;
     }
     if ($this->_exists($key, $group)) {
         return false;
     }
     return $this->set($key, $data, $group, (int) $expire);
 }
开发者ID:pantheon-systems,项目名称:wp-redis,代码行数:26,代码来源:object-cache.php


示例18: 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()
 {
     global $give_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();
     $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null;
     $user = $this->get_filtered_user();
     $log_query = array('post_parent' => $give_form, 'log_type' => 'sale', 'paged' => $paged, 'meta_query' => $this->get_meta_query());
     $logs = $give_logs->get_connected_logs($log_query);
     if ($logs) {
         foreach ($logs as $log) {
             $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true);
             // Make sure this payment hasn't been deleted
             if (get_post($payment_id)) {
                 $user_info = give_get_payment_meta_user_info($payment_id);
                 $payment_meta = give_get_payment_meta($payment_id);
                 $payment_amount = give_get_payment_amount($payment_id);
                 $logs_data[] = array('ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', 'payment_id' => $payment_id, 'form' => $log->post_parent, 'amount' => $payment_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:duongnguyen92,项目名称:tvd12v2,代码行数:33,代码来源:class-sales-logs-list-table.php


示例19: _wpsc_meta_migrate_anonymous_user_worker

 function _wpsc_meta_migrate_anonymous_user_worker()
 {
     global $wpdb;
     $blog_prefix = is_multisite() ? $wpdb->get_blog_prefix() : '';
     $key_pattern = "{$blog_prefix}_wpsc_";
     wp_suspend_cache_addition(true);
     $sql = 'SELECT ID FROM ' . $wpdb->users . ' WHERE user_login LIKE "\\_%" AND user_email = "" AND user_login = user_nicename AND user_login = display_name LIMIT 100';
     $user_ids = $wpdb->get_col($sql, 0);
     // Create an array to store users to be removed.
     $bin = array();
     foreach ($user_ids as $user_id) {
         $wpdb->query('INSERT INTO ' . $wpdb->wpsc_visitors . '(`id`) VALUES ( ' . $user_id . ' )');
         wpsc_set_visitor_expiration($user_id, DAY_IN_SECONDS);
         $meta = get_user_meta($user_id);
         foreach ($meta as $key => $value) {
             if (strpos($key, $key_pattern) === FALSE) {
                 continue;
             }
             $short_key = str_replace($key_pattern, '', $key);
             if ($short_key !== 'cart') {
                 wpsc_add_visitor_meta($user_id, $short_key, $value[0]);
             } else {
                 $wpsc_user_cart = maybe_unserialize(base64_decode($value[0]));
                 if (!$wpsc_user_cart instanceof wpsc_cart) {
                     $wpsc_user_cart = new wpsc_cart();
                 } else {
                     continue;
                 }
             }
         }
         $comment_count = $wpdb->get_var('SELECT COUNT(comment_ID) FROM ' . $wpdb->comments . ' WHERE user_id = ' . $user_id);
         if (!count_user_posts($user_id) && !$comment_count) {
             //wp_delete_user( $user_id );
             // Add user to bin.
             $bin[] = $user_id;
         }
     }
     // Remove users.
     if (!empty($bin)) {
         // Convert $bin to string.
         $bin = implode(',', $bin);
         $wpdb->query('DELETE FROM ' . $wpdb->users . ' WHERE ID IN (' . $bin . ')');
         $wpdb->query('DELETE FROM ' . $wpdb->usermeta . ' WHERE user_id IN (' . $bin . ')');
     }
     wp_suspend_cache_addition(false);
     exit(0);
 }
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:47,代码来源:wpsc-meta-util.php


示例20: wpsc_generate_product_feed

function wpsc_generate_product_feed()
{
    global $wpdb, $wp_query, $post;
    set_time_limit(0);
    // Don't build up a huge posts cache for the whole store - http://code.google.com/p/wp-e-commerce/issues/detail?id=885
    // WP 3.3+ only
    if (function_exists('wp_suspend_cache_addition')) {
        wp_suspend_cache_addition(true);
    }
    $chunk_size = apply_filters('wpsc_productfeed_chunk_size', 50);
    // Don't cache feed under WP Super-Cache
    define('DONOTCACHEPAGE', TRUE);
    $selected_category = '';
    $selected_product = '';
    $args = array('post_type' => 'wpsc-product', 'numberposts' => $chunk_size, 'offset' => 0, 'cache_results' => false);
    $args = apply_filters('wpsc_productfeed_query_args', $args);
    $self = site_url("/index.php?rss=true&amp;action=product_list{$selected_category}{$selected_product}");
    header("Content-Type: application/xml; charset=UTF-8");
    header('Content-Disposition: inline; filename="E-Commerce_Product_List.rss"');
    echo "<?xml version='1.0' encoding='UTF-8' ?>\n\r";
    echo "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'";
    $google_checkout_note = false;
    if ($_GET['xmlformat'] == 'google') {
        echo ' xmlns:g="http://base.google.com/ns/1.0"';
        // Is Google Checkout available as a payment gateway
        $selected_gateways = get_option('custom_gateway_options');
        if (in_array('google', $selected_gateways)) {
            $google_checkout_note = true;
        }
    } else {
        echo ' xmlns:product="http://www.buy.com/rss/module/productV2/"';
    }
    echo ">\n\r";
    echo "  <channel>\n\r";
    echo "    <title><![CDATA[" . get_option('blogname') . " Products]]></title>\n\r";
    echo "    <link>" . get_option('siteurl') . "/wp-admin/admin.php?page=" . WPSC_DIR_NAME . "/display-log.php</link>\n\r";
    echo "    <description>This is the WP e-Commerce Product List RSS feed</description>\n\r";
    echo "    <generator>WP e-Commerce Plugin</generator>\n\r";
    echo "    <atom:link href='{$self}' rel='self' type='application/rss+xml' />\n\r";
    $products = get_posts($args);
    while (count($products)) {
        foreach ($products as $post) {
            setup_postdata($post);
            $purchase_link = wpsc_product_url($post->ID);
            echo "    <item>\n\r";
            if ($google_checkout_note) {
                echo "      <g:payment_notes>Google Checkout</g:payment_notes>\n\r";
            }
            echo "      <title><![CDATA[" . get_the_title() . "]]></title>\n\r";
            echo "      <link>{$purchase_link}</link>\n\r";
            echo "      <description><![CDATA[" . apply_filters('the_content', get_the_content()) . "]]></description>\n\r";
            echo "      <pubDate>" . $post->post_modified_gmt . "</pubDate>\n\r";
            echo "      <guid>{$purchase_link}</guid>\n\r";
            $image_link = wpsc_the_product_thumbnail();
            if ($image_link !== FALSE) {
                if ($_GET['xmlformat'] == 'google') {
                    echo "      <g:image_link>{$image_link}</g:image_link>\n\r";
                } else {
                    echo "      <enclosure url='{$image_link}' />\n\r";
                }
            }
            $price = wpsc_calculate_price($post->ID);
            $currargs = array('display_currency_symbol' => false, 'display_decimal_point' => true, 'display_currency_code' => false, 'display_as_html' => false);
            $price = wpsc_currency_display($price, $currargs);
            $children = get_children(array('post_parent' => $post->ID, 'post_type' => 'wpsc-product'));
            foreach ($children as $child) {
                $child_price = wpsc_calculate_price($child->ID);
                if ($price == 0 && $child_price > 0) {
                    $price = $child_price;
                } else {
                    if ($child_price > 0 && $child_price < $price) {
                        $price = $child_price;
                    }
                }
            }
            if ($_GET['xmlformat'] == 'google') {
                echo "      <g:price>" . $price . "</g:price>\n\r";
                $google_elements = array();
                $product_meta = get_post_custom($post->ID);
                if (is_array($product_meta)) {
                    foreach ($product_meta as $meta_key => $meta_value) {
                        if (stripos($meta_key, 'g:') === 0) {
                            $google_elements[$meta_key] = $meta_value;
                        }
                    }
                }
                $google_elements = apply_filters('wpsc_google_elements', array('product_id' => $post->ID, 'elements' => $google_elements));
                $google_elements = $google_elements['elements'];
                $done_condition = FALSE;
                $done_availability = FALSE;
                $done_weight = FALSE;
                if (count($google_elements)) {
                    foreach ($google_elements as $element_name => $element_values) {
                        foreach ($element_values as $element_value) {
                            echo "      <" . $element_name . ">";
                            echo "<![CDATA[" . $element_value . "]]>";
                            echo "</" . $element_name . ">\n\r";
                        }
                        if ($element_name == 'g:shipping_weight') {
                            $done_weight = TRUE;
//.........这里部分代码省略.........
开发者ID:arturo-mayorga,项目名称:am_com,代码行数:101,代码来源:productfeed.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_suspend_cache_invalidation函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_super_cache_disable函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap