Changeset 1187234
- Timestamp:
- 06/25/2015 12:47:01 AM (11 years ago)
- Location:
- genoo/trunk
- Files:
-
- 6 edited
-
GenooInit.php (modified) (1 diff)
-
libs/Genoo/Frontend.php (modified) (2 diffs)
-
libs/Genoo/Wordpress/Attachment.php (modified) (3 diffs)
-
libs/Genoo/Wordpress/Utils.php (modified) (2 diffs)
-
libs/Genoo/Wordpress/Widgets.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
genoo/trunk/GenooInit.php
r1178698 r1187234 10 10 */ 11 11 12 use Genoo\RepositorySettings ,13 Genoo\RepositoryUser, 14 Genoo\Api, 15 Genoo\Cache, 16 Genoo\Wordpress\Widgets, 17 Genoo\Shortcodes, 18 Genoo\Users, 19 Genoo\Frontend, 20 Genoo\Admin, 21 Genoo\Wordpress\Action, 22 Genoo\Wordpress\Ajax, 23 Genoo\Wordpress\Debug, 24 Genoo\Wordpress\Comments, 25 Genoo\Wordpress\Cron;12 use Genoo\RepositorySettings; 13 use Genoo\RepositoryUser; 14 use Genoo\Api; 15 use Genoo\Cache; 16 use Genoo\Wordpress\Widgets; 17 use Genoo\Shortcodes; 18 use Genoo\Users; 19 use Genoo\Frontend; 20 use Genoo\Admin; 21 use Genoo\Wordpress\Action; 22 use Genoo\Wordpress\Ajax; 23 use Genoo\Wordpress\Debug; 24 use Genoo\Wordpress\Comments; 25 use Genoo\Wordpress\Cron; 26 26 27 27 class Genoo -
genoo/trunk/libs/Genoo/Frontend.php
r1185913 r1187234 12 12 namespace Genoo; 13 13 14 use Genoo\RepositorySettings ,15 Genoo\Wordpress\Utils, 16 Genoo\Wordpress\Filter, 17 Genoo\Wordpress\Action, 18 Genoo\ModalWindow, 19 Genoo\HtmlForm, 20 Genoo\Wordpress\Widgets;14 use Genoo\RepositorySettings; 15 use Genoo\Wordpress\Utils; 16 use Genoo\Wordpress\Filter; 17 use Genoo\Wordpress\Action; 18 use Genoo\ModalWindow; 19 use Genoo\HtmlForm; 20 use Genoo\Wordpress\Widgets; 21 21 use Genoo\Utils\Strings; 22 22 use Genoo\Wordpress\Debug; … … 107 107 // Global post 108 108 global $post; 109 // Do we have a post 110 if($post instanceof \WP_Post){ 111 // We only run this on single posts 112 if((Post::isSingle() || Post::isPage()) && Post::isPostType($post, $this->repositorySettings->getCTAPostTypes())){ 113 // Dynamic cta 114 $cta = new CTADynamic($post); 115 // If the post does have multiple ctas, continue 116 if($cta->hasMultiple()){ 117 // Set we have multiple CTAs 118 $this->hasMultipleCTAs = true; 119 // Get CTA's 120 $ctas = $cta->getCtas(); 121 $ctasRegister = $cta->getCtasRegister(); 122 // Injects widgets, registers them 123 $ctasWidgetsRegistered = Widgets::injectRegisterWidgets($ctasRegister); 124 // Save for footer print 125 $this->footerCTAModals = $ctasWidgetsRegistered; 126 // Repositions them 127 Widgets::injectMultipleIntoSidebar($ctasWidgetsRegistered); 128 // Pre-option values 129 Widgets::injectMultipleValues($ctasWidgetsRegistered); 109 // Firstly we do not run this anytime other then on real frontend 110 if(Utils::isSafeFrontend()){ 111 // Do we have a post 112 if($post instanceof \WP_Post){ 113 // We only run this on single posts 114 if((Post::isSingle() || Post::isPage()) && Post::isPostType($post, $this->repositorySettings->getCTAPostTypes())){ 115 // Dynamic cta 116 $cta = new CTADynamic($post); 117 // If the post does have multiple ctas, continue 118 if($cta->hasMultiple()){ 119 // Set we have multiple CTAs 120 $this->hasMultipleCTAs = true; 121 // Get CTA's 122 $ctas = $cta->getCtas(); 123 $ctasRegister = $cta->getCtasRegister(); 124 // Injects widgets, registers them 125 $ctasWidgetsRegistered = Widgets::injectRegisterWidgets($ctasRegister); 126 // Save for footer print 127 $this->footerCTAModals = $ctasWidgetsRegistered; 128 // Repositions them 129 Widgets::injectMultipleIntoSidebar($ctasWidgetsRegistered); 130 // Pre-option values 131 Widgets::injectMultipleValues($ctasWidgetsRegistered); 132 } 130 133 } 131 134 } -
genoo/trunk/libs/Genoo/Wordpress/Attachment.php
r1185913 r1187234 34 34 35 35 $css = new CSS(); 36 // Image preload for hover 37 if(!is_null($imgHover)){ 38 $css->addRule('body #' . $id. ' input:after') 39 ->add('content', 'url('. $srcHover[0] .')') 40 ->add('display', 'none !important'); 41 } 42 // Image 36 43 if(!is_null($img)){ 37 44 $css->addRule('body #' . $id. ' input') … … 46 53 ->add('max-width', '100%'); 47 54 } 55 // Image Hover 48 56 if(!is_null($imgHover)){ 49 57 $css->addRule('body #' . $id . ' input:hover, ' . '#' . $id . ' input:focus, ' . '#' . $id . ' input:active') … … 55 63 ->add('max-width', '100%'); 56 64 } 57 58 65 // clean up theme styles 59 66 $css->addRule('body #' . $id. ' input') -
genoo/trunk/libs/Genoo/Wordpress/Utils.php
r1178729 r1187234 149 149 public static function nonProtocolUrl($url) 150 150 { 151 $http = self::isSecure() ? 'https://' : 'http://'; 151 152 return str_replace( 152 153 array( … … 155 156 ), 156 157 array( 157 '//',158 ' //'158 $http, 159 'https://' 159 160 ), 160 161 $url 161 162 ); 162 163 } 164 165 /** 166 * @return bool 167 */ 168 public static function isSecure() 169 { 170 return 171 (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') 172 || $_SERVER['SERVER_PORT'] == 443; 173 } 174 175 176 /** 177 * Does what it says 178 * 179 * @param $array 180 * @return bool 181 */ 182 public static function definedAndFalse($array) 183 { 184 $r = $array; 185 if(is_array($r)){ 186 foreach($r as $constant){ 187 if (defined($constant) && constant($constant) == TRUE){ 188 return FALSE; 189 } 190 } 191 } 192 return TRUE; 193 } 194 195 /** 196 * @return bool 197 */ 198 public static function isSafeFrontend() 199 { 200 return self::definedAndFalse( 201 array( 202 'DOING_AJAX', 203 'DOING_AUTOSAVE', 204 'DOING_CRON', 205 'WP_ADMIN', 206 'WP_IMPORTING', 207 'WP_INSTALLING', 208 'WP_UNINSTALL_PLUGIN', 209 'IFRAME_REQUEST', 210 '#WP_INSTALLING_NETWORK', 211 'WP_NETWORK_ADMIN', 212 'WP_LOAD_IMPORTERS', 213 'WP_REPAIRING', 214 'WP_UNINSTALL_PLUGIN', 215 'WP_USER_ADMIN', 216 'XMLRPC_REQUEST' 217 ) 218 ); 219 } 163 220 } -
genoo/trunk/libs/Genoo/Wordpress/Widgets.php
r1185913 r1187234 13 13 14 14 use Genoo\Tracer; 15 use Genoo\Utils\Strings, 16 Genoo\Utils\ArrayObject, 17 Genoo\Wordpress\Action, 18 Genoo\WidgetCTADynamic, 19 Genoo\CTA; 15 use Genoo\Utils\Strings; 16 use Genoo\Utils\ArrayObject; 17 use Genoo\Wordpress\Action; 18 use Genoo\Wordpress\Utils; 19 use Genoo\WidgetCTADynamic; 20 use Genoo\CTA; 20 21 21 22 class Widgets … … 227 228 if(is_array($widgets) && !empty($widgets)){ 228 229 Filter::add('sidebars_widgets', function($sidebars) use ($widgets){ 229 // Go through sidebars 230 foreach($widgets as $sidebarKey => $widgetArray){ 231 // Sort array by position, only if array and positionable 232 if(is_array($widgetArray) && isset($widgetArray[0]->position)){ 233 usort($widgetArray, function($a, $b){ 234 return ($a->position == $b->position) 235 ? (($a->position < $b->position) ? -1 : 1) 236 : ($a->position - $b->position); 237 }); 238 } 239 // Each sidebar has an array of widgets, 240 // even one widget will be in an array 241 if(is_array($widgetArray) && !empty($widgetArray)){ 242 // Before going through widgets, removing instances of 243 // all dynamic CTA widgets, so we position them correctly 244 $sidebars[$sidebarKey] = ArrayObject::removeByValueLike($sidebars[$sidebarKey], 'genoodynamiccta'); 245 // Going through widgets 246 foreach($widgetArray as $widget){ 247 // If the sidebar they are assigned to exists, 248 // continue (if not, might have been removed, theme change etc.) 249 if(isset($sidebars[$sidebarKey])){ 250 // Check if it's not already there, because the widget "id" is unique 251 // it shouldn't be there more than once 252 if(!in_array($widget->widget, $sidebars[$sidebarKey])){ 253 // Positin wise setup 254 if($widget->position == -1){ // Last 255 $sidebars[$sidebarKey] = ArrayObject::appendToTheEnd($sidebars[$sidebarKey], $widget->widget); 256 } elseif ($widget->position == 1){ // First 257 $sidebars[$sidebarKey] = ArrayObject::prependToTheBeginning($sidebars[$sidebarKey], $widget->widget); 258 } else { // Other 259 $position = ($widget->position < 0) ? 0 : $widget->position - 1; 260 $sidebars[$sidebarKey] = ArrayObject::appendTo($sidebars[$sidebarKey], $position, $widget->widget); 230 // One last protection inside the filter (just a precaution) 231 if(Utils::isSafeFrontend()){ 232 // Go through sidebars 233 foreach($widgets as $sidebarKey => $widgetArray){ 234 // Sort array by position, only if array and positionable 235 if(is_array($widgetArray) && isset($widgetArray[0]->position)){ 236 usort($widgetArray, function($a, $b){ 237 return ($a->position == $b->position) 238 ? (($a->position < $b->position) ? -1 : 1) 239 : ($a->position - $b->position); 240 }); 241 } 242 // Each sidebar has an array of widgets, 243 // even one widget will be in an array 244 if(is_array($widgetArray) && !empty($widgetArray)){ 245 // Before going through widgets, removing instances of 246 // all dynamic CTA widgets, so we position them correctly 247 $sidebars[$sidebarKey] = ArrayObject::removeByValueLike($sidebars[$sidebarKey], 'genoodynamiccta'); 248 // Going through widgets 249 foreach($widgetArray as $widget){ 250 // If the sidebar they are assigned to exists, 251 // continue (if not, might have been removed, theme change etc.) 252 if(isset($sidebars[$sidebarKey])){ 253 // Check if it's not already there, because the widget "id" is unique 254 // it shouldn't be there more than once 255 if(!in_array($widget->widget, $sidebars[$sidebarKey])){ 256 // Positin wise setup 257 if($widget->position == -1){ // Last 258 $sidebars[$sidebarKey] = ArrayObject::appendToTheEnd($sidebars[$sidebarKey], $widget->widget); 259 } elseif ($widget->position == 1){ // First 260 $sidebars[$sidebarKey] = ArrayObject::prependToTheBeginning($sidebars[$sidebarKey], $widget->widget); 261 } else { // Other 262 $position = ($widget->position < 0) ? 0 : $widget->position - 1; 263 $sidebars[$sidebarKey] = ArrayObject::appendTo($sidebars[$sidebarKey], $position, $widget->widget); 264 } 261 265 } 262 266 } -
genoo/trunk/readme.txt
r1185913 r1187234 6 6 License: GPLv2 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.html 8 Stable tag: 2.9 8 Version: 2.9.0.5 9 9 10 10 Combine the flexibility of WordPress with the power of Genoo and experience amazing results!
Note: See TracChangeset
for help on using the changeset viewer.