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


PHP delete_post_meta函数代码示例

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


在下文中一共展示了delete_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: set_rows

 /**
  * Saves new period set to DB.
  *
  * @param int     $post_id
  * @param assoc   $periods
  * @param boolean $validate
  * @return assoc  errors hppaned during validation
  */
 public function set_rows($post_id, $periods, $validate = true)
 {
     $validation_errors = array();
     if ($post_id < 1 || !$this->meta_key) {
         $validation_errors['general'] = esc_html__('Parametes errors. Please contact support', 'adventure-tours');
         return $validation_errors;
     }
     if (!$periods) {
         delete_post_meta($post_id, $this->meta_key);
     } else {
         if ($validate) {
             foreach ($periods as $index => $period_data) {
                 $period_errors = $this->check_period_data($period_data);
                 if ($period_errors) {
                     $validation_errors[$index] = $period_errors;
                 }
             }
             if ($validation_errors) {
                 return $validation_errors;
             }
         }
         update_post_meta($post_id, $this->meta_key, $this->format_periods($periods));
     }
     return $validation_errors;
 }
开发者ID:j-kenneth,项目名称:Expeero,代码行数:33,代码来源:AtTourBookingService.php

示例3: art_save_postdata

function art_save_postdata($post_id)
{
    // verify this came from the our screen and with proper authorization,
    // because save_post can be triggered at other times
    if (!wp_verify_nonce($_POST['art-direction-nonce'], plugin_basename(__FILE__))) {
        return $post_id;
    }
    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, we're authenticated: we need to find and save the data
    delete_post_meta($post_id, 'art_direction_single');
    delete_post_meta($post_id, 'art_direction_global');
    if (trim($_POST['single-code']) != '') {
        add_post_meta($post_id, 'art_direction_single', stripslashes($_POST['single-code']));
    }
    if (trim($_POST['global-code']) != '') {
        add_post_meta($post_id, 'art_direction_global', stripslashes($_POST['global-code']));
        return true;
    }
}
开发者ID:ControlledChaos,项目名称:Better-Art-Direction,代码行数:27,代码来源:better-art-direction.php

示例4: comcon_meta_save

function comcon_meta_save()
{
    global $post;
    $post_id = $post->ID;
    if (!isset($_POST['comcon-form-nonce']) || !wp_verify_nonce($_POST['comcon-form-nonce'], basename(__FILE__))) {
        return $post->ID;
    }
    $post_type = get_post_type_object($post->post_type);
    if (!current_user_can($post_type->cap->edit_post, $post_id)) {
        return $post->ID;
    }
    $input = array();
    $input['position'] = isset($_POST['comcon-form-position']) ? $_POST['comcon-form-position'] : '';
    $input['major'] = isset($_POST['comcon-form-major']) ? $_POST['comcon-form-major'] : '';
    $input['order'] = str_pad($input['order'], 3, "0", STR_PAD_LEFT);
    foreach ($input as $field => $value) {
        $old = get_post_meta($post_id, 'comcon-form-' . $field, true);
        if ($value && '' == $old) {
            add_post_meta($post_id, 'comcon-form-' . $field, $value, true);
        } else {
            if ($value && $value != $old) {
                update_post_meta($post_id, 'comcon-form-' . $field, $value);
            } else {
                if ('' == $value && $old) {
                    delete_post_meta($post_id, 'comcon-form-' . $field, $old);
                }
            }
        }
    }
}
开发者ID:ucf-design-group,项目名称:vucf,代码行数:30,代码来源:functions-comcon.php

示例5: save_newsletter

function save_newsletter($post_id)
{
    // verify nonce
    if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    // check permissions
    if ('newsletter' == $_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;
    }
    $old = get_post_meta($post_id, "name", true);
    $new = $_POST["name"];
    if ($new && $new != $old) {
        update_post_meta($post_id, "name", $new);
    } elseif ('' == $new && $old) {
        delete_post_meta($post_id, "name", $old);
    }
}
开发者ID:JonathanCosta,项目名称:Vou-de-Marisa,代码行数:26,代码来源:marisa-newsletter.php

