add support for editor helpers, starting with partials
This commit is contained in:
parent
9f963e1fbd
commit
a2e5159a58
|
@ -5,7 +5,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||||
* Initialize the addon.
|
* Initialize the addon.
|
||||||
* @param ComicPress $comicpress The master ComicPress object.
|
* @param ComicPress $comicpress The master ComicPress object.
|
||||||
*/
|
*/
|
||||||
function init($comicpress) {
|
function init(&$comicpress) {
|
||||||
add_action('admin_menu', array(&$this, 'setup_admin_interface'));
|
add_action('admin_menu', array(&$this, 'setup_admin_interface'));
|
||||||
add_filter('attachment_fields_to_edit', array(&$this, 'setup_comic_metadata_buttons'), 10, 2);
|
add_filter('attachment_fields_to_edit', array(&$this, 'setup_comic_metadata_buttons'), 10, 2);
|
||||||
add_action('show_comic', array(&$this, 'show_comic'), 1, 1);
|
add_action('show_comic', array(&$this, 'show_comic'), 1, 1);
|
||||||
|
@ -372,6 +372,7 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||||
* Update ComicPress options.
|
* Update ComicPress options.
|
||||||
*/
|
*/
|
||||||
function handle_update_comicpress_options() {
|
function handle_update_comicpress_options() {
|
||||||
|
$this->comicpress->comicpress_options['helpers'] = array();
|
||||||
foreach ($this->comicpress->comicpress_options as $option => $value) {
|
foreach ($this->comicpress->comicpress_options as $option => $value) {
|
||||||
if (isset($_POST['cp'][$option])) {
|
if (isset($_POST['cp'][$option])) {
|
||||||
switch ($option) {
|
switch ($option) {
|
||||||
|
@ -415,7 +416,12 @@ class ComicPressAddonCore extends ComicPressAddon {
|
||||||
case 'category_page_usage':
|
case 'category_page_usage':
|
||||||
case 'layout';
|
case 'layout';
|
||||||
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
|
$this->comicpress->comicpress_options[$option] = $_POST['cp'][$option];
|
||||||
break;
|
break;
|
||||||
|
case 'helpers':
|
||||||
|
foreach ($_POST['cp'][$option] as $helper => $set) {
|
||||||
|
$this->comicpress->comicpress_options['helpers'][$helper] = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
<h2><?php _e('ComicPress Config', 'comicpress') ?></h2>
|
<h2><?php _e('ComicPress Config', 'comicpress') ?></h2>
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" />
|
<input type="hidden" name="cp[_nonce]" value="<?php echo $nonce ?>" />
|
||||||
<table>
|
<h3><?php _e('Global Options', 'comicpress') ?></h3>
|
||||||
|
<table class="widefat fixed">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row" valign="top"><?php _e('Master Comic Category', 'comicpress') ?></th>
|
<th scope="row" valign="top"><?php _e('Master Comic Category', 'comicpress') ?></th>
|
||||||
<td>
|
<td>
|
||||||
|
@ -93,10 +94,23 @@
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</table>
|
||||||
|
<h3><?php _e('Admin Options', 'comicpress') ?></h3>
|
||||||
|
<table class="widefat fixed">
|
||||||
<tr>
|
<tr>
|
||||||
<td> </td>
|
<th scope="row">
|
||||||
<td><input type="submit" value="<?php _e("Submit Changes", 'comicpress') ?>" /></td>
|
Enable editing helpers
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
foreach (array(
|
||||||
|
"show_partials_info" => __('Show partials info', 'comicpress')
|
||||||
|
) as $key => $label) { ?>
|
||||||
|
<label><input type="checkbox" name="cp[helpers][<?php echo $key ?>]" value="yes" <?php echo (($this->comicpress->comicpress_options['helpers'][$key] === true) ? 'checked="checked"' : '') ?> /> <?php echo $label ?></label>
|
||||||
|
<?php }
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
<input type="submit" value="<?php _e("Submit Changes", 'comicpress') ?>" /> </form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,7 +14,8 @@ class ComicPress {
|
||||||
'blogpost_count' => 10,
|
'blogpost_count' => 10,
|
||||||
'comic_space' => 'comic_only',
|
'comic_space' => 'comic_only',
|
||||||
'category_page_usage' => 'archive_list',
|
'category_page_usage' => 'archive_list',
|
||||||
'layout' => 'classic.inc'
|
'layout' => 'classic.inc',
|
||||||
|
'helpers' => array()
|
||||||
);
|
);
|
||||||
|
|
||||||
var $additional_stylesheets = array();
|
var $additional_stylesheets = array();
|
||||||
|
@ -56,6 +57,17 @@ class ComicPress {
|
||||||
$this->sort_comic_categories();
|
$this->sort_comic_categories();
|
||||||
|
|
||||||
add_action('wp_head', array(&$this, 'wp_head'));
|
add_action('wp_head', array(&$this, 'wp_head'));
|
||||||
|
|
||||||
|
if (current_user_can('edit_themes')) {
|
||||||
|
if (!empty($this->comicpress_options['helpers'])) {
|
||||||
|
if (isset($this->comicpress_options['helpers']['show_partials_info'])) {
|
||||||
|
add_filter('comicpress_partial', array(&$this, 'comicpress_partial'), 10, 2);
|
||||||
|
add_action('wp_head', array(&$this, 'setup_comicpress_partial'));
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action('wp_footer', array(&$this, 'announce_activated_helpers'));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function wp_head() {
|
function wp_head() {
|
||||||
|
@ -66,6 +78,43 @@ class ComicPress {
|
||||||
<script type="text/javascript" src="<?php echo get_template_directory_uri() . $uri ?>"></script>
|
<script type="text/javascript" src="<?php echo get_template_directory_uri() . $uri ?>"></script>
|
||||||
<?php }
|
<?php }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function announce_activated_helpers() {
|
||||||
|
echo "<center>[ <strong>Activated ComicPress helpers:</strong> " . implode(", ", array_keys($this->comicpress_options['helpers'])) . " ]</center>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup_comicpress_partial() { ?>
|
||||||
|
<style type="text/css">
|
||||||
|
.partial-helper {
|
||||||
|
position: absolute;
|
||||||
|
z-index: 100;
|
||||||
|
padding: 4px;
|
||||||
|
border: solid #333 1px;
|
||||||
|
background-color: #447;
|
||||||
|
opacity: 0.1;
|
||||||
|
-moz-opacity: 0.1;
|
||||||
|
-khtml-opacity: 0.1;
|
||||||
|
zoom: 1;
|
||||||
|
cursor: crosshair
|
||||||
|
}
|
||||||
|
|
||||||
|
.partial-helper:hover {
|
||||||
|
opacity: 1;
|
||||||
|
-moz-opacity: 1;
|
||||||
|
-khtml-opacity: 1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<!--[if IE gte 6]>
|
||||||
|
<style type="text/css">
|
||||||
|
.partial-helper { filter: alpha(opacity=10); }
|
||||||
|
.partial-helper:hover { filter: alpha(opacity=100); }
|
||||||
|
</style>
|
||||||
|
<![endif]-->
|
||||||
|
<?php }
|
||||||
|
|
||||||
|
function comicpress_partial($content, $target) {
|
||||||
|
return '<div class="partial-helper">' . substr(realpath($target), strlen(realpath(get_template_directory())) + 1) . '</div>' . $content;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flatten all WP categories into nodes like 0/3/5.
|
* Flatten all WP categories into nodes like 0/3/5.
|
||||||
|
|
|
@ -95,7 +95,11 @@ function include_partial($partials = '') {
|
||||||
|
|
||||||
$target = $comicpress->get_partial_path($partials);
|
$target = $comicpress->get_partial_path($partials);
|
||||||
|
|
||||||
if ($target !== false) { include($target); }
|
if ($target !== false) {
|
||||||
|
ob_start();
|
||||||
|
include($target);
|
||||||
|
echo apply_filters("comicpress_partial", ob_get_clean(), $target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function in_comic_category() {
|
function in_comic_category() {
|
||||||
|
|
Loading…
Reference in New Issue