Exemplo n.º 1
0
 public static function get_url($key, $utm_content = false, $utm_term = false, $utm_medium = false)
 {
     if (!isset(self::$urls[$key])) {
         return '';
     }
     $url = self::$urls[$key];
     // return url if no arguments
     if (!$utm_content) {
         return $url;
     }
     // add utm content
     self::$utm_content = $utm_content;
     // use key for term, if no term isset
     if (!$utm_term) {
         $utm_term = $key;
     }
     self::$utm_term = $utm_term;
     // apply medium only if medium isset
     if ($utm_medium) {
         self::set_medium($utm_medium);
     }
     // apply arguments
     $url = self::apply_analytics_arguments_to_url($url);
     return $url;
 }
 /**
  * Add Views advertising on modal shortcode window.
  *
  * Add Views advertising on modal shortcode window. Advertisng will be 
  * added only when Views plugin is not active.
  *
  * @since 1.7
  * @param string $content Content of this filter.
  * @return string Content with advert or not.
  */
 public function add_views_advertising($content)
 {
     /**
      * do not load advertising if Views are active
      */
     if (defined('WPV_VERSION')) {
         return $content;
     }
     /**
      * Allow to turn off views advert.
      *
      * This filter allow to turn off views advert even Viwes plugin is not 
      * avaialbe.
      *
      * @since 1.7
      *
      * @param boolean $show Show adver?
      */
     if (!apply_filters('show_views_advertising', true)) {
         return;
     }
     $content .= '<div class="types-marketing types-marketing-views">';
     $content .= sprintf('<h4><span class="icon-toolset-logo ont-color-orange"></span>%s</h4>', __('Want to create templates with fields?', 'wpcf'));
     $content .= sprintf('<p>%s</p>', __('The full Toolset package allows you to design templates for content and insert fields using the WordPress editor.', 'wpcf'));
     $content .= sprintf('<p class="buttons"><a href="%s" class="button" target="_blank">%s</a> <a href="%s" class="more" target="_blank">%s</a></p>', esc_attr(Types_Helper_Url::get_url('wp-types', true, 'meet-toolset', Types_Helper_Url::UTM_MEDIUM_POSTEDIT)), __('Meet Toolset', 'wpcf'), esc_attr(Types_Helper_Url::get_url('content-templates', true, 'creating-content-templates', Types_Helper_Url::UTM_MEDIUM_POSTEDIT)), __('Creating Templates for Content', 'wpcf'));
     $content .= '</div>';
     return $content;
 }
function wpcf_admin_ctt_list_header()
{
    $custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
    $custom_taxonomies = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
    if (empty($custom_types) && empty($custom_taxonomies)) {
        printf('<p>%s %s<a href="%s" target="_blank">%s &raquo;</a></p>', __('Post Types are user-defined content types. Taxonomies are used to categorize your content.', 'wpcf'), __('You can read more about Post Types and Taxonomies in this tutorial.', 'wpcf'), Types_Helper_Url::get_url('custom-post-types'), Types_Helper_Url::get_url('custom-post-types'));
    }
}
 public function prepare()
 {
     // documentation urls
     Types_Helper_Url::load_documentation_urls();
     // set analytics medium
     Types_Helper_Url::set_medium('field_group_editor');
     // add informations
     $this->prepare_informations();
 }
Exemplo n.º 5
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('field_group_editor');
     // add informations
     $this->prepare_informations();
 }
Exemplo n.º 6
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();
     }
 }
Exemplo n.º 7
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();
     }
 }
Exemplo n.º 8
0
<?php

