set_sections() public method

Set settings sections
public set_sections ( array $sections )
$sections array setting sections array
function wr2x_admin_init()
{
    require 'wr2x_class.settings-api.php';
    if (delete_transient('wr2x_flush_rules')) {
        global $wp_rewrite;
        wr2x_generate_rewrite_rules($wp_rewrite, true);
    }
    $sections = array(array('id' => 'wr2x_basics', 'title' => __('Basics', 'wp-retina-2x')), array('id' => 'wr2x_advanced', 'title' => __('Advanced', 'wp-retina-2x')));
    $wpsizes = wr2x_get_image_sizes();
    $sizes = array();
    foreach ($wpsizes as $name => $attr) {
        $sizes["{$name}"] = sprintf("%s (%dx%d)", $name, $attr['width'], $attr['height']);
    }
    $fields = array('wr2x_basics' => array(array('name' => 'ignore_sizes', 'label' => __('Disabled Sizes', 'wp-retina-2x'), 'desc' => __('<br />The selected sizes will not have their retina equivalent generated.', 'wp-retina-2x'), 'type' => 'multicheck', 'options' => $sizes), array('name' => 'auto_generate', 'label' => __('Auto Generate', 'wp-retina-2x'), 'desc' => __('Generate Retina images automatically when images are uploaded to the Media Library.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_advanced' => array(array('name' => 'method', 'label' => __('Method', 'wp-retina-2x'), 'desc' => __('<br />
                        The <b>Picturefill</b> method rewrites the HTML on-the-fly in order to use the new SRCSET. Since it is not supported by the browsers yet, the JS polyfill <a href="http://scottjehl.github.io/picturefill/">Picturefill</a> is used to load the images. <b>It is now the recommended method.</b><br /><br />
                        The <b>IMG Rewrite</b> method rewrites IMG\'s SRC tags on-the-fly with the retina images directly if the device supports them. This method does not work with most caching solutions.<br /><br />
                        The <b>Retina JS</b> method is a 100% JS solution. The HTML loads the normal images, then if a retina device is detected, the retina images will be loaded. It is fail-safe but not efficient (images are loaded twice).<br /><br />                        
                        The <b>Retina-Images method</b> uses a server handler: the images will be loaded through the <a href="https://github.com/Retina-Images/Retina-Images/">Retina-Images</a> PHP handler. Your .htaccess will be modified automatically. It might be too difficult to set-up if it does not work right away.<br /><br />
                	', 'wp-retina-2x'), 'type' => 'radio', 'default' => 'retina.js', 'options' => array('Picturefill' => __("Picturefill", 'wp-retina-2x'), 'HTML Rewrite' => __("IMG Rewrite", 'wp-retina-2x'), 'retina.js' => __("Retina.js", 'wp-retina-2x'), 'Retina-Images' => __("Retina-Images", 'wp-retina-2x'), 'none' => __("None", 'wp-retina-2x'))), array('name' => 'image_quality', 'label' => __('Quality', 'wp-retina-2x'), 'desc' => __('Image Compression quality (between 0 and 100).', 'wp-retina-2x'), 'type' => 'text', 'default' => 90), array('name' => 'debug', 'label' => __('Debug Mode', 'wp-retina-2x'), 'desc' => __('If checked, the client will be always served Retina images. <br />Please use it for testing purposes. It also generates a <a href="' . plugins_url("wp-retina-2x") . '/wp-retina-2x.log">log file</a> in the plugin folder.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'hide_retina_column', 'label' => __('Hide \'Retina\' column', 'wp-retina-2x'), 'desc' => __('Will hide the \'Retina Column\' from the Media Library.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'hide_retina_dashboard', 'label' => __('Hide Retina Dashboard', 'wp-retina-2x'), 'desc' => __('Doesn\'t show the Retina Dashboard menu and tools.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'ignore_mobile', 'label' => __('Ignore Mobile', 'wp-retina-2x'), 'desc' => __('Doesn\'t deliver Retina images to mobiles.<br />Does not work with Picturefill since it is managed by an external JS.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)));
    global $wr2x_settings_api;
    $wr2x_settings_api = new WeDevs_Settings_API();
    $wr2x_settings_api->set_sections($sections);
    $wr2x_settings_api->set_fields($fields);
    $wr2x_settings_api->admin_init();
}
function wpmc_admin_init()
{
    require 'wpmc_class.settings-api.php';
    global $wpmc_settings_api;
    $wpmc_settings_api = new WeDevs_Settings_API();
    $sections = array(array('id' => 'wpmc_basics', 'title' => __('Basics', 'wp-media-cleaner')));
    $fields = array('wpmc_basics' => array(array('name' => 'scan_media', 'label' => __('Scan Media', 'wp-media-cleaner'), 'desc' => __('The Media Library will be scanned.', 'wp-media-cleaner'), 'type' => 'checkbox', 'default' => true), array('name' => 'scan_files', 'label' => __('Scan Files', 'wp-media-cleaner'), 'desc' => __('The Uploads folder will be scanned.', 'wp-media-cleaner'), 'type' => 'checkbox', 'default' => true)));
    $wpmc_settings_api->set_sections($sections);
    $wpmc_settings_api->set_fields($fields);
    $wpmc_settings_api->admin_init();
}
function wr2x_admin_init()
{
    if (isset($_POST) && isset($_POST['wr2x_pro'])) {
        wr2x_validate_pro($_POST['wr2x_pro']['subscr_id']);
    }
    $pro_status = get_option('wr2x_pro_status', "Not Pro.");
    require 'wr2x_class.settings-api.php';
    if (delete_transient('wr2x_flush_rules')) {
        global $wp_rewrite;
        wr2x_generate_rewrite_rules($wp_rewrite, true);
    }
    $sections = array(array('id' => 'wr2x_basics', 'title' => __('Basics', 'wp-retina-2x')), array('id' => 'wr2x_advanced', 'title' => __('Advanced', 'wp-retina-2x')), array('id' => 'wr2x_pro', 'title' => __('Pro', 'wp-retina-2x')));
    $wpsizes = wr2x_get_image_sizes();
    $sizes = array();
    foreach ($wpsizes as $name => $attr) {
        $sizes["{$name}"] = sprintf("%s (%dx%d)", $name, $attr['width'], $attr['height']);
    }
    $fields = array('wr2x_basics' => array(array('name' => 'ignore_sizes', 'label' => __('Disabled Sizes', 'wp-retina-2x'), 'desc' => __('<br />The selected sizes will not have their retina equivalent generated.', 'wp-retina-2x'), 'type' => 'multicheck', 'options' => $sizes), array('name' => 'auto_generate', 'label' => __('Auto Generate', 'wp-retina-2x'), 'desc' => __('Generate retina images automatically when images are uploaded or re-generated.<br />The \'Disabled Sizes\' will be skipped.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => true), array('name' => 'full_size', 'label' => __('Full Size Retina (Pro)', 'wp-retina-2x'), 'desc' => __('Retina for the full-size image will be considered required.<br />Checks and upload feature are available.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_advanced' => array(array('name' => 'method', 'label' => __('Method', 'wp-retina-2x'), 'desc' => __('<br />Check the <a href="http://apps.meow.fr/wp-retina-2x/">plugin official page</a> if you want to know more about the methods to deliver the retina images.', 'wp-retina-2x'), 'type' => 'radio', 'default' => 'Picturefill', 'options' => array('Picturefill' => __("Picturefill (Recommended)", 'wp-retina-2x'), 'retina.js' => __("Retina.js", 'wp-retina-2x'), 'HTML Rewrite' => __("IMG Rewrite", 'wp-retina-2x'), 'Retina-Images' => __("Retina-Images", 'wp-retina-2x'), 'none' => __("None", 'wp-retina-2x'))), array('name' => 'image_quality', 'label' => __('Quality', 'wp-retina-2x'), 'desc' => __('<br />Image Compression quality (between 0 and 100).<br />That doesn\'t always actually work depending on your hosting service.', 'wp-retina-2x'), 'type' => 'text', 'default' => 90), array('name' => 'debug', 'label' => __('Debug Mode', 'wp-retina-2x'), 'desc' => __('If checked, the client will be always served Retina images. <br />Please use it for testing purposes. It creates a <a href="' . plugins_url("wp-retina-2x") . '/wp-retina-2x.log">log file</a> in the plugin folder.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'cdn_domain', 'label' => __('Custom CDN Domain (Pro)', 'wp-retina-2x'), 'desc' => __('<br />If not empty, your site domain will be replaced with this CDN domain (PictureFill and HTML Rewrite only).', 'wp-retina-2x'), 'type' => 'text', 'default' => ""), array('name' => 'picture_fill', 'label' => '', 'desc' => __('<h2>For PictureFill</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'picturefill_keep_src', 'label' => __('Keep IMG SRC (Pro)', 'wp-retina-2x'), 'desc' => __('With PictureFill, <b>src</b> tags are replaced by <b>src-set</b> tags and consequently search engines might not be able to find and reference those images. Keeping it will load images twice for retina devices on old browsers.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'picturefill_lazysizes', 'label' => __('Use Lazysizes (Pro)', 'wp-retina-2x'), 'desc' => __('HTML will be rewritten to support the lazysizes and the script will be also loaded. The images will be loaded in a lazy way (when the visitor is getting close to them).', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'picturefill_noscript', 'label' => __('No Picturefill Script', 'wp-retina-2x'), 'desc' => __('The script for Picturefill will not be loaded. Only the browsers with src-set support (e.g. Chrome) will display images. You can also load the Picturefill script manually.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'admin_screens', 'label' => '', 'desc' => __('<h2>Admin Screens</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'hide_retina_column', 'label' => __('Hide \'Retina\' column', 'wp-retina-2x'), 'desc' => __('Will hide the \'Retina Column\' from the Media Library.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'hide_retina_dashboard', 'label' => __('Hide Retina Dashboard', 'wp-retina-2x'), 'desc' => __('Doesn\'t show the Retina Dashboard menu and tools.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'retina_admin', 'label' => __('Admin in Retina', 'wp-retina-2x'), 'desc' => __('If checked, the WordPress Admin will also be Retina. Some plugins (like NextGen) do not like Retina enabled in the admin.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'mobile', 'label' => '', 'desc' => __('<h2>Mobiles</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'ignore_mobile', 'label' => __('Ignore Mobile', 'wp-retina-2x'), 'desc' => __('Doesn\'t deliver Retina images to mobiles.<br />PictureFill doesn\'t support it and cache will also prevent it from working.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_pro' => array(array('name' => 'pro', 'label' => '', 'desc' => __(sprintf('Status: %s<br /><br />With the Pro version, full support for the <b>Full Size Retina</b> will be added. You will also get a new and nice pop-up window with more <b>Details</b> in the Retina dashboard.', $pro_status), 'wp-retina-2x'), 'type' => 'html'), array('name' => 'subscr_id', 'label' => __('Serial', 'wp-retina-2x'), 'desc' => __('<br />Enter your serial or subscription ID here. If you don\'t have one yet, get one <a target="_blank" href="http://apps.meow.fr/wp-retina-2x/">right here</a>.', 'wp-retina-2x'), 'type' => 'text', 'default' => "")));
    global $wr2x_settings_api;
    $wr2x_settings_api = new WeDevs_Settings_API();
    $wr2x_settings_api->set_sections($sections);
    $wr2x_settings_api->set_fields($fields);
    $wr2x_settings_api->admin_init();
}
Esempio n. 4
0
function wpmc_admin_init()
{
    if (isset($_POST) && isset($_POST['wpmc_pro'])) {
        wpmc_validate_pro($_POST['wpmc_pro']['subscr_id']);
    }
    $pro_status = get_option('wpmc_pro_status', "Not Pro.");
    require 'wpmc_class.settings-api.php';
    global $wpmc_settings_api;
    $wpmc_settings_api = new WeDevs_Settings_API();
    $sections = array(array('id' => 'wpmc_basics', 'title' => __('Options', 'media-file-cleaner')), array('id' => 'wpmc_pro', 'title' => __('Serial Key (Pro)', 'media-file-cleaner')));
    global $shortcode_tags;
    $allshortcodes = array_diff($shortcode_tags, array());
    $my_shortcodes = array();
    foreach ($allshortcodes as $sc) {
        if ($sc != '__return_false') {
            array_push($my_shortcodes, str_replace('_shortcode', '', (string) $sc));
        }
    }
    $my_shortcodes = implode(', ', $my_shortcodes);
    $fields = array('wpmc_basics' => array(array('name' => 'scan_media', 'label' => __('Scan Media', 'media-file-cleaner'), 'desc' => __('The Media Library will be scanned.<br /><small>The medias from Media Library which seem not being used in your WordPress will be marked as to be deleted.</small>', 'media-file-cleaner'), 'type' => 'checkbox', 'default' => false), array('name' => 'scan_files', 'label' => __('Scan Files', 'media-file-cleaner'), 'desc' => __('The Uploads folder will be scanned.<br /><small>The files in your /uploads folder that don\'t seem being used in your WordPress will be marked as to be deleted. <b>If they are found in your Media Library, they will be considered as fine.</b></small>', 'media-file-cleaner'), 'type' => 'checkbox', 'default' => false), array('name' => 'shortcode', 'label' => __('Resolve Shortcode', 'media-file-cleaner'), 'desc' => sprintf(__('The shortcodes you are using in your posts and widgets will be resolved and checked.<br /><small>This process takes more resources. If the scanning suddenly stops, this might be the cause. Here is the list of the shortcodes enabled on your WordPress that you might be using: <b>%s</b>. Please note that the gallery shortcode is checked by the normal process. You don\'t need to have this option enabled for the WP gallery.</small>', 'media-file-cleaner'), $my_shortcodes), 'type' => 'checkbox', 'default' => false), array('name' => 'scan_non_ascii', 'label' => __('UTF-8 Support', 'media-file-cleaner'), 'desc' => __('The filenames in UTF-8 will not be skipped.<br /><small>PHP does not always work well with UTF-8 on all systems (Windows?). If the scanning suddenly stops, this might be the cause.</small>', 'media-file-cleaner'), 'type' => 'checkbox', 'default' => false), array('name' => 'hide_thumbnails', 'label' => __('Hide Thumbnails', 'media-file-cleaner'), 'desc' => __('Hide the thumbnails column.<br /><small>Useful if your WordPress if filled-up with huge images.</small>', 'media-file-cleaner'), 'type' => 'checkbox', 'default' => false)), 'wpmc_pro' => array(array('name' => 'pro', 'label' => '', 'desc' => sprintf(__("Status: %s", 'media-file-cleaner'), $pro_status), 'type' => 'html'), array('name' => 'subscr_id', 'label' => __('Serial', 'media-file-cleaner'), 'desc' => __('<br />Enter your serial or subscription ID here. If you don\'t have one yet, get one <a target="_blank" href="http://apps.meow.fr/media-file-cleaner/">right here</a>.', 'media-file-cleaner'), 'type' => 'text', 'default' => "")));
    $wpmc_settings_api->set_sections($sections);
    $wpmc_settings_api->set_fields($fields);
    $wpmc_settings_api->admin_init();
}
function wr2x_admin_init()
{
    if (isset($_POST) && isset($_POST['wr2x_pro'])) {
        wr2x_validate_pro($_POST['wr2x_pro']['subscr_id']);
    }
    $pro_status = get_option('wr2x_pro_status', "Not Pro.");
    require 'wr2x_class.settings-api.php';
    if (delete_transient('wr2x_flush_rules')) {
        global $wp_rewrite;
        wr2x_generate_rewrite_rules($wp_rewrite, true);
    }
    $sections = array(array('id' => 'wr2x_basics', 'title' => __('Basics', 'wp-retina-2x')), array('id' => 'wr2x_advanced', 'title' => __('Advanced', 'wp-retina-2x')), array('id' => 'wr2x_pro', 'title' => __('Pro', 'wp-retina-2x')));
    // Default Auto-Generate
    $auto_generate = wr2x_getoption('auto_generate', 'wr2x_basics', null);
    if ($auto_generate === null) {
        wr2x_setoption('auto_generate', 'wr2x_basics', 'on');
    }
    $wpsizes = wr2x_get_image_sizes();
    $sizes = array();
    foreach ($wpsizes as $name => $attr) {
        $sizes["{$name}"] = sprintf("<div style='float: left; text-align: right; margin-right: 5px; width: 20px;'>%s</div> <b>%s</b> <small>(Normal: %dx%d, Retina: %dx%d)</small>", wr2x_size_shortname($name), $name, $attr['width'], $attr['height'], $attr['width'] * 2, $attr['height'] * 2);
    }
    $fields = array('wr2x_basics' => array(array('name' => 'ignore_sizes', 'label' => __('Disabled Sizes', 'wp-retina-2x'), 'desc' => __('<br />The selected sizes will not have their retina equivalent generated.', 'wp-retina-2x'), 'type' => 'multicheck', 'options' => $sizes), array('name' => 'auto_generate', 'label' => __('Auto Generate', 'wp-retina-2x'), 'desc' => __('Generate retina images automatically when images are uploaded or re-generated.<br /><small>The \'Disabled Sizes\' will be skipped.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => true), array('name' => 'disable_responsive', 'label' => __('Disable Responsive<br/>(WP 4.4+)', 'wp-retina-2x'), 'desc' => __('Disable the Responsive Images feature of WordPress 4.4+.<br /><small>This feature can be quite messy for many websites as it creates a src-set automatically with all your image sizes in it. You can disable it completely here and get back control over your HTML as it is in the editor (while keeping the plugin adding Retina support, of course).</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'disable_medium_large', 'label' => __('Disable Medium Large<br/>(WP 4.4+)', 'wp-retina-2x'), 'desc' => __('Disable the image size called "Medium Large" created by in WordPress 4.4+.<br /><small>You probably don\'t need this and it creates additional images. Be careful however, future themes might use it.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'full_size', 'label' => __('Full Size Retina (Pro)', 'wp-retina-2x'), 'desc' => __('Retina for the full-size image will be considered required.<br /><small>Checks for Full-Size retina will be enabled and upload features made available.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_advanced' => array(array('name' => 'method', 'label' => __('Method', 'wp-retina-2x'), 'desc' => __('<br />In all cases (including "None"), Retina support will be added to the Responsive Images created by WP 4.4.<br />Check the <a href="http://apps.meow.fr/wp-retina-2x/retina-methods/">Retina Methods</a> page if you want to know more about those methods.', 'wp-retina-2x'), 'type' => 'radio', 'default' => 'Picturefill', 'options' => array('Picturefill' => __("Picturefill (Recommended)", 'wp-retina-2x'), 'retina.js' => __("Retina.js", 'wp-retina-2x'), 'HTML Rewrite' => __("IMG Rewrite", 'wp-retina-2x'), 'Retina-Images' => __("Retina-Images", 'wp-retina-2x'), 'none' => __("None", 'wp-retina-2x'))), array('name' => 'image_quality', 'label' => __('Quality', 'wp-retina-2x'), 'desc' => __('<br />Image Compression quality (between 0 and 100).<br />That doesn\'t always actually work depending on your hosting service.', 'wp-retina-2x'), 'type' => 'text', 'default' => 90), array('name' => 'debug', 'label' => __('Debug Mode', 'wp-retina-2x'), 'desc' => __('Retina images will be always displayed and a log file will be created. <br /><small>Please use it for testing purposes. It creates a <a href="' . plugins_url("wp-retina-2x") . '/wp-retina-2x.log">log file</a> in the plugin folder.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'cdn_domain', 'label' => __('Custom CDN Domain (Pro)', 'wp-retina-2x'), 'desc' => __('<br />If not empty, your site domain will be replaced with this CDN domain (PictureFill and HTML Rewrite only).', 'wp-retina-2x'), 'type' => 'text', 'default' => ""), array('name' => 'picture_fill', 'label' => '', 'desc' => __('<h2>For PictureFill</h2><small>Using "Keep IMG SRC" and "Use Lazysizes" is the perfect middle between SEO and Performance.<br />Since WP 4.4, the src-set is already created for post content. Those options will therefore only affect the images which are <u>not</u> in the post content.</small>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'picturefill_keep_src', 'label' => __('Keep IMG SRC (Pro)', 'wp-retina-2x'), 'desc' => __('Excellent for SEO. But Retina devices will get both normal and retina images.<br /><small>With PictureFill, <b>src</b> tags are replaced by <b>src-set</b> tags and consequently search engines might not be able to find and reference those images.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'picturefill_lazysizes', 'label' => __('Use Lazysizes (Pro)', 'wp-retina-2x'), 'desc' => __('Retina images will be loaded in a lazy way, when the visitor is getting close to them.<br /><small>HTML will be rewritten to support the lazysizes and the script will be also loaded. </small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'picturefill_noscript', 'label' => __('No Picturefill Script', 'wp-retina-2x'), 'desc' => __('The script for Picturefill will not be loaded.<br /><small>Only the browsers with src-set support (e.g. Chrome) will display images. You can also load the Picturefill script manually.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'admin_screens', 'label' => '', 'desc' => __('<h2>Admin Screens</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'hide_retina_column', 'label' => __('Hide \'Retina\' column', 'wp-retina-2x'), 'desc' => __('Will hide the \'Retina Column\' from the Media Library.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'hide_retina_dashboard', 'label' => __('Hide Retina Dashboard', 'wp-retina-2x'), 'desc' => __('Doesn\'t show the Retina Dashboard menu and tools.', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'retina_admin', 'label' => __('Admin in Retina', 'wp-retina-2x'), 'desc' => __('WordPress Admin will also be Retina.<br /><small>Some plugins (like NextGen) do not like Retina enabled in the admin.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false), array('name' => 'mobile', 'label' => '', 'desc' => __('<h2>Mobiles</h2>', 'wp-retina-2x'), 'type' => 'html'), array('name' => 'ignore_mobile', 'label' => __('Ignore Mobile', 'wp-retina-2x'), 'desc' => __('Doesn\'t deliver Retina images to mobiles.<br /><small>PictureFill doesn\'t support it and cache will also prevent it from working.</small>', 'wp-retina-2x'), 'type' => 'checkbox', 'default' => false)), 'wr2x_pro' => array(array('name' => 'pro', 'label' => '', 'desc' => __(sprintf('Status: %s<br /><br />With the Pro version, full support for the <b>Full Size Retina</b> will be added. You will also get a new and nice pop-up window with more <b>Details</b> in the Retina dashboard.', $pro_status), 'wp-retina-2x'), 'type' => 'html'), array('name' => 'subscr_id', 'label' => __('Serial', 'wp-retina-2x'), 'desc' => __('<br />Enter your serial or subscription ID here. If you don\'t have one yet, get one <a target="_blank" href="http://apps.meow.fr/wp-retina-2x/">right here</a>.', 'wp-retina-2x'), 'type' => 'text', 'default' => "")));
    global $wr2x_settings_api;
    $wr2x_settings_api = new WeDevs_Settings_API();
    $wr2x_settings_api->set_sections($sections);
    $wr2x_settings_api->set_fields($fields);
    $wr2x_settings_api->admin_init();
}
Esempio n. 6
0
 function admin_init()
 {
     require 'mfrh_class.settings-api.php';
     if (isset($_GET['reset'])) {
         if (file_exists(plugin_dir_path(__FILE__) . '/media-file-renamer.log')) {
             unlink(plugin_dir_path(__FILE__) . '/media-file-renamer.log');
         }
         if (file_exists(plugin_dir_path(__FILE__) . '/mfrh_sql.log')) {
             unlink(plugin_dir_path(__FILE__) . '/mfrh_sql.log');
         }
         if (file_exists(plugin_dir_path(__FILE__) . '/mfrh_sql_revert.log')) {
             unlink(plugin_dir_path(__FILE__) . '/mfrh_sql_revert.log');
         }
     }
     // Default Auto-Generate
     $auto_rename = $this->getoption('auto_rename', 'mfrh_basics', null);
     if ($auto_rename === null || $auto_rename === true) {
         $this->setoption('auto_rename', 'mfrh_basics', 'media_title');
     }
     // Default Rename Slug
     $rename_slug = $this->getoption('rename_slug', 'mfrh_basics', null);
     if ($rename_slug === null) {
         $this->setoption('rename_slug', 'mfrh_basics', 'on');
     }
     // Default Rename GUID
     $rename_guid = $this->getoption('rename_guid', 'mfrh_basics', null);
     if ($rename_guid === null) {
         $this->setoption('rename_guid', 'mfrh_basics', 'on');
     }
     // Default Update Posts
     $update_posts = $this->getoption('update_posts', 'mfrh_basics', null);
     if ($update_posts === null) {
         $this->setoption('update_posts', 'mfrh_basics', 'on');
     }
     // Default Post Meta
     $update_postmeta = $this->getoption('update_postmeta', 'mfrh_basics', null);
     if ($update_postmeta === null) {
         $this->setoption('update_postmeta', 'mfrh_basics', 'on');
     }
     // Default UTF-8
     $update_postmeta = $this->getoption('utf8_filename', 'mfrh_basics', null);
     if ($update_postmeta === null) {
         $this->setoption('utf8_filename', 'mfrh_basics', 'off');
     }
     // Force Rename
     $force_rename = $this->getoption('force_rename', 'mfrh_basics', null);
     if ($force_rename === null) {
         $this->setoption('force_rename', 'mfrh_basics', 'off');
     }
     if (isset($_POST) && isset($_POST['mfrh_pro'])) {
         $this->validate_pro($_POST['mfrh_pro']['subscr_id']);
     }
     $pro_status = get_option('mfrh_pro_status', "Not Pro.");
     $sections = array(array('id' => 'mfrh_basics', 'title' => __('Basics', 'media-file-renamer')), array('id' => 'mfrh_pro', 'title' => __('Pro', 'media-file-renamer')));
     $fields = array('mfrh_basics' => array(array('name' => 'auto_rename', 'label' => __('Auto Rename', 'media-file-renamer'), 'desc' => __('If the plugin considers that it is too dangerous to rename the file directly at some point, it will be flagged internally as <b>to be renamed</b>. The list of those flagged files can be found in Media > File Renamer and they can be renamed from there.', 'media-file-renamer'), 'type' => 'radio', 'default' => 'media_title', 'options' => array('none' => __("None<br /><small>Disabled. Only manual renaming can be used.</small><br />", 'media-file-renamer'), 'media_title' => __("Media Title<br /><small>The filename will be renamed automatically depending on the title of the media. <b>This is the recommended method.</b></small><br />", 'media-file-renamer'), 'post_title' => __("Post Title (Pro)<br /><small>The filename will be renamed automatically depending on the title of the post the media <b>is attached to</b>.</small><br />", 'media-file-renamer'))), array('name' => 'manual_rename', 'label' => __('Manual Rename (Pro)', 'media-file-renamer'), 'desc' => __('Enable manual renaming in the Media edit screen.<br /><small>This feature is only for Pro users (check the Pro tab).</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'numbered_files', 'label' => __('Numbered Files (Pro)', 'media-file-renamer'), 'desc' => __('Identical filenames will be allowed and a number will be added.<br /><small>This is useful if your titles the same ones for many of your images (myfile.jpg, myfile-2.jpg, myfile-3.jpg, etc).</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'side_updates', 'label' => '', 'desc' => __('<h1>Side-Updates</h1><small>When the files are renamed, many links to them on your WordPress might be broken. By default, the plugin updates all the references in the posts. As the plugin evolves (thanks to the Pro version), more and more plugins/themes will be covered by those updates as we discover them together.</small>', 'media-file-renamer'), 'type' => 'html'), array('name' => 'update_posts', 'label' => __('Update Posts', 'media-file-renamer'), 'desc' => __('Update the references to the renamed files in the posts (pages and custom types included).', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'update_postmeta', 'label' => __('Update Post Meta', 'media-file-renamer'), 'desc' => __('Update the references in the posts metadata (including pages and custom types metadata).', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'update_something', 'label' => __('', 'media-file-renamer'), 'desc' => __('<i>Something is not updated when you rename a file? Please <a href="http://apps.meow.fr/contact/">contact me</a> and I will add support for it.</i>', 'media-file-renamer'), 'type' => 'html', 'default' => false), array('name' => 'rename_slug', 'label' => __('Rename Slug', 'media-file-renamer'), 'desc' => __('The image slug will be renamed like the new filename.<br /><small>Better to keep this un-checked as the link might have been referenced somewhere else.</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => true), array('name' => 'rename_guid', 'label' => __('Rename GUID<br /><small>(aka "File name")</small>', 'media-file-renamer'), 'desc' => __('The GUID will be renamed like the new filename.<br /><small>Better to keep this un-checked. Have a look a the FAQ.</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'sync_alt', 'label' => __('Alt. Text = Title (Pro)<br /><small>Sync Alternative Text</small>', 'media-file-renamer'), 'desc' => __('The Alternative Text will always be synchronized with the Title.<br /><small>Keep in mind that the HTML in your posts and pages will be however not modified, that is too dangerous!</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'advanced', 'label' => '', 'desc' => __('<h1>Advanced</h1><small>If you are geeky this section might be more interesting for you. <b>Want to clear/reset the logs? Click <a href="?page=mfrh_settings&reset=true">here</a>.</b></small>', 'media-file-renamer'), 'type' => 'html'), array('name' => 'rename_on_save', 'label' => __('Rename On Save', 'media-file-renamer'), 'desc' => __('Attachments will be renamed automatically when published posts/pages are saved.<br /><small>You can change the names of your media while editing a post but that wouldn\'t let the plugin updates the HTML, of course. With this option, the plugin will check for any changes in the media names and will update your post right after you saved it.</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'utf8_filename', 'label' => __('UTF-8 Filename (Pro)', 'media-file-renamer'), 'desc' => __('The plugin will be allowed to use non-ASCII characters in the filenames.<br /><small>This usually doesn\'t work well on Windows installs.</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'force_rename', 'label' => __('Force Rename (Pro)', 'media-file-renamer'), 'desc' => __('Update the references to the file even if the file renaming itself was not successful.<br /><small>You might want to use that option if your install is broken and you are trying to link your Media to files for which the filenames has been altered (after a migration for exemple)</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'log', 'label' => __('Logs', 'media-file-renamer'), 'desc' => __('Simple logging that explains which actions has been run. The file is <a target="_blank" href="' . plugins_url("media-file-renamer") . '/media-file-renamer.log">media-file-renamer.log</a>.', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false), array('name' => 'logsql', 'label' => __('SQL Logs (Pro)<br />+ Revert SQL', 'media-file-renamer'), 'desc' => __('The files <a target="_blank" href="' . plugins_url("media-file-renamer") . '/mfrh_sql.log">mfrh_sql.log</a> and <a target="_blank" href="' . plugins_url("media-file-renamer") . '/mfrh_sql_revert.log">mfrh_sql_revert.log</a> will be created and they will include the raw SQL queries which were run by the plugin. If there is an issue, the revert file can help you reverting the changes more easily. <br /><small>This feature is only for Pro users (check the Pro tab).</small>', 'media-file-renamer'), 'type' => 'checkbox', 'default' => false)), 'mfrh_pro' => array(array('name' => 'pro', 'label' => '', 'desc' => __(sprintf('Status: %s', $pro_status), 'media-file-renamer'), 'type' => 'html'), array('name' => 'subscr_id', 'label' => __('Serial', 'media-file-renamer'), 'desc' => __('<br />Enter your serial or subscription ID here. If you don\'t have one yet, get one <a target="_blank" href="http://apps.meow.fr/media-file-renamer/">right here</a>.', 'media-file-renamer'), 'type' => 'text', 'default' => "")));
     global $mfrh_settings_api;
     $mfrh_settings_api = new WeDevs_Settings_API();
     $mfrh_settings_api->set_sections($sections);
     $mfrh_settings_api->set_fields($fields);
     $mfrh_settings_api->admin_init();
 }