Example #1
0
/**
 * Add Rocket informations into USER_AGENT
 *
 * @since 1.1.0
 */
function rocket_user_agent($user_agent)
{
    $consumer_key = '';
    if (isset($_POST[WP_ROCKET_SLUG]['consumer_key'])) {
        $consumer_key = $_POST[WP_ROCKET_SLUG]['consumer_key'];
    } else {
        if ('' != (string) get_rocket_option('consumer_key')) {
            $consumer_key = (string) get_rocket_option('consumer_key');
        }
    }
    $consumer_email = '';
    if (isset($_POST[WP_ROCKET_SLUG]['consumer_email'])) {
        $consumer_email = $_POST[WP_ROCKET_SLUG]['consumer_email'];
    } else {
        if ('' != (string) get_rocket_option('consumer_email')) {
            $consumer_email = (string) get_rocket_option('consumer_email');
        }
    }
    $bonus = !rocket_is_white_label() ? '' : '*';
    $bonus .= !get_rocket_option('do_beta') ? '' : '+';
    $new_ua = sprintf('%s;WP-Rocket|%s%s|%s|%s|%s|;', $user_agent, WP_ROCKET_VERSION, $bonus, $consumer_key, $consumer_email, esc_url(home_url()));
    return $new_ua;
}
Example #2
0
/**
 * Get WP Rocket footprint
 *
 * @since 2.0
 *
 * @param bool $debug (default: true) If true, adds the date of generation cache file
 * @return string The footprint that will be printed
 */
function get_rocket_footprint($debug = true)
{
    $footprint = !rocket_is_white_label() ? "\n" . '<!-- This website is like a Rocket, isn\'t it ? Performance optimized by WP Rocket. Learn more: http://wp-rocket.me' : "\n" . '<!-- Cached page for great performance';
    if ($debug) {
        $footprint .= ' - Debug: cached@' . time();
    }
    $footprint .= ' -->';
    return $footprint;
}
Example #3
0
<?php

defined('ABSPATH') or die('Cheatin\' uh?');
add_settings_section('rocket_display_tools', __('Tools', 'rocket'), '__return_false', 'tools');
if (!rocket_is_white_label()) {
    add_settings_field('rocket_do_beta', __('Beta Tester', 'rocket'), 'rocket_field', 'tools', 'rocket_display_tools', array(array('type' => 'checkbox', 'label' => __('Yes I do!', 'rocket'), 'label_for' => 'do_beta', 'label_screen' => __('Beta Tester', 'rocket')), array('type' => 'helper_description', 'name' => 'do_beta', 'description' => __('Check it to participate in the WP Rocket Beta Program and get earlier access to new versions, thanks in advance.', 'rocket'))));
}
add_settings_field('rocket_purge_all', __('Clear cache', 'rocket'), 'rocket_button', 'tools', 'rocket_display_tools', array('button' => array('button_label' => __('Clear cache', 'rocket'), 'url' => wp_nonce_url(admin_url('admin-post.php?action=purge_cache&type=all'), 'purge_cache_all')), 'helper_description' => array('name' => 'purge_all', 'description' => __('Clear the cache for the whole site.', 'rocket'))));
add_settings_field('rocket_preload', __('Preload cache', 'rocket'), 'rocket_button', 'tools', 'rocket_display_tools', array('button' => array('button_label' => __('Preload cache', 'rocket'), 'url' => wp_nonce_url(admin_url('admin-post.php?action=preload'), 'preload')), 'helper_description' => array('name' => 'preload', 'description' => __('Allows you to request a bot crawl to preload the cache (homepage and its internal links).', 'rocket'))));
add_settings_field('rocket_export_options', __('Settings Exporter', 'rocket'), 'rocket_field', 'tools', 'rocket_display_tools', array('type' => 'rocket_export_form', 'name' => 'export'));
add_settings_field('rocket_import_options', __('Settings Importer', 'rocket'), 'rocket_field', 'tools', 'rocket_display_tools', array('type' => 'rocket_import_upload_form'));
if (current_user_can('update_plugins')) {
    $temp_description = __('Please backup your settings before, use the "Download options" button above.', 'rocket');
    add_settings_field('rocket_rollback', __('Update Rollback', 'rocket'), 'rocket_button', 'tools', 'rocket_display_tools', array('button' => array('button_label' => sprintf(__('Reinstall v%s', 'rocket'), WP_ROCKET_LASTVERSION), 'url' => wp_nonce_url(admin_url('admin-post.php?action=rocket_rollback'), 'rocket_rollback')), 'helper_description' => array('name' => 'rollback', 'description' => sprintf(__('Is the version %s causing you some issues? You can ask for a rollback and reinstall the last version you used before.', 'rocket'), WP_ROCKET_VERSION)), 'helper_warning' => array('name' => 'rollback2', 'description' => $temp_description)));
}
unset($temp_description);
Example #4
0
<?php

