c3256182 by Kevin Burton

minor changes to chatterbox and hybrid galleries, PLUS adding the AddThis plugin

1 parent c320c4d5
<?php
/*
Plugin Name: Add This + Facebook Like
*/
namespace Tz\WordPress\Tools\AddThis;
use Tz\WordPress\Tools;
const OPTION_NAME = "addthis_pl";
call_user_func(function() {
Vars::$options = new Tools\WP_Option(OPTION_NAME);
Tools\add_shortcodes(__NAMESPACE__ . '\ShortCodes');
if (is_admin()) {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'Settings.php');
}
});
class ShortCodes {
public static function addthis() {
ob_start();
include('views/view.php');
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}
class Vars {
/**
* WordPress option for this module
* @type WP_Option
*/
public static $options;
}
?>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\AddThis\Settings;
use Tz\Common;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\AddThis;
const OPTION_GROUP = 'addthis_group'; // Grouping of options used for setting output by WP
const OPTION_SECTION = 'tz_addthis_main';
const ADMIN_PAGE = 'tz-tools-addthis'; // URI of options page
const CAPABILITY = 'manage_addthis_params'; // User & Roles capability name
call_user_func(function() {
$role = get_role('administrator');
$role->add_cap(CAPABILITY);
Tools\add_actions(__NAMESPACE__ . '\Actions');
});
function displayPage() {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views/Settings.php');
}
function validate($data) {
return $data;
}
/**
* @uses Tools\add_actions
*/
class Actions {
/**
* Creates a settings page for the WP admin
*/
public static function admin_menu() {
add_options_page('AddThis', 'AddThis', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\displayPage');
}
/**
* Generates variables for the module's options
*/
public static function admin_init() {
register_setting(OPTION_GROUP, AddThis\OPTION_NAME, __NAMESPACE__ . '\validate');
add_settings_section(OPTION_SECTION, 'AddThis Default Expanded Settings', function(){}, ADMIN_PAGE);
Tools\add_settings_fields(__NAMESPACE__ . '\Fields', ADMIN_PAGE, OPTION_SECTION);
}
}
/**
* Each function is a variable stored in the WP_Option
* @uses Tools\add_settings_fields
*/
class Fields {
public static function use_32px_icons() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function show_share_dropdown() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function facebook() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function twitter() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function googlebuzz() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function print_button() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function email() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function facebook_like() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function myspace() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function digg() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
public static function stumble_upon() {
echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
}
}
?>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\AddThis\Settings;
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>AddThis Settings</h2>
<form method="post" action="options.php">
<?php
settings_fields(OPTION_GROUP);
do_settings_sections(ADMIN_PAGE);
?>
<p class="submit"><input type="submit" class="button-primary" value="Save Changes" /></p>
</form>
</div>
\ No newline at end of file
<?php
namespace Tz\WordPress\Tools\AddThis;
?>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
<div class="addthis_toolbox <?php echo isset(Vars::$options['use_32px_icons']) ? "addthis_32x32_style" : ""; ?> addthis_default_style">
<?php if ( isset(Vars::$options['show_share_dropdown']) && Vars::$options['show_share_dropdown']==1): ?>
<a href="http://addthis.com/bookmark.php?v=250" class="addthis_button_compact">Share</a>
<span class="addthis_separator"> </span>
<?php endif; ?>
<?php if ( isset(Vars::$options['facebook']) && Vars::$options['facebook']==1): ?>
<a class="addthis_button_facebook"></a>
<?php endif; ?>
<?php if ( isset(Vars::$options['twitter']) && Vars::$options['twitter']==1): ?>
<a class="addthis_button_twitter"></a>
<?php endif; ?>
<?php if ( isset(Vars::$options['googlebuzz']) && Vars::$options['googlebuzz']==1): ?>
<a class="addthis_button_googlebuzz"></a>
<?php endif; ?>
<?php if ( isset(Vars::$options['email']) && Vars::$options['email']==1): ?>
<a class="addthis_button_email"></a>
<?php endif; ?>
<?php if ( isset(Vars::$options['print_button']) && Vars::$options['print_button']==1): ?>
<a class="addthis_button_print"></a>
<?php endif; ?>
<?php if ( isset(Vars::$options['myspace']) && Vars::$options['myspace']==1): ?>
<a class="addthis_button_myspace"></a>
<?php endif; ?>
<?php if ( isset(Vars::$options['digg']) && Vars::$options['digg']==1): ?>
<a class="addthis_button_digg"></a>
<?php endif; ?>
<?php if ( isset(Vars::$options['stumble_upon']) && Vars::$options['stumble_upon']==1): ?>
<a class="addthis_button_stumbleupon"></a>
<?php endif; ?>
<?php if ( isset(Vars::$options['facebook_like']) && Vars::$options['facebook_like']==1): ?>
<span class="addthis_separator"> </span>
<a class="addthis_button_facebook_like"></a>
<?php endif; ?>
</div>
\ No newline at end of file
<?php
use Tz\WordPress\Tools\ShortCodes;
namespace Tz\WordPress\Tools\HybridGallery;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\ShortCodes as SC;
//error_reporting(E_ALL);
......@@ -15,48 +17,50 @@ Author URI: http://www.gotenzing.com/
class HybridGallery {
public static $defaults;
public static $WP_Settings;
public static $widget_dir;
public static $upload_dir;
const SETTINGS_NS = 'hybridgallery';
const ADMIN_PAGE = 'hybridgallery-settings';
const CAPABILITY = 'hybridgallery_admin';
const SETTINGS_NS = 'hybridgallery';
const ADMIN_PAGE = 'hybridgallery-settings';
const CAPABILITY = 'hybridgallery_admin';
public static function cInit() {
$role = get_role('administrator');
$role->add_cap(self::CAPABILITY);
$role->add_cap(CAPABILITY);
self::$widget_dir = Tools\url('./', __FILE__);
self::$upload_dir = __DIR__.'/uploads/';
Vars::$widget_dir = Tools\url('./', __FILE__);
Vars::$upload_dir = __DIR__.'/uploads/';
require('inc/config.php');
self::$defaults = $config;
Vars::$defaults = $config;
unset($config);
$mArr = array();
foreach(self::$defaults as $option => $items) {
foreach(Vars::$defaults as $option => $items) {
$mArr[$option] = $items[0];
}
self::$WP_Settings = new \WP_Option(self::SETTINGS_NS, $mArr);
Vars::$WP_Settings = new Tools\WP_Option(SETTINGS_NS, $mArr);
ShortCodes\registerClass('HybridGallery_ShortCodes');
Tools\add_actions('HybridGallery_Actions');
}
SC\registerClass(__NAMESPACE__ . '\ShortCodes');
Tools\add_actions(__NAMESPACE__ . '\Actions');
function adminDisplay() {
$defaults = Vars::$defaults;
require(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'settings.php');
}
public static function adminDisplay() {
$defaults = self::$defaults;
require(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'settings.php');
}
class Vars {
public static $defaults;
public static $WP_Settings;
public static $widget_dir;
public static $upload_dir;
}
class HybridGallery_Actions {
class Actions {
public static function init() {
......@@ -91,11 +95,11 @@ class HybridGallery_Actions {
}
public static function admin_menu() {
add_options_page('HybridGallery Settings', 'HybridGallery Settings', HybridGallery::CAPABILITY, HybridGallery::ADMIN_PAGE, Array('HybridGallery', 'adminDisplay'));
add_options_page('HybridGallery Settings', 'HybridGallery Settings', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\adminDisplay');
}
public static function admin_init() {
register_setting(HybridGallery::SETTINGS_NS, HybridGallery::SETTINGS_NS);
register_setting(SETTINGS_NS, SETTINGS_NS);
}
public static function wp_print_scripts() {
......@@ -107,15 +111,15 @@ class HybridGallery_Actions {
}
class HybridGallery_ShortCodes {
class ShortCodes {
public static $defaults;
public static function HybridGallery($args = array(), $content, $tag) {
$WP_Settings = new \WP_Option(HybridGallery::SETTINGS_NS);
$WP_Settings = new Tools\WP_Option(SETTINGS_NS);
foreach (HybridGallery::$defaults as $key => $val) {
foreach (Vars::$defaults as $key => $val) {
if (isset($WP_Settings[$key])) {
self::$defaults[$key] = $WP_Settings[$key];
}
......@@ -133,6 +137,5 @@ class HybridGallery_ShortCodes {
}
HybridGallery::cInit();
?>
\ No newline at end of file
......
/*
START OF STATIC
*/
body, html {
margin:0px;
padding:0px;
height:100%;
}
body {
font: 12px/160% 'Trebuchet MS', Verdana, Arial, sans-serif;
color:#4D4D4D;
}
h1 {
color:#777;
margin: 0px 0 20px 0;
font-family: 'Tangerine', serif;
font-size: 48px;
text-shadow: 4px 4px 4px #aaa;
font-weight: normal;
}
h2 {
color:#777;
background-color: transparent;
font: normal 26px Georgia, Times, 'Times New Roman', serif;
margin: 0px 0 5px 0;
}
h3 {
color:#777;
background-color: transparent;
font: normal 20px Georgia, Times, 'Times New Roman', serif;
margin: 25px 0 5px 0;
}
h4 {
color:#777;
background-color: transparent;
font: normal 16px Georgia, Times, 'Times New Roman', serif;
margin: 0px 0 10px 0;
}
h5 {
color:#777;
background-color: transparent;
font: normal 16px Georgia, Times, 'Times New Roman', serif;
margin: 10px 0 5px 0;
}
hr { border:0; background-color: rgb(225,225,225); height:1px; margin: 5px 0px 10px 0px; clear: both; }
......
<?php
//namespace Tz\WordPress\Tools\HybridGallery;
error_reporting(E_ALL ^ E_DEPRECATED);
//use Tz\WordPress\Tools;
require_once("../../../../../wp-config.php");
Tz_import('Zend', '1.9');
Tz\import('Zend', '1.9');
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_HttpClient');
Zend_Loader::loadClass('Zend_Gdata_YouTube');
......
<?php
namespace Tz\WordPress\Tools\HybridGallery;
?>
<div id="ChatterBox_AdminContainer" class="wrap">
<?php screen_icon(); ?>
<h2>Hybrid Gallery Settings</h2>
......@@ -5,7 +9,7 @@
<form method="post" action="options.php">
<?php
settings_fields(HybridGallery::SETTINGS_NS);
settings_fields(SETTINGS_NS);
?>
......@@ -20,13 +24,13 @@
</thead>
<tbody>
<?php foreach($defaults as $option=>$item):
$wp_option = HybridGallery::SETTINGS_NS . '[' . $option . ']';
$wp_option = SETTINGS_NS . '[' . $option . ']';
?>
<tr>
<td><strong><?php echo $option; ?></strong></td>
<td><?php echo $item[1]; ?><br /><span style="color:#999;"><?php echo ($item[2]=="optional") ? "(optional)" : "(required)"; ?></span> <?php if($item[3]):?><strong>Shortcode Usage:</strong> [HybridGallery <?php echo $option; ?>="<?php echo $item[0]; ?>"]<?php endif;?></td>
<td><?php echo $item[0]; ?></td>
<td><input type="text" name="<?php echo $wp_option; ?>" value="<?php echo self::$WP_Settings[$option]; ?>" style="width:120px;" /></td>
<td><input type="text" name="<?php echo $wp_option; ?>" value="<?php echo Vars::$WP_Settings[$option]; ?>" style="width:120px;" /></td>
</tr>
<?php endforeach; ?>
</tbody>
......
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Tangerine" />
<link rel="stylesheet" href="<?php echo TzTools::tools_url('../assets/css/hybrid.gallery.css', __FILE__); ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo TzTools::tools_url('../assets/uploadify/uploadify.css', __FILE__); ?>" type="text/css" />
<script type="text/javascript">var global_settings = <?php echo json_encode(self::$defaults); ?>; var widget_dir = '<?php echo HybridGallery::$widget_dir.'/'; ?>'; var upload_dir = '<?php echo HybridGallery::$upload_dir;?>';</script>
<script type="text/javascript" src="<?php echo TzTools::tools_url('../assets/scripts/hybrid.gallery.js', __FILE__); ?>"></script>
<?php
namespace Tz\WordPress\Tools\HybridGallery;
use Tz\WordPress\Tools;
?>
<link rel="stylesheet" href="<?php echo Tools\url('../assets/css/hybrid.gallery.css', __FILE__); ?>" type="text/css" />
<link rel="stylesheet" href="<?php echo Tools\url('../assets/uploadify/uploadify.css', __FILE__); ?>" type="text/css" />
<script type="text/javascript">var global_settings = <?php echo json_encode(self::$defaults); ?>; var widget_dir = '<?php echo Vars::$widget_dir.'/'; ?>'; var upload_dir = '<?php echo Vars::$upload_dir;?>';</script>
<script type="text/javascript" src="<?php echo Tools\url('../assets/scripts/hybrid.gallery.js', __FILE__); ?>"></script>
<div id="TzHybridGallery">
......