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


PHP update_post_meta函数代码示例

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


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

示例1: post_save

 /**
  * Save Force SSL option to post or page
  *
  * @param int $post_id
  * @return int $post_id
  */
 public function post_save($post_id)
 {
     if (array_key_exists($this->getPlugin()->getSlug(), $_POST)) {
         if (!wp_verify_nonce($_POST[$this->getPlugin()->getSlug()], $this->getPlugin()->getSlug())) {
             return $post_id;
         }
         if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
             return $post_id;
         }
         if (@$_POST['post_type'] == 'page') {
             if (!current_user_can('edit_page', $post_id)) {
                 return $post_id;
             }
         } else {
             if (!current_user_can('edit_post', $post_id)) {
                 return $post_id;
             }
         }
         $force_ssl = @$_POST['force_ssl'] == 1 ? true : false;
         if ($force_ssl) {
             update_post_meta($post_id, 'force_ssl', 1);
         } else {
             delete_post_meta($post_id, 'force_ssl');
         }
         $force_ssl_children = @$_POST['force_ssl_children'] == 1 ? true : false;
         if ($force_ssl_children) {
             update_post_meta($post_id, 'force_ssl_children', 1);
         } else {
             delete_post_meta($post_id, 'force_ssl_children');
         }
     }
     return $post_id;
 }
开发者ID:tommbaker,项目名称:platform-www,代码行数:39,代码来源:Post.php

示例2: setUp

 public function setUp()
 {
     global $wpdb;
     parent::setUp();
     register_taxonomy('edu_test_tax_1', 'post');
     register_taxonomy('edu_test_tax_2', 'post');
     $t1 = wp_insert_term('Edu', 'edu_test_tax_1');
     $t2 = wp_insert_term('Edu', 'edu_test_tax_2');
     $t3 = wp_insert_term('Edu', 'ib_educator_category');
     $t4 = wp_insert_term('Mathematics', 'ib_educator_category');
     // Arbitrary term.
     $wpdb->update($wpdb->term_taxonomy, array('term_id' => $t1['term_id']), array('term_taxonomy_id' => $t2['term_taxonomy_id']), array('%d'), array('%d'));
     $wpdb->update($wpdb->term_taxonomy, array('term_id' => $t1['term_id']), array('term_taxonomy_id' => $t3['term_taxonomy_id']), array('%d'), array('%d'));
     $t2['term_id'] = $t1['term_id'];
     $t3['term_id'] = $t1['term_id'];
     // Create membership.
     $post_id = wp_insert_post(array('post_type' => 'ib_edu_membership', 'post_name' => 'edu-membership-1', 'post_title' => 'edu membership 1', 'post_status' => 'publish'));
     $ms = Edr_Memberships::get_instance();
     $meta = $ms->get_membership_meta();
     $meta['price'] = '10.05';
     $meta['period'] = '';
     $meta['duration'] = '';
     $meta['categories'] = array($t3['term_id'], $t4['term_id']);
     update_post_meta($post_id, '_ib_educator_membership', $meta);
     $this->posts[] = $post_id;
     $this->terms = array('term1' => $t1, 'term2' => $t2, 'term3' => $t3, 'term4' => $t4);
 }
开发者ID:zaro,项目名称:ibeducator,代码行数:27,代码来源:test-split-shared-term.php

示例3: add_post

 /**
  * Adds the post to the relevant site
  *
  * @param $post
  *
  * @param $blog
  *
  * @return int|\WP_Error
  */
 public function add_post($post, $blog)
 {
     if (!$blog || $this->post_exists($post, $blog)) {
         return FALSE;
     }
     $original_post_id = $post->ID;
     // store temp so that we can return it to the original post
     $source_content_id = Wpml2mlp_Helper::get_default_post_ID($post);
     $meta = get_post_meta($post->ID);
     $post->ID = NULL;
     // reset the post_id, new one will be created
     switch_to_blog((int) $blog['blog_id']);
     $new_post_id = wp_insert_post((array) $post);
     if ($new_post_id > 0) {
         foreach ($meta as $key => $value) {
             update_post_meta($new_post_id, $key, $value[0]);
         }
     }
     restore_current_blog();
     if (0 < $new_post_id) {
         $this->content_relations->set_relation(Wpml2mlp_Helper::get_default_blog(), (int) $blog['blog_id'], $source_content_id, $new_post_id, $post->post_type);
     }
     $post->ID = $original_post_id;
     return $new_post_id;
 }
开发者ID:JonZiemlich,项目名称:wpml2mlp,代码行数:34,代码来源:Wpml2mlp_Post_Creator.php

示例4: perpageath_save_postdata

/**
 * When the post is saved, saves our custom data.
 *
 * @param int $post_id The ID of the post being saved.
 */
function perpageath_save_postdata($post_id)
{
    /*
     * We need to verify this came from the our screen and with proper authorization,
     * because save_post can be triggered at other times.
     */
    // Check if our nonce is set.
    if (!isset($_POST['athcontent'])) {
        return $post_id;
    }
    $nonce = $_POST['athcontent'];
    // Verify that the nonce is valid.
    if (!wp_verify_nonce($nonce, 'athcallback')) {
        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 save the data now. */
    // Sanitize user input.
    $mydata = esc_sql(str_replace(array("\r\n", "\r", "\n"), '%BREAK%', $_POST['per-page-ath']));
    // Update the meta field in the database.
    update_post_meta($post_id, 'per-page-ath-content', $mydata);
}
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:40,代码来源:perpagehead.php

示例5: mc4wp_pro_install

/**
 * Runs on plugin activations
 * - Transfer any settings which may have been set in the Lite version of the plugin
 * - Creates a post type 'mc4wp-form' and enters the form mark-up from the Lite version
 */
function mc4wp_pro_install()
{
    // check if PRO option exists and contains data entered by user
    $pro_options = get_option('mc4wp', false);
    if ($pro_options !== false) {
        return false;
    }
    $default_options = array();
    $default_options['general'] = array('api_key' => '', 'license_key' => '');
    $default_options['checkbox'] = array('label' => 'Sign me up for the newsletter!', 'precheck' => 1, 'css' => 0, 'show_at_comment_form' => 0, 'show_at_registration_form' => 0, 'show_at_multisite_form' => 0, 'show_at_buddypress_form' => 0, 'show_at_edd_checkout' => 0, 'show_at_woocommerce_checkout' => 0, 'show_at_bbpress_forms' => 0, 'lists' => array(), 'double_optin' => 1, 'send_welcome' => 0);
    $default_options['form'] = array('css' => 0, 'custom_theme_color' => '#1af', 'ajax' => 1, 'double_optin' => 1, 'update_existing' => 0, 'replace_interests' => 1, 'send_welcome' => 0, 'text_success' => 'Thank you, your sign-up request was successful! Please check your e-mail inbox.', 'text_error' => 'Oops. Something went wrong. Please try again later.', 'text_invalid_email' => 'Please provide a valid email address.', 'text_already_subscribed' => 'Given email address is already subscribed, thank you!', 'redirect' => '', 'hide_after_success' => 0, 'send_email_copy' => 0);
    $lite_settings = array('general' => (array) get_option('mc4wp_lite'), 'checkbox' => (array) get_option('mc4wp_lite_checkbox'), 'form' => (array) get_option('mc4wp_lite_form'));
    foreach ($default_options as $group_key => $options) {
        foreach ($options as $option_key => $option_value) {
            if (isset($lite_settings[$group_key][$option_key]) && !empty($lite_settings[$group_key][$option_key])) {
                $default_options[$group_key][$option_key] = $lite_settings[$group_key][$option_key];
            }
        }
    }
    // Transfer form from Lite, but only if no Pro forms exist yet.
    $forms = get_posts(array('post_type' => 'mc4wp-form', 'post_status' => 'publish'));
    if (false == $forms) {
        // no forms found, try to transfer from lite.
        $form_markup = isset($lite_settings['form']['markup']) ? $lite_settings['form']['markup'] : "<p>\n\t<label for=\"mc4wp_email\">Email address: </label>\n\t<input type=\"email\" id=\"mc4wp_email\" name=\"EMAIL\" required placeholder=\"Your email address\" />\n</p>\n\n<p>\n\t<input type=\"submit\" value=\"Sign up\" />\n</p>";
        $form_ID = wp_insert_post(array('post_type' => 'mc4wp-form', 'post_title' => 'Sign-Up Form #1', 'post_content' => $form_markup, 'post_status' => 'publish'));
        $lists = isset($lite_settings['form']['lists']) ? $lite_settings['form']['lists'] : array();
        update_post_meta($form_ID, '_mc4wp_settings', array('lists' => $lists));
        update_option('mc4wp_default_form_id', $form_ID);
    }
    // store options
    update_option('mc4wp', $default_options['general']);
    update_option('mc4wp_checkbox', $default_options['checkbox']);
    update_option('mc4wp_form', $default_options['form']);
}
开发者ID:Infernosaint,项目名称:WPSetupTest2,代码行数:39,代码来源:install.php

示例6: save_meta_box_data

 function save_meta_box_data($post_id)
 {
     if (!isset($_POST['portfolio_meta_box_nonce'])) {
         return;
     }
     // Verify that the nonce is valid.
     if (!wp_verify_nonce($_POST['portfolio_meta_box_nonce'], 'portfolio_meta_box')) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (isset($_POST['post_type']) && 'portfolio' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
     }
     if (!isset($_POST['publishing_year'])) {
         return;
     }
     $my_data = sanitize_text_field($_POST['publishing_year']);
     update_post_meta($post_id, 'publishing_year', $my_data);
 }
开发者ID:amrollah,项目名称:web-engineering,代码行数:27,代码来源:cpt.php

示例7: do_save

 public function do_save($return_val, $data, $module)
 {
     if (empty($data['attachment_url'])) {
         return false;
     }
     $bits = file_get_contents($data['attachment_url']);
     $filename = $this->faker->uuid() . '.jpg';
     $upload = wp_upload_bits($filename, null, $bits);
     $data['guid'] = $upload['url'];
     $data['post_mime_type'] = 'image/jpeg';
     // Insert the attachment.
     $attach_id = wp_insert_attachment($data, $upload['file'], 0);
     if (!is_numeric($attach_id)) {
         return false;
     }
     if (!function_exists('wp_generate_attachment_metadata')) {
         // Make sure that this file is included, as wp_generate_attachment_metadata() depends on it.
         require_once ABSPATH . 'wp-admin/includes/image.php';
     }
     // Generate the metadata for the attachment, and update the database record.
     update_post_meta($attach_id, '_wp_attachment_metadata', wp_generate_attachment_metadata($attach_id, $upload['file']));
     // Flag the Object as FakerPress
     update_post_meta($attach_id, self::$flag, 1);
     return $attach_id;
 }
开发者ID:KiyaDigital,项目名称:tvarchive-canonical_wordpress,代码行数:25,代码来源:attachment.php

示例8: update

 /**
  *  updates the post_meta of the current object with the given value
  *
  * @param string $field
  * @param mixed $value
  * @nodoc
  */
 function update($field, $value)
 {
     if (isset($this->ID)) {
         update_post_meta($this->ID, $field, $value);
         $this->{$field} = $value;
     }
 }
开发者ID:pedrokoblitz,项目名称:centro-dialogo-aberto,代码行数:14,代码来源:timber-post.php

示例9: cresta_save_meta_box_data

function cresta_save_meta_box_data($post_id)
{
    if (!isset($_POST['cresta_meta_box_nonce'])) {
        return;
    }
    if (!wp_verify_nonce($_POST['cresta_meta_box_nonce'], 'cresta_meta_box')) {
        return;
    }
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
    }
    if (isset($_POST['cresta_new_field'])) {
        update_post_meta($post_id, '_get_cresta_plugin', $_POST['cresta_new_field']);
    } else {
        delete_post_meta($post_id, '_get_cresta_plugin');
    }
}
开发者ID:azkanurunala,项目名称:ThetaGlobal,代码行数:26,代码来源:cresta-metabox.php

