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


PHP wpcf_get_settings函数代码示例

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


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

示例1: wpcf_admin_general_settings_form_submit

function wpcf_admin_general_settings_form_submit($form)
{
    $settings = wpcf_get_settings();
    $data = $_POST['wpcf_settings'];
    foreach (array('register_translations_on_import', 'help_box') as $setting) {
        if (!isset($data[$setting])) {
            $settings[$setting] = 0;
        } else {
            $settings[$setting] = $data[$setting];
        }
    }
    update_option('wpcf_settings', $settings);
    // Credits
    // TODO Remove
    //    require_once WPCF_EMBEDDED_INC_ABSPATH . '/footer-credit.php';
    //    $option = get_option('wpcf_footer_credit', array());
    //    if (!isset($option['message'])) {
    //        $data = wpcf_footer_credit_defaults();
    //        shuffle($data);
    //        $option['message'] = rand(0, count($data));
    //    }
    //    if (!isset($_POST['show_credits'])) {
    //        update_option('wpcf_footer_credit',
    //                array('active' => 0, 'message' => $option['message']));
    //    } else {
    //        update_option('wpcf_footer_credit',
    //                array('active' => 1, 'message' => $option['message']));
    //    }
    wpcf_admin_message_store(__('Settings saved', 'wpcf'));
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:30,代码来源:settings.php

示例2: wpcf_admin_settings_form_submit

/**
 * Saves settings.
 * 
 * @param type $form 
 */
function wpcf_admin_settings_form_submit($form)
{
    $settings = wpcf_get_settings();
    $data = $_POST['wpcf_settings'];
    foreach ($settings as $setting => $value) {
        if (!isset($data[$setting])) {
            $settings[$setting] = 0;
        } else {
            $settings[$setting] = $data[$setting];
        }
    }
    update_option('wpcf_settings', $settings);
    // Credits
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/footer-credit.php';
    $option = get_option('wpcf_footer_credit', array());
    if (!isset($option['message'])) {
        $data = wpcf_footer_credit_defaults();
        shuffle($data);
        $option['message'] = rand(0, count($data));
    }
    if (!isset($_POST['show_credits'])) {
        update_option('wpcf_footer_credit', array('active' => 0, 'message' => $option['message']));
    } else {
        update_option('wpcf_footer_credit', array('active' => 1, 'message' => $option['message']));
    }
    wpcf_admin_message_store(__('Settings saved', 'wpcf'));
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:32,代码来源:settings.php

示例3: wpcf_admin_general_settings_form_submit

/**
 * Saves settings.
 *
 * @param type $form
 */
function wpcf_admin_general_settings_form_submit($form)
{
    if (isset($_POST['clear-cache-images']) || isset($_POST['clear-cache-images-outdated'])) {
        require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields/image.php';
        $cache_dir = wpcf_fields_image_get_cache_directory(true);
        if (is_wp_error($cache_dir)) {
            wpcf_admin_message_store($cache_dir->get_error_message());
        } else {
            if (isset($_POST['clear-cache-images'])) {
                wpcf_fields_image_clear_cache($cache_dir, 'all');
            } else {
                wpcf_fields_image_clear_cache($cache_dir);
            }
            wpcf_admin_message_store(__('Images cache cleared', 'wpcf'));
        }
        return true;
    }
    $settings = wpcf_get_settings();
    $data = $_POST['wpcf_settings'];
    $keys = array('add_resized_images_to_library' => 'esc_html', 'help_box' => 'esc_html', 'hide_standard_custom_fields_metabox' => 'esc_html', 'images_remote' => 'intval', 'images_remote_cache_time' => 'intval', 'register_translations_on_import' => 'esc_html', 'toolset_messages' => 'intval', 'postmeta_unfiltered_html' => 'on-off', 'usermeta_unfiltered_html' => 'on-off');
    foreach ($keys as $key => $validation) {
        if (!isset($data[$key])) {
            $settings[$key] = 0;
        } else {
            switch ($validation) {
                case 'intval':
                    $settings[$key] = intval($data[$key]);
                    break;
                case 'on-off':
                    if (preg_match('/^(on|off)$/', $data[$key])) {
                        $settings[$key] = $data[$key];
                    } else {
                        $settings[$key] = 'off';
                    }
                    break;
                case 'esc_html':
                default:
                    $settings[$key] = esc_html($data[$key]);
                    break;
            }
        }
    }
    /**
     * validate hide_standard_custom_fields_metabox
     */
    if (!preg_match('/^(show|hide)$/', $settings['hide_standard_custom_fields_metabox'])) {
        $settings['hide_standard_custom_fields_metabox'] = 'show';
    }
    /**
     * update_option
     */
    update_option('wpcf_settings', $settings);
    wpcf_admin_message_store(__('Settings saved.', 'wpcf'));
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:59,代码来源:settings.php

示例4: wpcf_sanitize_usermeta_values_on_save

 public static function wpcf_sanitize_usermeta_values_on_save($value)
 {
     if (current_user_can('unfiltered_html') && wpcf_get_settings('usermeta_unfiltered_html') != 'off') {
         return $value;
     }
     if (is_array($value)) {
         // Recursion
         $value = array_map(array('WPCF_Loader', 'wpcf_sanitize_usermeta_values_on_save'), $value);
     } else {
         $value = wp_filter_post_kses($value);
     }
     return $value;
 }
开发者ID:lytranuit,项目名称:wordpress,代码行数:13,代码来源:loader.php

示例5: wpcf_is_client

 /**
  * Check if user is a client, who bought Toolset
  * @return bool
  */
 function wpcf_is_client()
 {
     // for testing
     if (!WPCF_PAYED) {
         return false;
     }
     // check db stored value
     if (get_option('wpcf-is-client')) {
         $settings = wpcf_get_settings('help_box');
         // prioritise settings if available
         if ($settings) {
             switch ($settings) {
                 case 'by_types':
                 case 'all':
                     return false;
                 case 'no':
                     return true;
             }
         }
         $is_client = get_option('wpcf-is-client');
         // client
         if ($is_client === 'yes') {
             return true;
         }
         // user
         return false;
     }
     // no db stored value
     // make sure get_plugins() is available
     if (!function_exists('get_plugins')) {
         require_once ABSPATH . 'wp-admin/includes/plugin.php';
     }
     // all plugins
     $plugins = get_plugins();
     // check each plugin
     foreach ($plugins as $plugin) {
         // skip plugin that is not created by us
         if ($plugin['Author'] != 'OnTheGoSystems') {
             continue;
         }
         // check for toolset plugin and not embedded = user bought toolset
         if (preg_match("#(access|cred|layouts|module manager|views)#i", $plugin['Name']) && !preg_match('#embedded#i', $plugin['Name'])) {
             add_option('wpcf-is-client', 'yes');
             // set settings "help box" ounce to none
             $settings = get_option('wpcf_settings', array());
             $settings['help_box'] = 'no';
             update_option('wpcf_settings', $settings);
             return true;
         }
     }
     // if script comes to this point we have no option "wpcf-is-client" set
     // and also no bought toolset plugin
     add_option('wpcf-is-client', 'no');
     return false;
 }
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:59,代码来源:wpcf.php

示例6: wpcf_fields_image_clear_cache

/**
 * Clears remote image cache.
 *
 * @param type $action
 */
function wpcf_fields_image_clear_cache($cache_dir = null, $action = 'outdated')
{
    if (is_null($cache_dir)) {
        $cache_dir = wpcf_fields_image_get_cache_directory();
    }
    $refresh_time = intval(wpcf_get_settings('images_remote_cache_time'));
    if ($refresh_time == 0 && $action != 'all') {
        return true;
    }
    foreach (glob($cache_dir . DIRECTORY_SEPARATOR . "*") as $filename) {
        if ($action == 'all') {
            @unlink($filename);
        } else {
            $time_modified = filemtime($filename);
            if (time() - $time_modified > $refresh_time * 60 * 60) {
                @unlink($filename);
                // Clear resized images
                $path = pathinfo($filename);
                foreach (glob($path['dirname'] . DIRECTORY_SEPARATOR . $path['filename'] . "-*") as $resized) {
                    @unlink($resized);
                }
            }
        }
    }
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:30,代码来源:image.php

示例7: wpcf_admin_post_init

/**
 * Init functions for post edit pages.
 *
 * Core function. Works and stable. Do not move or change.
 * If required, add hooks only.
 *
 * @param type $post
 */
function wpcf_admin_post_init($post)
{
    add_action('admin_footer', 'wpcf_admin_fields_postfields_styles');
    wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
    wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset', '\'' . wp_create_nonce('form_fieldset_toggle') . '\'');
    // Get post_type
    $post_type = wpcf_admin_get_edited_post_type($post);
    /*
     *
     * This is left to maintain compatibility with older versions
     * TODO Remove
     */
    // Add items to View dropdown
    if (in_array($post_type, array('view', 'view-template', 'cred-form'))) {
        add_filter('editor_addon_menus_wpv-views', 'wpcf_admin_post_editor_addon_menus_filter');
        add_action('admin_footer', 'wpcf_admin_post_js_validation');
        wpcf_enqueue_scripts();
        wp_enqueue_script('toolset-colorbox');
        wp_enqueue_style('toolset-colorbox');
    }
    // Never show on 'Views' and 'View Templates'
    if (in_array($post_type, array('view', 'view-template'))) {
        return false;
    }
    // Add marketing box
    if (!in_array($post_type, array('post', 'page', 'cred-form')) && !defined('WPCF_RUNNING_EMBEDDED')) {
        $hide_help_box = true;
        $help_box = wpcf_get_settings('help_box');
        $custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
        if ($help_box != 'no') {
            if ($help_box == 'by_types' && array_key_exists($post_type, $custom_types)) {
                $hide_help_box = false;
            }
            if (function_exists('wprc_is_logged_to_repo') && wprc_is_logged_to_repo(WPCF_REPOSITORY)) {
                $hide_help_box = true;
            }
            if ($help_box == 'all') {
                $hide_help_box = false;
            }
            if (!$hide_help_box && !defined('WPV_VERSION')) {
                add_meta_box('wpcf-marketing', __('Display Custom Content', 'wpcf'), 'wpcf_admin_post_marketing_meta_box', $post_type, 'side', 'high');
            }
        }
    }
    // Are Types active?
    $wpcf_active = false;
    // Get groups
    $groups = wpcf_admin_post_get_post_groups_fields($post);
    foreach ($groups as $group) {
        $only_preview = '';
        //If Access plugin activated
        if (function_exists('wpcf_access_register_caps')) {
            //If user can't view own profile fields
            if (!current_user_can('view_fields_in_edit_page_' . $group['slug'])) {
                continue;
            }
            //If user can modify current group in own profile
            if (!current_user_can('modify_fields_in_edit_page_' . $group['slug'])) {
                $only_preview = 1;
            }
        }
        if (!empty($group['fields']) && empty($only_preview)) {
            $wpcf_active = true;
            break;
        }
    }
    // Activate scripts
    if ($wpcf_active) {
        add_action('admin_head', 'wpcf_post_preview_warning');
        wpcf_edit_post_screen_scripts();
    }
    // Add validation
    add_action('admin_footer', 'wpcf_admin_post_js_validation');
    /*
     * TODO Review
     * This is forced because of various Child cases
     * and when field are rendered via AJAX but not registered yet.
     *
     * Basically all fields that require additional JS should be added here.
     *
     * This is a must for now.
     * These fields need init JS in various cases.
     */
    wpcf_field_enqueue_scripts('date');
    wpcf_field_enqueue_scripts('image');
    wpcf_field_enqueue_scripts('file');
    wpcf_field_enqueue_scripts('skype');
    wpcf_field_enqueue_scripts('numeric');
    do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:98,代码来源:fields-post.php

示例8: wpcf_admin_import_data_from_xmlstring


//.........这里部分代码省略.........
        }
        // Insert types
        foreach ($types as $type_id => $type) {
            if (isset($type['add']) && !$type['add']) {
                continue;
            }
            if (isset($types_existing[$type_id])) {
                /*
                 *
                 * Compare checksum to see if updated
                 */
                $_checksum = $wpcf->import->checksum('custom_post_type', $type_id, $type['checksum']);
                if (!$_checksum) {
                    $result['updated'] += 1;
                }
            } else {
                $result['new'] += 1;
            }
            /*
             * Set type
             */
            unset($type['add'], $type['update'], $type['checksum']);
            $types_existing[$type_id] = $type;
            $types_check[] = $type_id;
        }
        update_option('wpcf-custom-types', $types_existing);
        // Add relationships
        /** EMERSON: Restore Types relationships when importing modules */
        if (!empty($data->post_relationships)) {
            $relationship_existing = get_option('wpcf_post_relationship', array());
            /**
             * be sure, $relationship_existing is a array!
             */
            if (!is_array($relationship_existing)) {
                $relationship_existing = array();
            }
            $relationship = json_decode($data->post_relationships->data, true);
            if (is_array($relationship)) {
                $relationship = array_merge($relationship_existing, $relationship);
                update_option('wpcf_post_relationship', $relationship);
            }
        }
    }
    // Process taxonomies
    if (!empty($data->taxonomies) && 'taxonomies' == $_type) {
        $imported = true;
        $taxonomies_existing = get_option('wpcf-custom-taxonomies', array());
        $taxonomies = array();
        $taxonomies_check = array();
        // Set insert data from XML
        foreach ($data->taxonomies->taxonomy as $taxonomy) {
            // TODO 1.2.1 Remove
            //            $_id = wpcf_modman_get_submitted_id( _TAX_MODULE_MANAGER_KEY_,
            //                    $taxonomy['__types_id'] );
            $_id = strval($taxonomy->__types_id);
            // If Types check if exists in $_POST
            if ($context == 'types' || $context == 'modman') {
                if (!isset($_POST['items']['taxonomies'][$_id])) {
                    continue;
                }
            }
            $taxonomy = wpcf_admin_import_export_simplexml2array($taxonomy);
            $taxonomies[$_id] = $taxonomy;
        }
        // Insert taxonomies
        foreach ($taxonomies as $taxonomy_id => $taxonomy) {
            if (isset($taxonomy['add']) && !$taxonomy['add'] && !$overwrite_tax) {
                continue;
            }
            if (isset($taxonomies_existing[$taxonomy_id])) {
                /*
                 *
                 * Compare checksum to see if updated
                 */
                $_checksum = $wpcf->import->checksum('custom_taxonomy', $taxonomy_id, $taxonomy['checksum']);
                if (!$_checksum) {
                    $result['updated'] += 1;
                }
            } else {
                $result['new'] += 1;
            }
            // Set tax
            unset($taxonomy['add'], $taxonomy['update'], $taxonomy['checksum']);
            $taxonomies_existing[$taxonomy_id] = $taxonomy;
            $taxonomies_check[] = $taxonomy_id;
        }
        update_option('wpcf-custom-taxonomies', $taxonomies_existing);
    }
    if ($imported) {
        // WPML bulk registration
        // TODO WPML move
        if (wpcf_get_settings('register_translations_on_import')) {
            wpcf_admin_bulk_string_translation();
        }
        // Flush rewrite rules
        wpcf_init_custom_types_taxonomies();
        flush_rewrite_rules();
    }
    return $result;
}
开发者ID:MiquelAdell,项目名称:miqueladell,代码行数:101,代码来源:module-manager.php

示例9: wpcf_get_extra_debug_info

/**
 * add types configuration to debug
 */
function wpcf_get_extra_debug_info($extra_debug)
{
    $extra_debug['types'] = wpcf_get_settings();
    return $extra_debug;
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:8,代码来源:admin.php

示例10: wpcf_admin_post_init

/**
 * Init functions for post edit pages.
 * 
 * Core function. Works and stable. Do not move or change.
 * If required, add hooks only.
 * 
 * @param type $upgrade 
 */
function wpcf_admin_post_init($post = false)
{
    global $wpcf;
    wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
    wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset', '\'' . wp_create_nonce('form_fieldset_toggle') . '\'');
    // Get post_type
    if ($post) {
        $post_type = get_post_type($post);
    } else {
        if (!isset($_GET['post_type'])) {
            $post_type = 'post';
        } else {
            if (in_array($_GET['post_type'], get_post_types(array('show_ui' => true)))) {
                $post_type = $_GET['post_type'];
            } else {
                return false;
            }
        }
    }
    // Set global $wpcf post object
    // CHECKPOINT
    $wpcf->post = $post;
    $wpcf->post_types->set($post_type);
    // Add items to View dropdown
    if (in_array($post_type, array('view', 'view-template'))) {
        add_filter('editor_addon_menus_wpv-views', 'wpcf_admin_post_editor_addon_menus_filter');
        add_action('admin_footer', 'wpcf_admin_post_js_validation');
        wpcf_enqueue_scripts();
    }
    // Never show on 'Views' and 'View Templates'
    // CRED should pass this check
    if (in_array($post_type, array('view', 'view-template'))) {
        return false;
    }
    // Add marketing box
    if (!in_array($post_type, array('post', 'page', 'cred-form')) && !defined('WPCF_RUNNING_EMBEDDED')) {
        $hide_help_box = true;
        $help_box = wpcf_get_settings('help_box');
        $custom_types = get_option('wpcf-custom-types', array());
        if ($help_box != 'no') {
            if ($help_box == 'by_types' && array_key_exists($post_type, $custom_types)) {
                $hide_help_box = false;
            }
            if (function_exists('wprc_is_logged_to_repo') && wprc_is_logged_to_repo(WPCF_REPOSITORY)) {
                $hide_help_box = true;
            }
            if ($help_box == 'all') {
                $hide_help_box = false;
            }
            if (!$hide_help_box) {
                add_meta_box('wpcf-marketing', __('Display Custom Content', 'wpcf'), 'wpcf_admin_post_marketing_meta_box', $post_type, 'side', 'high');
            }
        }
    }
    // Are Types active?
    $wpcf_active = false;
    // Get groups
    $groups = wpcf_admin_post_get_post_groups_fields($post);
    foreach ($groups as $group) {
        if (!empty($group['fields'])) {
            $wpcf_active = true;
            // Process fields
            $group['fields'] = wpcf_admin_post_process_fields($post, $group['fields'], true);
        }
        // Specially for CRED
        /*
         * 
         * TODO Setting some specific for CRED is wrong
         * Use hooks
         */
        if (!in_array($post_type, array('cred-form'))) {
            // Add meta boxes
            add_meta_box($group['slug'], wpcf_translate('group ' . $group['id'] . ' name', $group['name']), 'wpcf_admin_post_meta_box', $post_type, $group['meta_box_context'], 'high', $group);
        }
    }
    // Activate scripts
    if ($wpcf_active) {
        wp_enqueue_script('wpcf-fields-post', WPCF_EMBEDDED_RES_RELPATH . '/js/fields-post.js', array('jquery'), WPCF_VERSION);
        wp_enqueue_script('wpcf-form-validation', WPCF_EMBEDDED_RES_RELPATH . '/js/' . 'jquery-form-validation/jquery.validate.min.js', array('jquery'), WPCF_VERSION);
        wp_enqueue_script('wpcf-form-validation-additional', WPCF_EMBEDDED_RES_RELPATH . '/js/' . 'jquery-form-validation/additional-methods.min.js', array('jquery'), WPCF_VERSION);
        wp_enqueue_style('wpcf-fields-basic', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
        wp_enqueue_style('wpcf-fields-post', WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css', array('wpcf-fields-basic'), WPCF_VERSION);
        wpcf_enqueue_scripts();
    }
    // Add validation
    // TODO Move to wpcf_enqueue_scripts()
    add_action('admin_footer', 'wpcf_admin_post_js_validation');
    do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:97,代码来源:fields-post.php

示例11: wpcf_admin_import_data

/**
 * Imports data from XML.
 *
 * @global object $wpdb
 *
 */
function wpcf_admin_import_data($data = '', $redirect = true, $context = 'types', $args = array())
{
    global $wpdb;
    $data_installer = false;
    libxml_use_internal_errors(true);
    $data = simplexml_load_string($data);
    if (!$data) {
        echo '<div class="message error"><p>' . __('Error parsing XML', 'wpcf') . '</p></div>';
        foreach (libxml_get_errors() as $error) {
            echo '<div class="message error"><p>' . $error->message . '</p></div>';
        }
        libxml_clear_errors();
        return false;
    }
    $overwrite_settings = isset($_POST['overwrite-settings']);
    $overwrite_groups = isset($_POST['overwrite-groups']);
    $overwrite_fields = isset($_POST['overwrite-fields']);
    $overwrite_types = isset($_POST['overwrite-types']);
    $overwrite_tax = isset($_POST['overwrite-tax']);
    $delete_groups = isset($_POST['delete-groups']);
    $delete_fields = isset($_POST['delete-fields']);
    $delete_types = isset($_POST['delete-types']);
    $delete_tax = isset($_POST['delete-tax']);
    if ('wpvdemo' == $context && !empty($args)) {
        /**
         * allow overwrite
         */
        $overwrite_groups = true;
        $overwrite_fields = true;
        $overwrite_types = true;
        $overwrite_tax = true;
        include_once dirname(__FILE__) . '/classes/class.types.data.installer.php';
        $data_installer = new Types_Data_Installer($data, $args);
        $data = $data_installer->wpvdemo();
    }
    /**
     * process settings
     */
    if ($overwrite_settings && isset($data->settings)) {
        $wpcf_settings = wpcf_get_settings();
        foreach (wpcf_admin_import_export_simplexml2array($data->settings) as $key => $value) {
            $wpcf_settings[$key] = $value;
        }
        wpcf_save_settings($wpcf_settings);
        wpcf_admin_message_store(__('Settings are updated.', 'wpcf'));
    }
    // Process groups
    $groups_check = array();
    if (!empty($data->groups)) {
        $groups = array();
        // Set insert data from XML
        foreach ($data->groups->group as $group) {
            $group = wpcf_admin_import_export_simplexml2array($group);
            $groups[$group['ID']] = $group;
        }
        // Set insert data from POST
        if (!empty($_POST['groups'])) {
            foreach ($_POST['groups'] as $group_id => $group) {
                if (empty($groups[$group_id])) {
                    continue;
                }
                $groups[$group_id]['add'] = !empty($group['add']);
                $groups[$group_id]['update'] = isset($group['update']) && $group['update'] == 'update' ? true : false;
            }
        } else {
            foreach ($groups as $group_id => $group) {
                $groups[$group_id]['add'] = true;
                $groups[$group_id]['update'] = false;
            }
        }
        // Insert groups
        $show_import_fail_version_message = true;
        foreach ($groups as $group_id => $group) {
            $post = array('post_status' => $group['post_status'], 'post_type' => TYPES_CUSTOM_FIELD_GROUP_CPT_NAME, 'post_title' => $group['post_title'], 'post_content' => !empty($group['post_content']) ? $group['post_content'] : '');
            /**
             * preserve slug
             */
            if (array_key_exists('__types_id', $group)) {
                $post['post_name'] = $group['__types_id'];
            }
            if (isset($group['add']) && $group['add']) {
                $post_to_update = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_title = %s AND post_type = %s", $group['post_title'], TYPES_CUSTOM_FIELD_GROUP_CPT_NAME));
                // Update (may be forced by bulk action)
                if ($group['update'] || $overwrite_groups && !empty($post_to_update)) {
                    if (!empty($post_to_update)) {
                        $post['ID'] = $post_to_update;
                        $group_wp_id = wp_update_post($post);
                        if (!$group_wp_id) {
                            wpcf_admin_message_store(sprintf(__('Group "%s" update failed', 'wpcf'), $group['post_title']), 'error');
                        } else {
                            wpcf_admin_message_store(sprintf(__('Group "%s" updated', 'wpcf'), $group['post_title']));
                        }
                    } else {
                        wpcf_admin_message_store(sprintf(__('Group "%s" update failed', 'wpcf'), $group['post_title']), 'error');
//.........这里部分代码省略.........
开发者ID:aarongillett,项目名称:B22-151217,代码行数:101,代码来源:import-export.php

示例12: update_toolset_messages

 public function update_toolset_messages()
 {
     $settings = wpcf_get_settings();
     if (array_key_exists('value', $_POST) && 'checked' == $_POST['value']) {
         if (!add_option($this->option_disable, '1', '', 'no')) {
             update_option($this->option_disable, '1');
         }
         $settings['toolset_messages'] = true;
     } else {
         delete_option($this->option_disable);
         $settings['toolset_messages'] = false;
     }
     update_option('wpcf_settings', $settings);
     echo '<div class="updated"><p>';
     _e('Toolset Messages state saved!', 'wpcf');
     echo '</p></div>';
     die;
 }
开发者ID:sandum150,项目名称:cheltuieli,代码行数:18,代码来源:class.wpcf-marketing-messages.php

示例13: wpcf_admin_post_init

/**
 * Init functions for post edit pages.
 *
 * Core function. Works and stable. Do not move or change.
 * If required, add hooks only.
 *
 * @param type $post
 */
function wpcf_admin_post_init($post)
{
    add_action('admin_footer', 'wpcf_admin_fields_postfields_styles');
    wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
    wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset', '\'' . wp_create_nonce('form_fieldset_toggle') . '\'');
    // Get post_type
    $post_type = wpcf_admin_get_edited_post_type($post);
    /*
     *
     * This is left to maintain compatibility with older versions
     * TODO Remove
     */
    // Add items to View dropdown
    if (in_array($post_type, array('view', 'view-template', 'cred-form', 'cred-user-form'))) {
        add_filter('editor_addon_menus_wpv-views', 'wpcf_admin_post_editor_addon_menus_filter');
        add_action('admin_footer', 'wpcf_admin_post_js_validation');
        wpcf_enqueue_scripts();
        wp_enqueue_script('toolset-colorbox');
        wp_enqueue_style('toolset-colorbox');
    }
    // Never show on 'Views' and 'Content Templates'
    if (in_array($post_type, array('view', 'view-template'))) {
        return false;
    }
    /**
     * remove custom field WordPress metabox
     */
    if ('hide' == wpcf_get_settings('hide_standard_custom_fields_metabox')) {
        foreach (array('normal', 'advanced', 'side') as $context) {
            remove_meta_box('postcustom', $post_type, $context);
        }
    }
    // Add marketing box
    if (!wpcf_is_client() && !in_array($post_type, array('post', 'page', 'cred-form', 'cred-user-form')) && !defined('WPCF_RUNNING_EMBEDDED')) {
        $settings_help_box = wpcf_get_settings('help_box');
        $custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
        if ($settings_help_box == 'all' || array_key_exists($post_type, $custom_types)) {
            $displaying_custom_content = (include WPCF_ABSPATH . '/marketing/displaying-custom-content/title-content.php');
            add_meta_box('add_box_howto', $displaying_custom_content['title'], 'wpcf_admin_post_marketing_displaying_custom_content', $post_type, 'side', 'high');
        }
    }
    // Are Types active?
    $wpcf_active = false;
    // Get groups
    $groups = wpcf_admin_post_get_post_groups_fields($post);
    foreach ($groups as $group) {
        $only_preview = '';
        //If Access plugin activated
        if (function_exists('wpcf_access_register_caps')) {
            //If user can't view own profile fields
            if (!current_user_can('view_fields_in_edit_page_' . $group['slug'])) {
                continue;
            }
            //If user can modify current group in own profile
            if (!current_user_can('modify_fields_in_edit_page_' . $group['slug'])) {
                $only_preview = 1;
            }
        }
        if (!empty($group['fields']) && empty($only_preview)) {
            $wpcf_active = true;
            break;
        }
    }
    // Activate scripts
    if ($wpcf_active) {
        add_action('admin_head', 'wpcf_post_preview_warning');
        wpcf_edit_post_screen_scripts();
    }
    // Add validation
    add_action('admin_footer', 'wpcf_admin_post_js_validation');
    /*
     * TODO Review
     * This is forced because of various Child cases
     * and when field are rendered via AJAX but not registered yet.
     *
     * Basically all fields that require additional JS should be added here.
     *
     * This is a must for now.
     * These fields need init JS in various cases.
     */
    wpcf_field_enqueue_scripts('date');
    wpcf_field_enqueue_scripts('image');
    wpcf_field_enqueue_scripts('file');
    wpcf_field_enqueue_scripts('skype');
    wpcf_field_enqueue_scripts('numeric');
    do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:95,代码来源:fields-post.php

示例14: wpcf_fields_image_view

/**
 * View function.
 * 
 * @param type $params 
 */
function wpcf_fields_image_view($params)
{
    $output = '';
    $alt = false;
    $title = false;
    $class = array();
    // Get image data
    $image_data = wpcf_fields_image_get_data($params['field_value']);
    // Display error to admin only
    if (!empty($image_data['error'])) {
        if (current_user_can('administrator')) {
            return '<div style="padding:10px;background-color:Red;color:#FFFFFF;">' . 'Types: ' . $image_data['error'] . '</div>';
        }
        return $params['field_value'];
    }
    //if (!$image_data['is_outsider']) {
    //    if (current_user_can('administrator')) {
    //        return '<div style="padding:10px;background-color:Red;color:#FFFFFF;">'
    //                . 'Types: ' . sprintf(__('Directory %s not writable', 'wpcf'),
    //                        $image_data['abspath']) . '</div>';
    //    }
    //    return $params['field_value'];
    //}
    // Set alt
    if (isset($params['alt'])) {
        $alt = $params['alt'];
    }
    // Set title
    if (isset($params['title'])) {
        $title = $params['title'];
    }
    // Set attachment class
    if (!empty($params['size'])) {
        $class[] = 'attachment-' . $params['size'];
    }
    // Set align class
    if (!empty($params['align']) && $params['align'] != 'none') {
        $class[] = 'align' . $params['align'];
    }
    // Pre-configured size (use WP function)
    if ($image_data['is_attachment'] && !empty($params['size'])) {
        $output = wp_get_attachment_image($image_data['is_attachment'], $params['size'], false, array('class' => implode(' ', $class), 'alt' => $alt, 'title' => $title));
    } else {
        // Custom size
        $width = !empty($params['width']) ? intval($params['width']) : null;
        $height = !empty($params['height']) ? intval($params['height']) : null;
        $crop = !empty($params['proportional']) && $params['proportional'] == 'true' ? false : true;
        // Check if image is outsider
        if (!$image_data['is_outsider']) {
            $resized_image = wpcf_fields_image_resize_image($params['field_value'], $width, $height, 'relpath', false, $crop);
            if (!$resized_image) {
                $resized_image = $params['field_value'];
            } else {
                // Add to library
                $image_abspath = wpcf_fields_image_resize_image($params['field_value'], $width, $height, 'abspath', false, $crop);
                $add_to_library = wpcf_get_settings('add_resized_images_to_library');
                if ($add_to_library) {
                    global $wpdb;
                    $attachment_exists = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts}\r\r\n    WHERE post_type = 'attachment' AND guid=%s", $resized_image));
                    if (empty($attachment_exists)) {
                        // Add as attachment
                        $wp_filetype = wp_check_filetype(basename($image_abspath), null);
                        $attachment = array('post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($image_abspath)), 'post_content' => '', 'post_status' => 'inherit', 'guid' => $resized_image);
                        global $post;
                        $attach_id = wp_insert_attachment($attachment, $image_abspath, $post->ID);
                        // you must first include the image.php file
                        // for the function wp_generate_attachment_metadata() to work
                        require_once ABSPATH . "wp-admin" . '/includes/image.php';
                        $attach_data = wp_generate_attachment_metadata($attach_id, $image_abspath);
                        wp_update_attachment_metadata($attach_id, $attach_data);
                    }
                }
            }
        } else {
            $resized_image = $params['field_value'];
        }
        $output = '<img alt="';
        $output .= $alt !== false ? $alt : $resized_image;
        $output .= '" title="';
        $output .= $title !== false ? $title : $resized_image;
        $output .= '"';
        $output .= !empty($params['onload']) ? ' onload="' . $params['onload'] . '"' : '';
        $output .= !empty($class) ? ' class="' . implode(' ', $class) . '"' : '';
        $output .= ' src="' . $resized_image . '" />';
    }
    return $output;
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:92,代码来源:image.php

示例15: wpcf_admin_import_data


//.........这里部分代码省略.........
                continue;
            }
            unset($type['add'], $type['update']);
            $types_existing[$type_id] = $type;
            $types_check[] = $type_id;
            wpcf_admin_message_store(sprintf(__('Custom post type "%s" added/updated', 'wpcf'), $type_id));
        }
        // Delete types
        if ($delete_types) {
            foreach ($types_existing as $k => $v) {
                if (!in_array($k, $types_check)) {
                    unset($types_existing[$k]);
                    wpcf_admin_message_store(sprintf(__('Custom post type "%s" deleted', 'wpcf'), esc_html($k)));
                }
            }
        } else {
            if (!empty($_POST['types-to-be-deleted'])) {
                foreach ($_POST['types-to-be-deleted'] as $type_to_delete) {
                    wpcf_admin_message_store(sprintf(__('Custom post type "%s" deleted', 'wpcf'), $types_existing[$type_to_delete]['labels']['name']));
                    unset($types_existing[$type_to_delete]);
                }
            }
        }
        update_option('wpcf-custom-types', $types_existing);
    }
    // Process taxonomies
    if (!empty($data->taxonomies)) {
        $taxonomies_existing = get_option('wpcf-custom-taxonomies', array());
        $taxonomies = array();
        $taxonomies_check = array();
        // Set insert data from XML
        foreach ($data->taxonomies->taxonomy as $taxonomy) {
            $taxonomy = wpcf_admin_import_export_simplexml2array($taxonomy);
            $taxonomies[$taxonomy['id']] = $taxonomy;
        }
        // Set insert data from POST
        if (!empty($_POST['taxonomies'])) {
            foreach ($_POST['taxonomies'] as $taxonomy_id => $taxonomy) {
                if (empty($taxonomies[$taxonomy_id])) {
                    continue;
                }
                $taxonomies[$taxonomy_id]['add'] = !empty($taxonomy['add']);
                $taxonomies[$taxonomy_id]['update'] = isset($taxonomy['update']) && $taxonomy['update'] == 'update' ? true : false;
            }
        }
        // Insert taxonomies
        foreach ($taxonomies as $taxonomy_id => $taxonomy) {
            if (isset($taxonomy['add']) && !$taxonomy['add'] && !$overwrite_tax) {
                continue;
            }
            unset($taxonomy['add'], $taxonomy['update']);
            $taxonomies_existing[$taxonomy_id] = $taxonomy;
            $taxonomies_check[] = $taxonomy_id;
            wpcf_admin_message_store(sprintf(__('Custom taxonomy "%s" added/updated', 'wpcf'), $taxonomy_id));
        }
        // Delete taxonomies
        if ($delete_tax) {
            foreach ($taxonomies_existing as $k => $v) {
                if (!in_array($k, $taxonomies_check)) {
                    unset($taxonomies_existing[$k]);
                    wpcf_admin_message_store(sprintf(__('Custom taxonomy "%s" deleted', 'wpcf'), $k));
                }
            }
        } else {
            if (!empty($_POST['taxonomies-to-be-deleted'])) {
                foreach ($_POST['taxonomies-to-be-deleted'] as $taxonomy_to_delete) {
                    wpcf_admin_message_store(sprintf(__('Custom taxonomy "%s" deleted', 'wpcf'), $taxonomies_existing[$taxonomy_to_delete]['labels']['name']));
                    unset($taxonomies_existing[$taxonomy_to_delete]);
                }
            }
        }
        update_option('wpcf-custom-taxonomies', $taxonomies_existing);
    }
    // Add relationships
    if (!empty($data->post_relationships) && !empty($_POST['post_relationship'])) {
        $relationship_existing = get_option('wpcf_post_relationship', array());
        foreach ($data->post_relationships->post_relationship as $relationship) {
            $relationship = unserialize($relationship);
            $relationship = array_merge($relationship_existing, $relationship);
            update_option('wpcf_post_relationship', $relationship);
            wpcf_admin_message_store(__('Post relationships created', 'wpcf'));
            break;
        }
    }
    // WPML bulk registration
    if (wpcf_get_settings('register_translations_on_import')) {
        wpcf_admin_bulk_string_translation();
    }
    // Flush rewrite rules
    wpcf_init_custom_types_taxonomies();
    flush_rewrite_rules();
    if ($redirect) {
        echo '<script type="text/javascript">
<!--
window.location = "' . admin_url('admin.php?page=wpcf-import-export') . '"
//-->
</script>';
        die;
    }
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:101,代码来源:import-export.php


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