Skip to content

Commit

Permalink
Merge branch 'release-2.3.0-b2' into releases
Browse files Browse the repository at this point in the history
  • Loading branch information
archetyped committed Mar 19, 2014
2 parents bae74eb + 828a175 commit 3045934
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 56 deletions.
2 changes: 1 addition & 1 deletion client/js/dev/lib.admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

/* global SLB, postboxes, pagenow */

if ( window.SLB && SLB.attach ) { (function ($) {
if ( !!window.SLB && !!SLB.attach ) { (function ($) {

SLB.attach('Admin', {
/**
Expand Down
24 changes: 21 additions & 3 deletions client/js/dev/lib.view.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @author Archetyped
*/
/* global SLB */
if ( window.SLB && SLB.attach ) { (function ($) {
if ( !!window.SLB && !!SLB.attach ) { (function ($) {


/*-** Controller **-*/
Expand Down Expand Up @@ -1662,6 +1662,7 @@ var Viewer = {
autofit: true,
overlay_enabled: true,
overlay_opacity: '0.8',
title_default: false,
container: null,
slideshow_enabled: true,
slideshow_autostart: true,
Expand All @@ -1682,15 +1683,16 @@ var Viewer = {
_attr_parent: [
'theme',
'group_loop',
'ui_autofit', 'ui_animate', 'ui_overlay_opacity', 'ui_labels',
'ui_autofit', 'ui_animate', 'ui_overlay_opacity', 'ui_labels', 'ui_title_default',
'slideshow_enabled', 'slideshow_autostart', 'slideshow_duration'],

_attr_map: {
'group_loop': 'loop',
'ui_autofit': 'autofit',
'ui_animate': 'animate',
'ui_overlay_opacity': 'overlay_opacity',
'ui_labels': 'labels'
'ui_labels': 'labels',
'ui_title_default': 'title_default'
},

/* References */
Expand Down Expand Up @@ -3111,6 +3113,22 @@ var Content_Item = {
if ( !this.util.is_string(title, false) ) {
title = '';
}
//Strip default title
if ( !this.util.is_empty(title) && !this.get_viewer().get_attribute('title_default') ) {
var f = this.get_uri('source');
var i = f.lastIndexOf('/');
if ( -1 !== i ) {
f = f.substr(i + 1);
i = f.lastIndexOf('.');
if ( -1 !== i ) {
f = f.substr(0, i);
}
if ( title === f ) {
title = '';
}
}
}


//Cache retrieved value
this.set_attribute(prop_cached, title);
Expand Down
4 changes: 2 additions & 2 deletions client/js/prod/lib.view.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content-handlers/image/js/dev/handler.image.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ( window.SLB && SLB.has_child('View.extend_content_handler') ) {(function($) {
if ( !!window.SLB && SLB.has_child('View.extend_content_handler') ) {(function($) {
$(document).ready(function() {
SLB.View.extend_content_handler('image', {
/**
Expand Down
50 changes: 31 additions & 19 deletions controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ protected function _hooks() {

/* Admin */
add_action('admin_menu', $this->m('admin_menus'));
$this->util->add_filter('admin_plugin_row_meta_support', $this->m('admin_plugin_row_meta_support'));

/* Init */
add_action('wp', $this->m('_hooks_init'));
Expand Down Expand Up @@ -230,13 +231,14 @@ protected function _options() {
'slideshow_duration' => array('title' => __('Slide Duration (Seconds)', 'simple-lightbox'), 'default' => '6', 'attr' => array('size' => 3, 'maxlength' => 3), 'group' => array('ui', 40), 'in_client' => true),
'group_loop' => array('title' => __('Loop through items', 'simple-lightbox'),'default' => true, 'group' => array('ui', 50), 'in_client' => true),
'ui_overlay_opacity' => array('title' => __('Overlay Opacity (0 - 1)', 'simple-lightbox'), 'default' => '0.8', 'attr' => array('size' => 3, 'maxlength' => 3), 'group' => array('ui', 60), 'in_client' => true),
'ui_title_default' => array('title' => __('Enable default title', 'simple-lightbox'), 'default' => false, 'group' => array('ui', 70), 'in_client' => true),
'txt_loading' => array('title' => __('Loading indicator', 'simple-lightbox'), 'default' => 'Loading', 'group' => array('labels', 20)),
'txt_close' => array('title' => __('Close button', 'simple-lightbox'), 'default' => 'Close', 'group' => array('labels', 10)),
'txt_nav_next' => array('title' => __('Next Item button', 'simple-lightbox'), 'default' => 'Next', 'group' => array('labels', 30)),
'txt_nav_prev' => array('title' => __('Previous Item button', 'simple-lightbox'), 'default' => 'Previous', 'group' => array('labels', 40)),
'txt_slideshow_start' => array('title' => __('Start Slideshow button', 'simple-lightbox'), 'default' => 'Start slideshow', 'group' => array('labels', 50)),
'txt_slideshow_stop' => array('title' => __('Stop Slideshow button', 'simple-lightbox'),'default' => 'Stop slideshow', 'group' => array('labels', 60)),
'txt_group_status' => array('title' => __('Slideshow status format', 'simple-lightbox'), 'default' => 'Item %current% of %total%', 'group' => array('labels', 70))
'txt_group_status' => array('title' => __('Slideshow status format', 'simple-lightbox'), 'default' => 'Item %current% of %total%', 'group' => array('labels', 70))
),
'legacy' => array (
'header_activation' => null,
Expand Down Expand Up @@ -297,7 +299,7 @@ function admin_menus() {
//Add Support information
$support = $this->util->get_plugin_info('SupportURI');
if ( !empty($support) ) {
$pg_opts->add_content('support', __('Support', 'simple-lightbox'), $this->m('theme_page_callback_support'), 'secondary');
$pg_opts->add_content('support', __('Feedback & Support', 'simple-lightbox'), $this->m('theme_page_callback_support'), 'secondary');
}

//Add Actions
Expand All @@ -314,13 +316,22 @@ function admin_menus() {
* Support information
*/
public function theme_page_callback_support() {
echo '<p>';
_e("Getting support is easy! Whether you're experiencing an issue or have a feature request, click the button below to get support right now!", 'simple-lightbox');
echo '</p>';

$lnk_txt = __('Get Support', 'simple-lightbox');
// Description
$desc = __("<p>Simple Lightbox thrives on your feedback!</p><p>Click the button below to <strong>get help</strong>, <strong>request a feature</strong>, or <strong>provide some feedback</strong>!</p>", 'simple-lightbox');
echo $desc;
// Link
$lnk_uri = $this->util->get_plugin_info('SupportURI');
printf('<a href="%s" title="%s" target="_blank" class="button">%s</a>', $lnk_uri, esc_attr($lnk_txt), $lnk_txt);
$lnk_txt = __('Get Support &amp; Provide Feedback', 'simple-lightbox');
echo $this->util->build_html_link($lnk_uri, $lnk_txt, array('target' => '_blank', 'class' => 'button'));
}

/**
* Filter support link text in plugin metadata
* @param string $text Original link text
* @return string Modified link text
*/
public function admin_plugin_row_meta_support($text) {
return "Feedback &amp; Support";
}

/*-** Functionality **-*/
Expand Down Expand Up @@ -657,6 +668,9 @@ function process_links($content, $group = null) {
//Cache item attributes
$this->cache_media_item($uri, $type, $internal, $props_extra);

//Filter attributes
$attrs = $this->util->apply_filters('process_link_attributes', $attrs);

//Update link in content
$link_new = '<a ' . $this->util->build_attribute_string($attrs) . '>';
$content = str_replace($link, $link_new, $content);
Expand Down Expand Up @@ -814,15 +828,6 @@ function client_script_media($client_script) {

$m_items = $this->media_items = $this->get_cached_media_items();
foreach ( $m_items as $uri => $p ) {
/*
$type = $p->{$props->type};
//Initialize bucket (if necessary)
if ( !isset($m_bucket[$type]) ) {
$m_bucket[$type] = array();
}
//Add item to bucket
$m_bucket[$type][$uri] =& $m_items[$uri];
*/
//Set aside internal links for additional processing
if ( $p->internal && !isset($m_internals[$uri]) ) {
$m_internals[$uri] =& $m_items[$uri];
Expand Down Expand Up @@ -857,7 +862,7 @@ function client_script_media($client_script) {
}
}
//Destroy worker vars
unset($uris_base, $uris_flat, $q, $pids, $pd);
unset($uris_base, $uris_flat, $q, $pids, $pd, $file);
}

//Process items with attachment IDs
Expand Down Expand Up @@ -902,6 +907,7 @@ function client_script_media($client_script) {
foreach ( $atts as $att ) {
//Set post data
$m = array();

//Remap post data to properties
foreach ( $props_map as $prop_key => $prop_source ) {
$m[$props->{$prop_key}] = $att->{$prop_source};
Expand Down Expand Up @@ -934,13 +940,19 @@ function client_script_media($client_script) {

//Save attachment data (post & meta) to original object(s)
foreach ( $pids[$att->ID] as $uri ) {
$this->media_items[$uri] = (object) array_merge( (array) $m_items[$uri], $m);
$this->media_items[$uri] = array_merge( (array) $m_items[$uri], $m);
}

}
}
unset($atts, $atts_meta, $m, $a, $uri, $pids, $pids_flat);
}

// Filter media item properties
foreach ( $this->media_items as $key => $props ) {
$this->media_items[$key] = $this->util->apply_filters('media_item_properties', (object) $props);
}

//Expand URI variants
foreach ( $m_items as $uri => $p ) {
if ( empty($p->_entries) ) {
Expand Down
24 changes: 24 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* Functions
* Provides global access to specific functionality
* @package Simple Lightbox
* @author Archetyped
*/

/* Template Tags */

/**
* Activate links in user-defined content
* @param string $content
* @return string Updated content with activated links
*/
function slb_activate($content) {
// Validate
if ( empty($content) ) {
return $content;
}
// Activate links
$content = $GLOBALS['slb']->activate_links($content);
return $content;
}
7 changes: 4 additions & 3 deletions includes/class.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,13 @@ public function plugin_action_links($actions, $plugin_file, $plugin_data, $conte
*/
public function plugin_row_meta($plugin_meta, $plugin_file, $plugin_data, $status) {
$u = ( is_object($this->parent) && isset($this->parent->util) ) ? $this->parent->util : $this->util;
$hook_base = 'admin_plugin_row_meta_';
if ( $plugin_file == $u->get_plugin_base_name() ) {
//Add metadata
//Support
$t = __('Get Support', 'simple-lightbox');
// Add metadata
// Support
$l = $u->get_plugin_info('SupportURI');
if ( !empty($l) ) {
$t = __( $this->util->apply_filters($hook_base . 'support', 'Get Support'), 'simple-lightbox');
$plugin_meta[] = $u->build_html_link($l, $t);
}
}
Expand Down
32 changes: 16 additions & 16 deletions includes/class.utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,24 +501,24 @@ function extend_client_object($obj, $data = null, $out = false) {
* If no command is specified the validation conditions are returned
*/
public function validate_client_object($obj, $cmd = null) {
//Build condition
// Get base object
$base = $this->get_client_object();

// Build condition
$sep = '.';
$obj = trim( $this->get_client_object($obj) , $sep);
$offset = 0;
$len = strlen($obj);
$pos = $len;
$fmt = '(typeof %s != \'undefined\')';
$objs = array();
//Add segments to array (in reverse)
do {
$objs[] = sprintf($fmt, substr($obj, 0, $pos));
$offset = $pos - $len - 1;
} while ( $offset < $len && ( $pos = strrpos($obj, $sep, $offset) ) && $pos !== false );
//Format condition
$condition = implode(' && ', array_reverse($objs));
$obj = trim($obj, $sep);
// Strip base object
if ( 0 === strpos($obj, $base . $sep) ) {
$obj = substr($obj, strlen($base . $sep));
}
$fmt = '!!window.%1$s';
if ( !empty($obj) ) {
$fmt .= ' && %1$s.has_child(\'%2$s\')';
}
$condition = sprintf($fmt, $base, $obj);

//Wrap command in validation
if ( is_string($cmd) && !empty($cmd) ) {
if ( !empty($cmd) && is_string($cmd) ) {
$condition = sprintf('if ( %1$s ) { %2$s }', $condition, $cmd);
}
return $condition;
Expand Down Expand Up @@ -1691,7 +1691,7 @@ function build_script_element($content = '', $id = '', $wrap_jquery = true, $wai
$start = array('/* <![CDATA[ */');
$end = array('/* ]]> */');
if ( $wrap_jquery ) {
$start[] = 'if ( typeof(jQuery) !== \'undefined\' ) {(function($){';
$start[] = 'if ( !!window.jQuery ) {(function($){';
$end[] = '})(jQuery);}';

//Add event handler (if necessary)
Expand Down
8 changes: 7 additions & 1 deletion load.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ function slb_autoload($classname) {
require $path;
}
}
spl_autoload_register('slb_autoload');

spl_autoload_register('slb_autoload');
/* Load Assets */

$path = dirname(__FILE__) . '/';
require_once $path . 'controller.php';
$GLOBALS['slb'] = new SLB_Lightbox();
require_once $path . 'functions.php';
8 changes: 3 additions & 5 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Plugin Name: Simple Lightbox
Plugin URI: http://archetyped.com/lab/slb-2_3_0-beta/
Description: The highly customizable lightbox for WordPress
Version: 2.3.0-b1 (BETA)
Version: 2.3.0-b2 (BETA)
Author: Archetyped
Author URI: http://archetyped.com
Support URI: https://github.com/archetyped/simple-lightbox/wiki/Reporting-Issues
Support URI: https://github.com/archetyped/simple-lightbox/wiki/Feedback-&-Support
*/
/*
Copyright 2013 Sol Marchessault ([email protected])
Copyright 2014 Sol Marchessault ([email protected])
*/
$slb = null;
/**
Expand All @@ -18,8 +18,6 @@
function slb_init() {
$path = dirname(__FILE__) . '/';
require_once $path . 'load.php';
require_once $path . 'controller.php';
$GLOBALS['slb'] = new SLB_Lightbox();
}

add_action('init', 'slb_init', 1);
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.3.0-b1",
"version": "2.3.0-b2",
"title": "Simple Lightbox",
"description": "The highly-customizable lightbox for WordPress",
"author": "Sol Marchessault <[email protected]>",
Expand Down
12 changes: 12 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ Get more information on [Simple Lightbox's official page](http://archetyped.com/
3. Dark Theme

== Changelog ==

= 2.3.0-b2 =
* Add: Manual link activation template tag (`slb_activate()`)
* Add: Option to enable/disable usage of WordPress-generated media title
* Add: Filter: Link attributes (`slb_process_link_attributes`)
* Add: Filter: Media properties (`slb_media_item_properties`)
* Add: Filter: Support link text (`slb_admin_plugin_row_meta_support`)
* Optimize: Client-side object detection
* Optimize: Remove deprecated code
* Optimize: Loading process
* Update: Support URI, content

= 2.3.0-b1 =
* Add: Production versions of client-side code (JS)
* Add: Dev mode
Expand Down
2 changes: 1 addition & 1 deletion template-tags/item/js/dev/tag.item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ( window.SLB && SLB.has_child('View.extend_template_tag_handler') ) {(function($) {
if ( !!window.SLB && SLB.has_child('View.extend_template_tag_handler') ) {(function($) {
$(document).ready(function() {
SLB.View.extend_template_tag_handler('item', {
/**
Expand Down
2 changes: 1 addition & 1 deletion template-tags/ui/js/dev/tag.ui.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ( window.SLB && SLB.has_child('View.extend_template_tag_handler') ) {(function($) {
if ( !!window.SLB && SLB.has_child('View.extend_template_tag_handler') ) {(function($) {
$(document).ready(function() {
SLB.View.extend_template_tag_handler('ui', {
_hooks : function() {
Expand Down
2 changes: 1 addition & 1 deletion themes/baseline/js/dev/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ( window.SLB && SLB.has_child('View.extend_theme') ) {(function($) {
if ( !!window.SLB && SLB.has_child('View.extend_theme') ) {(function($) {
$(document).ready(function() {
SLB.View.extend_theme('slb_baseline', {
'breakpoints': {
Expand Down
2 changes: 1 addition & 1 deletion themes/default/js/dev/client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ( window.SLB && SLB.has_child('View.extend_theme') ) {(function($) {
if ( !!window.SLB && SLB.has_child('View.extend_theme') ) {(function($) {
$(document).ready(function() {
SLB.View.extend_theme('slb_default', {
/**
Expand Down

0 comments on commit 3045934

Please sign in to comment.