Import legacy nurinda.co.id website
This commit is contained in:
1 parent
3f59bb9038
commit
6e21646ac4
13389 files changed
+3246690
No files matched your search
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! function_exists( 'wpsp_admin_scripts' ) ) {
|
||||
add_action( 'admin_print_scripts-post-new.php', 'wpsp_admin_scripts', 11 );
|
||||
add_action( 'admin_print_scripts-post.php', 'wpsp_admin_scripts', 11 );
|
||||
/**
|
||||
* Add our admin scripts and styles
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_admin_scripts() {
|
||||
global $post_type, $post;
|
||||
if ( 'wp_show_posts' == $post_type ) {
|
||||
wp_enqueue_script( 'wpsp-admin-scripts', plugin_dir_url( __FILE__ ) . "js/admin-scripts.js", array( 'jquery' ), WPSP_VERSION, true );
|
||||
wp_localize_script( 'wpsp-admin-scripts', 'wpsp_object', array (
|
||||
'post_id' => ( isset( $post ) ) ? $post->ID : false,
|
||||
'nonce' => wp_create_nonce( 'wpsp_nonce' )
|
||||
));
|
||||
}
|
||||
|
||||
wp_enqueue_style( 'wpsp-admin', plugin_dir_url( __FILE__ ) . "css/admin.css", array(), WPSP_VERSION );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_translatable_strings' ) ) {
|
||||
add_action( 'admin_head','wpsp_translatable_strings', 0 );
|
||||
/**
|
||||
* Add some javascript variables to the admin head
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_translatable_strings() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var wpsp_add_posts = '<?php _e( 'WP Show Posts','wp-show-posts' );?>';
|
||||
var wpsp_nonce = '<?php echo wp_create_nonce( 'wpsp_nonce' ); ?>';
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_add_shortcode_button' ) ) {
|
||||
add_action( 'admin_init', 'wpsp_add_shortcode_button' );
|
||||
/*
|
||||
* Set it up so we can register our TinyMCE button
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_add_shortcode_button() {
|
||||
// check user permissions
|
||||
if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if WYSIWYG is enabled
|
||||
if ( get_user_option( 'rich_editing' ) == 'true') {
|
||||
add_filter( 'mce_external_plugins', 'wpsp_shortcodes_add_tinymce_plugin' );
|
||||
add_filter( 'mce_buttons', 'wpsp_shortcodes_register_button' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_shortcodes_add_tinymce_plugin' ) ) {
|
||||
/*
|
||||
* Register our tinyMCE button javascript
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_shortcodes_add_tinymce_plugin( $plugin_array ) {
|
||||
$plugin_array[ 'wpsp_shortcode_button' ] = plugin_dir_url( __FILE__ ) . '/js/button.js';
|
||||
return $plugin_array;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_shortcodes_register_button' ) ) {
|
||||
/*
|
||||
* Register our TinyMCE button
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_shortcodes_register_button( $buttons ) {
|
||||
array_push( $buttons, 'wpsp_shortcode_button' );
|
||||
return $buttons;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! function_exists( 'wpsp_get_json_option' ) ) {
|
||||
add_action( 'wp_ajax_wpsp_get_json_option', 'wpsp_get_json_option' );
|
||||
/**
|
||||
* Get the current option value
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_get_json_option() {
|
||||
if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) ) {
|
||||
wp_die( 'Permission declined' );
|
||||
}
|
||||
|
||||
$option = ( get_post_meta( intval( $_POST[ 'id' ] ), sanitize_text_field( $_POST[ 'key' ] ) ) ) ? get_post_meta( intval( $_POST[ 'id' ] ), sanitize_text_field( $_POST[ 'key' ] ), true ) : false;
|
||||
|
||||
if ( $option ) {
|
||||
echo wp_json_encode( $option );
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_get_terms' ) ) {
|
||||
add_action( 'wp_ajax_wpsp_get_terms', 'wpsp_get_terms' );
|
||||
/**
|
||||
* Get all of our terms depending on the set taxonomy
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_get_terms() {
|
||||
if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) ) {
|
||||
wp_die( 'Permission declined' );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['taxonomy'] ) ) {
|
||||
die();
|
||||
}
|
||||
|
||||
$terms = get_terms( sanitize_key( $_POST[ 'taxonomy' ] ), 'orderby=count&hide_empty=1' );
|
||||
$count = count( $terms );
|
||||
$types = array();
|
||||
if ( $count > 0 ) {
|
||||
foreach ( $terms as $term ) {
|
||||
$types[] = $term->slug;
|
||||
}
|
||||
}
|
||||
|
||||
echo wp_json_encode( $types );
|
||||
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_get_taxonomies' ) ) {
|
||||
add_action( 'wp_ajax_wpsp_get_taxonomies', 'wpsp_get_taxonomies' );
|
||||
/**
|
||||
* Get out taxonomies based on the set post type
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_get_taxonomies() {
|
||||
if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) ) {
|
||||
wp_die( 'Permission declined' );
|
||||
}
|
||||
|
||||
$terms = get_object_taxonomies( sanitize_text_field( $_POST[ 'post_type' ] ) );
|
||||
$count = count( $terms );
|
||||
$types = array();
|
||||
if ( $count > 0 ) {
|
||||
foreach ( $terms as $term ) {
|
||||
$types[] = $term;
|
||||
}
|
||||
}
|
||||
|
||||
echo wp_json_encode( $types );
|
||||
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_get_post_lists' ) ) {
|
||||
add_action( 'wp_ajax_wpsp_get_post_lists', 'wpsp_get_post_lists' );
|
||||
/**
|
||||
* Get all of our post lists
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_get_post_lists() {
|
||||
if ( ! isset( $_POST[ 'wpsp_nonce' ] ) || ! wp_verify_nonce( $_POST[ 'wpsp_nonce' ], 'wpsp_nonce' ) ) {
|
||||
wp_die( 'Permission declined' );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'posts_per_page' => -1,
|
||||
'post_type' => 'wp_show_posts',
|
||||
'post_status' => 'publish',
|
||||
'showposts' => -1
|
||||
);
|
||||
$posts = get_posts( $args );
|
||||
|
||||
$count = count( $posts );
|
||||
$types = array();
|
||||
if ( $count > 0 ) {
|
||||
foreach ( $posts as $post ) {
|
||||
$types[] = array( 'text' => $post->post_title, 'value' => $post->ID );
|
||||
}
|
||||
}
|
||||
|
||||
echo wp_json_encode( $types );
|
||||
|
||||
die();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: ButterBean
|
||||
* Plugin URI: https://github.com/justintadlock/butterbean
|
||||
* Description: A little post meta framework.
|
||||
* Version: 1.0.0
|
||||
* Author: Justin Tadlock
|
||||
* Author URI: http://themehybrid.com
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
// For each version release, the priority needs to decrement by 1. This is so that
|
||||
// we can load newer versions earlier than older versions when there's a conflict.
|
||||
add_action( 'init', 'butterbean_loader_100', 9999 );
|
||||
|
||||
if ( ! function_exists( 'butterbean_loader_100' ) ) {
|
||||
|
||||
/**
|
||||
* Loader function. Note to change the name of this function to use the
|
||||
* current version number of the plugin. `1.0.0` is `100`, `1.3.4` = `134`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function butterbean_loader_100() {
|
||||
|
||||
// If not in the admin, bail.
|
||||
if ( ! is_admin() )
|
||||
return;
|
||||
|
||||
// If ButterBean hasn't been loaded, let's load it.
|
||||
if ( ! defined( 'BUTTERBEAN_LOADED' ) ) {
|
||||
define( 'BUTTERBEAN_LOADED', true );
|
||||
|
||||
require_once( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'class-butterbean.php' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Change Log
|
||||
|
||||
## [1.0.0] - 2016-08-29
|
||||
|
||||
* Plugin launch. Everything's new!
|
||||
@@ -0,0 +1,867 @@
|
||||
<?php
|
||||
/**
|
||||
* Primary plugin class. This sets up and runs the show.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if ( ! class_exists( 'ButterBean' ) ) {
|
||||
|
||||
/**
|
||||
* Main ButterBean class. Runs the show.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
final class ButterBean {
|
||||
|
||||
/**
|
||||
* Directory path to the plugin folder.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $dir_path = '';
|
||||
|
||||
/**
|
||||
* Directory URI to the plugin folder.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $dir_uri = '';
|
||||
|
||||
/**
|
||||
* Directory path to the template folder.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $tmpl_path = '';
|
||||
|
||||
/**
|
||||
* Array of managers.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $managers = array();
|
||||
|
||||
/**
|
||||
* Array of manager types.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $manager_types = array();
|
||||
|
||||
/**
|
||||
* Array of section types.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $section_types = array();
|
||||
|
||||
/**
|
||||
* Array of control types.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $control_types = array();
|
||||
|
||||
/**
|
||||
* Array of setting types.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $setting_types = array();
|
||||
|
||||
/**
|
||||
* Whether this is a new post. Once the post is saved and we're
|
||||
* no longer on the `post-new.php` screen, this is going to be
|
||||
* `false`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var bool
|
||||
*/
|
||||
public $is_new_post = false;
|
||||
|
||||
/**
|
||||
* Returns the instance.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function get_instance() {
|
||||
|
||||
static $instance = null;
|
||||
|
||||
if ( is_null( $instance ) ) {
|
||||
$instance = new self;
|
||||
$instance->setup();
|
||||
$instance->includes();
|
||||
$instance->setup_actions();
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* Initial plugin setup.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function setup() {
|
||||
|
||||
$this->dir_path = apply_filters( 'butterbean_dir_path', trailingslashit( plugin_dir_path( __FILE__ ) ) );
|
||||
$this->dir_uri = apply_filters( 'butterbean_dir_uri', trailingslashit( plugin_dir_url( __FILE__ ) ) );
|
||||
|
||||
$this->tmpl_path = trailingslashit( $this->dir_path . 'tmpl' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads include and admin files for the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function includes() {
|
||||
|
||||
// If not in the admin, bail.
|
||||
if ( ! is_admin() )
|
||||
return;
|
||||
|
||||
// Load base classes.
|
||||
require_once( $this->dir_path . 'inc/class-manager.php' );
|
||||
require_once( $this->dir_path . 'inc/class-section.php' );
|
||||
require_once( $this->dir_path . 'inc/class-control.php' );
|
||||
require_once( $this->dir_path . 'inc/class-setting.php' );
|
||||
|
||||
// Load control sub-classes.
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-checkboxes.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-color.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-datetime.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-image.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-palette.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-radio.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-radio-image.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-select-group.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-textarea.php' );
|
||||
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-excerpt.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-multi-avatars.php' );
|
||||
require_once( $this->dir_path . 'inc/controls/class-control-parent.php' );
|
||||
|
||||
// Load setting sub-classes.
|
||||
require_once( $this->dir_path . 'inc/settings/class-setting-multiple.php' );
|
||||
require_once( $this->dir_path . 'inc/settings/class-setting-datetime.php' );
|
||||
require_once( $this->dir_path . 'inc/settings/class-setting-array.php' );
|
||||
|
||||
// Load functions.
|
||||
require_once( $this->dir_path . 'inc/functions-core.php' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up initial actions.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
private function setup_actions() {
|
||||
|
||||
// Call the register function.
|
||||
add_action( 'load-post.php', array( $this, 'register' ), 95 );
|
||||
add_action( 'load-post-new.php', array( $this, 'register' ), 95 );
|
||||
|
||||
// Register default types.
|
||||
add_action( 'butterbean_register', array( $this, 'register_manager_types' ), -95 );
|
||||
add_action( 'butterbean_register', array( $this, 'register_section_types' ), -95 );
|
||||
add_action( 'butterbean_register', array( $this, 'register_control_types' ), -95 );
|
||||
add_action( 'butterbean_register', array( $this, 'register_setting_types' ), -95 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registration callback. Fires the `butterbean_register` action hook to
|
||||
* allow plugins to register their managers.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function register() {
|
||||
|
||||
// If this is a new post, set the new post boolean.
|
||||
if ( 'load-post-new.php' === current_action() )
|
||||
$this->is_new_post = true;
|
||||
|
||||
// Get the current post type.
|
||||
$post_type = get_current_screen()->post_type;
|
||||
|
||||
// Action hook for registering managers.
|
||||
do_action( 'butterbean_register', $this, $post_type );
|
||||
|
||||
// Loop through the managers to see if we're using on on this screen.
|
||||
foreach ( $this->managers as $manager ) {
|
||||
|
||||
// If we found a matching post type, add our actions/filters.
|
||||
if ( ! in_array( $post_type, (array) $manager->post_type ) ) {
|
||||
$this->unregister_manager( $manager->name );
|
||||
continue;
|
||||
}
|
||||
|
||||
// Sort controls and sections by priority.
|
||||
uasort( $manager->controls, array( $this, 'priority_sort' ) );
|
||||
uasort( $manager->sections, array( $this, 'priority_sort' ) );
|
||||
}
|
||||
|
||||
// If no managers registered, bail.
|
||||
if ( ! $this->managers )
|
||||
return;
|
||||
|
||||
// Add meta boxes.
|
||||
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 5 );
|
||||
|
||||
// Save settings.
|
||||
add_action( 'save_post', array( $this, 'update' ) );
|
||||
|
||||
// Load scripts and styles.
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
add_action( 'butterbean_enqueue_scripts', array( $this, 'enqueue' ) );
|
||||
|
||||
// Localize scripts and Undescore templates.
|
||||
add_action( 'admin_footer', array( $this, 'localize_scripts' ) );
|
||||
add_action( 'admin_footer', array( $this, 'print_templates' ) );
|
||||
|
||||
// Renders our Backbone views.
|
||||
add_action( 'admin_print_footer_scripts', array( $this, 'render_views' ), 95 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object|string $manager
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function register_manager( $manager, $args = array() ) {
|
||||
|
||||
if ( ! is_object( $manager ) ) {
|
||||
|
||||
$type = isset( $args['type'] ) ? $this->get_manager_type( $args['type'] ) : $this->get_manager_type( 'default' );
|
||||
|
||||
$manager = new $type( $manager, $args );
|
||||
}
|
||||
|
||||
if ( ! $this->manager_exists( $manager->name ) )
|
||||
$this->managers[ $manager->name ] = $manager;
|
||||
|
||||
return $manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a manager object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_manager( $name ) {
|
||||
|
||||
if ( $this->manager_exists( $name ) )
|
||||
unset( $this->managers[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a manager object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return object|bool
|
||||
*/
|
||||
public function get_manager( $name ) {
|
||||
|
||||
return $this->manager_exists( $name ) ? $this->managers[ $name ] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a manager exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function manager_exists( $name ) {
|
||||
|
||||
return isset( $this->managers[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a manager type. This is just a method of telling ButterBean
|
||||
* the class of your custom manager type. It allows the manager to be
|
||||
* called without having to pass an object to `register_manager()`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param string $class
|
||||
* @return void
|
||||
*/
|
||||
public function register_manager_type( $type, $class ) {
|
||||
|
||||
if ( ! $this->manager_type_exists( $type ) )
|
||||
$this->manager_types[ $type ] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a manager type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_manager_type( $type ) {
|
||||
|
||||
if ( $this->manager_type_exists( $type ) )
|
||||
unset( $this->manager_types[ $type ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name for the manager type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
public function get_manager_type( $type ) {
|
||||
|
||||
return $this->manager_type_exists( $type ) ? $this->manager_types[ $type ] : $this->manager_types[ 'default' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a manager type exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function manager_type_exists( $type ) {
|
||||
|
||||
return isset( $this->manager_types[ $type ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a section type. This is just a method of telling ButterBean
|
||||
* the class of your custom section type. It allows the section to be
|
||||
* called without having to pass an object to `register_section()`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param string $class
|
||||
* @return void
|
||||
*/
|
||||
public function register_section_type( $type, $class ) {
|
||||
|
||||
if ( ! $this->section_type_exists( $type ) )
|
||||
$this->section_types[ $type ] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a section type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_section_type( $type ) {
|
||||
|
||||
if ( $this->section_type_exists( $type ) )
|
||||
unset( $this->section_types[ $type ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name for the section type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
public function get_section_type( $type ) {
|
||||
|
||||
return $this->section_type_exists( $type ) ? $this->section_types[ $type ] : $this->section_types[ 'default' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a section type exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function section_type_exists( $type ) {
|
||||
|
||||
return isset( $this->section_types[ $type ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a control type. This is just a method of telling ButterBean
|
||||
* the class of your custom control type. It allows the control to be
|
||||
* called without having to pass an object to `register_control()`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param string $class
|
||||
* @return void
|
||||
*/
|
||||
public function register_control_type( $type, $class ) {
|
||||
|
||||
if ( ! $this->control_type_exists( $type ) )
|
||||
$this->control_types[ $type ] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a control type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_control_type( $type ) {
|
||||
|
||||
if ( $this->control_type_exists( $type ) )
|
||||
unset( $this->control_types[ $type ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name for the control type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
public function get_control_type( $type ) {
|
||||
|
||||
return $this->control_type_exists( $type ) ? $this->control_types[ $type ] : $this->control_types[ 'default' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a control type exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function control_type_exists( $type ) {
|
||||
|
||||
return isset( $this->control_types[ $type ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a setting type. This is just a method of telling ButterBean
|
||||
* the class of your custom setting type. It allows the setting to be
|
||||
* called without having to pass an object to `register_setting()`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param string $class
|
||||
* @return void
|
||||
*/
|
||||
public function register_setting_type( $type, $class ) {
|
||||
|
||||
if ( ! $this->setting_type_exists( $type ) )
|
||||
$this->setting_types[ $type ] = $class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a setting type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_setting_type( $type ) {
|
||||
|
||||
if ( $this->setting_type_exists( $type ) )
|
||||
unset( $this->setting_types[ $type ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the class name for the setting type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
public function get_setting_type( $type ) {
|
||||
|
||||
return $this->setting_type_exists( $type ) ? $this->setting_types[ $type ] : $this->setting_types[ 'default' ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a setting type exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
public function setting_type_exists( $type ) {
|
||||
|
||||
return isset( $this->setting_types[ $type ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers our manager types so that devs don't have to directly instantiate
|
||||
* the class each time they register a manager. Instead, they can use the
|
||||
* `type` argument.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function register_manager_types() {
|
||||
|
||||
$this->register_manager_type( 'default', 'ButterBean_Manager' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers our section types so that devs don't have to directly instantiate
|
||||
* the class each time they register a section. Instead, they can use the
|
||||
* `type` argument.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function register_section_types() {
|
||||
|
||||
$this->register_section_type( 'default', 'ButterBean_Section' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers our control types so that devs don't have to directly instantiate
|
||||
* the class each time they register a control. Instead, they can use the
|
||||
* `type` argument.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function register_control_types() {
|
||||
|
||||
$this->register_control_type( 'default', 'ButterBean_Control' );
|
||||
$this->register_control_type( 'checkboxes', 'ButterBean_Control_Checkboxes' );
|
||||
$this->register_control_type( 'color', 'ButterBean_Control_Color' );
|
||||
$this->register_control_type( 'datetime', 'ButterBean_Control_Datetime' );
|
||||
$this->register_control_type( 'excerpt', 'ButterBean_Control_Excerpt' );
|
||||
$this->register_control_type( 'image', 'ButterBean_Control_Image' );
|
||||
$this->register_control_type( 'palette', 'ButterBean_Control_Palette' );
|
||||
$this->register_control_type( 'radio', 'ButterBean_Control_Radio' );
|
||||
$this->register_control_type( 'radio-image', 'ButterBean_Control_Radio_Image' );
|
||||
$this->register_control_type( 'select-group', 'ButterBean_Control_Select_Group' );
|
||||
$this->register_control_type( 'textarea', 'ButterBean_Control_Textarea' );
|
||||
$this->register_control_type( 'multi-avatars', 'ButterBean_Control_Multi_Avatars' );
|
||||
$this->register_control_type( 'parent', 'ButterBean_Control_Parent' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers our setting types so that devs don't have to directly instantiate
|
||||
* the class each time they register a setting. Instead, they can use the
|
||||
* `type` argument.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function register_setting_types() {
|
||||
|
||||
$this->register_setting_type( 'default', 'ButterBean_Setting' );
|
||||
$this->register_setting_type( 'single', 'ButterBean_Setting' );
|
||||
$this->register_setting_type( 'multiple', 'ButterBean_Setting_Multiple' );
|
||||
$this->register_setting_type( 'array', 'ButterBean_Setting_Array' );
|
||||
$this->register_setting_type( 'datetime', 'ButterBean_Setting_Datetime' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires an action hook to register/enqueue scripts/styles.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
|
||||
do_action( 'butterbean_enqueue_scripts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads scripts and styles.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
// Enqueue the main plugin script.
|
||||
wp_enqueue_script( 'butterbean', $this->dir_uri . "js/butterbean{$min}.js", array( 'backbone', 'wp-util' ), '', true );
|
||||
|
||||
// Enqueue the main plugin style.
|
||||
wp_enqueue_style( 'butterbean', $this->dir_uri . "css/butterbean{$min}.css" );
|
||||
|
||||
// Loop through the manager and its controls and call each control's `enqueue()` method.
|
||||
foreach ( $this->managers as $manager ) {
|
||||
|
||||
$manager->enqueue();
|
||||
|
||||
foreach ( $manager->sections as $section )
|
||||
$section->enqueue();
|
||||
|
||||
foreach ( $manager->controls as $control )
|
||||
$control->enqueue();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function for adding meta boxes. This function adds a meta box
|
||||
* for each of the managers.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $post_type
|
||||
* @return void
|
||||
*/
|
||||
public function add_meta_boxes( $post_type ) {
|
||||
|
||||
foreach ( $this->managers as $manager ) {
|
||||
|
||||
// If the manager is registered for the current post type, add a meta box.
|
||||
if ( in_array( $post_type, (array) $manager->post_type ) && $manager->check_capabilities() ) {
|
||||
|
||||
add_meta_box(
|
||||
"butterbean-ui-{$manager->name}",
|
||||
$manager->label,
|
||||
array( $this, 'meta_box' ),
|
||||
$post_type,
|
||||
$manager->context,
|
||||
$manager->priority,
|
||||
array( 'manager' => $manager )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the meta box. Note that the actual content of the meta box is
|
||||
* handled via Underscore.js templates. The only thing we're outputting here
|
||||
* is the nonce field.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object $post
|
||||
* @param array $metabox
|
||||
* @return void
|
||||
*/
|
||||
public function meta_box( $post, $metabox ) {
|
||||
|
||||
$manager = $metabox['args']['manager'];
|
||||
|
||||
$manager->post_id = $this->post_id = $post->ID;
|
||||
|
||||
// Nonce field to validate on save.
|
||||
wp_nonce_field( "butterbean_{$manager->name}_nonce", "butterbean_{$manager->name}" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes the appropriate section and control json data to the JS file.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function localize_scripts() {
|
||||
|
||||
$json = array( 'managers' => array() );
|
||||
|
||||
foreach ( $this->managers as $manager ) {
|
||||
|
||||
if ( $manager->check_capabilities() )
|
||||
$json['managers'][] = $manager->get_json();
|
||||
}
|
||||
|
||||
wp_localize_script( 'butterbean', 'butterbean_data', $json );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the Underscore.js templates.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function print_templates() {
|
||||
|
||||
$m_templates = array();
|
||||
$s_templates = array();
|
||||
$c_templates = array(); ?>
|
||||
|
||||
<script type="text/html" id="tmpl-butterbean-nav">
|
||||
<?php butterbean_get_nav_template(); ?>
|
||||
</script>
|
||||
|
||||
<?php foreach ( $this->managers as $manager ) {
|
||||
|
||||
if ( ! $manager->check_capabilities() )
|
||||
continue;
|
||||
|
||||
if ( ! in_array( $manager->type, $m_templates ) ) {
|
||||
$m_templates[] = $manager->type;
|
||||
|
||||
$manager->print_template();
|
||||
}
|
||||
|
||||
foreach ( $manager->sections as $section ) {
|
||||
|
||||
if ( ! in_array( $section->type, $s_templates ) ) {
|
||||
$s_templates[] = $section->type;
|
||||
|
||||
$section->print_template();
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( $manager->controls as $control ) {
|
||||
|
||||
if ( ! in_array( $control->type, $c_templates ) ) {
|
||||
$c_templates[] = $control->type;
|
||||
|
||||
$control->print_template();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders our Backbone views. We're calling this late in the page load so
|
||||
* that other scripts have an opportunity to extend with their own, custom
|
||||
* views for custom controls and such.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function render_views() { ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
( function( api ) {
|
||||
if ( _.isObject( api ) && _.isFunction( api.render ) ) {
|
||||
api.render();
|
||||
}
|
||||
}( butterbean ) );
|
||||
</script>
|
||||
<?php }
|
||||
|
||||
/**
|
||||
* Saves the settings.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function update( $post_id ) {
|
||||
|
||||
$do_autosave = defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE;
|
||||
$is_autosave = wp_is_post_autosave( $post_id );
|
||||
$is_revision = wp_is_post_revision( $post_id );
|
||||
|
||||
if ( $do_autosave || $is_autosave || $is_revision )
|
||||
return;
|
||||
|
||||
foreach ( $this->managers as $manager ) {
|
||||
|
||||
if ( $manager->check_capabilities() )
|
||||
$manager->save( $post_id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method for sorting sections and controls by priority.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @param object $a
|
||||
* @param object $b
|
||||
* @return int
|
||||
*/
|
||||
protected function priority_sort( $a, $b ) {
|
||||
|
||||
if ( $a->priority === $b->priority )
|
||||
return $a->instance_number - $b->instance_number;
|
||||
|
||||
return $a->priority - $b->priority;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance of the `ButterBean` class. This function is useful for quickly grabbing data
|
||||
* used throughout the plugin.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function butterbean() {
|
||||
return ButterBean::get_instance();
|
||||
}
|
||||
|
||||
// Let's do this thang!
|
||||
butterbean();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# Contributing
|
||||
|
||||
The code for the project is handled via its [GitHub Repository](https://github.com/justintadlock/butterbean). You can open tickets, create patches, and send pull requests there.
|
||||
|
||||
## Pull requests
|
||||
|
||||
Problem first. Solution second.
|
||||
|
||||
Pull requests should have a ticket open for discussion first. I rarely accept pull requests that aren't for a specific issue for various reasons. It's far better to post an issue and let me or the community provide feedback prior to creating a pull request.
|
||||
|
||||
Please don't make pull requests against the `master` branch. This is the latest, stable code. You can make a pull request against one of the point branches or the `dev` (future release) branch.
|
||||
|
||||
## Coding standards
|
||||
|
||||
In general, the project follows all WordPress [coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards). There are instances where it doesn't, opting for personal choices of my own, but in terms of contributing, following the WordPress standards is best practice.
|
||||
|
||||
## Script and style files
|
||||
|
||||
The project consists of several script and style files. When making patches or pull requests with changes to these files, only do so to the primary file. Don't create patches for the minified (`.min`) versions of the files. Those will be minified after a patch is merged into the code base.
|
||||
|
||||
## Language
|
||||
|
||||
All text strings follow U.S. English by default. While such guides are generally unneeded, in cases where style considerations are necessary, these will typically follow conventions laid out in *Elements of Style* or the *AP Stylebook*.
|
||||
|
||||
## Licensing
|
||||
|
||||
Any code contributed to the project via patches, pull requests, or other means will be licensed under the [GPL version 2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) or later. By contributing code to the project, you provide consent to use such code under this license. The exception to this rule is when bringing in third-party code with an alternate open source license.
|
||||
|
||||
## Versioning
|
||||
|
||||
The project uses [semantic versioning](http://semver.org). Version numbers will look like `3.2.1` where `3` is the "major" release, `2` is the minor release, and `1` is the patch release.
|
||||
@@ -0,0 +1,330 @@
|
||||
|
||||
/* Wrapper box */
|
||||
|
||||
.butterbean-ui { }
|
||||
|
||||
.butterbean-ui > .hndle {
|
||||
padding: 10px !important;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
.butterbean-ui .inside {
|
||||
margin: 0 !important;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Tabs wrapper. */
|
||||
|
||||
.butterbean-manager-default {
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
background: linear-gradient( 90deg, #fafafa 0%, #fafafa 180px, #fff 180px, #fff 100% );
|
||||
}
|
||||
|
||||
#side-sortables .butterbean-manager-default {
|
||||
background: linear-gradient( 90deg, #fafafa 0%, #fafafa 48px, #fff 48px, #fff 100% );
|
||||
}
|
||||
|
||||
@media only screen and ( max-width: 782px ), ( max-width: 980px ) and ( min-width: 851px ) {
|
||||
|
||||
.butterbean-manager-default {
|
||||
background: linear-gradient( 90deg, #fafafa 0%, #fafafa 48px, #fff 48px, #fff 100% );
|
||||
}
|
||||
}
|
||||
|
||||
/* Tab nav. */
|
||||
|
||||
.butterbean-manager-default .butterbean-nav {
|
||||
position: relative;
|
||||
float: left;
|
||||
list-style: none;
|
||||
width: 180px;/*20%;*/
|
||||
line-height: 1em;
|
||||
margin: 0 0 -1px 0;
|
||||
padding: 0;
|
||||
background-color: #fafafa;
|
||||
border-right: 1px solid #eee;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-nav li {
|
||||
display: block;
|
||||
position: relative;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-nav li a {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 10px;
|
||||
line-height: 20px !important;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid #eee;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-nav .dashicons {
|
||||
line-height: 20px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-nav li[aria-selected="true"] a {
|
||||
position: relative;
|
||||
font-weight: bold;
|
||||
color: #555;
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
|
||||
@media only screen and ( max-width: 782px ), ( max-width: 980px ) and ( min-width: 851px ) {
|
||||
.butterbean-manager-default .butterbean-nav { width: 48px; }
|
||||
|
||||
.butterbean-manager-default .butterbean-nav .dashicons {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font-size: 24px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-nav .dashicons::before {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-nav .label {
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
top: -1000em;
|
||||
left: -1000em;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Tab content wrapper */
|
||||
|
||||
.butterbean-manager-default .butterbean-content {
|
||||
float: left;
|
||||
width: calc( 100% - 180px );
|
||||
margin-left: -1px;
|
||||
border-left: 1px solid #eee;
|
||||
}
|
||||
|
||||
@media only screen and ( max-width: 782px ), ( max-width: 980px ) and ( min-width: 851px ) {
|
||||
|
||||
.butterbean-manager-default .butterbean-content {
|
||||
width: calc( 100% - 48px );
|
||||
}
|
||||
}
|
||||
|
||||
/* === Manager when in the side meta box. === */
|
||||
|
||||
@media only screen and ( min-width: 850px ) {
|
||||
|
||||
#side-sortables .butterbean-manager-default { background: #fff; }
|
||||
|
||||
#side-sortables .butterbean-manager-default .butterbean-content { width: 100%; }
|
||||
|
||||
#side-sortables .butterbean-manager-default .butterbean-nav {
|
||||
display: table;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#side-sortables .butterbean-manager-default .butterbean-nav li {
|
||||
display: table-cell;
|
||||
text-align: center;
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
|
||||
#side-sortables .butterbean-manager-default .butterbean-nav li:last-of-type { border-right: none; }
|
||||
|
||||
#side-sortables .butterbean-manager-default .butterbean-nav li a {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
#side-sortables .butterbean-manager-default .butterbean-nav .dashicons {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
font-size: 24px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
#side-sortables .butterbean-manager-default .butterbean-nav .dashicons::before {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
|
||||
#side-sortables .butterbean-manager-default .butterbean-nav .label {
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
top: -1000em;
|
||||
left: -1000em;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* === Content === */
|
||||
|
||||
.butterbean-manager-default .butterbean-section {
|
||||
padding: 12px 12px 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-section[aria-hidden="true"] { display: none; }
|
||||
.butterbean-manager-default .butterbean-section[aria-hidden="false"] { display: block; }
|
||||
|
||||
.butterbean-manager-default .butterbean-control {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-label {
|
||||
display : block !important; /* this is getting overwritten somewhere */
|
||||
font-weight : bold;
|
||||
display : inline-block;
|
||||
margin-bottom : 4px;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-control-checkbox .butterbean-label {
|
||||
display: inline !important;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-description {
|
||||
display : block;
|
||||
font-style : italic;
|
||||
margin-top : 4px;
|
||||
}
|
||||
|
||||
.butterbean-manager-default .butterbean-label + .butterbean-description {
|
||||
margin-top : 0;
|
||||
margin-bottom : 4px;
|
||||
}
|
||||
|
||||
/* === Media === */
|
||||
|
||||
.butterbean-control-image .butterbean-img {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 300px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.butterbean-placeholder {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
text-align: center;
|
||||
padding: 9px 0;
|
||||
line-height: 20px;
|
||||
border: 1px dashed rgb(180, 185, 190);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* === Textarea Control === */
|
||||
|
||||
.butterbean-control-textarea textarea,
|
||||
.butterbean-control-excerpt textarea {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 105px;
|
||||
}
|
||||
|
||||
/* === Date Control === */
|
||||
|
||||
.butterbean-control-datetime select {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* === Palette Control === */
|
||||
|
||||
.butterbean-control-palette label {
|
||||
display: block;
|
||||
padding: 0 10px 10px;
|
||||
}
|
||||
|
||||
.butterbean-control-palette label[aria-selected="true"] {
|
||||
padding-top: 5px;
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
.butterbean-palette-label {
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.butterbean-palette-block {
|
||||
display: table;
|
||||
width: 100%;
|
||||
height: 45px;
|
||||
border: 1px solid rgb(238, 238, 238);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.butterbean-palette-color {
|
||||
display: table-cell;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* === Radio Image Control === */
|
||||
|
||||
.butterbean-control-radio-image input[type="radio"] {
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
position: absolute !important;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.butterbean-control-radio-image img {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
padding: 1px;
|
||||
border: 4px solid transparent;
|
||||
}
|
||||
|
||||
.butterbean-control-radio-image img:hover,
|
||||
.butterbean-control-radio-image img:focus {
|
||||
border-color: #ccc;
|
||||
}
|
||||
|
||||
.butterbean-control-radio-image input:checked + span + img {
|
||||
border-color: #00a0d2;
|
||||
}
|
||||
|
||||
/* === Multi-avatars Control === */
|
||||
|
||||
.butterbean-multi-avatars-wrap label {
|
||||
display: inline-block;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.butterbean-multi-avatars-wrap input[type="checkbox"] {
|
||||
clip: rect( 1px, 1px, 1px, 1px );
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
position: absolute !important;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.butterbean-multi-avatars-wrap .avatar {
|
||||
box-sizing: border-box;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
padding: 1px;
|
||||
border: 4px solid transparent;
|
||||
}
|
||||
|
||||
#side-sortables .butterbean-multi-avatars-wrap .avatar {
|
||||
max-width: 60px;
|
||||
max-height: 60px;
|
||||
}
|
||||
|
||||
.butterbean-multi-avatars-wrap img:hover,
|
||||
.butterbean-multi-avatars-wrap img:focus {
|
||||
border-color: #ccc;
|
||||
}
|
||||
|
||||
.butterbean-multi-avatars-wrap input:checked + span + img {
|
||||
border-color: #00a0d2;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
.butterbean-ui>.hndle{padding:10px!important;border-bottom:1px solid #eee}.butterbean-ui .inside{margin:0!important;padding:0}.butterbean-manager-default{overflow:hidden;background:#fff;background:linear-gradient(90deg,#fafafa 0,#fafafa 180px,#fff 180px,#fff 100%)}#side-sortables .butterbean-manager-default{background:linear-gradient(90deg,#fafafa 0,#fafafa 48px,#fff 48px,#fff 100%)}@media only screen and (max-width:782px),(max-width:980px) and (min-width:851px){.butterbean-manager-default{background:linear-gradient(90deg,#fafafa 0,#fafafa 48px,#fff 48px,#fff 100%)}}.butterbean-manager-default .butterbean-nav{position:relative;float:left;list-style:none;width:180px;line-height:1em;margin:0 0 -1px 0;padding:0;background-color:#fafafa;border-right:1px solid #eee;box-sizing:border-box}.butterbean-manager-default .butterbean-nav li{display:block;position:relative;margin:0;padding:0;line-height:20px}.butterbean-manager-default .butterbean-nav li a{display:block;margin:0;padding:10px;line-height:20px!important;text-decoration:none;border-bottom:1px solid #eee;box-shadow:none}.butterbean-manager-default .butterbean-nav .dashicons{line-height:20px;margin-right:3px}.butterbean-manager-default .butterbean-nav li[aria-selected=true] a{position:relative;font-weight:700;color:#555;background-color:#e0e0e0}@media only screen and (max-width:782px),(max-width:980px) and (min-width:851px){.butterbean-manager-default .butterbean-nav{width:48px}.butterbean-manager-default .butterbean-nav .dashicons{width:24px;height:24px;font-size:24px;line-height:24px}.butterbean-manager-default .butterbean-nav .dashicons::before{width:24px;height:24px}.butterbean-manager-default .butterbean-nav .label{overflow:hidden;position:absolute;top:-1000em;left:-1000em;width:1px;height:1px}}.butterbean-manager-default .butterbean-content{float:left;width:calc(100% - 180px);margin-left:-1px;border-left:1px solid #eee}@media only screen and (max-width:782px),(max-width:980px) and (min-width:851px){.butterbean-manager-default .butterbean-content{width:calc(100% - 48px)}}@media only screen and (min-width:850px){#side-sortables .butterbean-manager-default{background:#fff}#side-sortables .butterbean-manager-default .butterbean-content{width:100%}#side-sortables .butterbean-manager-default .butterbean-nav{display:table;width:100%}#side-sortables .butterbean-manager-default .butterbean-nav li{display:table-cell;text-align:center;border-right:1px solid #eee}#side-sortables .butterbean-manager-default .butterbean-nav li:last-of-type{border-right:0}#side-sortables .butterbean-manager-default .butterbean-nav li a{padding:10px 0}#side-sortables .butterbean-manager-default .butterbean-nav .dashicons{width:24px;height:24px;font-size:24px;line-height:24px}#side-sortables .butterbean-manager-default .butterbean-nav .dashicons::before{width:24px;height:24px}#side-sortables .butterbean-manager-default .butterbean-nav .label{overflow:hidden;position:absolute;top:-1000em;left:-1000em;width:1px;height:1px}}.butterbean-manager-default .butterbean-section{padding:12px 12px 0;box-sizing:border-box}.butterbean-manager-default .butterbean-section[aria-hidden=true]{display:none}.butterbean-manager-default .butterbean-section[aria-hidden=false]{display:block}.butterbean-manager-default .butterbean-control{margin-bottom:20px}.butterbean-manager-default .butterbean-label{display:block!important;font-weight:700;display:inline-block;margin-bottom:4px}.butterbean-manager-default .butterbean-control-checkbox .butterbean-label{display:inline!important}.butterbean-manager-default .butterbean-description{display:block;font-style:italic;margin-top:4px}.butterbean-manager-default .butterbean-label+.butterbean-description{margin-top:0;margin-bottom:4px}.butterbean-control-image .butterbean-img{display:block;max-width:100%;max-height:300px;height:auto}.butterbean-placeholder{width:100%;position:relative;text-align:center;padding:9px 0;line-height:20px;border:1px dashed #b4b9be;box-sizing:border-box}.butterbean-control-textarea textarea,.butterbean-control-excerpt textarea{display:block;width:100%;height:105px}.butterbean-control-datetime select{vertical-align:top}.butterbean-control-palette label{display:block;padding:0 10px 10px}.butterbean-control-palette label[aria-selected=true]{padding-top:5px;background-color:#ddd}.butterbean-palette-label{line-height:28px}.butterbean-palette-block{display:table;width:100%;height:45px;border:1px solid #eee;box-sizing:border-box}.butterbean-palette-color{display:table-cell;height:100%}.butterbean-control-radio-image input[type=radio]{clip:rect(1px,1px,1px,1px);height:1px;overflow:hidden;position:absolute!important;width:1px}.butterbean-control-radio-image img{box-sizing:border-box;max-width:100%;height:auto;padding:1px;border:4px solid transparent}.butterbean-control-radio-image img:hover,.butterbean-control-radio-image img:focus{border-color:#ccc}.butterbean-control-radio-image input:checked+span+img{border-color:#00a0d2}.butterbean-multi-avatars-wrapLine truncated
|
||||
@@ -0,0 +1,110 @@
|
||||
[08-Nov-2025 01:43:48 UTC] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[08-Nov-2025 01:43:48 UTC] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[15-Nov-2025 02:56:16 UTC] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[15-Nov-2025 02:56:16 UTC] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[11-Dec-2025 17:25:36 UTC] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[11-Dec-2025 17:25:36 UTC] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[22-Feb-2026 00:42:17 UTC] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[22-Feb-2026 00:42:47 UTC] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[20-May-2026 08:04:30 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[20-May-2026 08:04:30 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[15-Jul-2026 14:30:10 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[15-Jul-2026 14:30:10 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[16-Jul-2026 13:44:12 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[16-Jul-2026 13:44:15 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[21-Aug-2026 12:44:51 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[21-Aug-2026 12:44:51 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[22-Aug-2026 01:26:17 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[22-Aug-2026 01:26:17 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
[24-Aug-2026 19:03:09 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function add_action() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/butterbean.php on line 19
|
||||
[24-Aug-2026 19:03:09 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function apply_filters() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php:144
|
||||
Stack trace:
|
||||
#0 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(118): ButterBean->setup()
|
||||
#1 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(862): ButterBean::get_instance()
|
||||
#2 /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php(866): butterbean()
|
||||
#3 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/class-butterbean.php on line 144
|
||||
@@ -0,0 +1,399 @@
|
||||
<?php
|
||||
/**
|
||||
* Base class for handling controls. Controls are the form fields for the manager. Each
|
||||
* control should be tied to a section.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control {
|
||||
|
||||
/**
|
||||
* Stores the manager object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
public $manager;
|
||||
|
||||
/**
|
||||
* Name/ID of the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $name = '';
|
||||
|
||||
/**
|
||||
* Label for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $label = '';
|
||||
|
||||
/**
|
||||
* Description for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $description = '';
|
||||
|
||||
/**
|
||||
* ID of the section the control is for.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $section = '';
|
||||
|
||||
/**
|
||||
* The setting key for the specific setting the control is tied to.
|
||||
* Controls can have multiple settings attached to them. The default
|
||||
* setting is `default`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $setting = 'default';
|
||||
|
||||
/**
|
||||
* Array of settings if the control has multiple settings.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $settings = array();
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'text';
|
||||
|
||||
/**
|
||||
* Form field attributes.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $attr = '';
|
||||
|
||||
/**
|
||||
* Choices for fields with multiple choices.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $choices = array();
|
||||
|
||||
/**
|
||||
* Priority (order) the control should be output.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var int
|
||||
*/
|
||||
public $priority = 10;
|
||||
|
||||
/**
|
||||
* The number of instances created.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var int
|
||||
*/
|
||||
protected static $instance_count = 0;
|
||||
|
||||
/**
|
||||
* The instance of the current control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var int
|
||||
*/
|
||||
public $instance_number;
|
||||
|
||||
/**
|
||||
* A callback function for deciding if a control is active.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var callable
|
||||
*/
|
||||
public $active_callback = '';
|
||||
|
||||
/**
|
||||
* A user role capability required to show the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $capability = '';
|
||||
|
||||
/**
|
||||
* A feature that the current post type must support to show the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $post_type_supports = '';
|
||||
|
||||
/**
|
||||
* A feature that the current theme must support to show the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $theme_supports = '';
|
||||
|
||||
/**
|
||||
* Stores the JSON data for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array()
|
||||
*/
|
||||
public $json = array();
|
||||
|
||||
/**
|
||||
* Creates a new control object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object $manager
|
||||
* @param string $name
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $manager, $name, $args = array() ) {
|
||||
|
||||
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
||||
|
||||
if ( isset( $args[ $key ] ) )
|
||||
$this->$key = $args[ $key ];
|
||||
}
|
||||
|
||||
$this->manager = $manager;
|
||||
$this->name = $name;
|
||||
|
||||
if ( empty( $args['settings'] ) || ! is_array( $args['settings'] ) )
|
||||
$this->settings['default'] = $name;
|
||||
|
||||
// Increment the instance count and set the instance number.
|
||||
self::$instance_count += 1;
|
||||
$this->instance_number = self::$instance_count;
|
||||
|
||||
// Set the active callback function if not set.
|
||||
if ( ! $this->active_callback )
|
||||
$this->active_callback = array( $this, 'active_callback' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts/styles for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {}
|
||||
|
||||
/**
|
||||
* Get the value for the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_value( $setting = 'default' ) {
|
||||
|
||||
$setting = $this->get_setting( $setting );
|
||||
|
||||
return $setting ? $setting->get_value() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the setting object associated with this control. If no setting is
|
||||
* found, `false` is returned.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return object|bool
|
||||
*/
|
||||
public function get_setting( $setting = 'default' ) {
|
||||
|
||||
return $this->manager->get_setting( $this->settings[ $setting ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attributes for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_attr() {
|
||||
|
||||
$defaults = array();
|
||||
|
||||
if ( isset( $this->settings[ $this->setting ] ) )
|
||||
$defaults['name'] = $this->get_field_name( $this->setting );
|
||||
|
||||
return wp_parse_args( $this->attr, $defaults );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML field name for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return array
|
||||
*/
|
||||
public function get_field_name( $setting = 'default' ) {
|
||||
|
||||
return "butterbean_{$this->manager->name}_setting_{$this->settings[ $setting ]}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the json array.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_json() {
|
||||
$this->to_json();
|
||||
|
||||
return $this->json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
|
||||
$this->json['manager'] = $this->manager->name;
|
||||
$this->json['section'] = $this->section;
|
||||
$this->json['setting'] = $this->setting;
|
||||
$this->json['settings'] = $this->settings;
|
||||
$this->json['name'] = $this->name;
|
||||
$this->json['label'] = $this->label;
|
||||
$this->json['type'] = $this->type;
|
||||
$this->json['description'] = $this->description;
|
||||
$this->json['choices'] = $this->choices;
|
||||
$this->json['active'] = $this->is_active();
|
||||
|
||||
$this->json['value'] = isset( $this->settings[ $this->setting ] ) ? $this->get_value( $this->setting ) : '';
|
||||
$this->json['field_name'] = isset( $this->settings[ $this->setting ] ) ? $this->get_field_name( $this->setting ) : '';
|
||||
|
||||
$this->json['attr'] = '';
|
||||
|
||||
foreach ( $this->get_attr() as $attr => $value ) {
|
||||
$this->json['attr'] .= sprintf( '%s="%s" ', esc_html( $attr ), esc_attr( $value ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the control is active.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function is_active() {
|
||||
|
||||
$is_active = call_user_func( $this->active_callback, $this );
|
||||
|
||||
return apply_filters( 'butterbean_is_control_active', $is_active, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Default active callback.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function active_callback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the control should be allowed at all.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function check_capabilities() {
|
||||
|
||||
if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
|
||||
return false;
|
||||
|
||||
if ( $this->post_type_supports && ! call_user_func_array( 'post_type_supports', array( get_post_type( $this->manager->post_id ), $this->post_type_supports ) ) )
|
||||
return false;
|
||||
|
||||
if ( $this->theme_supports && ! call_user_func_array( 'theme_supports', (array) $this->theme_supports ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints Underscore.js template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function print_template() { ?>
|
||||
|
||||
<script type="text/html" id="tmpl-butterbean-control-<?php echo esc_attr( $this->type ); ?>">
|
||||
<?php $this->get_template(); ?>
|
||||
</script>
|
||||
<?php }
|
||||
|
||||
/**
|
||||
* Gets the Underscore.js template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get_template() {
|
||||
butterbean_get_control_template( $this->type );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,550 @@
|
||||
<?php
|
||||
/**
|
||||
* Base class for handling managers. Managers are groups of sections, which are groups of
|
||||
* controls + settings. Managers are output as a metabox. This essentially allows
|
||||
* developers to output multiple post meta fields within a single metabox.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base manager class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Manager {
|
||||
|
||||
/**
|
||||
* The type of manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'default';
|
||||
|
||||
/**
|
||||
* Name of this instance of the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $name = '';
|
||||
|
||||
/**
|
||||
* Label for the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $label = '';
|
||||
|
||||
/**
|
||||
* Post type this manager is used on.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $post_type = 'post';
|
||||
|
||||
/**
|
||||
* Location of the meta box. Accepted values: 'normal', 'advanced', 'side'.
|
||||
*
|
||||
* @link https://developer.wordpress.org/reference/functions/add_meta_box/
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $context = 'advanced';
|
||||
|
||||
/**
|
||||
* Priority of the meta box. Accepted values: 'high', 'core', 'default', 'low'.
|
||||
*
|
||||
* @link https://developer.wordpress.org/reference/functions/add_meta_box/
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $priority = 'default';
|
||||
|
||||
/**
|
||||
* Array of sections.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $sections = array();
|
||||
|
||||
/**
|
||||
* Array of controls.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $controls = array();
|
||||
|
||||
/**
|
||||
* Array of settings.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $settings = array();
|
||||
|
||||
/**
|
||||
* A user role capability required to show the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $capability = '';
|
||||
|
||||
/**
|
||||
* A feature that the current post type must support to show the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $post_type_supports = '';
|
||||
|
||||
/**
|
||||
* A feature that the current theme must support to show the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $theme_supports = '';
|
||||
|
||||
/**
|
||||
* Stores the JSON data for the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array()
|
||||
*/
|
||||
public $json = array();
|
||||
|
||||
/**
|
||||
* ID of the post that's being edited.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var int
|
||||
*/
|
||||
public $post_id = 0;
|
||||
|
||||
/**
|
||||
* Sets up the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $name, $args = array() ) {
|
||||
|
||||
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
||||
|
||||
if ( isset( $args[ $key ] ) )
|
||||
$this->$key = $args[ $key ];
|
||||
}
|
||||
|
||||
// Make sure the post type is an array.
|
||||
$this->post_type = (array) $this->post_type;
|
||||
|
||||
// Set the manager name.
|
||||
$this->name = sanitize_key( $name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts/styles for the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {}
|
||||
|
||||
/**
|
||||
* Register a section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object|string $section
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function register_section( $section, $args = array() ) {
|
||||
|
||||
if ( ! is_object( $section ) ) {
|
||||
|
||||
$type = isset( $args['type'] ) ? butterbean()->get_section_type( $args['type'] ) : butterbean()->get_section_type( 'default' );
|
||||
|
||||
$section = new $type( $this, $section, $args );
|
||||
}
|
||||
|
||||
if ( ! $this->section_exists( $section->name ) )
|
||||
$this->sections[ $section->name ] = $section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object|string $control
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function register_control( $control, $args = array() ) {
|
||||
|
||||
if ( ! is_object( $control ) ) {
|
||||
|
||||
$type = isset( $args['type'] ) ? butterbean()->get_control_type( $args['type'] ) : butterbean()->get_control_type( 'default' );
|
||||
|
||||
$control = new $type( $this, $control, $args );
|
||||
}
|
||||
|
||||
if ( ! $this->control_exists( $control->name ) )
|
||||
$this->controls[ $control->name ] = $control;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object|string $setting
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function register_setting( $setting, $args = array() ) {
|
||||
|
||||
if ( ! is_object( $setting ) ) {
|
||||
|
||||
$type = isset( $args['type'] ) ? butterbean()->get_setting_type( $args['type'] ) : butterbean()->get_setting_type( 'default' );
|
||||
|
||||
$setting = new $type( $this, $setting, $args );
|
||||
}
|
||||
|
||||
if ( ! $this->setting_exists( $setting->name ) )
|
||||
$this->settings[ $setting->name ] = $setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a control and setting object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @param object|array $control Control object or array of control arguments.
|
||||
* @param object|array $setting Setting object or array of setting arguments.
|
||||
* @return void
|
||||
*/
|
||||
public function register_field( $name, $control, $setting ) {
|
||||
|
||||
is_object( $control ) ? $this->register_control( $control ) : $this->register_control( $name, $control );
|
||||
is_object( $setting ) ? $this->register_setting( $setting ) : $this->register_setting( $name, $setting );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a section object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_section( $name ) {
|
||||
|
||||
if ( $this->section_exists( $name ) )
|
||||
unset( $this->sections[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a control object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_control( $name ) {
|
||||
|
||||
if ( $this->control_exists( $name ) )
|
||||
unset( $this->controls[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a setting object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_setting( $name ) {
|
||||
|
||||
if ( $this->setting_exists( $name ) )
|
||||
unset( $this->settings[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a control and setting object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return void
|
||||
*/
|
||||
public function unregister_field( $name ) {
|
||||
|
||||
$this->unregister_control( $name );
|
||||
$this->unregister_setting( $name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a section object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return object|bool
|
||||
*/
|
||||
public function get_section( $name ) {
|
||||
|
||||
return $this->section_exists( $name ) ? $this->sections[ $name ] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a control object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return object|bool
|
||||
*/
|
||||
public function get_control( $name ) {
|
||||
|
||||
return $this->control_exists( $name ) ? $this->controls[ $name ] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a setting object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return object|bool
|
||||
*/
|
||||
public function get_setting( $name ) {
|
||||
|
||||
return $this->setting_exists( $name ) ? $this->settings[ $name ] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object that contains both the control and setting objects.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return object|bool
|
||||
*/
|
||||
public function get_field( $name ) {
|
||||
|
||||
$control = $this->get_control( $name );
|
||||
$setting = $this->get_setting( $name );
|
||||
|
||||
$field = array( 'name' => $name, 'control' => $control, 'setting' => $setting );
|
||||
|
||||
return $control && $setting ? (object) $field : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a section exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function section_exists( $name ) {
|
||||
|
||||
return isset( $this->sections[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a control exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function control_exists( $name ) {
|
||||
|
||||
return isset( $this->controls[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a setting exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function setting_exists( $name ) {
|
||||
|
||||
return isset( $this->settings[ $name ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a both a control and setting exist.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function field_exists( $name ) {
|
||||
|
||||
return $this->control_exists( $name ) && $this->setting_exists( $name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the json array.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_json() {
|
||||
$this->to_json();
|
||||
|
||||
return $this->json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom data to the JSON array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
|
||||
$sections_with_controls = array();
|
||||
$blocked_sections = array();
|
||||
|
||||
$this->json['name'] = $this->name;
|
||||
$this->json['type'] = $this->type;
|
||||
|
||||
// Get all sections that have controls.
|
||||
foreach ( $this->controls as $control )
|
||||
$sections_with_controls[] = $control->section;
|
||||
|
||||
$sections_with_controls = array_unique( $sections_with_controls );
|
||||
|
||||
// Get the JSON data for each section.
|
||||
foreach ( $this->sections as $section ) {
|
||||
|
||||
$caps = $section->check_capabilities();
|
||||
|
||||
if ( $caps && in_array( $section->name, $sections_with_controls ) )
|
||||
$this->json['sections'][] = $section->get_json();
|
||||
|
||||
if ( ! $caps )
|
||||
$blocked_sections[] = $section->name;
|
||||
}
|
||||
|
||||
// Get the JSON data for each control.
|
||||
foreach ( $this->controls as $control ) {
|
||||
|
||||
if ( $control->check_capabilities() && ! in_array( $control->section, $blocked_sections ) )
|
||||
$this->json['controls'][] = $control->get_json();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves each of the settings for the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function save( $post_id ) {
|
||||
|
||||
if ( ! $this->post_id )
|
||||
$this->post_id = $post_id;
|
||||
|
||||
// Verify the nonce for this manager.
|
||||
if ( ! isset( $_POST["butterbean_{$this->name}"] ) || ! wp_verify_nonce( $_POST["butterbean_{$this->name}"], "butterbean_{$this->name}_nonce" ) )
|
||||
return;
|
||||
|
||||
// Loop through each setting and save it.
|
||||
foreach ( $this->settings as $setting )
|
||||
$setting->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the control should be allowed at all.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function check_capabilities() {
|
||||
|
||||
if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
|
||||
return false;
|
||||
|
||||
if ( $this->post_type_supports && ! call_user_func_array( 'post_type_supports', array( get_post_type( $this->manager->post_id ), $this->post_type_supports ) ) )
|
||||
return false;
|
||||
|
||||
if ( $this->theme_supports && ! call_user_func_array( 'theme_supports', (array) $this->theme_supports ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints Underscore.js template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function print_template() { ?>
|
||||
|
||||
<script type="text/html" id="tmpl-butterbean-manager-<?php echo esc_attr( $this->type ); ?>">
|
||||
<?php $this->get_template(); ?>
|
||||
</script>
|
||||
<?php }
|
||||
|
||||
/**
|
||||
* Gets the Underscore.js template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get_template() {
|
||||
butterbean_get_manager_template( $this->type );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,291 @@
|
||||
<?php
|
||||
/**
|
||||
* Base class for handling sections. Sections house groups of controls. Multiple sections can
|
||||
* be added to a manager.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base section class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Section {
|
||||
|
||||
/**
|
||||
* Stores the project details manager object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
public $manager;
|
||||
|
||||
/**
|
||||
* Name/ID of the section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $name = '';
|
||||
|
||||
/**
|
||||
* The type of section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'default';
|
||||
|
||||
/**
|
||||
* Dashicons icon for the section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $icon = 'dashicons-admin-generic';
|
||||
|
||||
/**
|
||||
* Label for the section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $label = '';
|
||||
|
||||
/**
|
||||
* Description for the section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $description = '';
|
||||
|
||||
/**
|
||||
* Priority (order) the section should be output.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var int
|
||||
*/
|
||||
public $priority = 10;
|
||||
|
||||
/**
|
||||
* The number of instances created.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access protected
|
||||
* @var int
|
||||
*/
|
||||
protected static $instance_count = 0;
|
||||
|
||||
/**
|
||||
* The instance of the current section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var int
|
||||
*/
|
||||
public $instance_number;
|
||||
|
||||
/**
|
||||
* A callback function for deciding if a section is active.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var callable
|
||||
*/
|
||||
public $active_callback = '';
|
||||
|
||||
/**
|
||||
* A user role capability required to show the section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $capability = '';
|
||||
|
||||
/**
|
||||
* A feature that the current post type must support to show the section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $post_type_supports = '';
|
||||
|
||||
/**
|
||||
* A feature that the current theme must support to show the section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $theme_supports = '';
|
||||
|
||||
/**
|
||||
* Stores the JSON data for the manager.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array()
|
||||
*/
|
||||
public $json = array();
|
||||
|
||||
/**
|
||||
* Creates a new section object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object $manager
|
||||
* @param string $section
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $manager, $name, $args = array() ) {
|
||||
|
||||
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
||||
|
||||
if ( isset( $args[ $key ] ) )
|
||||
$this->$key = $args[ $key ];
|
||||
}
|
||||
|
||||
$this->manager = $manager;
|
||||
$this->name = $name;
|
||||
|
||||
// Increment the instance count and set the instance number.
|
||||
self::$instance_count += 1;
|
||||
$this->instance_number = self::$instance_count;
|
||||
|
||||
// Set the active callback function if not set.
|
||||
if ( ! $this->active_callback )
|
||||
$this->active_callback = array( $this, 'active_callback' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts/styles for the section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {}
|
||||
|
||||
/**
|
||||
* Returns the json array.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_json() {
|
||||
$this->to_json();
|
||||
|
||||
return $this->json;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
|
||||
$this->json['manager'] = $this->manager->name;
|
||||
$this->json['name'] = $this->name;
|
||||
$this->json['type'] = $this->type;
|
||||
$this->json['icon'] = preg_match( '/dashicons-/', $this->icon ) ? sprintf( 'dashicons %s', sanitize_html_class( $this->icon ) ) : esc_attr( $this->icon );
|
||||
$this->json['label'] = $this->label;
|
||||
$this->json['description'] = $this->description;
|
||||
$this->json['active'] = $this->is_active();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the section is active.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function is_active() {
|
||||
|
||||
$is_active = call_user_func( $this->active_callback, $this );
|
||||
|
||||
if ( $is_active )
|
||||
$is_active = $this->check_capabilities();
|
||||
|
||||
return apply_filters( 'butterbean_is_section_active', $is_active, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Default active callback.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function active_callback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the section should be allowed at all.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function check_capabilities() {
|
||||
|
||||
if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
|
||||
return false;
|
||||
|
||||
if ( $this->post_type_supports && ! call_user_func_array( 'post_type_supports', array( get_post_type( $this->manager->post_id ), $this->post_type_supports ) ) )
|
||||
return false;
|
||||
|
||||
if ( $this->theme_supports && ! call_user_func_array( 'theme_supports', (array) $this->theme_supports ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints Underscore.js template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function print_template() { ?>
|
||||
|
||||
<script type="text/html" id="tmpl-butterbean-section-<?php echo esc_attr( $this->type ); ?>">
|
||||
<?php $this->get_template(); ?>
|
||||
</script>
|
||||
<?php }
|
||||
|
||||
/**
|
||||
* Gets the Underscore.js template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get_template() {
|
||||
butterbean_get_section_template( $this->type );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
<?php
|
||||
/**
|
||||
* Base setting class for the fields manager.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base setting class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Setting {
|
||||
|
||||
/**
|
||||
* The type of setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'default';
|
||||
|
||||
/**
|
||||
* Stores the manager object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
public $manager;
|
||||
|
||||
/**
|
||||
* Name/ID of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $name = '';
|
||||
|
||||
/**
|
||||
* Value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $value = '';
|
||||
|
||||
/**
|
||||
* Default value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $default = '';
|
||||
|
||||
/**
|
||||
* Sanitization/Validation callback function.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $sanitize_callback = '';
|
||||
|
||||
/**
|
||||
* A user role capability required to save the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $capability = '';
|
||||
|
||||
/**
|
||||
* A feature that the current post type must support to save the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $post_type_supports = '';
|
||||
|
||||
/**
|
||||
* A feature that the current theme must support to save the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string|array
|
||||
*/
|
||||
public $theme_supports = '';
|
||||
|
||||
/**
|
||||
* Creates a new setting object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object $manager
|
||||
* @param string $cap
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $manager, $name, $args = array() ) {
|
||||
|
||||
foreach ( array_keys( get_object_vars( $this ) ) as $key ) {
|
||||
|
||||
if ( isset( $args[ $key ] ) )
|
||||
$this->$key = $args[ $key ];
|
||||
}
|
||||
|
||||
$this->manager = $manager;
|
||||
$this->name = $name;
|
||||
|
||||
if ( $this->sanitize_callback )
|
||||
add_filter( "butterbean_{$this->manager->name}_sanitize_{$this->name}", $this->sanitize_callback, 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_value() {
|
||||
|
||||
$value = get_post_meta( $this->manager->post_id, $this->name, true );
|
||||
|
||||
return ! $value && butterbean()->is_new_post ? $this->default : $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the posted value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_posted_value() {
|
||||
|
||||
$value = '';
|
||||
|
||||
if ( isset( $_POST[ $this->get_field_name() ] ) )
|
||||
$value = $_POST[ $this->get_field_name() ];
|
||||
|
||||
return $this->sanitize( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retuns the correct field name for the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function get_field_name() {
|
||||
|
||||
return "butterbean_{$this->manager->name}_setting_{$this->name}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes the value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function sanitize( $value ) {
|
||||
|
||||
return apply_filters( "butterbean_{$this->manager->name}_sanitize_{$this->name}", $value, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function save() {
|
||||
|
||||
if ( ! $this->check_capabilities() )
|
||||
return;
|
||||
|
||||
$old_value = $this->get_value();
|
||||
$new_value = $this->get_posted_value();
|
||||
|
||||
// If we have don't have a new value but do have an old one, delete it.
|
||||
if ( ! $new_value && $old_value )
|
||||
delete_post_meta( $this->manager->post_id, $this->name );
|
||||
|
||||
// If the new value doesn't match the old value, set it.
|
||||
else if ( $new_value !== $old_value )
|
||||
update_post_meta( $this->manager->post_id, $this->name, $new_value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the setting should be saved at all.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function check_capabilities() {
|
||||
|
||||
if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
|
||||
return false;
|
||||
|
||||
if ( $this->post_type_supports && ! call_user_func_array( 'post_type_supports', array( get_post_type( $this->manager->post_id ), $this->post_type_supports ) ) )
|
||||
return false;
|
||||
|
||||
if ( $this->theme_supports && ! call_user_func_array( 'theme_supports', (array) $this->theme_supports ) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Multiple checkbox control class. This is for array-type settings, so you'll need
|
||||
* to utilize a setting type that handles arrays. Both the `array` and `multiple`
|
||||
* setting types will do this.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Multiple checkboxes control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_CheckBoxes extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'checkboxes';
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json['value'] = (array) $this->get_value();
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
/**
|
||||
* Color control class. This class uses the core WordPress color picker. Expected
|
||||
* values are hex colors. This class also attempts to strip `#` from the hex color.
|
||||
* By design, it's recommended to add the `#` on output.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Color control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Color extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'color';
|
||||
|
||||
/**
|
||||
* Custom options to pass to the color picker. Mostly, this is a wrapper for
|
||||
* `iris()`, which is bundled with core WP. However, if they change pickers
|
||||
* in the future, it may correspond to a different script.
|
||||
*
|
||||
* @link http://automattic.github.io/Iris/#options
|
||||
* @link https://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var array
|
||||
*/
|
||||
public $options = array();
|
||||
|
||||
/**
|
||||
* Enqueue scripts/styles for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
wp_enqueue_script( 'wp-color-picker' );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attributes for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_attr() {
|
||||
$attr = parent::get_attr();
|
||||
|
||||
$setting = $this->get_setting();
|
||||
|
||||
$attr['class'] = 'butterbean-color-picker';
|
||||
$attr['type'] = 'text';
|
||||
$attr['maxlength'] = 7;
|
||||
$attr['data-default-color'] = $setting ? $setting->default : '';
|
||||
|
||||
return $attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value for the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_value( $setting = 'default' ) {
|
||||
|
||||
$value = parent::get_value( $setting );
|
||||
|
||||
return ltrim( $value, '#' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json['options'] = $this->options;
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* Date control class.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Date control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Date extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'date';
|
||||
|
||||
/**
|
||||
* Whether to show the time. Note that settings, particularly the
|
||||
* `ButterBean_Setting_Date` class will store the time as `00:00:00` if
|
||||
* no time is provided.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var bool
|
||||
*/
|
||||
public $show_time = true;
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @globl object $wp_locale
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
global $wp_locale;
|
||||
|
||||
parent::to_json();
|
||||
|
||||
$this->json['show_time'] = $this->show_time;
|
||||
|
||||
$field_name = $this->get_field_name();
|
||||
|
||||
// Get project start/end dates.
|
||||
$date = $this->get_value();
|
||||
|
||||
// Get the year, month, and day.
|
||||
$year = $date ? mysql2date( 'Y', $date, false ) : '';
|
||||
$month = $date ? mysql2date( 'm', $date, false ) : '';
|
||||
$day = $date ? mysql2date( 'd', $date, false ) : '';
|
||||
|
||||
// Get the hour, minute, and second.
|
||||
$hour = $date ? mysql2date( 'H', $date, false ) : '';
|
||||
$minute = $date ? mysql2date( 'i', $date, false ) : '';
|
||||
$second = $date ? mysql2date( 's', $date, false ) : '';
|
||||
|
||||
// Year
|
||||
$this->json['year'] = array(
|
||||
'value' => esc_attr( $year ),
|
||||
'label' => esc_html__( 'Year', 'butterbean' ),
|
||||
'name' => esc_attr( "{$field_name}_year" ),
|
||||
'attr' => sprintf( 'placeholder="%s" size="4" maxlength="4" autocomplete="off"', esc_attr( date_i18n( 'Y' ) ) )
|
||||
);
|
||||
|
||||
// Month
|
||||
$this->json['month'] = array(
|
||||
'value' => esc_attr( $month ),
|
||||
'name' => esc_attr( "{$field_name}_month" ),
|
||||
'label' => esc_html__( 'Month', 'butterbean' ),
|
||||
'choices' => array(
|
||||
array(
|
||||
'num' => '',
|
||||
'label' => ''
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
for ( $i = 1; $i < 13; $i = $i +1 ) {
|
||||
|
||||
$monthnum = zeroise( $i, 2 );
|
||||
$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
|
||||
|
||||
$this->json['month']['choices'][] = array(
|
||||
'num' => $monthnum,
|
||||
'label' => $monthtext
|
||||
);
|
||||
}
|
||||
|
||||
// Day
|
||||
$this->json['day'] = array(
|
||||
'value' => esc_attr( $day ),
|
||||
'name' => esc_attr( "{$field_name}_day" ),
|
||||
'label' => esc_html__( 'Day', 'butterbean' ),
|
||||
'attr' => sprintf( 'placeholder="%s" size="2" maxlength="2" autocomplete="off"', esc_attr( date_i18n( 'd' ) ) )
|
||||
);
|
||||
|
||||
// Hour
|
||||
$this->json['hour'] = array(
|
||||
'value' => esc_attr( $hour ),
|
||||
'name' => esc_attr( "{$field_name}_hour" ),
|
||||
'label' => esc_html__( 'Hour', 'butterbean' ),
|
||||
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
|
||||
);
|
||||
|
||||
// Minute
|
||||
$this->json['minute'] = array(
|
||||
'value' => esc_attr( $minute ),
|
||||
'name' => esc_attr( "{$field_name}_minute" ),
|
||||
'label' => esc_html__( 'Minute', 'butterbean' ),
|
||||
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
|
||||
);
|
||||
|
||||
// Second
|
||||
$this->json['second'] = array(
|
||||
'value' => esc_attr( $second ),
|
||||
'name' => esc_attr( "{$field_name}_second" ),
|
||||
'label' => esc_html__( 'Second', 'butterbean' ),
|
||||
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
|
||||
);
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* Datetime control class. This class is meant for storing a datetime in the format
|
||||
* of `YYYY-MM-DD HH:MM:SS` or `0000-00-00 00:00:00`. You can set the `$show_time`
|
||||
* property to `false`.
|
||||
*
|
||||
* Note that this control should be used in conjunction with the `datetime` setting
|
||||
* type or another custom class that can handle the datetime.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Datetime control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Datetime extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'datetime';
|
||||
|
||||
/**
|
||||
* Whether to show the time. Note that settings, particularly the
|
||||
* `ButterBean_Setting_Date` class will store the time as `00:00:00` if
|
||||
* no time is provided.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var bool
|
||||
*/
|
||||
public $show_time = true;
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @globl object $wp_locale
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
global $wp_locale;
|
||||
|
||||
parent::to_json();
|
||||
|
||||
$this->json['show_time'] = $this->show_time;
|
||||
|
||||
$field_name = $this->get_field_name();
|
||||
|
||||
// Get project start/end dates.
|
||||
$date = $this->get_value();
|
||||
|
||||
// Get the year, month, and day.
|
||||
$year = $date ? mysql2date( 'Y', $date, false ) : '';
|
||||
$month = $date ? mysql2date( 'm', $date, false ) : '';
|
||||
$day = $date ? mysql2date( 'd', $date, false ) : '';
|
||||
|
||||
// Get the hour, minute, and second.
|
||||
$hour = $date ? mysql2date( 'H', $date, false ) : '';
|
||||
$minute = $date ? mysql2date( 'i', $date, false ) : '';
|
||||
$second = $date ? mysql2date( 's', $date, false ) : '';
|
||||
|
||||
// Year
|
||||
$this->json['year'] = array(
|
||||
'value' => esc_attr( $year ),
|
||||
'label' => esc_html__( 'Year', 'butterbean' ),
|
||||
'name' => esc_attr( "{$field_name}_year" ),
|
||||
'attr' => sprintf( 'placeholder="%s" size="4" maxlength="4" autocomplete="off"', esc_attr( date_i18n( 'Y' ) ) )
|
||||
);
|
||||
|
||||
// Month
|
||||
$this->json['month'] = array(
|
||||
'value' => esc_attr( $month ),
|
||||
'name' => esc_attr( "{$field_name}_month" ),
|
||||
'label' => esc_html__( 'Month', 'butterbean' ),
|
||||
'choices' => array(
|
||||
array(
|
||||
'num' => '',
|
||||
'label' => ''
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
for ( $i = 1; $i < 13; $i = $i +1 ) {
|
||||
|
||||
$monthnum = zeroise( $i, 2 );
|
||||
$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
|
||||
|
||||
$this->json['month']['choices'][] = array(
|
||||
'num' => $monthnum,
|
||||
'label' => $monthtext
|
||||
);
|
||||
}
|
||||
|
||||
// Day
|
||||
$this->json['day'] = array(
|
||||
'value' => esc_attr( $day ),
|
||||
'name' => esc_attr( "{$field_name}_day" ),
|
||||
'label' => esc_html__( 'Day', 'butterbean' ),
|
||||
'attr' => sprintf( 'placeholder="%s" size="2" maxlength="2" autocomplete="off"', esc_attr( date_i18n( 'd' ) ) )
|
||||
);
|
||||
|
||||
// Hour
|
||||
$this->json['hour'] = array(
|
||||
'value' => esc_attr( $hour ),
|
||||
'name' => esc_attr( "{$field_name}_hour" ),
|
||||
'label' => esc_html__( 'Hour', 'butterbean' ),
|
||||
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
|
||||
);
|
||||
|
||||
// Minute
|
||||
$this->json['minute'] = array(
|
||||
'value' => esc_attr( $minute ),
|
||||
'name' => esc_attr( "{$field_name}_minute" ),
|
||||
'label' => esc_html__( 'Minute', 'butterbean' ),
|
||||
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
|
||||
);
|
||||
|
||||
// Second
|
||||
$this->json['second'] = array(
|
||||
'value' => esc_attr( $second ),
|
||||
'name' => esc_attr( "{$field_name}_second" ),
|
||||
'label' => esc_html__( 'Second', 'butterbean' ),
|
||||
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
|
||||
);
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/**
|
||||
* Excerpt control class. Note that this control isn't meant to be tied to a setting. Core
|
||||
* WP will save the excerpt. Also, make sure to disable the core excerpt metabox if using
|
||||
* this control.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Excerpt control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Excerpt extends ButterBean_Control_Textarea {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'excerpt';
|
||||
|
||||
/**
|
||||
* Gets the attributes for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function get_attr() {
|
||||
$attr = parent::get_attr();
|
||||
|
||||
$attr['id'] = 'post_excerpt';
|
||||
|
||||
return $attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML field name for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return string
|
||||
*/
|
||||
public function get_field_name( $setting = 'default' ) {
|
||||
return 'post_excerpt';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value for the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_value( $setting = 'default' ) {
|
||||
|
||||
return get_post( $this->manager->post_id )->post_excerpt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Underscore.js template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get_template() {
|
||||
butterbean_get_control_template( 'textarea' );
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
/**
|
||||
* Image control class. This control allows users to set an image. It passes the attachment
|
||||
* ID the setting, so you'll need a custom control class if you want to store anything else,
|
||||
* such as the URL or other data.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Image control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Image extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'image';
|
||||
|
||||
/**
|
||||
* Array of text labels to use for the media upload frame.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $l10n = array();
|
||||
|
||||
/**
|
||||
* Image size to display. If the size isn't found for the image,
|
||||
* the full size of the image will be output.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $size = 'large';
|
||||
|
||||
/**
|
||||
* Creates a new control object.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param object $manager
|
||||
* @param string $name
|
||||
* @param array $args
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $manager, $name, $args = array() ) {
|
||||
parent::__construct( $manager, $name, $args );
|
||||
|
||||
$this->l10n = wp_parse_args(
|
||||
$this->l10n,
|
||||
array(
|
||||
'upload' => esc_html__( 'Add image', 'butterbean' ),
|
||||
'set' => esc_html__( 'Set as image', 'butterbean' ),
|
||||
'choose' => esc_html__( 'Choose image', 'butterbean' ),
|
||||
'change' => esc_html__( 'Change image', 'butterbean' ),
|
||||
'remove' => esc_html__( 'Remove image', 'butterbean' ),
|
||||
'placeholder' => esc_html__( 'No image selected', 'butterbean' )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts/styles for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue() {
|
||||
|
||||
wp_enqueue_script( 'media-views' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json['l10n'] = $this->l10n;
|
||||
$this->json['size'] = $this->size;
|
||||
|
||||
$value = $this->get_value();
|
||||
$image = $alt = '';
|
||||
|
||||
if ( $value ) {
|
||||
$image = wp_get_attachment_image_src( absint( $value ), $this->size );
|
||||
$alt = get_post_meta( absint( $value ), '_wp_attachment_image_alt', true );
|
||||
}
|
||||
|
||||
$this->json['src'] = $image ? esc_url( $image[0] ) : '';
|
||||
$this->json['alt'] = $alt ? esc_attr( $alt ) : '';
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Multi-avatars control. This control is for outputting multiple users who can create,
|
||||
* edit, or publish posts of the given post type. Multiple users can be selected. The
|
||||
* data is expected to be an array. This control should be used with a setting type that
|
||||
* handles arrays, such as the built-in `array` or `multiple` types.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Multi-avatars control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Multi_Avatars extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'multi-avatars';
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json['value'] = is_array( $this->get_value() ) ? array_map( 'absint', $this->get_value() ) : array();
|
||||
$this->json['choices'] = array();
|
||||
|
||||
$users = get_users( array( 'role__in' => $this->get_roles() ) );
|
||||
|
||||
foreach ( $users as $user ) {
|
||||
$this->json['choices'][] = array(
|
||||
'id' => $user->ID,
|
||||
'name' => $user->display_name,
|
||||
'avatar' => get_avatar( $user->ID, 70 )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of user roles that are allowed to edit, publish, or create
|
||||
* posts of the given post type.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @global object $wp_roles
|
||||
* @return array
|
||||
*/
|
||||
public function get_roles() {
|
||||
global $wp_roles;
|
||||
|
||||
$roles = array();
|
||||
$type = get_post_type_object( get_post_type( $this->manager->post_id ) );
|
||||
|
||||
// Get the post type object caps.
|
||||
$caps = array( $type->cap->edit_posts, $type->cap->publish_posts, $type->cap->create_posts );
|
||||
$caps = array_unique( $caps );
|
||||
|
||||
// Loop through the available roles.
|
||||
foreach ( $wp_roles->roles as $name => $role ) {
|
||||
|
||||
foreach ( $caps as $cap ) {
|
||||
|
||||
// If the role is granted the cap, add it.
|
||||
if ( isset( $role['capabilities'][ $cap ] ) && true === $role['capabilities'][ $cap ] ) {
|
||||
$roles[] = $name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $roles;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Color palette control class. The purpose of this class is to give users a choice
|
||||
* of color palettes. The actual data that is stored is a key of your choosing.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Color palette control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Palette extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'palette';
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$value = $this->get_value();
|
||||
|
||||
// Make sure the colors have a hash.
|
||||
foreach ( $this->choices as $choice => $palette ) {
|
||||
$this->choices[ $choice ]['colors'] = array_map( 'butterbean_maybe_hash_hex_color', $palette['colors'] );
|
||||
|
||||
$this->choices[ $choice ]['selected'] = $value && $choice === $value;
|
||||
}
|
||||
|
||||
$this->json['choices'] = $this->choices;
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Post parent control class. This class is a specialty class meant for use in unique
|
||||
* scenarios where you're not using the core post parent drop-down. This is often the
|
||||
* case with flat post types that have a parent post. This control is not meant to be
|
||||
* used with a setting. Core WP will store the data in the `post.post_parent` field.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Post parent control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Parent extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'parent';
|
||||
|
||||
/**
|
||||
* The post type to select posts from.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $post_type = '';
|
||||
|
||||
/**
|
||||
* Returns the HTML field name for the control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return array
|
||||
*/
|
||||
public function get_field_name( $setting = 'default' ) {
|
||||
|
||||
return 'post_parent';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value for the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_value( $setting = 'default' ) {
|
||||
|
||||
return get_post( $this->manager->post_id )->post_parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$_post = get_post( $this->manager->post_id );
|
||||
|
||||
$posts = get_posts(
|
||||
array(
|
||||
'post_type' => $this->post_type ? $this->post_type : get_post_type( $this->manager->post_id ),
|
||||
'post_status' => 'any',
|
||||
'post__not_in' => array( $this->manager->post_id ),
|
||||
'posts_per_page' => -1,
|
||||
'post_parent' => 0,
|
||||
'orderby' => 'title',
|
||||
'order' => 'ASC',
|
||||
'fields' => array( 'ID', 'post_title' )
|
||||
)
|
||||
);
|
||||
|
||||
$this->json['choices'] = array( array( 'value' => 0, 'label' => '' ) );
|
||||
|
||||
foreach ( $posts as $post )
|
||||
$this->json['choices'][] = array( 'value' => $post->ID, 'label' => $post->post_title );
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Radio image control class extends the built-in radio control. This control is
|
||||
* meant for displaying an image instead of the radio fields.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Radio image control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Radio_Image extends ButterBean_Control_Radio {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'radio-image';
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
foreach ( $this->choices as $value => $args )
|
||||
$this->choices[ $value ]['url'] = esc_url( sprintf( $args['url'], get_template_directory_uri(), get_stylesheet_directory_uri() ) );
|
||||
|
||||
$this->json['choices'] = $this->choices;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Radio control class that creates a list of radio inputs to choose from.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Radio control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Radio extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'radio';
|
||||
|
||||
/**
|
||||
* Radio controls imply that a value should be set. Therefore, we will return
|
||||
* the default if there is no value.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $setting
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_value( $setting = 'default' ) {
|
||||
|
||||
$value = parent::get_value( $setting );
|
||||
$object = $this->get_setting( $setting );
|
||||
|
||||
return ! $value && $object ? $object->default : $value;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Select group control class. This works just like a normal select. However, it
|
||||
* allows for `<optgroup>` to be added.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Select group control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Select_Group extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'select-group';
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$choices = $group = array();
|
||||
|
||||
foreach ( $this->choices as $choice => $maybe_group ) {
|
||||
|
||||
if ( is_array( $maybe_group ) )
|
||||
$group[ $choice ] = $maybe_group;
|
||||
else
|
||||
$choices[ $choice ] = $maybe_group;
|
||||
}
|
||||
|
||||
$this->json['choices'] = $choices;
|
||||
$this->json['group'] = $group;
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Textarea control class.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Textarea control class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Control_Textarea extends ButterBean_Control {
|
||||
|
||||
/**
|
||||
* The type of control.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'textarea';
|
||||
|
||||
/**
|
||||
* Adds custom data to the json array. This data is passed to the Underscore template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function to_json() {
|
||||
parent::to_json();
|
||||
|
||||
$this->json['value'] = esc_textarea( $this->get_value() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,520 @@
|
||||
[08-Nov-2025 01:49:10 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[08-Nov-2025 01:49:10 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[08-Nov-2025 01:49:11 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[08-Nov-2025 01:49:12 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[08-Nov-2025 01:49:12 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[08-Nov-2025 01:49:14 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[08-Nov-2025 01:49:14 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[08-Nov-2025 01:49:15 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[08-Nov-2025 01:49:16 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[08-Nov-2025 01:49:17 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[08-Nov-2025 01:49:19 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[08-Nov-2025 01:49:19 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[08-Nov-2025 01:49:20 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[11-Dec-2025 17:28:04 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[11-Dec-2025 17:28:04 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[11-Dec-2025 17:28:04 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[11-Dec-2025 17:28:05 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[11-Dec-2025 17:28:05 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[11-Dec-2025 17:28:05 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[11-Dec-2025 17:28:05 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[11-Dec-2025 17:28:05 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[11-Dec-2025 17:28:05 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[11-Dec-2025 17:28:06 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[11-Dec-2025 17:28:06 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[11-Dec-2025 17:28:06 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[11-Dec-2025 17:28:06 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[22-Feb-2026 02:45:01 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[22-Feb-2026 02:45:06 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[22-Feb-2026 02:45:26 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[22-Feb-2026 02:45:36 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[22-Feb-2026 02:45:49 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[22-Feb-2026 02:45:53 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[22-Feb-2026 02:46:04 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[22-Feb-2026 02:46:11 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[22-Feb-2026 02:46:15 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[22-Feb-2026 02:46:19 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[22-Feb-2026 02:46:25 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[22-Feb-2026 02:46:59 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[22-Feb-2026 02:47:08 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[20-May-2026 08:05:12 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[20-May-2026 08:05:12 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[20-May-2026 08:05:12 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[15-Jul-2026 14:37:31 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[15-Jul-2026 14:37:32 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[15-Jul-2026 14:37:32 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[15-Jul-2026 14:37:33 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[15-Jul-2026 14:37:33 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[15-Jul-2026 14:37:34 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[15-Jul-2026 14:37:34 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[15-Jul-2026 14:37:35 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[15-Jul-2026 14:37:35 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[15-Jul-2026 14:37:36 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[15-Jul-2026 14:37:36 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[15-Jul-2026 14:37:37 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[15-Jul-2026 14:37:37 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[16-Jul-2026 15:57:21 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[16-Jul-2026 15:57:24 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[16-Jul-2026 15:57:33 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[16-Jul-2026 15:57:35 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[16-Jul-2026 15:57:38 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[16-Jul-2026 15:57:50 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[16-Jul-2026 15:58:01 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[16-Jul-2026 15:58:11 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[16-Jul-2026 15:58:15 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[16-Jul-2026 15:58:18 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[16-Jul-2026 15:58:37 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[16-Jul-2026 15:58:39 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[16-Jul-2026 15:58:39 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[21-Aug-2026 12:47:35 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[21-Aug-2026 12:47:35 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[21-Aug-2026 12:47:35 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[21-Aug-2026 12:47:36 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[21-Aug-2026 12:47:36 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[21-Aug-2026 12:47:36 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[21-Aug-2026 12:47:36 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[21-Aug-2026 12:47:36 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[21-Aug-2026 12:47:37 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[21-Aug-2026 12:47:37 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[21-Aug-2026 12:47:37 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[21-Aug-2026 12:47:37 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[21-Aug-2026 12:47:38 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[22-Aug-2026 01:29:06 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[22-Aug-2026 01:29:06 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[22-Aug-2026 01:29:06 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[22-Aug-2026 01:29:06 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[22-Aug-2026 01:29:06 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[22-Aug-2026 01:29:07 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[22-Aug-2026 01:29:07 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[22-Aug-2026 01:29:07 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[22-Aug-2026 01:29:07 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[22-Aug-2026 01:29:07 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[22-Aug-2026 01:29:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[22-Aug-2026 01:29:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[22-Aug-2026 01:29:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
[24-Aug-2026 19:05:02 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-checkboxes.php on line 20
|
||||
[24-Aug-2026 19:05:02 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-color.php on line 20
|
||||
[24-Aug-2026 19:05:02 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-date.php on line 19
|
||||
[24-Aug-2026 19:05:02 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php:24
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-datetime.php on line 24
|
||||
[24-Aug-2026 19:05:02 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Textarea' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-excerpt.php on line 21
|
||||
[24-Aug-2026 19:05:02 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-image.php on line 20
|
||||
[24-Aug-2026 19:05:02 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-multi-avatars.php on line 21
|
||||
[24-Aug-2026 19:05:03 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-palette.php on line 19
|
||||
[24-Aug-2026 19:05:03 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php:21
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-parent.php on line 21
|
||||
[24-Aug-2026 19:05:03 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control_Radio' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio-image.php on line 20
|
||||
[24-Aug-2026 19:05:03 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-radio.php on line 19
|
||||
[24-Aug-2026 19:05:03 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-select-group.php on line 19
|
||||
[24-Aug-2026 19:05:03 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Control' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php:19
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/controls/class-control-textarea.php on line 19
|
||||
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* Helper functions.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function for validating booleans before saving them as metadata. If the value is
|
||||
* `true`, we'll return a `1` to be stored as the meta value. Else, we return `false`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param mixed
|
||||
* @return bool|int
|
||||
*/
|
||||
function butterbean_validate_boolean( $value ) {
|
||||
|
||||
return wp_validate_boolean( $value ) ? 1 : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-WP 4.6 function for sanitizing hex colors.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $color
|
||||
* @return string
|
||||
*/
|
||||
function butterbean_sanitize_hex_color( $color ) {
|
||||
|
||||
if ( function_exists( 'sanitize_hex_color' ) )
|
||||
return sanitize_hex_color( $color );
|
||||
|
||||
return $color && preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ? $color : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-WP 4.6 function for sanitizing hex colors without a hash.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $color
|
||||
* @return string
|
||||
*/
|
||||
function butterbean_sanitize_hex_color_no_hash( $color ) {
|
||||
|
||||
if ( function_exists( 'sanitize_hex_color_no_hash' ) )
|
||||
return sanitize_hex_color_no_hash( $color );
|
||||
|
||||
$color = ltrim( $color, '#' );
|
||||
|
||||
if ( '' === $color )
|
||||
return '';
|
||||
|
||||
return butterbean_sanitize_hex_color( '#' . $color ) ? $color : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-WP 4.6 function for sanitizing a color and adding a hash.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $color
|
||||
* @return string
|
||||
*/
|
||||
function butterbean_maybe_hash_hex_color( $color ) {
|
||||
|
||||
if ( function_exists( 'maybe_hash_hex_color' ) )
|
||||
return maybe_hash_hex_color( $color );
|
||||
|
||||
if ( $unhashed = butterbean_sanitize_hex_color_no_hash( $color ) )
|
||||
return '#' . $unhashed;
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Underscore.js templates for managers.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $slug
|
||||
* @return void
|
||||
*/
|
||||
function butterbean_get_manager_template( $slug = '' ) {
|
||||
butterbean_get_template( 'manager', $slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Underscore.js templates for navs.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $slug
|
||||
* @return void
|
||||
*/
|
||||
function butterbean_get_nav_template( $slug = '' ) {
|
||||
butterbean_get_template( 'nav', $slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Underscore.js templates for sections.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $slug
|
||||
* @return void
|
||||
*/
|
||||
function butterbean_get_section_template( $slug = '' ) {
|
||||
butterbean_get_template( 'section', $slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Underscore.js templates for controls.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $slug
|
||||
* @return void
|
||||
*/
|
||||
function butterbean_get_control_template( $slug = '' ) {
|
||||
butterbean_get_template( 'control', $slug );
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getting Underscore.js templates.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param string $name
|
||||
* @param string $slug
|
||||
* @return void
|
||||
*/
|
||||
function butterbean_get_template( $name, $slug = '' ) {
|
||||
|
||||
// Allow devs to hook in early to bypass template checking.
|
||||
$located = apply_filters( "butterbean_pre_{$name}_template", '', $slug );
|
||||
|
||||
// If there's no template, let's try to find one.
|
||||
if ( ! $located ) {
|
||||
|
||||
$templates = array();
|
||||
|
||||
if ( $slug )
|
||||
$templates[] = "{$name}-{$slug}.php";
|
||||
|
||||
$templates[] = "{$name}.php";
|
||||
|
||||
// Allow devs to filter the template hierarchy.
|
||||
$templates = apply_filters( "butterbean_{$name}_template_hierarchy", $templates, $slug );
|
||||
|
||||
// Loop through the templates and locate one.
|
||||
foreach ( $templates as $template ) {
|
||||
|
||||
if ( file_exists( butterbean()->tmpl_path . $template ) ) {
|
||||
$located = butterbean()->tmpl_path . $template;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Allow devs to filter the final template.
|
||||
$located = apply_filters( "butterbean_{$name}_template", $located, $slug );
|
||||
|
||||
// Load the template.
|
||||
if ( $located )
|
||||
require( $located );
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Setting class for storing a single meta value as an array.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Array setting class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Setting_Array extends ButterBean_Setting {
|
||||
|
||||
/**
|
||||
* The type of setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'array';
|
||||
|
||||
/**
|
||||
* Sanitizes the value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param array $value
|
||||
* @return array
|
||||
*/
|
||||
public function sanitize( $values ) {
|
||||
|
||||
$multi_values = $values && ! is_array( $values ) ? explode( ',', $values ) : $values;
|
||||
|
||||
return $multi_values ? array_map( array( $this, 'map' ), $multi_values ) : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for sanitizing each value of the array.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function map( $value ) {
|
||||
|
||||
return apply_filters( "butterbean_{$this->manager->name}_sanitize_{$this->name}", $value, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function save() {
|
||||
|
||||
if ( ! $this->check_capabilities() )
|
||||
return;
|
||||
|
||||
$old_values = $this->get_value();
|
||||
$new_values = $this->get_posted_value();
|
||||
|
||||
// If there's an array of posted values, set them.
|
||||
if ( $new_values && is_array( $new_values ) && $new_values !== $old_values )
|
||||
return update_post_meta( $this->manager->post_id, $this->name, $new_values );
|
||||
|
||||
// If no array of posted values but we have old values, delete them.
|
||||
else if ( $old_values && ! $new_values )
|
||||
return delete_post_meta( $this->manager->post_id, $this->name );
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Date setting class. This is meant to be used in conjunction with the built-in
|
||||
* `ButterBean_Date_Control` or a sub-class that passes the appropriate values.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Date setting class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Setting_Date extends ButterBean_Setting {
|
||||
|
||||
/**
|
||||
* The type of setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'date';
|
||||
|
||||
/**
|
||||
* Gets the posted value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_posted_value() {
|
||||
|
||||
$field_name = $this->get_field_name();
|
||||
|
||||
// Get the posted date.
|
||||
$year = ! empty( $_POST[ "{$field_name}_year" ] ) ? zeroise( absint( $_POST[ "{$field_name}_year" ] ), 4 ) : '';
|
||||
$month = ! empty( $_POST[ "{$field_name}_month" ] ) ? zeroise( absint( $_POST[ "{$field_name}_month" ] ), 2 ) : '';
|
||||
$day = ! empty( $_POST[ "{$field_name}_day" ] ) ? zeroise( absint( $_POST[ "{$field_name}_day" ] ), 2 ) : '';
|
||||
|
||||
// Get the posted time.
|
||||
$hour = ! empty( $_POST[ "{$field_name}_hour" ] ) ? $this->validate_hour( $_POST[ "{$field_name}_hour" ] ) : '00';
|
||||
$minute = ! empty( $_POST[ "{$field_name}_minute" ] ) ? $this->validate_minute( $_POST[ "{$field_name}_minute" ] ) : '00';
|
||||
$second = ! empty( $_POST[ "{$field_name}_second" ] ) ? $this->validate_second( $_POST[ "{$field_name}_second" ] ) : '00';
|
||||
|
||||
$date = "{$year}-{$month}-{$day}";
|
||||
$time = "{$hour}:{$minute}:{$second}";
|
||||
|
||||
if ( $year && $month && $day && wp_checkdate( absint( $month ), absint( $day ), absint( $year ), $date ) )
|
||||
return "{$date} {$time}";
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the hour.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param int|string $hour
|
||||
* @return string
|
||||
*/
|
||||
public function validate_hour( $hour ) {
|
||||
|
||||
$hour = absint( $hour );
|
||||
|
||||
return $hour < 0 || $hour > 23 ? zeroise( $hour, 2 ) : '00';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the minute.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param int|string $minute
|
||||
* @return string
|
||||
*/
|
||||
public function validate_minute( $minute ) {
|
||||
|
||||
$minute = absint( $minute );
|
||||
|
||||
return $minute < 0 || $minute > 59 ? zeroise( $minute, 2 ) : '00';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the second.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param int|string $second
|
||||
* @return string
|
||||
*/
|
||||
public function validate_second( $second ) {
|
||||
|
||||
$second = absint( $second );
|
||||
|
||||
return $second < 0 || $second > 59 ? zeroise( $second, 2 ) : '00';
|
||||
}
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* Datetime setting class. This is meant to be used in conjunction with the built-in
|
||||
* `ButterBean_Datetime_Control` or a sub-class that passes the appropriate values.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @subpackage Admin
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Date setting class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Setting_Datetime extends ButterBean_Setting {
|
||||
|
||||
/**
|
||||
* The type of setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'datetime';
|
||||
|
||||
/**
|
||||
* Gets the posted value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_posted_value() {
|
||||
|
||||
$field_name = $this->get_field_name();
|
||||
|
||||
// Get the posted date.
|
||||
$year = ! empty( $_POST[ "{$field_name}_year" ] ) ? zeroise( absint( $_POST[ "{$field_name}_year" ] ), 4 ) : '';
|
||||
$month = ! empty( $_POST[ "{$field_name}_month" ] ) ? zeroise( absint( $_POST[ "{$field_name}_month" ] ), 2 ) : '';
|
||||
$day = ! empty( $_POST[ "{$field_name}_day" ] ) ? zeroise( absint( $_POST[ "{$field_name}_day" ] ), 2 ) : '';
|
||||
|
||||
// Get the posted time.
|
||||
$hour = ! empty( $_POST[ "{$field_name}_hour" ] ) ? $this->validate_hour( $_POST[ "{$field_name}_hour" ] ) : '00';
|
||||
$minute = ! empty( $_POST[ "{$field_name}_minute" ] ) ? $this->validate_minute( $_POST[ "{$field_name}_minute" ] ) : '00';
|
||||
$second = ! empty( $_POST[ "{$field_name}_second" ] ) ? $this->validate_second( $_POST[ "{$field_name}_second" ] ) : '00';
|
||||
|
||||
$date = "{$year}-{$month}-{$day}";
|
||||
$time = "{$hour}:{$minute}:{$second}";
|
||||
|
||||
if ( $year && $month && $day && wp_checkdate( absint( $month ), absint( $day ), absint( $year ), $date ) )
|
||||
return "{$date} {$time}";
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the hour.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param int|string $hour
|
||||
* @return string
|
||||
*/
|
||||
public function validate_hour( $hour ) {
|
||||
|
||||
$hour = absint( $hour );
|
||||
|
||||
return $hour < 0 || $hour > 23 ? zeroise( $hour, 2 ) : '00';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the minute.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param int|string $minute
|
||||
* @return string
|
||||
*/
|
||||
public function validate_minute( $minute ) {
|
||||
|
||||
$minute = absint( $minute );
|
||||
|
||||
return $minute < 0 || $minute > 59 ? zeroise( $minute, 2 ) : '00';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the second.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param int|string $second
|
||||
* @return string
|
||||
*/
|
||||
public function validate_second( $second ) {
|
||||
|
||||
$second = absint( $second );
|
||||
|
||||
return $second < 0 || $second > 59 ? zeroise( $second, 2 ) : '00';
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
/**
|
||||
* Setting class for storing multiple post meta values for a single key.
|
||||
*
|
||||
* @package ButterBean
|
||||
* @author Justin Tadlock <justin@justintadlock.com>
|
||||
* @copyright Copyright (c) 2015-2016, Justin Tadlock
|
||||
* @link https://github.com/justintadlock/butterbean
|
||||
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Multiple setting class.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
*/
|
||||
class ButterBean_Setting_Multiple extends ButterBean_Setting {
|
||||
|
||||
/**
|
||||
* The type of setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'multiple';
|
||||
|
||||
/**
|
||||
* Gets the value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_value() {
|
||||
|
||||
return get_post_meta( $this->manager->post_id, $this->name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitizes the value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param array $value
|
||||
* @return array
|
||||
*/
|
||||
public function sanitize( $values ) {
|
||||
|
||||
$multi_values = $values && ! is_array( $values ) ? explode( ',', $values ) : $values;
|
||||
|
||||
return $multi_values ? array_map( array( $this, 'map' ), $multi_values ) : array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for sanitizing each value of the array.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
public function map( $value ) {
|
||||
|
||||
return apply_filters( "butterbean_{$this->manager->name}_sanitize_{$this->name}", $value, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the value of the setting.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function save() {
|
||||
|
||||
if ( ! $this->check_capabilities() )
|
||||
return;
|
||||
|
||||
$old_values = $this->get_value();
|
||||
$new_values = $this->get_posted_value();
|
||||
|
||||
// If there's an array of posted values, set them.
|
||||
if ( is_array( $new_values ) )
|
||||
$this->set_values( $new_values, $old_values );
|
||||
|
||||
// If no array of posted values but we have old values, delete them.
|
||||
else if ( $old_values )
|
||||
$this->delete_values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loops through new and old meta values and updates.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param array $new_values
|
||||
* @param array $old_values
|
||||
* @return void
|
||||
*/
|
||||
public function set_values( $new_values, $old_values ) {
|
||||
|
||||
foreach ( $new_values as $new ) {
|
||||
|
||||
if ( ! in_array( $new, $old_values ) )
|
||||
$this->add_value( $new );
|
||||
}
|
||||
|
||||
foreach ( $old_values as $old ) {
|
||||
|
||||
if ( ! in_array( $old, $new_values ) )
|
||||
$this->remove_value( $old );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes old meta values.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function delete_values() {
|
||||
|
||||
return delete_post_meta( $this->manager->post_id, $this->name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a single meta value.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function add_value( $value ) {
|
||||
|
||||
return add_post_meta( $this->manager->post_id, $this->name, $value, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a single meta value.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function remove_value( $value ) {
|
||||
|
||||
return delete_post_meta( $this->manager->post_id, $this->name, $value );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
[08-Nov-2025 01:49:22 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[08-Nov-2025 01:49:22 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[08-Nov-2025 01:49:23 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[08-Nov-2025 01:49:23 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[15-Nov-2025 02:56:29 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[11-Dec-2025 17:28:06 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[11-Dec-2025 17:28:07 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[11-Dec-2025 17:28:07 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[11-Dec-2025 17:28:07 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[22-Feb-2026 02:47:33 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[22-Feb-2026 02:47:37 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[22-Feb-2026 02:47:45 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[22-Feb-2026 02:48:30 UTC] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[20-May-2026 08:05:13 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[15-Jul-2026 14:37:38 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[15-Jul-2026 14:37:39 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[15-Jul-2026 14:37:39 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[15-Jul-2026 14:37:40 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[16-Jul-2026 15:58:53 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[16-Jul-2026 15:58:59 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[16-Jul-2026 15:58:59 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[16-Jul-2026 15:59:02 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[21-Aug-2026 12:47:38 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[21-Aug-2026 12:47:38 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[21-Aug-2026 12:47:39 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[21-Aug-2026 12:47:39 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[22-Aug-2026 01:29:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[22-Aug-2026 01:29:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[22-Aug-2026 01:29:09 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[22-Aug-2026 01:29:09 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
[24-Aug-2026 19:05:03 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-array.php on line 18
|
||||
[24-Aug-2026 19:05:03 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-date.php on line 20
|
||||
[24-Aug-2026 19:05:04 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php:20
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-datetime.php on line 20
|
||||
[24-Aug-2026 19:05:04 Asia/Jakarta] PHP Fatal error: Uncaught Error: Class 'ButterBean_Setting' not found in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php:18
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/inc/settings/class-setting-multiple.php on line 18
|
||||
@@ -0,0 +1,875 @@
|
||||
window.butterbean = window.butterbean || {};
|
||||
|
||||
( function() {
|
||||
|
||||
// Bail if we don't have the JSON, which is passed in via `wp_localize_script()`.
|
||||
if ( _.isUndefined( butterbean_data ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Our global object. The `butterbean` object is just a wrapper to house everything
|
||||
* in a single namespace.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
var api = butterbean = {
|
||||
|
||||
/**
|
||||
* Houses the manager, section, and control views based on the `type`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
views : { managers : {}, sections : {}, controls : {} },
|
||||
|
||||
/**
|
||||
* Houses the manager, section, and control templates based on the `type`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
templates : { managers : {}, sections : {}, controls : {} }
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new manager view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param object $args
|
||||
* @return void
|
||||
*/
|
||||
api.views.register_manager = function( type, args ) {
|
||||
|
||||
if ( 'default' !== type )
|
||||
this.managers[ type ] = this.managers.default.extend( args );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a manager view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return object
|
||||
*/
|
||||
api.views.get_manager = function( type ) {
|
||||
|
||||
if ( this.manager_exists( type ) )
|
||||
return this.managers[ type ];
|
||||
|
||||
return this.managers.default;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a manager view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
api.views.unregister_manager = function( type ) {
|
||||
|
||||
if ( 'default' !== type && this.manager_exists( type ) )
|
||||
delete this.managers[ type ];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a manager view exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
api.views.manager_exists = function( type ) {
|
||||
|
||||
return this.managers.hasOwnProperty( type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new section view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param object $args
|
||||
* @return void
|
||||
*/
|
||||
api.views.register_section = function( type, args ) {
|
||||
|
||||
if ( 'default' !== type )
|
||||
this.sections[ type ] = this.sections.default.extend( args );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a section view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return object
|
||||
*/
|
||||
api.views.get_section = function( type ) {
|
||||
|
||||
if ( this.section_exists( type ) )
|
||||
return this.sections[ type ];
|
||||
|
||||
return this.sections.default;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a section view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
api.views.unregister_section = function( type ) {
|
||||
|
||||
if ( 'default' !== type && this.section_exists( type ) )
|
||||
delete this.sections[ type ];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a section view exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
api.views.section_exists = function( type ) {
|
||||
|
||||
return this.sections.hasOwnProperty( type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new control view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param object $args
|
||||
* @return void
|
||||
*/
|
||||
api.views.register_control = function( type, args ) {
|
||||
|
||||
if ( 'default' !== type )
|
||||
this.controls[ type ] = this.controls.default.extend( args );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a control view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return object
|
||||
*/
|
||||
api.views.get_control = function( type ) {
|
||||
|
||||
if ( this.control_exists( type ) )
|
||||
return this.controls[ type ];
|
||||
|
||||
return this.controls.default;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a control view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
api.views.unregister_control = function( type ) {
|
||||
|
||||
if ( 'default' !== type && this.control_exists( type ) )
|
||||
delete this.controls[ type ];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a control view exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
api.views.control_exists = function( type ) {
|
||||
|
||||
return this.controls.hasOwnProperty( type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new manager template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param object $args
|
||||
* @return void
|
||||
*/
|
||||
api.templates.register_manager = function( type ) {
|
||||
|
||||
this.managers[ type ] = wp.template( 'butterbean-manager-' + type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a manager template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return function
|
||||
*/
|
||||
api.templates.get_manager = function( type ) {
|
||||
|
||||
return this.manager_exists( type ) ? this.managers[ type ] : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a manager template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
api.templates.unregister_manager = function( type ) {
|
||||
|
||||
if ( this.manager_exists( type ) )
|
||||
delete this.managers[ type ];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a manager template exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
api.templates.manager_exists = function( type ) {
|
||||
|
||||
return this.managers.hasOwnProperty( type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new section template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param object $args
|
||||
* @return void
|
||||
*/
|
||||
api.templates.register_section = function( type ) {
|
||||
|
||||
this.sections[ type ] = wp.template( 'butterbean-section-' + type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a section template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return function
|
||||
*/
|
||||
api.templates.get_section = function( type ) {
|
||||
|
||||
return this.section_exists( type ) ? this.sections[ type ] : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a section template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
api.templates.unregister_section = function( type ) {
|
||||
|
||||
if ( this.section_exists( type ) )
|
||||
delete this.sections[ type ];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a section template exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
api.templates.section_exists = function( type ) {
|
||||
|
||||
return this.sections.hasOwnProperty( type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new control template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @param object $args
|
||||
* @return void
|
||||
*/
|
||||
api.templates.register_control = function( type ) {
|
||||
|
||||
this.controls[ type ] = wp.template( 'butterbean-control-' + type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a control template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return function
|
||||
*/
|
||||
api.templates.get_control = function( type ) {
|
||||
|
||||
return this.control_exists( type ) ? this.controls[ type ] : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a control template.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return void
|
||||
*/
|
||||
api.templates.unregister_control = function( type ) {
|
||||
|
||||
if ( this.control_exists( type ) )
|
||||
delete this.controls[ type ];
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if a control template exists.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @param string $type
|
||||
* @return bool
|
||||
*/
|
||||
api.templates.control_exists = function( type ) {
|
||||
|
||||
return this.controls.hasOwnProperty( type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders our managers, sections, and controls.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
api.render = function() {
|
||||
|
||||
// Loop through each of the managers and render their api.views.
|
||||
_.each( butterbean_data.managers, function( data ) {
|
||||
|
||||
// Create a new manager model with the JSON data for the manager.
|
||||
var manager = new Manager( data );
|
||||
|
||||
// Get the manager view callback.
|
||||
var callback = api.views.get_manager( data.type );
|
||||
|
||||
// Create a new manager view.
|
||||
var view = new callback( { model : manager } );
|
||||
|
||||
// Get the meta box element.
|
||||
var metabox = document.getElementById( 'butterbean-ui-' + manager.get( 'name' ) );
|
||||
|
||||
// Add the `.butterbean-ui` class to the meta box.
|
||||
metabox.className += ' butterbean-ui';
|
||||
|
||||
// Render the manager view.
|
||||
metabox.querySelector( '.inside' ).appendChild( view.render().el );
|
||||
|
||||
// Render the manager subviews.
|
||||
view.subview_render();
|
||||
|
||||
// Call the view's ready method.
|
||||
view.ready();
|
||||
} );
|
||||
};
|
||||
|
||||
/* === Templates === */
|
||||
|
||||
// Nav template.
|
||||
var nav_template = wp.template( 'butterbean-nav' );
|
||||
|
||||
/* === Models === */
|
||||
|
||||
// Manager model (each manager is housed within a meta box).
|
||||
var Manager = Backbone.Model.extend( {
|
||||
defaults : {
|
||||
name : '',
|
||||
type : '',
|
||||
sections : {},
|
||||
controls : {}
|
||||
}
|
||||
} );
|
||||
|
||||
// Section model (each section belongs to a manager).
|
||||
var Section = Backbone.Model.extend( {
|
||||
defaults : {
|
||||
name : '',
|
||||
type : '',
|
||||
label : '',
|
||||
description : '',
|
||||
icon : '',
|
||||
manager : '',
|
||||
active : '',
|
||||
selected : false
|
||||
}
|
||||
} );
|
||||
|
||||
// Control model (each control belongs to a manager and section).
|
||||
var Control = Backbone.Model.extend( {
|
||||
defaults : {
|
||||
name : '',
|
||||
type : '',
|
||||
label : '',
|
||||
description : '',
|
||||
icon : '',
|
||||
value : '',
|
||||
choices : {},
|
||||
attr : '',
|
||||
active : '',
|
||||
manager : '',
|
||||
section : '',
|
||||
setting : ''
|
||||
}
|
||||
} );
|
||||
|
||||
/* === Collections === */
|
||||
|
||||
/**
|
||||
* Stores our collection of section models.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access private
|
||||
* @var object
|
||||
*/
|
||||
var Sections = Backbone.Collection.extend( {
|
||||
model : Section
|
||||
} );
|
||||
|
||||
/* === Views === */
|
||||
|
||||
/**
|
||||
* The default manager view. Other views can extend this using the
|
||||
* `butterbean.views.register_manager()` function.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
api.views.managers[ 'default' ] = Backbone.View.extend( {
|
||||
|
||||
// Wrapper element for the manager view.
|
||||
tagName : 'div',
|
||||
|
||||
// Adds some custom attributes to the wrapper.
|
||||
attributes : function() {
|
||||
return {
|
||||
'id' : 'butterbean-manager-' + this.model.get( 'name' ),
|
||||
'class' : 'butterbean-manager butterbean-manager-' + this.model.get( 'type' )
|
||||
};
|
||||
},
|
||||
|
||||
// Initializes the view.
|
||||
initialize : function() {
|
||||
|
||||
var type = this.model.get( 'type' );
|
||||
|
||||
// If there's not yet a template for this manager type, create it.
|
||||
if ( ! api.templates.manager_exists( type ) )
|
||||
api.templates.register_manager( type );
|
||||
|
||||
// Get the manager template.
|
||||
this.template = api.templates.get_manager( type );
|
||||
},
|
||||
|
||||
// Renders the manager.
|
||||
render : function() {
|
||||
this.el.innerHTML = this.template( this.model.toJSON() );
|
||||
return this;
|
||||
},
|
||||
|
||||
// Renders the manager's sections and controls.
|
||||
// Important! This may change drastically in the future, possibly even
|
||||
// taken out of the manager view altogether. It's for this reason that
|
||||
// it's not recommended to create custom views for managers right now.
|
||||
subview_render : function() {
|
||||
|
||||
// Create a new section collection.
|
||||
var sections = new Sections();
|
||||
|
||||
// Loop through each section and add it to the collection.
|
||||
_.each( this.model.get( 'sections' ), function( data ) {
|
||||
|
||||
sections.add( new Section( data ) );
|
||||
} );
|
||||
|
||||
// Loop through each section in the collection and render its view.
|
||||
sections.forEach( function( section, i ) {
|
||||
|
||||
// Create a new nav item view for the section.
|
||||
var nav_view = new Nav_View( { model : section } );
|
||||
|
||||
// Render the nav item view.
|
||||
document.querySelector( '#butterbean-ui-' + section.get( 'manager' ) + ' .butterbean-nav' ).appendChild( nav_view.render().el );
|
||||
|
||||
// Get the section view callback.
|
||||
var callback = api.views.get_section( section.attributes.type );
|
||||
|
||||
// Create a new section view.
|
||||
var view = new callback( { model : section } );
|
||||
|
||||
// Render the section view.
|
||||
document.querySelector( '#butterbean-ui-' + section.get( 'manager' ) + ' .butterbean-content' ).appendChild( view.render().el );
|
||||
|
||||
// Call the section view's ready method.
|
||||
view.ready();
|
||||
|
||||
// If the first model, set it to selected.
|
||||
section.set( 'selected', 0 === i );
|
||||
}, this );
|
||||
|
||||
// Loop through each control for the manager and render its view.
|
||||
_.each( this.model.get( 'controls' ), function( data ) {
|
||||
|
||||
// Create a new control model.
|
||||
var control = new Control( data );
|
||||
|
||||
// Get the control view callback.
|
||||
var callback = api.views.get_control( data.type );
|
||||
|
||||
// Create a new control view.
|
||||
var view = new callback( { model : control } );
|
||||
|
||||
// Render the view.
|
||||
document.getElementById( 'butterbean-' + control.get( 'manager' ) + '-section-' + control.get( 'section' ) ).appendChild( view.render().el );
|
||||
|
||||
// Call the view's ready method.
|
||||
view.ready();
|
||||
} );
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
// Function that is executed *after* the view has been rendered.
|
||||
// This is meant to be overwritten in sub-views.
|
||||
ready : function() {}
|
||||
} );
|
||||
|
||||
/**
|
||||
* The default section view. Other views can extend this using the
|
||||
* `butterbean.views.register_section()` function.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
api.views.sections[ 'default' ] = Backbone.View.extend( {
|
||||
|
||||
// Wrapper element for the section.
|
||||
tagName : 'div',
|
||||
|
||||
// Adds custom attributes for the section wrapper.
|
||||
attributes : function() {
|
||||
return {
|
||||
'id' : 'butterbean-' + this.model.get( 'manager' ) + '-section-' + this.model.get( 'name' ),
|
||||
'class' : 'butterbean-section butterbean-section-' + this.model.get( 'type' ),
|
||||
'aria-hidden' : ! this.model.get( 'selected' )
|
||||
};
|
||||
},
|
||||
|
||||
// Initializes the view.
|
||||
initialize : function() {
|
||||
|
||||
// Add an event for when the model changes.
|
||||
this.model.on( 'change', this.onchange, this );
|
||||
|
||||
// Get the section type.
|
||||
var type = this.model.get( 'type' );
|
||||
|
||||
// If there's no template for this section type, create it.
|
||||
if ( ! api.templates.section_exists( type ) )
|
||||
api.templates.register_section( type );
|
||||
|
||||
// Gets the section template.
|
||||
this.template = api.templates.get_section( type );
|
||||
},
|
||||
|
||||
// Renders the section.
|
||||
render : function() {
|
||||
|
||||
// Only render template if model is active.
|
||||
if ( this.model.get( 'active' ) )
|
||||
this.el.innerHTML = this.template( this.model.toJSON() );
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
// Executed when the model changes.
|
||||
onchange : function() {
|
||||
|
||||
// Set the view's `aria-hidden` attribute based on whether the model is selected.
|
||||
this.el.setAttribute( 'aria-hidden', ! this.model.get( 'selected' ) );
|
||||
},
|
||||
|
||||
// Function that is executed *after* the view has been rendered.
|
||||
// This is meant to be overwritten in sub-views.
|
||||
ready : function() {}
|
||||
} );
|
||||
|
||||
/**
|
||||
* The nav item view for each section.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
var Nav_View = Backbone.View.extend( {
|
||||
|
||||
// Sets the template used.
|
||||
template : nav_template,
|
||||
|
||||
// Wrapper element for the nav item.
|
||||
tagName : 'li',
|
||||
|
||||
// Sets some custom attributes for the nav item wrapper.
|
||||
attributes : function() {
|
||||
return {
|
||||
'aria-selected' : this.model.get( 'selected' )
|
||||
};
|
||||
},
|
||||
|
||||
// Initializes the nav item view.
|
||||
initialize : function() {
|
||||
this.model.on( 'change', this.render, this );
|
||||
this.model.on( 'change', this.onchange, this );
|
||||
},
|
||||
|
||||
// Renders the nav item.
|
||||
render : function() {
|
||||
|
||||
// Only render template if model is active.
|
||||
if ( this.model.get( 'active' ) )
|
||||
this.el.innerHTML = this.template( this.model.toJSON() );
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
// Custom events.
|
||||
events : {
|
||||
'click a' : 'onselect'
|
||||
},
|
||||
|
||||
// Executed when the section model changes.
|
||||
onchange : function() {
|
||||
|
||||
// Set the `aria-selected` attibute based on the model selected state.
|
||||
this.el.setAttribute( 'aria-selected', this.model.get( 'selected' ) );
|
||||
},
|
||||
|
||||
// Executed when the link for the nav item is clicked.
|
||||
onselect : function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
// Loop through each of the models in the collection and set them to inactive.
|
||||
_.each( this.model.collection.models, function( m ) {
|
||||
|
||||
m.set( 'selected', false );
|
||||
}, this );
|
||||
|
||||
// Set this view's model to selected.
|
||||
this.model.set( 'selected', true );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* The default control view. Other views can extend this using the
|
||||
* `butterbean.views.register_control()` function.
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @access public
|
||||
* @var object
|
||||
*/
|
||||
api.views.controls[ 'default' ] = Backbone.View.extend( {
|
||||
|
||||
// Wrapper element for the control.
|
||||
tagName : 'div',
|
||||
|
||||
// Custom attributes for the control wrapper.
|
||||
attributes : function() {
|
||||
return {
|
||||
'id' : 'butterbean-control-' + this.model.get( 'name' ),
|
||||
'class' : 'butterbean-control butterbean-control-' + this.model.get( 'type' )
|
||||
};
|
||||
},
|
||||
|
||||
// Initiazlies the control view.
|
||||
initialize : function() {
|
||||
var type = this.model.get( 'type' );
|
||||
|
||||
// Only add a new control template if we have a different control type.
|
||||
if ( ! api.templates.control_exists( type ) )
|
||||
api.templates.register_control( type );
|
||||
|
||||
// Get the control template.
|
||||
this.template = api.templates.get_control( type );
|
||||
|
||||
// Bind changes so that the view is re-rendered when the model changes.
|
||||
_.bindAll( this, 'render' );
|
||||
this.model.bind( 'change', this.render );
|
||||
},
|
||||
|
||||
// Renders the control template.
|
||||
render : function() {
|
||||
|
||||
// Only render template if model is active.
|
||||
if ( this.model.get( 'active' ) )
|
||||
this.el.innerHTML = this.template( this.model.toJSON() );
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
// Function that is executed *after* the view has been rendered.
|
||||
// This is meant to be overwritten in sub-views.
|
||||
ready : function() {}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Adds the color control view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
api.views.register_control( 'color', {
|
||||
|
||||
// Calls the core WP color picker for the control's input.
|
||||
ready : function() {
|
||||
|
||||
var options = this.model.attributes.options;
|
||||
|
||||
jQuery( this.$el ).find( '.butterbean-color-picker' ).wpColorPicker( options );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Adds the color palette view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
api.views.register_control( 'palette', {
|
||||
|
||||
// Adds custom events.
|
||||
events : {
|
||||
'change input' : 'onselect'
|
||||
},
|
||||
|
||||
// Executed when one of the color palette's value has changed.
|
||||
// These are radio inputs.
|
||||
onselect : function() {
|
||||
|
||||
// Get the value of the input.
|
||||
var value = document.querySelector( '#' + this.el.id + ' input:checked' ).getAttribute( 'value' );
|
||||
|
||||
// Get all choices.
|
||||
var choices = this.model.get( 'choices' );
|
||||
|
||||
// Loop through choices and change the selected value.
|
||||
_.each( choices, function( choice, key ) {
|
||||
choice.selected = key === value;
|
||||
} );
|
||||
|
||||
// Because `choices` is an array, it's not recognized as a change. So, we
|
||||
// have to manually trigger a change here so that the view gets re-rendered.
|
||||
this.model.set( 'choices', choices ).trigger( 'change', this.model );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* Adds the image control view.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
api.views.register_control( 'image', {
|
||||
|
||||
// Adds custom events.
|
||||
events : {
|
||||
'click .butterbean-add-media' : 'showmodal',
|
||||
'click .butterbean-change-media' : 'showmodal',
|
||||
'click .butterbean-remove-media' : 'removemedia'
|
||||
},
|
||||
|
||||
// Executed when the show modal button is clicked.
|
||||
showmodal : function() {
|
||||
|
||||
|
||||
// If we already have a media modal, open it.
|
||||
if ( ! _.isUndefined( this.media_modal ) ) {
|
||||
|
||||
this.media_modal.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a new media modal.
|
||||
this.media_modal = wp.media( {
|
||||
frame : 'select',
|
||||
multiple : false,
|
||||
editing : true,
|
||||
title : this.model.get( 'l10n' ).choose,
|
||||
library : { type : 'image' },
|
||||
button : { text: this.model.get( 'l10n' ).set }
|
||||
} );
|
||||
|
||||
// Runs when an image is selected in the media modal.
|
||||
this.media_modal.on( 'select', function() {
|
||||
|
||||
// Gets the JSON data for the first selection.
|
||||
var media = this.media_modal.state().get( 'selection' ).first().toJSON();
|
||||
|
||||
// Size of image to display.
|
||||
var size = this.model.attributes.size;
|
||||
|
||||
// Updates the model for the view.
|
||||
this.model.set( {
|
||||
src : media.sizes[ size ] ? media.sizes[ size ]['url'] : media.url,
|
||||
alt : media.alt,
|
||||
value : media.id
|
||||
} );
|
||||
}, this );
|
||||
|
||||
// Opens the media modal.
|
||||
this.media_modal.open();
|
||||
},
|
||||
|
||||
// Executed when the remove media button is clicked.
|
||||
removemedia : function() {
|
||||
|
||||
// Updates the model for the view.
|
||||
this.model.set( { src : '', alt : '', value : '' } );
|
||||
}
|
||||
} );
|
||||
|
||||
}() );
|
||||
@@ -0,0 +1 @@
|
||||
window.butterbean=window.butterbean||{},function(){if(!_.isUndefined(butterbean_data)){var e=butterbean={views:{managers:{},sections:{},controls:{}},templates:{managers:{},sections:{},controls:{}}};e.views.register_manager=function(e,t){"default"!==e&&(this.managers[e]=this.managers.default.extend(t))},e.views.get_manager=function(e){return this.manager_exists(e)?this.managers[e]:this.managers.default},e.views.unregister_manager=function(e){"default"!==e&&this.manager_exists(e)&&delete this.managers[e]},e.views.manager_exists=function(e){return this.managers.hasOwnProperty(e)},e.views.register_section=function(e,t){"default"!==e&&(this.sections[e]=this.sections.default.extend(t))},e.views.get_section=function(e){return this.section_exists(e)?this.sections[e]:this.sections.default},e.views.unregister_section=function(e){"default"!==e&&this.section_exists(e)&&delete this.sections[e]},e.views.section_exists=function(e){return this.sections.hasOwnProperty(e)},e.views.register_control=function(e,t){"default"!==e&&(this.controls[e]=this.controls.default.extend(t))},e.views.get_control=function(e){return this.control_exists(e)?this.controls[e]:this.controls.default},e.views.unregister_control=function(e){"default"!==e&&this.control_exists(e)&&delete this.controls[e]},e.views.control_exists=function(e){return this.controls.hasOwnProperty(e)},e.templates.register_manager=function(e){this.managers[e]=wp.template("butterbean-manager-"+e)},e.templates.get_manager=function(e){return this.manager_exists(e)?this.managers[e]:!1},e.templates.unregister_manager=function(e){this.manager_exists(e)&&delete this.managers[e]},e.templates.manager_exists=function(e){return this.managers.hasOwnProperty(e)},e.templates.register_section=function(e){this.sections[e]=wp.template("butterbean-section-"+e)},e.templates.get_section=function(e){return this.section_exists(e)?this.sections[e]:!1},e.templates.unregister_section=function(e){this.section_exists(e)&&delete this.sections[e]},e.templates.section_exists=function(e){return this.sections.hasOwnProperty(e)},e.templates.register_control=function(e){this.controls[e]=wp.template("butterbean-control-"+e)},e.templates.get_control=function(e){return this.control_exists(e)?this.controls[e]:!1},e.templates.unregister_control=function(e){this.control_exists(e)&&delete this.controls[e]},e.templates.control_exists=function(e){return this.controls.hasOwnProperty(e)},e.render=function(){_.each(butterbean_data.managers,function(t){var i=new n(t),s=e.views.get_manager(t.type),a=new s({model:i}),o=document.getElementById("butterbean-ui-"+i.get("name"));o.className+=" butterbean-ui",o.querySelector(".inside").appendChild(a.render().el),a.subview_render(),a.ready()})};var t=wp.template("butterbean-nav"),n=Backbone.Model.extend({defaults:{name:"",type:"",sections:{},controls:{}}}),i=Backbone.Model.extend({defaults:{name:"",type:"",label:"",description:"",icon:"",manager:"",active:"",selected:!1}}),s=Backbone.Model.extend({defaults:{name:"",type:"",label:"",description:"",icon:"",value:"",choices:{},attr:"",active:"",manager:"",section:"",setting:""}}),a=Backbone.Collection.extend({model:i});e.views.managers["default"]=Backbone.View.extend({tagName:"div",attributes:function(){return{id:"butterbean-manager-"+this.model.get("name"),"class":"butterbean-manager butterbean-manager-"+this.model.get("type")}},initialize:function(){var t=this.model.get("type");e.templates.manager_exists(t)||e.templates.register_manager(t),this.template=e.templates.get_manager(t)},render:function(){return this.el.innerHTML=this.template(this.model.toJSON()),this},subview_render:function(){var t=new a;return _.each(this.model.get("sections"),function(e){t.add(new i(e))}),t.forEach(function(t,n){var i=new o({model:t});document.querySelector("#butterbean-ui-"+t.get("manager")+" .butterbean-nav").appendChild(i.render().el);var s=e.views.get_section(t.attributes.type),a=new s({model:t});document.querySelector("#butterbean-ui-"+t.get("manager")+" .butterbean-content").appendChild(a.render().el),a.ready(),t.set("selected",0===n)},this),_.each(this.model.get("controls"),function(t){var n=new s(t),i=e.views.get_control(t.type),a=new i({model:n});document.getElementById("butterbean-"+n.get("manager")+"-section-"+n.get("section")).appendChild(a.render().el),a.ready()}),this},ready:function(){}}),e.views.sections["default"]=Backbone.View.extend({tagName:"div",attributes:function(){return{id:"butterbean-"+this.model.get("manager")+"-section-"+this.model.get("name"),"class":"butterbean-section butterbean-section-"+this.model.get("type"),"aria-hidden":!this.model.get("selected")}},initialize:function(){this.model.on("change",this.onchange,this);var t=this.model.get("type");e.templates.section_exists(t)||e.templates.register_section(t),this.template=e.templates.get_section(t)},render:function(){return this.model.get("active")&&(this.el.innerHTML=this.template(this.model.toJSON())),this},onchange:function(){this.el.setAttribute("aria-hidden",!thisLine truncated
|
||||
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,152 @@
|
||||
# ButterBean
|
||||
|
||||
ButterBean is a neat little post meta box framework built on [Backbone.js](http://backbonejs.org) and [Underscore.js](http://underscorejs.org). You can run it as a standalone plugin or drop it into your own plugins.
|
||||
|
||||
The idea behind ButterBean came about because I often build custom post types that need quite a bit of custom metadata attached to the posts. Separating this into multiple meta boxes wasn't fun or user friendly. So, I decided to go with a single tabbed meta box instead.
|
||||
|
||||
And, that's what ButterBean is. It's essentially a meta box with tabs for lots of content.
|
||||
|
||||
## Just the interface
|
||||
|
||||
A lot of meta box frameworks try to do everything. They handle backend output, frontend output, and everything else you can think of. ButterBean is meant to be an interface only. Because every project's needs are vastly different, it doesn't make sense to stick you with a bunch of things you don't need. This means that the code can stay relatively lean and flexible, which makes it perfect for bundling in your plugins.
|
||||
|
||||
So, don't go looking for functions for outputting metadata on the front end from ButterBean. It doesn't have any. Use the core WordPress functionality or build your own wrapper functions.
|
||||
|
||||
## Documentation
|
||||
|
||||
This is a quick guide. If you're familiar with the WordPress Customization API, you should probably pick this up fairly quickly. A lot of the same concepts are used here.
|
||||
|
||||
### Installation
|
||||
|
||||
Drop the `butterbean` folder into your plugin. That's the simple part.
|
||||
|
||||
The script will auto-load itself on the correct admin hooks. You just need to load it like so:
|
||||
|
||||
```
|
||||
add_action( 'plugins_loaded', 'th_load' );
|
||||
|
||||
function th_load() {
|
||||
|
||||
require_once( 'path/to/butterbean/butterbean.php' );
|
||||
}
|
||||
```
|
||||
|
||||
### Registration
|
||||
|
||||
There's a built-in action hook called `butterbean_register`. You're going to use that to register everything. So, you need to set up a callback function for that.
|
||||
|
||||
```
|
||||
add_action( 'butterbean_register', 'th_register', 10, 2 );
|
||||
|
||||
function th_register( $butterbean, $post_type ) {
|
||||
|
||||
// Register managers, sections, controls, and settings here.
|
||||
}
|
||||
```
|
||||
|
||||
#### Registering a manager
|
||||
|
||||
A **manager** is a group of sections, controls, and settings. It's displayed as a single meta box. There can be multiple managers per screen (don't try multiples yet).
|
||||
|
||||
```
|
||||
$butterbean->register_manager(
|
||||
'example',
|
||||
array(
|
||||
'label' => esc_html__( 'Example', 'your-textdomain' ),
|
||||
'post_type' => 'your_post_type',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high'
|
||||
)
|
||||
);
|
||||
|
||||
$manager = $butterbean->get_manager( 'example' );
|
||||
```
|
||||
|
||||
#### Registering a section
|
||||
|
||||
A **section** is a group of controls within a manager. They are presented as "tabbed" sections in the UI.
|
||||
|
||||
```
|
||||
$manager->register_section(
|
||||
'section_1',
|
||||
array(
|
||||
'label' => esc_html__( 'Section 1', 'your-textdomain' ),
|
||||
'icon' => 'dashicons-admin-generic'
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
#### Registering a control
|
||||
|
||||
A **control** is essentially a form field. It's the field(s) that a user enters data into. Each control belongs to a section. Each control should also be tied to a setting (below).
|
||||
|
||||
```
|
||||
$manager->register_control(
|
||||
'abc_xyz', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'section_1',
|
||||
'label' => esc_html__( 'Control ABC', 'your-textdomain' ),
|
||||
'attr' => array( 'class' => 'widefat' )
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
#### Registering a setting
|
||||
|
||||
A **setting** is nothing more than some post metadata and how it gets stored. A setting belongs to a specific control.
|
||||
|
||||
```
|
||||
$manager->register_setting(
|
||||
'abc_xyz', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wp_filter_nohtml_kses'
|
||||
)
|
||||
);
|
||||
```
|
||||
|
||||
### JavaScript API
|
||||
|
||||
ButterBean was built using [Backbone](http://backbonejs.org) for handling models, collections, and views. It uses [Underscore](http://underscorejs.org) for rendering templates for the views. All output is handled via JavaScript rather than PHP so that we can do cool stuff on the fly without having to reload the page. This is particularly useful when you start building more complex controls.
|
||||
|
||||
You'll never need to touch JavaScript until you need to build a control that relies on JavaScript.
|
||||
|
||||
#### The butterbean object
|
||||
|
||||
`butterbean` is the global object that houses everything you ever want to touch on the JavaScript side of things. It's located in the `js/butterbean.js` file. This file is well-documented, so you'll want to dive into it for doing more advanced stuff.
|
||||
|
||||
`butterbean.views.register_control()` is what most people will end up using. It's a function for registering a custom control view. New views can be created for each `type` of control.
|
||||
|
||||
Here's a quick example of registering a view for a color control where we need to call the core WordPress `wpColorPicker()` function. It uses the `ready()` function, which is fired after the HTML has been rendered for the view.
|
||||
|
||||
```
|
||||
( function() {
|
||||
|
||||
butterbean.views.register_control( 'color', {
|
||||
|
||||
// Calls the core WP color picker for the control's input.
|
||||
ready : function() {
|
||||
|
||||
var options = this.model.attributes.options;
|
||||
|
||||
jQuery( this.$el ).find( '.butterbean-color-picker' ).wpColorPicker( options );
|
||||
}
|
||||
} );
|
||||
}() );
|
||||
```
|
||||
|
||||
## Professional Support
|
||||
|
||||
If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](http://themehybrid.com/board/topics), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 70,000+ users (and growing).
|
||||
|
||||
## Copyright and License
|
||||
|
||||
Various ideas from different projects have made their way into ButterBean. A few of the projects that had an important impact on the direction of this project are:
|
||||
|
||||
* Architecturally, the PHP code was modeled after the core WordPress Customization API. - [GPL 2+](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
|
||||
* The design concept of the default tabbed interface was taken from [WooCommerce](http://www.woothemes.com/woocommerce/). © WooThemes - [GPL 3+](http://www.gnu.org/licenses/gpl.html)
|
||||
* Code ideas for the media frame were borrowed from [WP Term Images](https://wordpress.org/plugins/wp-term-images/). © John James Jacoby - [GPL 2+](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
|
||||
|
||||
This project is licensed under the [GNU GPL](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html), version 2 or later.
|
||||
|
||||
2015-2016 © [Justin Tadlock](http://justintadlock.com).
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,11 @@
|
||||
<label>
|
||||
<input type="checkbox" value="true" {{{ data.attr }}} <# if ( data.value ) { #> checked="checked" <# } #> />
|
||||
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
</label>
|
||||
@@ -0,0 +1,22 @@
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<ul class="butterbean-checkbox-list">
|
||||
|
||||
<# _.each( data.choices, function( label, choice ) { #>
|
||||
|
||||
<li>
|
||||
<label>
|
||||
<input type="checkbox" value="{{ choice }}" name="{{ data.field_name }}[]" <# if ( -1 !== _.indexOf( data.value, choice ) ) { #> checked="checked" <# } #> />
|
||||
{{ label }}
|
||||
</label>
|
||||
</li>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</ul>
|
||||
@@ -0,0 +1,11 @@
|
||||
<label>
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<input {{{ data.attr }}} value="<# if ( data.value ) { #>#{{ data.value }}<# } #>" />
|
||||
</label>
|
||||
@@ -0,0 +1,55 @@
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<?php $month = '<label>
|
||||
<span class="screen-reader-text">{{ data.month.label }}</span>
|
||||
<select name="{{ data.month.name }}">
|
||||
<# _.each( data.month.choices, function( choice ) { #>
|
||||
<option value="{{ choice.num }}" <# if ( choice.num === data.month.value ) { #> selected="selected" <# } #>>{{ choice.label }}</option>
|
||||
<# } ) #>
|
||||
</select>
|
||||
</label>';
|
||||
|
||||
$day = '<label>
|
||||
<span class="screen-reader-text">{{ data.day.label }}</span>
|
||||
<input type="text" name="{{ data.day.name }}" value="{{ data.day.value }}" {{{ data.day.attr }}} />
|
||||
</label>';
|
||||
|
||||
$year = '<label>
|
||||
<span class="screen-reader-text">{{ data.year.label }}</span>
|
||||
<input type="text" name="{{ data.year.name }}" value="{{ data.year.value }}" {{{ data.year.attr }}} />
|
||||
</label>';
|
||||
|
||||
$hour = '<label>
|
||||
<span class="screen-reader-text">{{ data.hour.label }}</span>
|
||||
<input type="text" name="{{ data.hour.name }}" value="{{ data.hour.value }}" {{{ data.hour.attr }}} />
|
||||
</label>';
|
||||
|
||||
$minute = '<label>
|
||||
<span class="screen-reader-text">{{ data.minute.label }}</span>
|
||||
<input type="text" name="{{ data.minute.name }}" value="{{ data.minute.value }}" {{{ data.minute.attr }}} />
|
||||
</label>';
|
||||
|
||||
$second = '<label>
|
||||
<span class="screen-reader-text">{{ data.second.label }}</span>
|
||||
<input type="text" name="{{ data.second.name }}" value="{{ data.second.value }}" {{{ data.second.attr }}} />
|
||||
</label>'; ?>
|
||||
|
||||
<# if ( data.show_time ) { #>
|
||||
|
||||
<?php // Translators: 1: month, 2: day, 3: year, 4: hour, 5: minute, 6: second.
|
||||
printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s:%6$s', 'butterbean' ), $month, $day, $year, $hour, $minute, $second );
|
||||
?>
|
||||
|
||||
<# } else { #>
|
||||
|
||||
<?php // Translators: 1: month, 2: day, 3: year.
|
||||
printf( __( '%1$s %2$s, %3$s', 'butterbean' ), $month, $day, $year );
|
||||
?>
|
||||
|
||||
<# } #>
|
||||
@@ -0,0 +1,55 @@
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<?php $month = '<label>
|
||||
<span class="screen-reader-text">{{ data.month.label }}</span>
|
||||
<select name="{{ data.month.name }}">
|
||||
<# _.each( data.month.choices, function( choice ) { #>
|
||||
<option value="{{ choice.num }}" <# if ( choice.num === data.month.value ) { #> selected="selected" <# } #>>{{ choice.label }}</option>
|
||||
<# } ) #>
|
||||
</select>
|
||||
</label>';
|
||||
|
||||
$day = '<label>
|
||||
<span class="screen-reader-text">{{ data.day.label }}</span>
|
||||
<input type="text" name="{{ data.day.name }}" value="{{ data.day.value }}" {{{ data.day.attr }}} />
|
||||
</label>';
|
||||
|
||||
$year = '<label>
|
||||
<span class="screen-reader-text">{{ data.year.label }}</span>
|
||||
<input type="text" name="{{ data.year.name }}" value="{{ data.year.value }}" {{{ data.year.attr }}} />
|
||||
</label>';
|
||||
|
||||
$hour = '<label>
|
||||
<span class="screen-reader-text">{{ data.hour.label }}</span>
|
||||
<input type="text" name="{{ data.hour.name }}" value="{{ data.hour.value }}" {{{ data.hour.attr }}} />
|
||||
</label>';
|
||||
|
||||
$minute = '<label>
|
||||
<span class="screen-reader-text">{{ data.minute.label }}</span>
|
||||
<input type="text" name="{{ data.minute.name }}" value="{{ data.minute.value }}" {{{ data.minute.attr }}} />
|
||||
</label>';
|
||||
|
||||
$second = '<label>
|
||||
<span class="screen-reader-text">{{ data.second.label }}</span>
|
||||
<input type="text" name="{{ data.second.name }}" value="{{ data.second.value }}" {{{ data.second.attr }}} />
|
||||
</label>'; ?>
|
||||
|
||||
<# if ( data.show_time ) { #>
|
||||
|
||||
<?php // Translators: 1: month, 2: day, 3: year, 4: hour, 5: minute, 6: second.
|
||||
printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s:%6$s', 'butterbean' ), $month, $day, $year, $hour, $minute, $second );
|
||||
?>
|
||||
|
||||
<# } else { #>
|
||||
|
||||
<?php // Translators: 1: month, 2: day, 3: year.
|
||||
printf( __( '%1$s %2$s, %3$s', 'butterbean' ), $month, $day, $year );
|
||||
?>
|
||||
|
||||
<# } #>
|
||||
@@ -0,0 +1,24 @@
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<input type="hidden" class="butterbean-attachment-id" name="{{ data.field_name }}" value="{{ data.value }}" />
|
||||
|
||||
<# if ( data.src ) { #>
|
||||
<img class="butterbean-img" src="{{ data.src }}" alt="{{ data.alt }}" />
|
||||
<# } else { #>
|
||||
<div class="butterbean-placeholder">{{ data.l10n.placeholder }}</div>
|
||||
<# } #>
|
||||
|
||||
<p>
|
||||
<# if ( data.src ) { #>
|
||||
<button type="button" class="button button-secondary butterbean-change-media">{{ data.l10n.change }}</button>
|
||||
<button type="button" class="button button-secondary butterbean-remove-media">{{ data.l10n.remove }}</button>
|
||||
<# } else { #>
|
||||
<button type="button" class="button button-secondary butterbean-add-media">{{ data.l10n.upload }}</button>
|
||||
<# } #>
|
||||
</p>
|
||||
@@ -0,0 +1,23 @@
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<div class="butterbean-multi-avatars-wrap">
|
||||
|
||||
<# _.each( data.choices, function( user ) { #>
|
||||
|
||||
<label>
|
||||
<input type="checkbox" value="{{ user.id }}" name="{{ data.field_name }}[]" <# if ( -1 !== _.indexOf( data.value, user.id ) ) { #> checked="checked" <# } #> />
|
||||
|
||||
<span class="screen-reader-text">{{ user.name }}</span>
|
||||
|
||||
{{{ user.avatar }}}
|
||||
</label>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</div><!-- .butterbean-multi-avatars-wrap -->
|
||||
@@ -0,0 +1,23 @@
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<# _.each( data.choices, function( palette, choice ) { #>
|
||||
<label aria-selected="{{ palette.selected }}">
|
||||
<input type="radio" value="{{ choice }}" name="{{ data.field_name }}" <# if ( palette.selected ) { #> checked="checked" <# } #> />
|
||||
|
||||
<span class="butterbean-palette-label">{{ palette.label }}</span>
|
||||
|
||||
<div class="butterbean-palette-block">
|
||||
|
||||
<# _.each( palette.colors, function( color ) { #>
|
||||
<span class="butterbean-palette-color" style="background-color: {{ color }}"> </span>
|
||||
<# } ) #>
|
||||
|
||||
</div>
|
||||
</label>
|
||||
<# } ) #>
|
||||
@@ -0,0 +1,17 @@
|
||||
<label>
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<select name="{{ data.field_name }}" id="{{ data.field_name }}">
|
||||
|
||||
<# _.each( data.choices, function( choice ) { #>
|
||||
<option value="{{ choice.value }}" <# if ( choice.value === data.value ) { #> selected="selected" <# } #>>{{ choice.label }}</option>
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
</label>
|
||||
@@ -0,0 +1,17 @@
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<# _.each( data.choices, function( args, choice ) { #>
|
||||
|
||||
<label>
|
||||
<input type="radio" value="{{ choice }}" name="{{ data.field_name }}" <# if ( data.value === choice ) { #> checked="checked" <# } #> />
|
||||
<span class="screen-reader-text">{{ args.label }}</span>
|
||||
<img src="{{ args.url }}" alt="{{ args.label }}" />
|
||||
</label>
|
||||
|
||||
<# } ) #>
|
||||
@@ -0,0 +1,22 @@
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<ul class="butterbean-radio-list">
|
||||
|
||||
<# _.each( data.choices, function( label, choice ) { #>
|
||||
|
||||
<li>
|
||||
<label>
|
||||
<input type="radio" value="{{ choice }}" name="{{ data.field_name }}" <# if ( data.value === choice ) { #> checked="checked" <# } #> />
|
||||
{{ label }}
|
||||
</label>
|
||||
</li>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</ul>
|
||||
@@ -0,0 +1,33 @@
|
||||
<label>
|
||||
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<select {{{ data.attr }}}>
|
||||
|
||||
<# _.each( data.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
<# _.each( data.group, function( group ) { #>
|
||||
|
||||
<optgroup label="{{ group.label }}">
|
||||
|
||||
<# _.each( group.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( choice === data.value ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</optgroup>
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
@@ -0,0 +1,20 @@
|
||||
<label>
|
||||
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<select {{{ data.attr }}}>
|
||||
|
||||
<# _.each( data.choices, function( label, choice ) { #>
|
||||
|
||||
<option value="{{ choice }}" <# if ( data.value === choice ) { #> selected="selected" <# } #>>{{ label }}</option>
|
||||
|
||||
<# } ) #>
|
||||
|
||||
</select>
|
||||
</label>
|
||||
@@ -0,0 +1,11 @@
|
||||
<label>
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<textarea {{{ data.attr }}}>{{{ data.value }}}</textarea>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
</label>
|
||||
@@ -0,0 +1,11 @@
|
||||
<label>
|
||||
<# if ( data.label ) { #>
|
||||
<span class="butterbean-label">{{ data.label }}</span>
|
||||
<# } #>
|
||||
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
|
||||
<input type="{{ data.type }}" value="{{ data.value }}" {{{ data.attr }}} />
|
||||
</label>
|
||||
@@ -0,0 +1,80 @@
|
||||
[08-Nov-2025 01:47:53 UTC] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[08-Nov-2025 01:47:53 UTC] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[15-Nov-2025 02:56:26 UTC] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[15-Nov-2025 02:56:26 UTC] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[11-Dec-2025 17:27:41 UTC] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[11-Dec-2025 17:27:41 UTC] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[22-Feb-2026 02:31:23 UTC] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[22-Feb-2026 02:31:23 UTC] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[20-May-2026 08:05:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[20-May-2026 08:05:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[15-Jul-2026 14:36:44 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[15-Jul-2026 14:36:44 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[16-Jul-2026 15:50:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[16-Jul-2026 15:50:08 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[21-Aug-2026 12:47:17 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[21-Aug-2026 12:47:18 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[22-Aug-2026 01:28:48 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[22-Aug-2026 01:28:48 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
[24-Aug-2026 19:04:51 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-date.php on line 46
|
||||
[24-Aug-2026 19:04:51 Asia/Jakarta] PHP Fatal error: Uncaught Error: Call to undefined function __() in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php:46
|
||||
Stack trace:
|
||||
#0 {main}
|
||||
thrown in /home/nurm6544/public_html/wp-content/plugins/wp-show-posts/admin/butterbean/tmpl/control-datetime.php on line 46
|
||||
@@ -0,0 +1,2 @@
|
||||
<ul class="butterbean-nav"></ul>
|
||||
<div class="butterbean-content"></div>
|
||||
@@ -0,0 +1 @@
|
||||
<a href="#butterbean-{{ data.manager }}-section-{{ data.name }}"><i class="{{ data.icon }}" aria-hidden="true"></i><span class="label">{{ data.label }}</span></a>
|
||||
@@ -0,0 +1,3 @@
|
||||
<# if ( data.description ) { #>
|
||||
<span class="butterbean-description description">{{{ data.description }}}</span>
|
||||
<# } #>
|
||||
@@ -0,0 +1,46 @@
|
||||
#butterbean-control-taxonomy,
|
||||
#butterbean-control-terms {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#butterbean-ui-wp_show_posts input,
|
||||
#butterbean-ui-wp_show_posts select,
|
||||
#butterbean-ui-wp_show_posts textarea {
|
||||
padding: 10px;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.wpsp-pro {
|
||||
background: orange;
|
||||
padding: 5px;
|
||||
color: white;
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
#butterbean-ui-wp_show_posts .butterbean-control-color input {
|
||||
width: 80px;
|
||||
padding: 3px 5px;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
#butterbean-ui-wp_show_posts input[type="checkbox"] {
|
||||
width: auto;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.mce-i-wpsp-add-icon:before {
|
||||
content: "\f163";
|
||||
font: normal 20px/1 'dashicons';
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
#butterbean-control-wpsp_tax_term .butterbean-checkbox-list {
|
||||
display: -webkit-flex;
|
||||
display: flex;
|
||||
-webkit-flex-flow: wrap column;
|
||||
flex-flow: wrap column;
|
||||
max-height: 250px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -0,0 +1,255 @@
|
||||
function wpsp_get_taxonomy( type ) {
|
||||
type = typeof type !== 'undefined' ? type : 'post';
|
||||
var response = jQuery.getJSON({
|
||||
type: 'POST',
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'wpsp_get_taxonomies',
|
||||
wpsp_nonce: wpsp_object.nonce,
|
||||
post_type: type
|
||||
},
|
||||
async: false,
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return response.responseJSON;
|
||||
}
|
||||
|
||||
function wpsp_get_terms( type ) {
|
||||
type = typeof type !== 'undefined' ? type : 'post';
|
||||
var response = jQuery.getJSON({
|
||||
type: 'POST',
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'wpsp_get_terms',
|
||||
wpsp_nonce: wpsp_object.nonce,
|
||||
taxonomy: type
|
||||
},
|
||||
async: false,
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return response.responseJSON;
|
||||
}
|
||||
|
||||
function wpsp_get_option( key ) {
|
||||
key = typeof key !== 'undefined' ? key : 'wpsp_taxonomy';
|
||||
var response = jQuery.getJSON({
|
||||
type: 'POST',
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'wpsp_get_json_option',
|
||||
wpsp_nonce: wpsp_object.nonce,
|
||||
key: key,
|
||||
id: wpsp_object.post_id
|
||||
},
|
||||
async: false,
|
||||
dataType: 'json',
|
||||
}).done( function() {
|
||||
jQuery( '#butterbean-control-wpsp_taxonomy' ).css( 'display', 'block' );
|
||||
jQuery( '#butterbean-control-wpsp_tax_term' ).css( 'display', 'block' );
|
||||
});
|
||||
|
||||
return response.responseJSON;
|
||||
}
|
||||
|
||||
jQuery( document ).ready( function( $ ) {
|
||||
// Populate taxonomy select based on current post type value
|
||||
var taxonomies = wpsp_get_taxonomy( $( '#wpsp-post-type' ).val() );
|
||||
|
||||
$('#wpsp-taxonomy').append( $( '<option></option>' ) );
|
||||
$.each(taxonomies, function(key, value) {
|
||||
$('#wpsp-taxonomy').append( $( '<option></option>' ).attr( 'value', value ).text( value ) );
|
||||
});
|
||||
|
||||
// Set the selected taxonomy value on load
|
||||
$( '#wpsp-taxonomy' ).val( wpsp_get_option( 'wpsp_taxonomy' ) );
|
||||
|
||||
// Show any selected terms
|
||||
var terms = wpsp_get_terms( $( '#wpsp-taxonomy' ).val() );
|
||||
var term_values = wpsp_get_option( 'wpsp_tax_term' );
|
||||
|
||||
$.each(terms, function(key, value) {
|
||||
if ( null !== value ) {
|
||||
if ( $.isArray( term_values ) ) {
|
||||
var checked = ( $.inArray( value, term_values ) > -1 ) ? 'checked="checked"' : '';
|
||||
} else {
|
||||
var checked = ( value === term_values ) ? 'checked="checked"' : '';
|
||||
}
|
||||
|
||||
$('#butterbean-control-wpsp_tax_term .butterbean-checkbox-list').append( $( '<li><label><input ' + checked + ' type="checkbox" value="' + value + '" name="butterbean_wp_show_posts_setting_wpsp_tax_term[]" />' + value + '</label></li>' ) );
|
||||
}
|
||||
});
|
||||
|
||||
// Hide the terms of taxonomy is empty on load
|
||||
if ( '' == $( '#wpsp-taxonomy' ).val() ) {
|
||||
$( '#butterbean-control-wpsp_tax_term' ).hide();
|
||||
}
|
||||
|
||||
// When changing the post type option
|
||||
$( '#wpsp-post-type' ).change(function() {
|
||||
|
||||
$( '#butterbean-control-wpsp_tax_term' ).hide();
|
||||
|
||||
$( '#wpsp-taxonomy' ).empty();
|
||||
|
||||
$( '#wpsp-terms' ).empty();
|
||||
$( '#wpsp-terms' ).append( $( '<option></option>' ) );
|
||||
|
||||
var selectValues = wpsp_get_taxonomy( $(this).val(), false );
|
||||
|
||||
$('#wpsp-taxonomy').append( $( '<option></option>' ) );
|
||||
$.each(selectValues, function(key, value) {
|
||||
$('#wpsp-taxonomy').append( $( '<option></option>' ).attr( 'value', value ).text( value ) );
|
||||
});
|
||||
if ( '' == selectValues ) {
|
||||
$( '#butterbean-control-wpsp_taxonomy' ).hide();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_taxonomy' ).show();
|
||||
}
|
||||
});
|
||||
|
||||
// When changing the taxonomy option
|
||||
$( '#wpsp-taxonomy' ).change(function() {
|
||||
|
||||
// Empty the list of terms
|
||||
$( '#butterbean-control-wpsp_tax_term .butterbean-checkbox-list' ).empty();
|
||||
|
||||
// Get any selected terms
|
||||
var selectValues = wpsp_get_terms( $(this).val() );
|
||||
|
||||
// For each selected term, add the checkbox
|
||||
$.each(selectValues, function(key, value) {
|
||||
if ( null !== value ) {
|
||||
$('#butterbean-control-wpsp_tax_term .butterbean-checkbox-list').append( $( '<li><label><input type="checkbox" value="' + value + '" name="butterbean_wp_show_posts_setting_wpsp_tax_term[]" />' + value + '</label></li>' ) );
|
||||
}
|
||||
});
|
||||
|
||||
// Hide the terms area if we don't have any terms
|
||||
if ( '' == selectValues || ',' == selectValues ) {
|
||||
$( '#butterbean-control-wpsp_tax_term' ).hide();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_tax_term' ).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Fix color label bug introduced in WP 4.9.
|
||||
$( '.butterbean-control-color' ).each( function() {
|
||||
var _this = $( this );
|
||||
_this.find( '.wp-picker-input-wrap.hidden .butterbean-label' ).prependTo( _this );
|
||||
} );
|
||||
|
||||
// Dealing with the image options
|
||||
if ( ! $( '#wpsp-image' ).is( ':checked' ) ) {
|
||||
$( this ).parent().parent().siblings().hide();
|
||||
}
|
||||
|
||||
$( '#wpsp-image' ).change(function() {
|
||||
if ( ! this.checked ) {
|
||||
$( this ).parent().parent().siblings().hide();
|
||||
} else {
|
||||
$( this ).parent().parent().siblings().show();
|
||||
}
|
||||
});
|
||||
|
||||
// Excerpt or full content
|
||||
$( '#wpsp-content-type' ).change(function() {
|
||||
if ( 'excerpt' == $( this ).val() ) {
|
||||
$( '#butterbean-control-wpsp_excerpt_length' ).show();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_excerpt_length' ).hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Title
|
||||
if ( ! $( '#wpsp-include-title' ).is( ':checked' ) ) {
|
||||
$( '#butterbean-control-wpsp_title_element' ).hide();
|
||||
}
|
||||
|
||||
$( '#wpsp-include-title' ).change(function() {
|
||||
if ( ! this.checked ) {
|
||||
$( '#butterbean-control-wpsp_title_element' ).hide();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_title_element' ).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Author location
|
||||
if ( ! $( '#wpsp-include-author' ).is( ':checked' ) ) {
|
||||
$( '#butterbean-control-wpsp_author_location' ).hide();
|
||||
}
|
||||
|
||||
$( '#wpsp-include-author' ).change(function() {
|
||||
if ( ! this.checked ) {
|
||||
$( '#butterbean-control-wpsp_author_location' ).hide();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_author_location' ).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Date location
|
||||
if ( ! $( '#wpsp-include-date' ).is( ':checked' ) ) {
|
||||
$( '#butterbean-control-wpsp_date_location' ).hide();
|
||||
}
|
||||
|
||||
$( '#wpsp-include-date' ).change(function() {
|
||||
if ( ! this.checked ) {
|
||||
$( '#butterbean-control-wpsp_date_location' ).hide();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_date_location' ).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Terms location
|
||||
if ( ! $( '#wpsp-include-terms' ).is( ':checked' ) ) {
|
||||
$( '#butterbean-control-wpsp_terms_location' ).hide();
|
||||
}
|
||||
|
||||
$( '#wpsp-include-terms' ).change(function() {
|
||||
if ( ! this.checked ) {
|
||||
$( '#butterbean-control-wpsp_terms_location' ).hide();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_terms_location' ).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Comments link location
|
||||
if ( ! $( '#wpsp-include-comments-link' ).is( ':checked' ) ) {
|
||||
$( '#butterbean-control-wpsp_comments_location' ).hide();
|
||||
}
|
||||
|
||||
$( '#wpsp-include-comments-link' ).change(function() {
|
||||
if ( ! this.checked ) {
|
||||
$( '#butterbean-control-wpsp_comments_location' ).hide();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_comments_location' ).show();
|
||||
}
|
||||
});
|
||||
|
||||
// Dealing with the social options
|
||||
$( '#wpsp-social-sharing' ).parent().parent().siblings().hide();
|
||||
if ( $( '#wpsp-social-sharing' ).is( ':checked' ) ) {
|
||||
$( '#wpsp-social-sharing' ).parent().parent().siblings().show();
|
||||
}
|
||||
|
||||
$( '#wpsp-social-sharing' ).change(function() {
|
||||
if ( ! this.checked ) {
|
||||
$( this ).parent().parent().siblings().hide();
|
||||
} else {
|
||||
$( this ).parent().parent().siblings().show();
|
||||
}
|
||||
});
|
||||
|
||||
// Pagination
|
||||
if ( ! $( '#wpsp-pagination' ).is( ':checked' ) ) {
|
||||
$( '#butterbean-control-wpsp_ajax_pagination' ).hide();
|
||||
}
|
||||
|
||||
$( '#wpsp-pagination' ).change(function() {
|
||||
if ( ! this.checked ) {
|
||||
$( '#butterbean-control-wpsp_ajax_pagination' ).hide();
|
||||
} else {
|
||||
$( '#butterbean-control-wpsp_ajax_pagination' ).show();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
function wpsp_get_post_lists() {
|
||||
var response = jQuery.getJSON({
|
||||
type: 'POST',
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'wpsp_get_post_lists',
|
||||
wpsp_nonce: wpsp_nonce
|
||||
},
|
||||
async: false,
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
return response.responseJSON;
|
||||
}
|
||||
|
||||
console.log(wpsp_get_post_lists());
|
||||
|
||||
(function() {
|
||||
tinymce.PluginManager.add('wpsp_shortcode_button', function( editor, url ) {
|
||||
editor.addButton( 'wpsp_shortcode_button', {
|
||||
title: wpsp_add_posts,
|
||||
icon: 'wpsp-add-icon',
|
||||
onclick: function() {
|
||||
editor.windowManager.open( {
|
||||
width: 300,
|
||||
height: 75,
|
||||
title: wpsp_add_posts,
|
||||
body: [
|
||||
{
|
||||
type: 'listbox',
|
||||
name: 'wpsp_add_posts',
|
||||
label: false,
|
||||
'values': wpsp_get_post_lists(),
|
||||
}],
|
||||
onsubmit: function( e ) {
|
||||
editor.insertContent( '[wp_show_posts id="' + e.data.wpsp_add_posts + '"]');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,988 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! function_exists( 'wpsp_remove_metaboxes' ) ) {
|
||||
add_action( 'add_meta_boxes', 'wpsp_remove_metaboxes', 99 );
|
||||
/**
|
||||
* Remove all metaboxes from our WP Show Posts post type
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_remove_metaboxes( $post_type ){
|
||||
|
||||
// If we're not in the wp_show_posts post type, bail.
|
||||
if ( ! in_array( $post_type, array( 'wp_show_posts' ) ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
global $wp_meta_boxes;
|
||||
|
||||
// Don't remove the below
|
||||
$exceptions = array(
|
||||
'submitdiv',
|
||||
'butterbean-ui-wp_show_posts',
|
||||
'wpsp_shortcode_metabox'
|
||||
);
|
||||
|
||||
// Loop through all our metaboxes
|
||||
if ( ! empty( $wp_meta_boxes ) ) {
|
||||
foreach( $wp_meta_boxes as $page => $page_boxes ) {
|
||||
if ( ! empty( $page_boxes ) ) {
|
||||
foreach( $page_boxes as $context => $box_context ) {
|
||||
if ( ! empty( $box_context ) ) {
|
||||
foreach( $box_context as $box_type ) {
|
||||
if ( ! empty( $box_type ) ) {
|
||||
foreach( $box_type as $id => $box ) {
|
||||
/** Check to see if the meta box should be removed... */
|
||||
if ( ! in_array( $id, $exceptions ) ) {
|
||||
remove_meta_box( $id, $page, $context );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_get_post_types' ) ) {
|
||||
/**
|
||||
* List of all our post types exluding our own
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_get_post_types() {
|
||||
$post_types = get_post_types( array( 'public' => true ) );
|
||||
$types = array();
|
||||
foreach ( $post_types as $type ) {
|
||||
if ( 'wp_show_posts' !== $type && 'attachment' !== $type ) {
|
||||
$types[ $type ] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
return $types;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_load_butterbean' ) ) {
|
||||
add_action( 'plugins_loaded', 'wpsp_load_butterbean' );
|
||||
/**
|
||||
* Load butterbean inside our post type
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_load_butterbean() {
|
||||
require_once( trailingslashit( dirname( __FILE__ ) ) . '/butterbean/butterbean.php' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_register' ) ) {
|
||||
add_action( 'butterbean_register', 'wpsp_register', 10, 2 );
|
||||
/**
|
||||
* Create all of our metabox options
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_register( $butterbean, $post_type ) {
|
||||
|
||||
$defaults = wpsp_get_defaults();
|
||||
|
||||
// Register managers, sections, controls, and settings here.
|
||||
$butterbean->register_manager(
|
||||
'wp_show_posts',
|
||||
array(
|
||||
'label' => esc_html__( 'WP Show Posts', 'wp-show-posts' ),
|
||||
'post_type' => 'wp_show_posts',
|
||||
'context' => 'normal',
|
||||
'priority' => 'high'
|
||||
)
|
||||
);
|
||||
|
||||
$manager = $butterbean->get_manager( 'wp_show_posts' );
|
||||
|
||||
$manager->register_section(
|
||||
'wpsp_posts',
|
||||
array(
|
||||
'label' => esc_html__( 'Posts', 'wp-show-posts' ),
|
||||
'icon' => 'dashicons-admin-post'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_post_type', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_posts',
|
||||
'label' => esc_html__( 'Post type', 'wp-show-posts' ),
|
||||
'choices' => wpsp_get_post_types(),
|
||||
'attr' => array( 'id' => 'wpsp-post-type' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_post_type', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_post_type' ] ? $defaults[ 'wpsp_post_type' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_taxonomy', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_posts',
|
||||
'label' => esc_html__( 'Taxonomy', 'wp-show-posts' ),
|
||||
'choices' => array(),
|
||||
'attr' => array( 'id' => 'wpsp-taxonomy' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_taxonomy', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_taxonomy' ] ? $defaults[ 'wpsp_taxonomy' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_tax_term', // Same as setting name.
|
||||
array(
|
||||
'type' => 'checkboxes',
|
||||
'section' => 'wpsp_posts',
|
||||
'label' => esc_html__( 'Terms', 'wp-show-posts' ),
|
||||
'choices' => array(),
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_tax_term', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => '',
|
||||
'default' => $defaults[ 'wpsp_tax_term' ] ? $defaults[ 'wpsp_tax_term' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_posts_per_page', // Same as setting name.
|
||||
array(
|
||||
'type' => 'number',
|
||||
'section' => 'wpsp_posts',
|
||||
'label' => esc_html__( 'Posts per page', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_posts_per_page', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wpsp_sanitize_intval',
|
||||
'default' => $defaults[ 'wpsp_posts_per_page' ] ? $defaults[ 'wpsp_posts_per_page' ] : 10
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_pagination',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_posts',
|
||||
'label' => __( 'Pagination','wp-show-posts' ),
|
||||
'description' => __( 'Pagination should only be used if your posts are the only thing in the content area to prevent duplicate content issues.','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-pagination' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_pagination',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => $defaults[ 'wpsp_pagination' ] ? $defaults[ 'wpsp_pagination' ] : false
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_section(
|
||||
'wpsp_columns',
|
||||
array(
|
||||
'label' => esc_html__( 'Columns', 'wp-show-posts' ),
|
||||
'icon' => 'dashicons-grid-view'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_columns', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_columns',
|
||||
'label' => esc_html__( 'Columns', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'col-12' => '1',
|
||||
'col-6' => '2',
|
||||
'col-4' => '3',
|
||||
'col-3' => '4',
|
||||
'col-20' => '5'
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-columns' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_columns', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_columns' ] ? $defaults[ 'wpsp_columns' ] : '12'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_columns_gutter', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'wpsp_columns',
|
||||
'label' => esc_html__( 'Columns gutter', 'wp-show-posts' ),
|
||||
'attr' => array( 'class' => 'widefat' ),
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_columns_gutter', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_columns_gutter' ] ? $defaults[ 'wpsp_columns_gutter' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_section(
|
||||
'wpsp_images',
|
||||
array(
|
||||
'label' => esc_html__( 'Images', 'wp-show-posts' ),
|
||||
'icon' => 'dashicons-format-image'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_image',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_images',
|
||||
'label' => __( 'Images','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-image' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_image',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => $defaults[ 'wpsp_image' ]
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_image_width', // Same as setting name.
|
||||
array(
|
||||
'type' => 'number',
|
||||
'section' => 'wpsp_images',
|
||||
'label' => esc_html__( 'Image width (px)', 'wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-image-width' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_image_width', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wpsp_sanitize_absint',
|
||||
'default' => $defaults[ 'wpsp_image_width' ] ? $defaults[ 'wpsp_image_width' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_image_height', // Same as setting name.
|
||||
array(
|
||||
'type' => 'number',
|
||||
'section' => 'wpsp_images',
|
||||
'label' => esc_html__( 'Image height (px)', 'wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-image-height' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_image_height', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wpsp_sanitize_absint',
|
||||
'default' => $defaults[ 'wpsp_image_height' ] ? $defaults[ 'wpsp_image_height' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_image_alignment', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_images',
|
||||
'label' => esc_html__( 'Image alignment', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'left' => __( 'Left','wp-show-posts' ),
|
||||
'center' => __( 'Center','wp-show-posts' ),
|
||||
'right' => __( 'Right','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-image-alignment' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_image_alignment', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_image_alignment' ] ? $defaults[ 'wpsp_image_alignment' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_image_location', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_images',
|
||||
'label' => esc_html__( 'Image location', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'below-title' => __( 'Below title','wp-show-posts' ),
|
||||
'above-title' => __( 'Above title','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-image-location' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_image_location', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_image_location' ] ? $defaults[ 'wpsp_image_location' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_section(
|
||||
'wpsp_content',
|
||||
array(
|
||||
'label' => esc_html__( 'Content', 'wp-show-posts' ),
|
||||
'icon' => 'dashicons-editor-alignleft'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_content_type', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_content',
|
||||
'label' => esc_html__( 'Content type', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'excerpt' => __( 'Excerpt','wp-show-posts' ),
|
||||
'full' => __( 'Full','wp-show-posts' ),
|
||||
'none' => __( 'None','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-content-type' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_content_type', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_content_type' ] ? $defaults[ 'wpsp_content_type' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_excerpt_length', // Same as setting name.
|
||||
array(
|
||||
'type' => 'number',
|
||||
'section' => 'wpsp_content',
|
||||
'label' => esc_html__( 'Excerpt length (words)', 'wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-excerpt-length' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_excerpt_length', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wpsp_sanitize_absint',
|
||||
'default' => $defaults[ 'wpsp_excerpt_length' ] ? $defaults[ 'wpsp_excerpt_length' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_include_title',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_content',
|
||||
'label' => __( 'Include title','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-include-title' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_include_title',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => true
|
||||
)
|
||||
);
|
||||
|
||||
// Title element
|
||||
$manager->register_control(
|
||||
'wpsp_title_element', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_content',
|
||||
'label' => esc_html__( 'Title element', 'wp-show-posts-pro' ),
|
||||
'choices' => array(
|
||||
'' => '',
|
||||
'p' => 'p',
|
||||
'span' => 'span',
|
||||
'h1' => 'h1',
|
||||
'h2' => 'h2',
|
||||
'h3' => 'h3',
|
||||
'h4' => 'h4',
|
||||
'h5' => 'h5'
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-title-element' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_title_element', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_title_element' ] ? $defaults[ 'wpsp_title_element' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_read_more_text', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'wpsp_content',
|
||||
'label' => esc_html__( 'Read more text', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_read_more_text', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wp_kses_post',
|
||||
'default' => $defaults[ 'wpsp_read_more_text' ]
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_read_more_class', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'wpsp_content',
|
||||
'label' => esc_html__( 'Read more button class', 'wp-show-posts' ),
|
||||
'priority' => 75
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_read_more_class', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'esc_attr',
|
||||
'default' => $defaults[ 'wpsp_read_more_class' ] ? $defaults[ 'wpsp_read_more_class' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_section(
|
||||
'wpsp_post_meta',
|
||||
array(
|
||||
'label' => esc_html__( 'Meta', 'wp-show-posts' ),
|
||||
'icon' => 'dashicons-editor-ul'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_include_author',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_post_meta',
|
||||
'label' => __( 'Include author','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-include-author' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_include_author',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => $defaults[ 'wpsp_include_author' ] ? $defaults[ 'wpsp_include_author' ] : false
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_author_location', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_post_meta',
|
||||
'label' => esc_html__( 'Author location', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'below-title' => __( 'Below title','wp-show-posts' ),
|
||||
'below-post' => __( 'Below post','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-author-location' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_author_location', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_author_location' ] ? $defaults[ 'wpsp_author_location' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_include_date',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_post_meta',
|
||||
'label' => __( 'Include date','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-include-date' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_include_date',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => $defaults[ 'wpsp_include_date' ] ? $defaults[ 'wpsp_include_date' ] : false
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_date_location', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_post_meta',
|
||||
'label' => esc_html__( 'Date location', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'below-title' => __( 'Below title','wp-show-posts' ),
|
||||
'below-post' => __( 'Below post','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-date-location' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_date_location', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_date_location' ] ? $defaults[ 'wpsp_date_location' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_include_terms',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_post_meta',
|
||||
'label' => __( 'Include terms','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-include-terms' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_include_terms',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => $defaults[ 'wpsp_include_terms' ] ? $defaults[ 'wpsp_include_terms' ] : false
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_terms_location', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_post_meta',
|
||||
'label' => esc_html__( 'Terms location', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'below-title' => __( 'Below title','wp-show-posts' ),
|
||||
'below-post' => __( 'Below post','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-terms-location' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_terms_location', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_terms_location' ] ? $defaults[ 'wpsp_terms_location' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_include_comments',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_post_meta',
|
||||
'label' => __( 'Include comments link','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-include-comments-link' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_include_comments',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => $defaults[ 'wpsp_include_comments' ] ? $defaults[ 'wpsp_include_comments' ] : false
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_comments_location', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_post_meta',
|
||||
'label' => esc_html__( 'Comments link location', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'below-title' => __( 'Below title','wp-show-posts' ),
|
||||
'below-post' => __( 'Below post','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-comments-link-location' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_comments_location', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_comments_location' ] ? $defaults[ 'wpsp_comments_location' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_section(
|
||||
'wpsp_query_args',
|
||||
array(
|
||||
'label' => esc_html__( 'More settings', 'wp-show-posts' ),
|
||||
'icon' => 'dashicons-admin-generic',
|
||||
'priority' => 999
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_author', // Same as setting name.
|
||||
array(
|
||||
'type' => 'number',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Author ID', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_author', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wpsp_sanitize_absint',
|
||||
'default' => $defaults[ 'wpsp_author' ] ? $defaults[ 'wpsp_author' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_exclude_current',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => __( 'Exclude current','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-exclude-current' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_exclude_current',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => $defaults[ 'wpsp_exclude_current' ] ? $defaults[ 'wpsp_exclude_current' ] : false
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_post_id', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Post IDs', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_post_id', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_post_id' ] ? $defaults[ 'wpsp_post_id' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_exclude_post_id', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Exclude Post IDs', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_exclude_post_id', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_exclude_post_id' ] ? $defaults[ 'wpsp_exclude_post_id' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_ignore_sticky_posts',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => __( 'Ignore sticky posts','wp-show-posts' ),
|
||||
'attr' => array( 'id' => 'wpsp-ignore-sticky-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_ignore_sticky_posts',
|
||||
array(
|
||||
'sanitize_callback' => 'butterbean_validate_boolean',
|
||||
'default' => $defaults[ 'wpsp_ignore_sticky_posts' ] ? $defaults[ 'wpsp_ignore_sticky_posts' ] : false
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_offset', // Same as setting name.
|
||||
array(
|
||||
'type' => 'number',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Offset', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_offset', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wpsp_sanitize_absint',
|
||||
'default' => $defaults[ 'wpsp_offset' ] ? $defaults[ 'wpsp_offset' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_order', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Order', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'DESC' => __( 'Descending','wp-show-posts' ),
|
||||
'ASC' => __( 'Ascending','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-order' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_order', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_order' ] ? $defaults[ 'wpsp_order' ] : 'DESC'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_orderby', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Order by', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'none' => __( 'No order','wp-show-posts' ),
|
||||
'ID' => __( 'ID','wp-show-posts' ),
|
||||
'author' => __( 'Author','wp-show-posts' ),
|
||||
'title' => __( 'Title','wp-show-posts' ),
|
||||
'name' => __( 'Slug','wp-show-posts' ),
|
||||
'type' => __( 'Post type','wp-show-posts' ),
|
||||
'date' => __( 'Date','wp-show-posts' ),
|
||||
'modified' => __( 'Modified','wp-show-posts' ),
|
||||
'parent' => __( 'Parent','wp-show-posts' ),
|
||||
'rand' => __( 'Random','wp-show-posts' ),
|
||||
'comment_count' => __( 'Comment count','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-orderby' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_orderby', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_orderby' ] ? $defaults[ 'wpsp_orderby' ] : 'date'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_post_status', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Status', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'publish' => __( 'Published','wp-show-posts' ),
|
||||
'pending' => __( 'Pending','wp-show-posts' ),
|
||||
'draft' => __( 'Draft','wp-show-posts' ),
|
||||
'auto-draft' => __( 'Auto draft','wp-show-posts' ),
|
||||
'future' => __( 'Future','wp-show-posts' ),
|
||||
'private' => __( 'Private','wp-show-posts' ),
|
||||
'inherit' => __( 'Inherit','wp-show-posts' ),
|
||||
'trash' => __( 'Trash','wp-show-posts' ),
|
||||
'any' => __( 'Any','wp-show-posts' )
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-post-status' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_post_status', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_post_status' ] ? $defaults[ 'wpsp_post_status' ] : 'publish'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_meta_key', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Meta key', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_meta_key', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_meta_key' ] ? $defaults[ 'wpsp_meta_key' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_meta_value', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Meta value', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_meta_value', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_meta_value' ] ? $defaults[ 'wpsp_meta_value' ] : ''
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_tax_operator', // Same as setting name.
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'Tax operator', 'wp-show-posts' ),
|
||||
'choices' => array(
|
||||
'IN' => 'IN',
|
||||
'NOT IN' => 'NOT IN',
|
||||
'AND' => 'AND',
|
||||
'EXISTS' => 'EXISTS',
|
||||
'NOT EXISTS' => 'NOT EXISTS'
|
||||
),
|
||||
'attr' => array( 'id' => 'wpsp-tax-operator' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_tax_operator', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'sanitize_text_field',
|
||||
'default' => $defaults[ 'wpsp_tax_operator' ] ? $defaults[ 'wpsp_tax_operator' ] : 'IN'
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_control(
|
||||
'wpsp_no_results', // Same as setting name.
|
||||
array(
|
||||
'type' => 'text',
|
||||
'section' => 'wpsp_query_args',
|
||||
'label' => esc_html__( 'No results message', 'wp-show-posts' )
|
||||
)
|
||||
);
|
||||
|
||||
$manager->register_setting(
|
||||
'wpsp_no_results', // Same as control name.
|
||||
array(
|
||||
'sanitize_callback' => 'wp_kses_post',
|
||||
'default' => $defaults[ 'wpsp_no_results' ] ? $defaults[ 'wpsp_no_results' ] : ''
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_sanitize_intval' ) ) {
|
||||
/**
|
||||
* Sanitize our value so it has to be a positive integer
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_sanitize_intval( $input ) {
|
||||
if ( '' == $input ) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
return intval( $input );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_sanitize_absint' ) ) {
|
||||
/**
|
||||
* Sanitize our value so it can be a negative or positive integer
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_sanitize_absint( $input ) {
|
||||
if ( '' == $input ) {
|
||||
return $input;
|
||||
}
|
||||
|
||||
return absint( $input );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_add_meta_boxes' ) ) {
|
||||
add_action( 'add_meta_boxes_wp_show_posts', 'wpsp_add_meta_boxes' );
|
||||
/**
|
||||
* Add our usage metabox
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_add_meta_boxes( $post ){
|
||||
add_meta_box( 'wpsp_shortcode', __( 'Usage', 'wp-show-posts' ), 'wpsp_shortcode_metabox', 'wp_show_posts', 'side', 'low' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_shortcode_metabox' ) ) {
|
||||
/**
|
||||
* Meta box display callback.
|
||||
*
|
||||
* @param WP_Post $post Current post object.
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_shortcode_metabox( $post ) {
|
||||
?>
|
||||
<h4 style="margin-bottom:5px;"><?php _e( 'Shortcode','wp-show-posts' ); ?></h4>
|
||||
<input type="text" class="widefat" value='[wp_show_posts id="<?php echo $post->ID;?>"]' readonly />
|
||||
|
||||
<h4 style="margin-bottom:5px;"><?php _e( 'Function','wp-show-posts' ); ?></h4>
|
||||
<input type="text" class="widefat" value='<?php echo esc_attr( "<?php if ( function_exists( 'wpsp_display' ) ) wpsp_display( " . $post->ID . " ); ?>" ); ?>' readonly />
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wp_show_posts_type' ) ) {
|
||||
add_action( 'init', 'wp_show_posts_type', 0 );
|
||||
/**
|
||||
* Create our WP Show Posts post type
|
||||
* @since 0.1
|
||||
*/
|
||||
function wp_show_posts_type() {
|
||||
|
||||
$labels = array(
|
||||
'name' => _x( 'Post Lists', 'Post Type General Name', 'wp-show-posts' ),
|
||||
'singular_name' => _x( 'Post List', 'Post Type Singular Name', 'wp-show-posts' ),
|
||||
'menu_name' => __( 'WP Show Posts', 'wp-show-posts' ),
|
||||
'name_admin_bar' => __( 'WP Show Posts', 'wp-show-posts' ),
|
||||
'archives' => __( 'List Archives', 'wp-show-posts' ),
|
||||
'parent_item_colon' => __( 'Parent List:', 'wp-show-posts' ),
|
||||
'all_items' => __( 'All Lists', 'wp-show-posts' ),
|
||||
'add_new_item' => __( 'Add New List', 'wp-show-posts' ),
|
||||
'add_new' => __( 'Add New', 'wp-show-posts' ),
|
||||
'new_item' => __( 'New List', 'wp-show-posts' ),
|
||||
'edit_item' => __( 'Edit List', 'wp-show-posts' ),
|
||||
'update_item' => __( 'Update List', 'wp-show-posts' ),
|
||||
'view_item' => __( 'View List', 'wp-show-posts' ),
|
||||
'search_items' => __( 'Search List', 'wp-show-posts' ),
|
||||
'not_found' => __( 'Not found', 'wp-show-posts' ),
|
||||
'not_found_in_trash' => __( 'Not found in Trash', 'wp-show-posts' ),
|
||||
'featured_image' => __( 'Featured Image', 'wp-show-posts' ),
|
||||
'set_featured_image' => __( 'Set featured image', 'wp-show-posts' ),
|
||||
'remove_featured_image' => __( 'Remove featured image', 'wp-show-posts' ),
|
||||
'use_featured_image' => __( 'Use as featured image', 'wp-show-posts' ),
|
||||
'insert_into_item' => __( 'Insert into list', 'wp-show-posts' ),
|
||||
'uploaded_to_this_item' => __( 'Uploaded to this list', 'wp-show-posts' ),
|
||||
'items_list' => __( 'Items list', 'wp-show-posts' ),
|
||||
'items_list_navigation' => __( 'Items list navigation', 'wp-show-posts' ),
|
||||
'filter_items_list' => __( 'Filter items list', 'wp-show-posts' ),
|
||||
);
|
||||
$args = array(
|
||||
'label' => __( 'Post List', 'wp-show-posts' ),
|
||||
'labels' => $labels,
|
||||
'supports' => array( 'title' ),
|
||||
'hierarchical' => false,
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => true,
|
||||
'menu_position' => 5,
|
||||
'show_in_admin_bar' => false,
|
||||
'show_in_nav_menus' => false,
|
||||
'can_export' => true,
|
||||
'has_archive' => false,
|
||||
'exclude_from_search' => true,
|
||||
'publicly_queryable' => false,
|
||||
'capability_type' => 'page',
|
||||
);
|
||||
register_post_type( 'wp_show_posts', $args );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds WPSP_Widget widget.
|
||||
*/
|
||||
if ( ! class_exists( 'WPSP_Widget' ) ) {
|
||||
class WPSP_Widget extends WP_Widget {
|
||||
|
||||
/**
|
||||
* Register widget with WordPress.
|
||||
*/
|
||||
function __construct() {
|
||||
parent::__construct(
|
||||
'wpsp_widget', // Base ID
|
||||
__( 'WP Show Posts', 'wp-show-posts' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Front-end display of widget.
|
||||
*
|
||||
* @see WP_Widget::widget()
|
||||
*
|
||||
* @param array $args Widget arguments.
|
||||
* @param array $instance Saved values from database.
|
||||
*/
|
||||
public function widget( $args, $instance ) {
|
||||
echo $args['before_widget'];
|
||||
|
||||
if ( ! empty( $instance['title'] ) ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
|
||||
}
|
||||
|
||||
if ( function_exists( 'wpsp_display' ) ) {
|
||||
wpsp_display( absint( $instance['wpsp_id'] ) );
|
||||
}
|
||||
|
||||
echo $args['after_widget'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Back-end widget form.
|
||||
*
|
||||
* @see WP_Widget::form()
|
||||
*
|
||||
* @param array $instance Previously saved values from database.
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : '';
|
||||
$id = ! empty( $instance['wpsp_id'] ) ? $instance['wpsp_id'] : '';
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( esc_attr( 'Title:' ) ); ?></label>
|
||||
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>">
|
||||
</p>
|
||||
<p>
|
||||
<select name="<?php echo $this->get_field_name( 'wpsp_id' );?>" id="<?php echo $this->get_field_id( 'wpsp_id' );?>">
|
||||
<option value=""></option>
|
||||
<?php
|
||||
$args = array(
|
||||
'posts_per_page' => -1,
|
||||
'post_type' => 'wp_show_posts',
|
||||
'post_status' => 'publish',
|
||||
'showposts' => -1
|
||||
);
|
||||
$posts = get_posts( $args );
|
||||
|
||||
$count = count( $posts );
|
||||
$types = array();
|
||||
if ( $count > 0 ) {
|
||||
foreach ( $posts as $post ) {
|
||||
echo '<option value="' . $post->ID . '"' . selected( $id, $post->ID ) . '>' . $post->post_title . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize widget form values as they are saved.
|
||||
*
|
||||
* @see WP_Widget::update()
|
||||
*
|
||||
* @param array $new_instance Values just sent to be saved.
|
||||
* @param array $old_instance Previously saved values from database.
|
||||
*
|
||||
* @return array Updated safe values to be saved.
|
||||
*/
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = array();
|
||||
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
|
||||
$instance['wpsp_id'] = ( ! empty( $new_instance['wpsp_id'] ) ) ? absint( $new_instance['wpsp_id'] ) : '';
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
} // class WPSP_Widget
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_register_widget' ) ) {
|
||||
add_action( 'widgets_init', 'wpsp_register_widget' );
|
||||
|
||||
function wpsp_register_widget() {
|
||||
register_widget( 'WPSP_Widget' );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
body .wp-show-posts a{box-shadow:0 0 0 transparent}.wp-show-posts-entry-title a{text-decoration:none}a.wp-show-posts-read-more,a.wp-show-posts-read-more:visited{display:inline-block;padding:8px 15px;border:2px solid #222;color:#222;font-size:.8em;text-decoration:none}.wpsp-read-more{margin:0 0 1em;display:inline-block}a.wp-show-posts-read-more:focus,a.wp-show-posts-read-more:hover{border:2px solid transparent;color:#fff;background:#222;text-decoration:none}.wp-show-posts-image{margin-bottom:1em}.wp-show-posts-image.wpsp-image-left{float:left;margin-right:1.5em}.wp-show-posts-image.wpsp-image-right{float:right;margin-left:1.5em}.wp-show-posts-image.wpsp-image-center{display:block;text-align:center}.wp-show-posts-image img{margin:0!important;vertical-align:bottom;height:auto}.wp-show-posts-entry-header{margin:0 0 1em;padding:0}.wp-show-posts .wp-show-posts-entry-title{margin:0}.wp-show-posts-updated{display:none}.wp-show-posts-entry-content,.wp-show-posts-entry-summary{margin-bottom:1em}.wp-show-posts-entry-meta{font-size:.8em}.wp-show-posts-separator{opacity:.5}.wp-show-posts-meta a,.wp-show-posts-meta a:visited{color:rgba(0,0,0,.5)}.stack-wp-show-posts-byline,.stack-wp-show-posts-posted-on{display:block}.wp-show-posts-entry-meta-below-post{margin-bottom:1em}.wp-show-posts-columns:not(.wp-show-posts-masonry){display:flex;flex-wrap:wrap}.wp-show-posts-columns .wp-show-posts-single:not(.wp-show-posts-masonry-block){display:flex;flex-direction:row}.wp-show-posts-columns .wp-show-posts-single:not(.wp-show-posts-masonry-block) .wp-show-posts-image img{flex:0 0 auto;object-fit:scale-down}.wpsp-clear{clear:both;display:block;overflow:hidden;visibility:hidden;width:0;height:0}.wp-show-posts:not(.wp-show-posts-columns) .wp-show-posts-single:not(:last-child){margin-bottom:2em}.wpsp-load-more{margin-top:2em}.wp-show-posts-columns .wp-show-posts-inner{flex:1}.wp-show-posts-inner:after{clear:both;display:table;content:'';width:0;height:0;overflow:hidden;visibility:hidden}.wp-show-posts-single.post{margin-bottom:0}@media (min-width:768px){.wpsp-col-1,.wpsp-col-10,.wpsp-col-11,.wpsp-col-12,.wpsp-col-2,.wpsp-col-20,.wpsp-col-3,.wpsp-col-4,.wpsp-col-5,.wpsp-col-6,.wpsp-col-7,.wpsp-col-8,.wpsp-col-9{float:left}.wpsp-col-1{width:8.333333%}.wpsp-col-2{width:16.666667%}.wpsp-col-3{width:25%}.wpsp-col-4{width:33.333%}.wpsp-col-5{width:41.666667%}.wpsp-col-6{width:50%}.wpsp-col-7{width:58.333333%}.wpsp-col-8{width:66.666667%}.wpsp-col-9{width:75%}.wpsp-col-10{width:83.333333%}.wpsp-col-11{width:91.666667%}.wpsp-col-12{width:100%}.wpsp-col-20{width:20%}}@media (max-width:767px){.wp-show-posts-columns,.wp-show-posts-inner{margin-left:0!important;margin-right:0!important}.wp-show-posts-columns .wp-show-posts-single{display:block;width:100%}.wp-show-posts-image.wpsp-image-left,.wp-show-posts-image.wpsp-image-right{float:none;margin-right:0;margin-left:0}}.wp-show-posts-inner :last-child{margin-bottom:0}.screen-reader-text{clip:rect(1px,1px,1px,1px);position:absolute!important}.screen-reader-text:active,.screen-reader-text:focus,.screen-reader-text:hover{background-color:#f1f1f1;border-radius:3px;box-shadow:0 0 2px 2px rgba(0,0,0,.6);clip:auto!important;color:#21759b;display:block;font-size:14px;font-weight:700;height:auto;left:5px;line-height:normal;padding:15px 23px 14px;text-decoration:none;top:5px;width:auto;z-index:100000}.wpsp-clearfix:after{content:".";display:block;overflow:hidden;visibility:hidden;font-size:0;line-height:0;width:0;height:0}
|
||||
@@ -0,0 +1,253 @@
|
||||
body .wp-show-posts a {
|
||||
box-shadow: 0 0 0 transparent;
|
||||
}
|
||||
|
||||
.wp-show-posts-entry-title a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.wp-show-posts-read-more,
|
||||
a.wp-show-posts-read-more:visited {
|
||||
display: inline-block;
|
||||
padding: 8px 15px;
|
||||
border: 2px solid #222;
|
||||
color: #222;
|
||||
font-size: 0.8em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wpsp-read-more {
|
||||
margin: 0 0 1em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
a.wp-show-posts-read-more:hover,
|
||||
a.wp-show-posts-read-more:focus {
|
||||
border: 2px solid transparent;
|
||||
color: #fff;
|
||||
background: #222;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.wp-show-posts-image {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.wp-show-posts-image.wpsp-image-left {
|
||||
float: left;
|
||||
margin-right: 1.5em;
|
||||
}
|
||||
|
||||
.wp-show-posts-image.wpsp-image-right {
|
||||
float: right;
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
.wp-show-posts-image.wpsp-image-center {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.wp-show-posts-image img {
|
||||
margin: 0 !important;
|
||||
vertical-align: bottom;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.wp-show-posts-entry-header {
|
||||
margin: 0 0 1em;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.wp-show-posts .wp-show-posts-entry-title {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.wp-show-posts-updated {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.wp-show-posts-entry-summary,
|
||||
.wp-show-posts-entry-content {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.wp-show-posts-entry-meta {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.wp-show-posts-separator {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.wp-show-posts-meta a,
|
||||
.wp-show-posts-meta a:visited {
|
||||
color: rgba( 0,0,0,0.5 );
|
||||
}
|
||||
|
||||
.stack-wp-show-posts-byline,
|
||||
.stack-wp-show-posts-posted-on {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.wp-show-posts-entry-meta-below-post {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.wp-show-posts-columns:not(.wp-show-posts-masonry) {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.wp-show-posts-columns .wp-show-posts-single:not(.wp-show-posts-masonry-block) {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.wp-show-posts-columns .wp-show-posts-single:not(.wp-show-posts-masonry-block) .wp-show-posts-image img {
|
||||
flex: 0 0 auto;
|
||||
object-fit: scale-down;
|
||||
}
|
||||
|
||||
.wpsp-clear {
|
||||
clear: both;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.wp-show-posts:not(.wp-show-posts-columns) .wp-show-posts-single:not(:last-child) {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.wpsp-load-more {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.wp-show-posts-columns .wp-show-posts-inner {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.wp-show-posts-inner:after {
|
||||
clear: both;
|
||||
display: table;
|
||||
content: '';
|
||||
width: 0;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.wp-show-posts-single.post {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Bootstrap grid system */
|
||||
@media (min-width: 768px) {
|
||||
.wpsp-col-1, .wpsp-col-2, .wpsp-col-3, .wpsp-col-4, .wpsp-col-5, .wpsp-col-6, .wpsp-col-7, .wpsp-col-8, .wpsp-col-9, .wpsp-col-10, .wpsp-col-11, .wpsp-col-12, .wpsp-col-20 {
|
||||
float: left;
|
||||
}
|
||||
.wpsp-col-1 {
|
||||
width: 8.333333%;
|
||||
}
|
||||
.wpsp-col-2 {
|
||||
width: 16.666667%;
|
||||
}
|
||||
.wpsp-col-3 {
|
||||
width: 25%;
|
||||
}
|
||||
.wpsp-col-4 {
|
||||
width: 33.333%;
|
||||
}
|
||||
.wpsp-col-5 {
|
||||
width: 41.666667%;
|
||||
}
|
||||
.wpsp-col-6 {
|
||||
width: 50%;
|
||||
}
|
||||
.wpsp-col-7 {
|
||||
width: 58.333333%;
|
||||
}
|
||||
.wpsp-col-8 {
|
||||
width: 66.666667%;
|
||||
}
|
||||
.wpsp-col-9 {
|
||||
width: 75%;
|
||||
}
|
||||
.wpsp-col-10 {
|
||||
width: 83.333333%;
|
||||
}
|
||||
.wpsp-col-11 {
|
||||
width: 91.666667%;
|
||||
}
|
||||
.wpsp-col-12 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 5 columns */
|
||||
.wpsp-col-20 {
|
||||
width: 20%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.wp-show-posts-columns,
|
||||
.wp-show-posts-inner {
|
||||
margin-left: 0 !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
.wp-show-posts-columns .wp-show-posts-single {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
.wp-show-posts-image.wpsp-image-left,
|
||||
.wp-show-posts-image.wpsp-image-right {
|
||||
float: none;
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Spacing */
|
||||
.wp-show-posts-inner *:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Screen reader text*/
|
||||
.screen-reader-text {
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
position: absolute !important;
|
||||
}
|
||||
|
||||
.screen-reader-text:hover,
|
||||
.screen-reader-text:active,
|
||||
.screen-reader-text:focus {
|
||||
background-color: #f1f1f1;
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.6);
|
||||
clip: auto !important;
|
||||
color: #21759b;
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
height: auto;
|
||||
left: 5px;
|
||||
line-height: normal;
|
||||
padding: 15px 23px 14px;
|
||||
text-decoration: none;
|
||||
top: 5px;
|
||||
width: auto;
|
||||
z-index: 100000; /* Above WP toolbar */
|
||||
}
|
||||
|
||||
.wpsp-clearfix:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! function_exists( 'wpsp_pro_defaults' ) ) {
|
||||
add_filter( 'wpsp_defaults', 'wpsp_pro_compat_defaults' );
|
||||
/**
|
||||
* Set all of our pro defaults
|
||||
* This will only run if wpsp_pro_defaults() doesn't exist
|
||||
* WPSP Pro 0.5 and above won't need this
|
||||
*/
|
||||
function wpsp_pro_compat_defaults( $defaults ) {
|
||||
$defaults[ 'wpsp_image_lightbox' ] = false;
|
||||
$defaults[ 'wpsp_image_gallery' ] = false;
|
||||
$defaults[ 'wpsp_image_overlay_color' ] = '';
|
||||
$defaults[ 'wpsp_image_overlay_icon' ] = '';
|
||||
$defaults[ 'wpsp_ajax_pagination' ] = false;
|
||||
$defaults[ 'wpsp_masonry' ] = false;
|
||||
$defaults[ 'wpsp_social_sharing' ] = false;
|
||||
$defaults[ 'wpsp_social_sharing_alignment' ] = 'right';
|
||||
$defaults[ 'wpsp_twitter' ] = false;
|
||||
$defaults[ 'wpsp_facebook' ] = false;
|
||||
$defaults[ 'wpsp_googleplus' ] = false;
|
||||
$defaults[ 'wpsp_pinterest' ] = false;
|
||||
$defaults[ 'wpsp_love' ] = false;
|
||||
$defaults[ 'wpsp_featured_post' ] = false;
|
||||
$defaults[ 'wpsp_image_hover_effect' ] = '';
|
||||
$defaults[ 'wpsp_read_more_style' ] = 'hollow';
|
||||
$defaults[ 'wpsp_read_more_color' ] = 'black';
|
||||
$defaults[ 'wpsp_border' ] = '';
|
||||
$defaults[ 'wpsp_border_hover' ] = '';
|
||||
$defaults[ 'wpsp_filter' ] = false;
|
||||
$defaults[ 'wpsp_background' ] = '';
|
||||
$defaults[ 'wpsp_background_hover' ] = '';
|
||||
$defaults[ 'wpsp_title_color' ] = '';
|
||||
$defaults[ 'wpsp_title_color_hover' ] = '';
|
||||
$defaults[ 'wpsp_meta_color' ] = '';
|
||||
$defaults[ 'wpsp_meta_color_hover' ] = '';
|
||||
$defaults[ 'wpsp_text' ] = '';
|
||||
$defaults[ 'wpsp_link' ] = '';
|
||||
$defaults[ 'wpsp_link_hover' ] = '';
|
||||
$defaults[ 'wpsp_padding' ] = '';
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if ( ! function_exists( 'wpsp_get_defaults' ) ) {
|
||||
/**
|
||||
* Set all of our defaults
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_get_defaults() {
|
||||
$defaults = array(
|
||||
'wpsp_author' => '',
|
||||
'wpsp_author_location' => 'below-post',
|
||||
'wpsp_columns' => 'col-6',
|
||||
'wpsp_columns_gutter' => '2em',
|
||||
'wpsp_content_type' => 'excerpt',
|
||||
'wpsp_date_location' => 'below-title',
|
||||
'wpsp_exclude_current' => false,
|
||||
'wpsp_excerpt_length' => 30,
|
||||
'wpsp_post_id' => '',
|
||||
'wpsp_exclude_post_id' => '',
|
||||
'wpsp_ignore_sticky_posts' => false,
|
||||
'wpsp_image' => true,
|
||||
'wpsp_image_alignment' => 'center',
|
||||
'wpsp_image_height' => '',
|
||||
'wpsp_image_location' => 'below-title',
|
||||
'wpsp_image_width' => '',
|
||||
'wpsp_include_title' => true,
|
||||
'wpsp_title_element' => 'h2',
|
||||
'wpsp_include_terms' => false,
|
||||
'wpsp_include_author' => false,
|
||||
'wpsp_include_date' => true,
|
||||
'wpsp_include_comments' => false,
|
||||
'wpsp_comments_location' => 'below-post',
|
||||
'wpsp_inner_wrapper' => 'article',
|
||||
'wpsp_inner_wrapper_class' => '',
|
||||
'wpsp_inner_wrapper_style' => '',
|
||||
'wpsp_itemtype' => 'CreativeWork',
|
||||
'wpsp_meta_key' => '',
|
||||
'wpsp_meta_value' => '',
|
||||
'wpsp_offset' => 0,
|
||||
'wpsp_order' => 'DESC',
|
||||
'wpsp_orderby' => 'date',
|
||||
'wpsp_pagination' => false,
|
||||
'wpsp_post_meta_bottom_style' => 'stack',
|
||||
'wpsp_post_meta_top_style' => 'inline',
|
||||
'wpsp_post_status' => 'publish',
|
||||
'wpsp_post_type' => 'post',
|
||||
'wpsp_posts_per_page' => 10,
|
||||
'wpsp_read_more_text' => '',
|
||||
'wpsp_tax_operator' => 'IN',
|
||||
'wpsp_tax_term' => '',
|
||||
'wpsp_taxonomy' => 'category',
|
||||
'wpsp_terms_location' => 'below-post',
|
||||
'wpsp_wrapper' => 'section',
|
||||
'wpsp_wrapper_class' => '',
|
||||
'wpsp_wrapper_id' => false,
|
||||
'wpsp_wrapper_style' => '',
|
||||
'wpsp_no_results' => __( 'Sorry, no posts were found.','wp-show-posts' ),
|
||||
'wpsp_read_more_class' => 'wp-show-posts-read-more',
|
||||
);
|
||||
|
||||
return apply_filters( 'wpsp_defaults', $defaults );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
if ( ! function_exists( 'wpsp_get_min_suffix' ) ) {
|
||||
/**
|
||||
* Figure out if we should use minified scripts or not
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_get_min_suffix() {
|
||||
return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '-min';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the excerpt length.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
function wpsp_excerpt_length() {
|
||||
global $wpsp_id;
|
||||
return absint( wpsp_get_setting( $wpsp_id, 'wpsp_excerpt_length' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read more ellipses.
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
function wpsp_excerpt_more() {
|
||||
return apply_filters( 'wpsp_ellipses', '...' );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_excerpt' ) ) {
|
||||
/**
|
||||
* Build our excerpt
|
||||
* @since 0.9
|
||||
*/
|
||||
function wpsp_excerpt() {
|
||||
add_filter( 'excerpt_length', 'wpsp_excerpt_length', 999 );
|
||||
add_filter( 'excerpt_more', 'wpsp_excerpt_more', 999 );
|
||||
the_excerpt();
|
||||
remove_filter( 'excerpt_length', 'wpsp_excerpt_length', 999 );
|
||||
remove_filter( 'excerpt_more', 'wpsp_excerpt_more', 999 );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_meta' ) ) {
|
||||
/**
|
||||
* Build our post meta.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_meta( $location, $settings ) {
|
||||
$output = array();
|
||||
|
||||
if ( 'below-post' == $location ) {
|
||||
$post_meta_style = $settings[ 'post_meta_bottom_style' ];
|
||||
} elseif ( 'below-title' == $location ) {
|
||||
$post_meta_style = $settings[ 'post_meta_top_style' ];
|
||||
}
|
||||
|
||||
if ( ( $settings[ 'include_author' ] && $location == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && $location == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && $location == $settings[ 'terms_location' ] ) || ( $settings[ 'include_comments' ] && $location == $settings[ 'comments_location' ] ) ) {
|
||||
echo '<div class="wp-show-posts-entry-meta wp-show-posts-entry-meta-' . $location . ' post-meta-' . esc_attr( $post_meta_style ) . '">';
|
||||
}
|
||||
|
||||
// If our author is enabled, show it
|
||||
if ( $settings[ 'include_author' ] && $location == $settings[ 'author_location' ] ) {
|
||||
$output[] = apply_filters( 'wpsp_author_output', sprintf(
|
||||
'<span class="wp-show-posts-byline wp-show-posts-meta">
|
||||
<span class="wp-show-posts-author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">
|
||||
<a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url">
|
||||
<span class="author-name" itemprop="name">%3$s</span>
|
||||
</a>
|
||||
</span>
|
||||
</span>',
|
||||
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
|
||||
esc_attr( sprintf( __( 'View all posts by %s', 'wp-show-posts' ), get_the_author() ) ),
|
||||
esc_html( get_the_author() )
|
||||
) );
|
||||
}
|
||||
|
||||
// Show the date
|
||||
if ( $settings[ 'include_date' ] && $location == $settings[ 'date_location' ] ) {
|
||||
$time_string = '<time class="wp-show-posts-entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
|
||||
|
||||
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
|
||||
$time_string .= '<time class="wp-show-posts-updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';
|
||||
}
|
||||
|
||||
$time_string = sprintf( $time_string,
|
||||
esc_attr( get_the_date( 'c' ) ),
|
||||
esc_html( get_the_date() ),
|
||||
esc_attr( get_the_modified_date( 'c' ) ),
|
||||
esc_html( get_the_modified_date() )
|
||||
);
|
||||
|
||||
// If our date is enabled, show it
|
||||
$output[] = apply_filters( 'wpsp_date_output', sprintf(
|
||||
'<span class="wp-show-posts-posted-on wp-show-posts-meta">
|
||||
<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>
|
||||
</span>',
|
||||
esc_url( get_permalink() ),
|
||||
esc_attr( get_the_time() ),
|
||||
$time_string
|
||||
) );
|
||||
}
|
||||
|
||||
// Show the terms
|
||||
if ( $settings[ 'include_terms' ] && $location == $settings[ 'terms_location' ] ) {
|
||||
$output[] = apply_filters( 'wpsp_terms_output', sprintf( '<span class="wp-show-posts-terms wp-show-posts-meta">%1$s</span>',
|
||||
get_the_term_list( get_the_ID(), $settings[ 'taxonomy' ], '', apply_filters( 'wpsp_term_separator', ', ' ) )
|
||||
) );
|
||||
}
|
||||
|
||||
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) && ( $settings[ 'include_comments' ] && $location == $settings[ 'comments_location' ] ) ) {
|
||||
ob_start();
|
||||
echo '<span class="wp-show-posts-comments-link wp-show-posts-meta">';
|
||||
comments_popup_link( __( 'Leave a comment', 'wp-show-posts' ), __( '1 Comment', 'wp-show-posts' ), __( '% Comments', 'wp-show-posts' ) );
|
||||
echo '</span>';
|
||||
$comments_link = ob_get_clean();
|
||||
$output[] = $comments_link;
|
||||
}
|
||||
|
||||
// Set up our separator
|
||||
$separator = ( 'inline' == $post_meta_style ) ? ' <span class="wp-show-posts-separator">|</span> ' : '<br />';
|
||||
|
||||
// Echo our output
|
||||
echo implode( $separator, $output);
|
||||
|
||||
if ( ( $settings[ 'include_author' ] && $location == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && $location == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && $location == $settings[ 'terms_location' ] ) || ( $settings[ 'include_comments' ] && $location == $settings[ 'comments_location' ] ) ) {
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_add_post_meta_after_title' ) ) {
|
||||
add_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' );
|
||||
function wpsp_add_post_meta_after_title( $settings ) {
|
||||
if ( ( $settings[ 'include_author' ] && 'below-title' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-title' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-title' == $settings[ 'terms_location' ] ) || ( $settings[ 'include_comments' ] && 'below-title' == $settings[ 'comments_location' ] ) ) {
|
||||
wpsp_meta( 'below-title', $settings );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_add_post_meta_after_content' ) ) {
|
||||
add_action( 'wpsp_after_content','wpsp_add_post_meta_after_content', 10 );
|
||||
function wpsp_add_post_meta_after_content( $settings ) {
|
||||
if ( ( $settings[ 'include_author' ] && 'below-post' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-post' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-post' == $settings[ 'terms_location' ] ) || ( $settings[ 'include_comments' ] && 'below-post' == $settings[ 'comments_location' ] ) ) {
|
||||
wpsp_meta( 'below-post', $settings );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_post_image' ) ) {
|
||||
/**
|
||||
* Build our post image
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_post_image( $settings ) {
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $settings[ 'image' ] ) || ! $settings[ 'image' ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$image_id = get_post_thumbnail_id( get_the_ID(), 'full' );
|
||||
$image_url = wp_get_attachment_image_src( $image_id, 'full', true );
|
||||
$image_atts = wpsp_image_attributes( $image_url[1], $image_url[2], $settings[ 'image_width' ], $settings[ 'image_height' ] );
|
||||
|
||||
// Set pro settings for old versions of WPSP Pro.
|
||||
if ( defined( 'WPSP_PRO_VERSION' ) && version_compare( WPSP_PRO_VERSION, '0.6', '<' ) ) {
|
||||
$settings[ 'image_overlay_color' ] = wpsp_sanitize_hex_color( wpsp_get_setting( $settings['list_id'], 'wpsp_image_overlay_color' ) );
|
||||
$settings[ 'image_overlay_icon' ] = sanitize_text_field( wpsp_get_setting( $settings['list_id'], 'wpsp_image_overlay_icon' ) );
|
||||
$hover = sanitize_text_field( wpsp_get_setting( $settings['list_id'], 'wpsp_image_hover_effect' ) );
|
||||
} else {
|
||||
$hover = ( isset( $settings[ 'image_hover_effect' ] ) && '' !== $settings[ 'image_hover_effect' ] ) ? $settings[ 'image_hover_effect' ] : '';
|
||||
}
|
||||
|
||||
$disable_link = apply_filters( 'wpsp_disable_image_link', false, $settings );
|
||||
?>
|
||||
<div class="wp-show-posts-image <?php echo esc_attr( $hover . ' wpsp-image-' . $settings[ 'image_alignment' ] ); ?> ">
|
||||
<?php
|
||||
do_action( 'wpsp_inside_image_container', $settings );
|
||||
|
||||
if ( ! $disable_link ) {
|
||||
printf(
|
||||
'<a href="%1$s" %2$s title="%3$s">',
|
||||
esc_url( apply_filters( 'wpsp_image_href', get_the_permalink(), $settings ) ),
|
||||
apply_filters( 'wpsp_image_data', '', $settings ),
|
||||
esc_attr( apply_filters( 'wpsp_image_title', the_title_attribute( 'echo=0' ), $settings ) )
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! empty( $image_atts ) ) : ?>
|
||||
<img src="<?php echo WPSP_Resize( $image_url[0], $image_atts[ 'width' ], $image_atts[ 'height' ], $image_atts[ 'crop' ], true, $image_atts[ 'upscale' ] ); ?>" alt="<?php esc_attr( the_title() ); ?>" itemprop="image" class="<?php echo esc_attr( $settings[ 'image_alignment' ] ); ?>" />
|
||||
<?php else :
|
||||
the_post_thumbnail( apply_filters( 'wpsp_default_image_size', 'full' ), array( 'itemprop' => 'image' ) );
|
||||
endif;
|
||||
|
||||
if ( isset( $settings[ 'image_overlay_color' ] ) && ( '' !== $settings[ 'image_overlay_color' ] || '' !== $settings[ 'image_overlay_icon' ] ) ) {
|
||||
$color = ( $settings[ 'image_overlay_color' ] ) ? 'style="background-color:' . wpsp_hex2rgba( $settings[ 'image_overlay_color' ], apply_filters( 'wpsp_overlay_opacity', 0.7 ) ) . '"' : '';
|
||||
$icon = ( $settings[ 'image_overlay_icon' ] ) ? $settings[ 'image_overlay_icon' ] : 'no-icon';
|
||||
echo '<span class="wp-show-posts-image-overlay ' . esc_attr( $icon ) . '" ' . $color . '></span>';
|
||||
}
|
||||
|
||||
if ( ! $disable_link ) {
|
||||
echo '</a>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_add_post_image_before_title' ) ) {
|
||||
add_action( 'wpsp_before_header','wpsp_add_post_image_before_title' );
|
||||
|
||||
function wpsp_add_post_image_before_title( $settings ) {
|
||||
if ( 'above-title' == $settings[ 'image_location' ] ) {
|
||||
wpsp_post_image( $settings );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_add_post_image_before_content' ) ) {
|
||||
add_action( 'wpsp_before_content','wpsp_add_post_image_before_content' );
|
||||
|
||||
function wpsp_add_post_image_before_content( $settings ) {
|
||||
if ( 'below-title' == $settings[ 'image_location' ] ) {
|
||||
wpsp_post_image( $settings );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_read_more' ) ) {
|
||||
add_action( 'wpsp_after_content','wpsp_read_more', 5 );
|
||||
|
||||
function wpsp_read_more( $settings ) {
|
||||
if ( $settings[ 'read_more_text' ] ) {
|
||||
echo apply_filters( 'wpsp_read_more_output', sprintf('<div class="wpsp-read-more"><a title="%1$s" class="%4$s" href="%2$s">%3$s</a></div>',
|
||||
the_title_attribute( 'echo=0' ),
|
||||
esc_url( get_permalink() ),
|
||||
wp_kses_post( $settings[ 'read_more_text' ] ),
|
||||
esc_attr( $settings['read_more_class'] )
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_hex2rgba' ) ) {
|
||||
/**
|
||||
* Convert hex to RGBA
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_hex2rgba($color, $opacity = false) {
|
||||
|
||||
$default = 'rgb(0,0,0)';
|
||||
|
||||
// Return default if no color provided
|
||||
if ( empty( $color ) ) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
// Sanitize $color if "#" is provided
|
||||
if ($color[0] == '#' ) {
|
||||
$color = substr( $color, 1 );
|
||||
}
|
||||
|
||||
// Check if color has 6 or 3 characters and get values
|
||||
if ( strlen( $color ) == 6) {
|
||||
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
|
||||
} elseif ( strlen( $color ) == 3 ) {
|
||||
$hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
|
||||
// Convert hexadec to rgb
|
||||
$rgb = array_map('hexdec', $hex);
|
||||
|
||||
// Check if opacity is set(rgba or rgb)
|
||||
if ( $opacity ){
|
||||
if( abs( $opacity ) > 1) {
|
||||
$opacity = 1.0;
|
||||
}
|
||||
$output = 'rgba('.implode(",",$rgb).','.$opacity.')';
|
||||
} else {
|
||||
$output = 'rgb('.implode(",",$rgb).')';
|
||||
}
|
||||
|
||||
// Return rgb(a) color string
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_sanitize_hex_color' ) ) {
|
||||
function wpsp_sanitize_hex_color( $color ) {
|
||||
if ( '' === $color ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// 3 or 6 hex digits, or the empty string.
|
||||
if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
|
||||
return $color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_image_attributes' ) ) {
|
||||
/**
|
||||
* Build our image attributes
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_image_attributes( $og_width = '', $og_height = '', $new_width = '', $new_height = '' ) {
|
||||
$ignore_crop = array( '', '0', '9999' );
|
||||
|
||||
$image_atts = array(
|
||||
'width' => ( in_array( $new_width, $ignore_crop ) ) ? 9999 : intval( $new_width ),
|
||||
'height' => ( in_array( $new_height, $ignore_crop ) ) ? 9999 : intval( $new_height ),
|
||||
'crop' => ( in_array( $new_width, $ignore_crop ) || in_array( $new_height, $ignore_crop ) ) ? false : true
|
||||
);
|
||||
|
||||
// If there's no height or width, empty the array
|
||||
if ( 9999 == $image_atts[ 'width' ] && 9999 == $image_atts[ 'height' ] ) {
|
||||
$image_atts = array();
|
||||
}
|
||||
|
||||
if ( ! empty( $image_atts ) ) {
|
||||
// Is our width larger than the OG image and not proportional?
|
||||
$width_upscale = $image_atts[ 'width' ] > $og_width && $image_atts[ 'width' ] < 9999 ? true : false;
|
||||
|
||||
// Is our height larger than the OG image and not proportional?
|
||||
$height_upscale = $image_atts[ 'height' ] > $og_height && $image_atts[ 'height' ] < 9999 ? true : false;
|
||||
|
||||
// If both the height and width are larger than the OG image, upscale
|
||||
$image_atts[ 'upscale' ] = $width_upscale && $height_upscale ? true : false;
|
||||
|
||||
// If the width is larger than the OG image and the height isn't proportional, upscale
|
||||
$image_atts[ 'upscale' ] = $width_upscale && $image_atts[ 'height' ] < 9999 ? true : $image_atts[ 'upscale' ];
|
||||
|
||||
// If the height is larger than the OG image and width isn't proportional, upscale
|
||||
$image_atts[ 'upscale' ] = $height_upscale && $image_atts[ 'width' ] < 9999 ? true : $image_atts[ 'upscale' ];
|
||||
|
||||
// If we're upscaling, set crop to true
|
||||
$image_atts[ 'crop' ] = $image_atts[ 'upscale' ] ? true : $image_atts[ 'crop' ];
|
||||
|
||||
// If one of our sizes is upscaling but the other is proportional, show the full image
|
||||
if ( $width_upscale && $image_atts[ 'height' ] == 9999 || $height_upscale && $image_atts[ 'width' ] == 9999 ) {
|
||||
$image_atts = array();
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'wpsp_image_attributes', $image_atts );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wpsp_pagination' ) ) {
|
||||
/**
|
||||
* Build our regular pagination
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_pagination( $max_num_pages ) {
|
||||
// Don't print empty markup if there's only one page.
|
||||
if ( $max_num_pages < 2 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$paged_query = is_front_page() ? 'page' : 'paged';
|
||||
$paged = get_query_var( $paged_query ) ? intval( get_query_var( $paged_query ) ) : 1;
|
||||
$pagenum_link = html_entity_decode( get_pagenum_link() );
|
||||
$query_args = array();
|
||||
$url_parts = explode( '?', $pagenum_link );
|
||||
|
||||
if ( isset( $url_parts[1] ) ) {
|
||||
wp_parse_str( $url_parts[1], $query_args );
|
||||
}
|
||||
|
||||
$pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
|
||||
$pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
|
||||
|
||||
$format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
|
||||
$format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
|
||||
|
||||
// Set up paginated links.
|
||||
$links = paginate_links( array(
|
||||
'base' => $pagenum_link,
|
||||
'format' => $format,
|
||||
'total' => $max_num_pages,
|
||||
'current' => $paged,
|
||||
'mid_size' => apply_filters( 'wpsp_pagination_mid_size', 1 ),
|
||||
'add_args' => array_map( 'urlencode', $query_args ),
|
||||
'prev_text' => __( '← Previous', 'wp-show-posts' ),
|
||||
'next_text' => __( 'Next →', 'wp-show-posts' ),
|
||||
) );
|
||||
|
||||
if ( $links ) {
|
||||
echo '<div class="wpsp-load-more">' . $links . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
/**
|
||||
* Title : Aqua Resizer
|
||||
* Description : Resizes WordPress images on the fly
|
||||
* Version : 1.2.1
|
||||
* Author : Syamil MJ
|
||||
* Author URI : http://aquagraphite.com
|
||||
* License : WTFPL - http://sam.zoy.org/wtfpl/
|
||||
* Documentation : https://github.com/sy4mil/Aqua-Resizer/
|
||||
*
|
||||
* @param string $url - (required) must be uploaded using wp media uploader
|
||||
* @param int $width - (required)
|
||||
* @param int $height - (optional)
|
||||
* @param bool $crop - (optional) default to soft crop
|
||||
* @param bool $single - (optional) returns an array if false
|
||||
* @param bool $upscale - (optional) resizes smaller images
|
||||
* @uses wp_upload_dir()
|
||||
* @uses image_resize_dimensions()
|
||||
* @uses wp_get_image_editor()
|
||||
*
|
||||
* @return str|array
|
||||
*/
|
||||
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
if( ! class_exists( 'WPSP_Resize' ) ) {
|
||||
class WPSP_Exception extends Exception {}
|
||||
|
||||
class WPSP_Resize
|
||||
{
|
||||
/**
|
||||
* The singleton instance
|
||||
*/
|
||||
static private $instance = null;
|
||||
|
||||
/**
|
||||
* Should an WPSP_Exception be thrown on error?
|
||||
* If false (default), then the error will just be logged.
|
||||
*/
|
||||
public $throwOnError = false;
|
||||
|
||||
/**
|
||||
* No initialization allowed
|
||||
*/
|
||||
private function __construct() {}
|
||||
|
||||
/**
|
||||
* No cloning allowed
|
||||
*/
|
||||
private function __clone() {}
|
||||
|
||||
/**
|
||||
* For your custom default usage you may want to initialize an WPSP_Resize object by yourself and then have own defaults
|
||||
*/
|
||||
static public function getInstance() {
|
||||
if(self::$instance == null) {
|
||||
self::$instance = new self;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run, forest.
|
||||
*/
|
||||
public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
|
||||
try {
|
||||
// Validate inputs.
|
||||
if (!$url)
|
||||
throw new WPSP_Exception('$url parameter is required');
|
||||
if (!$width)
|
||||
throw new WPSP_Exception('$width parameter is required');
|
||||
if (!$height)
|
||||
throw new WPSP_Exception('$height parameter is required');
|
||||
|
||||
// Caipt'n, ready to hook.
|
||||
if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'WPSP_upscale'), 10, 6 );
|
||||
|
||||
// Define upload path & dir.
|
||||
$upload_info = wp_upload_dir();
|
||||
$upload_dir = $upload_info['basedir'];
|
||||
$upload_url = $upload_info['baseurl'];
|
||||
|
||||
$http_prefix = "http://";
|
||||
$https_prefix = "https://";
|
||||
$relative_prefix = "//"; // The protocol-relative URL
|
||||
|
||||
/* if the $url scheme differs from $upload_url scheme, make them match
|
||||
if the schemes differe, images don't show up. */
|
||||
if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
|
||||
$upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
|
||||
}
|
||||
elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
|
||||
$upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
|
||||
}
|
||||
elseif(!strncmp($url,$relative_prefix,strlen($relative_prefix))){ //if url begins with // make $upload_url begin with // as well
|
||||
$upload_url = str_replace(array( 0 => "$http_prefix", 1 => "$https_prefix"),$relative_prefix,$upload_url);
|
||||
}
|
||||
|
||||
|
||||
// Check if $img_url is local.
|
||||
if ( false === strpos( $url, $upload_url ) )
|
||||
throw new WPSP_Exception('Image must be local: ' . $url);
|
||||
|
||||
// Define path of image.
|
||||
$rel_path = str_replace( $upload_url, '', $url );
|
||||
$img_path = $upload_dir . $rel_path;
|
||||
|
||||
// Check if img path exists, and is an image indeed.
|
||||
if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) )
|
||||
throw new WPSP_Exception('Image file does not exist (or is not an image): ' . $img_path);
|
||||
|
||||
// Get image info.
|
||||
$info = pathinfo( $img_path );
|
||||
$ext = $info['extension'];
|
||||
list( $orig_w, $orig_h ) = getimagesize( $img_path );
|
||||
|
||||
// Get image size after cropping.
|
||||
$dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
|
||||
$dst_w = $dims[4];
|
||||
$dst_h = $dims[5];
|
||||
|
||||
// Return the original image only if it exactly fits the needed measures.
|
||||
if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
|
||||
$img_url = $url;
|
||||
$dst_w = $orig_w;
|
||||
$dst_h = $orig_h;
|
||||
} else {
|
||||
// Use this to check if cropped image already exists, so we can return that instead.
|
||||
$suffix = "{$dst_w}x{$dst_h}";
|
||||
$dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
|
||||
$destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
|
||||
|
||||
if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
|
||||
// Can't resize, so return false saying that the action to do could not be processed as planned.
|
||||
throw new WPSP_Exception('Unable to resize image because image_resize_dimensions() failed');
|
||||
}
|
||||
// Else check if cache exists.
|
||||
elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
|
||||
$img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
|
||||
}
|
||||
// Else, we resize the image and return the new resized image url.
|
||||
else {
|
||||
|
||||
$editor = wp_get_image_editor( $img_path );
|
||||
|
||||
if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) {
|
||||
throw new WPSP_Exception('Unable to get WP_Image_Editor: ' .
|
||||
$editor->get_error_message() . ' (is GD or ImageMagick installed?)');
|
||||
}
|
||||
|
||||
$resized_file = $editor->save();
|
||||
|
||||
if ( ! is_wp_error( $resized_file ) ) {
|
||||
$resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
|
||||
$img_url = $upload_url . $resized_rel_path;
|
||||
} else {
|
||||
throw new WPSP_Exception('Unable to save resized image file: ' . $editor->get_error_message());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Okay, leave the ship.
|
||||
if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'WPSP_upscale' ) );
|
||||
|
||||
// Return the output.
|
||||
if ( $single ) {
|
||||
// str return.
|
||||
$image = $img_url;
|
||||
} else {
|
||||
// array return.
|
||||
$image = array (
|
||||
0 => $img_url,
|
||||
1 => $dst_w,
|
||||
2 => $dst_h
|
||||
);
|
||||
}
|
||||
|
||||
return $image;
|
||||
}
|
||||
catch (WPSP_Exception $ex) {
|
||||
error_log('WPSP_Resize.process() error: ' . $ex->getMessage());
|
||||
|
||||
if ($this->throwOnError) {
|
||||
// Bubble up exception.
|
||||
throw $ex;
|
||||
}
|
||||
else {
|
||||
// Return false, so that this patch is backwards-compatible.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to overwrite WP computing of thumbnail measures
|
||||
*/
|
||||
function WPSP_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
|
||||
if ( ! $crop ) return null; // Let the wordpress default function handle this.
|
||||
// Here is the point we allow to use larger image size than the original one.
|
||||
$aspect_ratio = $orig_w / $orig_h;
|
||||
$new_w = $dest_w;
|
||||
$new_h = $dest_h;
|
||||
if ( ! $new_w ) {
|
||||
$new_w = intval( $new_h * $aspect_ratio );
|
||||
}
|
||||
if ( ! $new_h ) {
|
||||
$new_h = intval( $new_w / $aspect_ratio );
|
||||
}
|
||||
$size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
|
||||
$crop_w = round( $new_w / $size_ratio );
|
||||
$crop_h = round( $new_h / $size_ratio );
|
||||
$s_x = floor( ( $orig_w - $crop_w ) / 2 );
|
||||
$s_y = floor( ( $orig_h - $crop_h ) / 2 );
|
||||
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'WPSP_Resize' ) ) :
|
||||
/**
|
||||
* This is just a tiny wrapper function for the class above so that there is no
|
||||
* need to change any code in your own WP themes. Usage is still the same :)
|
||||
*/
|
||||
function WPSP_Resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
|
||||
/* WPML Fix */
|
||||
if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
|
||||
global $sitepress;
|
||||
$url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
|
||||
}
|
||||
|
||||
/* Jetpack Photon fix */
|
||||
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) && function_exists( 'jetpack_photon_url' ) ) {
|
||||
$type = ( $crop ) ? 'resize' : 'fit';
|
||||
$args = array( $type => $width . ',' . $height );
|
||||
return jetpack_photon_url( $url, $args );
|
||||
}
|
||||
|
||||
$WPSP_Resize = WPSP_Resize::getInstance();
|
||||
return $WPSP_Resize->process( $url, $width, $height, $crop, $single, $upscale );
|
||||
}
|
||||
endif;
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
add_action( 'wpsp_before_wrapper', 'wpsp_basic_styling' );
|
||||
function wpsp_basic_styling( $settings ) {
|
||||
// Start the magic
|
||||
$visual_css = array (
|
||||
|
||||
'.wp-show-posts-columns#wpsp-' . $settings[ 'list_id' ] => array(
|
||||
'margin-left' => ( '' !== $settings[ 'columns_gutter' ] && '12' !== $settings[ 'columns' ] ) ? '-' . esc_attr( $settings[ 'columns_gutter' ] ) : null
|
||||
),
|
||||
|
||||
'.wp-show-posts-columns#wpsp-' . $settings[ 'list_id' ] . ' .wp-show-posts-inner' => array(
|
||||
'margin' => ( '' !== $settings[ 'columns_gutter' ] && '12' !== $settings[ 'columns' ] ) ? '0 0 ' . esc_attr( $settings[ 'columns_gutter' ] ) . ' ' . esc_attr( $settings[ 'columns_gutter' ] ) : null,
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
// Output the above CSS
|
||||
$output = '';
|
||||
foreach( $visual_css as $k => $properties ) {
|
||||
|
||||
if ( !count( $properties ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$temporary_output = $k . ' {';
|
||||
$elements_added = 0;
|
||||
|
||||
foreach( $properties as $p => $v ) {
|
||||
|
||||
if ( empty( $v ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$elements_added++;
|
||||
$temporary_output .= $p . ': ' . $v . '; ';
|
||||
|
||||
}
|
||||
|
||||
$temporary_output .= "}";
|
||||
|
||||
if ( $elements_added > 0 ) {
|
||||
$output .= $temporary_output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$output = str_replace(array("\r", "\n"), '', $output);
|
||||
|
||||
if ( '' !== $output ) {
|
||||
echo '<style>';
|
||||
echo $output;
|
||||
echo '</style>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
/**
|
||||
* jquery-match-height master by @liabru
|
||||
* http://brm.io/jquery-match-height/
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
;(function(factory) { // eslint-disable-line no-extra-semi
|
||||
'use strict';
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof module !== 'undefined' && module.exports) {
|
||||
// CommonJS
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
// Global
|
||||
factory(jQuery);
|
||||
}
|
||||
})(function($) {
|
||||
/*
|
||||
* internal
|
||||
*/
|
||||
|
||||
var _previousResizeWidth = -1,
|
||||
_updateTimeout = -1;
|
||||
|
||||
/*
|
||||
* _parse
|
||||
* value parse utility function
|
||||
*/
|
||||
|
||||
var _parse = function(value) {
|
||||
// parse value and convert NaN to 0
|
||||
return parseFloat(value) || 0;
|
||||
};
|
||||
|
||||
/*
|
||||
* _rows
|
||||
* utility function returns array of jQuery selections representing each row
|
||||
* (as displayed after float wrapping applied by browser)
|
||||
*/
|
||||
|
||||
var _rows = function(elements) {
|
||||
var tolerance = 1,
|
||||
$elements = $(elements),
|
||||
lastTop = null,
|
||||
rows = [];
|
||||
|
||||
// group elements by their top position
|
||||
$elements.each(function(){
|
||||
var $that = $(this),
|
||||
top = $that.offset().top - _parse($that.css('margin-top')),
|
||||
lastRow = rows.length > 0 ? rows[rows.length - 1] : null;
|
||||
|
||||
if (lastRow === null) {
|
||||
// first item on the row, so just push it
|
||||
rows.push($that);
|
||||
} else {
|
||||
// if the row top is the same, add to the row group
|
||||
if (Math.floor(Math.abs(lastTop - top)) <= tolerance) {
|
||||
rows[rows.length - 1] = lastRow.add($that);
|
||||
} else {
|
||||
// otherwise start a new row group
|
||||
rows.push($that);
|
||||
}
|
||||
}
|
||||
|
||||
// keep track of the last row top
|
||||
lastTop = top;
|
||||
});
|
||||
|
||||
return rows;
|
||||
};
|
||||
|
||||
/*
|
||||
* _parseOptions
|
||||
* handle plugin options
|
||||
*/
|
||||
|
||||
var _parseOptions = function(options) {
|
||||
var opts = {
|
||||
byRow: true,
|
||||
property: 'height',
|
||||
target: null,
|
||||
remove: false
|
||||
};
|
||||
|
||||
if (typeof options === 'object') {
|
||||
return $.extend(opts, options);
|
||||
}
|
||||
|
||||
if (typeof options === 'boolean') {
|
||||
opts.byRow = options;
|
||||
} else if (options === 'remove') {
|
||||
opts.remove = true;
|
||||
}
|
||||
|
||||
return opts;
|
||||
};
|
||||
|
||||
/*
|
||||
* matchHeight
|
||||
* plugin definition
|
||||
*/
|
||||
|
||||
var matchHeight = $.fn.matchHeight = function(options) {
|
||||
var opts = _parseOptions(options);
|
||||
|
||||
// handle remove
|
||||
if (opts.remove) {
|
||||
var that = this;
|
||||
|
||||
// remove fixed height from all selected elements
|
||||
this.css(opts.property, '');
|
||||
|
||||
// remove selected elements from all groups
|
||||
$.each(matchHeight._groups, function(key, group) {
|
||||
group.elements = group.elements.not(that);
|
||||
});
|
||||
|
||||
// TODO: cleanup empty groups
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
if (this.length <= 1 && !opts.target) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// keep track of this group so we can re-apply later on load and resize events
|
||||
matchHeight._groups.push({
|
||||
elements: this,
|
||||
options: opts
|
||||
});
|
||||
|
||||
// match each element's height to the tallest element in the selection
|
||||
matchHeight._apply(this, opts);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/*
|
||||
* plugin global options
|
||||
*/
|
||||
|
||||
matchHeight.version = 'master';
|
||||
matchHeight._groups = [];
|
||||
matchHeight._throttle = 80;
|
||||
matchHeight._maintainScroll = false;
|
||||
matchHeight._beforeUpdate = null;
|
||||
matchHeight._afterUpdate = null;
|
||||
matchHeight._rows = _rows;
|
||||
matchHeight._parse = _parse;
|
||||
matchHeight._parseOptions = _parseOptions;
|
||||
|
||||
/*
|
||||
* matchHeight._apply
|
||||
* apply matchHeight to given elements
|
||||
*/
|
||||
|
||||
matchHeight._apply = function(elements, options) {
|
||||
var opts = _parseOptions(options),
|
||||
$elements = $(elements),
|
||||
rows = [$elements];
|
||||
|
||||
// take note of scroll position
|
||||
var scrollTop = $(window).scrollTop(),
|
||||
htmlHeight = $('html').outerHeight(true);
|
||||
|
||||
// get hidden parents
|
||||
var $hiddenParents = $elements.parents().filter(':hidden');
|
||||
|
||||
// cache the original inline style
|
||||
$hiddenParents.each(function() {
|
||||
var $that = $(this);
|
||||
$that.data('style-cache', $that.attr('style'));
|
||||
});
|
||||
|
||||
// temporarily must force hidden parents visible
|
||||
$hiddenParents.css('display', 'block');
|
||||
|
||||
// get rows if using byRow, otherwise assume one row
|
||||
if (opts.byRow && !opts.target) {
|
||||
|
||||
// must first force an arbitrary equal height so floating elements break evenly
|
||||
$elements.each(function() {
|
||||
var $that = $(this),
|
||||
display = $that.css('display');
|
||||
|
||||
// temporarily force a usable display value
|
||||
if (display !== 'inline-block' && display !== 'flex' && display !== 'inline-flex') {
|
||||
display = 'block';
|
||||
}
|
||||
|
||||
// cache the original inline style
|
||||
$that.data('style-cache', $that.attr('style'));
|
||||
|
||||
$that.css({
|
||||
'display': display,
|
||||
'padding-top': '0',
|
||||
'padding-bottom': '0',
|
||||
'margin-top': '0',
|
||||
'margin-bottom': '0',
|
||||
'border-top-width': '0',
|
||||
'border-bottom-width': '0',
|
||||
'height': '100px',
|
||||
'overflow': 'hidden'
|
||||
});
|
||||
});
|
||||
|
||||
// get the array of rows (based on element top position)
|
||||
rows = _rows($elements);
|
||||
|
||||
// revert original inline styles
|
||||
$elements.each(function() {
|
||||
var $that = $(this);
|
||||
$that.attr('style', $that.data('style-cache') || '');
|
||||
});
|
||||
}
|
||||
|
||||
$.each(rows, function(key, row) {
|
||||
var $row = $(row),
|
||||
targetHeight = 0;
|
||||
|
||||
if (!opts.target) {
|
||||
// skip apply to rows with only one item
|
||||
if (opts.byRow && $row.length <= 1) {
|
||||
$row.css(opts.property, '');
|
||||
return;
|
||||
}
|
||||
|
||||
// iterate the row and find the max height
|
||||
$row.each(function(){
|
||||
var $that = $(this),
|
||||
style = $that.attr('style'),
|
||||
display = $that.css('display');
|
||||
|
||||
// temporarily force a usable display value
|
||||
if (display !== 'inline-block' && display !== 'flex' && display !== 'inline-flex') {
|
||||
display = 'block';
|
||||
}
|
||||
|
||||
// ensure we get the correct actual height (and not a previously set height value)
|
||||
var css = { 'display': display };
|
||||
css[opts.property] = '';
|
||||
$that.css(css);
|
||||
|
||||
// find the max height (including padding, but not margin)
|
||||
if ($that.outerHeight(false) > targetHeight) {
|
||||
targetHeight = $that.outerHeight(false);
|
||||
}
|
||||
|
||||
// revert styles
|
||||
if (style) {
|
||||
$that.attr('style', style);
|
||||
} else {
|
||||
$that.css('display', '');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// if target set, use the height of the target element
|
||||
targetHeight = opts.target.outerHeight(false);
|
||||
}
|
||||
|
||||
// iterate the row and apply the height to all elements
|
||||
$row.each(function(){
|
||||
var $that = $(this),
|
||||
verticalPadding = 0;
|
||||
|
||||
// don't apply to a target
|
||||
if (opts.target && $that.is(opts.target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// handle padding and border correctly (required when not using border-box)
|
||||
if ($that.css('box-sizing') !== 'border-box') {
|
||||
verticalPadding += _parse($that.css('border-top-width')) + _parse($that.css('border-bottom-width'));
|
||||
verticalPadding += _parse($that.css('padding-top')) + _parse($that.css('padding-bottom'));
|
||||
}
|
||||
|
||||
// set the height (accounting for padding and border)
|
||||
$that.css(opts.property, (targetHeight - verticalPadding) + 'px');
|
||||
});
|
||||
});
|
||||
|
||||
// revert hidden parents
|
||||
$hiddenParents.each(function() {
|
||||
var $that = $(this);
|
||||
$that.attr('style', $that.data('style-cache') || null);
|
||||
});
|
||||
|
||||
// restore scroll position if enabled
|
||||
if (matchHeight._maintainScroll) {
|
||||
$(window).scrollTop((scrollTop / htmlHeight) * $('html').outerHeight(true));
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/*
|
||||
* matchHeight._applyDataApi
|
||||
* applies matchHeight to all elements with a data-match-height attribute
|
||||
*/
|
||||
|
||||
matchHeight._applyDataApi = function() {
|
||||
var groups = {};
|
||||
|
||||
// generate groups by their groupId set by elements using data-match-height
|
||||
$('[data-match-height], [data-mh]').each(function() {
|
||||
var $this = $(this),
|
||||
groupId = $this.attr('data-mh') || $this.attr('data-match-height');
|
||||
|
||||
if (groupId in groups) {
|
||||
groups[groupId] = groups[groupId].add($this);
|
||||
} else {
|
||||
groups[groupId] = $this;
|
||||
}
|
||||
});
|
||||
|
||||
// apply matchHeight to each group
|
||||
$.each(groups, function() {
|
||||
this.matchHeight(true);
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* matchHeight._update
|
||||
* updates matchHeight on all current groups with their correct options
|
||||
*/
|
||||
|
||||
var _update = function(event) {
|
||||
if (matchHeight._beforeUpdate) {
|
||||
matchHeight._beforeUpdate(event, matchHeight._groups);
|
||||
}
|
||||
|
||||
$.each(matchHeight._groups, function() {
|
||||
matchHeight._apply(this.elements, this.options);
|
||||
});
|
||||
|
||||
if (matchHeight._afterUpdate) {
|
||||
matchHeight._afterUpdate(event, matchHeight._groups);
|
||||
}
|
||||
};
|
||||
|
||||
matchHeight._update = function(throttle, event) {
|
||||
// prevent update if fired from a resize event
|
||||
// where the viewport width hasn't actually changed
|
||||
// fixes an event looping bug in IE8
|
||||
if (event && event.type === 'resize') {
|
||||
var windowWidth = $(window).width();
|
||||
if (windowWidth === _previousResizeWidth) {
|
||||
return;
|
||||
}
|
||||
_previousResizeWidth = windowWidth;
|
||||
}
|
||||
|
||||
// throttle updates
|
||||
if (!throttle) {
|
||||
_update(event);
|
||||
} else if (_updateTimeout === -1) {
|
||||
_updateTimeout = setTimeout(function() {
|
||||
_update(event);
|
||||
_updateTimeout = -1;
|
||||
}, matchHeight._throttle);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* bind events
|
||||
*/
|
||||
|
||||
// apply on DOM ready event
|
||||
$(matchHeight._applyDataApi);
|
||||
|
||||
// update heights on load and resize events
|
||||
$(window).bind('load', function(event) {
|
||||
matchHeight._update(false, event);
|
||||
});
|
||||
|
||||
// throttled update heights on resize events
|
||||
$(window).bind('resize orientationchange', function(event) {
|
||||
matchHeight._update(true, event);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
jQuery(document).ready( function($) {
|
||||
var s = document.body || document.documentElement, s = s.style;
|
||||
if ( s.webkitFlexWrap == '' || s.msFlexWrap == '' || s.flexWrap == '' ) return false;
|
||||
|
||||
jQuery('.wp-show-posts-columns .wp-show-posts-inner').matchHeight();
|
||||
|
||||
var rows = $.fn.matchHeight._rows($('.wp-show-posts-columns .wp-show-posts-inner'));
|
||||
|
||||
$.each(rows, function(i, row) {
|
||||
row.first().addClass('generate-column-first');
|
||||
row.last().addClass('generate-column-last');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
WP Show Posts is licensed under the GNU General Public License v2 or later
|
||||
More details here: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
== Bundled resources ==
|
||||
|
||||
= Butterbean =
|
||||
|
||||
Licensed under the GNU GPL, version 2 or later.
|
||||
2015-2016 © Justin Tadlock.
|
||||
|
||||
= MatchHeight.js =
|
||||
|
||||
jquery.matchHeight.js is licensed under The MIT License (MIT)
|
||||
Copyright (c) 2014 Liam Brummitt
|
||||
|
||||
= FontAwesome =
|
||||
|
||||
Icons generated with IcoMoon with the following licenses:
|
||||
|
||||
Font License: SIL OFL 1.1 - http://scripts.sil.org/OFL
|
||||
Code License: MIT License - http://opensource.org/licenses/mit-license.html
|
||||
|
||||
All brand icons are trademarks of their respective owners.
|
||||
|
||||
= Display Posts Shortcode =
|
||||
|
||||
Some of the base code of this plugin was borrowed from the awesome Display Posts Shortcode plugin by Bill Erickson.
|
||||
https://wordpress.org/plugins/display-posts-shortcode/
|
||||
http://www.billerickson.net/
|
||||
@@ -0,0 +1,264 @@
|
||||
=== WP Show Posts ===
|
||||
Contributors: edge22
|
||||
Donate link: https://wpshowposts.com
|
||||
Tags: show posts, display posts shortcode, portfolio, gallery, post columns
|
||||
Requires at least: 4.5
|
||||
Tested up to: 6.1
|
||||
Stable tag: 1.1.4
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
Add posts to your website from any post type using a simple shortcode.
|
||||
|
||||
== Description ==
|
||||
|
||||
= Note =
|
||||
|
||||
This plugin is only receiving security updates at this time. Check out our [GenerateBlocks](https://generateblocks.com/) plugin for a more modern solution.
|
||||
|
||||
https://vimeo.com/175638957
|
||||
|
||||
WP Show Posts allows you to display posts anywhere on your website using an easy to use shortcode.
|
||||
|
||||
You can pull posts from any post type like WooCommerce, Easy Digital Downloads etc..
|
||||
|
||||
This plugin works with any theme.
|
||||
|
||||
Here are the features in the free version:
|
||||
|
||||
= Posts =
|
||||
|
||||
* Post type
|
||||
* Taxonomy
|
||||
* Terms
|
||||
* Posts per page
|
||||
* Pagination
|
||||
|
||||
= Columns =
|
||||
|
||||
* Columns
|
||||
* Columns gutter
|
||||
|
||||
= Images =
|
||||
|
||||
* Show images
|
||||
* Image width
|
||||
* Image height
|
||||
* Image alignment
|
||||
* Image location
|
||||
|
||||
= Content =
|
||||
|
||||
* Content type (excerpt or full post)
|
||||
* Excerpt length
|
||||
* Include title
|
||||
* Read more text
|
||||
* Read more button class
|
||||
|
||||
= Meta =
|
||||
|
||||
* Include author
|
||||
* Author location
|
||||
* Include date
|
||||
* Date location
|
||||
* Include terms
|
||||
* Terms location
|
||||
|
||||
= More settings =
|
||||
|
||||
* Author ID
|
||||
* Exclude current
|
||||
* Post ID
|
||||
* Exclude post ID
|
||||
* Ignore sticky posts
|
||||
* Offset
|
||||
* Order
|
||||
* Order by
|
||||
* Status
|
||||
* Meta key
|
||||
* Meta value
|
||||
* Tax operator
|
||||
* No results message
|
||||
|
||||
= Our *Pro* version has these features =
|
||||
|
||||
https://vimeo.com/175660953
|
||||
|
||||
[Check out Pro](https://wpshowposts.com/ "Check out Pro")
|
||||
|
||||
= Posts =
|
||||
|
||||
* AJAX pagination
|
||||
|
||||
= Columns =
|
||||
|
||||
* Masonry
|
||||
* Featured post
|
||||
* Background color
|
||||
* Background color hover
|
||||
* Border color
|
||||
* Border color hover
|
||||
|
||||
= Images =
|
||||
|
||||
* Image overlay color
|
||||
* Image overlay icon
|
||||
* Image hover effect
|
||||
* Image lightbox
|
||||
* Image lightbox gallery
|
||||
|
||||
= Content =
|
||||
|
||||
* Read more style
|
||||
* Read more color
|
||||
* Content link color
|
||||
* Content link color hover
|
||||
* Content text color
|
||||
* Title color
|
||||
* Title color hover
|
||||
|
||||
= Meta =
|
||||
|
||||
* Meta color
|
||||
* Meta color hover
|
||||
|
||||
= Social =
|
||||
|
||||
* Twitter
|
||||
* Twitter color + hover
|
||||
* Facebook
|
||||
* Facebook color + hover
|
||||
* Google+
|
||||
* Google+ color + hover
|
||||
* Pinterest
|
||||
* Pinterest color + hover
|
||||
* Love it
|
||||
* Alignment
|
||||
|
||||
Check out GeneratePress, our awesome WordPress theme! (http://wordpress.org/themes/generatepress)
|
||||
|
||||
== Installation ==
|
||||
|
||||
There's two ways to install WP Show Posts.
|
||||
|
||||
1. Go to "Plugins > Add New" in your Dashboard and search for: WP Show Posts
|
||||
2. Download the .zip from WordPress.org, and upload the folder to the `/wp-content/plugins/` directory via FTP.
|
||||
|
||||
In most cases, #1 will work fine and is way easier.
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= How do I create a post list? =
|
||||
|
||||
* Make sure WP Show Posts is activated.
|
||||
* Navigate to "WP Show Posts > Add New" and configure your list.
|
||||
* Copy the shortcode provided for you when adding your new list.
|
||||
* Add your shortcode to your desired page or post.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. All of your created post lists.
|
||||
2. The "Posts" settings tab.
|
||||
3. The "Columns" settings tab.
|
||||
4. The "Images" settings tab.
|
||||
5. The "Content" settings tab.
|
||||
6. The "Meta" settings tab.
|
||||
7. The "More query ars" settings tab.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 1.1.4 =
|
||||
* Security: Improve escaping of settings that display HTML
|
||||
* Tweak: Add wpsp_query_args filter
|
||||
|
||||
= 1.1.3 =
|
||||
* New: Button class option
|
||||
* Fix: Duplicate post classes
|
||||
* Fix: Post classes PHP notice in some themes
|
||||
* Fix: PHP 7.2 PHP warning while editing lists
|
||||
* Tweak: Pass $settings to wpsp_wrapper_atts filter
|
||||
* Tweak: Remove font-size and line-height CSS (allow themes to handle it)
|
||||
|
||||
= 1.1.2 =
|
||||
* Fix: Performance issue dealing with lots of terms in list admin
|
||||
* Fix: Post class clashes with GP Premium
|
||||
* Tweak: Allow name in shortcode instead of ID
|
||||
* Tweak: Use theme defined font size for title elements (removes the default 30px)
|
||||
|
||||
= 1.1.1 =
|
||||
* Fix: Fix image hover effects in WPSP Pro
|
||||
|
||||
= 1.1 =
|
||||
* New: Allow multiple taxonomy terms to be selected
|
||||
* New: Choose the title HTML element
|
||||
* New: wpsp_disable_title_link filter
|
||||
* New: wpsp_disable_image_link filter
|
||||
* New: wpsp_read_more_output filter
|
||||
* New: wpsp_inside_wrapper hook
|
||||
* New: wpsp_image_attributes filter
|
||||
* New: wpsp_term_separator filter
|
||||
* New: Option to add comments number/link in post meta
|
||||
* New: Allow override of settings within shortcode parameter
|
||||
* New: Add standard post classes to each post
|
||||
* Tweak: Remove many function_exists() wrappers - check your custom functions!
|
||||
* Tweak: Pass list settings through hooks instead of using global
|
||||
* Tweak: Clean up code considerably
|
||||
* Tweak: Use the_excerpt() instead of custom function
|
||||
* Tweak: Remove border radius from read more buttons
|
||||
* Fix: Broken author setting
|
||||
* Fix: Remove image float on mobile
|
||||
* Fix: Missing color labels in WP 4.9
|
||||
|
||||
= 1.0 =
|
||||
* Add new hook inside image container: wpsp_inside_image_container
|
||||
* Fix issue with pagination and random post ordering
|
||||
* Clean up defaults to only include free options
|
||||
* Add margin to the top of pagination
|
||||
* Use manual excerpt if it's set
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 1.1.3 =
|
||||
* New: Button class option
|
||||
* Fix: Duplicate post classes
|
||||
* Fix: Post classes PHP notice in some themes
|
||||
* Fix: PHP 7.2 PHP warning while editing lists
|
||||
* Tweak: Pass $settings to wpsp_wrapper_atts filter
|
||||
* Tweak: Remove font-size and line-height CSS (allow themes to handle it)
|
||||
|
||||
= 1.1.2 =
|
||||
* Fix: Performance issue dealing with lots of terms in list admin
|
||||
* Fix: Post class clashes with GP Premium
|
||||
* Tweak: Allow name in shortcode instead of ID
|
||||
* Tweak: Use theme defined font size for title elements (removes the default 30px)
|
||||
|
||||
= 1.1.1 =
|
||||
* Fix: Fix image hover effects in WPSP Pro
|
||||
|
||||
= 1.1 =
|
||||
* New: Allow multiple taxonomy terms to be selected
|
||||
* New: Choose the title HTML element
|
||||
* New: wpsp_disable_title_link filter
|
||||
* New: wpsp_disable_image_link filter
|
||||
* New: wpsp_read_more_output filter
|
||||
* New: wpsp_inside_wrapper hook
|
||||
* New: wpsp_image_attributes filter
|
||||
* New: wpsp_term_separator filter
|
||||
* New: Option to add comments number/link in post meta
|
||||
* New: Allow override of settings within shortcode parameter
|
||||
* New: Add standard post classes to each post
|
||||
* Tweak: Remove many function_exists() wrappers - check your custom functions!
|
||||
* Tweak: Pass list settings through hooks instead of using global
|
||||
* Tweak: Clean up code considerably
|
||||
* Tweak: Use the_excerpt() instead of custom function
|
||||
* Tweak: Remove border radius from read more buttons
|
||||
* Fix: Broken author setting
|
||||
* Fix: Remove image float on mobile
|
||||
* Fix: Missing color labels in WP 4.9
|
||||
|
||||
= 1.0 =
|
||||
* Add new hook inside image container: wpsp_inside_image_container
|
||||
* Fix issue with pagination and random post ordering
|
||||
* Clean up defaults to only include free options
|
||||
* Add margin to the top of pagination
|
||||
* Use manual excerpt if it's set
|
||||
@@ -0,0 +1,595 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: WP Show Posts
|
||||
Plugin URI: https://wpshowposts.com
|
||||
Description: WP Show Posts allows you to list posts (from any post type) anywhere on your site. This includes WooCommerce products or any other post type you might have! Check out the pro version for even more features at https://wpshowposts.com.
|
||||
Version: 1.1.4
|
||||
Author: Tom Usborne
|
||||
Author URI: https://tomusborne.com
|
||||
License: GNU General Public License v2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
Text Domain: wp-show-posts
|
||||
*/
|
||||
|
||||
// No direct access, please
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Define the current version
|
||||
define( 'WPSP_VERSION', '1.1.4' );
|
||||
|
||||
// Add resizer script
|
||||
if ( ! class_exists( 'WPSP_Resize' ) ) {
|
||||
require_once plugin_dir_path( __FILE__ ) . 'inc/image-resizer.php';
|
||||
}
|
||||
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/defaults.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/functions.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/compat.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/styling.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'inc/deprecated.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/post-type.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/metabox.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/ajax.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/admin.php';
|
||||
require_once trailingslashit( plugin_dir_path( __FILE__ ) ) . 'admin/widget.php';
|
||||
|
||||
add_action( 'plugins_loaded', 'wpsp_load_textdomain' );
|
||||
/**
|
||||
* Load plugin textdomain.
|
||||
*
|
||||
* @since 0.5
|
||||
*/
|
||||
function wpsp_load_textdomain() {
|
||||
load_plugin_textdomain( 'wp-show-posts' );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'wpsp_enqueue_scripts' );
|
||||
/*
|
||||
* Enqueue our CSS to the front end
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function wpsp_enqueue_scripts() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '-min';
|
||||
wp_enqueue_style( 'wp-show-posts', plugins_url( "css/wp-show-posts{$suffix}.css", __FILE__ ), array(), WPSP_VERSION );
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a helpful wrapper to get our settings and defaults
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param int $id The post ID.
|
||||
* @param string $key The post meta key.
|
||||
* @return mixed The value of our key.
|
||||
*/
|
||||
function wpsp_get_setting( $id, $key ) {
|
||||
// Get our defaults
|
||||
$defaults = wpsp_get_defaults();
|
||||
|
||||
// Bail if our default isn't set
|
||||
if ( ! isset( $defaults[ $key ] ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we have a default, let's return a value
|
||||
return get_post_meta( $id, $key ) ? get_post_meta( $id, $key, true ) : $defaults[ $key ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove special characters from a string.
|
||||
*
|
||||
* @param string $string The string to remove special characters from.
|
||||
*/
|
||||
function wpsp_clean_string( $string ) {
|
||||
$string = str_replace( ' ', '-', $string );
|
||||
$string = preg_replace( '/[^A-Za-z0-9\-]/', '', $string );
|
||||
$string = str_replace( 'script', 'div', $string );
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/*
|
||||
* Build the front end of the plugin
|
||||
* $id parameter needs to match ID of custom post type entry
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param int $id The ID of the post.
|
||||
* @param string|array $custom_settings Custom settings we can pass to our list.
|
||||
*/
|
||||
function wpsp_display( $id, $custom_settings = false ) {
|
||||
// Set the global ID of our object
|
||||
global $wpsp_id;
|
||||
$wpsp_id = $id;
|
||||
|
||||
// Build our setting variables
|
||||
$settings = apply_filters( 'wpsp_settings', array(
|
||||
'list_id' => absint( $id ),
|
||||
'author' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_author' ) ),
|
||||
'columns' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_columns' ) ),
|
||||
'columns_gutter' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_columns_gutter' ) ),
|
||||
'content_type' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_content_type' ) ),
|
||||
'exclude_current' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_exclude_current' ) ),
|
||||
'excerpt_length' => absint( wpsp_get_setting( $id, 'wpsp_excerpt_length' ) ),
|
||||
'post_id' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_id' ) ),
|
||||
'exclude_post_id' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_exclude_post_id' ) ),
|
||||
'ignore_sticky_posts' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_ignore_sticky_posts' ) ),
|
||||
'include_title' => wp_validate_boolean( get_post_meta( $id, 'wpsp_include_title', true ) ),
|
||||
'title_element' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_title_element' ) ),
|
||||
'image' => sanitize_text_field( get_post_meta( $id, 'wpsp_image', true ), FILTER_VALIDATE_BOOLEAN ),
|
||||
'image_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_image_location' ) ),
|
||||
'image_alignment' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_image_alignment' ) ),
|
||||
'image_height' => absint( wpsp_get_setting( $id, 'wpsp_image_height' ) ),
|
||||
'image_width' => absint( wpsp_get_setting( $id, 'wpsp_image_width' ) ),
|
||||
'include_author' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_include_author' ) ),
|
||||
'author_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_author_location' ) ),
|
||||
'include_terms' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_include_terms' ) ),
|
||||
'terms_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_terms_location' ) ),
|
||||
'include_date' => wp_validate_boolean( get_post_meta( $id, 'wpsp_include_date', true ) ),
|
||||
'date_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_date_location' ) ),
|
||||
'include_comments' => wp_validate_boolean( get_post_meta( $id, 'wpsp_include_comments', true ) ),
|
||||
'comments_location' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_comments_location' ) ),
|
||||
'inner_wrapper' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_inner_wrapper' ) ),
|
||||
'inner_wrapper_class' => array_map( 'sanitize_html_class', ( explode( ' ', wpsp_get_setting( $id, 'wpsp_inner_wrapper_class' ) ) ) ),
|
||||
'inner_wrapper_style' => explode( ' ', esc_attr( wpsp_get_setting( $id, 'wpsp_inner_wrapper_style' ) ) ),
|
||||
'itemtype' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_itemtype' ) ),
|
||||
'meta_key' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_meta_key' ) ),
|
||||
'meta_value' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_meta_value' ) ),
|
||||
'offset' => absint( wpsp_get_setting( $id, 'wpsp_offset' ) ),
|
||||
'order' => sanitize_key( wpsp_get_setting( $id, 'wpsp_order' ) ),
|
||||
'orderby' => sanitize_key( wpsp_get_setting( $id, 'wpsp_orderby' ) ),
|
||||
'pagination' => wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_pagination' ) ),
|
||||
'post_type' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_type' ) ),
|
||||
'post_status' => wpsp_get_setting( $id, 'wpsp_post_status' ), // Validated later
|
||||
'posts_per_page' => intval( wpsp_get_setting( $id, 'wpsp_posts_per_page' ) ),
|
||||
'tax_operator' => wpsp_get_setting( $id, 'wpsp_tax_operator' ), // Validated later
|
||||
'tax_term' => wpsp_get_setting( $id, 'wpsp_tax_term' ),
|
||||
'taxonomy' => sanitize_key( wpsp_get_setting( $id, 'wpsp_taxonomy' ) ),
|
||||
'read_more_text' => wp_kses_post( wpsp_get_setting( $id, 'wpsp_read_more_text' ) ),
|
||||
'wrapper' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_wrapper' ) ),
|
||||
'wrapper_class' => array_map( 'sanitize_html_class', ( explode( ' ', wpsp_get_setting( $id, 'wpsp_wrapper_class' ) ) ) ),
|
||||
'wrapper_style' => explode( ' ', esc_attr( wpsp_get_setting( $id, 'wpsp_wrapper_style' ) ) ),
|
||||
'no_results' => wpsp_get_setting( $id, 'wpsp_no_results' ),
|
||||
'post_meta_bottom_style' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_meta_bottom_style' ) ),
|
||||
'post_meta_top_style' => sanitize_text_field( wpsp_get_setting( $id, 'wpsp_post_meta_top_style' ) ),
|
||||
'read_more_class' => esc_attr( wpsp_get_setting( $id, 'wpsp_read_more_class' ) ),
|
||||
) );
|
||||
|
||||
// Replace args with any custom args.
|
||||
if ( ! empty( $custom_settings ) ) {
|
||||
if ( is_array( $custom_settings ) ) {
|
||||
$settings = array_merge( $settings, $custom_settings );
|
||||
}
|
||||
|
||||
if ( ! is_array( $custom_settings ) ) {
|
||||
$settings_string = parse_str( $custom_settings, $custom_settings );
|
||||
$settings = array_merge( $settings, $custom_settings );
|
||||
}
|
||||
}
|
||||
|
||||
// Grab initiate args for query
|
||||
$args = array();
|
||||
|
||||
if ( '' !== $settings[ 'order' ] ) {
|
||||
$args[ 'order' ] = esc_attr( $settings[ 'order' ] );
|
||||
}
|
||||
|
||||
if ( '' !== $settings[ 'orderby' ] ) {
|
||||
$args[ 'orderby' ] = esc_attr( $settings[ 'orderby' ] );
|
||||
}
|
||||
|
||||
if ( 'rand' == $settings[ 'orderby' ] && $settings[ 'pagination' ] ) {
|
||||
$args[ 'orderby' ] = 'rand(' . absint( $id ) . ')';
|
||||
}
|
||||
|
||||
if ( '' !== $settings[ 'post_type' ] ) {
|
||||
$args[ 'post_type' ] = esc_attr( $settings[ 'post_type' ] );
|
||||
}
|
||||
|
||||
if ( '' !== $settings[ 'posts_per_page' ] ) {
|
||||
$args[ 'posts_per_page' ] = intval( $settings[ 'posts_per_page' ] );
|
||||
}
|
||||
|
||||
if ( $settings[ 'ignore_sticky_posts' ] ) {
|
||||
$args[ 'ignore_sticky_posts' ] = wp_validate_boolean( $settings[ 'ignore_sticky_posts' ] );
|
||||
}
|
||||
|
||||
if ( '' !== $settings[ 'meta_key' ] ) {
|
||||
$args[ 'meta_key' ] = esc_html( $settings[ 'meta_key' ] );
|
||||
}
|
||||
|
||||
if ( '' !== $settings[ 'meta_value' ] ) {
|
||||
$args[ 'meta_value' ] = esc_html( $settings[ 'meta_value' ] );
|
||||
}
|
||||
|
||||
if ( $settings[ 'offset' ] > 0 ) {
|
||||
$args[ 'offset' ] = intval( $settings[ 'offset' ] );
|
||||
}
|
||||
|
||||
if ( '' !== $settings[ 'author' ] ) {
|
||||
$args[ 'author' ] = esc_html( $settings[ 'author' ] );
|
||||
}
|
||||
|
||||
if ( $settings[ 'pagination' ] && ! is_single() ) {
|
||||
$paged_query = is_front_page() ? 'page' : 'paged';
|
||||
$args[ 'paged' ] = get_query_var( $paged_query );
|
||||
}
|
||||
|
||||
// Post Status
|
||||
$settings[ 'post_status' ] = explode( ', ', $settings[ 'post_status' ] );
|
||||
$validated = array();
|
||||
$available = array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash', 'any' );
|
||||
|
||||
foreach ( $settings[ 'post_status' ] as $unvalidated ) {
|
||||
if ( in_array( $unvalidated, $available ) ) {
|
||||
$validated[] = $unvalidated;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $validated ) ) {
|
||||
$args['post_status'] = $validated;
|
||||
}
|
||||
|
||||
// If taxonomy attributes, create a taxonomy query
|
||||
if ( ! empty( $settings[ 'taxonomy' ] ) && ! empty( $settings[ 'tax_term' ] ) ) {
|
||||
|
||||
if ( is_array( $settings[ 'tax_term' ] ) ) {
|
||||
$settings[ 'tax_term' ] = implode( ', ', $settings[ 'tax_term' ] );
|
||||
}
|
||||
|
||||
if ( 'current' == $settings[ 'tax_term' ] ) {
|
||||
global $post;
|
||||
$terms = wp_get_post_terms(get_the_ID(), $settings[ 'taxonomy' ]);
|
||||
$settings[ 'tax_term' ] = array();
|
||||
foreach ($terms as $term) {
|
||||
$settings[ 'tax_term' ][] = $term->slug;
|
||||
}
|
||||
} else {
|
||||
// Term string to array
|
||||
$settings[ 'tax_term' ] = explode( ', ', $settings[ 'tax_term' ] );
|
||||
}
|
||||
|
||||
// Validate operator
|
||||
if ( ! in_array( $settings[ 'tax_operator' ], array( 'IN', 'NOT IN', 'AND' ) ) ) {
|
||||
$settings[ 'tax_operator' ] = 'IN';
|
||||
}
|
||||
|
||||
$tax_args = array(
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => $settings[ 'taxonomy' ],
|
||||
'field' => 'slug',
|
||||
'terms' => $settings[ 'tax_term' ],
|
||||
'operator' => $settings[ 'tax_operator' ]
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$args = array_merge( $args, $tax_args );
|
||||
|
||||
}
|
||||
|
||||
// If Post IDs
|
||||
if ( $settings[ 'post_id' ] ) {
|
||||
$posts_in = array_map( 'intval', explode( ',', $settings[ 'post_id' ] ) );
|
||||
$args['post__in'] = $posts_in;
|
||||
}
|
||||
|
||||
// If Exclude Post IDs
|
||||
if ( $settings[ 'exclude_post_id' ] ) {
|
||||
$posts_not_in = array_map( 'intval', explode( ',', $settings[ 'exclude_post_id' ] ) );
|
||||
$args['post__not_in'] = $posts_not_in;
|
||||
}
|
||||
|
||||
// If Exclude Current
|
||||
if ( ( is_singular() && $settings[ 'exclude_current' ] ) || is_single() ) {
|
||||
$args['post__not_in'] = array( get_the_ID() );
|
||||
}
|
||||
|
||||
// Border
|
||||
if ( defined( 'WPSP_PRO_VERSION' ) && version_compare( WPSP_PRO_VERSION, '0.6', '<' ) ) {
|
||||
$border = wpsp_sanitize_hex_color( wpsp_get_setting( $settings['list_id'], 'wpsp_border' ) );
|
||||
if ( '' !== $border ) {
|
||||
$settings['wrapper_class'][] = 'include-border';
|
||||
if ( ! function_exists( 'wpsp_styling' ) ) {
|
||||
$border = 'border-color: ' . $border . ';';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Padding
|
||||
if ( defined( 'WPSP_PRO_VERSION' ) && version_compare( WPSP_PRO_VERSION, '0.6', '<' ) ) {
|
||||
$padding = sanitize_text_field( wpsp_get_setting( $settings['list_id'], 'wpsp_padding' ) );
|
||||
if ( '' !== $padding ) {
|
||||
$settings['wrapper_class'][] = 'include-padding';
|
||||
$padding = 'padding:' . $padding . ';';
|
||||
}
|
||||
}
|
||||
|
||||
// Columns
|
||||
if ( 'col-12' !== $settings[ 'columns' ] ) {
|
||||
wp_enqueue_script( 'wpsp-matchHeight', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/jquery.matchHeight.js', array( 'jquery' ), WPSP_VERSION, true );
|
||||
$settings[ 'wrapper_class' ][] = 'wp-show-posts-columns';
|
||||
}
|
||||
|
||||
// Featured post class
|
||||
$featured_post = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_featured_post' ) );
|
||||
|
||||
$current_post = '';
|
||||
if ( 'col-12' !== $settings[ 'columns' ] && $featured_post ) {
|
||||
if ( $settings[ 'columns' ] == 'col-6' ) {
|
||||
$current_post = 'wpsp-col-12';
|
||||
}
|
||||
|
||||
if ( $settings[ 'columns' ] == 'col-4' ) {
|
||||
$current_post = 'wpsp-col-8';
|
||||
}
|
||||
|
||||
if ( $settings[ 'columns' ] == 'col-3' ) {
|
||||
$current_post = 'wpsp-col-6';
|
||||
}
|
||||
|
||||
if ( $settings[ 'columns' ] == 'col-20' ) {
|
||||
$current_post = 'wpsp-col-6';
|
||||
}
|
||||
}
|
||||
|
||||
// Masonry
|
||||
$masonry = wp_validate_boolean( wpsp_get_setting( $id, 'wpsp_masonry' ) );
|
||||
|
||||
if ( $masonry ) {
|
||||
$settings[ 'wrapper_class' ][] = 'wp-show-posts-masonry';
|
||||
$settings[ 'inner_wrapper_class' ][] = ' wp-show-posts-masonry-' . esc_attr( $settings[ 'columns' ] );
|
||||
$settings[ 'inner_wrapper_class' ][] = ' wp-show-posts-masonry-block';
|
||||
|
||||
wp_enqueue_script( 'wpsp-imagesloaded' );
|
||||
wp_enqueue_script( 'jquery-masonry' );
|
||||
wp_add_inline_script( 'jquery-masonry', 'jQuery(function($){var $container = $(".wp-show-posts-masonry");$container.imagesLoaded( function(){$container.fadeIn( 1000 ).masonry({itemSelector : ".wp-show-posts-masonry-block",columnWidth: ".grid-sizer"}).css("opacity","1");});});' );
|
||||
}
|
||||
|
||||
// Add the default inner wrapper class
|
||||
// We don't create the class element up here like below, as we need to add classes inside the loop below as well
|
||||
$settings[ 'inner_wrapper_class' ][] = 'wp-show-posts-single';
|
||||
|
||||
if ( 'col-12' == $settings[ 'columns' ] ) {
|
||||
$settings[ 'inner_wrapper_class' ][] = 'wpsp-clearfix';
|
||||
}
|
||||
|
||||
// Add the default wrapper class
|
||||
$settings[ 'wrapper_class' ][] = 'wp-show-posts';
|
||||
|
||||
// Get the wrapper class
|
||||
if ( ! empty( $settings[ 'wrapper_class' ] ) ) {
|
||||
$settings[ 'wrapper_class' ] = ' class="' . esc_attr( implode( ' ', $settings[ 'wrapper_class' ] ) ) . '"';
|
||||
}
|
||||
|
||||
// Get the wrapper style
|
||||
if ( ! empty( $settings[ 'wrapper_style' ] ) ) {
|
||||
$settings[ 'wrapper_style' ] = ' style="' . esc_attr( implode( ' ', $settings[ 'wrapper_style' ] ) ) . '"';
|
||||
}
|
||||
|
||||
// Get the inner wrapper class
|
||||
if ( ! empty( $settings[ 'inner_wrapper_style' ] ) ) {
|
||||
$settings[ 'inner_wrapper_style' ] = ' style="' . esc_attr( implode( ' ', $settings[ 'inner_wrapper_style' ] ) ) . '"';
|
||||
}
|
||||
|
||||
$wrapper = wpsp_clean_string( $settings[ 'wrapper' ] );
|
||||
$inner_wrapper = wpsp_clean_string( $settings[ 'inner_wrapper' ] );
|
||||
|
||||
// Get the wrapper ID
|
||||
$wrapper_id = ' id="wpsp-' . esc_attr( $id ) . '"';
|
||||
|
||||
$wrapper_atts = apply_filters( 'wpsp_wrapper_atts', '', $settings );
|
||||
|
||||
do_action( 'wpsp_before_wrapper', $settings );
|
||||
|
||||
// Start the wrapper
|
||||
echo '<' . $wrapper . $wrapper_id . $settings[ 'wrapper_class' ] . $settings[ 'wrapper_style' ] . $wrapper_atts . '>';
|
||||
|
||||
do_action( 'wpsp_inside_wrapper', $settings );
|
||||
|
||||
if ( $masonry ) {
|
||||
echo '<div class="grid-sizer wpsp-' . esc_attr( $settings[ 'columns' ] ) . '"></div>';
|
||||
}
|
||||
|
||||
// Filter kept for backward compatibility.
|
||||
$args = apply_filters( 'wp_show_posts_shortcode_args', $args, $settings );
|
||||
|
||||
// Start the query.
|
||||
$query = new WP_Query( apply_filters( 'wpsp_query_args', $args, $settings ) );
|
||||
|
||||
// Start the loop
|
||||
if ( $query->have_posts() ) {
|
||||
while ( $query->have_posts() ) {
|
||||
$query->the_post();
|
||||
|
||||
// Get page
|
||||
$paged_query = is_front_page() ? 'page' : 'paged';
|
||||
$paged = ( get_query_var( $paged_query ) ) ? get_query_var( $paged_query ) : 1;
|
||||
|
||||
$featured = '';
|
||||
$column_class = '';
|
||||
|
||||
// Featured post
|
||||
if ( $settings[ 'columns' ] !== 'col-12' && $featured_post ) {
|
||||
if ( $query->current_post == 0 && $paged == 1 ) {
|
||||
$featured = ' featured-column ' . $current_post;
|
||||
} else {
|
||||
$featured = ' wpsp-' . $settings[ 'columns' ];
|
||||
}
|
||||
} elseif ( $settings[ 'columns' ] !== 'col-12' ) {
|
||||
$column_class .= ' wpsp-' . $settings[ 'columns' ];
|
||||
}
|
||||
|
||||
$post_classes = implode( ' ', $settings[ 'inner_wrapper_class' ] );
|
||||
|
||||
// Merge our classes with the post classes.
|
||||
if ( has_filter( 'post_class', 'generate_blog_post_classes' ) ) {
|
||||
remove_filter( 'post_class', 'generate_blog_post_classes' ); // Remove GPP classes.
|
||||
}
|
||||
|
||||
$post_classes .= ' ' . implode( ' ', get_post_class() );
|
||||
|
||||
if ( function_exists( 'generate_blog_post_classes' ) ) {
|
||||
add_filter( 'post_class', 'generate_blog_post_classes' ); // Re-add them.
|
||||
}
|
||||
|
||||
// Start inner container
|
||||
printf( '<%1$s class="%2$s" itemtype="http://schema.org/%3$s" itemscope>',
|
||||
$inner_wrapper,
|
||||
esc_attr( $post_classes . $column_class . $featured ),
|
||||
esc_attr( $settings[ 'itemtype' ] )
|
||||
);
|
||||
|
||||
echo '<div class="wp-show-posts-inner"' . $settings[ 'inner_wrapper_style' ] . '>';
|
||||
|
||||
do_action( 'wpsp_before_header', $settings );
|
||||
|
||||
// The title
|
||||
if ( $settings[ 'include_title' ] || ( $settings[ 'include_author' ] && 'below-title' == $settings[ 'author_location' ] ) || ( $settings[ 'include_date' ] && 'below-title' == $settings[ 'date_location' ] ) || ( $settings[ 'include_terms' ] && 'below-title' == $settings[ 'terms_location' ] ) ) : ?>
|
||||
<header class="wp-show-posts-entry-header">
|
||||
<?php
|
||||
|
||||
do_action( 'wpsp_before_title', $settings );
|
||||
|
||||
$title_element = wpsp_clean_string( $settings[ 'title_element' ] );
|
||||
|
||||
$before_title = sprintf(
|
||||
'<%1$s class="wp-show-posts-entry-title" itemprop="headline"><a href="%2$s" rel="bookmark">',
|
||||
$title_element,
|
||||
esc_url( get_permalink() )
|
||||
);
|
||||
|
||||
$after_title = '</a></' . $title_element . '>';
|
||||
|
||||
if ( apply_filters( 'wpsp_disable_title_link', false, $settings ) ) {
|
||||
$before_title = '<' . $title_element . ' class="wp-show-posts-entry-title" itemprop="headline">';
|
||||
$after_title = '</' . $title_element . '>';
|
||||
}
|
||||
|
||||
if ( $settings[ 'include_title' ] ) {
|
||||
the_title( $before_title, $after_title );
|
||||
}
|
||||
|
||||
do_action( 'wpsp_after_title', $settings );
|
||||
?>
|
||||
</header><!-- .entry-header -->
|
||||
<?php endif;
|
||||
|
||||
do_action( 'wpsp_before_content', $settings );
|
||||
|
||||
// Check to see if we have the more tag
|
||||
global $post;
|
||||
$more_tag = apply_filters( 'wpsp_more_tag', strpos( $post->post_content, '<!--more-->' ) );
|
||||
|
||||
// The excerpt or full content
|
||||
if ( 'excerpt' == $settings[ 'content_type' ] && $settings[ 'excerpt_length' ] && ! $more_tag && 'none' !== $settings[ 'content_type' ] ) : ?>
|
||||
<div class="wp-show-posts-entry-summary" itemprop="text">
|
||||
<?php wpsp_excerpt( absint( $settings[ 'excerpt_length' ] ) ); ?>
|
||||
</div><!-- .entry-summary -->
|
||||
<?php elseif ( ( 'full' == $settings[ 'content_type' ] || $more_tag ) && 'none' !== $settings[ 'content_type' ] ) : ?>
|
||||
<div class="wp-show-posts-entry-content" itemprop="text">
|
||||
<?php the_content( false, false ); ?>
|
||||
</div><!-- .entry-content -->
|
||||
<?php endif;
|
||||
|
||||
do_action( 'wpsp_after_content', $settings );
|
||||
|
||||
echo '</div><!-- wp-show-posts-inner -->';
|
||||
|
||||
if ( 'col-12' == $settings[ 'columns' ] ) {
|
||||
echo '<div class="wpsp-clear"></div>';
|
||||
}
|
||||
|
||||
// End inner container
|
||||
echo '</' . $inner_wrapper . '>';
|
||||
}
|
||||
} else {
|
||||
// no posts found
|
||||
echo $settings[ 'columns' ] !== 'col-12' ? '<div class="wpsp-no-results" style="margin-left: ' . esc_attr( $settings[ 'columns_gutter' ] ) . ';">' : '';
|
||||
echo wpautop( wp_kses_post( $settings[ 'no_results' ] ) );
|
||||
echo $settings[ 'columns' ] !== 'col-12' ? '</div>' : '';
|
||||
}
|
||||
|
||||
if ( $settings[ 'columns' ] !== 'col-12' ) {
|
||||
echo '<div class="wpsp-clear"></div>';
|
||||
}
|
||||
|
||||
echo '</' . $wrapper . '><!-- .wp-show-posts -->';
|
||||
|
||||
do_action( 'wpsp_after_wrapper', $settings );
|
||||
|
||||
// Pagination
|
||||
if ( $settings[ 'pagination' ] && $query->have_posts() && ! is_single() ) {
|
||||
$ajax_pagination = wp_validate_boolean( wpsp_get_setting( $settings['list_id'], 'wpsp_ajax_pagination' ) );
|
||||
|
||||
if ( $ajax_pagination && function_exists( 'wpsp_ajax_pagination' ) ) {
|
||||
|
||||
$max_page = $query->max_num_pages;
|
||||
$nextpage = intval( $paged ) + 1;
|
||||
|
||||
if ( $nextpage <= $max_page ) {
|
||||
$next_page_url = next_posts( $max_page, false );
|
||||
}
|
||||
|
||||
wpsp_ajax_pagination( $next_page_url, $paged, $max_page );
|
||||
wp_enqueue_script( 'wpsp-imagesloaded' );
|
||||
wp_enqueue_script( 'wpsp-ajax-pagination' );
|
||||
} else {
|
||||
wpsp_pagination( $query->max_num_pages );
|
||||
}
|
||||
}
|
||||
|
||||
if ( defined( 'WPSP_PRO_VERSION' ) && version_compare( WPSP_PRO_VERSION, '0.6', '<' ) ) {
|
||||
// Lightbox and gallery
|
||||
$image_lightbox = sanitize_text_field( wpsp_get_setting( $settings['list_id'], 'wpsp_image_lightbox' ) );
|
||||
if ( $image_lightbox ) {
|
||||
wp_enqueue_script( 'wpsp-featherlight' );
|
||||
wp_enqueue_style( 'wpsp-featherlight' );
|
||||
|
||||
$image_gallery = sanitize_text_field( wpsp_get_setting( $settings['list_id'], 'wpsp_image_gallery' ) );
|
||||
if ( $image_gallery ) {
|
||||
wp_enqueue_script( 'wpsp-featherlight-gallery' );
|
||||
wp_enqueue_style( 'wpsp-featherlight-gallery' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Restore original Post Data
|
||||
wp_reset_postdata();
|
||||
}
|
||||
|
||||
add_shortcode( 'wp_show_posts', 'wpsp_shortcode_function' );
|
||||
/*
|
||||
* Build the shortcode
|
||||
*
|
||||
* @since 0.1
|
||||
*
|
||||
* @param array $atts The shortcode attributes.
|
||||
*/
|
||||
function wpsp_shortcode_function( $atts ) {
|
||||
$atts = shortcode_atts(
|
||||
array(
|
||||
'id' => '',
|
||||
'name' => '',
|
||||
'settings' => ''
|
||||
), $atts, 'wp_show_posts'
|
||||
);
|
||||
|
||||
ob_start();
|
||||
|
||||
// Get the ID from the list name if it's provided.
|
||||
if ( ! empty( $atts['name'] ) ) {
|
||||
$list = get_page_by_title( $atts['name'], 'OBJECT', 'wp_show_posts' );
|
||||
$atts['id'] = $list->ID;
|
||||
}
|
||||
|
||||
if ( $atts['id'] ) {
|
||||
wpsp_display( $atts['id'], $atts['settings'] );
|
||||
}
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
Reference in new issue
Block a user