return array('no-archive-support' => array('type' => 'archive', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Archive_No_Support'), 'description' => array(array('type' => 'paragraph', 'content' => __('The archive is disabled for this post type.', 'types')), array('type' => 'paragraph', 'content' => __('To enable, go to <a href="%POST-TYPE-EDIT-HAS-ARCHIVE%">Options</a> and mark "has_archive".', 'types')))), 'archive-missing' => array('type' => 'archive', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Missing', 'Types_Helper_Condition_Archive_Missing'), 'description' => array(array('type' => 'paragraph', 'content' => __('Your theme is missing the standard WordPress archive for %POST-LABEL-PLURAL%.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit the %POST-LABEL-PLURAL% archive', 'types'), 'target' => '%POST-ARCHIVE-PERMALINK%'), array('type' => 'dialog', 'class' => 'button-primary types-button', 'label' => __('Resolve', 'types'), 'dialog' => array('id' => 'resolve-no-archive', 'description' => array(array('type' => 'paragraph', 'content' => __('Toolset plugins let you design archive pages without writing PHP. Your archives will include all
                    the fields that you need and your design.', 'types')), array('type' => 'link', 'class' => 'button-primary types-button', 'external' => true, 'label' => __('Learn about creating archives with Toolset', 'types'), 'target' => Types_Helper_Url::get_url('creating-archives-with-toolset', 'popup'))))))), 'archive-fields-missing' => array('type' => 'archive', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Missing', 'Types_Helper_Condition_Archive_No_Fields'), 'description' => array(array('type' => 'paragraph', 'content' => __('The %POST-LABEL-PLURAL% archive of your theme is missing custom fields.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit the %POST-LABEL-PLURAL% archive', 'types'), 'target' => '%POST-ARCHIVE-PERMALINK%'), array('type' => 'dialog', 'class' => 'button-primary types-button', 'label' => __('Resolve', 'types'), 'dialog' => array('id' => 'resolve-no-custom-fields', 'description' => array(array('type' => 'paragraph', 'content' => __('Toolset plugins let you design archives with custom fields, without writing PHP.', 'types')), array('type' => 'link', 'class' => 'button-primary types-button', 'external' => true, 'label' => __('Learn about creating archives with Toolset', 'types'), 'target' => Types_Helper_Url::get_url('creating-archives-with-toolset', 'popup'))))))), 'archive-fields' => array('type' => 'archive', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Missing', 'Types_Helper_Condition_Archive_Has_Fields'), 'description' => array(array('type' => 'paragraph', 'content' => __('Your theme displays the %POST-LABEL-SINGULAR% archive using the file: %POST-ARCHIVE-FILE%', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit the %POST-LABEL-PLURAL% archive', 'types'), 'target' => '%POST-ARCHIVE-PERMALINK%'))), 'views-archive-missing' => array('type' => 'archive', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Archive_Missing'), 'description' => array(array('type' => 'paragraph', 'content' => __('There is no WordPress Archive for %POST-LABEL-PLURAL%.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit the %POST-LABEL-PLURAL% archive', 'types'), 'target' => '%POST-ARCHIVE-PERMALINK%'), array('type' => 'link', 'class' => 'button-primary types-button', 'target' => '%POST-CREATE-VIEWS-ARCHIVE%', 'label' => __('Create archive', 'types')))), 'views-archive' => array('type' => 'archive', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Archive_Exists'), 'description' => array(array('type' => 'paragraph', 'content' => __('The WordPress Archive for %POST-LABEL-PLURAL% is "%POST-VIEWS-ARCHIVE%"', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit the %POST-LABEL-PLURAL% archive', 'types'), 'target' => '%POST-ARCHIVE-PERMALINK%'), array('type' => 'link', 'class' => 'button', 'label' => __('Edit WordPress Archive', 'types'), 'target' => '%POST-EDIT-VIEWS-ARCHIVE%'))), 'layouts-archive-missing' => array('type' => 'archive', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Layouts_Active', 'Types_Helper_Condition_Layouts_Archive_Missing'), 'description' => array(array('type' => 'paragraph', 'content' => __('There is no layout for the %POST-LABEL-PLURAL% archive.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit the %POST-LABEL-PLURAL% archive', 'types'), 'target' => '%POST-ARCHIVE-PERMALINK%'), array('type' => 'link', 'class' => 'button-primary types-button', 'label' => __('Create archive', 'types'), 'target' => '%POST-CREATE-LAYOUT-ARCHIVE%'))), 'layouts-archive' => array('type' => 'archive', 'conditions' => array('Types_Helper_Condition_Layouts_Active', 'Types_Helper_Condition_Layouts_Archive_Exists'), 'description' => array(array('type' => 'paragraph', 'content' => __('The layout for the %POST-LABEL-PLURAL% archive is "%POST-LAYOUT-ARCHIVE%".', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit the %POST-LABEL-PLURAL% archive', 'types'), 'target' => '%POST-ARCHIVE-PERMALINK%'), array('type' => 'link', 'class' => 'button', 'label' => __('Edit layout', 'types'), 'target' => '%POST-EDIT-LAYOUT-ARCHIVE%'))));
Exemplo n.º 9
0
<?php

return array('cred-missing' => array('type' => 'forms', 'conditions' => array('Types_Helper_Condition_Cred_Missing'), 'description' => array(array('type' => 'dialog', 'class' => 'button', 'label' => __('Create Form', 'types'), 'dialog' => array('id' => 'create-form', 'description' => array(array('type' => 'paragraph', 'content' => __('To create a form for front-end content submission and editing, you need to have CRED plugin installed.
                    CRED is part of the complete Toolset package for adding and displaying custom content.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Learn how CRED forms work', 'types'), 'target' => Types_Helper_Url::get_url('how-cred-work', 'popup'))))))), 'cred-forms-missing' => array('type' => 'forms', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Cred_Forms_Missing'), 'description' => array(array('type' => 'link', 'class' => 'button', 'target' => '%POST-CREATE-FORM%', 'label' => __('Create form', 'types')))), 'cred-forms' => array('type' => 'forms', 'conditions' => array('Types_Helper_Condition_Cred_Active', 'Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Cred_Forms_Exist'), 'description' => array(array('type' => 'paragraph', 'content' => '%POST-FORMS-LIST%', 'types'), array('type' => 'link', 'class' => 'button', 'target' => '%POST-CREATE-FORM%', 'label' => __('Create form', 'types')))), 'cred-layouts-forms-missing' => array('type' => 'forms', 'conditions' => array('Types_Helper_Condition_Layouts_Active', 'Types_Helper_Condition_Cred_Forms_Missing'), 'description' => array(array('type' => 'paragraph', 'content' => __('You can create forms for front-end submission and editing of %POST-LABEL-PLURAL%.', 'types')), array('type' => 'link', 'external' => true, 'target' => Types_Helper_Url::get_url('adding-forms-to-layouts', 'table'), 'label' => __('Learn how', 'types')))), 'cred-layouts-forms' => array('type' => 'forms', 'conditions' => array('Types_Helper_Condition_Layouts_Active', 'Types_Helper_Condition_Cred_Forms_Exist'), 'description' => array(array('type' => 'paragraph', 'content' => '%POST-FORMS-LIST%', 'types'), array('type' => 'link', 'external' => true, 'target' => Types_Helper_Url::get_url('adding-forms-to-layouts', 'table'), 'label' => __('How to add forms to layouts', 'types')))));
Exemplo n.º 10
0
/**
 * Returns contextual help.
 *
 * @param string $page
 * @param $contextual_help
 *
 * @return string
 * @deprecated Use Types_Asset_Help_Tab_Loader instead.
 */
function wpcf_admin_help($page, $contextual_help = '')
{
    Types_Helper_Url::load_documentation_urls();
    Types_Helper_Url::set_medium(Types_Helper_Url::UTM_MEDIUM_HELP);
    $help = '';
    switch ($page) {
        // Post Fields (list)
        case 'custom_fields':
        case 'wpcf-cf':
            $help .= '' . __("Types plugin organizes post fields in groups. Once you create a group, you can add the fields to it and control to what content it belongs.", 'wpcf') . PHP_EOL . PHP_EOL . sprintf(__('You can read more about Post Fields in this tutorial: %s.', 'wpcf'), sprintf('<a href="%s" target="_blank">%s &raquo;</a>', Types_Helper_Url::get_url('using-post-fields', true, 'using-custom-fields'), Types_Helper_Url::get_url('using-post-fields', false, false, false, false))) . PHP_EOL . PHP_EOL . __("On this page you can see your current post field groups, as well as information about which post types and taxonomies they are attached to, and whether they are active or not.", 'wpcf') . PHP_EOL . PHP_EOL . sprintf('<h3>%s</h3>', __('You have the following options:', 'wpcf')) . '<dl>' . '<dt>' . __('Add New', 'wpcf') . '</dt>' . '<dd>' . __('Use this to add a new post fields group which can be attached to a post type', 'wpcf') . '</dd>' . '<dt>' . __('Edit', 'wpcf') . '</dt>' . '<dd>' . __('Click to edit the post field group', 'wpcf') . '</dd>' . '<dt>' . __('Activate', 'wpcf') . '</dt>' . '<dd>' . __('Click to activate a post field group', 'wpcf') . '</dd>' . '<dt>' . __('Deactivate', 'wpcf') . '</dt>' . '<dd>' . __('Click to deactivate a post field group (this can be re-activated at a later date)', 'wpcf') . '</dd>' . '<dt>' . __('Delete', 'wpcf') . '</dt>' . '<dd>' . __('Click to delete a post field group.', 'wpcf') . ' ' . sprintf('<strong>%s</strong>', __('Warning: This cannot be undone.', 'wpcf')) . '</dd>' . '</dl>';
            break;
        case 'need-more-help':
            // Post fields
            $help .= sprintf('<h4>%s</h4>', __('Post Fields', 'wpcf'));
            $help .= '<ul>';
            $help .= sprintf('<li><a target="_blank" href="%s">%s &raquo;</a></li>', Types_Helper_Url::get_url('adding-fields', true), __('Adding post fields to content', 'wpcf'));
            $help .= sprintf('<li><a target="_blank" href="%s">%s &raquo;</a></li>', Types_Helper_Url::get_url('displaying-fields', true), __('Displaying post fields on front-end', 'wpcf'));
            $help .= '</ul>';
            // User fields
            $help .= sprintf('<h4>%s</h4>', __('User Fields', 'wpcf'));
            $help .= '<ul>';
            $help .= sprintf('<li><a target="_blank" href="%s">%s &raquo;</a></li>', Types_Helper_Url::get_url('adding-user-fields', true), __('Adding user fields to user profiles', 'wpcf'));
            $help .= sprintf('<li><a target="_blank" href="%s">%s &raquo;</a></li>', Types_Helper_Url::get_url('displaying-user-fields', true), __('Displaying user fields on front-end', 'wpcf'));
            $help .= '</ul>';
            // Term fields
            $help .= sprintf('<h4>%s</h4>
				<ul>
					<li><a target="_blank" href="%s">%s &raquo;</a></li>
					<li><a target="_blank" href="%s">%s &raquo;</a></li>
				</ul>', __('Term Fields', 'wpcf'), Types_Helper_Url::get_url('adding-term-fields', true), __('Adding term fields to taxonomies', 'wpcf'), Types_Helper_Url::get_url('displaying-term-fields', true), __('Displaying term fields on front-end', 'wpcf'));
            $help .= sprintf('<h4>%s</h4>', __('Post Types and Taxonomy', 'wpcf'));
            $help .= '<ul>';
            $help .= sprintf('<li><a target="_blank" href="%s">%s &raquo;</a></li>', Types_Helper_Url::get_url('custom-post-types', true), __('Creating and using post types', 'wpcf'));
            $help .= sprintf('<li><a target="_blank" href="%s">%s &raquo;</a></li>', Types_Helper_Url::get_url('custom-taxonomy', true), __('Arranging content with Taxonomy', 'wpcf'));
            $help .= sprintf('<li><a target="_blank" href="%s">%s &raquo;</a></li>', Types_Helper_Url::get_url('post-relationship', true), __('Creating parent / child relationships', 'wpcf'));
            $help .= '</ul>';
            break;
        case 'wpcf-ctt':
        case 'custom_taxonomies_list':
            $help .= '' . __('This is the Taxonomies list. It provides you with an overview of your data.', 'wpcf') . PHP_EOL . PHP_EOL . sprintf(__('You can read more about Post Types and Taxonomies in this tutorial. %s', 'wpcf'), sprintf('<a href="%s" target="_blank">%s &raquo;</a>', Types_Helper_Url::get_url('custom-post-types', true), Types_Helper_Url::get_url('custom-post-types', false, false, false, false))) . PHP_EOL . PHP_EOL . sprintf('<h3>%s</h3>', __('On this page you have the following options:', 'wpcf')) . '<dl>' . '<dt>' . __('Add New', 'wpcf') . '<dd>' . __('Use to create a new Taxonomy', 'wpcf') . '<dt>' . __('Edit', 'wpcf') . '<dd>' . __('Click to edit the settings of a Taxonomy', 'wpcf') . '</dd>' . '<dt>' . __('Deactivate', 'wpcf') . '<dd>' . __('Click to deactivate a Taxonomy (this can be reactivated at a later date)', 'wpcf') . '</dd>' . '<dt>' . __('Duplicate', 'wpcf') . '<dd>' . __('Click to duplicate a Taxonomy', 'wpcf') . '</dd>' . '<dt>' . __('Delete', 'wpcf') . '<dd>' . __('Click to delete a Taxonomy.', 'wpcf') . ' ' . sprintf('<strong>%s</strong>', __('Warning: This cannot be undone.', 'wpcf')) . '</dd>' . '</dl>';
            break;
        case 'wpcf-cpt':
        case 'post_types_list':
            $help .= '' . __('This is the main admin page for built-in Post Types and your Post Types. It provides you with an overview of your data.', 'wpcf') . PHP_EOL . PHP_EOL . __('Post Types are built-in and user-defined content types.', 'wpcf') . PHP_EOL . PHP_EOL . sprintf(__('You can read more about Post Types and Taxonomies in this tutorial. %s', 'wpcf'), sprintf('<a href="%s" target="_blank">%s &raquo;</a>', Types_Helper_Url::get_url('custom-post-types', true), Types_Helper_Url::get_url('custom-post-types', false, false, false, false))) . PHP_EOL . PHP_EOL . sprintf('<h3>%s</h3>', __('On this page you have the following options:', 'wpcf')) . '<dl>' . '<dt>' . __('Add New', 'wpcf') . '</dt>' . '<dd>' . __('Use to create a new Post Type', 'wpcf') . '</dd>' . '<dt>' . __('Edit', 'wpcf') . '</dt>' . '<dd>' . __('Click to edit the settings of a Post Type', 'wpcf') . '</dd>' . '<dt>' . __('Deactivate', 'wpcf') . '</dt>' . '<dd>' . __('Click to deactivate a Post Type (this can be reactivated at a later date)', 'wpcf') . '</dd>' . '<dt>' . __('Duplicate', 'wpcf') . '<dd>' . __('Click to duplicate a Post Type', 'wpcf') . '</dd>' . '<dt>' . __('Delete', 'wpcf') . '</dt>' . '<dd>' . __('Click to delete a Post Type.', 'wpcf') . ' ' . sprintf('<strong>%s</strong>', __('Warning: This cannot be undone.', 'wpcf')) . '</dd>' . '</dl>';
            break;
            // Add/Edit group form page
        // Add/Edit group form page
        case 'wpcf-edit':
        case 'edit_group':
            $help .= '' . __('This is the edit page for your Post Field Groups.', 'wpcf') . PHP_EOL . PHP_EOL . __('On this page you can create and edit your groups. To create a group, do the following:', 'wpcf') . '<ol style="list-style-type:decimal;"><li style="list-style-type:decimal;">' . __('Add a Title.', 'wpcf') . '</li><li style="list-style-type:decimal;">' . __('Choose where to display your group. You can attach this to both default WordPress post types and Post Types (you can also associate Taxonomy terms with Post Field Groups).', 'wpcf') . '</li><li style="list-style-type:decimal;">' . __('To add a field, click on "Add New Field" and choose the field you desire. This will be added to your Post Field Group.', 'wpcf') . '</li><li style="list-style-type:decimal;">' . __('Add information about your Post Field.', 'wpcf') . '</li></ol>' . '<h3>' . __('Tips', 'wpcf') . '</h3>' . '<ul><li>' . __('To ensure a user fills out a field, check Required in Validation section.', 'wpcf') . '</li><li>' . __('Once you have created a field, it will be saved for future use under "Choose from previously created fields" of "Add New Field" dialog.', 'wpcf') . '</li><li>' . __('You can drag and drop the order of your post fields.', 'wpcf') . '</li></ul>';
            break;
            // Add/Edit custom type form page
        // Add/Edit custom type form page
        case 'wpcf-edit-type':
        case 'edit_type':
            $help .= '' . __('Use this page to create a WordPress post type. If you’d like to learn more about Post Types you can read our detailed guide: <a href="https://wp-types.com/user-guides/create-a-custom-post-type/" target="_blank">https://wp-types.com/user-guides/create-a-custom-post-type/</a>', 'wpcf') . PHP_EOL . PHP_EOL . '<dt>' . __('Name and Description', 'wpcf') . '</dt>' . '<dd>' . __('Add a singular and plural name for your post type. You should also add a slug. This will be created from the post type name if none is added.', 'wpcf') . '</dd>' . '<dt>' . __('Visibility', 'wpcf') . '</dt>' . '<dd>' . __('Determine whether your post type will be visible on the admin menu to your users.', 'wpcf') . '</dd>' . '<dd>' . __('You can also adjust the menu position. The default position is 20, which means your post type will appear under “Pages”. You can find more information about menu positioning in the WordPress Codex. <a href="http://codex.wordpress.org/Function_Reference/register_post_type#Parameters" target="_blank">http://codex.wordpress.org/Function_Reference/register_post_type#Parameters</a>', 'wpcf') . '</dd>' . '<dd>' . __('The default post type icon is the pushpin icon that appears beside WordPress posts. You can change this by adding your own icon of 16px x 16px.', 'wpcf') . '</dd>' . '<dt>' . __('Select Taxonomies', 'wpcf') . '</dt>' . '<dd>' . __('Choose which taxonomies are to be associated with this post type.', 'wpcf') . '</dd>' . '<dt>' . __('Labels', 'wpcf') . '</dt>' . '<dd>' . __('Labels are the text that is attached to your post type name. Examples of them in use are “Add New Post” (where “Add New” is the label”) and “Edit Post” (where “Edit” is the label). In normal circumstances the defaults will suffice.', 'wpcf') . '</dd>' . '<dt>' . __('Custom Post Properties', 'wpcf') . '</dt>' . '<dd>' . __('Choose which sections to display on your “Add New” page.', 'wpcf') . '</dd>' . '<dt>' . __('Advanced Settings', 'wpcf') . '</dt>' . '<dd>' . __('Advanced settings give you even more control over your post type. You can read in detail what all of these settings do on our tutorial.', 'wpcf') . '</dd>' . '</dl>';
            break;
            // Add/Edit Taxonomy form page
        // Add/Edit Taxonomy form page
        case 'wpcf-edit-tax':
        case 'edit_tax':
            $help .= '' . __('You can use Taxonomies to categorize your content. Read more about what they are on our website: <a href="https://wp-types.com/user-guides/create-a-custom-post-type/" target="_blank">https://wp-types.com/user-guides/create-a-custom-post-type/ &raquo;</a> or you can read our guide about how to set them up: <a href="http://wp-types.com/user-guides/create-custom-taxonomies/" target="_blank">http://wp-types.com/user-guides/create-custom-taxonomies/</a>', 'wpcf') . '<dl>' . '<dt>' . __('Name and Description', 'wpcf') . '</dt>' . '<dd>' . __('Add a singular and plural name for your Taxonomy. You should also add a slug. This will be created from the Taxonomy name if none is added.', 'wpcf') . '</dd>' . '<dt>' . __('Visibility', 'wpcf') . '</dt>' . '<dd>' . __('Determine whether your Taxonomy will be visible on the admin menu to your users.', 'wpcf') . '</dd>' . '<dt>' . __('Select Post Types', 'wpcf') . '</dt>' . '<dd>' . __('Choose which Post Types this Taxonomy should be associated with.', 'wpcf') . '</dd>' . '<dt>' . __('Labels', 'wpcf') . '</dt>' . '<dd>' . __('Labels are the text that is attached to your Taxonomy name. Examples of them in use are “Add New Taxonomy” (where “Add New” is the label”) and “Edit Taxonomy” (where “Edit” is the label). In normal circumstances the defaults will suffice.', 'wpcf') . '</dd>' . '<dt>' . __('Options', 'wpcf') . '</dt>' . '<dd>' . __('Advanced settings give you even more control over your Taxonomy. You can read in detail what all of these settings do on our tutorial.', 'wpcf') . '</dd>' . '</dl>';
            break;
        case 'wpcf-um':
        case 'user_fields_list':
            $help .= '' . __("Types plugin organizes User Fields in groups. Once you create a group, you can add the fields to it and control to what content it belongs.", 'wpcf') . PHP_EOL . PHP_EOL . __("On this page you can see your current User Fields groups, as well as information about which user role they are attached to, and whether they are active or not.", 'wpcf') . sprintf('<h3>%s</h3>', __('You have the following options:', 'wpcf')) . '<dl>' . '<dt>' . __('Add New', 'wpcf') . '</dt>' . '<dd>' . __('Use this to add a new User Field Group', 'wpcf') . '</dd>' . '<dt>' . __('Edit', 'wpcf') . '</dt>' . '<dd>' . __('Click to edit the User Field Group', 'wpcf') . '</dd>' . '<dt>' . __('Activate', 'wpcf') . '</dt>' . '<dd>' . __('Click to activate a User Field Group', 'wpcf') . '</dd>' . '<dt>' . __('Deactivate', 'wpcf') . '</dt>' . '<dd>' . __('Click to deactivate a User Field Group (this can be re-activated at a later date)', 'wpcf') . '</dd>' . '<dt>' . __('Delete', 'wpcf') . '</dt>' . '<dd>' . __('Click to delete a User Field Group.', 'wpcf') . ' ' . sprintf('<strong>%s</strong>', __('Warning: This cannot be undone.', 'wpcf')) . '</dd>' . '</dl>';
            break;
        case 'wpcf-edit-usermeta':
        case 'user_fields_edit':
            $help .= '' . __('This is the edit page for your User Field Groups.', 'wpcf') . PHP_EOL . PHP_EOL . __('On this page you can create and edit your groups. To create a group, do the following:', 'wpcf') . '<ol><li>' . __('Add a Title', 'wpcf') . '</li><li>' . __('Choose where to display your group. You can attach this to both default WordPress user roles and custom roles.', 'wpcf') . '</li><li>' . __('To add a field, click on "Add New Field" and choose the field you desire. This will be added to your User Field Group.', 'wpcf') . '</li><li>' . __('Add information about your User Field.', 'wpcf') . '</li></ol>' . '<h3>' . __('Tips', 'wpcf') . '</h3>' . '<ul><li>' . __('To ensure a user fills out a field, check Required in Validation section.', 'wpcf') . '</li><li>' . __('Once you have created a field, it will be saved for future use under "Choose from previously created fields" of "Add New Field" dialog.', 'wpcf') . '</li><li>' . __('You can drag and drop the order of your user fields.', 'wpcf') . '</li></ul>';
            break;
    }
    // to keep already translated strings
    $help = str_replace('href="https://wp-types.com/user-guides/create-a-custom-post-type/"', 'href="' . Types_Helper_Url::get_url('custom-post-types', true) . '"', $help);
    $help = str_replace('href="http://wp-types.com/user-guides/create-a-custom-post-type/"', 'href="' . Types_Helper_Url::get_url('custom-post-types', true) . '"', $help);
    $help = str_replace('href="http://wp-types.com/user-guides/create-custom-taxonomies/"', 'href="' . Types_Helper_Url::get_url('custom-taxonomy', true) . '"', $help);
    $help = str_replace('href="http://wp-types.com/user-guides/using-custom-fields/"', 'href="' . Types_Helper_Url::get_url('using-post-fields', true, 'post-fields') . '"', $help);
    return wpautop($help);
}
function wpcf_admin_metabox_relationship($post_type)
{
    $form = array();
    $form['description'] = array('#type' => 'markup', '#markup' => sprintf('<p class="description">%s</p>', sprintf('%s <a href="%s" target="_blank">%s</a>.', __('Parent/child relationship lets you connect between posts of different types. When you edit a parent, you will see its children listed in a table and you can edit the fields of the children. When you edit a child, you can choose the parents. On the front-end, you can display a list of children or information about the parents.', 'wpcf'), Types_Helper_Url::get_url('post-relationship', true, 'parent_child_relationship', Types_Helper_Url::UTM_MEDIUM_POSTEDIT), __('Parent/child documentation', 'wpcf'))));
    $custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
    $is_error = false;
    $error_message = '';
    // Detect situations when we cannot configure post relationships yet. Render a message and finish.
    $is_unsaved_post_type = !isset($_REQUEST['wpcf-post-type']) || !isset($custom_types[$_REQUEST['wpcf-post-type']]);
    if ($is_unsaved_post_type) {
        $is_error = true;
        $error_message = __('Please save first, before you can edit the relationship.', 'wpcf');
    }
    $is_attachment = isset($_REQUEST['wpcf-post-type']) && 'attachment' == $_REQUEST['wpcf-post-type'];
    if ($is_attachment) {
        $is_error = true;
        $error_message = __('Post relationships are not allowed for the Media post type.', 'wpcf');
    }
    if ($is_error) {
        $form['alert'] = array('#type' => 'notice', '#markup' => $error_message);
        $form = wpcf_form(__FUNCTION__, $form);
        echo $form->renderForm();
        return;
    }
    $post_type = $custom_types[$_REQUEST['wpcf-post-type']];
    unset($custom_types);
    // No problems detected, go ahead and render the options.
    // belongs/children section
    $has = wpcf_pr_admin_get_has($post_type['slug']);
    $belongs = wpcf_pr_admin_get_belongs($post_type['slug']);
    $post_types = get_post_types('', 'objects');
    // parents
    $form['parent-h3'] = array('#type' => 'markup', '#markup' => sprintf('<h3>%s</h3>', __('Parent Post Types:', 'wpcf')));
    $form['parent-description'] = array('#type' => 'markup', '#markup' => sprintf('<p class="description">%s</p>', __('Select which post types will be parents of this type.', 'wpcf')));
    $options = array();
    // Build excluded post types
    global $wpcf;
    $excluded_post_types = $wpcf->excluded_post_types;
    $excluded_post_types[] = $post_type['slug'];
    // Explicitly exclude attachments for post relationships because there is no GUI for it
    // (but we're not excluding them from all Types functionality)
    $excluded_post_types[] = 'attachment';
    foreach ($post_types as $post_type_option_slug => $post_type_option) {
        $is_excluded = in_array($post_type_option_slug, $excluded_post_types);
        $has_no_ui = !$post_type_option->show_ui && !apply_filters('wpcf_show_ui_hide_in_relationships', true);
        if ($is_excluded || $has_no_ui) {
            continue;
        }
        $options[$post_type_option_slug] = array('#name' => 'ct[post_relationship][belongs][' . $post_type_option_slug . ']', '#title' => $post_type_option->labels->singular_name, '#default_value' => isset($belongs[$post_type_option_slug]), '#inline' => true, '#before' => '<li>', '#after' => '</li>', '#attributes' => array('class' => 'js-wpcf-relationship-checkbox', 'data-wpcf-type' => 'belongs', 'data-wpcf-value' => esc_attr($post_type_option_slug), 'data-wpcf-message-disabled' => esc_attr__('This post type is disabled, becouse is used as child post.', 'wpcf')));
        if (isset($has[$post_type_option_slug])) {
            $options[$post_type_option_slug]['#before'] = '<li class="disabled">';
            $options[$post_type_option_slug]['#attributes']['disabled'] = 'disabled';
        }
    }
    $form['table-pr-belongs-form'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'ct[post_relationship]', '#inline' => true, '#before' => '<ul>', '#after' => '</ul>');
    // child posts
    $form['child-h3'] = array('#type' => 'markup', '#markup' => sprintf('<hr /><h3>%s</h3>', __('Children Post Types:', 'wpcf')));
    $form['child-description'] = array('#type' => 'markup', '#markup' => sprintf('<p class="description">%s</p>', __('Select which post types will be children of this type.', 'wpcf')));
    $options = array();
    foreach ($post_types as $post_type_option_slug => $post_type_option) {
        if (in_array($post_type_option_slug, $excluded_post_types) || !$post_type_option->show_ui && !apply_filters('wpcf_show_ui_hide_in_relationships', true)) {
            continue;
        }
        $nonce = sprintf('child-post-fields-%s-%s', $post_type['slug'], $post_type_option_slug);
        $a = sprintf(' <span>(<a class="js-wpcf-edit-child-post-fields" href="#" data-wpcf-nonce="%s" data-wpcf-child="%s" data-wpcf-parent="%s" data-wpcf-title="%s" data-wpcf-buttons-apply="%s" data-wpcf-buttons-cancel="%s" data-wpcf-message-loading="%s" data-wpcf-save-status="%s">%s</a>)</span>', esc_attr(wp_create_nonce($nonce)), esc_attr($post_type_option_slug), esc_attr($post_type['slug']), esc_attr(sprintf(__('Select child fields from %s to be displayed in Post Relationship table', 'wpcf'), $post_type_option->labels->singular_name)), esc_attr__('Apply', 'wpcf'), esc_attr__('Cancel', 'wpcf'), esc_attr__('Please Wait, Loading…', 'wpcf'), esc_attr(isset($has[$post_type_option_slug]) ? 'saved' : 'new'), esc_attr__('Select fields', 'wpcf'));
        $options[$post_type_option_slug] = array('#name' => 'ct[post_relationship][has][' . $post_type_option_slug . ']', '#title' => $post_type_option->labels->singular_name, '#inline' => true, '#before' => '<li>', '#after' => $a . '</li>', '#attributes' => array('class' => 'js-wpcf-relationship-checkbox', 'data-wpcf-type' => 'has', 'data-wpcf-value' => esc_attr($post_type_option_slug), 'data-wpcf-message-disabled' => esc_attr__('This post type is disabled, becouse is used as parent post.', 'wpcf')));
        // Check if it already belongs
        if (isset($belongs[$post_type_option_slug])) {
            $options[$post_type_option_slug]['#before'] = '<li class="disabled">';
            $options[$post_type_option_slug]['#attributes']['disabled'] = 'disabled';
        } else {
            if (isset($has[$post_type_option_slug])) {
                $options[$post_type_option_slug]['#default_value'] = true;
                $options[$post_type_option_slug]['#before'] = '<li class="active">';
            }
        }
    }
    $form['table-pr-has-form'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'ct[post_relationship]', '#inline' => true, '#before' => '<ul>', '#after' => '</ul>');
    $form = wpcf_form(__FUNCTION__, $form);
    echo $form->renderForm();
}
Exemplo n.º 12
0
/**
 * Generates form data.
 * 
 * @deprecated Possibly deprecated, no usage found in Types. Possibly identical code in Types_Admin_Edit_Fields::get_field_form_data()
 */
function wpcf_admin_fields_form()
{
    /**
     * include common functions
     */
    include_once dirname(__FILE__) . '/common-functions.php';
    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') . '\'');
    $default = array();
    global $wpcf_button_style;
    global $wpcf_button_style30;
    global $wpcf;
    $form = array();
    $form['#form']['callback'] = array('wpcf_admin_save_fields_groups_submit');
    // Form sidebars
    if ($current_user_can_edit) {
        $form['open-sidebar'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-fields-align-right">');
        // Set help icon
        $form['help-icon'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-admin-fields-help"><img src="' . WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/res/images/question.png" style="position:relative;top:2px;" />&nbsp;<a href="' . Types_Helper_Url::get_url('using-post-fields', 'fields-editor', 'fields-help', Types_Helper_Url::UTM_MEDIUM_HELP) . '" target="_blank">' . __('Custom fields help', 'wpcf') . '</a></div>');
        $form['submit2'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
        $form['fields'] = array('#type' => 'fieldset', '#title' => __('Available fields', 'wpcf'));
        // Get field types
        $fields_registered = wpcf_admin_fields_get_available_types();
        foreach ($fields_registered as $filename => $data) {
            $form['fields'][basename($filename, '.php')] = array('#type' => 'markup', '#markup' => '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax&amp;wpcf_action=fields_insert' . '&amp;field=' . basename($filename, '.php') . '&amp;page=wpcf-edit') . '&amp;_wpnonce=' . wp_create_nonce('fields_insert') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary">' . $data['title'] . '</a> ');
            // Process JS
            if (!empty($data['group_form_js'])) {
                foreach ($data['group_form_js'] as $handle => $script) {
                    if (isset($script['inline'])) {
                        add_action('admin_footer', $script['inline']);
                        continue;
                    }
                    $deps = !empty($script['deps']) ? $script['deps'] : array();
                    $in_footer = !empty($script['in_footer']) ? $script['in_footer'] : false;
                    wp_register_script($handle, $script['src'], $deps, WPCF_VERSION, $in_footer);
                    wp_enqueue_script($handle);
                }
            }
            // Process CSS
            if (!empty($data['group_form_css'])) {
                foreach ($data['group_form_css'] as $handle => $script) {
                    if (isset($script['src'])) {
                        $deps = !empty($script['deps']) ? $script['deps'] : array();
                        wp_enqueue_style($handle, $script['src'], $deps, WPCF_VERSION);
                    } else {
                        if (isset($script['inline'])) {
                            add_action('admin_head', $script['inline']);
                        }
                    }
                }
            }
        }
        // Get fields created by user
        $fields = wpcf_admin_fields_get_fields(true, true);
        if (!empty($fields)) {
            $form['fields-existing'] = array('#type' => 'fieldset', '#title' => __('User created fields', 'wpcf'), '#id' => 'wpcf-form-groups-user-fields');
            foreach ($fields as $key => $field) {
                if (isset($update['fields']) && array_key_exists($key, $update['fields'])) {
                    continue;
                }
                if (!empty($field['data']['removed_from_history'])) {
                    continue;
                }
                $form['fields-existing'][$key] = array('#type' => 'markup', '#markup' => '<div id="wpcf-user-created-fields-wrapper-' . $field['id'] . '" style="float:left; margin-right: 10px;"><a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;wpcf_action=fields_insert_existing' . '&amp;page=wpcf-edit' . '&amp;field=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('fields_insert_existing') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary" onclick="jQuery(this).parent().fadeOut();" ' . ' data-slug="' . $field['id'] . '">' . htmlspecialchars(stripslashes($field['name'])) . '</a>' . '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;wpcf_action=remove_from_history' . '&amp;field_id=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('remove_from_history') . '&amp;wpcf_warning=' . sprintf(__('Are you sure that you want to remove field %s from history?', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '&amp;wpcf_ajax_update=wpcf-user-created-fields-wrapper-' . $field['id'] . '" title="' . sprintf(__('Remove field %s', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '" class="wpcf-ajax-link"><img src="' . WPCF_RES_RELPATH . '/images/delete-2.png" style="postion:absolute;margin-top:5px;margin-left:-4px;" /></a></div>');
            }
        }
        $form['close-sidebar'] = array('#type' => 'markup', '#markup' => '</div>');
    }
    // Group data
    $form['open-main'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-form-fields-main" class="wpcf-form-fields-main">');
    /**
     * Now starting form
     */
    /** End admin Styles * */
    // Group fields
    $form['fields_title'] = array('#type' => 'markup', '#markup' => '<h2>' . __('Fields', 'wpcf') . '</h2>');
    $show_under_title = true;
    $form['ajax-response-open'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-fields-sortable" class="ui-sortable">');
    // If it's update, display existing fields
    $existing_fields = array();
    if ($update && isset($update['fields'])) {
        foreach ($update['fields'] as $slug => $field) {
            $field['submitted_key'] = $slug;
            $field['group_id'] = $update['id'];
            $form_field = wpcf_fields_get_field_form_data($field['type'], $field);
            if (is_array($form_field)) {
                $form['draggable-open-' . rand()] = array('#type' => 'markup', '#markup' => '<div class="ui-draggable">');
                $form = $form + $form_field;
                $form['draggable-close-' . rand()] = array('#type' => 'markup', '#markup' => '</div>');
            }
            $existing_fields[] = $slug;
            $show_under_title = false;
        }
    }
    // Any new fields submitted but failed? (Don't double it)
    if (!empty($_POST['wpcf']['fields'])) {
        foreach ($_POST['wpcf']['fields'] as $key => $field) {
            if (in_array($key, $existing_fields)) {
                continue;
            }
            $field['submitted_key'] = $key;
            $form_field = wpcf_fields_get_field_form_data($field['type'], $field);
            if (is_array($form_field)) {
                $form['draggable-open-' . rand()] = array('#type' => 'markup', '#markup' => '<div class="ui-draggable">');
                $form = $form + $form_field;
                $form['draggable-close-' . rand()] = array('#type' => 'markup', '#markup' => '</div>');
            }
        }
        $show_under_title = false;
    }
    $form['ajax-response-close'] = array('#type' => 'markup', '#markup' => '</div>' . '<div id="wpcf-ajax-response"></div>');
    if ($show_under_title) {
        $form['fields_title']['#markup'] = $form['fields_title']['#markup'] . '<div id="wpcf-fields-under-title">' . __('There are no fields in this group. To add a field, click on the field buttons at the right.', 'wpcf') . '</div>';
    }
    // If update, create ID field
    if ($update) {
        $form['group_id'] = array('#type' => 'hidden', '#name' => 'group_id', '#value' => $update['id'], '#forced_value' => true);
    }
    $form['submit'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
    // Close main div
    $form['close-sidebar'] = array('#type' => 'markup', '#markup' => '</div>');
    $form = apply_filters('wpcf_form_fields', $form, $update);
    // Add JS settings
    wpcf_admin_add_js_settings('wpcfFormUniqueValuesCheckText', '\'' . __('Warning: same values selected', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUniqueNamesCheckText', '\'' . __('Warning: field name already used', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUniqueSlugsCheckText', '\'' . __('Warning: field slug already used', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormAlertOnlyPreview', sprintf("'%s'", __('Sorry, but this is only preview!', 'wpcf')));
    $form['form-close'] = array('#type' => 'markup', '#markup' => '</div>');
    /**
     * return form if current_user_can edit
     */
    if ($current_user_can_edit) {
        return $form;
    }
    return wpcf_admin_common_only_show($form);
}
Exemplo n.º 13
0
<?php

return array('single-missing' => array('type' => 'template', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Missing', 'Types_Helper_Condition_Single_Missing'), 'description' => array(array('type' => 'paragraph', 'content' => __('Your theme doesn’t have a template to display %POST-LABEL-PLURAL%.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit example %POST-LABEL-SINGULAR%', 'types'), 'target' => '%POST-PERMALINK%'), array('type' => 'dialog', 'class' => 'button-primary types-button', 'label' => __('Resolve', 'types'), 'dialog' => array('id' => 'resolve-single-no-template', 'description' => array(array('type' => 'paragraph', 'content' => __('Toolset plugins let you design templates for single items (%POST-LABEL-SINGULAR% pages) without
                        writing PHP. Your templates will include all the fields that you need and your design.', 'types')), array('type' => 'link', 'class' => 'button-primary types-button', 'external' => true, 'label' => __('Learn about creating templates with Toolset', 'types'), 'target' => Types_Helper_Url::get_url('creating-templates-with-toolset', 'popup'))))))), 'single-fields-missing' => array('type' => 'template', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Missing', 'Types_Helper_Condition_Single_No_Fields'), 'description' => array(array('type' => 'paragraph', 'content' => __('Your theme’s template file for displaying %POST-LABEL-SINGULAR% items is missing custom fields.', 'types')), array('type' => 'link', 'external' => true, 'label' => array('default' => __('Visit example %POST-LABEL-SINGULAR%', 'types'), 'post-edit' => __('Visit this %POST-LABEL-SINGULAR%', 'types')), 'target' => '%POST-PERMALINK%'), array('type' => 'dialog', 'class' => 'button-primary types-button', 'label' => __('Resolve', 'types'), 'dialog' => array('id' => 'resolve-single-no-fields', 'description' => array(array('type' => 'paragraph', 'content' => __('Toolset plugins let you design templates for single items (%POST-LABEL-SINGULAR% pages),
                    with all the fields that you need to display.', 'types')), array('type' => 'link', 'class' => 'button-primary types-button', 'external' => true, 'label' => __('Learn about creating templates with Toolset', 'types'), 'target' => Types_Helper_Url::get_url('creating-templates-with-toolset', 'popup'))))))), 'single-fields' => array('type' => 'template', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Missing', 'Types_Helper_Condition_Single_Has_Fields'), 'description' => array(array('type' => 'paragraph', 'content' => __('Your theme displays single %POST-LABEL-SINGULAR% pages using the template file: %POST-TEMPLATE-FILE%', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit example %POST-LABEL-SINGULAR%', 'types'), 'target' => '%POST-PERMALINK%'))), 'views-template-missing' => array('type' => 'template', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Template_Missing'), 'description' => array(array('type' => 'paragraph', 'content' => __('There is no Content Template for %POST-LABEL-SINGULAR% items.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit example %POST-LABEL-SINGULAR%', 'types'), 'target' => '%POST-PERMALINK%'), array('type' => 'link', 'class' => 'button-primary types-button', 'target' => '%POST-CREATE-CONTENT-TEMPLATE%', 'label' => __('Create Content Template', 'types')))), 'views-template' => array('type' => 'template', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Template_Exists'), 'description' => array(array('type' => 'paragraph', 'content' => __('The Content Template for %POST-LABEL-PLURAL% is "%POST-CONTENT-TEMPLATE-NAME%"', 'types')), array('type' => 'link', 'external' => true, 'label' => array('default' => __('Visit example %POST-LABEL-SINGULAR%', 'types'), 'post-edit' => __('Visit this %POST-LABEL-SINGULAR%', 'types')), 'target' => '%POST-PERMALINK%'), array('type' => 'link', 'class' => 'button', 'label' => __('Edit Content Template', 'types'), 'target' => '%POST-EDIT-CONTENT-TEMPLATE%'))), 'layouts-template-missing' => array('type' => 'template', 'priority' => 'important', 'conditions' => array('Types_Helper_Condition_Layouts_Active', 'Types_Helper_Condition_Layouts_Template_Missing'), 'description' => array(array('type' => 'paragraph', 'content' => __('There is no template layout for %POST-LABEL-SINGULAR% items.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit example %POST-LABEL-SINGULAR%', 'types'), 'target' => '%POST-PERMALINK%'), array('type' => 'link', 'class' => 'button-primary types-button', 'label' => __('Create template', 'types'), 'target' => '%POST-CREATE-LAYOUT-TEMPLATE%'))), 'layouts-template' => array('type' => 'template', 'conditions' => array('Types_Helper_Condition_Layouts_Active', 'Types_Helper_Condition_Layouts_Template_Exists'), 'description' => array(array('type' => 'paragraph', 'content' => __('The template layout for %POST-LABEL-SINGULAR% items is "%POST-LAYOUT-TEMPLATE%".', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Visit example %POST-LABEL-SINGULAR%', 'types'), 'target' => '%POST-PERMALINK%'), array('type' => 'link', 'class' => 'button', 'label' => __('Edit template', 'types'), 'target' => '%POST-EDIT-LAYOUT-TEMPLATE%'))));
Exemplo n.º 14
0
    function types_getting_started()
    {
        ?>
        <div class="notice is-dismissible" data-types-notice-dismiss-permanent="getting-started" style="border-left-color: #f05a29; position: relative; padding-right: 38px;">
            <div class="types-message-icon" style="float: left; margin: 2px 0 0 0; padding: 0 15px 0 0;">
                <?php 
        //<span class="icon-toolset-logo"></span>
        ?>
                <span class="icon-types-logo ont-icon-64" style="color: #f05a29;""></span>
            </div>

            <div style="margin-top: 8px;">
                <p>
                    <?php 
        _e('Toolset Types lets you add custom post types, custom fields and taxonomy.', 'wpcf');
        ?>
                </p>

                <a class="button-primary types-button types-external-link" style="margin-right: 10px;" target="_blank"
                   href="<?php 
        echo Types_Helper_Url::get_url('getting-started-types', 'notice-dismissible');
        ?>
">
                    <?php 
        _e('Getting started guide', 'wpcf');
        ?>
                </a>

                <span class="notice-dismiss"><span class="screen-reader-text">Dismiss</span></span>
            </div>

            <br style="clear:both;" />
        </div>
        <?php 
    }
Exemplo n.º 15
0
/**
 * Default credits.
 * 
 * @return string[]
 *
 * @fixme this is ancient, might need a review
 */
function wpcf_footer_credit_defaults()
{
    return array(sprintf(__("Functionality enhanced using %sWordPress Post Fields%s", 'wpcf'), sprintf('<a href="%s" target="_blank">', Types_Helper_Url::get_url('using-post-fields')), ' &raquo;</a>'), sprintf(__("Functionality enhanced using %sWordPress Post Types%s", 'wpcf'), sprintf('<a href="%s" target="_blank">', Types_Helper_Url::get_url('custom-post-types')), ' &raquo;</a>'), sprintf(__("Functionality enhanced using %sWordPress Taxonomy%s", 'wpcf'), sprintf('<a href="%s" target="_blank">', Types_Helper_Url::get_url('custom-taxonomy')), ' &raquo;</a>'));
}
Exemplo n.º 16
0
                    ' . __('The complete Toolset package lets you display custom content on the site’s front-end easily, without writing PHP code.', 'wpcf') . '
                </p>

                 <a target="_blank" href="' . Types_Helper_Url::get_url('compare-toolset-php', true) . '"><b>' . __('Toolset vs. PHP comparison', 'wpcf') . '</b></a>
            </div>


            <p style="padding-top: 10px; margin-bottom: 0; border-top: 1px solid #eee;">
                <a class="wpcf-arrow-right wpcf-no-glow" href="javascript:void(0)" data-wpcf-toggle-trigger="wpcf-displaying-custom-content-php-info">
                    ' . __('Show instructions for displaying custom content with PHP', 'wpcf') . '
                </a>
            </p>

            <div data-wpcf-toggle="wpcf-displaying-custom-content-php-info" style="display: none;">
                <p>
                    ' . __('If you are customizing an existing theme, consider <a href="https://codex.wordpress.org/Child_Themes" target="_blank">creating a child theme</a> first.', 'wpcf') . '
                </p>

                <p>
                    ' . __('Read about <a href="https://codex.wordpress.org/Post_Type_Templates" target="_blank">post type templates</a>, in the WordPress codex, to learn which template functions you should edit in your theme.', 'wpcf') . '
                </p>

                <p>
                    ' . __('Use <a href="https://codex.wordpress.org/Class_Reference/WP_Query" target="_blank">WP_Query</a> to load content from the database and display it.', 'wpcf') . '
                </p>

                <p>
                    ' . sprintf(__('Use %s to display custom fields in your PHP templates.', 'wpcf'), sprintf('<a href="%s" target="_blank">%s</a>', Types_Helper_Url::get_url('types-fields-api', true), __('Types fields API', 'wpcf'))) . '
                </p>
            </div>
        </div>');
Exemplo n.º 17
0
/**
 * Generates form data.
 */
function wpcf_admin_usermeta_form()
{
    /**
     * include common functions
     */
    include_once dirname(__FILE__) . '/common-functions.php';
    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') . '\'');
    $default = array();
    $current_user_can_edit = WPCF_Roles::user_can_create('user-meta-field');
    // If it's update, get data
    $update = false;
    if (isset($_REQUEST['group_id'])) {
        $update = wpcf_admin_fields_get_group(intval($_REQUEST['group_id']), TYPES_USER_META_FIELD_GROUP_CPT_NAME);
        $current_user_can_edit = WPCF_Roles::user_can_edit('user-meta-field', $update);
        if (empty($update)) {
            $update = false;
            wpcf_admin_message(sprintf(__("Group with ID %d do not exist", 'wpcf'), intval($_REQUEST['group_id'])));
        } else {
            $update['fields'] = wpcf_admin_fields_get_fields_by_group(sanitize_text_field($_REQUEST['group_id']), 'slug', false, true, false, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta');
            $update['show_for'] = wpcf_admin_get_groups_showfor_by_group(sanitize_text_field($_REQUEST['group_id']));
            $update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group(sanitize_text_field($_REQUEST['group_id']));
        }
    }
    $form = array();
    $form['#form']['callback'] = array('wpcf_admin_save_usermeta_groups_submit');
    $form['form-open'] = array('#type' => 'markup', '#markup' => sprintf('<div id="poststuff" class="%s">', $current_user_can_edit ? '' : 'wpcf-types-read-only'));
    // Form sidebars
    if ($current_user_can_edit) {
        $form['open-sidebar'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-fields-align-right">');
        // Set help icon
        $form['help-icon'] = array('#type' => 'markup', '#markup' => sprintf('<div class="wpcf-admin-fields-help"><img src="%s" style="position:relative;top:2px;" />&nbsp;
					<a href="%s" target="_blank">%s</a>
				</div>', WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/res/images/question.png', Types_Helper_Url::get_url('using-post-fields'), __('Usermeta help', 'wpcf')));
        $form['submit2'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
        $form['fields'] = array('#type' => 'fieldset', '#title' => __('Available fields', 'wpcf'));
        // Get field types
        $fields_registered = wpcf_admin_fields_get_available_types();
        foreach ($fields_registered as $filename => $data) {
            $form['fields'][basename($filename, '.php')] = array('#type' => 'markup', '#markup' => '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax&amp;wpcf_action=fields_insert' . '&amp;field=' . basename($filename, '.php') . '&amp;page=wpcf-edit-usermeta') . '&amp;_wpnonce=' . wp_create_nonce('fields_insert') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary">' . $data['title'] . '</a> ');
            // Process JS
            if (!empty($data['group_form_js'])) {
                foreach ($data['group_form_js'] as $handle => $script) {
                    if (isset($script['inline'])) {
                        add_action('admin_footer', $script['inline']);
                        continue;
                    }
                    $deps = !empty($script['deps']) ? $script['deps'] : array();
                    $in_footer = !empty($script['in_footer']) ? $script['in_footer'] : false;
                    wp_register_script($handle, $script['src'], $deps, WPCF_VERSION, $in_footer);
                    wp_enqueue_script($handle);
                }
            }
            // Process CSS
            if (!empty($data['group_form_css'])) {
                foreach ($data['group_form_css'] as $handle => $script) {
                    if (isset($script['src'])) {
                        $deps = !empty($script['deps']) ? $script['deps'] : array();
                        wp_enqueue_style($handle, $script['src'], $deps, WPCF_VERSION);
                    } else {
                        if (isset($script['inline'])) {
                            add_action('admin_head', $script['inline']);
                        }
                    }
                }
            }
        }
        // Get fields created by user
        $fields = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
        if (!empty($fields)) {
            $form['fields-existing'] = array('#type' => 'fieldset', '#title' => __('User created fields', 'wpcf'), '#id' => 'wpcf-form-groups-user-fields');
            foreach ($fields as $key => $field) {
                if (isset($update['fields']) && array_key_exists($key, $update['fields'])) {
                    continue;
                }
                if (!empty($field['data']['removed_from_history'])) {
                    continue;
                }
                $form['fields-existing'][$key] = array('#type' => 'markup', '#markup' => '<div id="wpcf-user-created-fields-wrapper-' . $field['id'] . '" style="float:left; margin-right: 10px;"><a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;page=wpcf-edit' . '&amp;wpcf_action=usermeta_insert_existing' . '&amp;field=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('usermeta_insert_existing') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary" onclick="jQuery(this).parent().fadeOut();" ' . 'data-slug="' . $field['id'] . '">' . htmlspecialchars(stripslashes($field['name'])) . '</a>' . '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;wpcf_action=remove_from_history2' . '&amp;field_id=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('remove_from_history2') . '&amp;wpcf_warning=' . sprintf(__('Are you sure that you want to remove field %s from history?', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '&amp;wpcf_ajax_update=wpcf-user-created-fields-wrapper-' . $field['id'] . '" title="' . sprintf(__('Remove field %s', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '" class="wpcf-ajax-link"><img src="' . WPCF_RES_RELPATH . '/images/delete-2.png" style="postion:absolute;margin-top:5px;margin-left:-4px;" /></a></div>');
            }
        }
        $form['close-sidebar'] = array('#type' => 'markup', '#markup' => '</div>');
    }
    // Group data
    $form['open-main'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-form-fields-main" class="wpcf-form-fields-main">');
    $form['title'] = array('#type' => 'textfield', '#name' => 'wpcf[group][name]', '#id' => 'wpcf-group-name', '#value' => $update ? wp_kses_post($update['name']) : '', '#inline' => true, '#attributes' => array('style' => 'width:100%;margin-bottom:10px;', 'placeholder' => __('Enter group title', 'wpcf')), '#validate' => array('required' => array('value' => true)));
    $form['description'] = array('#type' => 'textarea', '#id' => 'wpcf-group-description', '#name' => 'wpcf[group][description]', '#value' => $update ? wp_kses_post($update['description']) : '', '#attributes' => array('placeholder' => __('Enter a description for this group', 'wpcf')));
    // Show Fields for
    global $wp_roles;
    $options = array();
    $users_currently_supported = array();
    $form_types = array();
    foreach ($wp_roles->role_names as $role => $name) {
        $options[$role]['#name'] = 'wpcf[group][supports][' . $role . ']';
        $options[$role]['#title'] = ucwords($role);
        $options[$role]['#default_value'] = $update && !empty($update['show_for']) && in_array($role, $update['show_for']) ? 1 : 0;
        $options[$role]['#value'] = $role;
        $options[$role]['#inline'] = TRUE;
        $options[$role]['#suffix'] = '<br />';
        $options[$role]['#id'] = 'wpcf-form-groups-show-for-' . $role;
        $options[$role]['#attributes'] = array('class' => 'wpcf-form-groups-support-post-type');
        if ($update && !empty($update['show_for']) && in_array($role, $update['show_for'])) {
            $users_currently_supported[] = ucwords($role);
        }
    }
    if (empty($users_currently_supported)) {
        $users_currently_supported[] = __('Displayed for all users roles', 'wpcf');
    }
    /*
     * Show for FILTER
     */
    $temp = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'wpcf[group][supports]', '#inline' => true);
    /*
     *
     * Here we use unique function for all filters
     * Since Types 1.1.4
     */
    $form_users = _wpcf_filter_wrap('custom_post_types', __('Show For:', 'wpcf'), implode(', ', $users_currently_supported), __('Displayed for all users roles', 'wpcf'), $temp);
    /*
     * Now starting form
     */
    $access_notification = '';
    if (function_exists('wpcf_access_register_caps')) {
        $access_notification = '<div class="message custom wpcf-notif"><span class="wpcf-notif-congrats">' . __('This groups visibility is also controlled by the Access plugin.', 'wpcf') . '</span></div>';
    }
    $form['supports-table-open'] = array('#type' => 'markup', '#markup' => '<table class="widefat"><thead><tr><th>' . __('Where to display this group', 'wpcf') . '</th></tr></thead><tbody><tr><td>' . '<p>' . __('Each usermeta group can display different fields for user roles.', 'wpcf') . $access_notification . '</p>');
    /*
     * Join filter forms
     */
    // User Roles
    $form['p_wrap_1_' . wpcf_unique_id(serialize($form_users))] = array('#type' => 'markup', '#markup' => '<p class="wpcf-filter-wrap">');
    $form = $form + $form_users;
    $form['supports-table-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table><br />');
    /** Admin styles**/
    if (defined('TYPES_USE_STYLING_EDITOR') && TYPES_USE_STYLING_EDITOR && $current_user_can_edit) {
        $form['adminstyles-table-open'] = array('#type' => 'markup', '#markup' => '<table class="widefat" id="wpcf-admin-styles-box"><thead><tr><th>' . __('Styling Editor', 'wpcf') . '</th></tr></thead><tbody><tr><td>' . '<p>' . __('Customize Fields for admin panel.', 'wpcf') . '</p>');
        $admin_styles_value = $preview_profile = $edit_profile = '';
        if (isset($update['admin_styles'])) {
            $admin_styles_value = $update['admin_styles'];
        }
        $temp = '';
        if ($update) {
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
            $user_id = wpcf_usermeta_get_user();
            $preview_profile = wpcf_usermeta_preview_profile($user_id, $update, 1);
            $group = $update;
            $group['fields'] = wpcf_admin_usermeta_process_fields($user_id, $group['fields'], true, false);
            $edit_profile = wpcf_admin_render_fields($group, $user_id, 1);
            add_action('admin_enqueue_scripts', 'wpcf_admin_fields_form_fix_styles', PHP_INT_MAX);
        }
        $temp[] = array('#type' => 'radio', '#suffix' => '<br />', '#value' => 'edit_mode', '#title' => 'Edit mode', '#name' => 'wpcf[group][preview]', '#default_value' => '', '#before' => '<div class="wpcf-admin-css-preview-style-edit">', '#inline' => true, '#attributes' => array('onclick' => 'changePreviewHtml(\'editmode\')', 'checked' => 'checked'));
        $temp[] = array('#type' => 'radio', '#title' => 'Read Only', '#name' => 'wpcf[group][preview]', '#default_value' => '', '#after' => '</div>', '#inline' => true, '#attributes' => array('onclick' => 'changePreviewHtml(\'readonly\')'));
        $temp[] = array('#type' => 'textarea', '#name' => 'wpcf[group][admin_html_preview]', '#inline' => true, '#value' => '', '#id' => 'wpcf-form-groups-admin-html-preview', '#before' => '<h3>Field group HTML</h3>');
        $temp[] = array('#type' => 'textarea', '#name' => 'wpcf[group][admin_styles]', '#inline' => true, '#value' => $admin_styles_value, '#default_value' => '', '#id' => 'wpcf-form-groups-css-fields-editor', '#after' => '
            <div class="wpcf-update-preview-btn"><input type="button" value="Update preview" onclick="wpcfPreviewHtml()" style="float:right;" class="button-secondary"></div>
            <h3>' . __('Field group preview', 'wpcf') . '</h3>
            <div id="wpcf-update-preview-div">Preview here</div>
            <script type="text/javascript">
var wpcfReadOnly = ' . json_encode(base64_encode($preview_profile)) . ';
var wpcfEditMode = ' . json_encode(base64_encode($edit_profile)) . ';
var wpcfDefaultCss = ' . json_encode(base64_encode($admin_styles_value)) . ';
        </script>
        ', '#before' => sprintf('<h3>%s</h3>', __('Your CSS', 'wpcf')));
        $admin_styles = _wpcf_filter_wrap('admin_styles', __('Admin styles for fields:', 'wpcf'), '', '', $temp, __('Open style editor', 'wpcf'));
        $form['p_wrap_1_' . wpcf_unique_id(serialize($admin_styles))] = array('#type' => 'markup', '#markup' => '<p class="wpcf-filter-wrap">');
        $form = $form + $admin_styles;
        $form['adminstyles-table-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table><br />');
    }
    /** End admin Styles **/
    // Group fields
    $form['fields_title'] = array('#type' => 'markup', '#markup' => '<h2>' . __('Fields', 'wpcf') . '</h2>');
    $show_under_title = true;
    $form['ajax-response-open'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-fields-sortable" class="ui-sortable">');
    // If it's update, display existing fields
    $existing_fields = array();
    if ($update && isset($update['fields'])) {
        foreach ($update['fields'] as $slug => $field) {
            $field['submitted_key'] = $slug;
            $field['group_id'] = $update['id'];
            $form_field = wpcf_fields_get_field_form_data($field['type'], $field);
            if (is_array($form_field)) {
                $form['draggable-open-' . rand()] = array('#type' => 'markup', '#markup' => '<div class="ui-draggable">');
                $form = $form + $form_field;
                $form['draggable-close-' . rand()] = array('#type' => 'markup', '#markup' => '</div>');
            }
            $existing_fields[] = $slug;
            $show_under_title = false;
        }
    }
    // Any new fields submitted but failed? (Don't double it)
    if (!empty($_POST['wpcf']['fields'])) {
        foreach ($_POST['wpcf']['fields'] as $key => $field) {
            if (in_array($key, $existing_fields)) {
                continue;
            }
            $field['submitted_key'] = $key;
            $form_field = wpcf_fields_get_field_form_data($field['type'], $field);
            if (is_array($form_field)) {
                $form['draggable-open-' . rand()] = array('#type' => 'markup', '#markup' => '<div class="ui-draggable">');
                $form = $form + $form_field;
                $form['draggable-close-' . rand()] = array('#type' => 'markup', '#markup' => '</div>');
            }
        }
        $show_under_title = false;
    }
    $form['ajax-response-close'] = array('#type' => 'markup', '#markup' => '</div>' . '<div id="wpcf-ajax-response"></div>');
    if ($show_under_title) {
        $form['fields_title']['#markup'] = $form['fields_title']['#markup'] . '<div id="wpcf-fields-under-title">' . __('There are no fields in this group. To add a field, click on the field buttons at the right.', 'wpcf') . '</div>';
    }
    // If update, create ID field
    if ($update) {
        $form['group_id'] = array('#type' => 'hidden', '#name' => 'group_id', '#value' => $update['id'], '#forced_value' => true);
    }
    $form['submit'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
    // Close main div
    $form['close-sidebar'] = array('#type' => 'markup', '#markup' => '</div>');
    wpcf_admin_add_js_settings('wpcf_filters_association_or', '\'' . __('This group will appear on %pt% edit pages where content belongs to Taxonomy: %tx% or Content Template is: %vt%', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcf_filters_association_and', '\'' . __('This group will appear on %pt% edit pages where content belongs to Taxonomy: %tx% and Content Template is: %vt%', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcf_filters_association_all_pages', '\'' . __('all', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcf_filters_association_all_taxonomies', '\'' . __('any', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcf_filters_association_all_templates', '\'' . __('any', 'wpcf') . '\'');
    // Add JS settings
    wpcf_admin_add_js_settings('wpcfFormUniqueValuesCheckText', '\'' . __('Warning: same values selected', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUniqueNamesCheckText', '\'' . __('Warning: field name already used', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUniqueSlugsCheckText', '\'' . __('Warning: field slug already used', 'wpcf') . '\'');
    /**
     * close form div
     */
    $form['form-close'] = array('#type' => 'markup', '#markup' => '</div>');
    /**
     * return form if current_user_can edit
     */
    if ($current_user_can_edit) {
        return $form;
    }
    return wpcf_admin_common_only_show($form);
}
    /**
     * Summary.
     *
     * Description.
     *
     * @since x.x.x
     * @access (for functions: only use if private)
     *
     * @see Function/method/class relied on
     * @link URL
     * @global type $varname Description.
     * @global type $varname Description.
     *
     * @param type $var Description.
     * @param type $var Optional. Description.
     * @return type Description.
     */
    public function get_field_conditionals($form, $data)
    {
        /**
         * Sanitize form
         */
        if (!is_array($form)) {
            $form = array();
        }
        if (isset($data['meta_type'])) {
            switch ($data['meta_type']) {
                case 'postmeta':
                    $form['data-dependant-meta'] = array('#type' => 'markup', '#markup' => '<span id="data-dependant-meta" style="display:none;"
                            data-wpcf-action="wpcf_edit_field_condition_get"
                            data-wpcf-id="' . $data['name'] . '"
                            data-wpcf-group-id="' . $data['id'] . '"
                            data-wpcf-buttons-apply-nonce="' . wp_create_nonce('wpcf-conditional-apply-' . $data['id']) . '"
                            data-wpcf-meta-type="postmeta"></span>');
                    break;
                case 'custom_fields_group':
                case 'custom-fields-group':
                    $form['data-dependant-meta'] = array('#type' => 'markup', '#markup' => '<span id="data-dependant-meta" style="display:none;"
                            data-wpcf-action="wpcf_edit_custom_field_group_get"
                            data-wpcf-id="' . $data['name'] . '"
                            data-wpcf-group-id="' . $data['id'] . '"
                            data-wpcf-buttons-apply-nonce="' . wp_create_nonce('wpcf-conditional-apply-' . $data['id']) . '"
                            data-wpcf-meta-type="custom_fields_group"></span>');
                    break;
            }
        }
        $use_custom_logic = $this->use_custom_logic($data);
        $datas = wpcf_admin_fields_get_fields(true, false, true);
        ksort($datas, SORT_STRING);
        $form['form-begin'] = array('#type' => 'markup', '#markup' => '<form>');
        $form['simple-logic-open'] = array('#type' => 'markup', '#markup' => sprintf('<div class="js-wpcf-simple-logic %s">', $use_custom_logic ? 'hidden' : ''));
        $form['description'] = array('#type' => 'markup', '#markup' => wpautop(__("Specify additional filters that control this fields group display, based on values of other custom fields.", 'wpcf')));
        $show_relation = true && isset($data['data']['conditional_display']) && isset($data['data']['conditional_display']['conditions']) && !empty($data['data']['conditional_display']['conditions']);
        $form['cd-relation'] = array('#title' => __('Relation between conditions:', 'wpcf'), '#type' => 'radios', '#name' => 'relation', '#options' => array('AND' => array('#title' => 'AND', '#inline' => true, '#value' => 'AND'), 'OR' => array('#title' => 'OR', '#inline' => true, '#value' => 'OR')), '#default_value' => isset($data['data']['conditional_display']['relation']) ? $data['data']['conditional_display']['relation'] : 'AND', '#inline' => true, '#before' => sprintf('<div class="wpcf-cd-relation simple-logic %s">', $show_relation && 1 < count($data['data']['conditional_display']['conditions']) ? '' : 'hidden'), '#after' => '</div>');
        $form['options-markup-open'] = array('#type' => 'markup', '#title' => __('Options', 'wpcf'), '#markup' => sprintf('<table id="wpcf-conditional"><thead><tr>' . '<td class="wpcf-form-options-header-title">%s</th>' . '<td class="wpcf-form-options-header-value">%s</th>' . '<td class="wpcf-form-options-header-default">%s</th>' . '</tr></thead>' . '<tbody id="%s-sortable" class="js-wpcf-fields-conditions">', __('Field', 'wpcf'), __('Condition', 'wpcf'), __('Value', 'wpcf'), esc_attr($data['id'])));
        if ($show_relation) {
            $group = isset($data['meta_type']) && 'custom-fields-group' == $data['meta_type'];
            require_once WPCF_ABSPATH . '/includes/conditional-display.php';
            if (is_array($data['data']['conditional_display']['conditions']) && !empty($data['data']['conditional_display']['conditions'])) {
                foreach ($data['data']['conditional_display']['conditions'] as $condition) {
                    $form += wpcf_cd_admin_form_single_filter($data, $condition, null, $group);
                }
            }
        }
        $form['options-response-close'] = array('#type' => 'markup', '#markup' => '</table>');
        $form['button-add'] = array('#type' => 'button', '#inline' => true, '#value' => isset($data['data']['conditional_display']['conditions']) && !empty($data['data']['conditional_display']['conditions']) ? __('Add another condition', 'wpcf') : __('Add condition', 'wpcf'), '#name' => 'button-add', '#attributes' => array('class' => sprintf('js-wpcf-condition-button-add-row %s', isset($data['data']['conditional_display']['conditions']) ? 'alignright' : 'wpcf-block-center'), 'data-wpcf-nonce' => wp_create_nonce($this->get_nonce(__CLASS__, $data['id'], $data['meta_type'])), 'data-wpcf-id' => $data['id'], 'data-wpcf-meta-type' => $data['meta_type'], 'data-wpcf-label-add-condition' => __('Add condition', 'wpcf'), 'data-wpcf-label-add-another-condition' => __('Add another condition', 'wpcf')), '#before' => '<p>', '#after' => '</p>');
        $form['simple-logic-close'] = array('#type' => 'markup', '#markup' => '</div>');
        /**
         * Advanced conditional
         */
        $form['toggle_open_area'] = array('#type' => 'markup', '#markup' => sprintf('<div class="js-wpcf-advance-logic %s">', $use_custom_logic ? '' : 'hidden'));
        $form['custom-description'] = array('#type' => 'markup', '#markup' => wpautop(__('Customize conditions', 'wpcf')));
        $form['custom'] = array('#type' => 'textarea', '#name' => 'custom', '#inline' => true, '#value' => isset($data['data']['conditional_display']['custom']) ? $data['data']['conditional_display']['custom'] : '');
        $form['date_notice'] = array('#type' => 'markup', '#markup' => sprintf('<div style="display:none; margin-top:15px;" class="wpcf-cd-notice-date">
						<a href="%s" target="_blank">%s &raquo;</a></div>', Types_Helper_Url::get_url('date-filters', true), __('Dates can be entered using the date filters', 'wpcf')));
        $form['toggle_close'] = array('#type' => 'markup', '#markup' => '</div>');
        /**
         * switch button
         */
        $form['switch'] = array('#type' => 'markup', '#markup' => sprintf('<a href="#" data-wpcf-content-advanced="%s" data-wpcf-content-simple="%s" data-wpcf-custom-logic="%s" class="js-wpcf-condition-button-display-logic">%s</a>', __('Advanced text mode', 'wpcf'), __('Switch to basic mode', 'wpcf'), $use_custom_logic ? 'advance-logic' : 'simple-logic', $use_custom_logic ? __('Switch to basic mode', 'wpcf') : __('Advanced text mode', 'wpcf')), '#before' => '<p class="wpcf-fields-conditional-switch-container">', '#after' => '</p>', '#pattern' => '<BEFORE><ELEMENT><AFTER>');
        $form['custom_use'] = array('#type' => 'hidden', '#name' => 'custom_use', '#value' => $use_custom_logic, '#attributes' => array('class' => 'js-wpcf-condition-custom-use'));
        $form['form-end'] = array('#type' => 'markup', '#markup' => '</form>');
        return $form;
    }
Exemplo n.º 19
0
 /**
  * @param $post_types
  * @param $headline
  *
  * @return string
  */
 private function get_dashboard_types_table($post_types, $headline, $post_type_edit_link = true)
 {
     // documentation urls
     $documentation_urls = (include TYPES_DATA . '/documentation-urls.php');
     // add links to use analytics
     Types_Helper_Url::add_urls($documentation_urls);
     // set analytics medium
     Types_Helper_Url::set_medium('dashboard');
     /* messages */
     $messages_files = array(TYPES_DATA . '/dashboard/table/template.php', TYPES_DATA . '/dashboard/table/archive.php', TYPES_DATA . '/dashboard/table/views.php', TYPES_DATA . '/dashboard/table/forms.php');
     // add dashboard
     $rows = '';
     foreach ($post_types as $post_type) {
         $info_post_type = new Types_Information_Table('types-information-table');
         Types_Helper_Condition::set_post_type($post_type->get_name());
         Types_Helper_Placeholder::set_post_type($post_type->get_name());
         foreach ($messages_files as $message_file) {
             $this->load_data_to_table($message_file, $info_post_type);
         }
         $row = $this->get_twig()->render('/page/dashboard/table/tbody-row.twig', array('labels' => array('or' => __('Or...', 'types'), 'create_taxonomy' => __('Create taxonomy', 'types'), 'create_field_group' => __('Create field group', 'types'), 'no_archive_for' => __('No archive available for %s', 'types')), 'admin_url' => admin_url(), 'post_type' => $post_type, 'table' => $info_post_type, 'post_type_edit_link' => $post_type_edit_link));
         Types_Helper_Placeholder::replace($row);
         $rows .= $row;
     }
     // table view
     $data_thead = (require TYPES_DATA . '/dashboard/table/head.php');
     $table = $this->get_twig()->render('/page/dashboard/table.twig', array('labels' => array('headline' => $headline, 'admin' => __('WordPress admin', 'types'), 'frontend' => __('Front-end', 'types'), 'or' => __('Or...', 'types')), 'admin_url' => admin_url(), 'thead' => $data_thead, 'rows' => $rows));
     return $table;
 }
Exemplo n.º 20
0
 /**
  * Load URLs to documentation links so they can be obtained via get_url().
  * 
  * @since 2.1
  */
 public static function load_documentation_urls()
 {
     if (!self::$documentation_urls_loaded) {
         $documentation_urls = (include TYPES_DATA . '/documentation-urls.php');
         Types_Helper_Url::add_urls($documentation_urls);
         self::$documentation_urls_loaded = true;
     }
 }
<?php

$question_marks = array('template' => array('id' => 'template', 'title' => __('Template', 'types'), 'description' => array(array('type' => 'paragraph', 'content' => __('A template displays single-item pages with your design and fields.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Learn more', 'types'), 'target' => Types_Helper_Url::get_url('learn-how-template', 'tooltip')))), 'archive' => array('id' => 'archive', 'title' => __('Archive', 'types'), 'description' => array(array('type' => 'paragraph', 'content' => __('An archive is the standard list that WordPress produces for content.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Learn more', 'types'), 'target' => Types_Helper_Url::get_url('learn-how-archive', 'tooltip')))), 'views' => array('id' => 'views', 'title' => __('Views', 'types'), 'description' => array(array('type' => 'paragraph', 'content' => __('Views are custom lists of content, which you can display anywhere in the site.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Learn more', 'types'), 'target' => Types_Helper_Url::get_url('learn-how-views', 'tooltip')))), 'forms' => array('id' => 'forms', 'title' => __('Forms', 'types'), 'description' => array(array('type' => 'paragraph', 'content' => __('Forms allow to create and edit content from the site’s front-end.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Learn more', 'types'), 'target' => Types_Helper_Url::get_url('learn-how-forms', 'tooltip')))));
// Visual Composer
if (defined('WPB_VC_VERSION')) {
    $question_marks['template']['description'][1]['label'] = __('Creating templates with Visual Composer', 'types');
} else {
    if (class_exists('FLBuilderLoader')) {
        $question_marks['template']['description'][1]['label'] = __('Creating templates with Beaver Builder', 'types');
    } else {
        if (defined('WPDDL_DEVELOPMENT') || defined('WPDDL_PRODUCTION')) {
            $question_marks['template']['description'][1]['label'] = __('Creating templates with Layouts', 'types');
        }
    }
}
return $question_marks;
<?php

return array('layouts-not-compatible' => array('conditions' => array(), 'description' => array(array('type' => 'paragraph', 'content' => __('Layouts plugin is installed in your site, but it is not integrated with your theme.
								This will make it difficult to display custom content and fields. You can:', 'types')), array('type' => 'list', 'content' => array(__('Disable Layouts plugin and use Views plugin to design front-end display', 'types'), sprintf(__('Choose a different theme (<a href="%s" target="_blank">themes compatible with Layouts</a>)', 'types'), Types_Helper_Url::get_url('themes-compatible-with-layouts', 'table')), sprintf(__('Integrate Layouts with this theme (<a href="%s" target="_blank">Layouts integration instructions</a>)', 'types'), Types_Helper_Url::get_url('layouts-integration-instructions', 'table')))))));
Exemplo n.º 23
0
<?php

return array('views-missing' => array('type' => 'views', 'conditions' => array('Types_Helper_Condition_Views_Missing'), 'description' => array(array('type' => 'dialog', 'class' => 'button', 'label' => __('Create View', 'types'), 'dialog' => array('id' => 'create-view', 'description' => array(array('type' => 'paragraph', 'content' => __('To create a View for this content type, you need have Views plugin installed. Views is part of the
                    complete Toolset package for adding and displaying custom content.', 'types')), array('type' => 'link', 'external' => true, 'label' => __('Learn how Views work', 'types'), 'target' => Types_Helper_Url::get_url('how-views-work', 'popup'))))))), 'views-views-missing' => array('type' => 'views', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Views_Missing'), 'description' => array(array('type' => 'link', 'class' => 'button', 'target' => '%POST-CREATE-VIEW%', 'label' => __('Create View', 'types')))), 'views-views' => array('type' => 'views', 'conditions' => array('Types_Helper_Condition_Layouts_Missing', 'Types_Helper_Condition_Views_Views_Exist'), 'description' => array(array('type' => 'paragraph', 'content' => '%POST-VIEWS-LIST%', 'types'), array('type' => 'link', 'class' => 'button', 'target' => '%POST-CREATE-VIEW%', 'label' => __('Create View', 'types')))), 'views-layouts-views-missing' => array('type' => 'views', 'conditions' => array('Types_Helper_Condition_Layouts_Active', 'Types_Helper_Condition_Views_Views_Missing'), 'description' => array(array('type' => 'paragraph', 'content' => __('Edit any layout and add a View cell to it, to display lists of %POST-LABEL-PLURAL%.', 'types')), array('type' => 'link', 'external' => true, 'target' => Types_Helper_Url::get_url('adding-views-to-layouts', 'table'), 'label' => __('Learn how', 'types')))), 'views-layouts-views' => array('type' => 'views', 'conditions' => array('Types_Helper_Condition_Layouts_Active', 'Types_Helper_Condition_Views_Views_Exist'), 'description' => array(array('type' => 'paragraph', 'content' => '%POST-VIEWS-LIST%', 'types'), array('type' => 'link', 'external' => true, 'target' => Types_Helper_Url::get_url('adding-views-to-layouts', 'table'), 'label' => __('How to add Views to layouts', 'types')))));
Exemplo n.º 24
0
            </ul>
        <?php 
    }
    ?>

        <div class="hr"></div>

        <span><strong><?php 
    _e('Build complete sites without coding:', 'wpcf');
    ?>
</strong></span>
        <ul>
            <li>
	            <?php 
    printf('<a target="_blank" href="%s">%s &raquo;</a>', Types_Helper_Url::get_url('single-pages', true), __('Design templates for single pages', 'wpcf'));
    ?>
            </li>
            <li>
	            <?php 
    printf('<a target="_blank" href="%s">%s &raquo;</a>', Types_Helper_Url::get_url('views-user-guide', true, 'query-and-display'), __('Load and display custom content', 'wpcf'));
    ?>
            </li>
        </ul>

        <a href="javascript:void(0);" class="wpcf-button hide" style="float:right;"><?php 
    _e('Hide notifications', 'wpcf');
    ?>
<span class="wpcf-button-arrow hide"></span></a>
    </div><!-- END .wpcf-notif-dropdown -->
        <?php 
}