本文整理汇总了PHP中wp_defer_comment_counting函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_defer_comment_counting函数的具体用法?PHP wp_defer_comment_counting怎么用?PHP wp_defer_comment_counting使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_defer_comment_counting函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import_start
/**
* Parses the XML file and prepares us for the task of processing parsed data
*
* @param string $file Path to the WXR file for importing
*/
function import_start($file)
{
if (!is_file($file)) {
echo '<p><strong>' . __('Sorry, there has been an error.', 'anno') . '</strong><br />';
echo __('The file does not exist, please try again.', 'anno') . '</p>';
$this->footer();
die;
}
$import_data = $this->parse($file);
if (is_wp_error($import_data)) {
echo '<p><strong>' . __('Sorry, there has been an error.', 'anno') . '</strong><br />';
echo esc_html($import_data->get_error_message()) . '</p>';
$this->footer();
die;
}
$this->version = $import_data['version'];
$this->get_authors_from_import($import_data);
$this->posts = $import_data['posts'];
$this->terms = $import_data['terms'];
$this->categories = $import_data['categories'];
$this->tags = $import_data['tags'];
$this->base_url = esc_url($import_data['base_url']);
wp_defer_term_counting(true);
wp_defer_comment_counting(true);
do_action('import_start');
}
示例2: import_start
function import_start($file)
{
if (!is_file($file)) {
echo '<p><strong>' . __('Sorry, there has been an error.', 'wordpress-importer') . '</strong><br/>';
echo __('The file does not exist, please try again.', 'wordpress-importer') . '</p>';
$this->footer();
die;
}
$import_data = $this->parse($file);
if (is_wp_error($import_data)) {
echo '<p><strong>' . __('Sorry, there has been an error.', 'wordpress-importer') . '</strong><br/>';
echo esc_html($import_data->get_error_message()) . '</p>';
$this->footer();
die;
}
$this->version = $import_data['version'];
$this->get_authors_from_import($import_data);
$this->posts = $import_data['posts'];
$this->terms = $import_data['terms'];
$this->categories = $import_data['categories'];
$this->tags = $import_data['tags'];
$this->base_url = esc_url($import_data['base_url']);
// fix for: 'http://localhost/justmarriedmarried' = str_replace('http://localhost/just', 'http://localhost/justmarried', 'http://localhost/justmarried')
$this->wrong_replace = network_home_url() !== ($wrong_replace = str_replace($this->base_url, network_home_url(), network_home_url())) ? $wrong_replace : false;
wp_defer_term_counting(true);
wp_defer_comment_counting(true);
do_action('import_start');
// deprecated
do_action('tf_ext_import_start');
}
示例3: import_end
function import_end()
{
// Switch off importing flag and flush rewrite cache
wp_defer_term_counting(false);
wp_defer_comment_counting(true);
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
示例4: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
do_action('import_end');
}
示例5: import_end
public function import_end()
{
wp_cache_flush();
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
echo '<p>' . __('All done.', 'wordpress-importer') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'wordpress-importer') . '</a>' . '</p>';
echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'wordpress-importer') . '</p>';
do_action('import_end');
}
示例6: import_start
/**
* Parses the XML file and prepares us for the task of processing parsed data
*
* @param string $file Path to the WXR file for importing
*/
function import_start($file)
{
if (!is_file($file)) {
echo '<p><strong>' . __('Sorry, there has been an error.', 'anno') . '</strong><br />';
echo __('The file does not exist, please try again.', 'anno') . '</p>';
$this->footer();
die;
}
$import_data = $this->parse($file);
if (is_wp_error($import_data)) {
echo '<p><strong>' . __('Sorry, there has been an error.', 'anno') . '</strong><br />';
echo esc_html($import_data->get_error_message()) . '</p>';
$this->footer();
die;
}
// Validation error likely
if (isset($import_data['status']) && $import_data['status'] == 'error') {
echo '<h3>' . __('There were the following errors while trying to validate your XML. Please correct them and try again.', 'anno') . '</h3>';
foreach ($import_data['errors'] as $error) {
$error_lines[] = $error['line'];
echo '<div class="error">' . $error['fullMessage'] . '.</div>';
}
$this->output_XML($import_data['content'], $error_lines);
$this->footer();
die;
}
$this->version = $import_data['version'];
$this->get_authors_from_import($import_data);
$this->posts = $import_data['posts'];
$this->terms = $import_data['terms'];
$this->categories = $import_data['categories'];
$this->tags = $import_data['tags'];
$this->base_url = esc_url($import_data['base_url']);
wp_defer_term_counting(true);
wp_defer_comment_counting(true);
do_action('import_start');
}
示例7: cherry_plugin_import_end
function cherry_plugin_import_end()
{
wp_cache_flush();
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
update_option('cherry_sample_data', 1);
cherry_plugin_set_to_draft('hello-world');
cherry_plugin_set_to_draft('sample-page');
settings();
do_action('cherry_plugin_import_end');
session_name("import_xml");
session_destroy();
exit('import_json');
}
示例8: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
echo '<p>' . __('All done.', 'wordpress-importer') . ' <a href="' . admin_url() . '">' . __('Have fun!', 'wordpress-importer') . '</a></p>';
echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'wordpress-importer') . '</p>';
do_action('import_end');
// deprecated
do_action('tf_ext_import_end', array('version' => @$this->version, 'authors' => @$this->authors, 'posts' => @$this->posts, 'terms' => @$this->terms, 'categories' => @$this->categories, 'tags' => @$this->tags, 'base_url' => @$this->base_url, 'processed_authors' => @$this->processed_authors, 'author_mapping' => @$this->author_mapping, 'processed_terms' => @$this->processed_terms, 'processed_posts' => @$this->processed_posts, 'post_orphans' => @$this->post_orphans, 'processed_menu_items' => @$this->processed_menu_items, 'menu_item_orphans' => @$this->menu_item_orphans, 'missing_menu_items' => @$this->missing_menu_items, 'fetch_attachments' => @$this->fetch_attachments, 'url_remap' => @$this->url_remap, 'featured_images' => @$this->featured_images, 'old_site_url' => @$this->old_site_url, 'new_site_url' => @$this->new_site_url, 'upload_url_old' => @$this->upload_url_old, 'install_url' => @$this->install_url, 'tfuse_options' => @$this->tfuse_options));
}
示例9: import_end
/**
* Performs post-import cleanup of files and the cache
*/
public function import_end()
{
wp_cache_flush();
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
do_action('import_end');
}
示例10: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
echo '<p>' . __('Import complete.', 'wc_customer_relationship_manager') . '</p>';
echo '<p>' . sprintf(_n('%d Customer has been successfully added.', '%d Customers has been successfully added.', $this->row, 'wc_customer_relationship_manager'), $this->row) . '</p>';
if (!empty($this->groups_added)) {
echo '<p>' . sprintf(_n('%d Group has been successfully added.', '%d Groups has been successfully added.', count($this->groups_added), 'wc_customer_relationship_manager'), count($this->groups_added)) . ' (' . implode(', ', $this->groups_added) . ')</p>';
}
if (!empty($this->statuses_added)) {
echo '<p>' . sprintf(_n('%d Customer status has been successfully added.', '%d Customer statuses has been successfully added.', count($this->statuses_added), 'wc_customer_relationship_manager'), count($this->statuses_added)) . ' (' . implode(', ', $this->statuses_added) . ')</p>';
}
if (!empty($this->not_import)) {
echo '<p>' . sprintf(_n('%d Customer was not added.', '%d Customers was not added.', count($this->not_import), 'wc_customer_relationship_manager'), count($this->not_import)) . '</p>';
echo '<code>';
foreach ($this->not_import as $key => $value) {
echo $value[0] . '<br>';
}
echo '</code>';
}
do_action('wcrm_import_end');
}
示例11: 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');
}
示例12: import_end
/**
* Performs post-import cleanup of files and the cache
*/
function import_end()
{
wp_import_cleanup($this->id);
wp_cache_flush();
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
echo '<p>' . __('All done.', 'wordpress-importer') . '</p>';
do_action('import_end');
}
示例13: enable_comment_counting
public function enable_comment_counting()
{
wp_defer_comment_counting(false);
}
示例14: import_end
/**
* Performs post-import cleanup of files and the cache
*/
public function import_end()
{
//wp_cache_flush(); Stops output in some hosting environments
foreach (get_taxonomies() as $tax) {
delete_option("{$tax}_children");
_get_term_hierarchy($tax);
}
wp_defer_term_counting(false);
wp_defer_comment_counting(false);
do_action('import_end');
}
示例15: status_changes_convert_questions
function status_changes_convert_questions($n = 50, $offset = 0)
{
global $wpdb;
wp_defer_comment_counting(true);
$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->users} ");
if (0 == $user_count_result) {
return true;
}
// Calculate if this is the last page
if (0 == $offset) {
$current_page = 1;
} else {
$current_page = intval($offset / $n);
}
$total_pages = ceil($user_count_result / $n);
$users_sql = "SELECT ID FROM {$wpdb->users} ORDER BY ID ASC LIMIT %d OFFSET %d";
$answers_sql = "SELECT * FROM {$wpdb->comments} WHERE comment_type = 'sensei_user_answer' AND user_id = %d GROUP BY comment_post_ID ";
$grades_sql = "SELECT comment_post_ID, comment_content FROM {$wpdb->comments} WHERE comment_type = 'sensei_user_grade' AND user_id = %d GROUP BY comment_post_ID ";
$notes_sql = "SELECT comment_post_ID, comment_content FROM {$wpdb->comments} WHERE comment_type = 'sensei_answer_notes' AND user_id = %d GROUP BY comment_post_ID ";
$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
foreach ($user_ids as $user_id) {
$answer_grades = $answer_notes = array();
// Pre-process the answer grades
$_answer_grades = $wpdb->get_results($wpdb->prepare($grades_sql, $user_id), ARRAY_A);
foreach ($_answer_grades as $answer_grade) {
// This will overwrite existing entries with the newer ones
$answer_grades[$answer_grade['comment_post_ID']] = $answer_grade['comment_content'];
}
unset($_answer_grades);
// Pre-process the answer notes
$_answer_notes = $wpdb->get_results($wpdb->prepare($notes_sql, $user_id), ARRAY_A);
foreach ($_answer_notes as $answer_note) {
// This will overwrite existing entries with the newer ones
$answer_notes[$answer_note['comment_post_ID']] = $answer_note['comment_content'];
}
unset($_answer_notes);
// Grab all the questions for the user
$sql = $wpdb->prepare($answers_sql, $user_id);
$answers = $wpdb->get_results($sql, ARRAY_A);
foreach ($answers as $answer) {
// Excape data
$answer = wp_slash($answer);
$comment_ID = $answer['comment_ID'];
$meta_data = array();
// Check if the question has been graded, add as meta
if (!empty($answer_grades[$answer['comment_post_ID']])) {
$meta_data['user_grade'] = $answer_grades[$answer['comment_post_ID']];
}
// Check if there is an answer note, add as meta
if (!empty($answer_notes[$answer['comment_post_ID']])) {
$meta_data['answer_note'] = $answer_notes[$answer['comment_post_ID']];
}
// Wipe the unnessary data from the main comment
$data = array('comment_author' => '', 'comment_author_email' => '', 'comment_author_url' => '', 'comment_author_IP' => '', 'comment_agent' => '');
$data = array_merge($answer, $data);
$rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
if ($rval) {
if (!empty($meta_data)) {
foreach ($meta_data as $key => $value) {
// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
if ($wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->commentmeta} WHERE comment_id = %d AND meta_key = %s ", $comment_ID, $key))) {
continue;
// Found the meta data already
}
$result = $wpdb->insert($wpdb->commentmeta, array('comment_id' => $comment_ID, 'meta_key' => $key, 'meta_value' => $value));
}
}
}
}
}
$wpdb->flush();
if ($current_page == $total_pages) {
return true;
} else {
return false;
}
}