示例6: tzp_portfolio_meta_box_save

/**
 * Save portfolio meta when the save_post action is called
 *
 * @since 0.1.0
 * @param int $post_id Portfolio ID
 * @global array $post All of the data of current post
 * @return void
 */
function tzp_portfolio_meta_box_save($post_id)
{
    global $post;
    if (!isset($_POST['tzp_portfolio_meta_box_nonce']) || !wp_verify_nonce($_POST['tzp_portfolio_meta_box_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || defined('DOING_AJAX') && DOING_AJAX || isset($_REQUEST['buld_edit'])) {
        return $post_id;
    }
    if (isset($post->post_type) && $post->post_type == 'revision') {
        return $post_id;
    }
    if (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    // Default fields that get saved
    $fields = apply_filters('tzp_metabox_fields_save', array('_tzp_portfolio_url' => 'url', '_tzp_portfolio_date' => 'html', '_tzp_portfolio_client' => 'html', '_tzp_display_gallery' => 'checkbox', '_tzp_display_audio' => 'checkbox', '_tzp_display_video' => 'checkbox', '_tzp_gallery_images' => 'images', '_tzp_audio_poster_url' => 'url', '_tzp_audio_file_mp3' => 'url', '_tzp_audio_file_ogg' => 'url', '_tzp_video_poster_url' => 'url', '_tzp_video_file_m4v' => 'url', '_tzp_video_file_ogv' => 'url', '_tzp_video_file_mp4' => 'url', '_tzp_video_embed' => 'html'));
    foreach ($fields as $key => $type) {
        if (!empty($_POST[$key])) {
            // sanitize fields with apply_filters
            $new = apply_filters('tzp_metabox_save_' . $type, $_POST[$key]);
            update_post_meta($post_id, $key, $new);
        } else {
            delete_post_meta($post_id, $key);
        }
    }
}
开发者ID:TyRichards,项目名称:paradox,代码行数:35,代码来源:metaboxes.php

示例7: pl_save_data

function pl_save_data($post_id)
{
    if ($_GET['post_type'] == 'people' || $_POST['post_type'] == 'people') {
        global $pl_meta_box;
        // verify nonce
        if (!wp_verify_nonce($_POST['pl_meta_box_nonce'], basename(__FILE__))) {
            return $post_id;
        }
        // check autosave
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
            return $post_id;
        }
        // check permissions
        if ('page' == $_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;
        }
        foreach ($pl_meta_box['fields'] as $field) {
            $old = get_post_meta($post_id, $field['id'], true);
            $new = $_POST[$field['id']];
            if ($new && $new != $old) {
                update_post_meta($post_id, $field['id'], $new);
            } elseif ('' == $new && $old) {
                delete_post_meta($post_id, $field['id'], $old);
            }
        }
    }
}
开发者ID:TimurMG,项目名称:mg-red,代码行数:31,代码来源:people-metabox.php

示例8: update_job_fields

 public static function update_job_fields($post_id, array $args)
 {
     $fields = self::get_all_fields();
     foreach ($fields as $field) {
         if (!isset($args[$field->ID])) {
             continue;
         }
         switch ($field->type) {
             default:
             case 'text':
             case 'select':
             case 'url':
                 update_post_meta($post_id, 'cfield-' . $field->ID, $args[$field->ID]);
                 break;
             case 'checkbox':
                 $string = implode(",", $args[$field->ID]);
                 update_post_meta($post_id, 'cfield-' . $field->ID, $string);
                 break;
             case 'date':
                 if (!empty($args[$field->ID])) {
                     $date = DateTime::createFromFormat(get_option("date_format"), $args[$field->ID]);
                     update_post_meta($post_id, 'cfield-' . $field->ID, $date->format('Y-m-d h:i:s'));
                 } else {
                     if ($args[$field->ID] === '' || $time === 0) {
                         delete_post_meta($post_id, 'cfield-' . $field->ID);
                     }
                 }
                 break;
         }
     }
 }
开发者ID:linniepinski,项目名称:perssistant,代码行数:31,代码来源:field.php

示例9: give_video_update

function give_video_update($post_id)
{
    if (!wp_verify_nonce($_POST['video_fields_nonce'], __FILE__)) {
        return false;
    }
    // checking
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return false;
    }
    // autochecking
    if (!current_user_can('edit_post', $post_id)) {
        return false;
    }
    // checking user role
    //if( !isset($_POST['video']) ) return false;
    //if(! is_numeric($_POST['money']['sum'])) return false;
    // save
    $_POST['video'] = array_map('trim', $_POST['video']);
    foreach ($_POST['video'] as $key => $value) {
        if (empty($value)) {
            delete_post_meta($post_id, $key);
            // if field is empty
            continue;
        }
        update_post_meta($post_id, $key, $value);
        // add_post_meta()
    }
    return $post_id;
}
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:29,代码来源:functions.php

示例10: copy

 /**
  * Create a Duplicate post
  */
 static function copy($post, $post_title = '', $post_name = '', $post_type = 'sp_report')
 {
     // We don't want to clone revisions
     if ($post->post_type == 'revision') {
         return;
     }
     if ($post->post_type != 'attachment') {
         $status = 'draft';
     }
     $new_post_author = wp_get_current_user();
     $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $new_post_author->ID, 'post_content' => $post->post_content, 'post_excerpt' => $post->post_excerpt, 'post_mime_type' => $post->post_mime_type, 'post_password' => $post->post_password, 'post_status' => $post->post_status, 'post_title' => empty($post_title) ? $post->post_title : $post_title, 'post_type' => empty($post_type) ? $post->post_type : $post_type);
     if ($post_name != '') {
         $new_post['post_name'] = $post_name;
     }
     /*
     $new_post['post_date'] = $new_post_date =  $post->post_date ;
     $new_post['post_date_gmt'] = get_gmt_from_date($new_post_date);
     */
     $new_post_id = wp_insert_post($new_post);
     // If you have written a plugin which uses non-WP database tables to save
     // information about a post you can hook this action to dupe that data.
     if ($post->post_type == 'page' || function_exists('is_post_type_hierarchical') && is_post_type_hierarchical($post->post_type)) {
         do_action('sp_duplicate_page', $new_post_id, $post);
     } else {
         do_action('sp_duplicate_post', $new_post_id, $post);
     }
     delete_post_meta($new_post_id, '_sp_original');
     add_post_meta($new_post_id, '_sp_original', $post->ID);
     add_post_meta($new_post_id, '_open_count', 0);
     return $new_post_id;
 }