defined('ABSPATH') or die('Cheatin\' uh?');
add_settings_section('rocket_display_main_options', __('Basic options', 'rocket'), '__return_false', 'basic');
add_settings_field('rocket_lazyload', __('Lazyload:', 'rocket'), 'rocket_field', 'basic', 'rocket_display_main_options', array(array('type' => 'checkbox', 'label' => __('Images', 'rocket'), 'label_for' => 'lazyload', 'label_screen' => __('Lazyload on images', 'rocket')), array('type' => 'checkbox', 'label' => __('Iframes & Videos', 'rocket'), 'label_for' => 'lazyload_iframes', 'label_screen' => __('Lazyload on iframes and videos', 'rocket')), array('type' => 'helper_description', 'name' => 'lazyload', 'description' => __('LazyLoad displays images, iframes and videos on a page only when they are visible to the user.', 'rocket') . '<br/>' . __('This mechanism reduces the number of HTTP requests and improves the loading time.', 'rocket'))));
add_settings_field('rocket_minify', __('Files optimisation:<br/><span class="description">(Minification & Concatenation)</span>', 'rocket'), 'rocket_field', 'basic', 'rocket_display_main_options', array(array('type' => 'checkbox', 'label' => 'HTML', 'name' => 'minify_html', 'label_screen' => __('HTML Files minification', 'rocket')), array('parent' => 'minify_html', 'type' => 'checkbox', 'label' => 'Inline CSS', 'name' => 'minify_html_inline_css', 'label_screen' => 'Inline CSS minification'), array('parent' => 'minify_html', 'type' => 'checkbox', 'label' => 'Inline JS', 'name' => 'minify_html_inline_js', 'label_screen' => 'Inline JS minification'), array('type' => 'checkbox', 'label' => 'Google Fonts', 'name' => 'minify_google_fonts', 'label_screen' => __('Google Fonts minification', 'rocket')), array('type' => 'checkbox', 'label' => 'CSS', 'name' => 'minify_css', 'label_screen' => __('CSS Files minification', 'rocket')), array('type' => 'checkbox', 'label' => 'JS', 'name' => 'minify_js', 'label_screen' => __('JS Files minification', 'rocket')), array('type' => 'helper_description', 'name' => 'minify', 'description' => __('Minification removes any spaces and comments present in the CSS and JavaScript files.', 'rocket') . '<br/>' . __('This mechanism reduces the weight of each file and allows a faster reading of browsers and search engines.', 'rocket') . '<br/>' . __('Concatenation combines all CSS and JavaScript files.', 'rocket') . '<br/>' . __('This mechanism reduces the number of HTTP requests and improves the loading time.', 'rocket')), array('type' => 'helper_warning', 'name' => 'minify_help1', 'description' => __('Concatenating files can cause display errors.', 'rocket')), array('display' => !rocket_is_white_label(), 'type' => 'helper_warning', 'name' => 'minify_help2', 'description' => sprintf(__('In case of any errors we recommend you to turn off this option or watch the following video: <a href="%1$s" class="fancybox">%1$s</a>.', 'rocket'), defined('WPLANG') && WPLANG == 'fr_FR' ? 'http://www.youtube.com/embed/5-Llh0ivyjs' : 'http://www.youtube.com/embed/kymoxCwW03c'))));
// Mobile plugins list
$mobile_plugins = array('<a href="https://wordpress.org/plugins/wptouch/" target="_blank">WP Touch</a>', '<a href="https://wordpress.org/plugins/wp-mobile-detector/" target="_blank">WP Mobile Detector</a>', '<a href="https://wordpress.org/plugins/wiziapp-create-your-own-native-iphone-app" target="_blank">wiziApp</a>', '<a href="https://wordpress.org/plugins/wordpress-mobile-pack/" target="_blank">WordPress Mobile Pack</a>', '<a href="https://wordpress.org/plugins/wp-mobilizer/" target="_blank">WP-Mobilizer</a>', '<a href="https://wordpress.org/plugins/wp-mobile-edition/" target="_blank">WP Mobile Edition</a>');
add_settings_field('rocket_mobile', __('Mobile cache:', 'rocket'), 'rocket_field', 'basic', 'rocket_display_main_options', array(array('type' => 'checkbox', 'label' => __('Enable caching for mobile devices.', 'rocket'), 'label_for' => 'cache_mobile', 'label_screen' => __('Mobile cache:', 'rocket')), array('type' => 'helper_warning', 'name' => 'mobile', 'description' => wp_sprintf(__('Don\'t turn on this option if you use one of these plugins: %l.', 'rocket'), $mobile_plugins))));
add_settings_field('rocket_logged_user', __('Logged in user cache:', 'rocket'), 'rocket_field', 'basic', 'rocket_display_main_options', array('type' => 'checkbox', 'label' => __('Enable caching for logged in users.', 'rocket'), 'label_for' => 'cache_logged_user', 'label_screen' => __('Logged in user cache:', 'rocket')));
add_settings_field('rocket_ssl', __('SSL cache:', 'rocket'), 'rocket_field', 'basic', 'rocket_display_main_options', array('type' => 'checkbox', 'label' => __('Enable caching for pages with SSL protocol (<code>https://</code>).', 'rocket'), 'label_for' => 'cache_ssl', 'label_screen' => __('SSL cache:', 'rocket')));
add_settings_field('rocket_purge', __('Clear Cache Lifespan', 'rocket'), 'rocket_field', 'basic', 'rocket_display_main_options', array(array('type' => 'number', 'label_for' => 'purge_cron_interval', 'label_screen' => __('Clear Cache Lifespan', 'rocket'), 'fieldset' => 'start'), array('type' => 'select', 'label_for' => 'purge_cron_unit', 'label_screen' => __('Unit of time', 'rocket'), 'fieldset' => 'end', 'options' => array('SECOND_IN_SECONDS' => __('second(s)', 'rocket'), 'MINUTE_IN_SECONDS' => __('minute(s)', 'rocket'), 'HOUR_IN_SECONDS' => __('hour(s)', 'rocket'), 'DAY_IN_SECONDS' => __('day(s)', 'rocket'))), array('type' => 'helper_description', 'name' => 'purge', 'description' => __('By default, cache lifespan is 24 hours. This means that once created, the cache files are automatically removed after 24 hours before being recreated.', 'rocket') . '<br/>' . __('This can be useful if you display your latest tweets or rss feeds in your sidebar, for example.', 'rocket')), array('type' => 'helper_help', 'name' => 'purge', 'description' => __('Specify 0 for unlimited lifetime.', 'rocket'))));
Example #5
0
function rocket_admin_bar($wp_admin_bar)
{
    if (!current_user_can(apply_filters('rocket_capacity', 'manage_options'))) {
        return;
    }
    $action = 'purge_cache';
    // Parent
    $wp_admin_bar->add_menu(array('id' => 'wp-rocket', 'title' => WP_ROCKET_PLUGIN_NAME, 'href' => admin_url('options-general.php?page=' . WP_ROCKET_PLUGIN_SLUG)));
    // Settings
    $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'rocket-settings', 'title' => __('Settings', 'rocket'), 'href' => admin_url('options-general.php?page=' . WP_ROCKET_PLUGIN_SLUG)));
    if (rocket_valid_key()) {
        if (rocket_is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
            // Purge All
            $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'purge-all', 'title' => __('Clear cache', 'rocket'), 'href' => '#'));
            if ($langlinks = get_rocket_wpml_langs_for_admin_bar()) {
                foreach ($langlinks as $lang) {
                    $wp_admin_bar->add_menu(array('parent' => 'purge-all', 'id' => 'purge-all-' . $lang['code'], 'title' => $lang['flag'] . '&nbsp;' . $lang['anchor'], 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&type=all&lang=' . $lang['code']), $action . '_all')));
                }
            }
        } else {
            if (rocket_is_plugin_active('qtranslate/qtranslate.php') || rocket_is_plugin_active('polylang/polylang.php')) {
                // Purge All
                $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'purge-all', 'title' => __('Clear cache', 'rocket'), 'href' => '#'));
                // Add submenu for each active langs
                if (rocket_is_plugin_active('qtranslate/qtranslate.php')) {
                    $langlinks = get_rocket_qtranslate_langs_for_admin_bar();
                } else {
                    if (rocket_is_plugin_active('polylang/polylang.php')) {
                        $langlinks = get_rocket_polylang_langs_for_admin_bar();
                    }
                }
                foreach ($langlinks as $lang) {
                    $wp_admin_bar->add_menu(array('parent' => 'purge-all', 'id' => 'purge-all-' . $lang['code'], 'title' => $lang['flag'] . '&nbsp;' . $lang['anchor'], 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&type=all&lang=' . $lang['code']), $action . '_all')));
                }
                // Add subemnu "All langs"
                $wp_admin_bar->add_menu(array('parent' => 'purge-all', 'id' => 'purge-all-all', 'title' => '<div class="dashicons-before dashicons-admin-site" style="line-height:1.5"> ' . __('All languages', 'rocket') . '</div>', 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&type=all&lang=all'), $action . '_all')));
            } else {
                // Purge All
                $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'purge-all', 'title' => __('Clear cache', 'rocket'), 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&type=all'), $action . '_all')));
            }
        }
        if (is_admin()) {
            // Purge a post
            global $pagenow, $post;
            if ($post && 'post.php' == $pagenow && isset($_GET['action'], $_GET['post'])) {
                $pobject = get_post_type_object($post->post_type);
                $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'purge-post', 'title' => __('Clear this post', 'rocket'), 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&type=post-' . $post->ID), $action . '_post-' . $post->ID)));
            }
        } else {
            // Purge this URL (frontend)
            $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'purge-url', 'title' => __('Purge this URL', 'rocket'), 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&type=url'), $action . '_url')));
        }
        $action = 'preload';
        // Go robot gogo !
        if (rocket_is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
            $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'preload-cache', 'title' => __('Preload cache', 'rocket'), 'href' => '#'));
            if ($langlinks = get_rocket_wpml_langs_for_admin_bar()) {
                foreach ($langlinks as $lang) {
                    $wp_admin_bar->add_menu(array('parent' => 'preload-cache', 'id' => 'preload-cache-' . $lang['code'], 'title' => $lang['flag'] . '&nbsp;' . $lang['anchor'], 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&lang=' . $lang['code']), $action)));
                }
            }
        } else {
            if (rocket_is_plugin_active('qtranslate/qtranslate.php') || rocket_is_plugin_active('polylang/polylang.php')) {
                $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'preload-cache', 'title' => __('Preload cache', 'rocket'), 'href' => '#'));
                if (rocket_is_plugin_active('qtranslate/qtranslate.php')) {
                    $langlinks = get_rocket_qtranslate_langs_for_admin_bar();
                } else {
                    if (rocket_is_plugin_active('polylang/polylang.php')) {
                        $langlinks = get_rocket_polylang_langs_for_admin_bar();
                    }
                }
                foreach ($langlinks as $lang) {
                    $wp_admin_bar->add_menu(array('parent' => 'preload-cache', 'id' => 'preload-cache-' . $lang['code'], 'title' => $lang['flag'] . '&nbsp;' . $lang['anchor'], 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&lang=' . $lang['code']), $action)));
                }
                $wp_admin_bar->add_menu(array('parent' => 'preload-cache', 'id' => 'preload-cache-all', 'title' => '<div class="dashicons-before dashicons-admin-site" style="line-height:1.5;"> ' . __('All languages', 'rocket') . '</div>', 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action . '&lang=all'), $action)));
            } else {
                $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'preload-cache', 'title' => __('Preload cache', 'rocket'), 'href' => wp_nonce_url(admin_url('admin-post.php?action=' . $action), $action)));
            }
        }
    }
    if (!rocket_is_white_label()) {
        // Go to WP Rocket Documentation
        $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'docs', 'title' => __('Documentation', 'rocket'), 'href' => 'http://docs.wp-rocket.me'));
        // Go to WP Rocket Support
        $wp_admin_bar->add_menu(array('parent' => 'wp-rocket', 'id' => 'support', 'title' => __('Support', 'rocket'), 'href' => 'http://wp-rocket.me/support/'));
    }
}
Example #6
0
<?php

