$value) {
if (strpos($setting, 'reject') === false && $value == '1') {
$caching = true;
break;
}
}
echo '
';
printf(__('The Genesis Framework extension is currently %s ', 'w3-total-cache'),
($caching ? '' . __('enabled', 'w3-total-cache') . '' :
'' . __('disabled', 'w3-total-cache') . ''));
if ($caching)
printf(__('and caching via %s', 'w3-total-cahe'),$config->get_string('fragmentcache.engine'));
echo '.
';
}
/**
* Setups sections
*/
function admin_init() {
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/extensions.php');
// Register our settings field group
w3tc_add_settings_section(
'header', // Unique identifier for the settings section
'Header', // Section title
'__return_false', // Section callback (we don't want anything)
'genesis.theme' // extension id, used to uniquely identify the extension;
);
w3tc_add_settings_section(
'content',
'Content',
'__return_false',
'genesis.theme'
);
w3tc_add_settings_section(
'sidebar',
'Sidebar',
'__return_false',
'genesis.theme'
);
w3tc_add_settings_section(
'footer',
'Footer',
'__return_false',
'genesis.theme'
);
w3tc_add_settings_section(
'exclusions',
'Disable fragment cache',
'__return_false',
'genesis.theme'
);
$settings = $this->settings();
foreach($settings as $setting => $meta) {
/**
* @var $label
* @var $description
* @var $section
* @var $type
*/
extract($meta);
w3tc_add_settings_field($setting, $label,
array($this, 'print_setting'), 'genesis.theme', $section,
array('label_for'=>$setting, 'type'=>$type,
'description' => $description));
}
}
/**
*
* @param $setting
* @param $args
*/
function print_setting($setting, $args) {
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/extensions.php');
list($name, $id) = w3tc_get_name_and_id('genesis.theme', $setting);
if ($args['type'] != 'custom')
w3_ui_element($args['type'], $setting, $name, w3tc_get_extension_config('genesis.theme', $setting), w3_extension_is_sealed('genesis.theme'));
else {
if ($setting == 'fragment_reject_roles'):
$saved_roles = w3tc_get_extension_config('genesis.theme', $setting);
if (!is_array($saved_roles))
$saved_roles = array();
?>
$role_data ) : ?>
type="checkbox" name="[]" value="" id="role_" />
'Header', 'genesis_footer' => 'Footer', 'genesis_sidebar' => 'Sidebar', 'genesis_loop' =>'The Loop', 'wp_head' => 'wp_head', 'wp_footer' => 'wp_footer', 'genesis_comments' => 'Comments', 'genesis_pings' => 'Pings', 'genesis_do_nav'=>'Primary navigation', 'genesis_do_subnav' => 'Secondary navigation');?>
type="hidden" name="" value="" />
$hook_label ) : ?>
type="checkbox" name="[]" value="" id="role_" />
get_boolean('fragmentcache.enabled');
$activation_enabled = $activation_enabled && defined('PARENT_THEME_NAME') && PARENT_THEME_NAME == 'Genesis' &&
defined('PARENT_THEME_VERSION') && version_compare(PARENT_THEME_VERSION, '1.9.0') >= 0;
$message = array();
if (is_network_admin()) {
w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/themes.php');
$themes = w3tc_get_themes();
$exists = false;
foreach ($themes as $theme) {
if (strtolower($theme->Template) == 'genesis')
$exists = true;
}
if (!$exists)
$message[] = 'Genesis Framework';
}elseif (!(defined('PARENT_THEME_NAME') && PARENT_THEME_NAME == 'Genesis'))
$message[] = 'Genesis Framework version >= 1.9.0';
if (!$config->get_boolean('fragmentcache.enabled'))
$message[] = 'Fragment Cache (W3 Total Cache Pro)';
$extensions['genesis.theme'] = array (
'name' => 'Genesis Framework',
'author' => 'W3 EDGE',
'description' => 'Provides 30-60% improvement in page generation time for the Genesis Framework by Copyblogger Media.',
'author uri' => 'http://www.w3-edge.com/',
'extension uri' => 'http://www.w3-edge.com/',
'extension id' => 'genesis.theme',
'version' => '0.1',
'enabled' => $activation_enabled,
'requirements' => implode(', ', $message),
'path' => 'w3-total-cache/extensions/Genesis.php'
);
return $extensions;
}
/**
* @return array
*/
function settings() {
return
array(
'wp_head' =>
array(
'type' => 'checkbox',
'section' => 'header',
'label' => __('Cache wp_head loop:', 'w3-total-cache'),
'description' =>__('Cache wp_head. This includes the embedded CSS, JS etc.', 'w3-total-cache')
),
'genesis_header' =>
array(
'type' => 'checkbox',
'section' => 'header',
'label' => __('Cache header:', 'w3-total-cache'),
'description' => __('Cache header loop. This is the area where the logo is located.', 'w3-total-cache')
),
'genesis_do_nav' =>
array(
'type' => 'checkbox',
'section' => 'header',
'label' => __('Cache primary navigation:', 'w3-total-cache'),
'description' => __('Caches the navigation filter; per page.', 'w3-total-cache')
),
'genesis_do_subnav' =>
array(
'type' => 'checkbox',
'section' => 'header',
'label' => __('Cache secondary navigation:', 'w3-total-cache'),
'description' => __('Caches secondary navigation filter; per page.', 'w3-total-cache'),
),
'loop_front_page' =>
array(
'type' => 'checkbox',
'section' => 'content',
'label' => __('Cache front page post loop:', 'w3-total-cache'),
'description' => __('Caches the front page post loop, pagination is supported.', 'w3-total-cache')
),
'loop_single' =>
array(
'type' => 'checkbox',
'section' => 'content',
'label' => __('Cache single post / page:', 'w3-total-cache'),
'description' => __('Caches the single post / page loop, pagination is supported.', 'w3-total-cache')
),
'loop_single_excluded' =>
array(
'type' => 'textarea',
'section' => 'content',
'label' => __('Excluded single pages / posts:', 'w3-total-cache'),
'description' => __('List of pages / posts that should not have the single post / post loop cached. Specify one page / post per line.', 'w3-total-cache')
),
'loop_single_genesis_comments' =>
array(
'type' => 'checkbox',
'section' => 'content',
'label' => __('Cache comments:', 'w3-total-cache'),
'description' => __('Caches the comments loop, pagination is supported.', 'w3-total-cache')
),
'loop_single_genesis_pings' =>
array(
'type' => 'checkbox',
'section' => 'content',
'label' => __('Cache pings:', 'w3-total-cache'),
'description' => __('Caches the ping loop, pagination is supported. One per line.', 'w3-total-cache')
),
'sidebar' =>
array(
'type' => 'checkbox',
'section' => 'sidebar',
'label' => __('Cache sidebar:', 'w3-total-cache'),
'description' => __('Caches sidebar loop, the widget area.', 'w3-total-cache')
),
'sidebar_excluded' =>
array(
'type' => 'textarea',
'section' => 'sidebar',
'label' => __('Exclude pages:', 'w3-total-cache'),
'description' => __('List of pages that should not have sidebar cached. Specify one page / post per line.', 'w3-total-cache')
),
'genesis_footer' =>
array(
'type' => 'checkbox',
'section' => 'footer',
'label' => __('Cache footer:', 'w3-total-cache'),
'description' => __('Caches footer loop.', 'w3-total-cache')
),
'wp_footer' =>
array(
'type' => 'checkbox',
'section' => 'footer',
'label' => __('Cache footer:', 'w3-total-cache'),
'description' => __('Caches wp_footer loop.', 'w3-total-cache')
),
'fragment_reject_logged_roles' =>
array('type' => 'checkbox',
'section' => 'exclusions',
'label' => __('Disable fragment cache:', 'w3-total-cache'),
'description' => 'Don\'t use fragment cache with the following hooks and for the specified user roles.'
),
'fragment_reject_logged_roles_on_actions' =>
array('type' => 'custom',
'section' => 'exclusions',
'label' => __('Select hooks:', 'w3-total-cache'),
'description' => __('Select hooks from the list that should not be cached if user belongs to any of the roles selected below.', 'w3-total-cache')
),
'fragment_reject_roles' =>
array('type' => 'custom',
'section' => 'exclusions',
'label' => __('Select roles:', 'w3-total-cache'),
'description' => __('Select user roles that should not use the fragment cache.', 'w3-total-cache')
)
);
}
}
$ext = new W3_GenesisAdmin();
$ext->run();