Esempio n. 1
0
/**
 * Settings form.
 *
 * @return string
 */
function wpcf_admin_general_settings_form()
{
    $settings = wpcf_get_settings();
    $form = array();
    $form['#form']['callback'] = 'wpcf_admin_general_settings_form_submit';
    $form['open-table'] = array('#type' => 'markup', '#markup' => '<table class="form-table"><tbody>');
    $form['images'] = array('#id' => 'add_resized_images_to_library', '#name' => 'wpcf_settings[add_resized_images_to_library]', '#title' => __('Remote Images', 'wpcf'), '#type' => 'checkbox', '#label' => __('Add resized images to the media library', 'wpcf'), '#description' => __('Types will automatically add the resized images as attachments to the media library. Choose this to automatically upload resized images to a CDN.', 'wpcf'), '#inline' => true, '#default_value' => !empty($settings['add_resized_images_to_library']), '#pattern' => '<tr><th scope="row"><TITLE></th><td><ELEMENT><LABEL><DESCRIPTION>');
    $form['images_remote'] = array('#id' => 'images_remote', '#name' => 'wpcf_settings[images_remote]', '#type' => 'checkbox', '#label' => __('Allow resizing of remote images', 'wpcf'), '#description' => __('Types will try to scale remote images.', 'wpcf'), '#inline' => true, '#default_value' => !empty($settings['images_remote']), '#pattern' => '<br /><ELEMENT><LABEL><DESCRIPTION>');
    $form['images_remote_clear'] = array('#id' => 'images_remote_cache_time', '#name' => 'wpcf_settings[images_remote_cache_time]', '#type' => 'select', '#title' => __('Images cache', 'wpcf'), '#pattern' => sprintf('<br />%s', __('Invalidate cached images that are more than <ELEMENT> hours old.', 'wpcf')), '#options' => array(__('Never', 'wpcf') => '0', '24' => '24', '36' => '36', '48' => '48', '72' => '72'), '#inline' => true, '#default_value' => intval($settings['images_remote_cache_time']));
    $form['clear_images_cache'] = array('#type' => 'submit', '#name' => 'clear-cache-images', '#id' => 'clear-cache-images', '#attributes' => array('id' => 'clear-cache-images', 'class' => 'button-secondary'), '#value' => __('Clear Cached Images', 'wpcf'), '#inline' => true, '#pattern' => '<br /><ELEMENT>');
    $form['clear_images_cache_outdated'] = array('#id' => 'clear-cache-images-outdated', '#type' => 'submit', '#name' => 'clear-cache-images-outdated', '#attributes' => array('id' => 'clear-cache-images-outdated', 'class' => 'button-secondary'), '#value' => __('Clear Outdated Cached Images', 'wpcf'), '#inline' => true, '#pattern' => ' <ELEMENT></td></tr>');
    if (function_exists('icl_register_string')) {
        $form['register_translations_on_import'] = array('#id' => 'register_translations_on_import', '#name' => 'wpcf_settings[register_translations_on_import]', '#type' => 'checkbox', '#title' => __('WPML Integration', 'wpcf'), '#label' => __("When importing, add texts to WPML's String Translation table", 'wpcf'), '#inline' => true, '#default_value' => !empty($settings['register_translations_on_import']), '#pattern' => '<tr><th scope="row"><TITLE></th><td><ELEMENT><LABEL><DESCRIPTION></td></th>', '#inline' => true);
    }
    $form['help-box'] = array('#id' => 'help_box', '#name' => 'wpcf_settings[help_box]', '#type' => 'radios', '#options' => array('all' => array('#value' => 'all', '#title' => __("Show help box on all custom post editing screens", 'wpcf')), 'by_types' => array('#value' => 'by_types', '#title' => __("Show help box only on custom post types that were created by Types", 'wpcf')), 'no' => array('#value' => 'no', '#title' => __("Don't show help box on any custom post type editing screen", 'wpcf'))), '#inline' => true, '#default_value' => $settings['help_box'], '#pattern' => '<tr><th scope="row"><TITLE></th><td><ELEMENT><DESCRIPTION></td></th>', '#title' => __('Help Box', 'wpcf'));
    $form['hide_standard_custom_fields_metabox'] = array('#id' => 'hide_standard_custom_fields_metabox', '#name' => 'wpcf_settings[hide_standard_custom_fields_metabox]', '#type' => 'radios', '#description' => __('This setting allow to hide standard WordPress Custom Field Metabox.', 'wpcf'), '#options' => array('all' => array('#value' => 'show', '#title' => __('Show standard WordPress Custom Field Metabox', 'wpcf')), 'by_types' => array('#value' => 'hide', '#title' => __('Hide standard WordPress Custom Field Metabox', 'wpcf'))), '#inline' => true, '#default_value' => preg_match('/^(show|hide)$/', $settings['hide_standard_custom_fields_metabox']) ? $settings['hide_standard_custom_fields_metabox'] : 'show', '#title' => __('Custom Field Metabox', 'wpcf'), '#pattern' => '<tr><th scope="row"><TITLE></th><td><ELEMENT><DESCRIPTION></td></th>');
    if (!WPCF_Types_Marketing_Messages::check_register()) {
        $form['toolset_messages'] = array('#id' => 'toolset_messages', '#name' => 'wpcf_settings[toolset_messages]', '#type' => 'checkbox', '#label' => __('Disable all messages about other Toolset components', 'wpcf'), '#default_value' => isset($settings['toolset_messages']) ? intval($settings['toolset_messages']) : 0, '#title' => __('Toolset Messages', 'wpcf'), '#pattern' => '<tr><th scope="row"><TITLE></th><td><ELEMENT><LABEL><DESCRIPTION></td></th>', '#inline' => true);
    }
    $form['postmeta-unfiltered-html'] = array('#id' => 'postmeta_unfiltered_html', '#name' => 'wpcf_settings[postmeta_unfiltered_html]', '#type' => 'radios', '#title' => __('Custom fields - unfiltered HTML', 'wpcf'), '#options' => array('on' => array('#value' => 'on', '#title' => __('Enable saving unfiltered HTML in Types custom fields for users with higher roles', 'wpcf')), 'off' => array('#value' => 'off', '#title' => __('Disable saving unfiltered HTML in Types custom fields for all users', 'wpcf'))), '#inline' => false, '#default_value' => $settings['postmeta_unfiltered_html'], '#pattern' => '<tr><th scope="row"><TITLE></th><td><ELEMENT><LABEL><DESCRIPTION></td></th>');
    $form['usermeta-unfiltered-html'] = array('#id' => 'usermeta_unfiltered_html', '#name' => 'wpcf_settings[usermeta_unfiltered_html]', '#type' => 'radios', '#title' => __('Usermeta fields - unfiltered HTML', 'wpcf'), '#options' => array('on' => array('#value' => 'on', '#title' => __("Enable saving unfiltered HTML in Types usermeta fields for users with higher roles", 'wpcf')), 'off' => array('#value' => 'off', '#title' => __("Disable saving unfiltered HTML in Types usermeta fields for all users", 'wpcf'))), '#inline' => false, '#default_value' => $settings['usermeta_unfiltered_html'], '#pattern' => '<tr><th scope="row"><TITLE></th><td><ELEMENT><LABEL><DESCRIPTION></td></th>');
    $form['open-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#attributes' => array('id' => 'general-settings-submit', 'class' => 'button-primary'), '#value' => __('Save Changes', 'wpcf'));
    return $form;
}
Esempio n. 2
0
/**
 * Menu page display.
 */
