Plugin Directory

Changeset 1187234


Ignore:
Timestamp:
06/25/2015 12:47:01 AM (11 years ago)
Author:
latorante
Message:

Updating to version 2.9.0.5

Location:
genoo/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • genoo/trunk/GenooInit.php

    r1178698 r1187234  
    1010 */
    1111
    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;
     12use Genoo\RepositorySettings;
     13use Genoo\RepositoryUser;
     14use Genoo\Api;
     15use Genoo\Cache;
     16use Genoo\Wordpress\Widgets;
     17use Genoo\Shortcodes;
     18use Genoo\Users;
     19use Genoo\Frontend;
     20use Genoo\Admin;
     21use Genoo\Wordpress\Action;
     22use Genoo\Wordpress\Ajax;
     23use Genoo\Wordpress\Debug;
     24use Genoo\Wordpress\Comments;
     25use Genoo\Wordpress\Cron;
    2626
    2727class Genoo
  • genoo/trunk/libs/Genoo/Frontend.php

    r1185913 r1187234  
    1212namespace Genoo;
    1313
    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;
     14use Genoo\RepositorySettings;
     15use Genoo\Wordpress\Utils;
     16use Genoo\Wordpress\Filter;
     17use Genoo\Wordpress\Action;
     18use Genoo\ModalWindow;
     19use Genoo\HtmlForm;
     20use Genoo\Wordpress\Widgets;
    2121use Genoo\Utils\Strings;
    2222use Genoo\Wordpress\Debug;
     
    107107        // Global post
    108108        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                    }
    130133                }
    131134            }
  • genoo/trunk/libs/Genoo/Wordpress/Attachment.php

    r1185913 r1187234  
    3434
    3535        $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
    3643        if(!is_null($img)){
    3744            $css->addRule('body #' . $id.  ' input')
     
    4653                ->add('max-width', '100%');
    4754        }
     55        // Image Hover
    4856        if(!is_null($imgHover)){
    4957            $css->addRule('body #' . $id . ' input:hover, ' . '#' . $id . ' input:focus, ' . '#' . $id . ' input:active')
     
    5563                ->add('max-width', '100%');
    5664        }
    57 
    5865        // clean up theme styles
    5966        $css->addRule('body #' . $id.  ' input')
  • genoo/trunk/libs/Genoo/Wordpress/Utils.php

    r1178729 r1187234  
    149149    public static function nonProtocolUrl($url)
    150150    {
     151        $http = self::isSecure() ? 'https://' : 'http://';
    151152        return str_replace(
    152153            array(
     
    155156            ),
    156157            array(
    157                 '//',
    158                 '//'
     158                $http,
     159                'https://'
    159160            ),
    160161            $url
    161162        );
    162163    }
     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    }
    163220}
  • genoo/trunk/libs/Genoo/Wordpress/Widgets.php

    r1185913 r1187234  
    1313
    1414use Genoo\Tracer;
    15 use Genoo\Utils\Strings,
    16     Genoo\Utils\ArrayObject,
    17     Genoo\Wordpress\Action,
    18     Genoo\WidgetCTADynamic,
    19     Genoo\CTA;
     15use Genoo\Utils\Strings;
     16use Genoo\Utils\ArrayObject;
     17use Genoo\Wordpress\Action;
     18use Genoo\Wordpress\Utils;
     19use Genoo\WidgetCTADynamic;
     20use Genoo\CTA;
    2021
    2122class Widgets
     
    227228        if(is_array($widgets) && !empty($widgets)){
    228229            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                                        }
    261265                                    }
    262266                                }
  • genoo/trunk/readme.txt

    r1185913 r1187234  
    66License: GPLv2 or later
    77License URI: http://www.gnu.org/licenses/gpl-2.0.html
    8 Stable tag: 2.9
     8Version: 2.9.0.5
    99
    1010Combine the flexibility of WordPress with the power of Genoo and experience amazing results!
Note: See TracChangeset for help on using the changeset viewer.