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


PHP wp_update_term_count_now函数代码示例

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


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

示例1: screen

 public function screen()
 {
     $Shopp = Shopp::object();
     if (!current_user_can('shopp_settings_checkout')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $purchasetable = ShoppDatabaseObject::tablename(ShoppPurchase::$table);
     $next = sDB::query("SELECT IF ((MAX(id)) > 0,(MAX(id)+1),1) AS id FROM {$purchasetable} LIMIT 1");
     $next_setting = shopp_setting('next_order_id');
     if ($next->id > $next_setting) {
         $next_setting = $next->id;
     }
     $term_recount = false;
     if (!empty($_POST['save'])) {
         check_admin_referer('shopp-setup-management');
         $next_order_id = $_POST['settings']['next_order_id'] = intval($_POST['settings']['next_order_id']);
         if ($next_order_id >= $next->id) {
             if (sDB::query("ALTER TABLE {$purchasetable} AUTO_INCREMENT=" . sDB::escape($next_order_id))) {
                 $next_setting = $next_order_id;
             }
         }
         $_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']);
         // Recount terms when this setting changes
         if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) {
             $term_recount = true;
         }
         shopp_set_formsettings();
         $this->notice(Shopp::__('Management settings saved.'), 'notice', 20);
     }
     if ($term_recount) {
         $taxonomy = ProductCategory::$taxon;
         $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
         if (!empty($terms)) {
             wp_update_term_count_now($terms, $taxonomy);
         }
     }
     $states = array(__('Map the label to an order state:', 'Shopp') => array_merge(array('' => ''), Lookup::txnstatus_labels()));
     $statusLabels = shopp_setting('order_status');
     $statesLabels = shopp_setting('order_states');
     $reasonLabels = shopp_setting('cancel_reasons');
     if (empty($reasonLabels)) {
         $reasonLabels = array(__('Not as described or expected', 'Shopp'), __('Wrong size', 'Shopp'), __('Found better prices elsewhere', 'Shopp'), __('Product is missing parts', 'Shopp'), __('Product is defective or damaaged', 'Shopp'), __('Took too long to deliver', 'Shopp'), __('Item out of stock', 'Shopp'), __('Customer request to cancel', 'Shopp'), __('Item discontinued', 'Shopp'), __('Other reason', 'Shopp'));
     }
     $promolimit = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '15', '20', '25');
     $lowstock = shopp_setting('lowstock_level');
     if (empty($lowstock)) {
         $lowstock = 0;
     }
     include $this->ui('management.php');
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:50,代码来源:OrdersSettings.php