开发者ID:radscheit,项目名称:unicorn,代码行数:34,代码来源:class-sendpress-posts.php

示例11: pvbu_setPostViews

function pvbu_setPostViews($postID)
{
    $count_key = 'post_views_by_user';
    $count = get_post_meta($postID, $count_key, true);
    //echo '<script type="text/javascript">console.log('.$count.')</script>';
    $user_array = array();
    if ($count == '') {
        if (is_user_logged_in()) {
            $user_ID = get_current_user_id();
            $user_array[$user_ID] = date("Y-m-d H:i:s");
            add_post_meta($postID, 'post_views_by_user', $user_array);
        }
    } else {
        if (is_user_logged_in()) {
            $user_ID = get_current_user_id();
            var_dump($count[$user_ID]);
            if ($count[$user_ID] == null) {
                $count[$user_ID] = date("Y-m-d H:i:s");
                delete_post_meta($postID, $count_key);
                add_post_meta($postID, 'post_views_by_user', $count);
            } else {
                return;
            }
        }
    }
}
开发者ID:sshuvro58,项目名称:WP_Post_View_by_User,代码行数:26,代码来源:post-view-by-user.php

示例12: save_custom_composer_meta

function save_custom_composer_meta($post_id)
{
    if (!isset($_POST['custom_composer_meta_box_nonce']) || !wp_verify_nonce($_POST['custom_composer_meta_box_nonce'], basename(__FILE__))) {
        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;
        }
    } elseif (!current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    $old = get_post_meta($post_id, 'cmsms_content_composer_text', true);
    if (isset($_POST['cmsms_content_composer_text'])) {
        $new = $_POST['cmsms_content_composer_text'];
    } else {
        $new = '';
    }
    if (isset($new) && $new !== $old) {
        update_post_meta($post_id, 'cmsms_content_composer_text', $new);
    } elseif (isset($old) && $new === '') {
        delete_post_meta($post_id, 'cmsms_content_composer_text', $old);
    }
}
开发者ID:TheFactorsGroup,项目名称:SunkistVitamins,代码行数:27,代码来源:cmsms-content-composer.php

