Plugin Directory

Changeset 1436092


Ignore:
Timestamp:
06/13/2016 09:39:46 PM (10 years ago)
Author:
WebTechGlobal
Message:

Added Trello, Guzzle and oAuth1 libraries added. They will be used for Trello features but are not fully integrated yet.

Location:
multitool/trunk
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • multitool/trunk/classes/class-configuration.php

    r1431029 r1436092  
    7979            // WTG Cron main hourly job processes all scheduled actions.
    8080            array( 'init',                           array( 'multitool', 'webtechglobal_hourly_cron_function', 1 ),       'cron', null ),         
    81             // When admin logged in runs constantly.
    82             array( 'init',                           array( 'multitool', 'administrator_triggered_automation', 1 ),       'administrator', null ),         
    83 
     81            array( 'admin_init',                     array( 'multitool', 'administrator_triggered_automation', 1 ),       'administrator', null ),         
     82   
    8483            ################################################################
    8584            #                                                              #
  • multitool/trunk/classes/class-files.php

    r1173545 r1436092  
    9191        if ( $test_type ) {
    9292            $wp_filetype = wp_check_filetype( $file_array['name'], false );
     93           
     94            // TODO: remove use of extract() as it is depreciated
    9395            extract( $wp_filetype );
    9496           
  • multitool/trunk/classes/class-globalui.php

    r1428502 r1436092  
    6464    * @author Ryan R. Bayne
    6565    * @package WebTechGlobal WordPress Plugins
    66     * @version 1.0
     66    *
     67    * @version 1.5
    6768    */
    6869    function developer_toolbar_webtechglobaladmin() {
     
    113114                $args = array(
    114115                    'id'     => 'webtechglobal-toolbarmenu-postdisplay',
     116                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
     117                    'title'  => $title,
     118                    'href'   => $href,           
     119                );
     120               
     121                $wp_admin_bar->add_menu( $args );
     122                                             
     123                // Trace display.       
     124                $href = wp_nonce_url( admin_url() . 'admin.php?page=' . $_GET['page'] . '&multitoolaction=' . 'tracedisplay'  . '', 'tracedisplay' );
     125                $switch = MULTITOOL_Options::get_option( 'debugtracedisplay', false );
     126                if( $switch ){
     127                    $title = __( 'Hide Trace', 'multitool' );
     128                } else {
     129                    $title = __( 'Display Trace', 'multitool' );
     130                }
     131               
     132                $args = array(
     133                    'id'     => 'webtechglobal-toolbarmenu-tracedisplay',
     134                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
     135                    'title'  => $title,
     136                    'href'   => $href,           
     137                );
     138               
     139                $wp_admin_bar->add_menu( $args );
     140                                                             
     141                // Trace log.       
     142                $href = wp_nonce_url( admin_url() . 'admin.php?page=' . $_GET['page'] . '&multitoolaction=' . 'tracelog'  . '', 'tracelog' );
     143                $switch = MULTITOOL_Options::get_option( 'debugtracelog', false );
     144                if( $switch ){
     145                    $title = __( 'Start Trace Log', 'multitool' );
     146                } else {
     147                    $title = __( 'Stop Trace Log', 'multitool' );
     148                }
     149               
     150                $args = array(
     151                    'id'     => 'webtechglobal-toolbarmenu-tracelog',
    115152                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
    116153                    'title'  => $title,
  • multitool/trunk/classes/class-install.php

    r1428502 r1436092  
    1717
    1818class MULTITOOL_Install {
    19                 
     19         
    2020    /**
    2121    * Install __construct persistently registers database tables and is the
    2222    * first point to monitoring installation state
    2323    */
    24     public function __construct() {
     24    public function __construct() {     
    2525        // load class used at all times
    26         $this->DB = MULTITOOL::load_class( 'MULTITOOL_DB', 'class-wpdb.php', 'classes' );
     26        $this->DB = new MULTITOOL_DB();
    2727        $this->PHP = new MULTITOOL_PHP();             
    2828    }
     
    126126    function create_tables() {     
    127127        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );         
    128 var_dump(__FUNCTION__);
     128
    129129        self::webtechglobal_projects();
    130130        self::webtechglobal_projectsmeta();
  • multitool/trunk/classes/class-multitool.php

    r1431029 r1436092  
    5252           
    5353    /**
    54     * This class is being introduced gradually, we will move various lines and config functions from the main file to load here eventually
     54    * This class is being introduced gradually, we will move various
     55    * lines and config functions from the main file to load here eventually.
     56    *
     57    * @version 1.2
    5558    */
    5659    public function __construct() {
    5760        global $multitool_settings;
    5861             
    59         // TODO: can we add some of these objects to $MULTITOOL_Class for other classes to use.
    6062        $this->DB = self::load_class( 'MULTITOOL_DB', 'class-wpdb.php', 'classes' );
    6163        $this->PHP = self::load_class( 'MULTITOOL_PHP', 'class-phplibrary.php', 'classes' );
     
    7274        $this->FOOWIDGET = self::load_class( 'Foo_Widget', 'class-widgets.php', 'classes' );
    7375       
    74         // None WebTechGlobal Class
     76        // Load all none WebTechGlobal Class when required.
    7577        $this->TGM = MULTITOOL::load_class( 'TGM_Plugin_Activation', 'class-tgm-plugin-activation.php', 'classes' );
    76 
     78       
     79        // TODO: strictly not admin only settings, function needs renamed.
    7780        $multitool_settings = self::adminsettings();
    7881       
     
    8184        $this->add_filters(self::filters());
    8285
     86        // Admin only stuff.
    8387        if( is_admin() ){
    8488       
    85             // admin globals
     89            // Get the options array.
    8690            global $multitool_notice_array;
    87            
    88             $multitool_notice_array = array();// set notice array for storing new notices in (not persistent notices)
    89            
    90             // load class used from admin only                   
     91            $multitool_notice_array = MULTITOOL_Options::get_option( 'notifications' );
     92                 
    9193            $this->UI = self::load_class( 'MULTITOOL_UI', 'class-ui.php', 'classes' );
    9294            $this->Helparray = self::load_class( 'MULTITOOL_Help', 'class-help.php', 'classes' );       
     
    123125            return false;// User has not activated admin triggered automation. 
    124126        }
     127       
     128        // Get the time of the last admin triggered event, ensure 15 minute delay.
     129        $last_auto_time = get_option( 'webtechglobal_autoadmin_lasttime');
     130       
     131        // Might need to initiate the value.
     132        if( !$last_auto_time )
     133        {     
     134            update_option( 'webtechglobal_autoadmin_lasttime', time() );
     135            return;
     136        }
     137       
     138        $next_earliest_time = $last_auto_time + 900;
     139        if( $next_earliest_time > time() )
     140        {
     141           
     142            $message = sprintf( __( 'Administrator triggered automation did not run as it has
     143                        run within the last 15 minutes. The last time administration
     144                        automation was run was at %s and it cannot run again until %s or
     145                        later. The current time is %s', 'multitool' ),
     146                        date( "Y-m-d H:i:s", $last_auto_time ),
     147                        date( "Y-m-d H:i:s", $next_earliest_time ),
     148                        date( "Y-m-d H:i:s", time() )
     149            );
     150                       
     151            multitool_trace_primary(
     152                'admintrigauto',
     153                $message,
     154                array(),
     155                false,
     156                false,
     157                true
     158            );
     159           
     160            return false;// 15 minutes have not passed since the last event.
     161        }
     162       
     163        // Update the last auto admin time.
     164        update_option( 'webtechglobal_autoadmin_lasttime', time() );
    125165               
    126166        // Encorce maximum number of administration accounts.
     
    226266        wp_enqueue_script( 'jquery-ui-datepicker' );                           
    227267        wp_enqueue_script( 'jquery-ui-datetimepicker', plugins_url( 'multitool/js/datetimepicker/jquery.datetimepicker.full.min.js' ), __FILE__ ); 
     268       
     269        wp_enqueue_script( 'jquery' );
     270       
     271        // Trello
     272        $trello_key = 'c3edd889433c851194664930e6958e01';
     273        // TODO: only enqueue when Trello service activated.
     274
     275        wp_deregister_script('trello-client1');
     276        wp_register_script('trello-client1', "https://trello.com/1/client.js?key=$trello_key" );
     277        wp_enqueue_script('trello-client1');   
     278       
     279        wp_deregister_script('trello-userauth');
     280        wp_register_script('trello-userauth', plugins_url( 'multitool/js/trello/trellouserauth.js' ), 'Trello', false );
     281        wp_enqueue_script('trello-userauth');   
     282
    228283    }   
    229284
  • multitool/trunk/classes/class-options.php

    r1431029 r1436092  
    4141                'capabilities',             // (array) individual admin view capability requirements.
    4242                'adm_trig_auto',            // (bool) switch for administrator triggered automation.
    43                 'securityevent_admincap',   // (array) details about a security event related to maximum admin accounts.   
     43                'securityevent_admincap',   // (array) details about a security event related to maximum admin accounts. 
    4444            );                                                                                               
    45            
     45
     46                         
    4647        //Add security sensitive options here i.e. tokens, keys.
    4748        case 'private' :
     
    5455            'postdump', // (boolean) switch in Developer Menu for displaying $_POST.
    5556            'getdump', // (boolean) switch in Developer Menu for displaying $_GET.
     57            'debugtracedisplay',
     58            'debugtracelog'
    5659        );
    5760    }
     
    132135                        'webtechglobal_auto_lasttime'          => array( 1,0,1, time()   ),// (time()) The last time an automated event was run by WTG plugins.
    133136                        'webtechglobal_auto_actionssettings'   => array( 1,0,1, array()  ),// (array) User condfiguration for automated actions, overwriting defaults.             
     137                        'webtechglobal_autoadmin_lasttime'     => array( 1,1,1, time() ),// (array) The last time auto administration ran.
    134138                    ); 
    135139                   
     
    140144               
    141145                    $merged_options = array( 
    142                         'mergedexample'          => array( 'merged',0,0,0, array() ),// an example private option.
    143                         'postdump'               => array( 'merged',1,1,1, false ),// an example private option.
    144                         'getdump'                => array( 'merged',1,1,1, false ),// an example private option.
     146                        'postdump'               => array( 'merged',1,1,1, false ),// (boolean) Switch in Developer menu for displaying $_POST data.
     147                        'getdump'                => array( 'merged',1,1,1, false ),// (boolean) Switch in Developer menu for displaying $_GET dump.
     148                        'debugtracedisplay'      => array( 'merged',1,1,1, false ),// (boolean) Switch in Developer menu for displaying trace for the current page load.
     149                        'debugtracelog'          => array( 'merged',1,1,1, false ),// (boolean) Switch in Developer menu for logging trace for the current page load.
    145150                    );
    146151                   
     
    251256     * or multitool_$name as appropriate.
    252257     *
     258     * @version 1.2
    253259     * @param string $name Option name
    254260     * @param mixed $default (optional)
     
    259265     * error advising the developer to change the option name.
    260266     */
    261     public static function get_option( $name, $default = false ) {
    262        
     267    public static function get_option( $name, $default = false, $maybe_unserialize = true ) {
     268                                   
    263269        // First check if the requested option is a non_compact one.
    264270        if ( self::is_valid( $name, 'non_compact' ) ) {
    265             return get_option( "multitool_$name", $default );
     271            $option_value = get_option( "multitool_$name", $default );
     272            if( $maybe_unserialize )
     273            {
     274                return maybe_unserialize( $option_value );
     275            }
    266276        }
    267277
  • multitool/trunk/classes/class-pluginmenu.php

    r1420327 r1436092  
    419419        $menu_array['developercoretable']['parent'] = 'developersection';
    420420        $menu_array['developercoretable']['tabmenu'] = true;
     421         
     422        // wp core table example
     423        $menu_array['developertrello']['groupname'] = 'developertools';
     424        $menu_array['developertrello']['slug'] = 'multitool_developertrello';
     425        $menu_array['developertrello']['menu'] = __( 'Trello', 'multitool' );
     426        $menu_array['developertrello']['pluginmenu'] = __( 'Trello', 'multitool' );
     427        $menu_array['developertrello']['name'] = "developertrello";
     428        $menu_array['developertrello']['title'] = __( 'Trello', 'multitool' );
     429        $menu_array['developertrello']['parent'] = 'developersection';
     430        $menu_array['developertrello']['tabmenu'] = true;
    421431                                                                           
    422432        return $menu_array;
  • multitool/trunk/classes/class-requests.php

    r1428502 r1436092  
    14931493            $delay = $_POST['nextjobdelay'];   
    14941494        }
    1495        
    1496        
     1495
    14971496        $next_event_time = microtime( true ) + $delay;
    14981497       
     
    17661765        return;
    17671766    }   
     1767
     1768    /**
     1769    * Switch for Trace display which allows trace to be seen by administrators.
     1770    *
     1771    * @version 1.0
     1772    */
     1773    public function tracedisplay () {
     1774        $new = null;
     1775        $current = MULTITOOL_Options::get_option( 'debugtracedisplay' );
     1776        if( $current === true )
     1777        {
     1778            MULTITOOL_Options::update_option( 'debugtracedisplay', false );
     1779                $this->UI->create_notice(
     1780                    __( 'Trace display has been switched off and trace information will be hidden.
     1781                    This does not switch of trace logging which may still add entries to your server
     1782                    or WordPress log file.', 'multitool' ),
     1783                    'success',
     1784                    'Small',
     1785                    __( 'Now Hiding Trace', 'multitool' )
     1786                );
     1787        }
     1788        elseif( $current === false )
     1789        {       
     1790            MULTITOOL_Options::update_option( 'debugtracedisplay', true );
     1791            $this->UI->create_notice(
     1792                __( 'Trace display has been switched on and you will see information
     1793                for any traces that are included in each page load.', 'multitool' ),
     1794                'success',
     1795                'Small',
     1796                __( 'Now Displaying Trace', 'multitool' )
     1797            );   
     1798        }
     1799
     1800        return;
     1801    }
     1802   
     1803    /**
     1804    * Deletes redundant user meta "wp_capabilities" data which causes
     1805    * incorrect count of each role.
     1806    *
     1807    * @version 1.0
     1808    *
     1809    * @todo break this down into individual queries for each role so that
     1810    * the output explains more about what was deleted.
     1811    */
     1812    public function rolecountvalidation () {
     1813        global $wpdb;
     1814       
     1815        $total_meta_deleted = 0;
     1816       
     1817        $result = MULTITOOL_DB::selectwherearray(
     1818            $wpdb->usermeta,
     1819            'meta_key = "wp_capabilities"'
     1820        );
     1821       
     1822        foreach( $result as $key => $user )
     1823        {                           
     1824            // Avoid doing anything with accounts likely to be key holders.
     1825            if( $user['user_id'] < 3 )
     1826            {
     1827                continue;
     1828            }           
     1829           
     1830            // Get the expected user that may not actually exist anymore.
     1831            $got_user = get_user_by( 'user_id', $user['user_id'] );
     1832             
     1833            // If no user for the meta lets delete the meta - cleanup time!
     1834            if( !$got_user )
     1835            {                                       
     1836                delete_user_meta( $user['user_id'], 'wp_capabilities', $user['user_id'] );
     1837                ++$total_meta_deleted; 
     1838            }   
     1839        }
     1840       
     1841        $this->UI->create_notice(
     1842            sprintf( __( 'A total of %s meta values were deleted with the key
     1843            wp_capabilities due to no longer have a user.', 'multitool' ), $total_meta_deleted ),
     1844            'success',
     1845            'Small',
     1846            __( 'User Meta (wp_capabilities) Cleanup Results', 'multitool' )
     1847        );
     1848       
     1849        return;
     1850    }   
    17681851   
    17691852}// MULTITOOL_Requests       
  • multitool/trunk/classes/class-security.php

    r1431029 r1436092  
    6060        // return admin and NEAR admin and a count of result (array)
    6161        $total_admin_accounts = MULTITOOL_Users::total_administrators( true, true );   
    62        
     62
     63        multitool_trace_primary(
     64            'admincapdebug',
     65            'Total Admin Accounts: ' . $total_admin_accounts,
     66            array(),// $atts
     67            true,// $errorlog
     68            true,// $wperror
     69            true
     70        );
     71       
    6372        // As the administration limit been broken - a security matter!     
    6473        if( $total_admin_accounts > $cap ) {
  • multitool/trunk/classes/class-ui.php

    r1431029 r1436092  
    4343    * @author Ryan R. Bayne
    4444    * @package WebTechGlobal WordPress Plugins
    45     * @version 1.0
     45    * @version 1.5
    4646    *
    4747    * @deprecated
     
    119119               
    120120                $wp_admin_bar->add_menu( $args );
    121                                                    
     121               
     122                // Trace display.       
     123                $href = wp_nonce_url( admin_url() . 'admin.php?page=' . $_GET['page'] . '&multitoolaction=' . 'tracedisplay'  . '', 'tracedisplay' );
     124                $switch = MULTITOOL_Options::get_option( 'debugtracedisplay', false );
     125
     126                if( $switch ){
     127                    $title = __( 'Hide Trace', 'multitool' );
     128                } else {
     129                    $title = __( 'Display Trace', 'multitool' );
     130                }
     131               
     132                $args = array(
     133                    'id'     => 'webtechglobal-toolbarmenu-tracedisplay',
     134                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
     135                    'title'  => $title,
     136                    'href'   => $href,           
     137                );
     138               
     139                $wp_admin_bar->add_menu( $args );
     140                                                             
     141                // Trace log.       
     142                $href = wp_nonce_url( admin_url() . 'admin.php?page=' . $_GET['page'] . '&multitoolaction=' . 'tracelog'  . '', 'tracelog' );
     143                $switch = MULTITOOL_Options::get_option( 'debugtracelog', false );
     144                if( $switch ){
     145                    $title = __( 'Start Trace Log', 'multitool' );
     146                } else {
     147                    $title = __( 'Stop Trace Log', 'multitool' );
     148                }
     149               
     150                $args = array(
     151                    'id'     => 'webtechglobal-toolbarmenu-tracelog',
     152                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
     153                    'title'  => $title,
     154                    'href'   => $href,           
     155                );
     156               
     157                $wp_admin_bar->add_menu( $args );
     158                                                                   
    122159            // Group - Configuration Options
    123160            $args = array(
     
    12921329    }
    12931330   
    1294     public function update_notice_array() {
     1331    /**
     1332    * Updates the notifications array. This needs to be replaced by
     1333    * class-options.php methods.
     1334    *
     1335    * @version 1.3
     1336    *
     1337    * @todo depreciate and replace using methods in new options class.
     1338    */
     1339    private static function update_notice_array() {
    12951340        global $multitool_notice_array;     
    12961341        return update_option( 'multitool_notifications',maybe_serialize( $multitool_notice_array ) );   
     
    13031348    * @package Multitool
    13041349    * @since 0.0.11
    1305     * @version 1.2
     1350    * @version 1.3
    13061351    *
    13071352    * @returns HTML notice
     
    13351380                // this class causes the notice to appear at the top of screen so is not suitable for use deep inside content
    13361381                $output = '<div class="' . $type . '">
    1337                     <h4>' . $title . '</h4>
     1382                    <h3>' . $title . '</h3>
    13381383                    <p>' . $message . '</p>
    13391384                </div>';
     
    13621407    * in the $notice_array it does not output.   
    13631408    *
    1364     * a) use create_prompt() to get an action from the current user based on conditions i.e. configuration issue
    1365     * b) use create_message() to create a notice for another user for when they login
     1409    * a) use create_prompt() to get an action from the current user based on
     1410    * conditions i.e. configuration issue
     1411    *
     1412    * b) use create_message() to create a notice for another user
     1413    * for when they login.
    13661414    *
    13671415    * @param mixed $message
     
    13701418    * @param mixed $title
    13711419    * @param mixed $sensitive
    1372     *
    1373     * @version 1.2
    1374     */
    1375     public function create_notice( $message, $type = 'info', $size = 'Small', $title = false, $helpurl = false ){
     1420    * @param boolean $hash generate hash to prevent duplicate notices, important within automation being triggered often.
     1421    *
     1422    * @version 1.4
     1423    */
     1424    public static function create_notice( $message, $type = 'info', $size = 'Small', $title = false, $helpurl = false, $hash = false ){
    13761425        global $multitool_notice_array, $current_user;
    13771426               
     
    13831432        $key = time() . rand(10000,99999);
    13841433
     1434        // Re-init this option if it is not valid. Currently it becomes unset and requires this.
     1435        if( !is_array( $multitool_notice_array ) )
     1436        {                         
     1437            $multitool_notice_array = array(); 
     1438        }
     1439       
    13851440        $multitool_notice_array['notices'][$current_user->ID][$key]['sensitive'] = false;
    13861441        $multitool_notice_array['notices'][$current_user->ID][$key]['message'] = $message;
     
    13901445        $multitool_notice_array['notices'][$current_user->ID][$key]['created'] = time();
    13911446        $multitool_notice_array['notices'][$current_user->ID][$key]['helpurl'] = $helpurl;
    1392 
    1393         return $this->update_notice_array( $multitool_notice_array );
     1447        $multitool_notice_array['notices'][$current_user->ID][$key]['time'] = time();
     1448                 
     1449        return self::update_notice_array( $multitool_notice_array );
    13941450    }
    13951451
  • multitool/trunk/classes/class-wpdb.php

    r1428502 r1436092  
    6060    * @package Multitool
    6161    * @since 7.0.0
    62     * @version 1.0
     62    * @version 1.1
    6363    *
    6464    * @param mixed $tablename
     
    6767    * @param mixed $select
    6868    */
    69     public function selectwherearray( $tablename, $condition=null, $orderby=null, $select = '*', $object = 'ARRAY_A', $sort = null ){
     69    public static function selectwherearray( $tablename, $condition=null, $orderby=null, $select = '*', $object = 'ARRAY_A', $sort = null ){
    7070        global $wpdb;
    7171        $condition = empty ( $condition)? '' : ' WHERE ' . $condition;
  • multitool/trunk/functions/functions.debug.php

    r1428502 r1436092  
    6666
    6767/**
    68 * Log an error. Initially using error_log() but this method is
    69 * expected to grow in later versions of the class and will offer
    70 * extra options for storing debugging information.
     68* Log an error with extra information.
    7169*
    7270* Feel free to use error_log() on its own however keep in mind that
     
    9088    $message .= ' (get help@webtechglobal.co.uk)';
    9189   
    92     return error_log( $message, $message_type, $destination, $extra_headers);
     90    return error_log( $message, $message_type, $destination, $extra_headers );
    9391}
    9492
     
    125123* @version 1.0
    126124*/
    127 function multitool_get_error_codes() {
    128     $classobject = new WP_Error();
     125function multitool_get_error_codes( $classobject ) {
    129126    return $classobject->get_error_codes();
    130127}
     
    136133* @version 1.0
    137134*/
    138 function multitool_get_error_code() {
    139     $classobject = new WP_Error();
     135function multitool_get_error_code( $classobject ) {
    140136    return $classobject->get_error_code();
    141137}
     
    148144* @version 1.0
    149145*/
    150 function multitool_get_error_messages( $code ) {
    151     $classobject = new WP_Error();
     146function multitool_get_error_messages( $classobject, $code ) {
    152147    return $classobject->get_error_messages( $code );
    153148}       
     
    160155* @version 1.0
    161156*/
    162 function multitool_get_error_message( $code ) {
    163     $classobject = new WP_Error();
     157function multitool_get_error_message( $classobject, $code ) {
    164158    return $classobject->get_error_messages( $code );
    165159}       
     
    170164* @version 1.0
    171165*/
    172 function multitool_get_error_data( $code ) {
    173     $classobject = new WP_Error();
     166function multitool_get_error_data( $classobject, $code ) {
    174167    return $classobject->get_error_data( $code );
    175168}       
     
    180173* @version 1.1
    181174*/
    182 function multitool_error_append( $code, $message, $data ) {
    183     $classobject = new WP_Error();   
     175function multitool_error_append( $classobject, $code, $message, $data ) {   
    184176    return $classobject->add( $code, $message, $data );
    185177}       
     
    191183* @version 1.1
    192184*/
    193 function multitool_error_add_data( $data, $code ) {
    194     $classobject = new WP_Error();
     185function multitool_error_add_data( $classobject, $data, $code ) {
    195186    return $classobject->add_data( $data, $code );
    196187}       
     
    201192* @version 1.1
    202193*/
    203 function multitool_error_remove( $code ) {
    204     $classobject = new WP_Error();
     194function multitool_error_remove( $classobject, $code ) {
    205195    return $classobject->remove( $code );
    206196}   
     
    230220/**
    231221* Restore error handler to the previous/server configured one.
     222*
     223* @version 1.0
    232224*/
    233225function multitool_error_handler_restore() {
     
    238230* restore_exception_handler — Restores the previously defined
    239231* exception handler function.
     232*
     233* @version 1.0
    240234*/
    241235function multitool_exception_handler_restore () {
     
    246240/**
    247241* set_exception_handler — Sets a user-defined exception handler function.
     242*
     243* @version 1.0
    248244*/
    249245function multitool_exception_handler_set() {
     
    251247    return;
    252248}
     249
     250/**
     251* Display and log traces. One function that can do both or either. The idea is
     252* to setup extensive traces then control all of them with global settings.
     253*
     254* @version 1.0
     255*
     256* @param string $code pass __FUNCTION__ or a unique code i.e. 22JAN2016-ryanbayne
     257* @param string $message
     258* @param int $message_type 0=PHP logger|1=Email|2=Depreciated|3=Append to file|4=SAPI logging handler
     259* @param string $destination
     260* @param string $extra_headers
     261* @param mixed $line
     262* @param mixed $function
     263* @param mixed $class
     264* @param mixed $time
     265*/
     266function multitool_trace_primary( $code, $message, $atts = array(), $errorlog = false, $wperror = false, $adminnotice = false ) {
     267
     268    $trace_display = MULTITOOL_Options::get_option( 'debugtracedisplay' );
     269    $trace_log = MULTITOOL_Options::get_option( 'debugtracelog' );
     270    if( !$trace_display && !$trace_log ){ return; }
     271   
     272    // Start with some debug_backtrace() values.
     273    $debug_backtrace = debug_backtrace();
     274    $file_one = '';
     275    $line_one = '';
     276    $func_one = '';
     277    $args_one = '';
     278    $file_two = '';
     279    $file_two = '';
     280    $file_two = '';
     281    $file_two = '';
     282    if( $debug_backtrace )
     283    {
     284        $file_one = $debug_backtrace[0]['file'];
     285        $line_one = $debug_backtrace[0]['line'];
     286        $func_one = $debug_backtrace[0]['function'];
     287        $args_one = $debug_backtrace[0]['args'];
     288       
     289        // TODO: these values appear as arrays in the notice.
     290        $file_two = $debug_backtrace[1]['file'];
     291        $file_two = $debug_backtrace[1]['line'];
     292        $file_two = $debug_backtrace[1]['function'];
     293        $file_two = $debug_backtrace[1]['args'];
     294    }
     295   
     296    // Extract $atts which will be used in each of the methods below.
     297    $args = shortcode_atts(
     298        array(
     299            'message_type'   => 0,// error_log() parameter
     300            'destination'    => null,// error_log() parameter
     301            'extra_headers'  => null,// error_log() parameter
     302        ),
     303        $atts
     304    );
     305   
     306
     307    // Display the trace in a notice with formatting.
     308    // TODO: consider being able to add information to existing trace notice much like in WP_Error().
     309    if( $adminnotice )
     310    {   
     311        $notice_message = '';
     312
     313        // Default message acts as the traces description.
     314        $notice_message .= '<h4>Main Information</h4>';
     315        $notice_message .= $message;
     316       
     317        // Add extra information for the developer debugging.
     318        $notice_message .= '<h4>Backtrace Information (debug_backtrace())</h4>';       
     319        $notice_message .= '<ul>';
     320        $notice_message .= '<li>File One: '. $file_one .'</li>';
     321        $notice_message .= '<li>Line One: '. $line_one .'</li>';
     322        $notice_message .= '<li>Function One: '. $func_one .'</li>';
     323        $notice_message .= '<li>File Two: '. $file_two .'</li>';
     324        $notice_message .= '<li>Line Two: '. $line_two .'</li>';
     325        $notice_message .= '<li>Function Two: '. $function_two .'</li>';
     326        $notice_message .= '</ul>';
     327       
     328        // Create the notice which is stored before being displayed.
     329        $title = __( 'Trace Results Code: ' . $code, 'multitool' );
     330        // TODO: improve notice to allow specific trade to be disabled, by code
     331        // may require a list of trace to undo the action of hiding specific trace.
     332        MULTITOOL_UI::create_notice( $notice_message,'info','Large',$title );   
     333    }
     334   
     335    // Create new WP_Error().
     336    if( $wperror )
     337    {
     338        new WP_Error( $code, $message, array(/* array */));         
     339    }
     340   
     341    // Default server logging method using error_log().
     342    if( $errorlog )
     343    {
     344        $message = 'Multitool: ';
     345        $message .= $message;
     346        $message .= ' (get help@webtechglobal.co.uk)';
     347       
     348        return error_log(
     349            $message,
     350            $args['message_type'],
     351            $args['destination'],
     352            $args['extra_headers']
     353        );
     354
     355    }
     356}
    253357?>
  • multitool/trunk/multitool.php

    r1431029 r1436092  
    22/*
    33Plugin Name: Multitool Beta
    4 Version: 1.0.6
     4Version: 1.0.7
    55Plugin URI: http://www.webtechglobal.co.uk/wtg-plugin-framework-wordpress/
    66Description: Multitool does a little bit of everything.
     
    2727See <http://www.gnu.org/licenses/>.
    2828*/           
    29   
     29 
    3030// Prohibit direct script loading
    3131defined( 'ABSPATH' ) || die( 'Direct script access is not allowed!' );
     
    4141
    4242// define package constants...                                           
    43 if(!defined( "MULTITOOL_VERSION") ){define( "MULTITOOL_VERSION", '1.0.6' );}
     43if(!defined( "MULTITOOL_VERSION") ){define( "MULTITOOL_VERSION", '1.0.7' );}
    4444if(!defined( "MULTITOOL_RELEASENAME") ){define( "MULTITOOL_RELEASENAME", 'Beta' );}                         
    4545if(!defined( "MULTITOOL_TITLE") ){define( "MULTITOOL_TITLE", 'Multitool' );}
     
    7676
    7777// Class required on loading.
     78require_once( MULTITOOL_DIR_PATH . 'classes/class-wpdb.php' );
    7879require_once( MULTITOOL_DIR_PATH . 'classes/class-install.php');
    7980require_once( MULTITOOL_DIR_PATH . 'classes/class-options.php');
    80 require_once( MULTITOOL_DIR_PATH . 'classes/class-wpdb.php' );
    8181require_once( MULTITOOL_DIR_PATH . 'classes/class-configuration.php' );
    8282require_once( MULTITOOL_DIR_PATH . 'classes/class-multitool.php' );
     
    100100$install = new MULTITOOL_Install();
    101101register_activation_hook( __FILE__, array( $install, 'install_plugin' ) );
    102 register_deactivation_hook( __FILE__, array( $install, 'deactivate_plugin' ) );                                                                                             
     102register_deactivation_hook( __FILE__, array( $install, 'deactivate_plugin' ) );                                                                                                
    103103?>
  • multitool/trunk/readme.txt

    r1431029 r1436092  
    7575
    7676== Changelog ==
     77= 1.0.7 =
     78* Feature Changes
     79    * Developer menu now offers ability to display trace.
     80    * Developer menu now offers ability to log trace.
     81    * Added a tool to delete redundant wp_capabilities user-meta data and fix problems with incorrect role count.
     82* Technical Notes
     83    * New function for creating a trace with the ability to display and log using server and WordPress.
     84    * New "lib" folder added.
     85    * Guzzle extensible PHP HTTP client added to "lib".
     86    * Trello package by Steven Maguire from GitHub added to "lib"
     87    * trelloclient.js added to "js" folder.
     88    * Trello integration partly reversed and not ready.
     89   
    7790= 1.0.6 =
    7891* Feature Changes
  • multitool/trunk/views/developersection.php

    r1420327 r1436092  
    308308        $this->UI->postbox_content_footer();                       
    309309    }     
    310 }?>
     310}
     311?>
  • multitool/trunk/views/userssection.php

    r1431029 r1436092  
    138138        $this->UI->postbox_content_header( $box['title'], $box['args']['formid'], $intro, false );       
    139139       
    140         //$this->FORMS->form_start( $box['args']['formid'], $box['args']['formid'], $box['title'] );
     140        $this->FORMS->form_start( $box['args']['formid'], $box['args']['formid'], $box['title'] );
    141141        ?> 
    142142
     
    162162            echo '</table>'; 
    163163           
    164             // TODO: add other roles to this list, consider custom roles.         
     164            // TODO: add other roles to this list, consider custom roles.
     165           
     166            // TODO: compare totals and display notice if there is mismatch.         
    165167            ?>
    166168           
     
    169171        <?php
    170172             
    171         //$this->UI->postbox_content_footer();
     173        $this->UI->postbox_content_footer();
    172174    }
    173175}?>
Note: See TracChangeset for help on using the changeset viewer.