示例2: updates

 public function updates()
 {
     $builtin_path = SHOPP_PATH . '/templates';
     $theme_path = sanitize_path(STYLESHEETPATH . '/shopp');
     if (Shopp::str_true($this->form('theme_templates')) && !is_dir($theme_path)) {
         $this->form['theme_templates'] = 'off';
         $this->notice(Shopp::__("Shopp theme templates can't be used because they don't exist."), 'error');
     }
     if (empty($this->form('catalog_pagination'))) {
         $this->form['catalog_pagination'] = 0;
     }
     // Recount terms when this setting changes
     if ($this->form('outofstock_catalog') != shopp_setting('outofstock_catalog')) {
         $taxonomy = ProductCategory::$taxon;
         $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
         if (!empty($terms)) {
             wp_update_term_count_now($terms, $taxonomy);
         }
     }
     shopp_set_formsettings();
     $this->notice(Shopp::__('Presentation settings saved.'), 'notice', 20);
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:22,代码来源:Presentation.php

示例3: wp_update_term_count

/**
 * Updates the amount of terms in taxonomy.
 *
 * If there is a taxonomy callback applied, then it will be called for updating
 * the count.
 *
 * The default action is to count what the amount of terms have the relationship
 * of term ID. Once that is done, then update the database.
 *
 * @since 2.3.0
 *
 * @staticvar array $_deferred
 *
 * @param int|array $terms    The term_taxonomy_id of the terms.
 * @param string    $taxonomy The context of the term.
 * @return bool If no terms will return false, and if successful will return true.
 */
function wp_update_term_count($terms, $taxonomy, $do_deferred = false)
{
    static $_deferred = array();
    if ($do_deferred) {
        foreach ((array) array_keys($_deferred) as $tax) {
            wp_update_term_count_now($_deferred[$tax], $tax);
            unset($_deferred[$tax]);
        }
    }
    if (empty($terms)) {
        return false;
    }
    if (!is_array($terms)) {
        $terms = array($terms);
    }
    if (wp_defer_term_counting()) {
        if (!isset($_deferred[$taxonomy])) {
            $_deferred[$taxonomy] = array();
        }
        $_deferred[$taxonomy] = array_unique(array_merge($_deferred[$taxonomy], $terms));
        return true;
    }
    return wp_update_term_count_now($terms, $taxonomy);
}
开发者ID:n8maninger,项目名称:WordPress,代码行数:41,代码来源:taxonomy-functions.php

示例4: mark_posts_save

 /**
  * Save the meta when the post is saved
  *
  * @since    1.0.0
  *
  * @param $post_id ID of the post e.g. '1'
  *
  * @return mixed
  */
 public function mark_posts_save($post_id)
 {
     // Check if our nonce is set.
     if (!isset($_POST['mark_posts_inner_meta_box_nonce'])) {
         return $post_id;
     }
     $nonce = $_POST['mark_posts_inner_meta_box_nonce'];
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($nonce, 'mark_posts_inner_meta_box')) {
         return $post_id;
     }
     // If this is an autosave, our form has not been submitted,
     // so we don't want to do anything.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // Check the user's permissions.
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return $post_id;
         }
     }
     /* OK, its safe for us to mark_posts_save the data now. */
     // Sanitize the user input.
     $mydata = sanitize_text_field($_POST['mark_posts_term_id']);
     $myterm = get_term($mydata, 'marker');
     // Update the meta field.
     update_post_meta($post_id, 'mark_posts_term_id', $mydata);
     // Update taxonomy count
     @wp_update_term_count_now($mydata, 'marker');
     // Clear transient dashboard stats
     delete_transient('marker_posts_stats');
 }
开发者ID:flymke,项目名称:mark-posts,代码行数:46,代码来源:class-mark-posts-admin.php

示例5: updateAll

 /**
  * Update all taxonomies.
  * This should only ever be called from a cron job scheduled by EasyRecipeScheduler because it can potentially take quite a while
  */
 function updateAll()
 {
     /** @var wpdb $wpdb */
     global $wpdb;
     /**
      * If we are already running, don't do it again
      */
     if ($this->scheduler->isRunning()) {
         return;
     }
     /**
      * Set as running
      * Set a "timeout" of 10 minutes. This will prevent it being re-run for 10 minutes if the current run terminates abnormally for any reason
      */
     $this->scheduler->setRunning(10 * 60);
     $q = "SELECT ID FROM {$wpdb->posts} WHERE post_type NOT IN ('attachment','index','nav_menu_item')";
     $postIDs = $wpdb->get_col($q);
     $this->countTerms['cuisine'] = array();
     $this->countTerms['course'] = array();
     foreach ($postIDs as $postID) {
         $post = WP_Post::get_instance($postID);
         $this->update($post, false);
     }
     /**
      * Update any term counts that we may have adjusted
      */
     if (count($this->countTerms['cuisine']) > 0) {
         wp_update_term_count_now(array_unique(array_keys($this->countTerms['cuisine'])), 'cuisine');
     }
     if (count($this->countTerms['course']) > 0) {
         wp_update_term_count_now(array_unique(array_keys($this->countTerms['course'])), 'course');
     }
     /**
      * Mark the taxonomies as having been created
      */
     $settings = EasyRecipeSettings::getInstance();
     $settings->taxonomiesCreated = true;
     $settings->update();
     /**
      * Mark this job as complete
      */
     $this->scheduler->terminate();
 }
开发者ID:Bakerpedia,项目名称:Developement_WPengine,代码行数:47,代码来源:EasyRecipeTaxonomies.php

