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


PHP acf_save_post函数代码示例

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


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

示例1: save_attachment

 function save_attachment($post, $attachment)
 {
     // bail early if not valid nonce
     if (!acf_verify_nonce('attachment')) {
         return $post;
     }
     // validate and save
     if (acf_validate_save_post(true)) {
         acf_save_post($post['ID']);
     }
     // return
     return $post;
 }
开发者ID:de190909,项目名称:WPTest,代码行数:13,代码来源:attachment.php

示例2: acf_form_head

function acf_form_head()
{
    // verify nonce
    if (acf_verify_nonce('acf_form')) {
        // validate data
        if (acf_validate_save_post(true)) {
            // form
            $GLOBALS['acf_form'] = acf_extract_var($_POST, '_acf_form');
            $GLOBALS['acf_form'] = @json_decode(base64_decode($GLOBALS['acf_form']), true);
            // validate
            if (empty($GLOBALS['acf_form'])) {
                return;
            }
            // vars
            $post_id = acf_maybe_get($GLOBALS['acf_form'], 'post_id', 0);
            // allow for custom save
            $post_id = apply_filters('acf/pre_save_post', $post_id, $GLOBALS['acf_form']);
            // save
            acf_save_post($post_id);
            // vars
            $return = acf_maybe_get($GLOBALS['acf_form'], 'return', '');
            // redirect
            if ($return) {
                // update %placeholders%
                $return = str_replace('%post_url%', get_permalink($post_id), $return);
                // redirect
                wp_redirect($return);
                exit;
            }
        }
        // if
    }
    // if
    // load acf scripts
    acf_enqueue_scripts();
}
开发者ID:de190909,项目名称:WPTest,代码行数:36,代码来源:api-template.php

示例3: save_post

 function save_post($post_id)
 {
     // do not save if this is an auto save routine
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // verify and remove nonce
     if (!acf_verify_nonce('post', $post_id)) {
         return $post_id;
     }
     // validate and save
     if (get_post_status($post_id) == 'publish') {
         if (acf_validate_save_post(true)) {
             acf_save_post($post_id);
         }
     } else {
         acf_save_post($post_id);
     }
     // return
     return $post_id;
 }
开发者ID:tofubuddha,项目名称:example,代码行数:21,代码来源:post.php

示例4: save_term

 function save_term($term_id, $tt_id, $taxonomy)
 {
     // verify and remove nonce
     if (!acf_verify_nonce('taxonomy')) {
         return $term_id;
     }
     // save data
     if (acf_validate_save_post(true)) {
         acf_save_post("{$taxonomy}_{$term_id}");
     }
 }
开发者ID:quangnpd,项目名称:jobshop_web,代码行数:11,代码来源:taxonomy.php