defined('ABSPATH') or die('Cheatin\' uh?');
add_settings_section('rocket_display_imp_options', __('Advanced options', 'rocket'), '__return_false', 'advanced');
add_settings_field('rocket_dns_prefetch', __('Prefetch DNS requests:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'textarea', 'label_for' => 'dns_prefetch', 'label_screen' => __('Prefetch DNS requests:', 'rocket')), array('type' => 'helper_description', 'name' => 'dns_prefetch', 'description' => __('DNS prefetching is a way for browsers to anticipate the DNS resolution of external domains from your site.', 'rocket') . '<br/>' . __('This mechanism reduces the latency of some external files.', 'rocket')), array('display' => !rocket_is_white_label(), 'type' => 'helper_help', 'name' => 'dns_prefetch', 'description' => sprintf(__('To learn more about this option and how to use it correctly, we advise you to watch the following video: <a href="%1$s" class="fancybox">%1$s</a>.', 'rocket'), defined('WPLANG') && WPLANG == 'fr_FR' ? 'http://www.youtube.com/embed/ElJCtUidLwc' : 'http://www.youtube.com/embed/jKMU6HgMMrA')), array('type' => 'helper_help', 'name' => 'dns_prefetch', 'description' => __('<strong>Note:</strong> Enter the domain names without their protocol, for example: <code>//ajax.googleapis.com</code> without <code>http:</code> (one per line).', 'rocket'))));
add_settings_field('rocket_purge_pages', __('Empty the cache of the following pages when updating a post:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'textarea', 'label_for' => 'cache_purge_pages', 'label_screen' => __('Empty the cache of the following pages when updating a post:', 'rocket')), array('type' => 'helper_help', 'name' => 'purge_pages', 'description' => __('Enter the URL of additionnal pages to purge when updating a post (one per line).', 'rocket') . '<br/>' . __('You can use regular expressions (regex).', 'rocket')), array('type' => 'helper_help', 'name' => 'purge_pages', 'description' => __('<strong>Note:</strong> When you update a post or when a comment is posted, the homepage, categories and tags associated with this post are automatically removed from the cache and then recreated by our bot.', 'rocket'))));
add_settings_field('rocket_reject_uri', __('Never cache the following pages:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'textarea', 'label_for' => 'cache_reject_uri', 'label_screen' => __('Never cache the following pages:', 'rocket')), array('type' => 'helper_help', 'name' => 'reject_uri', 'description' => __('Enter the URL of pages to reject (one per line).', 'rocket') . '<br/>' . __('You can use regular expressions (regex).', 'rocket')), array('type' => 'helper_help', 'name' => 'cache_reject_ua', 'description' => __('<strong>Note:</strong> The cart and checkout pages are auto-excluded from the cache for WooCommerce, Easy Digital Download, iThemes Exchange, Jigoshop & WP-Shop.', 'rocket'))));
add_settings_field('rocket_reject_cookies', __('Don\'t cache pages that use the following cookies:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'textarea', 'label_for' => 'cache_reject_cookies', 'label_screen' => __('Don\'t cache pages that use the following cookies:', 'rocket')), array('type' => 'helper_help', 'name' => 'reject_cookies', 'description' => __('List the names of the cookies (one per line).', 'rocket'))));
add_settings_field('rocket_query_strings', __('Cache pages that use the following query strings (GET parameters):', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'textarea', 'label_for' => 'cache_query_strings', 'label_screen' => __('Cache pages that use the following query strings (GET parameters):', 'rocket')), array('type' => 'helper_help', 'name' => 'query_strings', 'description' => __('List of query strings which can be cached (one per line).', 'rocket'))));
add_settings_field('rocket_reject_ua', __('Never send cache pages for these user agents:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'textarea', 'label_for' => 'cache_reject_ua', 'label_screen' => __('Never send cache pages for these user agents:', 'rocket')), array('type' => 'helper_help', 'name' => 'cache_reject_ua', 'description' => __('Enter the user agents name to reject (one per line).', 'rocket') . '<br/>' . __('You can use regular expressions (regex).', 'rocket'))));
add_settings_field('rocket_minify_combine_all', __('Reducing the number of minified files in one file on:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'checkbox', 'label' => 'CSS', 'name' => 'minify_css_combine_all', 'label_screen' => __('CSS Files minification', 'rocket')), array('type' => 'checkbox', 'label' => 'JS', 'name' => 'minify_js_combine_all', 'label_screen' => __('JS Files minification', 'rocket')), array('type' => 'helper_description', 'name' => 'rocket_minify_combine_all', 'description' => __('<strong>Note:</strong> We combine the minified files in little groups <strong>to ensure the best compatibility and better performance</strong>.', 'rocket') . '<br/>' . __('However <strong>you can force the minification to create only 1 file</strong> by activating this option.', 'rocket') . '<br/>' . __('But it\'s not recommended to do that because <strong>you won\'t take advantage of the parallelization of the download</strong>: it\'s faster to download 4 files in parallel rather than one big file.', 'rocket')), array('type' => 'helper_warning', 'name' => 'rocket_minify_combine_all', 'description' => __('Depending to your server configuration, these options can break your website. If you have any issues, you must deactivate it!', 'rocket'))));
add_settings_field('rocket_exclude_css', __('<b>CSS</b> files to exclude from minification:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'textarea', 'label_for' => 'exclude_css', 'label_screen' => __('<b>CSS</b> files to exclude from minification:', 'rocket')), array('type' => 'helper_help', 'name' => 'exclude_css', 'description' => __('Enter the URL of <b>CSS</b> files to reject (one per line).', 'rocket') . '<br/>' . __('You can use regular expressions (regex).', 'rocket'))));
add_settings_field('rocket_exclude_js', __('<b>JS</b> files to exclude from minification:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'textarea', 'label_for' => 'exclude_js', 'label_screen' => __('<b>JS</b> files to exclude from minification:', 'rocket')), array('type' => 'helper_help', 'name' => 'exclude_js', 'description' => __('Enter the URL of <b>JS</b> files to reject (one per line).', 'rocket') . '<br/>' . __('You can use regular expressions (regex).', 'rocket'))));
add_settings_field('minify_js_in_footer', __('<b>JS</b> files to be included in the footer during the minification process:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'repeater', 'label_screen' => __('<b>JS</b> files to be included in the footer during the minification process:', 'rocket'), 'name' => 'minify_js_in_footer', 'placeholder' => 'http://', 'repeater_drag_n_drop' => true, 'repeater_label_add_field' => __('Add URL', 'rocket')), array('type' => 'helper_help', 'name' => 'minify_js_in_footer', 'description' => __('Empty the field to remove it.', 'rocket'), 'class' => 'hide-if-js'), array('type' => 'helper_warning', 'name' => 'minify_js_in_footer', 'description' => __('You must specify the complete URL of the files.', 'rocket'))));
add_settings_field('rocket_deferred_js', __('<b>JS</b> files with deferred loading:', 'rocket'), 'rocket_field', 'advanced', 'rocket_display_imp_options', array(array('type' => 'rocket_defered_module'), array('type' => 'helper_help', 'name' => 'deferred_js', 'description' => __('You can add JavaScript files that will be loaded asynchronously at the same time as the page loads.', 'rocket')), array('type' => 'helper_help', 'name' => 'deferred_js', 'description' => __('Empty the field to remove it.', 'rocket'), 'class' => 'hide-if-js'), array('type' => 'helper_warning', 'name' => 'deferred_js', 'description' => __('You must specify the complete URL of the files.', 'rocket'))));
Example #7
0
function rocket_force_info_result($res, $action, $args)
{
    if ('plugin_information' == $action && isset($args->slug) && 'wp-rocket' == $args->slug && isset($res->external) && $res->external) {
        $request = wp_remote_post(WP_ROCKET_WEB_INFO, array('timeout' => 30, 'action' => 'plugin_information', 'request' => serialize($args)));
        if (is_wp_error($request)) {
            $res = new WP_Error('plugins_api_failed', sprintf(__('An unexpected error occurred. Something may be wrong with WP-Rocket.me or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.', 'rocket'), WP_ROCKET_WEB_SUPPORT), $request->get_error_message());
        } else {
            $res = maybe_unserialize(wp_remote_retrieve_body($request));
            if (!is_object($res) && !is_array($res)) {
                $res = new WP_Error('plugins_api_failed', sprintf(__('An unexpected error occurred. Something may be wrong with WP-Rocket.me or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.', 'rocket'), WP_ROCKET_WEB_SUPPORT), wp_remote_retrieve_body($request));
            }
        }
        if (!is_wp_error($res) && rocket_is_white_label()) {
            $res = (array) $res;
            $res['name'] = get_rocket_option('wl_plugin_name');
            $res['slug'] = sanitize_key($res['name']);
            $res['author'] = get_rocket_option('wl_author');
            $res['homepage'] = get_rocket_option('wl_author_URI');
            $res['wl_plugin_URI'] = get_rocket_option('wl_plugin_URI');
            $res['author_profile'] = get_rocket_option('wl_author_URI');
            $res['sections']['changelog'] = str_replace(array('wp-rocket', 'rocket_'), array($res['slug'], $res['slug'] . '_'), $res['sections']['changelog']);
            $res['sections']['changelog'] = str_replace(array('WP Rocket', 'WP&nbsp;Rocket', 'WP-Rocket'), $res['name'], $res['sections']['changelog']);
            $res['sections']['description'] = implode("\n", get_rocket_option('wl_description'));
            unset($res['sections']['installation'], $res['sections']['faq'], $res['contributors']);
            $res = (object) $res;
        }
    }
    return $res;
}
Example #8
0
/**
 * The main settings page construtor using the required functions from WP
 * @since 1.1.0 Add tabs, tools tab and change options severity
 * @since 1.0
 */
function rocket_display_options()
{
    $modules = array('api-key', 'basic', 'advanced', 'cloudflare', 'cdn', 'white-label', 'tools', 'tutorials', 'faq', 'support');
    foreach ($modules as $module) {
        require WP_ROCKET_ADMIN_UI_MODULES_PATH . $module . '.php';
    }
    ?>
	
	<div class="wrap">

	<h2><?php 
    echo WP_ROCKET_PLUGIN_NAME;
    ?>
 <small><sup><?php 
    echo WP_ROCKET_VERSION;
    ?>
</sup></small></h2>
	<form action="options.php" id="rocket_options" method="post" enctype="multipart/form-data">
		<?php 
    settings_fields('wp_rocket');
    rocket_hidden_fields(array('consumer_key', 'consumer_email', 'secret_key', 'license', 'secret_cache_key', 'minify_css_key', 'minify_js_key', 'version', 'cloudflare_old_settings'));
    submit_button();
    ?>
		<h2 class="nav-tab-wrapper hide-if-no-js">
			<?php 
    if (rocket_valid_key()) {
        ?>
				<a href="#tab_basic" class="nav-tab"><?php 
        _e('Basic options', 'rocket');
        ?>
</a>
				<a href="#tab_advanced" class="nav-tab"><?php 
        _e('Advanced options', 'rocket');
        ?>
</a>
				<?php 
        if (get_rocket_option('do_cloudflare')) {
            ?>
					<a href="#tab_cloudflare" class="nav-tab">CloudFlare</a>
				<?php 
        }
        ?>
				<a href="#tab_cdn" class="nav-tab"><?php 
        _e('CDN', 'rocket');
        ?>
</a>
				<?php 
        if (defined('WP_RWL')) {
            ?>
					<a href="#tab_whitelabel" class="nav-tab"><?php 
            _e('White Label', 'rocket');
            ?>
</a>
				<?php 
        }
        ?>
				<a href="#tab_tools" class="nav-tab"><?php 
        _e('Tools', 'rocket');
        ?>
</a>
				<?php 
        if (!rocket_is_white_label()) {
            ?>
					<?php 
            if (defined('WPLANG') && 'fr_FR' == WPLANG || 'fr_FR' == get_locale()) {
                ?>
						<a href="#tab_tutorials" class="nav-tab"><?php 
                _e('Tutorials', 'rocket');
                ?>
</a>
					<?php 
            }
            ?>
					<a href="#tab_faq" class="nav-tab"><?php 
            _e('FAQ', 'rocket');
            ?>
</a>
					<a href="#tab_support" class="nav-tab"><?php 
            _e('Support', 'rocket');
            ?>
</a>
				<?php 
        }
        ?>
			<?php 
    } else {
        ?>
				<a href="#tab_apikey" class="nav-tab"><?php 
        _e('License', 'rocket');
        ?>
</a>
				<a href="#tab_faq" class="nav-tab"><?php 
        _e('FAQ', 'rocket');
        ?>
</a>
				<a href="#tab_support" class="nav-tab file-error"><?php 
        _e('Support', 'rocket');
        ?>
</a>
			<?php 
    }
    ?>
			<?php 
    do_action('rocket_tab', rocket_valid_key());
    ?>
		</h2>
		<div id="rockettabs">
			<?php 
    if (rocket_valid_key()) {
        ?>
				<div class="rkt-tab" id="tab_basic"><?php 
        do_settings_sections('basic');
        ?>
</div>
				<div class="rkt-tab" id="tab_advanced"><?php 
        do_settings_sections('advanced');
        ?>
</div>
				<div class="rkt-tab" id="tab_cloudflare" <?php 
        echo get_rocket_option('do_cloudflare') ? '' : 'style="display:none"';
        ?>
><?php 
        do_settings_sections('cloudflare');
        ?>
</div>
				<div class="rkt-tab" id="tab_cdn"><?php 
        do_settings_sections('cdn');
        ?>
</div>
				<?php 
        $class_hidden = !defined('WP_RWL') ? ' hidden' : '';
        ?>
				<div class="rkt-tab<?php 
        echo $class_hidden;
        ?>
" id="tab_whitelabel"><?php 
        do_settings_sections('white_label');
        ?>
</div>
				<div class="rkt-tab" id="tab_tools"><?php 
        do_settings_sections('tools');
        ?>
</div>
				<?php 
        if (!rocket_is_white_label()) {
            ?>
					<div class="rkt-tab" id="tab_tutorials"><?php 
            do_settings_sections('tutorials');
            ?>
</div>
					<div class="rkt-tab rkt-tab-txt" id="tab_faq"><?php 
            do_settings_sections('faq');
            ?>
</div>
					<div class="rkt-tab rkt-tab-txt" id="tab_support"><?php 
            do_settings_sections('support');
            ?>
</div>
				<?php 
        }
        ?>
			<?php 
    } else {
        ?>
				<div class="rkt-tab" id="tab_apikey"><?php 
        do_settings_sections('apikey');
        ?>
</div>
				<div class="rkt-tab rkt-tab-txt" id="tab_faq"><?php 
        do_settings_sections('faq');
        ?>
</div>
				<div class="rkt-tab rkt-tab-txt" id="tab_support"><?php 
        do_settings_sections('support');
        ?>
</div>
			<?php 
    }
    ?>
			<?php 
    do_action('rocket_tab_content', rocket_valid_key());
    ?>
		</div>
		<?php 
    submit_button();
    ?>
	</form>
<?php 
}
Example #9
0
function __rocket_white_label($plugins)
{
    // We change the plugin's header
    $plugins['wp-rocket/wp-rocket.php'] = array('Name' => get_rocket_option('wl_plugin_name'), 'PluginURI' => get_rocket_option('wl_plugin_URI'), 'Version' => isset($plugins['wp-rocket/wp-rocket.php']['Version']) ? $plugins['wp-rocket/wp-rocket.php']['Version'] : '', 'Description' => reset(get_rocket_option('wl_description')), 'Author' => get_rocket_option('wl_author'), 'AuthorURI' => get_rocket_option('wl_author_URI'), 'TextDomain' => isset($plugins['wp-rocket/wp-rocket.php']['TextDomain']) ? $plugins['wp-rocket/wp-rocket.php']['TextDomain'] : '', 'DomainPath' => isset($plugins['wp-rocket/wp-rocket.php']['DomainPath']) ? $plugins['wp-rocket/wp-rocket.php']['DomainPath'] : '');
    // if white label, remove our names from contributors
    if (rocket_is_white_label()) {
        remove_filter('plugin_row_meta', 'rocket_plugin_row_meta', 10, 2);
    }
    return $plugins;
}