示例6: presentation

 public function presentation()
 {
     if (!current_user_can('shopp_settings_presentation')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $builtin_path = SHOPP_PATH . '/templates';
     $theme_path = sanitize_path(STYLESHEETPATH . '/shopp');
     $term_recount = false;
     if (!empty($_POST['save'])) {
         check_admin_referer('shopp-settings-presentation');
         $updated = __('Shopp presentation settings saved.', 'Shopp');
         if (isset($_POST['settings']['theme_templates']) && $_POST['settings']['theme_templates'] == 'on' && !is_dir($theme_path)) {
             $_POST['settings']['theme_templates'] = 'off';
             $updated = __('Shopp theme templates can\'t be used because they don\'t exist.', 'Shopp');
         }
         if (empty($_POST['settings']['catalog_pagination'])) {
             $_POST['settings']['catalog_pagination'] = 0;
         }
         // Recount terms when this setting changes
         if (isset($_POST['settings']['outofstock_catalog']) && $_POST['settings']['outofstock_catalog'] != shopp_setting('outofstock_catalog')) {
             $term_recount = true;
         }
         shopp_set_formsettings();
         $this->notice(Shopp::__('Presentation settings saved.'), 'notice', 20);
     }
     if ($term_recount) {
         $taxonomy = ProductCategory::$taxon;
         $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
         if (!empty($terms)) {
             wp_update_term_count_now($terms, $taxonomy);
         }
     }
     // Copy templates to the current WordPress theme
     if (!empty($_POST['install'])) {
         check_admin_referer('shopp-settings-presentation');
         copy_shopp_templates($builtin_path, $theme_path);
     }
     $status = 'available';
     if (!is_dir($theme_path)) {
         $status = 'directory';
     } else {
         if (!is_writable($theme_path)) {
             $status = 'permissions';
         } else {
             $builtin = array_filter(scandir($builtin_path), 'filter_dotfiles');
             $theme = array_filter(scandir($theme_path), 'filter_dotfiles');
             if (empty($theme)) {
                 $status = 'ready';
             } else {
                 if (array_diff($builtin, $theme)) {
                     $status = 'incomplete';
                 }
             }
         }
     }
     $category_views = array('grid' => __('Grid', 'Shopp'), 'list' => __('List', 'Shopp'));
     $row_products = array(2, 3, 4, 5, 6, 7);
     $productOrderOptions = ProductCategory::sortoptions();
     $productOrderOptions['custom'] = __('Custom', 'Shopp');
     $orderOptions = array('ASC' => __('Order', 'Shopp'), 'DESC' => __('Reverse Order', 'Shopp'), 'RAND' => __('Shuffle', 'Shopp'));
     $orderBy = array('sortorder' => __('Custom arrangement', 'Shopp'), 'created' => __('Upload date', 'Shopp'));
     include $this->ui('presentation.php');
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:63,代码来源:Setup.php

示例7: shipping

 /**
  * Renders the shipping settings screen and processes updates
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return void
  **/
 public function shipping()
 {
     if (!current_user_can('shopp_settings_shipping')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $sub = 'settings';
     $term_recount = false;
     if (shopp_setting_enabled('shipping')) {
         $sub = 'rates';
     }
     if (isset($_GET['sub']) && in_array($_GET['sub'], array_keys($this->subscreens))) {
         $sub = $_GET['sub'];
     }
     if (!empty($_POST['save']) && empty($_POST['module'])) {
         check_admin_referer('shopp-settings-shipping');
         $_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']);
         // Recount terms when this setting changes
         if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) {
             $term_recount = true;
         }
         shopp_set_formsettings();
         $updated = __('Shipping settings saved.', 'Shopp');
     }
     // Handle ship rates UI
     if ('rates' == $sub && 'on' == shopp_setting('shipping')) {
         return $this->shiprates();
     }
     if ($term_recount) {
         $taxonomy = ProductCategory::$taxon;
         $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
         if (!empty($terms)) {
             wp_update_term_count_now($terms, $taxonomy);
         }
     }
     $base = shopp_setting('base_operations');
     $regions = Lookup::regions();
     $region = $regions[$base['region']];
     $useRegions = shopp_setting('shipping_regions');
     $areas = Lookup::country_areas();
     if (is_array($areas[$base['country']]) && $useRegions == 'on') {
         $areas = array_keys($areas[$base['country']]);
     } else {
         $areas = array($base['country'] => $base['name']);
     }
     unset($countries, $regions);
     $carrierdata = Lookup::shipcarriers();
     $serviceareas = array('*', substr($base['country'], 0, 2));
     foreach ($carrierdata as $c => $record) {
         if (!in_array($record->areas, $serviceareas)) {
             continue;
         }
         $carriers[$c] = $record->name;
     }
     unset($carrierdata);
     $shipping_carriers = shopp_setting('shipping_carriers');
     if (empty($shipping_carriers)) {
         $shipping_carriers = array_keys($carriers);
     }
     $rates = shopp_setting('shipping_rates');
     if (!empty($rates)) {
         ksort($rates);
     }
     $lowstock = shopp_setting('lowstock_level');
     if (empty($lowstock)) {
         $lowstock = 0;
     }
     include $this->ui('shipping.php');
 }
开发者ID:BlessySoftwares,项目名称:anvelocom,代码行数:76,代码来源:System.php

示例8: import_end

 /**
  * Performs post-import cleanup of files and the cache
  */
 function import_end()
 {
     wp_import_cleanup($this->id);
     wp_defer_term_counting(false);
     wp_defer_comment_counting(false);
     wp_cache_flush();
     $taxonomies = get_taxonomies();
     foreach ($taxonomies as $tax) {
         delete_option("{$tax}_children");
         _get_term_hierarchy($tax);
         $args = array('hide_empty' => 0, 'fields' => 'ids');
         $terms = get_terms($tax, $args);
         if (is_array($terms) && !empty($terms)) {
             wp_update_term_count_now($terms, $tax);
         }
     }
     do_action('import_end');
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:21,代码来源:wordpress-importer.php

示例9: upgrade_120


//.........这里部分代码省略.........
                     foreach ($metafields as $field) {
                         sDB::query("INSERT INTO {$meta_table} (parent, context, type, name, value)\n\t\t\t\t\t\t\t\t\t\t\tSELECT {$term_id}, 'category', 'meta', '{$field}', {$field}\n\t\t\t\t\t\t\t\t\t\t\tFROM {$category_table}\n\t\t\t\t\t\t\t\t\t\t\tWHERE id={$term->id}");
                     }
                     // Update category images to new term ids
                     sDB::query("UPDATE {$meta_table} set parent='{$term_id}' WHERE parent='" . ((int) $term->id + $category_image_offset) . "' AND context='category' AND type='image'");
                 }
             }
             if ('shopp_tag' == $taxonomy) {
                 $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->term_taxonomy} (term_id, taxonomy, description, parent, count) VALUES ( %d, %s, %s, %d, %d)", $term_id, $taxonomy, $description, $parent, 0));
                 $tt_ids[$taxonomy][$term_id] = (int) $wpdb->insert_id;
             }
         }
         update_option('shopp_category_children', '');
         // Re-catalog custom post type_products term relationships (new taxonomical catalog) from old Shopp catalog table
         $wp_taxonomies = array(0 => 'shopp_category', 1 => 'shopp_tag', 'category' => 'shopp_category', 'tag' => 'shopp_tag');
         $cols = 'wp.ID AS product, c.parent, c.type';
         $where = "type='category' OR type='tag'";
         if ($db_version >= 1125) {
             $cols = 'wp.ID AS product, c.parent, c.taxonomy, c.type';
             $where = "taxonomy=0 OR taxonomy=1";
         }
         $rels = sDB::query("SELECT {$cols} FROM {$catalog_table} AS c LEFT JOIN {$wpdb->posts} AS wp ON c.product=wp.post_parent AND wp.post_type='{$post_type}' WHERE {$where}", 'array');
         foreach ((array) $rels as $r) {
             $object_id = $r->product;
             $taxonomy = $wp_taxonomies[$db_version >= 1125 ? $r->taxonomy : $r->type];
             $term_id = $mapping[$taxonomy][$r->parent];
             if (!isset($tt_ids[$taxonomy])) {
                 continue;
             }
             if (!isset($tt_ids[$taxonomy][$term_id])) {
                 continue;
             }
             $tt_id = $tt_ids[$taxonomy][$term_id];
             if (empty($tt_id)) {
                 continue;
             }
             sDB::query("INSERT {$wpdb->term_relationships} (object_id, term_taxonomy_id) VALUES ({$object_id}, {$tt_id})");
         }
         if (isset($tt_ids['shopp_category'])) {
             wp_update_term_count_now($tt_ids['shopp_category'], 'shopp_category');
         }
         if (isset($tt_ids['shopp_tag'])) {
             wp_update_term_count_now($tt_ids['shopp_tag'], 'shopp_tag');
         }
         // Clear custom post type parents
         sDB::query("UPDATE {$wpdb->posts} SET post_parent=0 WHERE post_type='{$post_type}'");
     }
     // END if ($db_version <= 1131)
     if ($db_version <= 1133) {
         // Ditch old WP pages for pseudorific new ones
         $search = array();
         $shortcodes = array('[catalog]', '[cart]', '[checkout]', '[account]');
         foreach ($shortcodes as $string) {
             $search[] = "post_content LIKE '%{$string}%'";
         }
         $results = sDB::query("SELECT ID, post_title AS title, post_name AS slug, post_content FROM {$wpdb->posts} WHERE post_type='page' AND (" . join(" OR ", $search) . ")", 'array');
         $pages = $trash = array();
         foreach ($results as $post) {
             $trash[] = $post->ID;
             foreach ($shortcodes as $code) {
                 if (strpos($post->post_content, $code) === false) {
                     continue;
                 }
                 $pagename = trim($code, '[]');
                 $pages[$pagename] = array('title' => $post->title, 'slug' => $post->slug);
             }
             // end foreach $shortcodes
         }
         // end foreach $results
         shopp_set_setting('storefront_pages', $pages);
         sDB::query("UPDATE {$wpdb->posts} SET post_name=CONCAT(post_name, '-deprecated'), post_status='trash' where ID IN (" . join(', ', $trash) . ")");
     }
     // Move needed price table columns to price meta records
     if ($db_version <= 1135) {
         $meta_table = ShoppDatabaseObject::tablename('meta');
         $price_table = ShoppDatabaseObject::tablename('price');
         // Move 'options' to meta 'options' record
         sDB::query("INSERT INTO {$meta_table} (parent, context, type, name, value, created, modified)\n\t\t\t\t\t\tSELECT id, 'price', 'meta', 'options', options, created, modified FROM {$price_table}");
         // Merge 'weight', 'dimensions' and 'donation' columns to a price 'settings' record
         sDB::query("INSERT INTO {$meta_table} (parent, context, type, name, value, created, modified)\n\t\t\t\t\t\t\tSELECT id, 'price', 'meta', 'settings',\n\t\t\t\t\t\t\tCONCAT('a:2:{s:10:\"dimensions\";',\n\t\t\t\t\t\t\t\tIF(weight = 0 AND dimensions = '0', 'a:0:{}',\n\t\t\t\t\t\t\t\t\tIF(dimensions = '0',\n\t\t\t\t\t\t\t\t\t\tCONCAT(\n\t\t\t\t\t\t\t\t\t\t\t'a:1:{s:6:\"weight\";s:', CHAR_LENGTH(weight), ':\"', weight, '\";}'\n\t\t\t\t\t\t\t\t\t\t), dimensions\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t), 's:8:\"donation\";', IF(donation='', 'N;', donation), '}'\n\t\t\t\t\t\t\t), created, modified FROM {$price_table}");
     }
     // END if ($db_version <= 1135)
     if ($db_version <= 1145) {
         // Update purchase gateway property to use gateway class names
         // for proper order event handling on 1.1-generated orders
         $gateways = array('PayPal Standard' => 'PayPalStandard', 'PayPal Expresss' => 'PayPalExpress', 'PayPal Pro' => 'PayPalPro', '2Checkout.com' => '_2Checkout', 'Authorize.Net' => 'AuthorizeNet', 'Google Checkout' => 'GoogleCheckout', 'HSBC ePayments' => 'HSBCepayments', 'iDeal Mollie' => 'iDealMollie', 'Manual Processing' => 'ManualProcessing', 'Merchant Warrior' => 'MerchantWarrior', 'Offline Payment' => 'OfflinePayment', 'PayPal Payflow Pro' => 'PayflowPro', 'Test Mode' => 'TestMode');
         foreach ($gateways as $name => $classname) {
             sDB::query("UPDATE {$purchase_table} SET gateway='{$classname}' WHERE gateway='{$name}'");
         }
     }
     // END if ($db_version <= 1145)
     if ($db_version <= 1148) {
         $price_table = ShoppDatabaseObject::tablename('price');
         sDB::query("UPDATE {$price_table} SET optionkey=(options*7001) WHERE context='addon'");
     }
     if ($db_verison <= 1150) {
         $meta_table = ShoppDatabaseObject::tablename('meta');
         sDB::query("DELETE {$meta_table} FROM {$meta_table} LEFT OUTER JOIN (SELECT MAX(id) AS keepid FROM {$meta_table} WHERE context='category' AND type='meta' GROUP BY parent, name) AS keepRowTable ON {$meta_table}.id = keepRowTable.keepid WHERE keepRowTable.keepid IS NULL AND context='category' AND type='meta'");
     }
 }
