Ejemplo n.º 1
0
 public function prepare()
 {
     // documentation urls
     Types_Helper_Url::load_documentation_urls();
     // set analytics medium
     Types_Helper_Url::set_medium('post_editor');
     // add information
     $this->prepare_information();
     // @todo load scripts
     if (function_exists('wpcf_edit_post_screen_scripts')) {
         wpcf_edit_post_screen_scripts();
     }
 }
Ejemplo n.º 2
0
 public function prepare()
 {
     // documentation urls
     $documentation_urls = (include TYPES_DATA . '/information/documentation-urls.php');
     // add links to use analytics
     Types_Helper_Url::add_urls($documentation_urls);
     // set analytics medium
     Types_Helper_Url::set_medium('post_editor');
     // add informations
     $this->prepare_informations();
     // @todo load scripts
     if (function_exists('wpcf_edit_post_screen_scripts')) {
         wpcf_edit_post_screen_scripts();
     }
 }
Ejemplo n.º 3
0
/**
 * 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);
}
Ejemplo n.º 4
0
function __wpcf_usermeta_test_groups($groups)
{
    if (!empty($groups)) {
        return $groups;
    }
    $groups = wpcf_admin_fields_get_groups('wp-types-user-group');
    $check = false;
    if (!empty($groups)) {
        foreach ($groups as $group_id => $group) {
            // Mark meta box as hidden
            $groups[$group_id]['__show_meta_box'] = false;
            if (empty($group['is_active'])) {
                unset($groups[$group_id]);
                continue;
            }
            $fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true, 'wp-types-user-group', 'wpcf-usermeta');
            if (empty($fields)) {
                unset($groups[$group_id]);
                continue;
            }
            $check = true;
        }
    }
    if (!$check) {
        remove_action('admin_enqueue_scripts', 'wpcf_admin_post_add_to_editor_js');
    } else {
        wpcf_edit_post_screen_scripts();
    }
    return $groups;
}
/**
 * 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);
}
 /**
  * Load various assets needed by the toolset-forms blob.
  *
  * @since 1.9
  */
 private function add_toolset_forms_support()
 {
     // JS and CSS assets related to fields - mostly generic ones.
     wpcf_edit_post_screen_scripts();
     // Needed for fields that have something to do with files
     WPToolset_Field_File::file_enqueue_scripts();
     // Extra enqueuing of media assets needed since WPToolset_Field_File doesn't know about termmeta.
     wp_enqueue_media();
     // We need to append form-specific data for the JS validation script.
     add_action('admin_footer', array($this, 'render_js_validation_data'));
     // Pretend we're about to create new form via toolset-forms, even if we're not going to.
     // This will load some assets needed for image field preview (specifically the 'wptoolset-forms-admin' style).
     // Hacky, but better than re-registering the toolset-forms stylesheet elsewhere.
     $faux_form_bootstrap = new WPToolset_Forms_Bootstrap();
     $faux_form_bootstrap->form('faux');
     $asset_manager = Types_Asset_Manager::get_instance();
     // Enqueue the main page script
     $asset_manager->register_script(self::PAGE_SCRIPT_NAME, TYPES_RELPATH . '/public/page/add_term.js', array('jquery', 'toolset-utils'), TYPES_VERSION, true);
     $asset_manager->enqueue_scripts(self::PAGE_SCRIPT_NAME);
 }
 /**
  * Load various assets needed by the toolset-forms blob.
  *
  * @since 1.9
  */
 private function add_toolset_forms_support()
 {
     // JS and CSS assets related to fields - mostly generic ones.
     wpcf_edit_post_screen_scripts();
     // Needed for fields that have something to do with files
     WPToolset_Field_File::file_enqueue_scripts();
     // Extra enqueuing of media assets needed since WPToolset_Field_File doesn't know about termmeta.
     wp_enqueue_media();
     // We need to append form-specific data for the JS validation script.
     add_action('admin_footer', array($this, 'render_js_validation_data'));
 }
Ejemplo n.º 8
0
 /**
  * Load various assets needed by the toolset-forms blob.
  *
  * @since 1.9
  */
 private function add_toolset_forms_support()
 {
     // JS and CSS assets related to fields - mostly generic ones.
     wpcf_edit_post_screen_scripts();
     // Needed for fields that have something to do with files
     WPToolset_Field_File::file_enqueue_scripts();
     // Extra enqueuing of media assets needed since WPToolset_Field_File doesn't know about termmeta.
     wp_enqueue_media();
     // We need to append form-specific data for the JS validation script.
     add_action('admin_footer', array($this, 'render_js_validation_data'));
     // Pretend we're about to create new form via toolset-forms, even if we're not going to.
     // This will load some assets needed for image field preview (specifically the 'wptoolset-forms-admin' style).
     // Hacky, but better than re-registering the toolset-forms stylesheet elsewhere.
     $faux_form_bootstrap = new WPToolset_Forms_Bootstrap();
     $faux_form_bootstrap->form('faux');
 }