示例5: save_post

 function save_post($post_id, $post)
 {
     // bail ealry if no allowed to save this post type
     if (!$this->allow_save_post($post)) {
         return $post_id;
     }
     // ensure saving to the correct post
     if (!acf_verify_nonce('post', $post_id)) {
         return $post_id;
     }
     // validate for published post (allow draft to save without validation)
     if (get_post_status($post_id) == 'publish') {
         // show errors
         acf_validate_save_post(true);
     }
     // save
     acf_save_post($post_id);
     // return
     return $post_id;
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:20,代码来源:post.php

示例6: admin_load

 function admin_load()
 {
     // globals
     global $plugin_page;
     // set currrent
     $this->view['slug'] = $plugin_page;
     // verify and remove nonce
     if (acf_verify_nonce('options')) {
         // save data
         if (acf_validate_save_post(true)) {
             // get post_id (allow lang modification)
             $post_id = acf_get_valid_post_id('options');
             // save
             acf_save_post($post_id);
             // redirect
             wp_redirect(admin_url("admin.php?page={$plugin_page}&message=1"));
             exit;
         }
     }
     add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
 }
开发者ID:bmavus,项目名称:wp-theme-blank,代码行数:21,代码来源:options-page.php

示例7: save_user

 function save_user($user_id)
 {
     // verify and remove nonce
     if (!acf_verify_nonce('user')) {
         return $user_id;
     }
     // save data
     if (acf_validate_save_post(true)) {
         acf_save_post("user_{$user_id}");
     }
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:11,代码来源:user.php

示例8: ajax_update_attachment

 function ajax_update_attachment()
 {
     // validate
     if (!wp_verify_nonce($_REQUEST['nonce'], 'acf_nonce')) {
         wp_send_json_error();
     }
     if (empty($_REQUEST['attachments'])) {
         wp_send_json_error();
     }
     foreach ($_REQUEST['attachments'] as $id => $changes) {
         if (!current_user_can('edit_post', $id)) {
             wp_send_json_error();
         }
         $post = get_post($id, ARRAY_A);
         if ('attachment' != $post['post_type']) {
             wp_send_json_error();
         }
         if (isset($changes['title'])) {
             $post['post_title'] = $changes['title'];
         }
         if (isset($changes['caption'])) {
             $post['post_excerpt'] = $changes['caption'];
         }
         if (isset($changes['description'])) {
             $post['post_content'] = $changes['description'];
         }
         if (isset($changes['alt'])) {
             $alt = wp_unslash($changes['alt']);
             if ($alt != get_post_meta($id, '_wp_attachment_image_alt', true)) {
                 $alt = wp_strip_all_tags($alt, true);
                 update_post_meta($id, '_wp_attachment_image_alt', wp_slash($alt));
             }
         }
         /** This filter is documented in wp-admin/includes/media.php */
         $post = apply_filters('attachment_fields_to_save', $post, $changes);
         // save post
         wp_update_post($post);
         // save meta
         acf_save_post($id);
     }
     wp_send_json_success();
 }
开发者ID:TMBR,项目名称:johnjohn,代码行数:42,代码来源:gallery.php

示例9: save_term

 function save_term($term_id, $tt_id, $taxonomy)
 {
     // verify and remove nonce
     if (!acf_verify_nonce('taxonomy')) {
         return $term_id;
     }
     // valied and show errors
     acf_validate_save_post(true);
     // save
     acf_save_post('term_' . $term_id);
 }
开发者ID:rmikeska,项目名称:ushipnetwork,代码行数:11,代码来源:taxonomy.php

示例10: save_post

 function save_post($post_id, $post)
 {
     // do not save if this is an auto save routine
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     // bail early if is acf-field-group or acf-field
     if (in_array($post->post_type, array('acf-field', 'acf-field-group'))) {
         return $post_id;
     }
     // verify and remove nonce
     if (!acf_verify_nonce('post', $post_id)) {
         return $post_id;
     }
     // validate and save
     if (get_post_status($post_id) == 'publish') {
         if (acf_validate_save_post(true)) {
             acf_save_post($post_id);
         }
     } else {
         acf_save_post($post_id);
     }
     // return
     return $post_id;
 }
开发者ID:de190909,项目名称:WPTest,代码行数:25,代码来源:post.php

示例11: acf_form_head

function acf_form_head()
{
    // verify nonce
    if (acf_verify_nonce('acf_form')) {
        // validate data
        if (acf_validate_save_post(true)) {
            // form
            $form = acf_extract_var($_POST, '_acf_form');
            $form = @json_decode(base64_decode($form), true);
            // validate
            if (empty($form)) {
                return;
            }
            // allow for custom save
            $form['post_id'] = apply_filters('acf/pre_save_post', $form['post_id'], $form);
            // save
            acf_save_post($form['post_id']);
            // redirect
            if (!empty($form['return'])) {
                // update %placeholders%
                $form['return'] = str_replace('%post_url%', get_permalink($form['post_id']), $form['return']);
                // redirect
                wp_redirect($form['return']);
                exit;
            }
        }
        // if
    }
    // if
    // load acf scripts
    acf_enqueue_scripts();
}
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:32,代码来源:api-template.php

示例12: admin_load

 function admin_load()
 {
     // globals
     global $plugin_page;
     // vars
     $this->page = acf_get_options_page($plugin_page);
     // verify and remove nonce
     if (acf_verify_nonce('options')) {
         // save data
         if (acf_validate_save_post(true)) {
             // get post_id (allow lang modification)
             $post_id = acf_get_valid_post_id($this->page['post_id']);
             // set autoload
             acf_update_setting('autoload', $this->page['autoload']);
             // save
             acf_save_post($post_id);
             // redirect
             wp_redirect(admin_url("admin.php?page={$plugin_page}&message=1"));
             exit;
         }
     }
     // actions
     add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'));
 }
开发者ID:Aqro,项目名称:NewDWM,代码行数:24,代码来源:options-page.php

示例13: customize_save

 function customize_save($customizer)
 {
     // get widgets
     $widgets = $this->get_customizer_widgets($customizer);
     // bail ealry if no widgets
     if (empty($widgets)) {
         return;
     }
     // append values
     foreach ($widgets as $widget) {
         // bail early if no acf_value
         if (!$widget->acf) {
             continue;
         }
         // fake post data
         $_POST['acf'] = $widget->acf['values'];
         // save
         acf_save_post($widget->acf['ID']);
         // get widget base
         $id_data = $widget->id_data();
         // remove [acf] data from saved widget array
         add_filter('pre_update_option_' . $id_data['base'], array($this, 'pre_update_option'), 10, 3);
     }
 }
开发者ID:Garth619,项目名称:Femi9,代码行数:24,代码来源:widget.php

示例14: ajax_update_attachment

 function ajax_update_attachment()
 {
     // validate nonce
     if (!wp_verify_nonce($_POST['nonce'], 'acf_nonce')) {
         wp_send_json_error();
     }
     // bail early if no attachments
     if (empty($_POST['attachments'])) {
         wp_send_json_error();
     }
     // loop over attachments
     foreach ($_POST['attachments'] as $id => $changes) {
         if (!current_user_can('edit_post', $id)) {
             wp_send_json_error();
         }
         $post = get_post($id, ARRAY_A);
         if ('attachment' != $post['post_type']) {
             wp_send_json_error();
         }
         if (isset($changes['title'])) {
             $post['post_title'] = $changes['title'];
         }
         if (isset($changes['caption'])) {
             $post['post_excerpt'] = $changes['caption'];
         }
         if (isset($changes['description'])) {
             $post['post_content'] = $changes['description'];
         }
         if (isset($changes['alt'])) {
             $alt = wp_unslash($changes['alt']);
             if ($alt != get_post_meta($id, '_wp_attachment_image_alt', true)) {
                 $alt = wp_strip_all_tags($alt, true);
                 update_post_meta($id, '_wp_attachment_image_alt', wp_slash($alt));
             }
         }
         // save post
         wp_update_post($post);
         /** This filter is documented in wp-admin/includes/media.php */
         // - seems off to run this filter AFTER the update_post function, but there is a reason
         // - when placed BEFORE, an empty post_title will be populated by WP
         // - this filter will still allow 3rd party to save extra image data!
         $post = apply_filters('attachment_fields_to_save', $post, $changes);
         // save meta
         acf_save_post($id);
     }
     // return
     wp_send_json_success();
 }
开发者ID:rmikeska,项目名称:ushipnetwork,代码行数:48,代码来源:gallery.php

示例15: save_widget

 function save_widget()
 {
     // bail early if no nonce
     if (!acf_verify_nonce('widget')) {
         return;
     }
     // vars
     $id = acf_maybe_get($_POST, 'widget-id');
     // save data
     if ($id && acf_validate_save_post()) {
         acf_save_post("widget_{$id}");
     }
 }
开发者ID:sdh100shaun,项目名称:pantheon,代码行数:13,代码来源:widget.php


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