Plugin Directory

Changeset 1359834


Ignore:
Timestamp:
02/27/2016 08:12:47 PM (10 years ago)
Author:
WebTechGlobal
Message:

Sidebar data moved from main global settings array to a new option.

Location:
wtg-portal-manager/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wtg-portal-manager/trunk/classes/class-install.php

    r1267909 r1359834  
    271271        // notifications array (persistent notice feature)
    272272        add_option( 'wtgportalmanager_notifications', serialize( array() ) );
     273       
     274        // Sidebars Array
     275        add_option( 'wtgportalmanager_sidebars', array(), false );
    273276    }
    274277   
  • wtg-portal-manager/trunk/classes/class-requests.php

    r1359302 r1359834  
    779779    */
    780780    public function createsidebar() {
    781         global $wtgportalmanager_settings;
    782         $wtgportalmanager_settings['sidebars'][] = $_POST['newsidebarname'];
    783         $this->WTGPORTALMANAGER->update_settings( $wtgportalmanager_settings );   
    784         $this->UI->create_notice( __( "A new sidebar has been stored in this plugins options (WP currently offers no alternative solution). As a result the new sidebar will only be available while this plugin is active.", 'wtgportalmanager' ), 'success', 'Small', __( 'Sidebar Registered', 'wtgportalmanager' ) );
     781       
     782        // Install sidebars option. This can be removed after March 2016.
     783        if( !is_array( get_option( 'wtgportalmanager_sidebars' ) ) ) {
     784            add_option( 'wtgportalmanager_sidebars', array(), false );   
     785        }   
     786                         
     787        $this->WTGPORTALMANAGER->insert_sidebar( $_POST['newsidebarname'] );
     788           
     789        $this->UI->create_notice(
     790            __( "A new sidebar has been stored in this plugins
     791            options (WP currently offers no alternative solution). As a result the new
     792            sidebar will only be available while this plugin is active.", 'wtgportalmanager' ),
     793            'success',
     794            'Small',
     795            __( 'Sidebar Registered', 'wtgportalmanager' )
     796        );
    785797    }
    786798   
     
    852864    */
    853865    public function setupportaltwitter() {
     866        global $wtgportalmanager_settings;
    854867       
    855868        // Allow use of the Twitter API globally.
     
    944957    * @package WTG Portal Manager
    945958    * @since 0.0.1
    946     * @version 1.1
    947     */
    948     public function selectupdatesources() {
    949         global $wtgportalmanager_settings;       
     959    * @version 1.2
     960    */
     961    public function selectupdatesources() {       
    950962        $this->DB->update_project_meta( WTGPORTALMANAGER_PROJECT_ID, 'updatepagesources', $_POST['informationsources'] );
    951963        $this->UI->create_notice( __( "Sources of information for your Updates page were saved. You should check your current portals Updates page and ensure it is displaying what you expect.", 'wtgportalmanager' ), 'success', 'Small', __( 'Update Sources Saved', 'wtgportalmanager' ) );                               
     
    959971    * @package WTG Portal Manager
    960972    * @since 0.0.1
    961     * @version 1.1
    962     */
    963     public function selectactivitysources() {
    964         global $wtgportalmanager_settings;       
     973    * @version 1.2
     974    */
     975    public function selectactivitysources() {       
    965976        $this->DB->update_project_meta( WTGPORTALMANAGER_PROJECT_ID, 'activitypagesources', $_POST['informationsources'] );
    966         $this->UI->create_notice( __( "Sources of information for your Activity page were saved. You should check your current portals Updates page and ensure it is displaying what you expect.", 'wtgportalmanager' ), 'success', 'Small', __( 'Activity Sources Saved', 'wtgportalmanager' ) );                               
     977        $this->UI->create_notice(
     978            __( "Sources of information for your Activity page were saved. You should
     979            check your current portals Updates page and ensure it is displaying what you expect.", 'wtgportalmanager' ),
     980            'success',
     981            'Small',
     982            __( 'Activity Sources Saved', 'wtgportalmanager' )
     983        );                               
    967984    }
    968985
  • wtg-portal-manager/trunk/classes/class-wtgportalmanager.php

    r1359302 r1359834  
    713713        }       
    714714    }
    715        
    716     /**
    717     * Register sidebars created by WTG Plugin Manager
    718     *
    719     * @author Ryan R. Bayne
    720     * @package WTG Portal Manager
    721     * @since 0.0.1
    722     * @version 1.0
    723     */
    724     public function register_sidebars() {
    725         global $wtgportalmanager_settings, $wp_registered_sidebars;
    726            
    727         // sidebars that are always required - themes only
    728         /*
    729         for ($i = 1; $i <= 4; $i++)
    730         {
    731             register_sidebar(array(
    732                 'name' => __('Footer area','mfn-opts') .' #'.$i,
    733                 'id' => 'footer-area-'.$i,
    734                 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    735                 'after_widget' => '</aside>',
    736                 'before_title' => '<h4>',
    737                 'after_title' => '</h4>',
    738             ));
    739         }
    740         */
    741        
    742         // users custom sidebars
    743         if( isset( $wtgportalmanager_settings['sidebars'] ) && is_array( $wtgportalmanager_settings['sidebars'] ) )
    744         {
    745             foreach ( $wtgportalmanager_settings['sidebars'] as $sidebar )
    746             {   
    747                 register_sidebar( array (
    748                     'name' => $sidebar,
    749                     'id' => 'sidebar-'. str_replace("+", "-", urlencode(strtolower($sidebar))) ,
    750                     'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    751                     'after_widget' => '</aside>',
    752                     'before_title' => '<h3>',
    753                     'after_title' => '</h3>',
    754                 ));
    755             }   
    756         }
    757     }
    758                
     715               
    759716    /**
    760717    * register admin only .css must be done before printing styles
     
    31133070   
    31143071    /**
    3115     * Gets array of custom sidebars registered using this plugin with ID as key.
    3116     *
    3117     * Does not include all WP registered sidebars.
    3118     *
    3119     * @author Ryan R. Bayne
    3120     * @package WTG Portal Manager
    3121     * @since 0.0.1
    3122     * @version 1.1
    3123     */
    3124     public function get_sidebars( $scope = 'all' ) {
    3125         global $wtgportalmanager_settings;
    3126 
    3127         // get custom sidebar names and ID's
    3128         $array_of_sidebars = array();
    3129         if( isset( $wtgportalmanager_settings['sidebars'] ) )
    3130         {
    3131             foreach( $wtgportalmanager_settings['sidebars'] as $sidebar ) {
    3132                 $sidebar_id = 'sidebar-'. str_replace("+", "-", urlencode(strtolower($sidebar)));
    3133                 $array_of_sidebars[ $sidebar_id ] = $sidebar;   
    3134             }
    3135         }       
    3136        
    3137         return $array_of_sidebars;
    3138     }
    3139    
    3140     /**
    3141     * Get sidebars that have been linked with the giving portal
    3142     *
    3143     * @author Ryan R. Bayne
    3144     * @package WTG Portal Manager
    3145     * @since 0.0.1
    3146     * @version 1.0
    3147     */
    3148     public function get_portal_sidebars( $project_id ) {
    3149    
    3150     }
    3151    
    3152     /**
    31533072    * Updates entry in portal meta table.
    31543073    *
     
    34583377    * Saves sidebar to WTG Portal Manager settings. They are registered on init.
    34593378    *
    3460     * @author Ryan R. Bayne
    3461     * @package REPLACEPACKAGE
     3379    * Only add the sidebar name and get the array key for the new sidebar array.
     3380    *
     3381    * @author Ryan R. Bayne
     3382    * @package WebTechGlobal WordPress Plugins
    34623383    * @since 0.0.1
    34633384    * @version 1.0
    3464     */
    3465     public function insert_sidebar( $sidebar_name ) {
    3466         global $wtgportalmanager_settings;
    3467         $wtgportalmanager_settings['sidebars'][] = $sidebar_name;
    3468         return self::update_settings( $wtgportalmanager_settings );   
    3469     }
    3470    
     3385    *
     3386    * @todo 1 This function is expected to return a sidebar ID - does it really need to?
     3387    */
     3388    public function insert_sidebar( $sidebar_name ) {   
     3389        $sidebars_array = get_option( 'wtgportalmanager_sidebars' );
     3390        $sidebars_array['createdsidebars'][] = $sidebar_name;
     3391        update_option( 'wtgportalmanager_sidebars', $sidebars_array, false );   
     3392    }
     3393   
     3394    /**
     3395    * Register sidebars created by WTG Plugin Manager.
     3396    *
     3397    * @author Ryan R. Bayne
     3398    * @package WTG Portal Manager
     3399    * @since 0.0.1
     3400    * @version 1.2
     3401    */
     3402    public function register_sidebars() {
     3403
     3404        // sidebars that are always required - themes only
     3405        /*
     3406        for ($i = 1; $i <= 4; $i++)
     3407        {
     3408            register_sidebar(array(
     3409                'name' => __('Footer area','mfn-opts') .' #'.$i,
     3410                'id' => 'footer-area-'.$i,
     3411                'before_widget' => '<aside id="%1$s" class="widget %2$s">',
     3412                'after_widget' => '</aside>',
     3413                'before_title' => '<h4>',
     3414                'after_title' => '</h4>',
     3415            ));
     3416        }
     3417        */
     3418       
     3419        // Get and register user created sidebars.
     3420        $sidebars_array = get_option( 'wtgportalmanager_sidebars' );
     3421       
     3422        // users custom sidebars
     3423        if( is_array( $sidebars_array ) && isset( $sidebars_array['createdsidebars'] ) && is_array( $sidebars_array['createdsidebars'] ) )
     3424        {
     3425            foreach ( $sidebars_array['createdsidebars'] as $sidebar )
     3426            {   
     3427                register_sidebar( array (
     3428                    'name' => $sidebar,
     3429                    'id' => 'sidebar-'. str_replace("+", "-", urlencode(strtolower($sidebar))) ,
     3430                    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
     3431                    'after_widget' => '</aside>',
     3432                    'before_title' => '<h3>',
     3433                    'after_title' => '</h3>',
     3434                ));
     3435            }   
     3436        }
     3437    }
     3438   
     3439    /**
     3440    * Gets array of custom sidebars registered using this plugin with ID as key.
     3441    * The key application makes the array easier to work with in many situations.
     3442    *
     3443    * Does not include all WP registered sidebars only this plugins.
     3444    * It may include other plugins sidebars in future if the option becomes shared.
     3445    * You will know this by the option name.
     3446    *
     3447    * @author Ryan R. Bayne
     3448    * @package WTG Portal Manager
     3449    * @since 0.0.1
     3450    * @version 1.2
     3451    */
     3452    public function get_sidebars( $scope = 'all' ) {
     3453        $array_of_sidebars = get_option( 'wtgportalmanager_sidebars' );
     3454       
     3455        if( is_array( $array_of_sidebars['createdsidebars'] ) )
     3456        {
     3457            foreach( $array_of_sidebars['createdsidebars'] as $sidebar ) {
     3458                $sidebar_id = 'sidebar-'. str_replace("+", "-", urlencode(strtolower($sidebar)));
     3459                $array_of_sidebars[ $sidebar_id ] = $sidebar;   
     3460            }
     3461        }       
     3462       
     3463        return $array_of_sidebars;
     3464    }
     3465   
     3466    /**
     3467    * Get sidebars that have been linked with the giving portal.
     3468    *
     3469    * @author Ryan R. Bayne
     3470    * @package WTG Portal Manager
     3471    * @since 0.0.1
     3472    * @version 1.0
     3473    */
     3474    public function get_portal_sidebars( $project_id ) {
     3475   
     3476    }
     3477                 
    34713478    /**
    34723479    * Get all capabilities and returns in array.
  • wtg-portal-manager/trunk/readme.txt

    r1359302 r1359834  
    9090
    9191== Changelog ==
     92= 1.0.4 = 
     93* Feature Changes   
     94    * None
     95* Technical Changes
     96    * User created sidebars are now stored in option "wtgportalmanager_sidebars".
     97* Work In Progress
     98    * Current Portal Selection menu on main page defaults to the first item.
     99    * Too many configuration values are being stored in the settings array. Starting with sidebars move them to individual options.
     100    * Serialize API credentials using key stored in plugin.
     101    * Need a way to delete values in a form and reset it.
     102    * Add functionality to the portal information in head of pages i.e. link to the portal, quick tools.
     103    * Allow more than one Twitter account to be used on Updates list.
     104    * Default values on Create Portal menus might be the cause of security warnings.
     105    * Developer widget - will include portal ID and functionality for quickly changing portal.
     106    * Setup a Trello account for this project.
     107
    92108= 1.0.3 = 
    93109* Feature Changes   
     
    99115* Work In Progress
    100116    * Current Portal Selection menu on main page defaults to the first item.
     117    * Too many configuration values are being stored in the settings array. Starting with sidebars move them to individual options.
    101118    * Serialize API credentials using key stored in plugin.
    102119    * Need a way to delete values in a form and reset it.
  • wtg-portal-manager/trunk/wtg-portal-manager.php

    r1359302 r1359834  
    22/*
    33Plugin Name: WTG Portal Manager Beta
    4 Version: 1.0.3
     4Version: 1.0.4
    55Plugin URI: http://www.webtechglobal.co.uk/
    66Description: Every service and product can have a portal on your WordPress site.
     
    4242
    4343// define constants, feel free to add some of your own...                             
    44 if(!defined( "WTGPORTALMANAGER_VERSION") ){define( "WTGPORTALMANAGER_VERSION", '1.0.3' );}
     44if(!defined( "WTGPORTALMANAGER_VERSION") ){define( "WTGPORTALMANAGER_VERSION", '1.0.4' );}
    4545if(!defined( "WTGPORTALMANAGER_NAME") ){define( "WTGPORTALMANAGER_NAME", 'WTG Portal Manager' );}
    4646if(!defined( "WTGPORTALMANAGER__FILE__") ){define( "WTGPORTALMANAGER__FILE__", __FILE__);}
Note: See TracChangeset for help on using the changeset viewer.