示例10: save

 /**
  * Save metabox data.
  *
  * @param  int $post_id Current post type ID.
  *
  * @return void
  */
 public function save($post_id)
 {
     // Verify nonce.
     if (!isset($_POST['wcboleto_metabox_nonce']) || !wp_verify_nonce($_POST['wcboleto_metabox_nonce'], basename(__FILE__))) {
         return $post_id;
     }
     // Verify if this is an auto save routine.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // Check permissions.
     if ('shop_order' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return $post_id;
         }
     } elseif (!current_user_can('edit_post', $post_id)) {
         return $post_id;
     }
     if (isset($_POST['wcboleto_expiration_date']) && !empty($_POST['wcboleto_expiration_date'])) {
         // Gets boleto data.
         $boleto_data = get_post_meta($post_id, 'wc_boleto_data', true);
         $boleto_data['data_vencimento'] = sanitize_text_field($_POST['wcboleto_expiration_date']);
         // Update boleto data.
         update_post_meta($post_id, 'wc_boleto_data', $boleto_data);
         // Gets order data.
         $order = new WC_Order($post_id);
         // Add order note.
         $order->add_order_note(sprintf(__('Expiration date updated to: %s', 'wcboleto'), $boleto_data['data_vencimento']));
         // Send email notification.
         $this->email_notification($order, $boleto_data['data_vencimento']);
     }
 }