开发者ID:crunnells,项目名称:shopp,代码行数:101,代码来源:Install.php

示例10: shipping

 /**
  * Renders the shipping settings screen and processes updates
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return void
  **/
 public function shipping()
 {
     if (!current_user_can('shopp_settings_shipping')) {
         wp_die(__('You do not have sufficient permissions to access this page.'));
     }
     $sub = 'settings';
     $term_recount = false;
     if (shopp_setting_enabled('shipping')) {
         $sub = 'rates';
     }
     if (isset($_GET['sub']) && in_array($_GET['sub'], array_keys($this->subscreens))) {
         $sub = $_GET['sub'];
     }
     if (!empty($_POST['save']) && empty($_POST['module'])) {
         check_admin_referer('shopp-settings-shipping');
         $_POST['settings']['order_shipfee'] = Shopp::floatval($_POST['settings']['order_shipfee']);
         // Recount terms when this setting changes
         if (isset($_POST['settings']['inventory']) && $_POST['settings']['inventory'] != shopp_setting('inventory')) {
             $term_recount = true;
         }
         shopp_set_formsettings();
         $updated = __('Shipping settings saved.', 'Shopp');
     }
     // Handle ship rates UI
     if ('rates' == $sub && 'on' == shopp_setting('shipping')) {
         return $this->shiprates();
     }
     if ($term_recount) {
         $taxonomy = ProductCategory::$taxon;
         $terms = get_terms($taxonomy, array('hide_empty' => 0, 'fields' => 'ids'));
         if (!empty($terms)) {
             wp_update_term_count_now($terms, $taxonomy);
         }
     }
     $carrierdata = Lookup::shipcarriers();
     $serviceareas = array('*', ShoppBaseLocale()->code());
     foreach ($carrierdata as $c => $record) {
         if (!in_array($record->areas, $serviceareas)) {
             continue;
         }
         $carriers[$c] = $record->name;
     }
     unset($carrierdata);
     $shipping_carriers = shopp_setting('shipping_carriers');
     if (empty($shipping_carriers)) {
         $shipping_carriers = array_keys($carriers);
     }
     $imperial = 'imperial' == ShoppBaseLocale()->units();
     $weights = $imperial ? array('oz' => Shopp::__('ounces (oz)'), 'lb' => Shopp::__('pounds (lbs)')) : array('g' => Shopp::__('gram (g)'), 'kg' => Shopp::__('kilogram (kg)'));
     $weightsmenu = menuoptions($weights, shopp_setting('weight_unit'), true);
     $dimensions = $imperial ? array('in' => Shopp::__('inches (in)'), 'ft' => Shopp::__('feet (ft)')) : array('cm' => Shopp::__('centimeters (cm)'), 'm' => Shopp::__('meters (m)'));
     $dimsmenu = menuoptions($dimensions, shopp_setting('dimension_unit'), true);
     $rates = shopp_setting('shipping_rates');
     if (!empty($rates)) {
         ksort($rates);
     }
     $lowstock = shopp_setting('lowstock_level');
     if (empty($lowstock)) {
         $lowstock = 0;
     }
     include $this->ui('shipping.php');
 }