示例13: save_postdata_gallery

function save_postdata_gallery($post_id)
{
    global $post, $gallery_box;
    foreach ($gallery_box as $meta_box) {
        if (!wp_verify_nonce($_POST[$meta_box['name'] . '_noncename'], plugin_basename(__FILE__))) {
            return $post_id;
        }
        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;
            }
        }
        $data = $_POST[$meta_box['name']];
        if (get_post_meta($post_id, $meta_box['name']) == "") {
            add_post_meta($post_id, $meta_box['name'], $data, true);
        } elseif ($data != get_post_meta($post_id, $meta_box['name'], true)) {
            update_post_meta($post_id, $meta_box['name'], $data);
        } elseif ($data == "") {
            delete_post_meta($post_id, $meta_box['name'], get_post_meta($post_id, $meta_box['name'], true));
        }
    }
}
开发者ID:yunfanLu,项目名称:wordpress,代码行数:26,代码来源:gallery_box.php

示例14: savePackage

 function savePackage($post)
 {
     if (!current_user_can('edit_posts')) {
         return;
     }
     if (get_post_type() != 'wpdmpro' || !isset($_POST['file'])) {
         return;
     }
     // Deleted old zipped file
     $zipped = get_post_meta($post, "__wpdm_zipped_file", true);
     if ($zipped != '' && file_exists($zipped)) {
         @unlink($zipped);
     }
     $cdata = get_post_custom($post);
     foreach ($cdata as $k => $v) {
         $tk = str_replace("__wpdm_", "", $k);
         if (!isset($_POST['file'][$tk]) && $tk !== $k) {
             delete_post_meta($post, $k);
         }
     }
     foreach ($_POST['file'] as $meta_key => $meta_value) {
         $key_name = "__wpdm_" . $meta_key;
         update_post_meta($post, $key_name, $meta_value);
     }
     if (get_post_meta($post, '__wpdm_masterkey', true) == '') {
         update_post_meta($post, '__wpdm_masterkey', uniqid());
     }
     if (isset($_POST['reset_key']) && $_POST['reset_key'] == 1) {
         update_post_meta($post, '__wpdm_masterkey', uniqid());
     }
     if (isset($_REQUEST['reset_udl'])) {
         delete_post_meta($post, '__wpdmx_user_download_count');
     }
     //do_action('after_update_package',$post, $_POST['file']);
 }
开发者ID:wilxsv,项目名称:prevensionPublicLibrary,代码行数:35,代码来源:class.Packages.php

示例15: wedding_style_web_dorado_meta_save

function wedding_style_web_dorado_meta_save($post_id)
{
    // authentication checks
    // check user permissions
    if (isset($_POST['post_type']) && $_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;
        }
    }
    $current_data = get_post_meta($post_id, 'web_dorado_meta_date', TRUE);
    if (isset($_POST['web_dorado_meta_date'])) {
        $new_data = $_POST['web_dorado_meta_date'];
    } else {
        $new_data = "";
    }
    if (gettype($post_id) == 'integer') {
        if (is_null($new_data)) {
            delete_post_meta($post_id, 'web_dorado_meta_date');
        } else {
            update_post_meta($post_id, 'web_dorado_meta_date', $new_data);
            add_post_meta($post_id, 'web_dorado_meta_date', $new_data, TRUE);
        }
    } elseif (!is_null($new_data)) {
        update_post_meta($post_id, 'web_dorado_meta_date', $new_data);
    }
    return $post_id;
}
开发者ID:javalidigital,项目名称:multipla,代码行数:31,代码来源:meta-functions.php


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