mirror of
https://github.com/10h30/genesis-simple-sidebars.git
synced 2026-07-11 18:46:05 +09:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 357bc65a70 | |||
| 4e5bfa7caf | |||
| f96e67d4df | |||
| fde95b0dd7 | |||
| 76e5f73e28 | |||
| 5a1b4bec6e | |||
| 2f6eb81ed6 | |||
| 13505bdc2b | |||
| ed788e7432 | |||
| 5d5b60de23 | |||
| 7395bd6db3 | |||
| ee29d99335 | |||
| 5300ec9601 | |||
| ff6077078d | |||
| 8d371db957 | |||
| 4b8381b9ca | |||
| 4ab113f4a8 | |||
| eeddc174f8 | |||
| 62da09e2df | |||
| f021c01b25 | |||
| eedd494ae5 | |||
| d8e63f2ccd | |||
| dcae718c4a | |||
| b69d318af9 | |||
| f84db05c75 | |||
| c47dd22e92 | |||
| 39f21130f4 | |||
| 718dfd9a55 | |||
| cf767d3206 | |||
| 39f34f9982 | |||
| 78faae2bbd | |||
| 00d39a0424 | |||
| 160fe214ed |
@@ -0,0 +1,14 @@
|
||||
# Default behavior
|
||||
* text=auto
|
||||
|
||||
# Text files
|
||||
*.php text
|
||||
*.css text
|
||||
*.js text
|
||||
*.md text
|
||||
|
||||
# Binary files
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.gif binary
|
||||
*.ico binary
|
||||
@@ -0,0 +1,4 @@
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
.svn
|
||||
node_modules/
|
||||
@@ -0,0 +1,5 @@
|
||||
.git
|
||||
.gitignore
|
||||
.gitattributes
|
||||
.svnignore
|
||||
node_modules
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(grunt) {
|
||||
|
||||
// Load tasks
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
|
||||
// Dependencies
|
||||
|
||||
// PHP
|
||||
|
||||
// Lint .php files for syntax errors
|
||||
phplint: {
|
||||
all: [ '*.php', 'lib/**/*.php' ]
|
||||
},
|
||||
|
||||
|
||||
// I18n
|
||||
|
||||
// Add text domain as last argument of i18n functions
|
||||
addtextdomain: {
|
||||
php: {
|
||||
options: {
|
||||
updateDomains: true
|
||||
},
|
||||
target: {
|
||||
files: {
|
||||
src: [
|
||||
'*.php',
|
||||
'lib/**/*.php'
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Check text domain is last argument of i18n functions
|
||||
checktextdomain: {
|
||||
options: {
|
||||
text_domain: '<%= pkg.name %>',
|
||||
keywords: [
|
||||
'__:1,2d',
|
||||
'_e:1,2d',
|
||||
'_x:1,2c,3d',
|
||||
'_ex:1,2c,3d',
|
||||
'_n:1,2,4d',
|
||||
'_nx:1,2,4c,5d',
|
||||
'_n_noop:1,2,3d',
|
||||
'_nx_noop:1,2,3c,4d',
|
||||
'esc_attr__:1,2d',
|
||||
'esc_html__:1,2d',
|
||||
'esc_attr_e:1,2d',
|
||||
'esc_html_e:1,2d',
|
||||
'esc_attr_x:1,2c,3d',
|
||||
'esc_html_x:1,2c,3d'
|
||||
]
|
||||
},
|
||||
files: {
|
||||
expand: true,
|
||||
src: [
|
||||
'*.php',
|
||||
'includes/**/*.php'
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// Build language .pot file
|
||||
makepot: {
|
||||
plugin: {
|
||||
options: {
|
||||
domainPath: '/languages',
|
||||
processPot: function( pot ) {
|
||||
pot.headers['report-msgid-bugs-to'] = 'StudioPress <translations@studiopress.com>';
|
||||
pot.headers['last-translator'] = 'StudioPress <translations@studiopress.com>';
|
||||
pot.headers['language-team'] = 'English <translations@studiopress.com>';
|
||||
pot.headers['plural-forms'] = 'nplurals=2; plural=n != 1;';
|
||||
pot.headers['x-generator'] = 'grunt-wp-i18n 0.4.4';
|
||||
pot.headers['x-poedit-basepath'] = '.';
|
||||
pot.headers['x-poedit-language'] = 'English';
|
||||
pot.headers['x-poedit-country'] = 'UNITED STATES';
|
||||
pot.headers['x-poedit-sourcecharset'] = 'utf-8';
|
||||
pot.headers['x-poedit-keywordslist'] = '__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;';
|
||||
pot.headers['x-poedit-bookmarks'] = '';
|
||||
pot.headers['x-poedit-searchpath-0'] = '.';
|
||||
pot.headers['x-textdomain-support'] = 'yes';
|
||||
return pot;
|
||||
},
|
||||
type: 'wp-plugin'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
@@ -1,181 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This registers the settings field and adds empty array to the options table
|
||||
*/
|
||||
add_action('admin_init', 'register_ss_settings');
|
||||
function register_ss_settings() {
|
||||
register_setting(SS_SETTINGS_FIELD, SS_SETTINGS_FIELD);
|
||||
add_option(SS_SETTINGS_FIELD, '__return_empty_array', '', 'yes');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function adds our "Simple Sidebars" submenu item
|
||||
*/
|
||||
add_action('admin_menu', 'ss_settings_init', 15);
|
||||
function ss_settings_init() {
|
||||
|
||||
add_submenu_page('genesis', __('Simple Sidebars','ss'), __('Simple Sidebars','ss'), 'manage_options', 'simple-sidebars', 'ss_settings_admin');
|
||||
|
||||
}
|
||||
|
||||
add_action('admin_init', 'ss_action_functions');
|
||||
function ss_action_functions() {
|
||||
|
||||
if ( !isset( $_REQUEST['page'] ) || $_REQUEST['page'] != 'simple-sidebars' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This section handles the data if a new sidebar is created
|
||||
*/
|
||||
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'create' ) {
|
||||
ss_create_sidebar( $_POST['new_sidebar'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* This section will handle the data if a sidebar is deleted
|
||||
*/
|
||||
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'delete' && isset( $_REQUEST['id'] ) ) {
|
||||
ss_delete_sidebar( $_REQUEST['id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* This section will handle the data if a sidebar is to be modified
|
||||
*/
|
||||
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' && !isset( $_REQUEST['id'] ) ) {
|
||||
ss_edit_sidebar( $_POST['edit_sidebar'] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is what actually gets output to the page.
|
||||
* It handles the markup, builds the form, etc.
|
||||
*/
|
||||
function ss_settings_admin() { ?>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<?php
|
||||
if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'edit' ) :
|
||||
|
||||
$_sidebars = get_option( SS_SETTINGS_FIELD );
|
||||
|
||||
if ( array_key_exists( $_REQUEST['id'], (array)$_sidebars ) ) {
|
||||
$_sidebar = stripslashes_deep( $_sidebars[$_REQUEST['id']] );
|
||||
} else {
|
||||
wp_die( __('Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'ss') );
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php screen_icon('themes'); ?>
|
||||
<h2><?php _e('Edit Sidebar', 'ss'); ?></h2>
|
||||
|
||||
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=edit' ); ?>">
|
||||
<?php wp_nonce_field('simple-sidebars-action_edit-sidebar'); ?>
|
||||
<table class="form-table">
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e('Name', 'ss'); ?></label></th>
|
||||
<td><input name="edit_sidebar[name]" id="edit_sidebar[name]" type="text" value="<?php echo esc_html( $_sidebar['name'] ); ?>" size="40" />
|
||||
<p class="description"><?php _e('A recognizable name for your new sidebar widget area', 'ss'); ?></p></td>
|
||||
</tr>
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e('ID', 'ss'); ?></label></th>
|
||||
<td>
|
||||
<input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" disabled="disabled" />
|
||||
<input name="edit_sidebar[id]" id="edit_sidebar[id]" type="hidden" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" />
|
||||
<p class="description"><?php _e('The unique ID is used to register the sidebar widget area (cannot be changed)', 'ss'); ?></p></td>
|
||||
</tr>
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e('Description', 'ss'); ?></label></th>
|
||||
<td><textarea name="edit_sidebar[description]" id="edit_sidebar[description]" rows="3" cols="50" style="width: 97%;"><?php echo esc_html( $_sidebar['description'] ); ?></textarea></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e('Update', 'ee'); ?>" /></p>
|
||||
|
||||
</form>
|
||||
|
||||
<?php else : ?>
|
||||
|
||||
<?php screen_icon('themes'); ?>
|
||||
<h2><?php _e('Genesis - Simple Sidebars', 'ss'); ?></h2>
|
||||
|
||||
<div id="col-container">
|
||||
|
||||
<div id="col-right">
|
||||
<div class="col-wrap">
|
||||
|
||||
<h3><?php _e('Current Sidebars', 'ss'); ?></h3>
|
||||
<table class="widefat tag fixed" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" id="name" class="manage-column column-name"><?php _e('Name', 'ss'); ?></th>
|
||||
<th scope="col" class="manage-column column-slug"><?php _e('ID', 'ss'); ?></th>
|
||||
<th scope="col" id="description" class="manage-column column-description"><?php _e('Description', 'ss'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column column-name"><?php _e('Name', 'ss'); ?></th>
|
||||
<th scope="col" class="manage-column column-slug"><?php _e('ID', 'ss'); ?></th>
|
||||
<th scope="col" class="manage-column column-description"><?php _e('Description', 'ss'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-list" class="list:tag">
|
||||
|
||||
<?php ss_sidebar_table_rows(); ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div><!-- /col-right -->
|
||||
|
||||
<div id="col-left">
|
||||
<div class="col-wrap">
|
||||
|
||||
|
||||
<div class="form-wrap">
|
||||
<h3><?php _e('Add New Sidebar', 'ss'); ?></h3>
|
||||
|
||||
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=create' ); ?>">
|
||||
<?php wp_nonce_field('simple-sidebars-action_create-sidebar'); ?>
|
||||
|
||||
<div class="form-field form-required">
|
||||
<label for="sidebar-name"><?php _e('Name', 'ss'); ?></label>
|
||||
<input name="new_sidebar[name]" id="sidebar-name" type="text" value="" size="40" aria-required="true" />
|
||||
<p><?php _e('A recognizable name for your new sidebar widget area', 'ss'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="sidebar-id"><?php _e('ID', 'ss'); ?></label>
|
||||
<input name="new_sidebar[id]" id="sidebar-id" type="text" value="" size="40" />
|
||||
<p><?php _e('The unique ID is used to register the sidebar widget area', 'ss'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="sidebar-description"><?php _e('Description', 'ss'); ?></label>
|
||||
<textarea name="new_sidebar[description]" id="sidebar-description" rows="5" cols="40"></textarea>
|
||||
</div>
|
||||
|
||||
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php _e('Add New Sidebar', 'ss'); ?>" /></p>
|
||||
</form></div>
|
||||
|
||||
</div>
|
||||
</div><!-- /col-left -->
|
||||
|
||||
</div><!-- /col-container -->
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
</div><!-- /wrap -->
|
||||
|
||||
<?php
|
||||
}
|
||||
-181
@@ -1,181 +0,0 @@
|
||||
<?php
|
||||
function ss_sidebar_table_rows() {
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$_sidebars = $wp_registered_sidebars;
|
||||
|
||||
$alt = true;
|
||||
|
||||
foreach ( (array)$_sidebars as $id => $info ) { ?>
|
||||
|
||||
<?php
|
||||
$is_editable = isset( $info['editable'] ) && $info['editable'] ? true : false;
|
||||
?>
|
||||
|
||||
<tr <?php if ( $alt ) { echo 'class="alternate"'; $alt = false; } else { $alt = true; } ?>>
|
||||
<td class="name column-name">
|
||||
<?php
|
||||
if ( $is_editable ) {
|
||||
printf( '<a class="row-title" href="%s" title="Edit %s">%s</a>', admin_url('admin.php?page=simple-sidebars&action=edit&id=' . esc_html( $id ) ), esc_html( $info['name'] ), esc_html( $info['name'] ) );
|
||||
} else {
|
||||
printf( '<strong class="row-title">%s</strong>', esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( $is_editable ) : ?>
|
||||
<br />
|
||||
<div class="row-actions">
|
||||
<span class="edit"><a href="<?php echo admin_url('admin.php?page=simple-sidebars&action=edit&id=' . esc_html( $id ) ); ?>"><?php _e('Edit', 'ss'); ?></a> | </span>
|
||||
<span class="delete"><a class="delete-tag" href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=simple-sidebars&action=delete&id=' . esc_html( $id ) ), 'simple-sidebars-action_delete-sidebar' ); ?>"><?php _e('Delete', 'ss'); ?></a></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</td>
|
||||
<td class="slug column-slug"><?php echo esc_html( $id ); ?></td>
|
||||
<td class="description column-description"><?php echo esc_html( $info['description'] )?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function ss_create_sidebar( $args = array() ) {
|
||||
|
||||
if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
|
||||
wp_die( ss_error_message(1) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// nonce verification
|
||||
check_admin_referer('simple-sidebars-action_create-sidebar');
|
||||
|
||||
$db = (array)get_option(SS_SETTINGS_FIELD);
|
||||
$new = array(
|
||||
sanitize_title_with_dashes( $args['id'] ) => array(
|
||||
'name' => esc_html( $args['name'] ),
|
||||
'description' => esc_html( $args['description'] )
|
||||
)
|
||||
);
|
||||
|
||||
if ( array_key_exists( $args['id'], $db ) ) {
|
||||
wp_die( ss_error_message(2) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$_sidebars = wp_parse_args( $new, $db );
|
||||
|
||||
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
||||
wp_redirect( admin_url('admin.php?page=simple-sidebars&created=true') );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function ss_edit_sidebar( $args = array() ) {
|
||||
|
||||
if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
|
||||
wp_die( ss_error_message(3) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// nonce verification
|
||||
check_admin_referer('simple-sidebars-action_edit-sidebar');
|
||||
|
||||
$db = (array)get_option(SS_SETTINGS_FIELD);
|
||||
$new = array(
|
||||
sanitize_title_with_dashes( $args['id'] ) => array(
|
||||
'name' => esc_html( $args['name'] ),
|
||||
'description' => esc_html( $args['description'] )
|
||||
)
|
||||
);
|
||||
|
||||
if ( !array_key_exists( $args['id'], $db ) ) {
|
||||
wp_die( ss_error_message(3) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$_sidebars = wp_parse_args( $new, $db );
|
||||
|
||||
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
||||
wp_redirect( admin_url('admin.php?page=simple-sidebars&edited=true') );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function ss_delete_sidebar( $id = '' ) {
|
||||
|
||||
if ( empty( $id ) ) {
|
||||
wp_die( ss_error_message(4) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// nonce verification
|
||||
check_admin_referer('simple-sidebars-action_delete-sidebar');
|
||||
|
||||
$_sidebars = (array)get_option( SS_SETTINGS_FIELD );
|
||||
|
||||
if ( !isset( $_sidebars[$id] ) ) {
|
||||
wp_die( ss_error_message(4) );
|
||||
exit;
|
||||
}
|
||||
|
||||
unset( $_sidebars[$id] );
|
||||
|
||||
update_option( SS_SETTINGS_FIELD, $_sidebars );
|
||||
wp_redirect( admin_url('admin.php?page=simple-sidebars&deleted=true') );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
function ss_error_message( $error = false ) {
|
||||
|
||||
if ( !$error ) return false;
|
||||
|
||||
switch( (int)$error ) {
|
||||
|
||||
case 1:
|
||||
return __('Oops! Please choose a valid Name and ID for this sidebar', 'ss');
|
||||
break;
|
||||
case 2:
|
||||
return __('Oops! That sidebar ID already exists');
|
||||
break;
|
||||
case 3:
|
||||
return __('Oops! You are trying to edit a sidebar that does not exist, or is not editable', 'ss');
|
||||
break;
|
||||
case 4:
|
||||
return __('Oops! You are trying to delete a sidebar that does not exist, or cannot be deleted', 'ss');
|
||||
break;
|
||||
default:
|
||||
return __('Oops! Something went wrong. Try again.', 'ss');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
add_action('admin_notices', 'ss_success_message');
|
||||
function ss_success_message() {
|
||||
|
||||
if ( !isset( $_REQUEST['page'] ) || $_REQUEST['page'] != 'simple-sidebars' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$format = '<div id="message" class="updated"><p><strong>%s</strong></p></div>';
|
||||
|
||||
if ( isset( $_REQUEST['created'] ) && $_REQUEST['created'] === 'true' ) {
|
||||
printf( $format, __('New sidebar successfully created!', 'ss') );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['edited'] ) && $_REQUEST['edited'] === 'true' ) {
|
||||
printf( $format, __('Sidebar successfully edited!', 'ss') );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['deleted'] ) && $_REQUEST['deleted'] === 'true' ) {
|
||||
printf( $format, __('Sidebar successfully deleted.', 'ss') );
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
class Genesis_Simple_Sidebars {
|
||||
|
||||
/**
|
||||
* Plugin version
|
||||
*/
|
||||
public $plugin_version = '2.1.0';
|
||||
|
||||
/**
|
||||
* Minimum WordPress version.
|
||||
*/
|
||||
public $min_wp_version = '4.7.2';
|
||||
|
||||
/**
|
||||
* Minimum Genesis version.
|
||||
*/
|
||||
public $min_genesis_version = '2.4.2';
|
||||
|
||||
/**
|
||||
* The plugin textdomain, for translations.
|
||||
*/
|
||||
public $plugin_textdomain = 'genesis-simple-sidebars';
|
||||
|
||||
/**
|
||||
* The url to the plugin directory.
|
||||
*/
|
||||
public $plugin_dir_url;
|
||||
|
||||
/**
|
||||
* The path to the plugin directory.
|
||||
*/
|
||||
public $plugin_dir_path;
|
||||
|
||||
/**
|
||||
* The main settings field for this plugin.
|
||||
*/
|
||||
public $settings_field = 'ss-settings';
|
||||
|
||||
/**
|
||||
* Core functions of sidebar registration and output.
|
||||
*/
|
||||
public $core;
|
||||
|
||||
/**
|
||||
* Admin menu and settings page.
|
||||
*/
|
||||
public $admin;
|
||||
|
||||
/**
|
||||
* Entry settings and metadata.
|
||||
*/
|
||||
public $entry;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->plugin_dir_url = plugin_dir_url( __FILE__ );
|
||||
$this->plugin_dir_path = plugin_dir_path( __FILE__ );
|
||||
|
||||
// For backward compatibility
|
||||
define( 'SS_PLUGIN_DIR', $this->plugin_dir_path );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
register_activation_hook( __FILE__, array( $this, 'activation' ) );
|
||||
|
||||
$this->load_plugin_textdomain();
|
||||
$this->includes();
|
||||
$this->instantiate();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin activation hook. Runs when plugin is activated.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function activation() {
|
||||
|
||||
if ( ! defined( 'PARENT_THEME_VERSION' ) || ! version_compare( PARENT_THEME_VERSION, $this->min_genesis_version, '>=' ) ) {
|
||||
|
||||
deactivate_plugins( plugin_basename( __FILE__ ) );
|
||||
wp_die( sprintf( __( 'Sorry, you cannot run Genesis Simple Sidebars without WordPress %s and <a href="%s">Genesis %s</a>, or greater.', 'genesis-simple-sidebars' ), $this->min_wp_version, 'http://my.studiopress.com/?download_id=91046d629e74d525b3f2978e404e7ffa', $this->min_genesis_version ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the plugin textdomain, for translation.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function load_plugin_textdomain() {
|
||||
load_plugin_textdomain( $this->plugin_textdomain, false, $this->plugin_dir_path . 'languages/' );
|
||||
}
|
||||
|
||||
/**
|
||||
* All general includes.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function includes() {
|
||||
|
||||
//require_once( $this->plugin_dir_path . 'includes/functions.php' );
|
||||
//require_once( $this->plugin_dir_path . 'includes/deprecated.php' );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Include the class file, instantiate the classes, create objects.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function instantiate() {
|
||||
|
||||
add_action( 'genesis_setup', array( $this, 'genesis_dependencies' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and instantiate any Genesis dependencies.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function genesis_dependencies() {
|
||||
|
||||
require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-core.php' );
|
||||
$this->core = new Genesis_Simple_Sidebars_Core;
|
||||
$this->core->init();
|
||||
|
||||
// Anything beyond this point should only be loaded if in the admin.
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-entry.php' );
|
||||
$this->entry = new Genesis_Simple_Sidebars_Entry;
|
||||
$this->entry->init();
|
||||
|
||||
require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-term.php' );
|
||||
$this->term = new Genesis_Simple_Sidebars_Term;
|
||||
$this->term->init();
|
||||
|
||||
require_once( $this->plugin_dir_path . 'includes/class-genesis-simple-sidebars-admin.php' );
|
||||
$this->admin = new Genesis_Simple_Sidebars_Admin;
|
||||
$this->admin->admin_menu();
|
||||
|
||||
// For backward compatibility
|
||||
global $_genesis_simple_sidebars;
|
||||
$_genesis_simple_sidebars = $this->admin;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to retrieve the static object without using globals.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
function Genesis_Simple_Sidebars() {
|
||||
|
||||
static $object;
|
||||
|
||||
if ( null == $object ) {
|
||||
$object = new Genesis_Simple_Sidebars;
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
/**
|
||||
* Initialize the object on `plugins_loaded`.
|
||||
*/
|
||||
add_action( 'plugins_loaded', array( Genesis_Simple_Sidebars(), 'init' ) );
|
||||
@@ -0,0 +1,357 @@
|
||||
<?php
|
||||
/**
|
||||
* Controls the creation, deletion, and editing of Simple Sidebar.
|
||||
*
|
||||
* @author StudioPress
|
||||
*/
|
||||
|
||||
/**
|
||||
* Registers a new admin page, providing content and corresponding menu item
|
||||
* for the Genesis Simple Sidebars plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
class Genesis_Simple_Sidebars_Admin extends Genesis_Admin_Basic {
|
||||
|
||||
/**
|
||||
* Settings field.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public $settings_field;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->settings_field = Genesis_Simple_Sidebars()->settings_field;
|
||||
|
||||
// For backward compatibility
|
||||
define( 'SS_SETTINGS_FIELD', $this->settings_field );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an admin menu item and settings page.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @uses Genesis_Admin::create() Register the admin page
|
||||
*
|
||||
* @see Genesis_Admin_Import_Export::actions() Handle creating, editing, and deleting sidebars.
|
||||
*/
|
||||
public function admin_menu() {
|
||||
|
||||
$page_id = 'simple-sidebars';
|
||||
|
||||
$menu_ops = array(
|
||||
'submenu' => array(
|
||||
'parent_slug' => 'genesis',
|
||||
'page_title' => __( 'Genesis - Simple Sidebars', 'genesis-simple-sidebars' ),
|
||||
'menu_title' => __( 'Simple Sidebars', 'genesis-simple-sidebars' )
|
||||
)
|
||||
);
|
||||
|
||||
// Empty, as we'll be building the page manually
|
||||
$page_ops = array();
|
||||
|
||||
$this->create( $page_id, $menu_ops, $page_ops, $this->settings_field );
|
||||
|
||||
// Simpe Sidebar actions (create, edit, or delete)
|
||||
add_action( 'admin_init', array( $this, 'actions' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for displaying the Simple Sidebars admin page.
|
||||
*
|
||||
* Echoes out HTML.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
*/
|
||||
public function admin() {
|
||||
|
||||
echo '<div class="wrap">';
|
||||
|
||||
if ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] ) {
|
||||
require_once( Genesis_Simple_Sidebars()->plugin_dir_path . '/includes/views/admin-edit.php' );
|
||||
}
|
||||
else {
|
||||
require_once( Genesis_Simple_Sidebars()->plugin_dir_path . '/includes/views/admin-main.php' );
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display sidebar table rows.
|
||||
*
|
||||
* Displays table rows of sidebars for viewing and editing on the main admin page.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
*/
|
||||
public function table_rows() {
|
||||
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
$_sidebars = $wp_registered_sidebars;
|
||||
|
||||
$alt = true;
|
||||
|
||||
foreach ( (array) $_sidebars as $id => $info ) :
|
||||
|
||||
$is_editable = isset( $info['editable'] ) && $info['editable'] ? true : false;
|
||||
|
||||
?>
|
||||
|
||||
<tr <?php if ( $alt ) { echo 'class="alternate"'; $alt = false; } else { $alt = true; } ?>>
|
||||
<td class="name column-name">
|
||||
<?php
|
||||
if ( $is_editable ) {
|
||||
printf( '<a class="row-title" href="%s" title="Edit %s">%s</a>', admin_url('admin.php?page=simple-sidebars&action=edit&id=' . esc_html( $id ) ), esc_html( $info['name'] ), esc_html( $info['name'] ) );
|
||||
} else {
|
||||
printf( '<strong class="row-title">%s</strong>', esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ( $is_editable ) : ?>
|
||||
<br />
|
||||
<div class="row-actions">
|
||||
<span class="edit"><a href="<?php echo admin_url('admin.php?page=simple-sidebars&action=edit&id=' . esc_html( $id ) ); ?>"><?php _e('Edit', 'genesis-simple-sidebars'); ?></a> | </span>
|
||||
<span class="delete"><a class="delete-tag" href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=simple-sidebars&action=delete&id=' . esc_html( $id ) ), 'simple-sidebars-action_delete-sidebar' ); ?>"><?php _e('Delete', 'genesis-simple-sidebars'); ?></a></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
</td>
|
||||
<td class="slug column-slug"><?php echo esc_html( $id ); ?></td>
|
||||
<td class="description column-description"><?php echo esc_html( $info['description'] )?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
endforeach;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler.
|
||||
*
|
||||
* Depending on what action was intended by the user, this method calls the appropriate action method.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
*/
|
||||
public function actions() {
|
||||
|
||||
if ( ! genesis_is_menu_page( 'simple-sidebars' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This section handles the data if a new sidebar is created
|
||||
*/
|
||||
if ( isset( $_REQUEST['action'] ) && 'create' == $_REQUEST['action'] ) {
|
||||
$this->create_sidebar( $_POST['new_sidebar'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* This section will handle the data if a sidebar is deleted
|
||||
*/
|
||||
if ( isset( $_REQUEST['action'] ) && 'delete' == $_REQUEST['action'] && isset( $_REQUEST['id'] ) ) {
|
||||
$this->delete_sidebar( $_REQUEST['id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* This section will handle the data if a sidebar is to be modified
|
||||
*/
|
||||
if ( isset( $_REQUEST['action'] ) && 'edit' == $_REQUEST['action'] && ! isset( $_REQUEST['id'] ) ) {
|
||||
$this->edit_sidebar( $_POST['edit_sidebar'] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add custom notices that display when you successfully create, edit, or delete a sidebar.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return null Returns null if not on the correct admin page.
|
||||
*/
|
||||
public function notices() {
|
||||
|
||||
if ( ! genesis_is_menu_page( 'simple-sidebars' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$pattern = '<div id="message" class="updated"><p><strong>%s</strong></p></div>';
|
||||
|
||||
if ( isset( $_REQUEST['created'] ) && 'true' === $_REQUEST['created'] ) {
|
||||
printf( $pattern, __( 'New sidebar successfully created!', 'genesis-simple-sidebars' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['edited'] ) && 'true' === $_REQUEST['edited'] ) {
|
||||
printf( $pattern, __( 'Sidebar successfully edited!', 'genesis-simple-sidebars' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['deleted'] ) && 'true' === $_REQUEST['deleted'] ) {
|
||||
printf( $pattern, __( 'Sidebar successfully deleted.', 'genesis-simple-sidebars' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a sidebar.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
*/
|
||||
protected function create_sidebar( $args = array() ) {
|
||||
|
||||
if ( empty( $args['name'] ) ) {
|
||||
wp_die( $this->error( 1 ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// nonce verification
|
||||
check_admin_referer( 'simple-sidebars-action_create-sidebar' );
|
||||
|
||||
// Change empty or numeric IDs to the name, lowercased and separated by dashes.
|
||||
if ( empty( $args['id'] ) || is_numeric( $args['id'] ) ) {
|
||||
$args['id'] = $args['name'];
|
||||
}
|
||||
|
||||
// Strip all but alphanumeric, sanitize with dashes.
|
||||
$id = preg_replace( "/[^a-zA-Z0-9 -]+/", "", sanitize_title_with_dashes( $args['id'] ) );
|
||||
|
||||
$db = (array) get_option( $this->settings_field );
|
||||
|
||||
$new = array(
|
||||
$id => array(
|
||||
'name' => esc_html( $args['name'] ),
|
||||
'description' => esc_html( $args['description'] )
|
||||
),
|
||||
);
|
||||
|
||||
if ( array_key_exists( $id, $db ) ) {
|
||||
wp_die( $this->error( 2 ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$_sidebars = wp_parse_args( $new, $db );
|
||||
|
||||
update_option( $this->settings_field, $_sidebars );
|
||||
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&created=true' ) );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a sidebar.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
*/
|
||||
protected function edit_sidebar( $args = array() ) {
|
||||
|
||||
if ( empty( $args['name'] ) || empty( $args['id'] ) ) {
|
||||
wp_die( $this->error( 3 ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// nonce verification
|
||||
check_admin_referer( 'simple-sidebars-action_edit-sidebar' );
|
||||
|
||||
$db = (array) get_option( $this->settings_field );
|
||||
$new = array(
|
||||
$args['id'] => array(
|
||||
'name' => esc_html( $args['name'] ),
|
||||
'description' => esc_html( $args['description'] )
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! array_key_exists( $args['id'], $db ) ) {
|
||||
wp_die( $this->error( 3 ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$_sidebars = wp_parse_args( $new, $db );
|
||||
|
||||
update_option( $this->settings_field, $_sidebars );
|
||||
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&edited=true' ) );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a sidebar.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
*/
|
||||
protected function delete_sidebar( $id = '' ) {
|
||||
|
||||
if ( empty( $id ) ) {
|
||||
wp_die( $this->error( 4 ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// nonce verification
|
||||
check_admin_referer( 'simple-sidebars-action_delete-sidebar' );
|
||||
|
||||
$_sidebars = (array) get_option( $this->settings_field );
|
||||
|
||||
if ( ! isset( $_sidebars[$id] ) ) {
|
||||
wp_die( $this->error( 4 ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
unset( $_sidebars[$id] );
|
||||
|
||||
update_option( $this->settings_field, $_sidebars );
|
||||
wp_redirect( admin_url( 'admin.php?page=simple-sidebars&deleted=true' ) );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an error message by ID.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @return string Returns an error string based on an error ID.
|
||||
*/
|
||||
protected function error( $error = false ) {
|
||||
|
||||
if ( ! $error )
|
||||
return false;
|
||||
|
||||
switch( (int) $error ) {
|
||||
|
||||
case 1:
|
||||
return __( 'Oops! Please choose a valid Name for this sidebar', 'genesis-simple-sidebars' );
|
||||
break;
|
||||
case 2:
|
||||
return __( 'Oops! That sidebar ID already exists', 'genesis-simple-sidebars' );
|
||||
break;
|
||||
case 3:
|
||||
return __( 'Oops! You are trying to edit a sidebar that does not exist, or is not editable', 'genesis-simple-sidebars' );
|
||||
break;
|
||||
case 4:
|
||||
return __( 'Oops! You are trying to delete a sidebar that does not exist, or cannot be deleted', 'genesis-simple-sidebars' );
|
||||
break;
|
||||
default:
|
||||
return __( 'Oops! Something went wrong. Try again.', 'genesis-simple-sidebars' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Controls the core functions of registration and output of Sidebars
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
class Genesis_Simple_Sidebars_Core {
|
||||
|
||||
/**
|
||||
* The created sidebars.
|
||||
*/
|
||||
private $sidebars;
|
||||
|
||||
/**
|
||||
* Public taxonomies.
|
||||
*/
|
||||
private $public_taxonomies;
|
||||
|
||||
/**
|
||||
* Initialize the class.
|
||||
*/
|
||||
public function init() {
|
||||
|
||||
add_action( 'widgets_init', array( $this, 'register_sidebars' ) );
|
||||
add_action( 'get_header', array( $this, 'swap_sidebars' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Take created sidebars and register them with WordPress.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function register_sidebars() {
|
||||
|
||||
$sidebars = Genesis_Simple_Sidebars()->core->get_sidebars();
|
||||
|
||||
if ( ! $sidebars ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Cycle through created sidebars, register them as widget areas
|
||||
foreach ( (array) $sidebars as $id => $info ) {
|
||||
|
||||
if ( ! isset( $info['name'] ) || ! isset( $info['description'] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
genesis_register_sidebar( array(
|
||||
'name' => esc_html( $info['name'] ),
|
||||
'id' => $id,
|
||||
'description' => esc_html( $info['description'] ),
|
||||
'editable' => 1,
|
||||
) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove default sidebars and inject custom sidebars.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function swap_sidebars() {
|
||||
|
||||
// Header
|
||||
if ( is_registered_sidebar( 'header-right' ) ) {
|
||||
global $wp_registered_sidebars;
|
||||
$wp_registered_sidebars['ss-header-right-temp'] = $wp_registered_sidebars['header-right'];
|
||||
unset( $wp_registered_sidebars['header-right'] );
|
||||
add_action( 'genesis_header_right', array( $this, 'do_header_right' ) );
|
||||
}
|
||||
|
||||
// Sidebars
|
||||
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
|
||||
remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
|
||||
add_action( 'genesis_sidebar', array( $this, 'do_primary_sidebar' ) );
|
||||
add_action( 'genesis_sidebar_alt', array( $this, 'do_secondary_sidebar' ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Output custom header widget area, if one is set. Otherwise output default.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function do_header_right() {
|
||||
|
||||
global $wp_registered_sidebars;
|
||||
|
||||
if ( ! $this->do_sidebar( '_ss_header' ) ) {
|
||||
$wp_registered_sidebars['header-right'] = $wp_registered_sidebars['ss-header-right-temp'];
|
||||
}
|
||||
|
||||
unset( $wp_registered_sidebars['ss-header-right-temp'] );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Output custom primary sidebar, if one is set. Otherwise output default.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function do_primary_sidebar() {
|
||||
|
||||
if ( ! $this->do_sidebar( '_ss_sidebar' ) ) {
|
||||
genesis_do_sidebar();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Output custom secondary sidebar, if one is set. Otherwise output default.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function do_secondary_sidebar() {
|
||||
|
||||
if ( ! $this->do_sidebar( '_ss_sidebar_alt' ) ) {
|
||||
genesis_do_sidebar_alt();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show widgets in a particular sidebar.
|
||||
*
|
||||
* @param string $key sidebar id you wish to output.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function do_sidebar( $key ) {
|
||||
|
||||
if ( is_singular() && $key = genesis_get_custom_field( $key ) ) {
|
||||
|
||||
if ( dynamic_sidebar( $key ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( is_tax() || is_category() || is_tag() ) {
|
||||
|
||||
if ( $key = get_term_meta( get_queried_object()->term_id, $key, true ) ) {
|
||||
dynamic_sidebar( $key );
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all custom registered sidebars.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function get_sidebars( $cache = true ) {
|
||||
|
||||
if ( ! $cache ) {
|
||||
return stripslashes_deep( get_option( Genesis_Simple_Sidebars()->settings_field ) );
|
||||
}
|
||||
|
||||
if ( is_null( $this->sidebars ) ) {
|
||||
$this->sidebars = stripslashes_deep( get_option( Genesis_Simple_Sidebars()->settings_field ) );
|
||||
}
|
||||
|
||||
return $this->sidebars;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return taxonomy ids.
|
||||
*
|
||||
* Helper function to return the array keys from a taxonomy query.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function get_public_taxonomies() {
|
||||
|
||||
if ( is_null( $this->public_taxonomies ) ) {
|
||||
$this->public_taxonomies = get_taxonomies( array(
|
||||
'show_ui' => true,
|
||||
'public' => true,
|
||||
) );
|
||||
}
|
||||
|
||||
$this->public_taxonomies = apply_filters( 'genesis_simple_sidebars_taxonomies', array_keys( $this->public_taxonomies ) );
|
||||
|
||||
return $this->public_taxonomies;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this site has disabled 3 column layouts or not.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function has_3_column_layout() {
|
||||
|
||||
$layouts = genesis_get_layouts();
|
||||
|
||||
$three_column_layouts = array(
|
||||
'content-sidebar-sidebar',
|
||||
'sidebar-content-sidebar',
|
||||
'sidebar-sidebar-content',
|
||||
);
|
||||
|
||||
foreach ( $three_column_layouts as $layout ) {
|
||||
if ( array_key_exists( $layout, $layouts ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
class Genesis_Simple_Sidebars_Entry {
|
||||
|
||||
public function init() {
|
||||
|
||||
add_action( 'admin_menu', array( $this, 'add_metaboxes' ) );
|
||||
add_action( 'save_post', array( $this, 'metabox_save' ), 1, 2 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Cycle through supported post types and add metaboxes.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function add_metaboxes() {
|
||||
|
||||
foreach ( (array) get_post_types( array( 'public' => true ) ) as $type ) {
|
||||
|
||||
if ( post_type_supports( $type, 'genesis-simple-sidebars' ) || $type == 'post' || $type == 'page' ) {
|
||||
add_meta_box( 'ss_inpost_metabox', __( 'Sidebar Selection', 'genesis-simple-sidebars' ), array( $this, 'metabox_content' ), $type, 'side', 'low' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Include the metabox content.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function metabox_content() {
|
||||
|
||||
require_once( Genesis_Simple_Sidebars()->plugin_dir_path . 'includes/views/entry-metabox-content.php' );
|
||||
|
||||
print_r( get_post_meta( get_the_ID() ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the metabox fields when the entry is saved.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
public function metabox_save( $post_id, $post ) {
|
||||
|
||||
if ( ! isset( $_POST['genesis_simple_sidebars'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = wp_parse_args( $_POST['genesis_simple_sidebars'], array(
|
||||
'_ss_header' => '',
|
||||
'_ss_sidebar' => '',
|
||||
'_ss_sidebar_alt' => '',
|
||||
) );
|
||||
|
||||
genesis_save_custom_fields( $data, 'genesis-simple-sidebars-save-entry', 'genesis-simple-sidebars-save-entry-nonce', $post );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class Genesis_Simple_Sidebars_Term {
|
||||
|
||||
public function init() {
|
||||
|
||||
add_action( 'init', array( $this, 'add_term_fields' ) );
|
||||
|
||||
}
|
||||
|
||||
public function add_term_fields() {
|
||||
|
||||
$taxonomies = Genesis_Simple_Sidebars()->core->get_public_taxonomies();
|
||||
|
||||
if ( ! empty( $taxonomies ) && is_admin() && is_array( $taxonomies ) ) {
|
||||
|
||||
foreach ( $taxonomies as $tax ) {
|
||||
add_action( "{$tax}_edit_form", array( $this, 'term_sidebar_form' ), 9, 2 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function term_sidebar_form( $tag, $taxonomy ) {
|
||||
|
||||
require_once( Genesis_Simple_Sidebars()->plugin_dir_path . 'includes/views/term-edit-sidebar-form.php' );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_activation_check() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_deactivate() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_genesis_init() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_register_sidebars() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_sidebars_init() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_do_sidebar() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_do_sidebar_alt() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_do_one_sidebar() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_get_taxonomies() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.2
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_has_3_column_layouts() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function simplesidebars_settings_menu() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_add_inpost_metabox() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_inpost_metabox() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_inpost_metabox_save() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_term_edit_init() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
*
|
||||
* @since 0.9.0
|
||||
* @deprecated 2.1.0
|
||||
*/
|
||||
function ss_term_sidebar() {
|
||||
_deprecated_function( __FUNCTION__, '2.1.0' );
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
$sidebars = Genesis_Simple_Sidebars()->core->get_sidebars();
|
||||
|
||||
if ( array_key_exists( $_REQUEST['id'], (array) $sidebars ) ) {
|
||||
$sidebar = stripslashes_deep( $sidebars[ $_REQUEST['id'] ] );
|
||||
} else {
|
||||
wp_die( __( 'Nice try, partner. But that sidebar doesn\'t exist. Click back and try again.', 'genesis-simple-sidebars' ) );
|
||||
}
|
||||
?>
|
||||
<h1><?php _e( 'Edit Sidebar', 'genesis-simple-sidebars' ); ?></h1>
|
||||
|
||||
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=edit' ); ?>">
|
||||
<?php wp_nonce_field( 'simple-sidebars-action_edit-sidebar' ); ?>
|
||||
|
||||
<table class="form-table">
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="edit_sidebar[name]"><?php _e( 'Name', 'genesis-simple-sidebars' ); ?></label></th>
|
||||
<td><input name="edit_sidebar[name]" id="edit_sidebar[name]" type="text" value="<?php echo esc_html( $sidebar['name'] ); ?>" size="40" />
|
||||
<p class="description"><?php _e( 'A recognizable name for your new sidebar widget area', 'genesis-simple-sidebars' ); ?></p></td>
|
||||
</tr>
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="edit_sidebar[id]"><?php _e( 'ID', 'genesis-simple-sidebars' ); ?></label></th>
|
||||
<td>
|
||||
<input type="text" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" readonly />
|
||||
<input name="edit_sidebar[id]" id="edit_sidebar[id]" type="hidden" value="<?php echo esc_html( $_REQUEST['id'] ); ?>" size="40" />
|
||||
<p class="description"><?php _e( 'The unique ID is used to register the sidebar widget area (cannot be changed)', 'genesis-simple-sidebars' ); ?></p></td>
|
||||
</tr>
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="edit_sidebar[description]"><?php _e( 'Description', 'genesis-simple-sidebars' ); ?></label></th>
|
||||
<td><textarea name="edit_sidebar[description]" id="edit_sidebar[description]" rows="3" cols="50" style="width: 97%;"><?php echo esc_html( $sidebar['description'] ); ?></textarea></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php _e( 'Update', 'genesis-simple-sidebars' ); ?>" /></p>
|
||||
|
||||
</form>
|
||||
@@ -0,0 +1,69 @@
|
||||
<h1><?php _e( 'Genesis - Simple Sidebars', 'genesis-simple-sidebars' ); ?></h1>
|
||||
|
||||
<div id="col-container">
|
||||
|
||||
<div id="col-right">
|
||||
<div class="col-wrap">
|
||||
|
||||
<h3><?php _e( 'Current Sidebars', 'genesis-simple-sidebars' ); ?></h3>
|
||||
<table class="widefat tag fixed" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" id="name" class="manage-column column-name"><?php _e( 'Name', 'genesis-simple-sidebars' ); ?></th>
|
||||
<th scope="col" class="manage-column column-slug"><?php _e( 'ID', 'genesis-simple-sidebars' ); ?></th>
|
||||
<th scope="col" id="description" class="manage-column column-description"><?php _e( 'Description', 'genesis-simple-sidebars' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="col" class="manage-column column-name"><?php _e( 'Name', 'genesis-simple-sidebars' ); ?></th>
|
||||
<th scope="col" class="manage-column column-slug"><?php _e( 'ID', 'genesis-simple-sidebars' ); ?></th>
|
||||
<th scope="col" class="manage-column column-description"><?php _e( 'Description', 'genesis-simple-sidebars' ); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
<tbody id="the-list" class="list:tag">
|
||||
|
||||
<?php $this->table_rows(); ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div><!-- /col-right -->
|
||||
|
||||
<div id="col-left">
|
||||
<div class="col-wrap">
|
||||
|
||||
|
||||
<div class="form-wrap">
|
||||
<h3><?php _e( 'Add New Sidebar', 'genesis-simple-sidebars' ); ?></h3>
|
||||
|
||||
<form method="post" action="<?php echo admin_url( 'admin.php?page=simple-sidebars&action=create' ); ?>">
|
||||
<?php wp_nonce_field( 'simple-sidebars-action_create-sidebar' ); ?>
|
||||
|
||||
<div class="form-field form-required">
|
||||
<label for="sidebar-name"><?php _e( 'Name', 'genesis-simple-sidebars' ); ?></label>
|
||||
<input name="new_sidebar[name]" id="sidebar-name" type="text" value="" size="40" aria-required="true" />
|
||||
<p><?php _e( 'A recognizable name for your new sidebar widget area', 'genesis-simple-sidebars' ); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="sidebar-id"><?php _e( 'ID', 'genesis-simple-sidebars' ); ?></label>
|
||||
<input name="new_sidebar[id]" id="sidebar-id" type="text" value="" size="40" />
|
||||
<p><?php _e( 'The unique ID is used to register the sidebar widget area', 'genesis-simple-sidebars' ); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="form-field">
|
||||
<label for="sidebar-description"><?php _e( 'Description', 'genesis-simple-sidebars' ); ?></label>
|
||||
<textarea name="new_sidebar[description]" id="sidebar-description" rows="5" cols="40"></textarea>
|
||||
</div>
|
||||
|
||||
<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php _e( 'Add New Sidebar', 'genesis-simple-sidebars' ); ?>" /></p>
|
||||
</form></div>
|
||||
|
||||
</div>
|
||||
</div><!-- /col-left -->
|
||||
|
||||
</div><!-- /col-container -->
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
$sidebars = Genesis_Simple_Sidebars()->core->get_sidebars();
|
||||
global $wp_registered_sidebars;
|
||||
wp_nonce_field( 'genesis-simple-sidebars-save-entry', 'genesis-simple-sidebars-save-entry-nonce' );
|
||||
|
||||
if ( is_registered_sidebar( 'header-right' ) ) : ?>
|
||||
<p>
|
||||
<label class="howto" for="genesis_simple_sidebars[_ss_header]"><span><?php echo esc_attr( $wp_registered_sidebars['header-right']['name'] ); ?><span></label>
|
||||
<select name="genesis_simple_sidebars[_ss_header]" id="genesis_simple_sidebars[_ss_header]" style="width: 99%">
|
||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||
<?php
|
||||
foreach ( (array) $sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_header' ), false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php endif;
|
||||
|
||||
if ( is_registered_sidebar( 'sidebar' ) ) : ?>
|
||||
<p>
|
||||
<label class="howto" for="genesis_simple_sidebars[_ss_sidebar]"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar']['name'] ); ?><span></label>
|
||||
<select name="genesis_simple_sidebars[_ss_sidebar]" id="genesis_simple_sidebars[_ss_sidebar]" style="width: 99%">
|
||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||
<?php
|
||||
foreach ( (array) $sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_sidebar' ), false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php endif;
|
||||
|
||||
if ( is_registered_sidebar( 'sidebar-alt' ) ) : ?>
|
||||
<p>
|
||||
<label class="howto" for="genesis_simple_sidebars[_ss_sidebar_alt]"><span><?php echo esc_attr( $wp_registered_sidebars['sidebar-alt']['name'] ); ?><span></label>
|
||||
<select name="genesis_simple_sidebars[_ss_sidebar_alt]" id="genesis_simple_sidebars[_ss_sidebar_alt]" style="width: 99%">
|
||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||
<?php
|
||||
foreach ( (array) $sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field( '_ss_sidebar_alt' ), false ), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php endif;
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php $sidebars = Genesis_Simple_Sidebars()->core->get_sidebars(); ?>
|
||||
|
||||
<h3><?php _e( 'Sidebar Options', 'genesis-simple-sidebars' ); ?></h3>
|
||||
<table class="form-table">
|
||||
|
||||
<?php if ( is_registered_sidebar( 'header-right' ) ) : ?>
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="genesis-meta[_ss_header]"><?php _e( 'Header Right', 'genesis-simple-sidebars' ); ?></label></th>
|
||||
<td>
|
||||
<select name="genesis-meta[_ss_header]" id="genesis-meta[_ss_header]" style="padding-right: 10px;">
|
||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||
<?php
|
||||
foreach ( (array) $sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_header', true ), false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar]"><?php _e( 'Primary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
|
||||
<td>
|
||||
<select name="genesis-meta[_ss_sidebar]" id="genesis-meta[_ss_sidebar]" style="padding-right: 10px;">
|
||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||
<?php
|
||||
foreach ( (array) $sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_sidebar', true ), false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php if ( Genesis_Simple_Sidebars()->core->has_3_column_layout() ) : ?>
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="genesis-meta[_ss_sidebar_alt]"><?php _e( 'Secondary Sidebar', 'genesis-simple-sidebars' ); ?></label></th>
|
||||
<td>
|
||||
<select name="genesis-meta[_ss_sidebar_alt]" id="genesis-meta[_ss_sidebar_alt]" style="padding-right: 10px;">
|
||||
<option value=""><?php _e( 'Default', 'genesis-simple-sidebars' ); ?></option>
|
||||
<?php
|
||||
foreach ( (array) $sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, get_term_meta( $tag->term_id, '_ss_sidebar_alt', true ) , false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
-84
@@ -1,84 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This bit of code registers the meta box on posts/pages,
|
||||
* so that users can choose what sidebar to use.
|
||||
*/
|
||||
add_action('admin_menu', 'ss_add_inpost_metabox');
|
||||
function ss_add_inpost_metabox() {
|
||||
add_meta_box('ss_inpost_metabox', __('Sidebar Selection', 'genesis'), 'ss_inpost_metabox', 'post', 'side', 'low');
|
||||
add_meta_box('ss_inpost_metabox', __('Sidebar Selection', 'genesis'), 'ss_inpost_metabox', 'page', 'side', 'low');
|
||||
}
|
||||
|
||||
function ss_inpost_metabox() {
|
||||
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
||||
?>
|
||||
|
||||
<input type="hidden" name="ss_inpost_nonce" value="<?php echo wp_create_nonce(plugin_basename(__FILE__)); ?>" />
|
||||
|
||||
<p>
|
||||
<label class="howto" for="_ss_sidebar"><span><?php _e('Primary Sidebar', 'ss'); ?><span></label>
|
||||
<select name="_ss_sidebar" id="_ss_sidebar" style="width: 99%">
|
||||
<option value=""><?php _e('Default', 'ss'); ?></option>
|
||||
<?php
|
||||
foreach ( (array)$_sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field('_ss_sidebar'), false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label class="howto" for="_ss_sidebar_alt"><span><?php _e('Secondary Sidebar', 'ss'); ?><span></label>
|
||||
<select name="_ss_sidebar_alt" id="_ss_sidebar_alt" style="width: 99%">
|
||||
<option value=""><?php _e('Default', 'ss'); ?></option>
|
||||
<?php
|
||||
foreach ( (array)$_sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, genesis_get_custom_field('_ss_sidebar_alt'), false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* This bit of code saves the sidebars chosen as post meta.
|
||||
*/
|
||||
add_action('save_post', 'ss_inpost_metabox_save', 1, 2);
|
||||
function ss_inpost_metabox_save( $post_id, $post ) {
|
||||
|
||||
// verify the nonce
|
||||
if ( !isset($_POST['ss_inpost_nonce']) || !wp_verify_nonce( $_POST['ss_inpost_nonce'], plugin_basename(__FILE__) ) )
|
||||
return $post->ID;
|
||||
|
||||
// don't try to save the data under autosave, ajax, or future post.
|
||||
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return;
|
||||
if ( defined('DOING_AJAX') && DOING_AJAX ) return;
|
||||
if ( defined('DOING_CRON') && DOING_CRON ) return;
|
||||
|
||||
// is the user allowed to edit the post or page?
|
||||
if ( ( 'page' == $_POST['post_type'] && !current_user_can('edit_page', $post->ID) ) || !current_user_can('edit_post', $post->ID ) )
|
||||
return $post->ID;
|
||||
|
||||
$_sidebars = array(
|
||||
'_ss_sidebar' => $_POST['_ss_sidebar'],
|
||||
'_ss_sidebar_alt' => $_POST['_ss_sidebar_alt']
|
||||
);
|
||||
|
||||
// store the custom fields
|
||||
foreach ( $_sidebars as $key => $value ) {
|
||||
|
||||
if ( $post->post_type == 'revision' ) return; // don't try to store data during revision save
|
||||
|
||||
if ( $value ) {
|
||||
// save/update
|
||||
update_post_meta($post->ID, $key, $value);
|
||||
} else {
|
||||
// delete if blank
|
||||
delete_post_meta($post->ID, $key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,226 @@
|
||||
# Copyright (C) 2011 Genesis Layout Extras by David Decker of deckerweb.de
|
||||
# This file is distributed under the same license as the Genesis Layout Extras package.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Genesis Simple Sidebars (Plugin)\n"
|
||||
"Report-Msgid-Bugs-To: http://wordpress.org/tags/genesis-simple-sidebars\n"
|
||||
"POT-Creation-Date: 2011-12-24 01:10+0100\n"
|
||||
"PO-Revision-Date: 2011-12-24 01:18+0100\n"
|
||||
"Last-Translator: David Decker <deckerweb.mobil@googlemail.com>\n"
|
||||
"Language-Team: DECKERWEB <deckerweb.mobil@googlemail.com>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Poedit-Language: German\n"
|
||||
"X-Poedit-Country: GERMANY\n"
|
||||
"X-Poedit-SourceCharset: utf-8\n"
|
||||
"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
|
||||
"X-Textdomain-Support: yes\n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:17
|
||||
msgid "Simple Sidebars"
|
||||
msgstr "Einfache Sidebars"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:66
|
||||
msgid "Nice try, partner. But that sidebar doesn't exist. Click back and try again."
|
||||
msgstr "Netter Versuch, doch leider existiert diese Sidebar nicht. Gehen Sie zurück und versuchen Sie es erneut."
|
||||
|
||||
#@ ss
|
||||
#: admin.php:72
|
||||
msgid "Edit Sidebar"
|
||||
msgstr "Sidebar bearbeiten"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:79
|
||||
#: admin.php:117
|
||||
#: admin.php:125
|
||||
#: admin.php:152
|
||||
msgid "Name"
|
||||
msgstr "Name"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:81
|
||||
#: admin.php:154
|
||||
msgid "A recognizable name for your new sidebar widget area"
|
||||
msgstr "Ein passender Name für Ihren neuen Sidebar-Widget-Bereich"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:85
|
||||
#: admin.php:118
|
||||
#: admin.php:126
|
||||
#: admin.php:158
|
||||
msgid "ID"
|
||||
msgstr "ID"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:89
|
||||
msgid "The unique ID is used to register the sidebar widget area (cannot be changed)"
|
||||
msgstr "Die einzigartige ID wird verwendet, um den Sidebar-Widget-Bereich zu registrieren. Diese ID kann nicht verändert werden. Verwenden Sie am besten nur kleinbuchstaben, Bindestriche (Minus) und Zahlen."
|
||||
|
||||
#@ ss
|
||||
#: admin.php:93
|
||||
#: admin.php:119
|
||||
#: admin.php:127
|
||||
#: admin.php:164
|
||||
msgid "Description"
|
||||
msgstr "Beschreibung"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:99
|
||||
msgid "Update"
|
||||
msgstr "Aktualisieren"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:106
|
||||
msgid "Genesis - Simple Sidebars"
|
||||
msgstr "Genesis - Einfache Sidebars"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:113
|
||||
msgid "Current Sidebars"
|
||||
msgstr "Aktuelle Sidebars"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:146
|
||||
#: admin.php:168
|
||||
msgid "Add New Sidebar"
|
||||
msgstr "Neue Sidebar hinzufügen"
|
||||
|
||||
#@ ss
|
||||
#: admin.php:160
|
||||
msgid "The unique ID is used to register the sidebar widget area"
|
||||
msgstr "Die einzigartige ID wird verwendet, um den neuen Sidebar-Widget-Bereich zu registrieren. Diese ID kann nicht verändert werden. Verwenden Sie am besten nur kleinbuchstaben, Bindestriche (Minus) und Zahlen."
|
||||
|
||||
#@ ss
|
||||
#: functions.php:28
|
||||
msgid "Edit"
|
||||
msgstr "Bearbeiten"
|
||||
|
||||
#@ ss
|
||||
#: functions.php:29
|
||||
msgid "Delete"
|
||||
msgstr "Löschen"
|
||||
|
||||
#@ ss
|
||||
#: functions.php:145
|
||||
msgid "Oops! Please choose a valid Name and ID for this sidebar"
|
||||
msgstr "Oops! Bitte wählen Sie einen gültigen Namen und eine gültige ID für diese Sidebar"
|
||||
|
||||
#@ ss
|
||||
#: functions.php:148
|
||||
msgid "Oops! That sidebar ID already exists"
|
||||
msgstr "Oops! Diese Sidebar-ID existiert bereits"
|
||||
|
||||
#@ ss
|
||||
#: functions.php:151
|
||||
msgid "Oops! You are trying to edit a sidebar that does not exist, or is not editable"
|
||||
msgstr "Oops! Sie versuchen eine Sidebar zu bearbeiten, die nicht existiert, oder nicht bearbeitet werden kann"
|
||||
|
||||
#@ ss
|
||||
#: functions.php:154
|
||||
msgid "Oops! You are trying to delete a sidebar that does not exist, or cannot be deleted"
|
||||
msgstr "Oops! Sie versuchen eine Sidebar zu löschen, die nicht existiert oder nicht gelöscht werden kann/ darf"
|
||||
|
||||
#@ ss
|
||||
#: functions.php:157
|
||||
msgid "Oops! Something went wrong. Try again."
|
||||
msgstr "Oops! Etwas ging schief. Bitte versuchen Sie es noch einmal."
|
||||
|
||||
#@ ss
|
||||
#: functions.php:173
|
||||
msgid "New sidebar successfully created!"
|
||||
msgstr "Neue Sidebar erfolgreich erstellt!"
|
||||
|
||||
#@ ss
|
||||
#: functions.php:178
|
||||
msgid "Sidebar successfully edited!"
|
||||
msgstr "Sidebar erfolgreich bearbeitet!"
|
||||
|
||||
#@ ss
|
||||
#: functions.php:183
|
||||
msgid "Sidebar successfully deleted."
|
||||
msgstr "Sidebar erfolgreich gelöscht."
|
||||
|
||||
#@ ss
|
||||
#: inpost.php:10
|
||||
msgid "Sidebar Selection"
|
||||
msgstr "Sidebar-Auswahl"
|
||||
|
||||
#@ ss
|
||||
#: inpost.php:22
|
||||
#: term.php:29
|
||||
msgid "Primary Sidebar"
|
||||
msgstr "Haupt-Sidebar (Primary)"
|
||||
|
||||
#@ ss
|
||||
#: inpost.php:24
|
||||
#: inpost.php:43
|
||||
#: term.php:32
|
||||
#: term.php:46
|
||||
msgid "Default"
|
||||
msgstr "Standard"
|
||||
|
||||
#@ ss
|
||||
#: inpost.php:41
|
||||
#: term.php:43
|
||||
msgid "Secondary Sidebar"
|
||||
msgstr "Zweit-Sidebar (Secondary)"
|
||||
|
||||
#@ ss
|
||||
#: plugin.php:24
|
||||
#, php-format
|
||||
msgid "Sorry, you can't activate unless you have installed <a href=\"%s\">Genesis</a>"
|
||||
msgstr "Hinweis: Dieses Plugin kann <em>nicht</em> aktiviert werden, solange das <a href=\"%s\">Genesis Framework</a> nicht installiert ist."
|
||||
|
||||
#@ ss
|
||||
#: plugin.php:29
|
||||
#, php-format
|
||||
msgid "Sorry, you cannot activate without <a href=\"%s\">Genesis %s</a> or greater"
|
||||
msgstr "Hinweis: Dieses Plugin kann <em>nicht</em> aktiviert werden, außer das <a href=\"%s\">Genesis Framework Version %s</a> oder höher ist installiert."
|
||||
|
||||
#@ ss
|
||||
#: term.php:25
|
||||
msgid "Sidebar Options"
|
||||
msgstr "Sidebar-Optionen"
|
||||
|
||||
#@ ss
|
||||
#. translators: plugin header field 'Name'
|
||||
#: plugin.php:0
|
||||
msgid "Genesis Simple Sidebars"
|
||||
msgstr "Genesis Einfache Sidebars"
|
||||
|
||||
#@ ss
|
||||
#. translators: plugin header field 'PluginURI'
|
||||
#: plugin.php:0
|
||||
msgid "http://www.studiopress.com/plugins/simple-sidebars"
|
||||
msgstr "http://www.studiopress.com/plugins/simple-sidebars"
|
||||
|
||||
#@ ss
|
||||
#. translators: plugin header field 'Description'
|
||||
#: plugin.php:0
|
||||
msgid "Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas."
|
||||
msgstr "Genesis Einfache Sidebars (Simple Sidebars) erlaubt es auf einfache Art und Weise neue Sidebar-Widget-Bereiche zu erstellen und zu verwenden."
|
||||
|
||||
#@ ss
|
||||
#. translators: plugin header field 'Author'
|
||||
#: plugin.php:0
|
||||
msgid "Nathan Rice"
|
||||
msgstr "Nathan Rice"
|
||||
|
||||
#@ ss
|
||||
#. translators: plugin header field 'AuthorURI'
|
||||
#: plugin.php:0
|
||||
msgid "http://www.nathanrice.net/"
|
||||
msgstr "http://www.nathanrice.net/"
|
||||
|
||||
#@ ss
|
||||
#. translators: plugin header field 'Version'
|
||||
#: plugin.php:0
|
||||
msgid "0.9.2"
|
||||
msgstr "0.9.2"
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
# Copyright (C) 2015 Nathan Rice
|
||||
# This file is distributed under the GNU General Public License v2.0 (or later).
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Genesis Simple Sidebars 2.0.2\n"
|
||||
"Report-Msgid-Bugs-To: StudioPress <translations@studiopress.com>\n"
|
||||
"POT-Creation-Date: 2015-09-29 20:53:32+00:00\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: StudioPress <translations@studiopress.com>\n"
|
||||
"Language-Team: English <translations@studiopress.com>\n"
|
||||
"X-Generator: grunt-wp-i18n 0.4.4\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Poedit-Basepath: .\n"
|
||||
"X-Poedit-Language: English\n"
|
||||
"X-Poedit-Country: UNITED STATES\n"
|
||||
"X-Poedit-SourceCharset: utf-8\n"
|
||||
"X-Poedit-KeywordsList: "
|
||||
"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
|
||||
"attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
|
||||
"X-Poedit-Bookmarks: \n"
|
||||
"X-Poedit-SearchPath-0: .\n"
|
||||
"X-Textdomain-Support: yes\n"
|
||||
|
||||
#: includes/admin.php:32 includes/views/main.php:2
|
||||
msgid "Genesis - Simple Sidebars"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:33
|
||||
msgid "Simple Sidebars"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:107
|
||||
msgid "Edit"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:108
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:173
|
||||
msgid "New sidebar successfully created!"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:178
|
||||
msgid "Sidebar successfully edited!"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:183
|
||||
msgid "Sidebar successfully deleted."
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:319
|
||||
msgid "Oops! Please choose a valid Name and ID for this sidebar"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:322
|
||||
msgid "Oops! That sidebar ID already exists"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:325
|
||||
msgid ""
|
||||
"Oops! You are trying to edit a sidebar that does not exist, or is not "
|
||||
"editable"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:328
|
||||
msgid ""
|
||||
"Oops! You are trying to delete a sidebar that does not exist, or cannot be "
|
||||
"deleted"
|
||||
msgstr ""
|
||||
|
||||
#: includes/admin.php:331
|
||||
msgid "Oops! Something went wrong. Try again."
|
||||
msgstr ""
|
||||
|
||||
#: includes/inpost.php:12
|
||||
msgid "Sidebar Selection"
|
||||
msgstr ""
|
||||
|
||||
#: includes/inpost.php:35 includes/inpost.php:50 includes/term.php:37
|
||||
#: includes/term.php:54
|
||||
msgid "Default"
|
||||
msgstr ""
|
||||
|
||||
#: includes/term.php:30
|
||||
msgid "Sidebar Options"
|
||||
msgstr ""
|
||||
|
||||
#: includes/term.php:34
|
||||
msgid "Primary Sidebar"
|
||||
msgstr ""
|
||||
|
||||
#: includes/term.php:51
|
||||
msgid "Secondary Sidebar"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/edit.php:5
|
||||
msgid "Nice try, partner. But that sidebar doesn't exist. Click back and try again."
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/edit.php:9
|
||||
msgid "Edit Sidebar"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/edit.php:17 includes/views/main.php:13
|
||||
#: includes/views/main.php:21 includes/views/main.php:48
|
||||
msgid "Name"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/edit.php:19 includes/views/main.php:50
|
||||
msgid "A recognizable name for your new sidebar widget area"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/edit.php:23 includes/views/main.php:14
|
||||
#: includes/views/main.php:22 includes/views/main.php:54
|
||||
msgid "ID"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/edit.php:27
|
||||
msgid ""
|
||||
"The unique ID is used to register the sidebar widget area (cannot be "
|
||||
"changed)"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/edit.php:31 includes/views/main.php:15
|
||||
#: includes/views/main.php:23 includes/views/main.php:60
|
||||
msgid "Description"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/edit.php:37
|
||||
msgid "Update"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/main.php:9
|
||||
msgid "Current Sidebars"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/main.php:42 includes/views/main.php:64
|
||||
msgid "Add New Sidebar"
|
||||
msgstr ""
|
||||
|
||||
#: includes/views/main.php:56
|
||||
msgid "The unique ID is used to register the sidebar widget area"
|
||||
msgstr ""
|
||||
|
||||
#: plugin.php:48
|
||||
msgid ""
|
||||
"Sorry, you cannot run Simple Sidebars without WordPress %s and <a "
|
||||
"href=\"%s\">Genesis %s</a>, or greater."
|
||||
msgstr ""
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Genesis Simple Sidebars"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
msgid "http://www.studiopress.com/plugins/simple-sidebars"
|
||||
msgstr ""
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid ""
|
||||
"Genesis Simple Sidebars allows you to easily create and use new sidebar "
|
||||
"widget areas."
|
||||
msgstr ""
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "Nathan Rice"
|
||||
msgstr ""
|
||||
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "http://www.nathanrice.net/"
|
||||
msgstr ""
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "genesis-simple-sidebars",
|
||||
"description": "Development files for the Genesis Simple Sidebars plugin.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/copyblogger/genesis-simple-sidebars"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-autoprefixer": "^0.8.1",
|
||||
"grunt-checktextdomain": "^0.1.1",
|
||||
"grunt-contrib-cssmin": "^0.10.0",
|
||||
"grunt-contrib-imagemin": "^0.7.1",
|
||||
"grunt-contrib-jshint": "^0.10.0",
|
||||
"grunt-contrib-uglify": "^0.5.0",
|
||||
"grunt-contrib-watch": "^0.6.1",
|
||||
"grunt-csscomb": "~2.0.1",
|
||||
"grunt-jsbeautifier": "^0.2.7",
|
||||
"grunt-jsvalidate": "^0.2.2",
|
||||
"grunt-phplint": "0.0.5",
|
||||
"grunt-styledocco": "^0.1.4",
|
||||
"grunt-wp-i18n": "^0.4.7",
|
||||
"load-grunt-tasks": "^0.6.0"
|
||||
},
|
||||
"plugin": {
|
||||
"name": "Genesis Simple Sidebars",
|
||||
"uri": "https://github.com/copyblogger/genesis-simple-sidebars",
|
||||
"description": "Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.",
|
||||
"author": "StudioPress",
|
||||
"authoruri": "http://www.studiopress.com/",
|
||||
"version": "2.0.2",
|
||||
"license": "GPL-2.0+",
|
||||
"licenseuri": "http://www.gnu.org/licenses/gpl-2.0.html",
|
||||
"textdomain": "genesis-simple-sidebars"
|
||||
}
|
||||
}
|
||||
+11
-109
@@ -2,117 +2,19 @@
|
||||
/*
|
||||
Plugin Name: Genesis Simple Sidebars
|
||||
Plugin URI: http://www.studiopress.com/plugins/simple-sidebars
|
||||
|
||||
Description: Genesis Simple Sidebars allows you to easily create and use new sidebar widget areas.
|
||||
Version: 0.9
|
||||
|
||||
Author: Nathan Rice
|
||||
Author URI: http://www.nathanrice.net/
|
||||
|
||||
Version: 2.1.0
|
||||
|
||||
Text Domain: genesis-simple-sidebars
|
||||
Domain Path: /languages/
|
||||
|
||||
License: GNU General Public License v2.0 (or later)
|
||||
License URI: http://www.opensource.org/licenses/gpl-license.php
|
||||
*/
|
||||
|
||||
// require Genesis 1.2 upon activation
|
||||
register_activation_hook(__FILE__, 'ss_activation_check');
|
||||
function ss_activation_check() {
|
||||
|
||||
$latest = '1.2';
|
||||
|
||||
$theme_info = get_theme_data(TEMPLATEPATH.'/style.css');
|
||||
|
||||
if( basename(TEMPLATEPATH) != 'genesis' ) {
|
||||
deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourself
|
||||
wp_die( sprintf( __('Sorry, you can\'t activate unless you have installed <a href="%s">Genesis</a>', 'ss'), 'http://www.studiopress.com/themes/genesis' ) );
|
||||
}
|
||||
|
||||
if( version_compare( $theme_info['Version'], $latest, '<' ) ) {
|
||||
deactivate_plugins(plugin_basename(__FILE__)); // Deactivate ourself
|
||||
wp_die( sprintf( __('Sorry, you cannot activate without <a href="%s">Genesis %s</a> or greater', 'ss'), 'http://www.studiopress.com/support/showthread.php?t=19576', $latest ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Define our constants
|
||||
define('SS_SETTINGS_FIELD', 'ss-settings');
|
||||
define('SS_PLUGIN_DIR', dirname(__FILE__));
|
||||
|
||||
// Include files
|
||||
require_once(SS_PLUGIN_DIR . '/admin.php');
|
||||
require_once(SS_PLUGIN_DIR . '/functions.php');
|
||||
require_once(SS_PLUGIN_DIR . '/inpost.php');
|
||||
require_once(SS_PLUGIN_DIR . '/term.php');
|
||||
|
||||
/**
|
||||
* This function registers the created sidebars
|
||||
*/
|
||||
add_action('widgets_init', 'ss_register_sidebars');
|
||||
function ss_register_sidebars() {
|
||||
|
||||
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
||||
if ( !$_sidebars ) return;
|
||||
|
||||
foreach ( (array)$_sidebars as $id => $info ) {
|
||||
|
||||
register_sidebar(array(
|
||||
'name' => esc_html( $info['name'] ),
|
||||
'id' => $id,
|
||||
'description' => esc_html( $info['description'] ),
|
||||
'editable' => 1,
|
||||
|
||||
'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-wrap">',
|
||||
'after_widget' => "</div></div>\n",
|
||||
'before_title' => '<h4 class="widgettitle">',
|
||||
'after_title' => "</h4>\n"
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove the default sidebars, run some conditional logic,
|
||||
* use alternate sidebars if necessary, else fallback on default sidebars.
|
||||
*/
|
||||
add_action('get_header', 'ss_sidebars_init');
|
||||
function ss_sidebars_init() {
|
||||
remove_action('genesis_sidebar', 'genesis_do_sidebar');
|
||||
remove_action('genesis_sidebar_alt', 'genesis_do_sidebar_alt');
|
||||
add_action('genesis_sidebar', 'ss_do_sidebar');
|
||||
add_action('genesis_sidebar_alt', 'ss_do_sidebar_alt');
|
||||
}
|
||||
|
||||
function ss_do_sidebar() {
|
||||
|
||||
if ( is_singular() && $_sidebar = genesis_get_custom_field('_ss_sidebar') ) {
|
||||
if ( dynamic_sidebar($_sidebar) ) return;
|
||||
}
|
||||
|
||||
if ( is_category() ) {
|
||||
$term = get_term( get_query_var('cat'), 'category' );
|
||||
if( isset( $term->meta['_ss_sidebar'] ) && dynamic_sidebar( $term->meta['_ss_sidebar'] ) ) return;
|
||||
}
|
||||
|
||||
if ( is_tag() ) {
|
||||
$term = get_term( get_query_var('tag_id'), 'post_tag' );
|
||||
if( isset( $term->meta['_ss_sidebar'] ) && dynamic_sidebar( $term->meta['_ss_sidebar'] ) ) return;
|
||||
}
|
||||
|
||||
genesis_do_sidebar();
|
||||
|
||||
}
|
||||
function ss_do_sidebar_alt() {
|
||||
|
||||
if ( is_singular() && $_sidebar_alt = genesis_get_custom_field('_ss_sidebar_alt') ) {
|
||||
if ( dynamic_sidebar($_sidebar_alt) ) return;
|
||||
}
|
||||
|
||||
if ( is_category() ) {
|
||||
$term = get_term( get_query_var('cat'), 'category' );
|
||||
if( isset( $term->meta['_ss_sidebar_alt'] ) && dynamic_sidebar( $term->meta['_ss_sidebar_alt'] ) ) return;
|
||||
}
|
||||
|
||||
if ( is_tag() ) {
|
||||
$term = get_term( get_query_var('tag_id'), 'post_tag' );
|
||||
if( isset( $term->meta['_ss_sidebar_alt'] ) && dynamic_sidebar( $term->meta['_ss_sidebar_alt'] ) ) return;
|
||||
}
|
||||
|
||||
genesis_do_sidebar_alt();
|
||||
|
||||
}
|
||||
require_once( plugin_dir_path( __FILE__ ) . 'genesis-simple-sidebars.php' );
|
||||
|
||||
+49
-12
@@ -1,16 +1,16 @@
|
||||
=== Plugin Name ===
|
||||
Contributors: nathanrice
|
||||
Contributors: nathanrice, wpmuguru
|
||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5553118
|
||||
Tags: hooks, genesis, genesiswp, studiopress
|
||||
Requires at least: 2.9
|
||||
Tested up to: 3.0
|
||||
Stable tag: 0.9
|
||||
Requires at least: 3.6
|
||||
Tested up to: 4.5
|
||||
Stable tag: 2.1.0
|
||||
|
||||
This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Theme Framework on a per post, per page, or per tag/category archive basis.
|
||||
This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Framework on a per post, per page, or per tag/category archive basis.
|
||||
|
||||
== Description ==
|
||||
|
||||
This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Theme Framework on a per post, per page, or per tag/category archive basis.
|
||||
This plugin allows you to create multiple, dynamic widget areas, and assign those widget areas to sidebar locations within the Genesis Framework on a per post, per page, or per tag/category archive basis.
|
||||
|
||||
Creating widget areas programmatically, then using conditional logic to properly assign them to sidebar locations can be a complex task for a beginner. This plugin allows you to do all this from a simple administration menu, and assign widget areas to sidebar locations with simple drop-down menus within the post/page edit screens, or when editing a tag or category.
|
||||
|
||||
@@ -37,11 +37,48 @@ Not in the way you're probably thinking. The markup surrounding the widget area
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 0.1 =
|
||||
* Initial Alpha Release
|
||||
= 2.1.0 =
|
||||
* Rewrite based on new plugin boilerplate.
|
||||
|
||||
= 2.0.3 =
|
||||
* Fix warnings and notices.
|
||||
|
||||
= 2.0.2 =
|
||||
* Change text domain, update POT file.
|
||||
|
||||
= 2.0.1 =
|
||||
* Genesis 2.0.1 compatibility with term meta keys.
|
||||
* Use actual sidebar name, instead of hard coded names.
|
||||
* Fix incorrect textdomain.
|
||||
|
||||
= 2.0.0 =
|
||||
* Compatibility with Genesis 2.0.0.
|
||||
* Standards.
|
||||
|
||||
= 1.0.0 =
|
||||
* Reorganize theme files.
|
||||
* Standards
|
||||
|
||||
= 0.9.2.1 =
|
||||
* Restore default tag/category support.
|
||||
* Default custom taxonomy support to on for public taxonomies.
|
||||
* Remove secondary selection when no 3 column layouts are enabled.
|
||||
|
||||
= 0.9.2 =
|
||||
* Added support for custom taxonomies.
|
||||
* Added translation support.
|
||||
* bug fix to prevent invalid sidebar creation.
|
||||
|
||||
= 0.9.1 =
|
||||
* Added support for custom post types.
|
||||
|
||||
= 0.9 =
|
||||
* Fixed "is not array" errors reported by users
|
||||
* Added nonce verification for security purposes
|
||||
* Added error and success messages
|
||||
* Bump to pre-release 0.9 branch
|
||||
* Fixed "is not array" errors reported by users.
|
||||
* Added nonce verification for security purposes.
|
||||
* Added error and success messages.
|
||||
* Bump to pre-release 0.9 branch.
|
||||
|
||||
= 0.1 =
|
||||
* Initial Alpha Release.
|
||||
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This function, hooked to display on the category/tag edit forms,
|
||||
* adds new fields to select a sidebar. The variables $tag and $taxonomy
|
||||
* are passed via the hook so that we can use them.
|
||||
*/
|
||||
add_action('category_edit_form', 'ss_term_sidebar', 9, 2);
|
||||
add_action('post_tag_edit_form', 'ss_term_sidebar', 9, 2);
|
||||
function ss_term_sidebar($tag, $taxonomy) {
|
||||
|
||||
// Merge Defaults to prevent notices
|
||||
$tag->meta = wp_parse_args( $tag->meta, array( '_ss_sidebar' => '', '_ss_sidebar_alt' => '' ) );
|
||||
|
||||
// Pull custom sidebars
|
||||
$_sidebars = stripslashes_deep( get_option( SS_SETTINGS_FIELD ) );
|
||||
|
||||
?>
|
||||
|
||||
<h3><?php _e('Sidebar Options', 'ss'); ?></h3>
|
||||
<table class="form-table">
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="meta[_ss_sidebar]"><?php _e('Primary Sidebar', 'ss'); ?></label></th>
|
||||
<td>
|
||||
<select name="meta[_ss_sidebar]" id="meta[_ss_sidebar]" style="padding-right: 10px;">
|
||||
<option value=""><?php _e('Default', 'ss'); ?></option>
|
||||
<?php
|
||||
foreach ( (array)$_sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, $tag->meta['_ss_sidebar'] , false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr class="form-field">
|
||||
<th scope="row" valign="top"><label for="meta[_ss_sidebar_alt]"><?php _e('Secondary Sidebar', 'ss'); ?></label></th>
|
||||
<td>
|
||||
<select name="meta[_ss_sidebar_alt]" id="meta[_ss_sidebar_alt]" style="padding-right: 10px;">
|
||||
<option value=""><?php _e('Default', 'ss'); ?></option>
|
||||
<?php
|
||||
foreach ( (array)$_sidebars as $id => $info ) {
|
||||
printf( '<option value="%s" %s>%s</option>', esc_html( $id ), selected( $id, $tag->meta['_ss_sidebar_alt'] , false), esc_html( $info['name'] ) );
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
Reference in New Issue
Block a user