예제 #1
0
/**
 * Perform term count update immediately.
 *
 * @since 2.5.0
 *
 * @param array  $terms    The term_taxonomy_id of terms to update.
 * @param string $taxonomy The context of the term.
 * @return true Always true when complete.
 */
function wp_update_term_count_now($terms, $taxonomy)
{
    $terms = array_map('intval', $terms);
    $taxonomy = get_taxonomy($taxonomy);
    if (!empty($taxonomy->update_count_callback)) {
        call_user_func($taxonomy->update_count_callback, $terms, $taxonomy);
    } else {
        $object_types = (array) $taxonomy->object_type;
        foreach ($object_types as &$object_type) {
            if (0 === strpos($object_type, 'attachment:')) {
                list($object_type) = explode(':', $object_type);
            }
        }
        if ($object_types == array_filter($object_types, 'post_type_exists')) {
            // Only post types are attached to this taxonomy
            _update_post_term_count($terms, $taxonomy);
        } else {
            // Default count updater
            _update_generic_term_count($terms, $taxonomy);
        }
    }
    clean_term_cache($terms, '', false);
    return true;
}
예제 #2
0
 function updateTaxCount()
 {
     global $wpdb;
     $arg_tax = $wpdb->get_col("SELECT term_taxonomy_id as id  FROM {$wpdb->term_taxonomy}");
     $taxonomy = new stdClass();
     $taxonomy->name = '';
     _update_generic_term_count($arg_tax, $taxonomy);
 }
 /**
  * Update the term count for a user and taxonomy
  *
  * @since 0.1.0
  *
  * @param int $user_id
  */
 public function update_term_user_count($terms = array(), $taxonomy = '')
 {
     // Fallback to this taxonomy
     if (empty($taxonomy)) {
         $taxonomy = $this->taxonomy;
     }
     // Update counts
     _update_generic_term_count($terms, $taxonomy);
 }
 /**
  * ipn_response_data_handler helper function use for further process 
  * @since    1.0.0
  * return boolean
  */
 public function ipn_response_data_handler($posted = null)
 {
     /**
      * Create array for store data to post table.
      */
     global $wp;
     if (isset($posted) && !empty($posted)) {
         /**
          * check payment status is available because some of PayPal transaction payment_status is not available 
          */
         if (isset($posted['payment_status']) && !empty($posted['payment_status'])) {
             $payment_status = ucfirst(str_replace('_', ' ', $posted['payment_status']));
             $term = term_exists($payment_status, 'paypal_ipn_type');
             if ($term !== 0 && $term !== null) {
             } else {
                 $term = wp_insert_term($payment_status, 'paypal_ipn_type', array('slug' => $posted['payment_status']));
             }
         }
         if (isset($posted['txn_id'])) {
             $paypal_txn_id = $posted['txn_id'];
         } elseif (isset($posted['subscr_id'])) {
             $paypal_txn_id = $posted['subscr_id'];
         } elseif (isset($posted['recurring_payment_id'])) {
             $paypal_txn_id = $posted['recurring_payment_id'];
         } elseif (isset($posted['masspay_txn_id'])) {
             $paypal_txn_id = $posted['masspay_txn_id'];
         } elseif (isset($posted['transaction_id'])) {
             $paypal_txn_id = $posted['transaction_id'];
         } elseif (isset($posted['account_key'])) {
             $paypal_txn_id = $posted['account_key'];
         } elseif (isset($posted['preapproval_key'])) {
             $paypal_txn_id = $posted['preapproval_key'];
         } elseif (isset($posted['pay_key'])) {
             $paypal_txn_id = $posted['pay_key'];
         } elseif (isset($posted['mp_id'])) {
             $paypal_txn_id = $posted['mp_id'];
         }
         $new_posted = $this->paypal_ipn_for_wordpress_parse_ipn_data($posted);
         //txn_type_own
         /**
          *  development hook paypal_ipn_for_wordpress_mailchimp_handler 
          */
         if ('yes' == get_option('enable_mailchimp')) {
             if (isset($new_posted['txn_type_own']) && !empty($new_posted['txn_type_own'])) {
                 $txn_type_own = $new_posted['txn_type_own'] == 'recurring_payments_p' ? 'recurring_payment_profile' : $new_posted['txn_type_own'];
                 if ('yes' == get_option($txn_type_own)) {
                     do_action('paypal_ipn_for_wordpress_mailchimp_handler', $posted);
                 }
             }
         }
         if (isset($new_posted['txn_type_own'])) {
             $post_status = $new_posted['txn_type_own'];
         } elseif (isset($posted['txn_type'])) {
             $post_status = $new_posted['txn_type'];
         } elseif (isset($posted['transaction_type'])) {
             $post_status = $new_posted['transaction_type'];
         } else {
             $post_status = 'Not-Available';
         }
         if ($this->paypal_ipn_for_wordpress_exist_post_by_title($paypal_txn_id) == false) {
             $insert_ipn_array = array('ID' => '', 'post_type' => 'paypal_ipn', 'post_status' => $post_status, 'post_title' => $paypal_txn_id);
             $post_id = wp_insert_post($insert_ipn_array);
             /**
              * check payment status is available because some of PayPal transaction payment_status is not available 
              */
             if (isset($posted['payment_status']) && !empty($posted['payment_status'])) {
                 $tag[] = $term['term_id'];
                 $update_term = wp_set_post_terms($post_id, $tag, 'paypal_ipn_type');
                 _update_generic_term_count($term['term_taxonomy_id'], 'paypal_ipn_type');
             }
             $this->ipn_response_postmeta_handler($post_id, $posted);
         } else {
             $post_id = $this->paypal_ipn_for_wordpress_exist_post_by_title($paypal_txn_id);
             wp_update_post(array('ID' => $post_id, 'post_status' => $post_status));
             $this->ipn_response_postmeta_handler($post_id, $posted);
         }
     }
 }