开发者ID:forthrobot,项目名称:inuvik,代码行数:70,代码来源:System.php

示例11: import_categories

 /**
  * Import the web links categories
  *
  * @return int Number of imported categories
  */
 private function import_categories()
 {
     $cat_count = 0;
     $taxonomy = 'link_category';
     $this->categories = array();
     $categories = $this->plugin->get_component_categories('com_weblinks', 'cl');
     if (is_array($categories)) {
         $terms = array();
         foreach ($categories as $category) {
             $obj_cat = get_term_by('slug', $category['name'], $taxonomy);
             if ($obj_cat !== false) {
                 $this->categories[$category['name']] = $obj_cat->term_id;
                 continue;
                 // Do not import already imported category
             }
             // Insert the category
             $new_category = array('cat_name' => $category['title'], 'category_description' => $category['description'], 'category_nicename' => $category['name'], 'taxonomy' => $taxonomy);
             // Hook before inserting the category
             $new_category = apply_filters('fgj2wp_pre_insert_category', $new_category, $category);
             $cat_id = wp_insert_category($new_category, true);
             if (!is_a($cat_id, 'WP_Error')) {
                 $cat_count++;
                 $terms[] = $cat_id;
                 $this->categories[$category['name']] = $cat_id;
             } else {
                 $this->plugin->display_admin_error(__('Error:', 'fgj2wp') . ' ' . print_r($cat_id, true));
                 continue;
             }
             // Hook after inserting the category
             do_action('fgj2wp_post_insert_category', $cat_id, $category);
         }
         // Update cache
         if (!empty($terms)) {
             wp_update_term_count_now($terms, $taxonomy);
             $this->plugin->clean_cache($terms);
         }
     }
     return $cat_count;
 }
