c3256182 by Kevin Burton

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

1 parent c320c4d5
1 <?php
2 /*
3 Plugin Name: Add This + Facebook Like
4 */
5
6 namespace Tz\WordPress\Tools\AddThis;
7 use Tz\WordPress\Tools;
8
9 const OPTION_NAME = "addthis_pl";
10
11 call_user_func(function() {
12 Vars::$options = new Tools\WP_Option(OPTION_NAME);
13
14 Tools\add_shortcodes(__NAMESPACE__ . '\ShortCodes');
15
16 if (is_admin()) {
17 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'Settings.php');
18 }
19
20 });
21
22 class ShortCodes {
23 public static function addthis() {
24 ob_start();
25 include('views/view.php');
26 $output = ob_get_contents();
27 ob_end_clean();
28 return $output;
29 }
30 }
31
32 class Vars {
33 /**
34 * WordPress option for this module
35 * @type WP_Option
36 */
37 public static $options;
38 }
39
40 ?>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\AddThis\Settings;
3
4 use Tz\Common;
5 use Tz\WordPress\Tools;
6 use Tz\WordPress\Tools\AddThis;
7
8 const OPTION_GROUP = 'addthis_group'; // Grouping of options used for setting output by WP
9 const OPTION_SECTION = 'tz_addthis_main';
10 const ADMIN_PAGE = 'tz-tools-addthis'; // URI of options page
11 const CAPABILITY = 'manage_addthis_params'; // User & Roles capability name
12
13 call_user_func(function() {
14 $role = get_role('administrator');
15 $role->add_cap(CAPABILITY);
16
17 Tools\add_actions(__NAMESPACE__ . '\Actions');
18 });
19
20 function displayPage() {
21 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views/Settings.php');
22 }
23
24 function validate($data) {
25 return $data;
26 }
27
28 /**
29 * @uses Tools\add_actions
30 */
31 class Actions {
32 /**
33 * Creates a settings page for the WP admin
34 */
35 public static function admin_menu() {
36 add_options_page('AddThis', 'AddThis', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\displayPage');
37 }
38
39 /**
40 * Generates variables for the module's options
41 */
42 public static function admin_init() {
43 register_setting(OPTION_GROUP, AddThis\OPTION_NAME, __NAMESPACE__ . '\validate');
44 add_settings_section(OPTION_SECTION, 'AddThis Default Expanded Settings', function(){}, ADMIN_PAGE);
45
46 Tools\add_settings_fields(__NAMESPACE__ . '\Fields', ADMIN_PAGE, OPTION_SECTION);
47 }
48 }
49
50 /**
51 * Each function is a variable stored in the WP_Option
52 * @uses Tools\add_settings_fields
53 */
54 class Fields {
55
56
57 public static function use_32px_icons() {
58 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
59 }
60
61
62 public static function show_share_dropdown() {
63 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
64 }
65
66 public static function facebook() {
67 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
68 }
69
70 public static function twitter() {
71 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
72 }
73
74 public static function googlebuzz() {
75 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
76 }
77
78 public static function print_button() {
79 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
80 }
81
82 public static function email() {
83 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
84 }
85
86 public static function facebook_like() {
87 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
88 }
89
90 public static function myspace() {
91 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
92 }
93
94 public static function digg() {
95 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
96 }
97
98 public static function stumble_upon() {
99 echo '<input type="checkbox" id="' . __FUNCTION__ . '" name="' . AddThis\OPTION_NAME . '[' . __FUNCTION__ . ']" value="1" ' . checked('1', AddThis\Vars::$options[__FUNCTION__], false) . ' />';
100 }
101
102 }
103
104
105
106 ?>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\AddThis\Settings;
3 ?>
4 <div class="wrap">
5 <?php screen_icon(); ?>
6 <h2>AddThis Settings</h2>
7
8 <form method="post" action="options.php">
9 <?php
10 settings_fields(OPTION_GROUP);
11 do_settings_sections(ADMIN_PAGE);
12 ?>
13 <p class="submit"><input type="submit" class="button-primary" value="Save Changes" /></p>
14 </form>
15 </div>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 namespace Tz\WordPress\Tools\AddThis;
3
4 ?>
5 <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js"></script>
6 <div class="addthis_toolbox <?php echo isset(Vars::$options['use_32px_icons']) ? "addthis_32x32_style" : ""; ?> addthis_default_style">
7
8 <?php if ( isset(Vars::$options['show_share_dropdown']) && Vars::$options['show_share_dropdown']==1): ?>
9 <a href="http://addthis.com/bookmark.php?v=250" class="addthis_button_compact">Share</a>
10 <span class="addthis_separator"> </span>
11 <?php endif; ?>
12
13 <?php if ( isset(Vars::$options['facebook']) && Vars::$options['facebook']==1): ?>
14 <a class="addthis_button_facebook"></a>
15 <?php endif; ?>
16
17 <?php if ( isset(Vars::$options['twitter']) && Vars::$options['twitter']==1): ?>
18 <a class="addthis_button_twitter"></a>
19 <?php endif; ?>
20
21 <?php if ( isset(Vars::$options['googlebuzz']) && Vars::$options['googlebuzz']==1): ?>
22 <a class="addthis_button_googlebuzz"></a>
23 <?php endif; ?>
24
25 <?php if ( isset(Vars::$options['email']) && Vars::$options['email']==1): ?>
26 <a class="addthis_button_email"></a>
27 <?php endif; ?>
28
29 <?php if ( isset(Vars::$options['print_button']) && Vars::$options['print_button']==1): ?>
30 <a class="addthis_button_print"></a>
31 <?php endif; ?>
32
33 <?php if ( isset(Vars::$options['myspace']) && Vars::$options['myspace']==1): ?>
34 <a class="addthis_button_myspace"></a>
35 <?php endif; ?>
36
37 <?php if ( isset(Vars::$options['digg']) && Vars::$options['digg']==1): ?>
38 <a class="addthis_button_digg"></a>
39 <?php endif; ?>
40
41 <?php if ( isset(Vars::$options['stumble_upon']) && Vars::$options['stumble_upon']==1): ?>
42 <a class="addthis_button_stumbleupon"></a>
43 <?php endif; ?>
44
45
46
47 <?php if ( isset(Vars::$options['facebook_like']) && Vars::$options['facebook_like']==1): ?>
48 <span class="addthis_separator"> </span>
49 <a class="addthis_button_facebook_like"></a>
50 <?php endif; ?>
51
52
53
54 </div>
...\ No newline at end of file ...\ No newline at end of file
1 <?php 1 <?php
2 2
3 use Tz\WordPress\Tools\ShortCodes; 3 namespace Tz\WordPress\Tools\HybridGallery;
4
4 use Tz\WordPress\Tools; 5 use Tz\WordPress\Tools;
6 use Tz\WordPress\Tools\ShortCodes as SC;
5 7
6 //error_reporting(E_ALL); 8 //error_reporting(E_ALL);
7 9
...@@ -15,48 +17,50 @@ Author URI: http://www.gotenzing.com/ ...@@ -15,48 +17,50 @@ Author URI: http://www.gotenzing.com/
15 17
16 18
17 19
18 class HybridGallery {
19 20
20 public static $defaults; 21
21 public static $WP_Settings;
22 public static $widget_dir;
23 public static $upload_dir;
24 22
23 const SETTINGS_NS = 'hybridgallery';
24 const ADMIN_PAGE = 'hybridgallery-settings';
25 const CAPABILITY = 'hybridgallery_admin';
25 26
26 const SETTINGS_NS = 'hybridgallery'; 27
27 const ADMIN_PAGE = 'hybridgallery-settings'; 28 $role = get_role('administrator');
28 const CAPABILITY = 'hybridgallery_admin'; 29 $role->add_cap(CAPABILITY);
29 30
30 public static function cInit() { 31 Vars::$widget_dir = Tools\url('./', __FILE__);
31 $role = get_role('administrator'); 32 Vars::$upload_dir = __DIR__.'/uploads/';
32 $role->add_cap(self::CAPABILITY); 33
33 34 require('inc/config.php');
34 self::$widget_dir = Tools\url('./', __FILE__); 35 Vars::$defaults = $config;
35 self::$upload_dir = __DIR__.'/uploads/'; 36
36 37 unset($config);
37 require('inc/config.php');
38 self::$defaults = $config;
39
40
41 $mArr = array();
42 foreach(self::$defaults as $option => $items) {
43 $mArr[$option] = $items[0];
44 }
45
46 self::$WP_Settings = new \WP_Option(self::SETTINGS_NS, $mArr);
47
48 ShortCodes\registerClass('HybridGallery_ShortCodes');
49 Tools\add_actions('HybridGallery_Actions');
50 }
51 38
52 public static function adminDisplay() { 39 $mArr = array();
53 $defaults = self::$defaults; 40 foreach(Vars::$defaults as $option => $items) {
54 require(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'settings.php'); 41 $mArr[$option] = $items[0];
55 } 42 }
43
44 Vars::$WP_Settings = new Tools\WP_Option(SETTINGS_NS, $mArr);
45
46 SC\registerClass(__NAMESPACE__ . '\ShortCodes');
47 Tools\add_actions(__NAMESPACE__ . '\Actions');
48
49 function adminDisplay() {
50 $defaults = Vars::$defaults;
51 require(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . 'settings.php');
52 }
56 53
54
55 class Vars {
56 public static $defaults;
57 public static $WP_Settings;
58 public static $widget_dir;
59 public static $upload_dir;
57 } 60 }
58 61
59 class HybridGallery_Actions { 62
63 class Actions {
60 64
61 public static function init() { 65 public static function init() {
62 66
...@@ -91,11 +95,11 @@ class HybridGallery_Actions { ...@@ -91,11 +95,11 @@ class HybridGallery_Actions {
91 } 95 }
92 96
93 public static function admin_menu() { 97 public static function admin_menu() {
94 add_options_page('HybridGallery Settings', 'HybridGallery Settings', HybridGallery::CAPABILITY, HybridGallery::ADMIN_PAGE, Array('HybridGallery', 'adminDisplay')); 98 add_options_page('HybridGallery Settings', 'HybridGallery Settings', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\adminDisplay');
95 } 99 }
96 100
97 public static function admin_init() { 101 public static function admin_init() {
98 register_setting(HybridGallery::SETTINGS_NS, HybridGallery::SETTINGS_NS); 102 register_setting(SETTINGS_NS, SETTINGS_NS);
99 } 103 }
100 104
101 public static function wp_print_scripts() { 105 public static function wp_print_scripts() {
...@@ -107,15 +111,15 @@ class HybridGallery_Actions { ...@@ -107,15 +111,15 @@ class HybridGallery_Actions {
107 111
108 } 112 }
109 113
110 class HybridGallery_ShortCodes { 114 class ShortCodes {
111 115
112 public static $defaults; 116 public static $defaults;
113 117
114 public static function HybridGallery($args = array(), $content, $tag) { 118 public static function HybridGallery($args = array(), $content, $tag) {
115 119
116 $WP_Settings = new \WP_Option(HybridGallery::SETTINGS_NS); 120 $WP_Settings = new Tools\WP_Option(SETTINGS_NS);
117 121
118 foreach (HybridGallery::$defaults as $key => $val) { 122 foreach (Vars::$defaults as $key => $val) {
119 if (isset($WP_Settings[$key])) { 123 if (isset($WP_Settings[$key])) {
120 self::$defaults[$key] = $WP_Settings[$key]; 124 self::$defaults[$key] = $WP_Settings[$key];
121 } 125 }
...@@ -133,6 +137,5 @@ class HybridGallery_ShortCodes { ...@@ -133,6 +137,5 @@ class HybridGallery_ShortCodes {
133 137
134 } 138 }
135 139
136 HybridGallery::cInit();
137 140
138 ?> 141 ?>
...\ No newline at end of file ...\ No newline at end of file
......
1 /* 1 /*
2 START OF STATIC 2 START OF STATIC
3 */ 3 */
4 body, html {
5 margin:0px;
6 padding:0px;
7 height:100%;
8 }
9
10 body {
11 font: 12px/160% 'Trebuchet MS', Verdana, Arial, sans-serif;
12 color:#4D4D4D;
13 }
14
15 h1 {
16 color:#777;
17 margin: 0px 0 20px 0;
18 font-family: 'Tangerine', serif;
19 font-size: 48px;
20 text-shadow: 4px 4px 4px #aaa;
21 font-weight: normal;
22 }
23 h2 {
24 color:#777;
25 background-color: transparent;
26 font: normal 26px Georgia, Times, 'Times New Roman', serif;
27 margin: 0px 0 5px 0;
28 }
29 h3 {
30 color:#777;
31 background-color: transparent;
32 font: normal 20px Georgia, Times, 'Times New Roman', serif;
33 margin: 25px 0 5px 0;
34 }
35
36 h4 {
37 color:#777;
38 background-color: transparent;
39 font: normal 16px Georgia, Times, 'Times New Roman', serif;
40 margin: 0px 0 10px 0;
41 }
42
43 h5 {
44 color:#777;
45 background-color: transparent;
46 font: normal 16px Georgia, Times, 'Times New Roman', serif;
47 margin: 10px 0 5px 0;
48 }
49
50
51 4
52 hr { border:0; background-color: rgb(225,225,225); height:1px; margin: 5px 0px 10px 0px; clear: both; } 5 hr { border:0; background-color: rgb(225,225,225); height:1px; margin: 5px 0px 10px 0px; clear: both; }
53 6
......
1 <?php 1 <?php
2 //namespace Tz\WordPress\Tools\HybridGallery;
3
2 error_reporting(E_ALL ^ E_DEPRECATED); 4 error_reporting(E_ALL ^ E_DEPRECATED);
5 //use Tz\WordPress\Tools;
6
7
8
3 require_once("../../../../../wp-config.php"); 9 require_once("../../../../../wp-config.php");
4 10
5 Tz_import('Zend', '1.9'); 11 Tz\import('Zend', '1.9');
6 require_once 'Zend/Loader.php'; 12 require_once 'Zend/Loader.php';
7 Zend_Loader::loadClass('Zend_Gdata_HttpClient'); 13 Zend_Loader::loadClass('Zend_Gdata_HttpClient');
8 Zend_Loader::loadClass('Zend_Gdata_YouTube'); 14 Zend_Loader::loadClass('Zend_Gdata_YouTube');
......
1 <?php
2 namespace Tz\WordPress\Tools\HybridGallery;
3 ?>
4
1 <div id="ChatterBox_AdminContainer" class="wrap"> 5 <div id="ChatterBox_AdminContainer" class="wrap">
2 <?php screen_icon(); ?> 6 <?php screen_icon(); ?>
3 <h2>Hybrid Gallery Settings</h2> 7 <h2>Hybrid Gallery Settings</h2>
...@@ -5,7 +9,7 @@ ...@@ -5,7 +9,7 @@
5 <form method="post" action="options.php"> 9 <form method="post" action="options.php">
6 10
7 <?php 11 <?php
8 settings_fields(HybridGallery::SETTINGS_NS); 12 settings_fields(SETTINGS_NS);
9 ?> 13 ?>
10 14
11 15
...@@ -20,13 +24,13 @@ ...@@ -20,13 +24,13 @@
20 </thead> 24 </thead>
21 <tbody> 25 <tbody>
22 <?php foreach($defaults as $option=>$item): 26 <?php foreach($defaults as $option=>$item):
23 $wp_option = HybridGallery::SETTINGS_NS . '[' . $option . ']'; 27 $wp_option = SETTINGS_NS . '[' . $option . ']';
24 ?> 28 ?>
25 <tr> 29 <tr>
26 <td><strong><?php echo $option; ?></strong></td> 30 <td><strong><?php echo $option; ?></strong></td>
27 <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> 31 <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>
28 <td><?php echo $item[0]; ?></td> 32 <td><?php echo $item[0]; ?></td>
29 <td><input type="text" name="<?php echo $wp_option; ?>" value="<?php echo self::$WP_Settings[$option]; ?>" style="width:120px;" /></td> 33 <td><input type="text" name="<?php echo $wp_option; ?>" value="<?php echo Vars::$WP_Settings[$option]; ?>" style="width:120px;" /></td>
30 </tr> 34 </tr>
31 <?php endforeach; ?> 35 <?php endforeach; ?>
32 </tbody> 36 </tbody>
......
1 <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Tangerine" /> 1 <?php
2 <link rel="stylesheet" href="<?php echo TzTools::tools_url('../assets/css/hybrid.gallery.css', __FILE__); ?>" type="text/css" /> 2 namespace Tz\WordPress\Tools\HybridGallery;
3 <link rel="stylesheet" href="<?php echo TzTools::tools_url('../assets/uploadify/uploadify.css', __FILE__); ?>" type="text/css" /> 3
4 <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> 4 use Tz\WordPress\Tools;
5 <script type="text/javascript" src="<?php echo TzTools::tools_url('../assets/scripts/hybrid.gallery.js', __FILE__); ?>"></script> 5 ?>
6 <link rel="stylesheet" href="<?php echo Tools\url('../assets/css/hybrid.gallery.css', __FILE__); ?>" type="text/css" />
7 <link rel="stylesheet" href="<?php echo Tools\url('../assets/uploadify/uploadify.css', __FILE__); ?>" type="text/css" />
8 <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>
9 <script type="text/javascript" src="<?php echo Tools\url('../assets/scripts/hybrid.gallery.js', __FILE__); ?>"></script>
6 10
7 <div id="TzHybridGallery"> 11 <div id="TzHybridGallery">
8 12
......