function wpcf_admin_menu_settings()
{
    $show_toolset_messages = !WPCF_Types_Marketing_Messages::check_register();
    ob_start();
    wpcf_add_admin_header(__('Settings', 'wpcf'));
    ?>
    <p style="font-weight: bold;"><?php 
    _e('This screen contains the Types settings for your site.', 'wpcf');
    ?>
</p>
    <ul class="horlist">
        <li><a href="#types-image-settings"><?php 
    _e('Image Settings', 'wpcf');
    ?>
</a></li>
        <li><a href="#types-general-settings"><?php 
    _e('General Setings', 'wpcf');
    ?>
</a></li>
        <?php 
    if ($show_toolset_messages) {
        ?>
<li><a href="#toolset-messages"><?php 
        _e('Toolset Messages', 'wpcf');
        ?>
</a></li><?php 
    }
    ?>
        <li><a href="#debug"><?php 
    _e('Debug Information', 'wpcf');
    ?>
</a></li>
    </ul>
    <br style='clear:both'/><br /><br />
    <a id="types-image-settings"></a>
    <table class="widefat" id="types_image_settings_table">
        <thead>
            <tr>
                <th><?php 
    _e('Image Settings', 'wpcf');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php 
    echo '<br /><form method="post" action="" id="wpcf-image-settings-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
    $form = wpcf_form('wpcf_form_image_settings');
    echo $form->renderForm();
    echo '</form>';
    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <br /><br />
    <a id="types-general-settings"></a>
    <table class="widefat" id="types_general_settings_table">
        <thead>
            <tr>
                <th><?php 
    _e('General Settings', 'wpcf');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php 
    echo '<br /><form method="post" action="" id="wpcf-general-settings-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
    $form = wpcf_form('wpcf_form_general_settings');
    echo $form->renderForm();
    echo '</form>';
    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <br /><br />
<?php 
    /**
     * Toolset Messages
     */
    if ($show_toolset_messages) {
        ?>
    <a id="toolset-messages"></a>
    <table class="widefat" id="toolset_messages">
        <thead>
            <tr>
                <th><?php 
        _e('Toolset Messages', 'wpcf');
        ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <?php 
        echo '<br /><form method="post" action="" id="wpcf-toolset-messages-form" class="wpcf-settings-form ' . 'wpcf-form-validate">';
        $form = wpcf_form('wpcf_form_toolset_messages');
        echo $form->renderForm();
        echo '</form>';
        ?>
                </td>
            </tr>
        </tbody>
    </table>
    <br /><br />
<?php 
    }
    /**
     * Debug Information
     */
    ?>
    <a id="debug"></a>
    <table class="widefat" id="debug_table">
        <thead>
            <tr>
                <th><?php 
    _e('Debug Information', 'wpcf');
    ?>
</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
<?php 
    printf(__('For retrieving debug information if asked by a support person, use the <a href="%s">debug information</a> page.', 'wpcf'), admin_url('admin.php?page=wpcf-debug-information'));
    ?>
                </td>
            </tr>
        </tbody>
    </table>
    <?php 
    wpcf_add_admin_footer();
    echo ob_get_clean();
}