开发者ID:jgabrielfreitas,项目名称:MultipagosTestesAPP,代码行数:39,代码来源:class-wc-boleto-metabox.php

示例11: check_three_col_table

function check_three_col_table()
{
    global $post;
    if (get_post_meta($post->ID, "num_three_col_tables", $single = true) == "") {
        update_post_meta($post->ID, 'num_three_col_tables', 0, true);
    }
}
开发者ID:nachatate,项目名称:clients.gsvcap.mobile,代码行数:7,代码来源:three-col-table.php

示例12: kopa_click_like_button

 function kopa_click_like_button()
 {
     check_ajax_referer('kopa_click_like_button', 'ajax_nonce');
     if (!empty($_POST['post_id'])) {
         $result = array('status' => 'disable', 'total' => 0);
         $post_id = (int) $_POST['post_id'];
         $status = $_POST['status'];
         $include_text = $_POST['include_text'];
         $public_key = KOPA_OPT_PREFIX . 'likes';
         $single_key = KOPA_OPT_PREFIX . 'like_by_' . KopaUtil::get_client_IP();
         $total = KopaUtil::get_likes($post_id);
         $is_liked = KopaUtil::is_liked($post_id);
         if ('enable' == $status && !$is_liked) {
             $total++;
             update_post_meta($post_id, $single_key, true);
             update_post_meta($post_id, $public_key, abs($total));
             $result['class'] = 'kopa-button-likes-disable';
         } else {
             $total--;
             delete_post_meta($post_id, $single_key);
             update_post_meta($post_id, $public_key, abs($total));
             $result['class'] = 'kopa-button-likes-enable';
         }
         if ($include_text) {
             if ($total < 2) {
                 $total .= __(' Like', kopa_get_domain());
             } else {
                 $total .= __(' Likes', kopa_get_domain());
             }
         }
         $result['total'] = $total;
         echo json_encode($result);
     }
     exit;
 }
开发者ID:dgordon86,项目名称:breakbiodark,代码行数:35,代码来源:ajax.php

示例13: update_sale_price

 function update_sale_price($post_id)
 {
     if (get_post_type($post_id) == $this->post_type) {
         $price = STRental::get_price($post_id);
         update_post_meta($post_id, 'sale_price', $price);
     }
 }
开发者ID:HatchForce,项目名称:bachtraveller,代码行数:7,代码来源:class.cruise.php

示例14: ultimatum_meta_save_postdata

function ultimatum_meta_save_postdata( $post_id, $post ) {
	//echo '<pre>';print_r($_POST);die();
	//* Verify the nonce
	if ( ! isset( $_POST[ 'ultimatum_additional_meta_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'ultimatum_additional_meta_nonce' ], 'ultimatum_additional_meta' ) )
		return;
	
	//* Don't try to save the data under autosave, ajax, or future post.
	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
		return;
	if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
		return;
	if ( defined( 'DOING_CRON' ) && DOING_CRON )
		return;
	//* Grab the post object
	$post = get_post( $post );
	
	//* Don't save if WP is creating a revision (same as DOING_AUTOSAVE?)
	if ( 'revision' === $post->post_type )
		return;
	//* Check that the user is allowed to edit the post
	if ( ! current_user_can( 'edit_post', $post->ID ) )
		return;
	
	$mydata = $_POST['ultimatum_video'];
    update_post_meta($post->ID, 'ultimatum_video', $mydata);
	$mydata = $_POST['ultimatum_author'];
	update_post_meta($post->ID, 'ultimatum_author', $mydata);
}
开发者ID:polaris610,项目名称:medicalhound,代码行数:28,代码来源:ultimatum-meta.php

示例15: linkblog_save_post

function linkblog_save_post($post_id)
{
    // Ignore if doing an autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return;
    }
    // verify data came from the linkblog meta box
    if (!wp_verify_nonce($_POST['linkblog_noncename'], plugin_basename(__FILE__))) {
        return;
    }
    // Check user permissions
    if ('post' == $_POST['post_type']) {
        if (!current_user_can('edit_page', $post_id)) {
            return;
        }
    } else {
        if (!current_user_can('edit_post', $post_id)) {
            return;
        }
    }
    $linkblog_data = $_POST['linkblog_url'];
    if ($linkblog_data == "") {
        return;
    } else {
        update_post_meta($post_id, 'linkblog_url', $linkblog_data);
    }
}
开发者ID:arnabwahid,项目名称:WP-Linkblog,代码行数:27,代码来源:wp-linkblog.php


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