Skip to content

Commit

Permalink
Merge branch 'release-2.4.0-rc1' into releases
Browse files Browse the repository at this point in the history
  • Loading branch information
archetyped committed Apr 28, 2015
2 parents c7b751b + 88f40ab commit 51486eb
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 54 deletions.
32 changes: 31 additions & 1 deletion controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ protected function _options() {
)
);

parent::_options($opts);
parent::_set_options($opts);
}

/* Methods */
Expand Down Expand Up @@ -387,6 +387,30 @@ function is_enabled() {
return !!$ret;
}

/**
* Make sure content is valid for processing/activation
*
* @param string $content Content to validate
* @return bool TRUE if content is valid (FALSE otherwise)
*/
protected function is_content_valid($content = '') {
// Invalid hooks
if ( doing_filter('get_the_excerpt') )
return false;

// Non-string value
if ( !is_string($content) )
return false;

// Empty string
$content = trim($content);
if ( empty($content) )
return false;

// Content is valid
return true;
}

/**
* Activates galleries extracted from post
* @see get_post_galleries()
Expand Down Expand Up @@ -428,6 +452,9 @@ function activate_galleries($galleries) {
* @return string Post content
*/
public function activate_links($content, $group = null) {
if ( !$this->is_content_valid($content) ) {
return $content;
}
// Filter content before processing links
$content = $this->util->apply_filters('pre_process_links', $content);

Expand Down Expand Up @@ -1203,6 +1230,9 @@ function group_get_wrapper() {
* @return string Modified post content
*/
function group_shortcodes($content) {
if ( !$this->is_content_valid($content) ) {
return $content;
}
// Setup shortcodes to wrap
$shortcodes = $this->util->apply_filters('group_shortcodes', array( 'gallery', 'nggallery' ));
// Set custom callback
Expand Down
8 changes: 7 additions & 1 deletion includes/class.base.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,17 @@ private function _env() {
add_action( ( is_admin() ) ? 'admin_print_footer_scripts' : 'wp_footer', $this->util->m('set_client_context'), $this->util->priority('client_footer_output') );
}

/**
* Initialize options
* To be implemented in child classes
*/
protected function _options() {}

/**
* Initialize options
* To be called by child class
*/
protected function _options($options_config = null) {
protected function _set_options($options_config = null) {
$class = $this->util->get_class('Options');
$key = 'options';
if ( $this->shares($key) ) {
Expand Down
3 changes: 2 additions & 1 deletion includes/class.content_handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ public function clear() {
* Retrieves handlers sorted by priority
* @see parent::get()
* @uses get_cache()
* @param mixed $args Unused
* @return array Handlers
*/
public function get() {
public function get($args = null) {
$items = $this->get_cache();
if ( empty($items) ) {
//Retrieve items
Expand Down
30 changes: 16 additions & 14 deletions includes/class.field_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function &get_path_value($path = '') {
* @return mixed Member value if found (Default: empty string)
*/
function get_parent_value($member, $name = '', $default = '') {
$parent =& $this->get_parent();
$parent = $this->get_parent();
return $this->get_object_value($parent, $member, $name, $default, 'parent');
}

Expand Down Expand Up @@ -535,7 +535,7 @@ function get_data($context = '', $top = true) {
//Iterate through objects
while ( !empty($obj_path) ) {
//Get next object
$obj =& array_shift($obj_path);
$obj = array_shift($obj_path);
//Shorten path
array_shift($path);
//Check for value in object and stop iteration if matching data found
Expand Down Expand Up @@ -572,7 +572,7 @@ function set_parent($parent = null) {
return false;
//Parent passed as object reference wrapped in array
if ( is_array($parent) && isset($parent[0]) && is_object($parent[0]) )
$parent =& $parent[0];
$parent = $parent[0];

//No parent set but parent ID (previously) set in object
if ( empty($parent) && is_string($this->parent) )
Expand All @@ -585,22 +585,22 @@ function set_parent($parent = null) {
/**
* @var SLB
*/
$b =& $this->get_base();
if ( $b && isset($b->fields) && $b->fields->has($parent) ) {
$parent =& $b->fields->get($parent);
$b = $this->get_base();
if ( !!$b && isset($b->fields) && $b->fields->has($parent) ) {
$parent = $b->fields->get($parent);
}
}

//Set parent value on object
if ( is_string($parent) || is_object($parent) )
$this->parent =& $parent;
$this->parent = $parent;
}

/**
* Retrieve field type parent
* @return SLB_Field_Type Reference to parent field
* @return SLB_Field_Type Parent field
*/
function &get_parent() {
function get_parent() {
return $this->parent;
}

Expand Down Expand Up @@ -981,11 +981,13 @@ function get_styles() {
* @return mixed Formatted value
*/
function format($value, $context = '') {
$handler = 'format_' . trim(strval($context));
//Only process if context is valid and has a handler
if ( !empty($context) && method_exists($this, $handler) ) {
//Pass value to handler
$value = $this->{$handler}($value, $context);
if ( is_scalar($context) && !empty($context) ) {
$handler = 'format_' . trim(strval($context));
//Only process if context is valid and has a handler
if ( !empty($context) && method_exists($this, $handler) ) {
//Pass value to handler
$value = $this->{$handler}($value, $context);
}
}
//Return formatted value
return $value;
Expand Down
12 changes: 6 additions & 6 deletions includes/class.field_collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ function set_data($item, $value = '', $save = true, $force_set = false) {
* @param string|obj $id Unique name for item or item instance
* @param array $properties (optional) Item properties
* @param bool $update (optional) Update or overwrite existing item (Default: FALSE)
* @return object Reference to new item
* @return object Newly-added item
*/
function &add($id, $properties = array(), $update = false) {
function add($id, $properties = array(), $update = false) {
$item;
$args = func_get_args();
//Properties
Expand Down Expand Up @@ -308,7 +308,7 @@ function get_data($item = null, $context = '', $top = true) {
$this->load_data();
$ret = null;
if ( $this->has($item) ) {
$item =& $this->get($item);
$item = $this->get($item);
$ret = $item->get_data($context, $top);
} else {
$ret = parent::get_data($context, $top);
Expand Down Expand Up @@ -344,7 +344,7 @@ function add_items($items = array(), $update = false) {
* Retrieve reference to items in collection
* @return array Collection items (reference)
*/
function get_items($group = null, $sort = 'priority') {
function &get_items($group = null, $sort = 'priority') {
$gset = $this->group_exists($group);
if ( $gset ) {
$items = $this->get_group_items($group);
Expand Down Expand Up @@ -540,7 +540,7 @@ function add_to_group($group, $items, $priority = 10) {
//Add Items
foreach ( $items as $item ) {
//Skip if not in current collection
$itm_ref =& $this->get($item);
$itm_ref = $this->get($item);
if ( !$itm_ref ) {
continue;
}
Expand All @@ -558,7 +558,7 @@ function add_to_group($group, $items, $priority = 10) {
if ( !isset($items[$priority]) ) {
$items[$priority] = array();
}
$items[$priority][$itm_id] =& $itm_ref;
$items[$priority][$itm_id] = $itm_ref;
}
unset($itm_ref);
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class.option.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function get_default($context = '') {
* Sets parent based on default value
*/
function set_parent($parent = null) {
$p =& $this->get_parent();
$p = $this->get_parent();
if ( empty($parent) && empty($p) ) {
$parent = 'text';
$d = $this->get_default();
Expand Down
8 changes: 4 additions & 4 deletions includes/class.options.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function migrate($full = false) {
$d = null;
$this->load_data();

$items =& $this->get_items();
$items = $this->get_items();

//Migrate separate options to unified option
if ( $full ) {
Expand Down Expand Up @@ -280,7 +280,7 @@ function register_fields($fields) {
function set_parents($fields) {
if ( !is_admin() )
return false;
$items =& $this->get_items();
$items = &$this->get_items();
foreach ( array_keys($items) as $opt ) {
$items[$opt]->set_parent();
}
Expand Down Expand Up @@ -442,7 +442,7 @@ function get_key() {
function &add($id, $properties = array(), $update = false) {
//Create item
$args = func_get_args();
$ret =& call_user_func_array(array('parent', 'add'), $args);
$ret = call_user_func_array(array('parent', 'add'), $args);
return $ret;
}

Expand Down Expand Up @@ -498,7 +498,7 @@ function build_init() {
* @return array Associative array of options
*/
function build_client_output() {
$items =& $this->get_items();
$items = $this->get_items();
$out = array();
foreach ( $items as $option ) {
if ( !$option->get_in_client() )
Expand Down
2 changes: 1 addition & 1 deletion includes/class.themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected function _options() {
)
);

parent::_options($opts);
parent::_set_options($opts);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions includes/class.utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class SLB_Utilities {

/* Constructors */

function __construct(&$obj) {
function __construct($obj) {
if ( is_object($obj) ) {
$this->_parent =& $obj;
$this->_parent = $obj;
}
}

Expand Down Expand Up @@ -620,7 +620,7 @@ function get_parent() {
* @return mixed Parent property value
*/
function get_parent_property($prop, $default = '') {
$p =& $this->get_parent();
$p = $this->get_parent();
return ( !!$p && property_exists($p, $prop) ) ? $p->{$prop} : $default;
}

Expand Down
2 changes: 1 addition & 1 deletion main.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Simple Lightbox
Plugin URI: http://archetyped.com/lab/slb-2_4_0-beta/
Description: The highly customizable lightbox for WordPress
Version: 2.4.0-b3
Version: 2.4.0-rc1
Author: Archetyped
Author URI: http://archetyped.com
Support URI: https://github.com/archetyped/simple-lightbox/wiki/Feedback-&-Support
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-lightbox",
"version": "2.4.0-b3",
"version": "2.4.0-rc1",
"title": "Simple Lightbox",
"description": "The highly-customizable lightbox for WordPress",
"author": "Sol Marchessault <sol@archetyped.com>",
Expand Down
28 changes: 8 additions & 20 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: Archetyped
Donate link: http://gum.co/slb-donate
License: GPLv2
Tags: lightbox, gallery, photography, images, theme, template, style
Requires at least: 3.9
Tested up to: 3.9
Requires at least: 4.2.1
Tested up to: 4.2.1
Stable tag: trunk

The highly customizable lightbox for WordPress
Expand Down Expand Up @@ -57,24 +57,12 @@ Get more information on [Simple Lightbox's official page](http://archetyped.com/

== Changelog ==

= 2.4.0 (Beta 3) =
* JS: Optimize: View Controller
* JS: Update: Set default ID for components
* JS: Optimize: Component properties
* JS: Optimize: Remove unused/deprecated Component methods/properties
* JS: Optimize: Component references handling
* JS: Optimize: Component attribute handling
* JS: Optimize: Component DOM handling

= 2.4.0 (Beta 2) =
* JS: Optimize: Core library
* JS: Optimize: Utilities library
* JS: Optimize: Default template tags (item, ui)
* JS: Optimize: Default content handlers (image)
* JS: Optimize: Default themes (baseline, default)
* JS: Optimize: View controller

= 2.4.0 (Beta 1) =
= 2.4.0 (RC1) =

* Update: WordPress version compatibility (v4.2.1)
* Optimize: Standardize code
* Optimize: Do not process excerpt content
* Optimize: Client-side libraries (Phase 1)
* Add: Set group via `slb_activate()`
* Add: Set group via `activate_links()`
* Add: `slb_is_enabled` filter
Expand Down

0 comments on commit 51486eb

Please sign in to comment.