Pojo Sidebars - Version 1.0.0

Version Description

  • Initial Public Release!
Download this release

Release Info

Developer KingYes
Plugin Icon Pojo Sidebars
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

includes/class-pojo-sidebars-admin-ui.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ final class Pojo_Sidebars_Admin_UI {
5
+
6
+ protected $_menu_parent = '';
7
+ protected $_capability = 'edit_theme_options';
8
+
9
+ public function register_sidebars() {
10
+ if ( ! Pojo_Sidebars::instance()->db->has_sidebars() )
11
+ return;
12
+
13
+ $sidebars = Pojo_Sidebars::instance()->db->get_sidebars();
14
+
15
+ foreach ( $sidebars as $sidebar ) {
16
+ $sidebar_classes = array( 'pojo-sidebar' );
17
+
18
+ register_sidebar(
19
+ array(
20
+ 'id' => 'pojo-sidebar-' . sanitize_title( $sidebar->term_id ),
21
+ 'name' => $sidebar->name,
22
+ 'description' => $sidebar->description,
23
+ 'before_widget' => '<section id="%1$s" class="widget ' . esc_attr( implode( ' ', $sidebar_classes ) ) . ' %2$s"><div class="widget-inner">',
24
+ 'after_widget' => '</div></section>',
25
+ 'before_title' => '<h5 class="widget-title"><span>',
26
+ 'after_title' => '</span></h5>',
27
+ )
28
+ );
29
+ }
30
+ }
31
+
32
+ public function register_menu() {
33
+ add_submenu_page(
34
+ $this->_menu_parent,
35
+ __( 'Sidebars', 'pojo-sidebars' ),
36
+ __( 'Sidebars', 'pojo-sidebars' ),
37
+ $this->_capability,
38
+ 'edit-tags.php?taxonomy=pojo_sidebars'
39
+ );
40
+ }
41
+
42
+ public function menu_highlight() {
43
+ global $parent_file, $submenu_file;
44
+
45
+ if ( 'edit-tags.php?taxonomy=pojo_sidebars' === $submenu_file ) {
46
+ $parent_file = $this->_menu_parent;
47
+ }
48
+ }
49
+
50
+ public function manage_columns( $columns ) {
51
+ $old_columns = $columns;
52
+ $columns = array(
53
+ 'cb' => $old_columns['cb'],
54
+ 'name' => $old_columns['name'],
55
+ 'ID' => __( 'ID', 'pojo-sidebars' ),
56
+ 'shortcode' => __( 'Shortcode', 'pojo-sidebars' ),
57
+ 'description' => $old_columns['description'],
58
+ );
59
+
60
+ return $columns;
61
+ }
62
+
63
+ public function sortable_columns( $sortable_columns ) {
64
+ $sortable_columns['ID'] = 'ID';
65
+ return $sortable_columns;
66
+ }
67
+
68
+ public function manage_custom_columns( $value, $column_name, $term_id ) {
69
+ switch ( $column_name ) {
70
+ case 'ID' :
71
+ $value = 'pojo-sidebar-' . $term_id;
72
+ break;
73
+
74
+ case 'shortcode' :
75
+ $value = '<input type="text" readonly value="' . esc_attr( '[pojo-sidebar id="' . $term_id . '"]' ) . '" />';
76
+ break;
77
+ }
78
+
79
+ return $value;
80
+ }
81
+
82
+ public function admin_head() {
83
+ if ( 'edit-pojo_sidebars' !== get_current_screen()->id )
84
+ return;
85
+
86
+ ?><style>#addtag div.form-field.term-slug-wrap, #edittag tr.form-field.term-slug-wrap { display: none; }</style><?php
87
+ }
88
+
89
+ public function admin_footer() {
90
+ if ( 'edit-pojo_sidebars' !== get_current_screen()->id )
91
+ return;
92
+
93
+ ?>
94
+ <script>jQuery( document ).ready( function( $ ) {
95
+ var $wrapper = $( '#addtag, #edittag' );
96
+ $wrapper.find( 'div.form-field.term-name-wrap > p' ).text( '<?php _e( 'The name of sidebar, must be unique.', 'pojo-sidebars' ); ?>' );
97
+ $wrapper.find( 'tr.form-field.term-name-wrap p.description' ).text( '<?php _e( '', 'pojo-sidebars' ); ?>' );
98
+ } );</script><?php
99
+ }
100
+
101
+ public function pojo_get_core_sidebars( $sidebars ) {
102
+ $our_sidebars = array();
103
+ foreach ( Pojo_Sidebars::instance()->db->get_sidebars() as $sidebar_term ) {
104
+ $our_sidebars[] = 'pojo-sidebar-' . $sidebar_term->term_id;
105
+ }
106
+
107
+ foreach ( $sidebars as $sidebar_id => $sidebar_name ) {
108
+ if ( in_array( $sidebar_id, $our_sidebars ) )
109
+ unset( $sidebars[ $sidebar_id ] );
110
+ }
111
+
112
+ return $sidebars;
113
+ }
114
+
115
+ public function __construct() {
116
+ if ( class_exists( 'Pojo_Core' ) )
117
+ $this->_menu_parent = 'pojo-home';
118
+ else
119
+ $this->_menu_parent = 'themes.php';
120
+
121
+ $this->register_sidebars();
122
+
123
+ add_action( 'admin_menu', array( &$this, 'register_menu' ), 100 );
124
+ add_action( 'admin_head', array( &$this, 'menu_highlight' ) );
125
+
126
+ add_filter( 'manage_edit-pojo_sidebars_columns', array( &$this, 'manage_columns' ) );
127
+ add_filter( 'manage_pojo_sidebars_custom_column', array( &$this, 'manage_custom_columns' ), 10, 3 );
128
+ add_filter( 'manage_edit-pojo_sidebars_sortable_columns', array( &$this, 'sortable_columns' ) );
129
+
130
+ add_action( 'admin_head', array( &$this, 'admin_head' ) );
131
+ add_action( 'admin_footer', array( &$this, 'admin_footer' ) );
132
+
133
+ add_filter( 'pojo_get_core_sidebars', array( &$this, 'pojo_get_core_sidebars' ) );
134
+ }
135
+
136
+ }
includes/class-pojo-sidebars-db.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ final class Pojo_Sidebars_DB {
5
+
6
+ protected $_sidebars = null;
7
+
8
+ protected function _register_taxonomy() {
9
+ // Taxonomy: pojo_sidebars.
10
+ $labels = array(
11
+ 'name' => __( 'Sidebars', 'pojo-sidebars' ),
12
+ 'singular_name' => __( 'Sidebar', 'pojo-sidebars' ),
13
+ 'menu_name' => _x( 'Sidebars', 'Admin menu name', 'pojo-sidebars' ),
14
+ 'search_items' => __( 'Search Sidebars', 'pojo-sidebars' ),
15
+ 'all_items' => __( 'All Sidebars', 'pojo-sidebars' ),
16
+ 'parent_item' => __( 'Parent Sidebar', 'pojo-sidebars' ),
17
+ 'parent_item_colon' => __( 'Parent Sidebar:', 'pojo-sidebars' ),
18
+ 'edit_item' => __( 'Edit Sidebar', 'pojo-sidebars' ),
19
+ 'update_item' => __( 'Update Sidebar', 'pojo-sidebars' ),
20
+ 'add_new_item' => __( 'Add New Sidebar', 'pojo-sidebars' ),
21
+ 'new_item_name' => __( 'New Sidebar Name', 'pojo-sidebars' ),
22
+ );
23
+
24
+ $args = array(
25
+ 'hierarchical' => false,
26
+ 'labels' => $labels,
27
+ 'public' => false,
28
+ 'show_in_nav_menus' => false,
29
+ 'show_ui' => false,
30
+ 'capabilities' => array( 'edit_theme_options' ),
31
+ 'query_var' => false,
32
+ 'rewrite' => false,
33
+ );
34
+
35
+ register_taxonomy(
36
+ 'pojo_sidebars',
37
+ apply_filters( 'pojo_taxonomy_objects_sidebars', array() ),
38
+ apply_filters( 'pojo_taxonomy_args_sidebars', $args )
39
+ );
40
+ }
41
+
42
+ public function get_sidebars() {
43
+ if ( is_null( $this->_sidebars ) ) {
44
+ $this->_sidebars = get_terms(
45
+ 'pojo_sidebars',
46
+ array(
47
+ 'hide_empty' => false,
48
+ )
49
+ );
50
+ }
51
+ return $this->_sidebars;
52
+ }
53
+
54
+ public function has_sidebars() {
55
+ $sidebars = $this->get_sidebars();
56
+ return ! empty( $sidebars );
57
+ }
58
+
59
+ public function __construct() {
60
+ $this->_register_taxonomy();
61
+ }
62
+
63
+ }
includes/class-pojo-sidebars-shortcode.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ final class Pojo_Sidebars_Shortcode {
5
+
6
+ public function render( $atts = array() ) {
7
+ if ( empty( $atts['id'] ) )
8
+ return '';
9
+
10
+ ob_start();
11
+
12
+ $sidebar_id = 'pojo-sidebar-' . $atts['id'];
13
+ dynamic_sidebar( $sidebar_id );
14
+
15
+ return ob_get_clean();
16
+ }
17
+
18
+ public function __construct() {
19
+ add_shortcode( 'pojo-sidebar', array( &$this, 'render' ) );
20
+ }
21
+
22
+ }
languages/pojo-sidebars.pot ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #: includes/class-pojo-sidebars-admin-ui.php:97
7
+ #, fuzzy
8
+ msgid ""
9
+ msgstr ""
10
+ "Project-Id-Version: pojo-sidebars 1.0.0\n"
11
+ "Report-Msgid-Bugs-To: \n"
12
+ "POT-Creation-Date: 2015-04-23 16:06+0300\n"
13
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
+ "Language-Team: LANGUAGE <LL@li.org>\n"
16
+ "Language: \n"
17
+ "MIME-Version: 1.0\n"
18
+ "Content-Type: text/plain; charset=CHARSET\n"
19
+ "Content-Transfer-Encoding: 8bit\n"
20
+
21
+ #: includes/class-pojo-sidebars-admin-ui.php:35
22
+ #: includes/class-pojo-sidebars-admin-ui.php:36
23
+ #: includes/class-pojo-sidebars-db.php:11
24
+ msgid "Sidebars"
25
+ msgstr ""
26
+
27
+ #: includes/class-pojo-sidebars-admin-ui.php:55
28
+ msgid "ID"
29
+ msgstr ""
30
+
31
+ #: includes/class-pojo-sidebars-admin-ui.php:56
32
+ msgid "Shortcode"
33
+ msgstr ""
34
+
35
+ #: includes/class-pojo-sidebars-admin-ui.php:96
36
+ msgid "The name of sidebar, must be unique."
37
+ msgstr ""
38
+
39
+ #: includes/class-pojo-sidebars-db.php:12
40
+ msgid "Sidebar"
41
+ msgstr ""
42
+
43
+ #: includes/class-pojo-sidebars-db.php:13
44
+ msgctxt "Admin menu name"
45
+ msgid "Sidebars"
46
+ msgstr ""
47
+
48
+ #: includes/class-pojo-sidebars-db.php:14
49
+ msgid "Search Sidebars"
50
+ msgstr ""
51
+
52
+ #: includes/class-pojo-sidebars-db.php:15
53
+ msgid "All Sidebars"
54
+ msgstr ""
55
+
56
+ #: includes/class-pojo-sidebars-db.php:16
57
+ msgid "Parent Sidebar"
58
+ msgstr ""
59
+
60
+ #: includes/class-pojo-sidebars-db.php:17
61
+ msgid "Parent Sidebar:"
62
+ msgstr ""
63
+
64
+ #: includes/class-pojo-sidebars-db.php:18
65
+ msgid "Edit Sidebar"
66
+ msgstr ""
67
+
68
+ #: includes/class-pojo-sidebars-db.php:19
69
+ msgid "Update Sidebar"
70
+ msgstr ""
71
+
72
+ #: includes/class-pojo-sidebars-db.php:20
73
+ msgid "Add New Sidebar"
74
+ msgstr ""
75
+
76
+ #: includes/class-pojo-sidebars-db.php:21
77
+ msgid "New Sidebar Name"
78
+ msgstr ""
79
+
80
+ #: pojo-sidebars.php:55 pojo-sidebars.php:66
81
+ msgid "Cheatin&#8217; huh?"
82
+ msgstr ""
pojo-sidebars.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Pojo Sidebars
4
+ Plugin URI: http://pojo.me/
5
+ Description: Pojo Sidebars generates as many sidebars as you need. It then allows you to place them on any Post, Page or Custom Posts Type in your WordPress site.
6
+ Author: Pojo Team
7
+ Author URI: http://pojo.me/
8
+ Version: 1.0.0
9
+ Text Domain: pojo-sidebars
10
+ Domain Path: /languages/
11
+ */
12
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
+
14
+ define( 'POJO_SIDEBARS__FILE__', __FILE__ );
15
+ define( 'POJO_SIDEBARS_BASE', plugin_basename( POJO_SIDEBARS__FILE__ ) );
16
+
17
+ final class Pojo_Sidebars {
18
+
19
+ /**
20
+ * @var Pojo_Sidebars The one true Pojo_Sidebars
21
+ * @since 1.0.0
22
+ */
23
+ private static $_instance = null;
24
+
25
+ /**
26
+ * @var Pojo_Sidebars_Admin_UI
27
+ */
28
+ public $admin_ui;
29
+
30
+ /**
31
+ * @var Pojo_Sidebars_DB
32
+ */
33
+ public $db;
34
+
35
+ /**
36
+ * @var Pojo_Sidebars_Shortcode
37
+ */
38
+ public $shortcode;
39
+
40
+ public function load_textdomain() {
41
+ load_plugin_textdomain( 'pojo-sidebars', false, basename( dirname( __FILE__ ) ) . '/languages' );
42
+ }
43
+
44
+ /**
45
+ * Throw error on object clone
46
+ *
47
+ * The whole idea of the singleton design pattern is that there is a single
48
+ * object therefore, we don't want the object to be cloned.
49
+ *
50
+ * @since 1.0.0
51
+ * @return void
52
+ */
53
+ public function __clone() {
54
+ // Cloning instances of the class is forbidden
55
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'pojo-sidebars' ), '1.0.0' );
56
+ }
57
+
58
+ /**
59
+ * Disable unserializing of the class
60
+ *
61
+ * @since 1.0.0
62
+ * @return void
63
+ */
64
+ public function __wakeup() {
65
+ // Unserializing instances of the class is forbidden
66
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'pojo-sidebars' ), '1.0.0' );
67
+ }
68
+
69
+ /**cd
70
+ * @return Pojo_Sidebars
71
+ */
72
+ public static function instance() {
73
+ if ( is_null( self::$_instance ) ) {
74
+ self::$_instance = new Pojo_Sidebars();
75
+ }
76
+ return self::$_instance;
77
+ }
78
+
79
+ public function bootstrap() {
80
+ include( 'includes/class-pojo-sidebars-db.php' );
81
+ include( 'includes/class-pojo-sidebars-admin-ui.php' );
82
+ include( 'includes/class-pojo-sidebars-shortcode.php' );
83
+
84
+ $this->db = new Pojo_Sidebars_DB();
85
+ $this->admin_ui = new Pojo_Sidebars_Admin_UI();
86
+ $this->shortcode = new Pojo_Sidebars_Shortcode();
87
+ }
88
+
89
+ private function __construct() {
90
+ add_action( 'init', array( &$this, 'bootstrap' ) );
91
+ add_action( 'plugins_loaded', array( &$this, 'load_textdomain' ) );
92
+ }
93
+
94
+ }
95
+
96
+ Pojo_Sidebars::instance();
97
+ // EOF
readme.txt ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Pojo Sidebars ===
2
+ Contributors: pojo.me, KingYes, ariel.k
3
+ Tags: pojo, sidebars
4
+ Requires at least: 4.1
5
+ Tested up to: 4.2
6
+ Stable tag: 1.0.0
7
+ License: GPLv2 or later
8
+
9
+ Pojo Sidebars generates as many sidebars as you need. It then allows you to place them on any Post, Page or Custom Posts Type in your WordPress site.
10
+
11
+ == Description ==
12
+
13
+ With Pojo Sidebars you can create as many sidebars you need for any page you want. Especially for themes based on [Pojo Framework](http://pojo.me/?utm_source=wp-repo&utm_medium=link&utm_campaign=sidebars).
14
+
15
+ You can easily separate your site into sections, as well as set a specific sidebar for every single page or custom post type.
16
+
17
+ You can replace any sidebar with a different one by embedding it in the Text Editor with a unique shortcode.
18
+
19
+ <strong>Display a sidebar using a built-in shortcode:</strong>
20
+
21
+ <code>[pojo-sidebar id="sidebarID"]</code>
22
+
23
+ <strong>Display a sidebar using a WordPress function:</strong>
24
+
25
+ <code><?php dynamic_sidebar( 'sidebarID' ) ); ?></code>
26
+
27
+ Would you like to like to contribute to Pojo Sidebars? You are more than welcome to submit your requests on the [GitHub repo](https://github.com/pojome/pojo-sidebars/). Also, if you have any notes about the code, please open a ticket on this issue tracker.
28
+
29
+ == Installation ==
30
+
31
+ <strong>Automatic Installation</strong>
32
+
33
+ 1. Install using the WordPress built-in Plugin installer > Add New
34
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
35
+ 1. Go to the Builder tab in the Pages or Widgets menu
36
+ 1. Drag and drop the widget and set it
37
+ 1. Enjoy!
38
+
39
+ <strong>Manual Installation</strong>
40
+
41
+ 1. Extract the zip file and just drop the contents in the <code>wp-content/plugins/</code> directory of your WordPress installation
42
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
43
+ 1. Go to the Builder tab in the Pages or Widgets menu
44
+ 1. Drag and drop the widget and set it
45
+ 1. Enjoy!
46
+
47
+ == Screenshots ==
48
+
49
+ 1. Dashboard
50
+ 2. Widgets Area
51
+ 3. Widgets Area 2
52
+
53
+ == Changelog ==
54
+
55
+ = 1.0.0 =
56
+ * Initial Public Release!
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file