开发者ID:ryan2407,项目名称:Vision,代码行数:44,代码来源:class-fg-joomla-to-wordpress-weblinks.php

示例12: terms_tax_count

 /**
  * Recount the items for a taxonomy
  * 
  * @return boolean
  */
 private function terms_tax_count($taxonomy)
 {
     $terms = get_terms(array($taxonomy));
     // Get the term taxonomies
     $terms_taxonomies = array();
     foreach ($terms as $term) {
         $terms_taxonomies[] = $term->term_taxonomy_id;
     }
     if (!empty($terms_taxonomies)) {
         return wp_update_term_count_now($terms_taxonomies, $taxonomy);
     } else {
         return true;
     }
 }
开发者ID:ryan2407,项目名称:Vision,代码行数:19,代码来源:class-fg-joomla-to-wordpress-admin.php

示例13: assign_terms

 /**
  * Bulk insert rows into the term_relationships table
  * @param array List of post IDs (or oother object IDs)
  * @param array List of term IDs
  * @param mixed WP taxonomy object
  * @return bool Success of insert
  */
 function assign_terms($object_ids = array(), $term_taxonomy_ids = array(), $taxonomy = false)
 {
     global $wpdb;
     if (empty($object_ids) || empty($term_taxonomy_ids) || empty($taxonomy)) {
         return false;
     }
     $wpdb->query("SET unique_checks=0");
     // Insert the the relationships from post_ids => $defaults
     $query = "INSERT INTO `{$wpdb->term_relationships}` (\n      object_id, term_taxonomy_id\n    ) VALUES";
     foreach ($term_taxonomy_ids as $term_taxonomy_id) {
         foreach ($object_ids as $object_id) {
             $query .= $wpdb->prepare("(%d, %d),", $object_id, $term_taxonomy_id);
         }
     }
     $query = rtrim($query, ',');
     $a = $wpdb->query($query);
     // Commit the changes
     $wpdb->query("SET unique_checks=1");
     // Update the "total" count for each term that was affected
     wp_update_term_count_now($term_taxonomy_ids, $taxonomy->name);
     return true;
 }
开发者ID:britco,项目名称:wp-default-terms,代码行数:29,代码来源:actions.php


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