• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wpcf_admin_import_data函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: hack_around_legacy_import_routine

 private function hack_around_legacy_import_routine($import_data, $import_args = null)
 {
     add_filter('wpcf_admin_message_store', '__return_false');
     $_POST['overwrite-settings'] = isset($import_args['overwrite-settings']) ? (bool) $import_args['overwrite-settings'] : false;
     $_POST['overwrite-groups'] = isset($import_args['overwrite-groups']) && 1 == $import_args['overwrite-groups'] ? 1 : 0;
     $_POST['overwrite-fields'] = isset($import_args['overwrite-fields']) && 1 == $import_args['overwrite-fields'] ? 1 : 0;
     $_POST['overwrite-types'] = isset($import_args['overwrite-types']) && 1 == $import_args['overwrite-types'] ? 1 : 0;
     $_POST['overwrite-tax'] = isset($import_args['overwrite-tax']) && 1 == $import_args['overwrite-tax'] ? 1 : 0;
     $_POST['post_relationship'] = isset($import_args['post_relationship']) ? (bool) $import_args['post_relationship'] : false;
     $_POST['delete-groups'] = isset($import_args['delete-groups']) ? (bool) $import_args['delete-groups'] : false;
     $_POST['delete-fields'] = isset($import_args['delete-fields']) ? (bool) $import_args['delete-fields'] : false;
     $_POST['delete-types'] = isset($import_args['delete-types']) ? (bool) $import_args['delete-types'] : false;
     $_POST['delete-tax'] = isset($import_args['delete-tax']) ? (bool) $import_args['delete-tax'] : false;
     /**
      * This can be emtpy string '' or 'wpvdemo', but this second option has a serious bug with xml parsing/looping
      */
     $context = isset($import_args['context']) ? $import_args['context'] : '';
     // Not sure if this is needed
     require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
     require_once WPCF_EMBEDDED_INC_ABSPATH . '/import-export.php';
     // Prepare legacy arguments for Types_Data_Installer
     $legacy_args = array();
     if (isset($import_args['overwrite'])) {
         $legacy_args['force_import_post_name'] = wpcf_getarr($import_args, 'overwrite', array());
     }
     if (isset($import_args['skip'])) {
         $legacy_args['force_skip_post_name'] = wpcf_getarr($import_args, 'skip', array());
     }
     if (isset($import_args['duplicate'])) {
         $legacy_args['force_duplicate_post_name'] = wpcf_getarr($import_args, 'duplicate', array());
     }
     $result = wpcf_admin_import_data($import_data, false, $context, $legacy_args);
     return true;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:34,代码来源:import_from_zip_file.php


示例2: sync

 /**
  * Compare checksums of types and import accordingly
  */
 public function sync()
 {
     $index = array();
     $configs = $this->getConfigs();
     $current = get_option('types-manager-index', array());
     $_POST['overwrite-groups'] = $_POST['overwrite-types'] = $_POST['overwrite-fields'] = $_POST['overwrite-tax'] = 1;
     $import = array();
     foreach ($configs as $export_type => $types) {
         if (empty($types['__key'])) {
             continue;
         }
         $__key = $types['__key'];
         foreach ($types as $id => $data) {
             if ($id == '__key') {
                 continue;
             }
             $index[$export_type][$id] = md5(serialize($data));
             if (!isset($current[$export_type][$id]) || $current[$export_type][$id] != $index[$export_type][$id]) {
                 // Import function checks for this
                 $_POST[$export_type][$id] = array('add' => true, 'update' => true);
                 $import[$export_type]['__key'] = $__key;
                 $import[$export_type][$id] = $data;
             }
         }
     }
     if (count($import)) {
         require_once WPCF_INC_ABSPATH . '/fields.php';
         require_once WPCF_INC_ABSPATH . '/import-export.php';
         $xml = self::toXml($import, 'types');
         foreach ($import as $export_type => $_) {
             wpcf_admin_import_data($xml, false, $export_type);
         }
         wpcf_init_custom_types_taxonomies();
         flush_rewrite_rules();
         update_option('types-manager-index', $index);
     }
     unset($_POST['overwrite-groups'], $_POST['overwrite-types'], $_POST['overwrite-fields'], $_POST['overwrite-tax']);
 }
开发者ID:wemakecustom,项目名称:wp-config-manager,代码行数:41,代码来源:Types.php


示例3: wpcf_embedded_check_import

/**
 * Imports settings.
 */
function wpcf_embedded_check_import()
{
    if (file_exists(WPCF_EMBEDDED_ABSPATH . '/settings.php')) {
        require_once WPCF_EMBEDDED_ABSPATH . '/admin.php';
        require_once WPCF_EMBEDDED_ABSPATH . '/settings.php';
        $dismissed = get_option('wpcf_dismissed_messages', array());
        if (in_array($timestamp, $dismissed)) {
            return false;
        }
        if ($timestamp > get_option('wpcf-types-embedded-import', 0)) {
            if (!$auto_import) {
                $link = "<a href=\"" . admin_url('?types-embedded-import=1&amp;_wpnonce=' . wp_create_nonce('embedded-import')) . "\">";
                $text = sprintf(__('You have Types import pending. %sClick here to import.%s %sDismiss message.%s', 'wpcf'), $link, '</a>', "<a onclick=\"jQuery(this).parent().parent().fadeOut();\" class=\"wpcf-ajax-link\" href=\"" . admin_url('admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=dismiss_message&amp;id=' . $timestamp . '&amp;_wpnonce=' . wp_create_nonce('dismiss_message')) . "\">", '</a>');
                wpcf_admin_message($text);
            }
            if ($auto_import || isset($_GET['types-embedded-import']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'embedded-import')) {
                if (file_exists(WPCF_EMBEDDED_ABSPATH . '/settings.xml')) {
                    $_POST['overwrite-groups'] = 1;
                    $_POST['overwrite-fields'] = 1;
                    $_POST['overwrite-types'] = 1;
                    $_POST['overwrite-tax'] = 1;
                    //                    $_POST['delete-groups'] = 0;
                    //                    $_POST['delete-fields'] = 0;
                    //                    $_POST['delete-types'] = 0;
                    //                    $_POST['delete-tax'] = 0;
                    $_POST['post_relationship'] = 1;
                    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
                    require_once WPCF_EMBEDDED_INC_ABSPATH . '/import-export.php';
                    $data = @file_get_contents(WPCF_EMBEDDED_ABSPATH . '/settings.xml');
                    wpcf_admin_import_data($data, false, 'types-auto-import');
                    update_option('wpcf-types-embedded-import', $timestamp);
                    wp_redirect(admin_url());
                } else {
                    $code = __('settings.xml file missing', 'wpcf');
                    wpcf_admin_message($code, 'error');
                }
            }
        }
    }
}
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:43,代码来源:functions.php


示例4: wpcf_admin_import_export_form

/**
 * Import/Export form data.
 * 
 * @return type 
 */
function wpcf_admin_import_export_form()
{
    $form = array();
    $form['wpnonce'] = array('#type' => 'hidden', '#name' => '_wpnonce', '#value' => wp_create_nonce('wpcf_import'));
    if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'wpcf_import')) {
        if (isset($_POST['import-final'])) {
            if ($_POST['mode'] == 'file' && !empty($_POST['file']) && file_exists(urldecode($_POST['file']))) {
                $info = pathinfo(urldecode($_POST['file']));
                $is_zip = $info['extension'] == 'zip' ? true : false;
                if ($is_zip) {
                    $zip = zip_open(urldecode($_POST['file']));
                    if (is_resource($zip)) {
                        while (($zip_entry = zip_read($zip)) !== false) {
                            if (zip_entry_name($zip_entry) == 'settings.xml') {
                                $data = @zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                            }
                        }
                    } else {
                        echo '<div class="message error"><p>' . __('Unable to open zip file', 'wpcf') . '</p></div>';
                        return array();
                    }
                } else {
                    $data = @file_get_contents(urldecode($_POST['file']));
                }
                if ($data) {
                    wpcf_admin_import_data($data);
                } else {
                    echo '<div class="message error"><p>' . __('Unable to process file', 'wpcf') . '</p></div>';
                    return array();
                }
            }
            if ($_POST['mode'] == 'text' && !empty($_POST['text'])) {
                $charset = !empty($_POST['text-encoding']) ? $_POST['text-encoding'] : get_option('blog_charset');
                wpcf_admin_import_data(stripslashes(html_entity_decode($_POST['text'], ENT_QUOTES, $charset)));
            }
        } else {
            if (isset($_POST['step'])) {
                $mode = 'none';
                $data = '';
                if (!empty($_POST['import-file']) && !empty($_FILES['file']['tmp_name'])) {
                    if ($_FILES['file']['type'] == 'text/xml') {
                        $_FILES['file']['name'] .= '.txt';
                    }
                    $_POST['action'] = 'wp_handle_upload';
                    $uploaded_file = wp_handle_upload($_FILES['file'], array('test_form' => false, 'upload_error_handler' => 'wpcf_admin_import_export_file_upload_error'));
                    if (isset($uploaded_file['error'])) {
                        return array();
                    }
                    if (empty($uploaded_file['file'])) {
                        echo '<div class="message error"><p>' . __('Error uploading file', 'wpcf') . '</p></div>';
                        return array();
                    }
                    $info = pathinfo($uploaded_file['file']);
                    $is_zip = $info['extension'] == 'zip' ? true : false;
                    if ($is_zip) {
                        $zip = zip_open($uploaded_file['file']);
                        if (is_resource($zip)) {
                            while (($zip_entry = zip_read($zip)) !== false) {
                                if (zip_entry_name($zip_entry) == 'settings.xml') {
                                    $data = @zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                                }
                            }
                        } else {
                            echo '<div class="message error"><p>' . __('Unable to open zip file', 'wpcf') . '</p></div>';
                            return array();
                        }
                    } else {
                        $data = @file_get_contents($uploaded_file['file']);
                    }
                    $form['file'] = array('#type' => 'hidden', '#name' => 'file', '#value' => urlencode($uploaded_file['file']));
                    $mode = 'file';
                } else {
                    if (!empty($_POST['import-text']) && !empty($_POST['text'])) {
                        $data = stripslashes($_POST['text']);
                        if (preg_match('/encoding=("[^"]*"|\'[^\']*\')/s', $data, $match)) {
                            $charset = trim($match[1], '"');
                        } else {
                            $charset = !empty($_POST['text-encoding']) ? $_POST['text-encoding'] : get_option('blog_charset');
                        }
                        $form['text'] = array('#type' => 'hidden', '#name' => 'text', '#value' => htmlentities(stripslashes($_POST['text']), ENT_QUOTES, $charset));
                        $form['text-encoding'] = array('#type' => 'hidden', '#name' => 'text-encoding', '#value' => $charset);
                        $mode = 'text';
                    }
                }
                if (empty($data)) {
                    echo '<div class="message error"><p>' . __('Data not valid', 'wpcf') . '</p></div>';
                    return array();
                }
                $data = wpcf_admin_import_export_settings($data);
                if (empty($data)) {
                    echo '<div class="message error"><p>' . __('Data not valid', 'wpcf') . '</p></div>';
                    return array();
                }
                $form = array_merge($form, $data);
                $form['mode'] = array('#type' => 'hidden', '#name' => 'mode', '#value' => $mode);
//.........这里部分代码省略.........
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:101,代码来源:import-export.php


示例5: wpcf_admin_import_export_form

/**
 * Import/Export form data.
 *
 * @return type
 *
 * @deprecated in 2.0, to remove
 */
function wpcf_admin_import_export_form()
{
    $form = array();
    $form['wpnonce'] = array('#type' => 'hidden', '#name' => '_wpnonce', '#value' => wp_create_nonce('wpcf_import'));
    $form_base = $form;
    $show_first_screen = true;
    if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'wpcf_import')) {
        $show_first_screen = false;
        if (isset($_POST['import-final'])) {
            if ($_POST['mode'] == 'file' && !empty($_POST['file'])) {
                $file = get_transient(sanitize_text_field($_POST['file']));
                if (file_exists($file)) {
                    $info = pathinfo($file);
                    $is_zip = $info['extension'] == 'zip' ? true : false;
                    if ($is_zip) {
                        $zip = zip_open($file);
                        if (is_resource($zip)) {
                            while (($zip_entry = zip_read($zip)) !== false) {
                                if (zip_entry_name($zip_entry) == 'settings.xml') {
                                    $data = @zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                                }
                            }
                        } else {
                            echo '<div class="message error"><p>' . __('Unable to open zip file', 'wpcf') . '</p></div>';
                            return array();
                        }
                    } else {
                        $data = @file_get_contents($file);
                    }
                    @unlink($file);
                    if ($data) {
                        wpcf_admin_import_data($data);
                    } else {
                        echo '<div class="message error"><p>' . __('Unable to process file', 'wpcf') . '</p></div>';
                        return array();
                    }
                } else {
                    echo '<div class="message error"><p>' . __('Unable to process file', 'wpcf') . '</p></div>';
                    return array();
                }
            }
            if ($_POST['mode'] == 'text' && !empty($_POST['text'])) {
                $charset = !empty($_POST['text-encoding']) ? sanitize_text_field($_POST['text-encoding']) : get_option('blog_charset');
                wpcf_admin_import_data(stripslashes(html_entity_decode($_POST['text'], ENT_QUOTES, $charset)));
            }
        } elseif (isset($_POST['step'])) {
            $mode = 'none';
            $data = '';
            if (!empty($_POST['import-file']) && !empty($_FILES['file']['tmp_name'])) {
                if ($_FILES['file']['type'] == 'text/xml') {
                    $_FILES['file']['name'] .= '.txt';
                }
                /*
                 *
                 * We need to move uploaded file manually
                 */
                if (!empty($_FILES['file']['error'])) {
                    echo '<div class="message error"><p>' . __('Error uploading file', 'wpcf') . '</p></div>';
                    return array();
                }
                $wp_upload_dir = wp_upload_dir();
                $new_file = $wp_upload_dir['basedir'] . '/' . sanitize_file_name($_FILES['file']['name']);
                $move = move_uploaded_file($_FILES['file']['tmp_name'], $new_file);
                if (!$move) {
                    echo '<div class="message error"><p>' . __('Error moving uploaded file', 'wpcf') . '</p></div>';
                    return array();
                }
                $uploaded_file = array('file' => $new_file);
                $info = pathinfo($uploaded_file['file']);
                $is_zip = $info['extension'] == 'zip' ? true : false;
                if ($is_zip) {
                    $zip = zip_open($uploaded_file['file']);
                    if (is_resource($zip)) {
                        while (($zip_entry = zip_read($zip)) !== false) {
                            if (zip_entry_name($zip_entry) == 'settings.xml') {
                                $data = @zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                            }
                        }
                    } else {
                        echo '<div class="message error"><p>' . __('Unable to open zip file', 'wpcf') . '</p></div>';
                        return array();
                    }
                } else {
                    $data = @file_get_contents($uploaded_file['file']);
                }
                /**
                 * use Transients API to store file fullpath
                 */
                $current_user = wp_get_current_user();
                $cache_key = md5($current_user->user_email . $uploaded_file['file']);
                set_transient($cache_key, $uploaded_file['file'], 60 * 60);
                $form['file'] = array('#type' => 'hidden', '#name' => 'file', '#value' => $cache_key);
                $mode = 'file';
//.........这里部分代码省略.........
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:import-export.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wpcf_admin_is_repetitive函数代码示例发布时间:2022-05-23
下一篇:
PHP wpcf_admin_get_taxonomies_by_group函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap