Plugin Directory

Changeset 1428502


Ignore:
Timestamp:
06/01/2016 05:33:25 PM (10 years ago)
Author:
WebTechGlobal
Message:

Wide range of improvements.

Location:
multitool/trunk
Files:
4 added
3 deleted
17 edited

Legend:

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

    r1422006 r1428502  
    664664        return;
    665665    }
    666        
     666   
     667    /**
     668    * Delete a record in schedule table using row ID.
     669    *
     670    * @param mixed $rowid
     671    * @version 1.0
     672    */
     673    public function delete_wtgcron_job_byrowid( $rowid ) {
     674        global $wpdb;
     675        return MULTITOOL_DB::delete( $wpdb->webtechglobal_schedule, 'rowid = ' . $rowid );
     676    }
     677           
    667678    /**
    668679    * Get a registered (for automation) plugin by name (not title).
  • multitool/trunk/classes/class-configuration.php

    r1422006 r1428502  
    1515defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
    1616                                               
    17 class MULTITOOL_Configuration extends MULTITOOL_Log {
     17class MULTITOOL_Configuration {
    1818
    1919    /**
     
    226226    * @author Ryan R. Bayne
    227227    * @package WebTechGlobal WordPress Plugins
    228     * @version 0.3
     228    * @version 1.4
    229229    *
    230230    * @todo Create a postbox with individual options i.e.
     
    258258        // of WordPress and the error display switch is global to all WTG plugins
    259259        if(!defined( "WEBTECHGLOBAL_ERRORDISPLAY") ){define( "WEBTECHGLOBAL_ERRORDISPLAY", true );}
     260       
     261        // Display $_POST and $_GET information, function checks if activated.
     262        multitool_dump_request();
    260263    } 
    261264   
  • multitool/trunk/classes/class-forms.php

    r1422006 r1428502  
    278278    * @since 0.0.9
    279279    * @version 1.0
     280    *
     281    * @todo consider serializing form validation option so that the data stored is less sensitive.
    280282    */
    281283    public function register_form_forsecurity( $formid, $postbox_id, $page_name ) {
  • multitool/trunk/classes/class-globalui.php

    r1420327 r1428502  
    6868    function developer_toolbar_webtechglobaladmin() {
    6969        global $wp_admin_bar;
    70        
     70               
    7171        // Top Level/Level One
    7272        $args = array(
     
    8080                'id'     => 'webtechglobal-toolbarmenu-debugtools',
    8181                'parent' => 'webtechglobal-toolbarmenu-developers',
    82                 'title'  => __( 'Debug Toolsc', 'text_domain' ),
     82                'title'  => __( 'Debug Tools', 'text_domain' ),
    8383                'meta'   => array( 'class' => 'first-toolbar-group' )         
    8484            );       
     
    9797                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
    9898                    'title'  => $error_display_title,
     99                    'href'   => $href,           
     100                );
     101               
     102                $wp_admin_bar->add_menu( $args );
     103                           
     104                // $_POST data display switch       
     105                $href = wp_nonce_url( admin_url() . 'admin.php?page=' . $_GET['page'] . '&multitoolaction=' . 'postdumpswitch'  . '', 'postdumpswitch' );
     106                $switch = MULTITOOL_Options::get_option( 'postdump', false );
     107                if( $switch ){
     108                    $title = __( 'Hide $_POST', 'multitool' );
     109                } else {
     110                    $title = __( 'Display $_POST', 'multitool' );
     111                }
     112               
     113                $args = array(
     114                    'id'     => 'webtechglobal-toolbarmenu-postdisplay',
     115                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
     116                    'title'  => $title,
    99117                    'href'   => $href,           
    100118                );
  • multitool/trunk/classes/class-install.php

    r1420327 r1428502  
    1010* @author Ryan Bayne   
    1111* @since 0.0.1
    12 * @version 1.3
     12* @version 1.4
    1313*/
    1414
     
    1717
    1818class MULTITOOL_Install {
    19    
    20     public $twitter_service_status = false;
    21    
     19                 
    2220    /**
    2321    * Install __construct persistently registers database tables and is the
     
    2523    */
    2624    public function __construct() {
    27 
     25        // load class used at all times
     26        $this->DB = MULTITOOL::load_class( 'MULTITOOL_DB', 'class-wpdb.php', 'classes' );
     27        $this->PHP = new MULTITOOL_PHP();             
     28    }
     29   
     30    /**
     31    * Registers this plugins database tables in $wpdb for full integration.
     32    * This is called within construct in class-multitool.php as the action
     33    * is required during every load.
     34    *
     35    * @version 1.0
     36    */
     37    public function register_schema()
     38    {                     
     39        // register webtechglobal_scheduele table
     40        add_action( 'init', array( $this, 'register_webtechglobal_tables' ) );
     41        add_action( 'switch_blog', array( $this, 'register_webtechglobal_tables' ) );
     42       
     43        // register tables manually as the hook may have been missed
     44        $this->register_webtechglobal_tables();                                       
     45    }                               
     46
     47    /**
     48    * Reinstall ALL database tables for this plugin.
     49    *
     50    * @version 1.3
     51    */   
     52    public function reinstalldatabasetables() {
     53        global $wpdb;
     54       
     55        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     56         
     57        self::webtechglobal_projects( true );
     58        self::webtechglobal_projectsmeta( true );
     59        self::webtechglobal_postboxes( true );       
     60        self::webtechglobal_help( true );
     61        self::webtechglobal_helpmeta( true );
     62        self::webtechglobal_schedule( true );
     63       
    2864        // set service statuses to determine if tables should be installed or not
    2965        // this is important for updating plugin and auto updating tables
    3066        $this->twitter_service_status = get_option( 'webtechglobal_twitterservice' );
    31        
    32         // load class used at all times
    33         $this->DB = MULTITOOL::load_class( 'MULTITOOL_DB', 'class-wpdb.php', 'classes' );
    34         $this->PHP = new MULTITOOL_PHP();
    35                
    36         // on activation run install_plugin() method which then runs more methods i.e. create_tables();
    37         register_activation_hook( MULTITOOL_DIR_PATH . 'multitool.php', array( $this, 'install_plugin' ) );
    38 
    39         // on deactivation run disabled_plugin() - not a full uninstall
    40         register_deactivation_hook( MULTITOOL_DIR_PATH . 'multitool.php',  array( $this, 'deactivate_plugin' ) );
    41        
    42         // register webtechglobal_log table
    43         add_action( 'init', array( $this, 'register_webtechglobal_log_table' ) );
    44         add_action( 'switch_blog', array( $this, 'register_webtechglobal_log_table' ) );
    45         $this->register_webtechglobal_log_table(); // register tables manually as the hook may have been missed             
    46        
    47         // register webtechglobal_projects table
    48         add_action( 'init', array( $this, 'register_webtechglobal_projects_table' ) );
    49         add_action( 'switch_blog', array( $this, 'register_webtechglobal_projects_table' ) );
    50         $this->register_webtechglobal_projects_table(); // register tables manually as the hook may have been missed             
    51 
    52         // register webtechglobal_projectsmeta table
    53         add_action( 'init', array( $this, 'register_webtechglobal_projectsmeta_table' ) );
    54         add_action( 'switch_blog', array( $this, 'register_webtechglobal_projectsmeta_table' ) );
    55         $this->register_webtechglobal_projectsmeta_table(); // register tables manually as the hook may have been missed             
    56                
    57         // register webtechglobal_postboxes table
    58         add_action( 'init', array( $this, 'register_webtechglobal_postboxes_table' ) );
    59         add_action( 'switch_blog', array( $this, 'register_webtechglobal_postboxes_table' ) );
    60         $this->register_webtechglobal_postboxes_table(); // register tables manually as the hook may have been missed             
    61                
    62         // register webtechglobal_help table
    63         add_action( 'init', array( $this, 'register_webtechglobal_help_table' ) );
    64         add_action( 'switch_blog', array( $this, 'register_webtechglobal_help_table' ) );
    65         $this->register_webtechglobal_help_table(); // register tables manually as the hook may have been missed             
    66                
    67         // register webtechglobal_helpmeta table
    68         add_action( 'init', array( $this, 'register_webtechglobal_helpmeta_table' ) );
    69         add_action( 'switch_blog', array( $this, 'register_webtechglobal_helpmeta_table' ) );
    70         $this->register_webtechglobal_helpmeta_table(); // register tables manually as the hook may have been missed             
    71                
    72         // register twitter service tables
    73         if( $this->twitter_service_status ) {
    74            
    75             // register webtechglobal_tweetswaiting table
    76             add_action( 'init', array( $this, 'register_webtechglobal_tweetswaiting_table' ) );
    77             add_action( 'switch_blog', array( $this, 'register_webtechglobal_tweetswaiting_table' ) );
    78             $this->register_webtechglobal_tweetswaiting_table(); // register tables manually as the hook may have been missed             
    79                    
    80             // register webtechglobal_socialaccounts table
    81             add_action( 'init', array( $this, 'register_webtechglobal_socialaccounts_table' ) );
    82             add_action( 'switch_blog', array( $this, 'register_webtechglobal_socialaccounts_table' ) );
    83             $this->register_webtechglobal_socialaccounts_table(); // register tables manually as the hook may have been missed             
    84                
    85         } 
    86        
    87         // register webtechglobal_scheduele table
    88         add_action( 'init', array( $this, 'register_webtechglobal_schedule_table' ) );
    89         add_action( 'switch_blog', array( $this, 'register_webtechglobal_schedule_table' ) );
    90         $this->register_webtechglobal_schedule_table(); // register tables manually as the hook may have been missed             
    91                                      
    92     }                               
    93 
    94     function register_webtechglobal_log_table() {
     67        if( $this->twitter_service_status ) {       
     68            self::webtechglobal_tweetswaiting();
     69            self::webtechglobal_socialaccounts();
     70        }       
     71    }
     72   
     73    function install_options() {     
     74        // installation state values
     75        update_option( 'multitool_installedversion', MULTITOOL_VERSION );# will only be updated when user prompted to upgrade rather than activation
     76        update_option( 'multitool_installeddate', time() );# update the installed date, this includes the installed date of new versions
     77       
     78        // notifications array (persistent notice feature)
     79        add_option( 'multitool_notifications', serialize( array() ) );
     80       
     81        // New options installation process as of May 2016 by Ryan R. Bayne
     82        $all_options = MULTITOOL_Options::install();
     83    }
     84   
     85    function install_plugin() {
     86        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
     87        self::create_tables();
     88        self::install_options();
     89    }
     90   
     91    /**
     92    * Deactivate plugin - can use it for uninstall but usually not
     93    * 1. can use to cleanup WP CRON schedule, remove plugins scheduled events
     94    *
     95    * @version 1.0
     96    */
     97    function deactivate_plugin() {
     98       
     99    }
     100       
     101    function register_webtechglobal_tables() {
    95102        global $wpdb;
    96         $wpdb->webtechglobal_log = "{$wpdb->prefix}webtechglobal_log";
    97     }   
    98    
    99     // projects table - set $wpdb
    100     // this table is being used in multiple WTG plugins for easy integration
    101     // changes must be reflected in all plugins
    102     function register_webtechglobal_projects_table() {
    103         global $wpdb;
     103       
    104104        $wpdb->webtechglobal_projects = "{$wpdb->prefix}webtechglobal_projects";
    105     }
    106 
    107 
    108     // projects meta table - set $wpdb
    109     function register_webtechglobal_projectsmeta_table() {
    110         global $wpdb;
    111105        $wpdb->webtechglobal_projectsmeta = "{$wpdb->prefix}webtechglobal_projectsmeta";
    112     }
    113    
    114     // id content table
    115     function register_webtechglobal_postboxes_table() {
    116         global $wpdb;
    117106        $wpdb->webtechglobal_postboxes = "{$wpdb->prefix}webtechglobal_postboxes";
    118     }
    119    
    120     // help content table
    121     function register_webtechglobal_help_table() {
    122         global $wpdb;
    123107        $wpdb->webtechglobal_help = "{$wpdb->prefix}webtechglobal_help";
    124     }
    125 
    126     // help meta content table
    127     function register_webtechglobal_helpmeta_table() {
    128         global $wpdb;
    129108        $wpdb->webtechglobal_helpmeta = "{$wpdb->prefix}webtechglobal_helpmeta";
    130     }
    131    
    132     // tweets waiting table
    133     function register_webtechglobal_tweetswaiting_table() {
    134         global $wpdb;
    135         $wpdb->webtechglobal_tweetswaiting = "{$wpdb->prefix}webtechglobal_tweetswaiting";
    136     }
    137    
    138     // twitter accounts table
    139     function register_webtechglobal_socialaccounts_table() {
    140         global $wpdb;
    141         $wpdb->webtechglobal_socialaccounts = "{$wpdb->prefix}webtechglobal_socialaccounts";
    142     }
    143    
    144     // schedule table
    145     function register_webtechglobal_schedule_table() {
    146         global $wpdb;
    147109        $wpdb->webtechglobal_schedule = "{$wpdb->prefix}webtechglobal_schedule";
     110       
     111        // Twitter services tables are optional.
     112        if( get_option( 'webtechglobal_twitterservice' ) ) {
     113            $wpdb->webtechglobal_socialaccounts = "{$wpdb->prefix}webtechglobal_socialaccounts";
     114            $wpdb->webtechglobal_tweetswaiting = "{$wpdb->prefix}webtechglobal_tweetswaiting";
     115        }
    148116    }
    149117     
     
    158126    function create_tables() {     
    159127        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );         
    160         self::webtechglobal_log();
     128var_dump(__FUNCTION__);
    161129        self::webtechglobal_projects();
    162130        self::webtechglobal_projectsmeta();
     
    167135       
    168136        // install twitter service tables (would be based on prior install)
    169         if( $this->twitter_service_status === true ) {       
     137        if( get_option( 'webtechglobal_twitterservice' ) === true ) {       
    170138            self::webtechglobal_tweetswaiting();
    171139            self::webtechglobal_socialaccounts();
    172140        }
    173     }
    174    
    175     /**
    176     * Global WebTechGlobal log table as used in all WTG plugins.
    177     * This approach helps to keep the database tidy, while still providing
    178     * an still improving log system and with all log entries in a single table.
    179     * Behaviours relating to integration of these plugins can be spotted easier.
    180     *
    181     * @author Ryan R. Bayne
    182     * @package WebTechGlobal WordPress Plugins
    183     * @since 0.0.3
    184     * @version 1.3
    185     */
    186     public function webtechglobal_log( $drop = false ) {
    187         global $charset_collate,$wpdb;
    188        
    189         if( $drop === true ) {
    190             $this->DB->drop_table( $wpdb->webtechglobal_log );   
    191         }
    192                
    193         // webtechglobal_log - log everything in this table and use the data for multiple purposes
    194         $sql_create_table = "CREATE TABLE {$wpdb->webtechglobal_log} (
    195         row_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    196         service varchar(250) DEFAULT 'trainingtools',
    197         outcome tinyint(1) unsigned NOT NULL DEFAULT 1,
    198         timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    199         line int(11) unsigned DEFAULT NULL,
    200         file varchar(250) DEFAULT NULL,
    201         function varchar(250) DEFAULT NULL,
    202         sqlresult blob,
    203         sqlquery mediumtext DEFAULT NULL,
    204         sqlerror mediumtext,
    205         wordpresserror mediumtext,
    206         screenshoturl varchar(500) DEFAULT NULL,
    207         userscomment mediumtext,
    208         page varchar(250) DEFAULT NULL,
    209         version varchar(45) DEFAULT NULL,
    210         panelid varchar(250) DEFAULT NULL,
    211         panelname varchar(250) DEFAULT NULL,
    212         tabscreenid varchar(250) DEFAULT NULL,
    213         tabscreenname varchar(250) DEFAULT NULL,
    214         dump longblob,
    215         ipaddress varchar(45) DEFAULT NULL,
    216         userid int(11) unsigned DEFAULT NULL,
    217         comment mediumtext,type varchar(500) DEFAULT NULL,
    218         category varchar(100) DEFAULT NULL,
    219         action varchar(100) DEFAULT NULL,
    220         priority varchar(45) DEFAULT NULL,
    221         triga varchar(45) DEFAULT NULL,
    222         PRIMARY KEY (row_id) ) $charset_collate; ";
    223        
    224         dbDelta( $sql_create_table );   
    225        
    226         // row_id
    227         // service - the plugin, theme or web service triggering log entry
    228         // outcome - set a positive (1) or negative (0) outcome
    229         // timestamp
    230         // line - __LINE__
    231         // file - __FILE__
    232         // function - __FUNCTION__
    233         // sqlresult - return from the query (dont go mad with this and store large or sensitive data where possible)
    234         // sqlquery - the query as executed
    235         // sqlerror - if failed MySQL error in here
    236         // wordpresserror - if failed store WP error
    237         // screenshoturl - if screenshot taking and uploaded
    238         // userscomment - if user is testing they can submit a comment with error i.e. what they done to cause it
    239         // page - plugin page ID i.e. c2pdownloads
    240         // version - version of the plugin (plugin may store many logs over many versions)
    241         // panelid - (will be changed to formid i.e. savebasicsettings)
    242         // panelname - (will be changed to formname i.e Save Basic Settings)
    243         // tabscreenid - the tab number i.e. 0 or 1 or 5
    244         // tabscreenname - the on screen name of the tab in question, if any i.e. Downloads Overview
    245         // dump - anything the developer thinks will help with debugging or training
    246         // ipaddress - security side of things, record who is using the site
    247         // userid - if user logged into WordPress
    248         // comment - developers comment in-code i.e. recommendation on responding to the log entry
    249         // type - general|error|trace
    250         // category - any term that suits the section or system
    251         // action - what was being attempted, if known
    252         // priority - low|medium|high (low should be default, medium if the log might help improve the plugin or user experience or minor PHP errors, high for critical errors especially security related
    253         // triga - (trigger but that word is taking) not sure we need this       
    254141    }
    255142       
     
    592479        dbDelta( $sql_create_table );
    593480    }     
    594                                                                      
    595     /**
    596     * Reinstall ALL database tables for this plugin.
    597     *
    598     * Checks if a table exists to avoid error on attempting to delete.
    599     *
    600     * DROP TABLE is used and create_tables() then called.
    601     *
    602     * @author Ryan R. Bayne
    603     * @package WebTechGlobal WordPress Plugins
    604     * @since 0.0.1
    605     * @version 1.3
    606     */   
    607     public function reinstalldatabasetables() {
    608         global $wpdb;
    609        
    610         require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    611          
    612         self::webtechglobal_log( true );
    613         self::webtechglobal_projects( true );
    614         self::webtechglobal_projectsmeta( true );
    615         self::webtechglobal_postboxes( true );       
    616         self::webtechglobal_help( true );
    617         self::webtechglobal_helpmeta( true );
    618         self::webtechglobal_schedule( true );
    619        
    620         // set service statuses to determine if tables should be installed or not
    621         // this is important for updating plugin and auto updating tables
    622         $this->twitter_service_status = get_option( 'webtechglobal_twitterservice' );
    623         if( $this->twitter_service_status ) {       
    624             self::webtechglobal_tweetswaiting();
    625             self::webtechglobal_socialaccounts();
    626         }       
    627     }
    628    
    629     function install_options() {
    630         // installation state values
    631         update_option( 'multitool_installedversion', MULTITOOL_VERSION );# will only be updated when user prompted to upgrade rather than activation
    632         update_option( 'multitool_installeddate',time() );# update the installed date, this includes the installed date of new versions
    633        
    634         // schedule settings
    635         require( MULTITOOL_DIR_PATH . 'arrays/schedule_array.php' );       
    636         add_option( 'multitool_schedule', serialize( $multitool_schedule_array ) );
    637 
    638         // notifications array (persistent notice feature)
    639         add_option( 'multitool_notifications', serialize( array() ) );
    640     }
    641    
    642     function install_plugin() {
    643        
    644         require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    645                      
    646         $this->create_tables();
    647         $this->install_options();
    648                
    649         update_option( 'multitool_is_installed', true );
    650     }
    651    
    652     /**
    653     * Deactivate plugin - can use it for uninstall but usually not
    654     * 1. can use to cleanup WP CRON schedule, remove plugins scheduled events
    655     *
    656     * @author Ryan R. Bayne
    657     * @package Multitool
    658     * @since 0.0.1
    659     * @version 1.0
    660     */
    661     function deactivate_plugin() {
    662        
    663     }           
     481                                                                               
    664482}
    665483?>
  • multitool/trunk/classes/class-multitool.php

    r1422006 r1428502  
    11<?php 
    22/**
    3  * Core file, provides required functionality for even basic plugins.     
     3 * Core file, provides required functionality for
     4 * even basic plugins.     
    45 *
    56 * @package Multitool
     
    5657        global $multitool_settings;
    5758             
    58         // load class used at all times
     59        // TODO: can we add some of these objects to $MULTITOOL_Class for other classes to use.
    5960        $this->DB = self::load_class( 'MULTITOOL_DB', 'class-wpdb.php', 'classes' );
    6061        $this->PHP = self::load_class( 'MULTITOOL_PHP', 'class-phplibrary.php', 'classes' );
     
    6263        $this->Files = self::load_class( 'MULTITOOL_Files', 'class-files.php', 'classes' );
    6364        $this->CONFIG = self::load_class( 'MULTITOOL_Configuration', 'class-configuration.php', 'classes' );
    64         $this->LOG = self::load_class( 'MULTITOOL_Log', 'class-log.php', 'classes' );
    6565        $this->AUTO = self::load_class( 'WEBTECHGLOBAL_Automation', 'class-automation.php', 'classes' );
    6666
     67        // Register the plugins own schema.
     68        $install = new MULTITOOL_Install();
     69        $install->register_schema();
     70       
    6771        // Widget Classes
    6872        $this->FOOWIDGET = self::load_class( 'Foo_Widget', 'class-widgets.php', 'classes' );
     
    119123            return false;// User has not activated admin triggered automation. 
    120124        }
    121                  
    122         // clear out log table (48 hour log)
    123         self::log_cleanup();
    124125               
    125126        // Encorce maximum number of administration accounts.
     
    17611762   
    17621763    /**
    1763     * Gets the schedule array from wordpress option table.
    1764     * Array [times] holds permitted days and hours.
    1765     * Array [limits] holds the maximum post creation numbers
    1766     */
    1767     public static function get_option_schedule_array() {
    1768         $multitool_schedule_array = get_option( 'multitool_schedule' );
    1769         return maybe_unserialize( $multitool_schedule_array );   
    1770     }
    1771    
    1772     /**
    17731764    * Builds text link, also validates it to ensure it still exists.
    17741765    *
     
    18141805        }     
    18151806    }     
    1816    
    1817     /**
    1818     * Updates the schedule array from wordpress option table.
    1819     * Array [times] holds permitted days and hours.
    1820     * Array [limits] holds the maximum post creation numbers
    1821     */
    1822     public function update_option_schedule_array( $schedule_array ){
    1823         $schedule_array_serialized = maybe_serialize( $schedule_array );
    1824         return update_option( 'multitool_schedule', $schedule_array_serialized);   
    1825     }
    18261807   
    18271808    public function update_settings( $multitool_settings ){
     
    19451926        }
    19461927        return true;   
    1947     }
    1948    
    1949     /**
    1950     * Stores the last known reason why auto event was refused during checks in event_check()
    1951     */
    1952     public function event_return( $return_reason){
    1953         $multitool_schedule_array = self::get_option_schedule_array();
    1954         $multitool_schedule_array['history']['lastreturnreason'] = $return_reason;
    1955         self::update_option_schedule_array( $multitool_schedule_array );   
    19561928    } 
    19571929   
     
    24062378    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
    24072379}
    2408        
    2409 /**
    2410 * Lists tickets post type using standard WordPress list table
    2411 */
    2412 class MULTITOOL_Log_Table extends WP_List_Table {
    2413    
    2414     /** ************************************************************************
    2415      * REQUIRED. Set up a constructor that references the parent constructor. We
    2416      * use the parent reference to set some default configs.
    2417      ***************************************************************************/
    2418     function __construct() {
    2419         global $status, $page;
    2420              
    2421         //Set parent defaults
    2422         parent::__construct( array(
    2423             'singular'  => 'movie',     //singular name of the listed records
    2424             'plural'    => 'movies',    //plural name of the listed records
    2425             'ajax'      => false        //does this table support ajax?
    2426         ) );
    2427        
    2428     }
    2429    
    2430     /** ************************************************************************
    2431      * Recommended. This method is called when the parent class can't find a method
    2432      * specifically build for a given column. Generally, it's recommended to include
    2433      * one method for each column you want to render, keeping your package class
    2434      * neat and organized. For example, if the class needs to process a column
    2435      * named 'title', it would first see if a method named $this->column_title()
    2436      * exists - if it does, that method will be used. If it doesn't, this one will
    2437      * be used. Generally, you should try to use custom column methods as much as
    2438      * possible.
    2439      *
    2440      * Since we have defined a column_title() method later on, this method doesn't
    2441      * need to concern itself with any column with a name of 'title'. Instead, it
    2442      * needs to handle everything else.
    2443      *
    2444      * For more detailed insight into how columns are handled, take a look at
    2445      * WP_List_Table::single_row_columns()
    2446      *
    2447      * @param array $item A singular item (one full row's worth of data)
    2448      * @param array $column_name The name/slug of the column to be processed
    2449      * @return string Text or HTML to be placed inside the column <td>
    2450      **************************************************************************/
    2451     function column_default( $item, $column_name){
    2452              
    2453         $attributes = "class=\"$column_name column-$column_name\"";
    2454                
    2455         switch( $column_name){
    2456             case 'row_id':
    2457                 return $item['row_id'];   
    2458                 break;
    2459             case 'timestamp':
    2460                 return $item['timestamp'];   
    2461                 break;               
    2462             case 'outcome':
    2463                 return $item['outcome'];
    2464                 break;
    2465             case 'category':
    2466                 echo $item['category']; 
    2467                 break;
    2468             case 'action':
    2469                 echo $item['action']; 
    2470                 break; 
    2471             case 'line':
    2472                 echo $item['line']; 
    2473                 break;                 
    2474             case 'file':
    2475                 echo $item['file']; 
    2476                 break;                 
    2477             case 'function':
    2478                 echo $item['function']; 
    2479                 break;                 
    2480             case 'sqlresult':
    2481                 echo $item['sqlresult']; 
    2482                 break;       
    2483             case 'sqlquery':
    2484                 echo $item['sqlquery']; 
    2485                 break;
    2486             case 'sqlerror':
    2487                 echo $item['sqlerror']; 
    2488                 break;       
    2489             case 'wordpresserror':
    2490                 echo $item['wordpresserror']; 
    2491                 break;       
    2492             case 'screenshoturl':
    2493                 echo $item['screenshoturl']; 
    2494                 break;       
    2495             case 'userscomment':
    2496                 echo $item['userscomment']; 
    2497                 break; 
    2498             case 'page':
    2499                 echo $item['page']; 
    2500                 break;
    2501             case 'version':
    2502                 echo $item['version']; 
    2503                 break;
    2504             case 'panelname':
    2505                 echo $item['panelname']; 
    2506                 break;
    2507             case 'tabscreenname':
    2508                 echo $item['tabscreenname']; 
    2509                 break;
    2510             case 'dump':
    2511                 echo $item['dump']; 
    2512                 break;
    2513             case 'ipaddress':
    2514                 echo $item['ipaddress']; 
    2515                 break;
    2516             case 'userid':
    2517                 echo $item['userid']; 
    2518                 break;
    2519             case 'comment':
    2520                 echo $item['comment']; 
    2521                 break;
    2522             case 'type':
    2523                 echo $item['type']; 
    2524                 break;
    2525             case 'priority':
    2526                 echo $item['priority']; 
    2527                 break; 
    2528             case 'thetrigger':
    2529                 echo $item['thetrigger']; 
    2530                 break;
    2531                                        
    2532             default:
    2533                 return 'No column function or default setup in switch statement';
    2534         }
    2535     }
    2536                    
    2537     /** ************************************************************************
    2538     * Recommended. This is a custom column method and is responsible for what
    2539     * is rendered in any column with a name/slug of 'title'. Every time the class
    2540     * needs to render a column, it first looks for a method named
    2541     * column_{$column_title} - if it exists, that method is run. If it doesn't
    2542     * exist, column_default() is called instead.
    2543     *
    2544     * This example also illustrates how to implement rollover actions. Actions
    2545     * should be an associative array formatted as 'slug'=>'link html' - and you
    2546     * will need to generate the URLs yourself. You could even ensure the links
    2547     *
    2548     *
    2549     * @see WP_List_Table::::single_row_columns()
    2550     * @param array $item A singular item (one full row's worth of data)
    2551     * @return string Text to be placed inside the column <td> (movie title only )
    2552     **************************************************************************/
    2553     /*
    2554     function column_title( $item){
    2555 
    2556     } */
    2557    
    2558     /** ************************************************************************
    2559      * REQUIRED! This method dictates the table's columns and titles. This should
    2560      * return an array where the key is the column slug (and class) and the value
    2561      * is the column's title text. If you need a checkbox for bulk actions, refer
    2562      * to the $columns array below.
    2563      *
    2564      * The 'cb' column is treated differently than the rest. If including a checkbox
    2565      * column in your table you must create a column_cb() method. If you don't need
    2566      * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
    2567      *
    2568      * @see WP_List_Table::::single_row_columns()
    2569      * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
    2570      **************************************************************************/
    2571     function get_columns() {
    2572         $columns = array(
    2573             'row_id' => 'Row ID',
    2574             'timestamp' => 'Timestamp',
    2575             'category'     => 'Category'
    2576         );
    2577        
    2578         if( isset( $this->action ) ){
    2579             $columns['action'] = 'Action';
    2580         }                                       
    2581            
    2582         if( isset( $this->line ) ){
    2583             $columns['line'] = 'Line';
    2584         }
    2585                      
    2586         if( isset( $this->file ) ){
    2587             $columns['file'] = 'File';
    2588         }
    2589                
    2590         if( isset( $this->function ) ){
    2591             $columns['function'] = 'Function';
    2592         }       
    2593  
    2594         if( isset( $this->sqlresult ) ){
    2595             $columns['sqlresult'] = 'SQL Result';
    2596         }
    2597 
    2598         if( isset( $this->sqlquery ) ){
    2599             $columns['sqlquery'] = 'SQL Query';
    2600         }
    2601  
    2602         if( isset( $this->sqlerror ) ){
    2603             $columns['sqlerror'] = 'SQL Error';
    2604         }
    2605          
    2606         if( isset( $this->wordpresserror ) ){
    2607             $columns['wordpresserror'] = 'WP Error';
    2608         }
    2609 
    2610         if( isset( $this->screenshoturl ) ){
    2611             $columns['screenshoturl'] = 'Screenshot';
    2612         }
    2613        
    2614         if( isset( $this->userscomment ) ){
    2615             $columns['userscomment'] = 'Users Comment';
    2616         }
    2617  
    2618         if( isset( $this->columns_array->page ) ){
    2619             $columns['page'] = 'Page';
    2620         }
    2621 
    2622         if( isset( $this->version ) ){
    2623             $columns['version'] = 'Version';
    2624         }
    2625  
    2626         if( isset( $this->panelname ) ){
    2627             $columns['panelname'] = 'Panel Name';
    2628         }
    2629  
    2630         if( isset( $this->tabscreenid ) ){
    2631             $columns['tabscreenid'] = 'Screen ID';
    2632         }
    2633 
    2634         if( isset( $this->tabscreenname ) ){
    2635             $columns['tabscreenname'] = 'Screen Name';
    2636         }
    2637 
    2638         if( isset( $this->dump ) ){
    2639             $columns['dump'] = 'Dump';
    2640         }
    2641 
    2642         if( isset( $this->ipaddress) ){
    2643             $columns['ipaddress'] = 'IP Address';
    2644         }
    2645 
    2646         if( isset( $this->userid ) ){
    2647             $columns['userid'] = 'User ID';
    2648         }
    2649 
    2650         if( isset( $this->comment ) ){
    2651             $columns['comment'] = 'Comment';
    2652         }
    2653 
    2654         if( isset( $this->type ) ){
    2655             $columns['type'] = 'Type';
    2656         }
    2657                                    
    2658         if( isset( $this->priority ) ){
    2659             $columns['priority'] = 'Priority';
    2660         }
    2661        
    2662         if( isset( $this->thetrigger ) ){
    2663             $columns['thetrigger'] = 'Trigger';
    2664         }
    2665 
    2666         return $columns;
    2667     }
    2668    
    2669     /** ************************************************************************
    2670      * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
    2671      * you will need to register it here. This should return an array where the
    2672      * key is the column that needs to be sortable, and the value is db column to
    2673      * sort by. Often, the key and value will be the same, but this is not always
    2674      * the case (as the value is a column name from the database, not the list table).
    2675      *
    2676      * This method merely defines which columns should be sortable and makes them
    2677      * clickable - it does not handle the actual sorting. You still need to detect
    2678      * the ORDERBY and ORDER querystring variables within prepare_items_further() and sort
    2679      * your data accordingly (usually by modifying your query ).
    2680      *
    2681      * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array( 'data_values',bool)
    2682      **************************************************************************/
    2683     function get_sortable_columns() {
    2684         $sortable_columns = array(
    2685             //'post_title'     => array( 'post_title', false ),     //true means it's already sorted
    2686         );
    2687         return $sortable_columns;
    2688     }
    2689    
    2690     /** ************************************************************************
    2691      * Optional. If you need to include bulk actions in your list table, this is
    2692      * the place to define them. Bulk actions are an associative array in the format
    2693      * 'slug'=>'Visible Title'
    2694      *
    2695      * If this method returns an empty value, no bulk action will be rendered. If
    2696      * you specify any bulk actions, the bulk actions box will be rendered with
    2697      * the table automatically on display().
    2698      *
    2699      * Also note that list tables are not automatically wrapped in <form> elements,
    2700      * so you will need to create those manually in order for bulk actions to function.
    2701      *
    2702      * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
    2703      **************************************************************************/
    2704     function get_bulk_actions() {
    2705         $actions = array(
    2706 
    2707         );
    2708         return $actions;
    2709     }
    2710    
    2711     /** ************************************************************************
    2712      * Optional. You can handle your bulk actions anywhere or anyhow you prefer.
    2713      * For this example package, we will handle it in the class to keep things
    2714      * clean and organized.
    2715      *
    2716      * @see $this->prepare_items_further()
    2717      **************************************************************************/
    2718     function process_bulk_action() {
    2719        
    2720         //Detect when a bulk action is being triggered...
    2721         if( 'delete'===$this->current_action() ) {
    2722             wp_die( 'Items deleted (or they would be if we had items to delete)!' );
    2723         }
    2724        
    2725     }
    2726    
    2727     /** ************************************************************************
    2728      * REQUIRED! This is where you prepare your data for display. This method will
    2729      * usually be used to query the database, sort and filter the data, and generally
    2730      * get it ready to be displayed. At a minimum, we should set $this->items and
    2731      * $this->set_pagination_args(), although the following properties and methods
    2732      * are frequently interacted with here...
    2733      *
    2734      * @global WPDB $wpdb
    2735      * @uses $this->_column_headers
    2736      * @uses $this->items
    2737      * @uses $this->get_columns()
    2738      * @uses $this->get_sortable_columns()
    2739      * @uses $this->get_pagenum()
    2740      * @uses $this->set_pagination_args()
    2741      **************************************************************************/
    2742     function prepare_items_further( $data, $per_page = 5) {
    2743         global $wpdb; //This is used only if making any database queries       
    2744        
    2745         /**
    2746          * REQUIRED. Now we need to define our column headers. This includes a complete
    2747          * array of columns to be displayed (slugs & titles), a list of columns
    2748          * to keep hidden, and a list of columns that are sortable. Each of these
    2749          * can be defined in another method (as we've done here) before being
    2750          * used to build the value for our _column_headers property.
    2751          */
    2752         $columns = $this->get_columns();
    2753         $hidden = array();
    2754         $sortable = $this->get_sortable_columns();
    2755        
    2756         /**
    2757          * REQUIRED. Finally, we build an array to be used by the class for column
    2758          * headers. The $this->_column_headers property takes an array which contains
    2759          * 3 other arrays. One for all columns, one for hidden columns, and one
    2760          * for sortable columns.
    2761          */
    2762         $this->_column_headers = array( $columns, $hidden, $sortable);
    2763        
    2764         /**
    2765          * Optional. You can handle your bulk actions however you see fit. In this
    2766          * case, we'll handle them within our package just to keep things clean.
    2767          */
    2768         $this->process_bulk_action();
    2769      
    2770         /**
    2771          * REQUIRED for pagination. Let's figure out what page the user is currently
    2772          * looking at. We'll need this later, so you should always include it in
    2773          * your own package classes.
    2774          */
    2775         $current_page = $this->get_pagenum();
    2776        
    2777         /**
    2778          * REQUIRED for pagination. Let's check how many items are in our data array.
    2779          * In real-world use, this would be the total number of items in your database,
    2780          * without filtering. We'll need this later, so you should always include it
    2781          * in your own package classes.
    2782          */
    2783         $total_items = count( $data);
    2784 
    2785         /**
    2786          * The WP_List_Table class does not handle pagination for us, so we need
    2787          * to ensure that the data is trimmed to only the current page. We can use
    2788          * array_slice() to
    2789          */
    2790         $data = array_slice( $data,(( $current_page-1)*$per_page), $per_page);
    2791  
    2792         /**
    2793          * REQUIRED. Now we can add our *sorted* data to the items property, where
    2794          * it can be used by the rest of the class.
    2795          */
    2796         $this->items = $data;
    2797  
    2798         /**
    2799          * REQUIRED. We also have to register our pagination options & calculations.
    2800          */
    2801         $this->set_pagination_args( array(
    2802             'total_items' => $total_items,                  //WE have to calculate the total number of items
    2803             'per_page'    => $per_page,                     //WE have to determine how many items to show on a page
    2804             'total_pages' => ceil( $total_items/$per_page)   //WE have to calculate the total number of pages
    2805         ) );
    2806     }
    2807 }// end MULTITOOL_Log_Table class
    28082380?>
  • multitool/trunk/classes/class-options.php

    r1365905 r1428502  
    33 * Handle all things "options".
    44 *
    5  * An adaption of class.jetpack-options.php which focuses on the standard actions
    6  * for options: add, update and ensuring validity or tracing options applicable
    7  * to the plugin.
     5 * @todo Add option to log all option changes for monitoring users more.
    86 *
    9  * I would like to add more...
    10  * @todo Ensure this class protects against overwriting options groups (array) by individual values. This appears to be the case but it needs confirmed and then needs to be applied to all WTG plugins to prevent a bug removing options.
    11  * @todo Add ability to undo option changes using a backup - use would need to activate this service.
    12  * @todo Ensure all option changes are logged.
    13  * @todo Create UI and the functions required to present a list of options to the user. The style used for Jetpacks list of modules could be nice.
     7 * @todo Create a list of options and values. On options view.
    148 *
    159 * @package WebTechGlobal WordPress Plugins
     
    2216
    2317    private static $grouped_options = array(
    24         'compact' => 'jetpack_options',
    25         'private' => 'jetpack_private_options'
     18        'compact' => 'multitool_options',
     19        'compactold' => 'multitool_settings',
     20        'private' => 'multitool_private_options',
     21        'webtechglobal' => 'webtechglobal_options'
    2622    );
    2723
    28     // TODO 5: Function not hacked yet. Please stick to the same format.
     24    /**
     25    * All valid option names. Used to validation and throw error
     26    * prior to attempting to access specified option.
     27    *
     28    * @param mixed $type
     29    * @version 1.0
     30    */
    2931    public static function get_option_names( $type = 'compact' ) {
    3032        switch ( $type ) {
    3133        case 'non-compact' :
     34       
     35        //Individual options here, will be prepended with "multitool".
    3236        case 'non_compact' :
    3337            return array(
    34                 'activated',
    35                 'active_modules',
    36                 'available_modules',
    37                 'do_activate',
    38                 'log',
    39                 'autoupdate_plugins',          // (array)  An array of plugin ids ( eg. jetpack/jetpack ) that should be autoupdated
    40                 'autoupdate_themes',           // (array)  An array of theme ids ( eg. twentyfourteen ) that should be autoupdated
    41                 'autoupdate_core',             // (bool)   Whether or not to autoupdate core
    42                 'json_api_full_management',    // (bool)   Allow full management (eg. Activate, Upgrade plugins) of the site via the JSON API.
    43                 'sync_non_public_post_stati',  // (bool)   Allow synchronisation of posts and pages with non-public status.
    44                 'site_icon_url',               // (string) url to the full site icon
    45                 'site_icon_id',                // (int)    Attachment id of the site icon file
    46                 'dismissed_manage_banner',     // (bool) Dismiss Jetpack manage banner allows the user to dismiss the banner permanently
    47                 'restapi_stats_cache',         // (array) Stats Cache data.
    48                 'unique_connection',           // (array)  A flag to determine a unique connection to wordpress.com two values "connected" and "disconnected" with values for how many times each has occured
    49                 'protect_whitelist'            // (array) IP Address for the Protect module to ignore
    50             );
    51 
     38                'notifications',            // (array) admin side notification storage.
     39                'installedversion',         // (string) original installed version.
     40                'installeddate',            // (timestamp) original time when plugin was installed.
     41                'formvalidation',           // (array) stores the plugins forms for comparison after submission.
     42                'capabilities',             // (array) individual admin view capability requirements.
     43                'adm_trig_auto',            // (bool) switch for administrator triggered automation.
     44                'securityevent_admincap',   // (array) details about a security event related to maximum admin accounts.   
     45            );                                                                                               
     46           
     47        //Add security sensitive options here i.e. tokens, keys.
    5248        case 'private' :
    5349            return array(
    54                 'register',
    55                 'blog_token',                  // (string) The Client Secret/Blog Token of this site.
    56                 'user_token',                  // (string) The User Token of this site. (deprecated)
    57                 'user_tokens'                  // (array)  User Tokens for each user of this site who has connected to jetpack.wordpress.com.
    5850            );
    5951        }
    6052
     53        // Return compact options.
    6154        return array(
    62             'id',                           // (int)    The Client ID/WP.com Blog ID of this site.
    63             'publicize_connections',        // (array)  An array of Publicize connections from WordPress.com
    64             'master_user',                  // (int)    The local User ID of the user who connected this site to jetpack.wordpress.com.
    65             'version',                      // (string) Used during upgrade procedure to auto-activate new modules. version:time
    66             'old_version',                  // (string) Used to determine which modules are the most recently added. previous_version:time
    67             'fallback_no_verify_ssl_certs', // (int)    Flag for determining if this host must skip SSL Certificate verification due to misconfigured SSL.
    68             'time_diff',                    // (int)    Offset between Jetpack server's clocks and this server's clocks. Jetpack Server Time = time() + (int) Jetpack_Options::get_option( 'time_diff' )
    69             'public',                       // (int|bool) If we think this site is public or not (1, 0), false if we haven't yet tried to figure it out.
    70             'videopress',                   // (array)  VideoPress options array.
    71             'is_network_site',              // (int|bool) If we think this site is a network or a single blog (1, 0), false if we haven't yet tried to figue it out.
    72             'social_links',                 // (array)  The specified links for each social networking site.
    73             'identity_crisis_whitelist',    // (array)  An array of options, each having an array of the values whitelisted for it.
    74             'gplus_authors',                // (array)  The Google+ authorship information for connected users.
    75             'last_heartbeat',               // (int)    The timestamp of the last heartbeat that fired.
    76             'last_security_report',         // (int)    The timestamp of the last security report that was run.
    77             'sync_bulk_reindexing',         // (bool)   If a bulk reindex is currently underway.
    78             'jumpstart',                    // (string) A flag for whether or not to show the Jump Start.  Accepts: new_connection, jumpstart_activated, jetpack_action_taken, jumpstart_dismissed.
    79             'hide_jitm'                     // (array)  A list of just in time messages that we should not show because they have been dismissed by the user
     55            'postdump', // (boolean) switch in Developer Menu for displaying $_POST.
     56            'getdump', // (boolean) switch in Developer Menu for displaying $_GET.
    8057        );
    8158    }
    8259
    83     // TODO 5: Function not hacked yet. Please stick to the same format.
     60    /**
     61    * Created to replace get_options_names() which holds only option names.
     62    *
     63    * This method holds option names and their default values. We can thus
     64    * query default values to correct missing options.
     65    *
     66    * We can also set each option to be installed by default or by trigger i.e.
     67    * during procedure.     
     68    *
     69    * @author Ryan R. Bayne
     70    * @param mixed $type
     71    * @version 1.0
     72    *
     73    * @param mixed $type single|merged|secure|deprec
     74    * @param mixed $return all|keys|install|update|delete|value
     75    * @param string|array $name use to get specific option details
     76    *
     77    * @todo complete $return by allowing specific information to be returned.
     78    * @todo complete $name which makes procedure return data for one or more options.
     79    * @todo add this method to get_options_names() and return keys only in it.
     80    * @todo move installation options to compact.
     81    */
     82    public static function get_option_information( $type = 'merged', $return = 'keys', $name = array() ) {
     83       
     84            /*
     85           
     86            Types Explained
     87            Single - individual records in the WP options table.
     88            Merged - a single array of many options installed in WP options table.
     89            Secure - coded options, not installed in data, developer must configure.
     90            Deprec - depreciated option.
     91
     92            Options Array Values Explained
     93            0. Install (0|1) - add to options on activation of the plugin using add_option() only.
     94            1. Update (0|1)  - update option on activation i.e. version (rarely used) using update_option always.
     95            2. Delete (0|1)  - delete when user uninstalls using form (most should be removed).
     96            3. Value (mixed)     - options default value.   
     97           
     98            */
     99           
     100            switch ( $type ) {
     101                case 'single':
     102               
     103                    $single_options = array( 
     104                        // Multitool core options.                                 
     105                        'notifications'          => array( 1,0,1, array()           ),// (array) admin side notification storage.
     106                        'installedversion'       => array( 1,0,1, MULTITOOL_VERSION ),// (string) original installed version.
     107                        'installeddate'          => array( 1,0,1, time()            ),// (timestamp) original time when plugin was installed.
     108                        'updatededversion'       => array( 1,1,1, MULTITOOL_VERSION ),// (string) original installed version.
     109                        'formvalidation'         => array( 1,1,1, array()           ),// (array) stores the plugins forms for comparison after submission.
     110                        'capabilities'           => array( 0,0,1, array()           ),// (array) individual admin view capability requirements.
     111                        'adm_trig_auto'          => array( 0,0,1, false             ),// (bool) switch for administrator triggered automation.
     112                        'securityevent_admincap' => array( 0,1,1, array()           ),// (array) details about a security event related to maximum admin accounts.   
     113
     114                        // System specific options
     115                        'twitterservice'         => array( 0,0,1, false             ),// (unknown???) likely to be a boolean switch for twitter services.
     116                       
     117                    ); 
     118                   
     119                    return $single_options;
     120                               
     121                    break;
     122                case 'merged':
     123               
     124                    $merged_options = array( 
     125                        'mergedexample'          => array( 'merged',0,0,0, array() ),// an example private option.
     126                        'postdump'               => array( 'merged',1,1,1, false ),// an example private option.
     127                        'getdump'                => array( 'merged',1,1,1, false ),// an example private option.
     128                    );
     129                   
     130                    return $merged_options;
     131                           
     132                    break;
     133                case 'secure':
     134                    return;
     135                    break;
     136                case 'deprec':
     137                    return;
     138                    break;
     139            }
     140    }
     141
     142    /**
     143    * Install all options into the WordPress options table.
     144    * Does not update, only adds and so this method is only suitable
     145    * for activation.
     146    *
     147    * We focus on adding missing options when they are required after the
     148    * first time installation.
     149    *
     150    * @version 1.0
     151    */
     152    public function install() {
     153        $single_options = self::get_option_information( 'single', 'all' );
     154        $merged_options = self::get_option_information( 'merged', 'all' );
     155        $all_options = array_merge( $single_options, $merged_options );
     156        if( $all_options )
     157        {
     158            foreach( $all_options as $option_name => $option_information )
     159            {
     160                /*
     161               
     162                $option_information Example
     163                array (size=4)
     164                  0 => int 1
     165                  1 => int 1
     166                  2 => int 1
     167                  3 => string '1.0.4' (length=5)
     168                 
     169                 
     170                Values Explained
     171                0. Install (0|1) - add to options on activation of the plugin using add_option() only.
     172                1. Update (0|1)  - update option on activation i.e. version (rarely used) using update_option always.
     173                2. Delete (0|1)  - delete when user uninstalls using form (most should be removed).
     174                3. Value (mixed)     - options default value.   
     175                         
     176                */
     177               
     178                if( $option_information[0] === 1 )
     179                {
     180                    add_option( $option_name, $option_information[3] );
     181                }
     182                elseif( $option_information[1] === 1 )
     183                {
     184                    // Option is to be updated when plugin is activated, rare.
     185                    update_option( $option_name, $option_information[3], false );
     186                }   
     187            }
     188        }
     189        return;
     190    }   
     191
     192    /**
     193    * Confirm that a required option or array of options
     194    * are valid by name.
     195    *
     196    * Pass group if the option/s belong to a group and are not
     197    * stored as a seperate "non_compact" entry in the options table.
     198    *
     199    * @param mixed $name
     200    * @param mixed $group
     201    * @return mixed
     202    */
    84203    public static function is_valid( $name, $group = null ) {
    85204        if ( is_array( $name ) ) {
     
    112231
    113232    /**
    114      * Returns the requested option.  Looks in jetpack_options or jetpack_$name as appropriate.
     233     * Returns the requested option.  Looks in multitool_options group
     234     * or multitool_$name as appropriate.
    115235     *
    116236     * @param string $name Option name
    117237     * @param mixed $default (optional)
    118238     *
    119      * @todo 5: Function not hacked yet. Please stick to the same format.
     239     * @todo how can we get a grouped option without giving the group?
     240     * If two groups have the same option name the returned value could be
     241     * wrong. Add some lines that compares all groups and raises a specific
     242     * error advising the developer to change the option name.
    120243     */
    121244    public static function get_option( $name, $default = false ) {
     245       
     246        // First check if the requested option is a non_compact one.
    122247        if ( self::is_valid( $name, 'non_compact' ) ) {
    123             return get_option( "jetpack_$name", $default );
    124         }
    125 
     248            return get_option( "multitool_$name", $default );
     249        }
     250
     251        // Must be a grouped option, loop through groups.
    126252        foreach ( array_keys( self::$grouped_options ) as $group ) {
    127253            if ( self::is_valid( $name, $group ) ) {
     
    130256        }
    131257
    132         trigger_error( sprintf( 'Invalid Jetpack option name: %s', $name ), E_USER_WARNING );
     258        trigger_error( sprintf( 'Invalid Multitool option name: %s', $name ), E_USER_WARNING );
    133259
    134260        return $default;
    135261    }
    136262
    137     // TODO 5: Function not hacked yet. Please stick to the same format.
     263    /**
     264    * Update a giving grouped option. Will add the $value if it
     265    * does not already exist. The $name is the key.
     266    *
     267    * @param mixed $group
     268    * @param mixed $name
     269    * @param mixed $value
     270    */                               
    138271    private static function update_grouped_option( $group, $name, $value ) {
    139272        $options = get_option( self::$grouped_options[ $group ] );
     
    147280
    148281    /**
    149      * Updates the single given option.  Updates jetpack_options or jetpack_$name as appropriate.
     282     * Updates the single given option.
     283     * Updates multitool_options or jetpack_$name as appropriate.
    150284     *
    151285     * @param string $name Option name
     
    153287     * @param string $autoload If not compact option, allows specifying whether to autoload or not
    154288     *
    155      * @todo 5 Function not hacked yet. Please stick to the same format.
     289     * @todo Check original functions use of do('pre_update_jetpack_option_
     290     * which requires add_action that calls the delete method in this class.
     291     * Why delete every option prior to update?
    156292     */
    157293    public static function update_option( $name, $value, $autoload = null ) {
    158         /**
    159          * Fires before Jetpack updates a specific option.
    160          *
    161          * @since 3.0.0
    162          *
    163          * @param str $name The name of the option being updated.
    164          * @param mixed $value The new value of the option.
    165          */
    166         do_action( 'pre_update_jetpack_option_' . $name, $name, $value );
    167294        if ( self::is_valid( $name, 'non_compact' ) ) {
    168             /**
     295            /**             
    169296             * Allowing update_option to change autoload status only shipped in WordPress v4.2
    170297             * @link https://github.com/WordPress/WordPress/commit/305cf8b95
    171298             */
    172299            if ( version_compare( $GLOBALS['wp_version'], '4.2', '>=' ) ) {
    173                 return update_option( "jetpack_$name", $value, $autoload );
    174             }
    175             return update_option( "jetpack_$name", $value );
     300                return update_option( "multitool_$name", $value, $autoload );
     301            }
     302            return update_option( "multitool_$name", $value );
    176303        }
    177304
     
    182309        }
    183310
    184         trigger_error( sprintf( 'Invalid Jetpack option name: %s', $name ), E_USER_WARNING );
     311        trigger_error( sprintf( 'Invalid Multitool option name: %s', $name ), E_USER_WARNING );
    185312
    186313        return false;
     
    188315
    189316    /**
    190      * Updates the multiple given options.  Updates jetpack_options and/or jetpack_$name as appropriate.
     317     * Updates the multiple given options.  Updates jetpack_options and/or
     318     * jetpack_$name as appropriate.
    191319     *
    192320     * @param array $array array( option name => option value, ... )
    193      *
    194      * @todo 5: Function not hacked yet. Please stick to the same format.
    195321     */
    196322    public static function update_options( $array ) {
     
    198324
    199325        foreach ( array_diff( $names, self::get_option_names(), self::get_option_names( 'non_compact' ), self::get_option_names( 'private' ) ) as $unknown_name ) {
    200             trigger_error( sprintf( 'Invalid Jetpack option name: %s', $unknown_name ), E_USER_WARNING );
     326            trigger_error( sprintf( 'Invalid Multitool option name: %s', $unknown_name ), E_USER_WARNING );
    201327            unset( $array[ $unknown_name ] );
    202328        }
     
    209335    /**
    210336     * Deletes the given option.  May be passed multiple option names as an array.
    211      * Updates jetpack_options and/or deletes jetpack_$name as appropriate.
     337     * Updates multitool_options and/or deletes multitool_$name as appropriate.
    212338     *
    213339     * @param string|array $names
    214      *
    215      * @todo 5: Function not hacked yet. Please stick to the same format.
    216340     */
    217341    public static function delete_option( $names ) {
     
    220344
    221345        if ( ! self::is_valid( $names ) ) {
    222             trigger_error( sprintf( 'Invalid Jetpack option names: %s', print_r( $names, 1 ) ), E_USER_WARNING );
     346            trigger_error( sprintf( 'Invalid Multitool option names: %s', print_r( $names, 1 ) ), E_USER_WARNING );
    223347
    224348            return false;
     
    226350
    227351        foreach ( array_intersect( $names, self::get_option_names( 'non_compact' ) ) as $name ) {
    228             if ( ! delete_option( "jetpack_$name" ) ) {
     352            if ( ! delete_option( "multitool_$name" ) ) {
    229353                $result = false;
    230354            }
     
    240364    }
    241365
    242     // TODO 5: Function not hacked yet. Please stick to the same format.
     366    /**
     367    * Get one of many groups of options then return a value from within the
     368    * group.
     369    *
     370    * @param string $group non_compact, private, compact
     371    * @param mixed $name
     372    * @param mixed $default
     373    */
    243374    private static function get_grouped_option( $group, $name, $default ) {
    244375        $options = get_option( self::$grouped_options[ $group ] );
     376       
     377        // Does the group have the giving option name?
    245378        if ( is_array( $options ) && isset( $options[ $name ] ) ) {
    246379            return $options[ $name ];
     
    250383    }
    251384
    252     // TODO 5: Function not hacked yet. Please stick to the same format.
     385    /**
     386    * Delete an option value from grouped options.
     387    *
     388    * @param mixed $group
     389    * @param mixed $names
     390    */
    253391    private static function delete_grouped_option( $group, $names ) {
    254392        $options = get_option( self::$grouped_options[ $group ], array() );
  • multitool/trunk/classes/class-phplibrary.php

    r1420327 r1428502  
    1919    * when on installation blog unless manually activated)
    2020    *
    21     * @version 1.3
     21    * @version 1.4
    2222    */
    2323    public function var_dump( $value, $header = false, $append = '<br>' ){
    24            
     24        if( !current_user_can( 'activate_plugins') )
     25        {
     26            return false;
     27        }   
     28       
    2529        if( defined( 'WEBTECHGLOBAL_ERRORDISPLAY' ) && WEBTECHGLOBAL_ERRORDISPLAY === true ){
    2630
  • multitool/trunk/classes/class-requests.php

    r1422006 r1428502  
    5858       
    5959        // arriving here means check_admin_referer() security is positive       
    60         global $cont;
    61              
    62         $this->PHP->var_dump( $_POST, '<h1>$_POST</h1>' );           
    63         $this->PHP->var_dump( $_GET, '<h1>$_GET</h1>' );   
     60        global $cont;   
    6461                             
    6562        // $_POST security, $_GET nonce check is handled earlier.
     
    16601657        return;
    16611658    }
     1659
     1660    /**
     1661    * Reset security event information for the maximum
     1662    * administration accounts protection.
     1663    *
     1664    * @version 1.0
     1665    */
     1666    public function securityeventadmincap () {
     1667        delete_option( 'multitool_securityevent_admincap' );
     1668       
     1669        $output_text =  __( "The security event details for
     1670        maximum administration account protection was deleted
     1671        from the WordPress options table. If information about
     1672        an event of this nature appears on the interface please
     1673        treat it very seriously.", 'multitool' );
     1674         
     1675        $this->UI->create_notice(
     1676            $output_text,
     1677            'success',
     1678            'Small',
     1679            __( 'Security Details Deleted', 'multitool' )
     1680        );
     1681               
     1682        return;
     1683    }
     1684
     1685    /**
     1686    * Developer menu switch for displaying/hiding $_POST dump.
     1687    *
     1688    * @version 1.0
     1689    */
     1690    public function postdumpswitch () {
     1691        $current_value = MULTITOOL_Options::get_option( 'postdump' );
     1692       
     1693        if( !$current_value )
     1694        {
     1695            MULTITOOL_Options::update_option( 'postdump', true );
     1696           
     1697            $output_text =  __( "All form submitted data (\$_POST) will be dumped
     1698            for debugging. This has been activated within the Developer Menu
     1699            and can be disabled there also. Note that this configuration
     1700            applies to all administrators at this time. Please consider
     1701            your sites security while you debug.", 'multitool' );
     1702             
     1703            $this->UI->create_notice(
     1704                $output_text,
     1705                'success',
     1706                'Small',
     1707                __( 'Now Displaying $_POST', 'multitool' )
     1708            );         
     1709        }
     1710        else
     1711        {
     1712            MULTITOOL_Options::update_option( 'postdump', false );
     1713           
     1714            $output_text =  __( "Form data will not be dumped for
     1715            debugging anymore. This applies to all administrators.", 'multitool' );
     1716             
     1717            $this->UI->create_notice(
     1718                $output_text,
     1719                'success',
     1720                'Small',
     1721                __( 'Now Hiding $_POST', 'multitool' )
     1722            );         
     1723        }
     1724    }
     1725   
     1726    /**
     1727    * Developer menu switch for displaying/hiding $_POST dump.
     1728    *
     1729    * @version 1.0
     1730    */
     1731    public function getdumpswitch () {
     1732        $current_value = MULTITOOL_Options::get_option( 'getdump' );
     1733       
     1734        if( !$current_value )
     1735        {
     1736            MULTITOOL_Options::update_option( 'getdump', true );
     1737           
     1738            $output_text =  __( "All action link (\$_GET) will be dumped
     1739            for debugging. This has been activated within the Developer Menu
     1740            and can be disabled there also. Note that this configuration
     1741            applies to all administrators at this time. Please consider
     1742            your sites security while you debug.", 'multitool' );
     1743             
     1744            $this->UI->create_notice(
     1745                $output_text,
     1746                'success',
     1747                'Small',
     1748                __( 'Now Displaying $_GET', 'multitool' )
     1749            );         
     1750        }
     1751        else
     1752        {
     1753            MULTITOOL_Options::update_option( 'getdump', false );
     1754           
     1755            $output_text =  __( "All action links data (\$_GET) will
     1756            now be hidden. This applies to all administrators.", 'multitool' );
     1757             
     1758            $this->UI->create_notice(
     1759                $output_text,
     1760                'success',
     1761                'Small',
     1762                __( 'Now Hiding $_GET', 'multitool' )
     1763            );         
     1764        }
     1765
     1766        return;
     1767    }   
    16621768   
    16631769}// MULTITOOL_Requests       
  • multitool/trunk/classes/class-ui.php

    r1420327 r1428502  
    4444    * @package WebTechGlobal WordPress Plugins
    4545    * @version 1.0
     46    *
     47    * @deprecated
     48    * @todo finish moving use of this function to globalui.php
    4649    */
    4750    function developer_toolbar_webtechglobaladmin() {
     
    8083               
    8184                $wp_admin_bar->add_menu( $args );
    82                    
     85               
     86                // $_POST data display switch       
     87                $href = wp_nonce_url( admin_url() . 'admin.php?page=' . $_GET['page'] . '&multitoolaction=' . 'postdumpswitch'  . '', 'postdumpswitch' );
     88                $switch = MULTITOOL_Options::get_option( 'postdump', false );
     89                if( $switch ){
     90                    $title = __( 'Hide $_POST', 'multitool' );
     91                } else {
     92                    $title = __( 'Display $_POST', 'multitool' );
     93                }
     94               
     95                $args = array(
     96                    'id'     => 'webtechglobal-toolbarmenu-postdisplay',
     97                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
     98                    'title'  => $title,
     99                    'href'   => $href,           
     100                );
     101               
     102                $wp_admin_bar->add_menu( $args );
     103               
     104                // $_GET data display switch       
     105                $href = wp_nonce_url( admin_url() . 'admin.php?page=' . $_GET['page'] . '&multitoolaction=' . 'getdumpswitch'  . '', 'getdumpswitch' );
     106                $switch = MULTITOOL_Options::get_option( 'getdump', false );
     107                if( $switch ){
     108                    $title = __( 'Hide $_GET', 'multitool' );
     109                } else {
     110                    $title = __( 'Display $_GET', 'multitool' );
     111                }
     112               
     113                $args = array(
     114                    'id'     => 'webtechglobal-toolbarmenu-getdumpdisplay',
     115                    'parent' => 'webtechglobal-toolbarmenu-debugtools',
     116                    'title'  => $title,
     117                    'href'   => $href,           
     118                );
     119               
     120                $wp_admin_bar->add_menu( $args );
     121                                                   
    83122            // Group - Configuration Options
    84123            $args = array(
  • multitool/trunk/classes/class-wpdb.php

    r1420327 r1428502  
    144144    * @version 1.0
    145145    */
    146     public function delete( $tablename, $condition ){
     146    public static function delete( $tablename, $condition ){
    147147        global $wpdb;
    148148        return $wpdb->query( "DELETE FROM $tablename WHERE $condition ");
  • multitool/trunk/languages

    • Property svn:ignore set to
      csv2post-en_US.mo
      csv2post-en_US.po
  • multitool/trunk/multitool.php

    r1422006 r1428502  
    22/*
    33Plugin Name: Multitool Beta
    4 Version: 1.0.4
     4Version: 1.0.5
    55Plugin URI: http://www.webtechglobal.co.uk/wtg-plugin-framework-wordpress/
    66Description: Multitool does a little bit of everything.
     
    4141
    4242// define package constants...                                           
    43 if(!defined( "MULTITOOL_VERSION") ){define( "MULTITOOL_VERSION", '1.0.4' );}
     43if(!defined( "MULTITOOL_VERSION") ){define( "MULTITOOL_VERSION", '1.0.5' );}
    4444if(!defined( "MULTITOOL_RELEASENAME") ){define( "MULTITOOL_RELEASENAME", 'Beta' );}                         
    4545if(!defined( "MULTITOOL_TITLE") ){define( "MULTITOOL_TITLE", 'Multitool' );}
     
    7272if(!defined( "WEBTECHGLOBAL_AUTHORURI" ) ){define( "WEBTECHGLOBAL_AUTHORURI", 'https://www.webtechglobal.co.uk/' );}
    7373
    74 // Classes
     74require_once( MULTITOOL_DIR_PATH . 'functions/functions.debug.php');
     75require_once( MULTITOOL_DIR_PATH . 'classes/class-install.php');
     76require_once( MULTITOOL_DIR_PATH . 'classes/class-options.php');
    7577require_once( MULTITOOL_DIR_PATH . 'classes/class-wpdb.php' );
    76 require_once( MULTITOOL_DIR_PATH . 'classes/class-log.php' );
    7778require_once( MULTITOOL_DIR_PATH . 'classes/class-configuration.php' );
    7879require_once( MULTITOOL_DIR_PATH . 'classes/class-multitool.php' );
     
    8687add_action( 'plugins_loaded', array( 'MULTITOOL', 'init' ));
    8788
    88 // TODO: Old method of initiating plugin, custom_post_types needs finished now.
    89 //$MULTITOOL = new MULTITOOL();
    90 //$MULTITOOL->custom_post_types();
    91 
    92 // localization
     89// Once plugins are aloded apply localization.
    9390function multitool_textdomain() {
    9491    load_plugin_textdomain( 'multitool', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
    9592}
    96 add_action( 'plugins_loaded', 'multitool_textdomain' );                                                                                                 
     93add_action( 'plugins_loaded', 'multitool_textdomain' );
     94
     95// Install the plugin on activation only.
     96$install = new MULTITOOL_Install();
     97register_activation_hook( __FILE__, array( $install, 'install_plugin' ) );
     98register_deactivation_hook( __FILE__, array( $install, 'deactivate_plugin' ) );                                                                                             
    9799?>
  • multitool/trunk/readme.txt

    r1422006 r1428502  
    7474
    7575== Changelog ==
     76= 1.0.5 =
     77* Feature Changes
     78    * Can now reset security event data for maximum administration account feature.
     79* Technical Notes
     80    * New options class now in use.
     81    * multitool_is_installed option no longer in use and removed.
     82    * schedule-array.php file deleted (part of old schedule system)
     83    * New function.debug.php file added, the start of better error handling and debugging.
     84    * Now display $_POST dumps by activating it in the developer menu.
     85    * Now display $_GET dumps by activating that in the developer menu also.
     86    * Log system removed, too bulky and planned it to handle too much.
     87   
    7688= 1.0.4 =
    7789* Feature Changes
  • multitool/trunk/views/developercoretable.php

    r1420327 r1428502  
    553553   
    554554    /**
    555     * Process bulk actions.
    556     *
    557     * @version 1.0
     555    * Process bulk actions which are done using $_POST.
     556    *
     557    * @version 1.1
    558558    */
    559559    public function process_bulk_action()
     
    563563        // User must have permission or die!
    564564        if( !current_user_can( $this->full_actions[ $this->current_action() ]['capability'] ) ) {
    565             die( 'Naughty script kiddie detected website will self-destruct in 30 seconds!' );
     565            die( __( 'You do not have permission to perform this action.', 'multitool' ) );
    566566        }
    567        
    568         // Nonce must be correct or die!         
    569         if ( ! wp_verify_nonce( esc_attr( $_REQUEST['_wpnonce'] ), 'multitool_' . $this->current_action() . '_items' ) ) {
    570             die( 'Low rate hacker detected the system will laugh for 30 seconds!' );
    571         }
    572567
    573568        switch ( $this->current_action() ) {
     
    585580                break;
    586581            case 'delete':
    587 
    588            
    589                 // Detect row action click to delete a single row.
    590                 if ( 'delete' === $this->current_action() ) {
    591 
    592                     self::delete_item( absint( $_GET['item'] ) );
    593 
    594                     wp_redirect( esc_url( add_query_arg() ) );
    595                     exit;
    596            
    597                 }
    598 
     582   
    599583                // If the delete bulk action is submitted.
    600                 if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-delete' )
    601                 || ( isset( $_POST['action2'] ) && $_POST['action2'] == 'bulk-delete' )
    602                 ) {
    603 
    604                     $delete_ids = esc_sql( $_POST['bulk-delete'] );
    605 
    606                     // loop over the array of record IDs and delete them
     584                if ( ( isset( $_POST['action2'] ) && $_POST['action2'] == 'delete' ) )
     585                {
     586                    $delete_ids = esc_sql( $_POST[ $this->bulkid ] );
     587
    607588                    foreach ( $delete_ids as $id ) {
    608589                        self::delete_item( $id );
    609590                    }
    610591
    611                     wp_redirect( esc_url( add_query_arg() ) );
    612                     exit;
     592                    wp_die( __( 'Your items have been deleted.', 'multitool' ) );
    613593                }
    614  
    615              
     594   
    616595                break;
    617596           default;
     
    630609    public static function delete_item( $id ) {
    631610        global $wpdb;
    632 
    633         /*   Perform query here for deleting record
    634         $wpdb->delete(
    635             "{$wpdb->prefix}customers",
    636             [ 'ID' => $id ],
    637             [ '%d' ]
    638         );
    639         */
     611        return MULTITOOL_DB::delete( $wpdb->changethistotablename, 'id = ' . $id );
    640612    }
    641613 
  • multitool/trunk/views/main.php

    r1422006 r1428502  
    6363            array( $this->view_name . '-support', __( 'Support', 'multitool' ), array( $this, 'parent' ), 'side','default',array( 'formid' => 'support' ), true, 'activate_plugins' ),           
    6464            array( $this->view_name . '-developertoolssetup', __( 'Developer Tools Setup', 'multitool' ), array( $this, 'parent' ), 'side','default',array( 'formid' => 'developertoolssetup' ), true, 'activate_plugins' ),           
     65            array( $this->view_name . '-serversettings', __( 'Server Settings', 'multitool' ), array( $this, 'parent' ), 'side','default',array( 'formid' => 'serversettings' ), true, 'activate_plugins' ),           
    6566        );
    6667       
     
    757758        $this->UI->postbox_content_footer();
    758759    }
    759        
     760 
     761    /**
     762    * List of environment variables/constants.
     763    *
     764    * @author Ryan Bayne
     765    * @package WebTechGlobal WordPress Plugins
     766    * @since 0.0.3
     767    * @version 1.0
     768    */
     769    public function postbox_main_serversettings( $data, $box ) {
     770        global $wp_roles, $multitool_settings, $MULTITOOL_Class;
     771       
     772        $intro = __( 'Use these values to troubleshoot problems. Your servers
     773        configuration can be seen here and any number of values can affect how
     774        WordPress or plugins operate. Send this information to WebTechGlobal
     775        when troubleshooting.', 'multitool' );
     776       
     777        $this->UI->postbox_content_header(
     778            $box['title'],
     779            $box['args']['formid'],
     780            $intro,
     781            false
     782        );       
     783       
     784        $this->FORMS->form_start( $box['args']['formid'], $box['args']['formid'], $box['title'] );
     785        ?>
     786               
     787        <table class="form-table">
     788
     789        <?php
     790        // 
     791        $this->FORMS->input_subline(
     792            '',
     793            __( '', 'multitool')     
     794        );
     795       
     796        /*
     797          Value Constant    Description Note
     798        1   E_ERROR (integer)   Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.     
     799        2   E_WARNING (integer) Run-time warnings (non-fatal errors). Execution of the script is not halted.     
     800        4   E_PARSE (integer)   Compile-time parse errors. Parse errors should only be generated by the parser. 
     801        8   E_NOTICE (integer)  Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.   
     802        16  E_CORE_ERROR (integer)  Fatal errors that occur during PHP's initial startup. This is like an E_ERROR, except it is generated by the core of PHP.   
     803        32  E_CORE_WARNING (integer)    Warnings (non-fatal errors) that occur during PHP's initial startup. This is like an E_WARNING, except it is generated by the core of PHP.   
     804        64  E_COMPILE_ERROR (integer)   Fatal compile-time errors. This is like an E_ERROR, except it is generated by the Zend Scripting Engine.     
     805        128 E_COMPILE_WARNING (integer) Compile-time warnings (non-fatal errors). This is like an E_WARNING, except it is generated by the Zend Scripting Engine.   
     806        256 E_USER_ERROR (integer)  User-generated error message. This is like an E_ERROR, except it is generated in PHP code by using the PHP function trigger_error().     
     807        512 E_USER_WARNING (integer)    User-generated warning message. This is like an E_WARNING, except it is generated in PHP code by using the PHP function trigger_error().     
     808        1024    E_USER_NOTICE (integer) User-generated notice message. This is like an E_NOTICE, except it is generated in PHP code by using the PHP function trigger_error().   
     809        2048    E_STRICT (integer)  Enable to have PHP suggest changes to your code which will ensure the best interoperability and forward compatibility of your code. Since PHP 5 but not included in E_ALL until PHP 5.4.0
     810        4096    E_RECOVERABLE_ERROR (integer)   Catchable fatal error. It indicates that a probably dangerous error occurred, but did not leave the Engine in an unstable state. If the error is not caught by a user defined handle (see also set_error_handler()), the application aborts as it was an E_ERROR.   Since PHP 5.2.0
     811        8192    E_DEPRECATED (integer)  Run-time notices. Enable this to receive warnings about code that will not work in future versions. Since PHP 5.3.0
     812        16384   E_USER_DEPRECATED (integer) User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function trigger_error(). Since PHP 5.3.0
     813        32767   E_ALL (integer) All errors and warnings, as supported, except of level E_STRICT prior to PHP 5.4.0. 32767 in PHP 5.4.x, 30719 in PHP 5.3.x, 6143 in PHP 5.2.x, 2047 previously
     814            */         
     815        ?>
     816
     817        </table>
     818   
     819        <?php   
     820        $this->UI->postbox_content_footer();
     821    }
     822         
    760823}?>
  • multitool/trunk/views/scheduledactions.php

    r1420327 r1428502  
    315315    */
    316316    public function no_items() {
    317       _e( 'No movies avaliable.', 'sp' );
     317      _e( 'No actions have been scheduled.', 'multitool' );
    318318    }
    319319   
     
    416416    */
    417417    function column_cb( $item )
    418     {
    419         return sprintf( '<input type="checkbox" name="schedulebulk[]" value="%s" />', $item['rowid'] );   
     418    {                 var_dump($item);
     419        return sprintf(
     420            '<input type="checkbox" name="%1$s[]" value="%2$s" />',
     421            /*$1%s*/ $this->bulkid,
     422            /*$2%s*/ $item['rowid'] //The value of the checkbox should be the record's id
     423        );   
    420424    }
    421425   
     
    459463            // Create a nonce for this action.
    460464            $nonce = wp_create_nonce( 'multitool_' . $the_action . '_items' );
    461            
     465                                     var_dump($the_action);
    462466            // Build action link.       
    463467            $final_actions[ $the_action ] =
    464468           
    465                     sprintf( '<a href="?page=%s&action=%s&item=%s&_wpnonce=%s">' . $a['label'] . '</a>',
     469                    sprintf( '<a href="?page=%s&action=%s&item=%s&_wpnonce=%s">' . $a['label'] . ' - ' . $the_action . '</a>',
    466470                    esc_attr( $_REQUEST['page'] ),
    467471                    $the_action,
     
    479483    * Process bulk actions.
    480484    *
    481     * @version 1.0
     485    * @version 1.1
    482486    */
    483487    public function process_bulk_action()
    484488    {
    485489        if( !$this->current_action() ) { return; }
    486 
     490               
    487491        // User must have permission or die!
    488492        if( !current_user_can( $this->full_actions[ $this->current_action() ]['capability'] ) ) {
    489             die( 'Naughty script kiddie detected website will self-destruct in 30 seconds!' );
     493            die( __( 'You do not have permission to perform this action.', 'multitool' ) );
    490494        }
    491        
    492         // Nonce must be correct or die!         
    493         if ( ! wp_verify_nonce( esc_attr( $_REQUEST['_wpnonce'] ), 'multitool_' . $this->current_action() . '_items' ) ) {
    494             die( 'Low rate hacker detected the system will laugh for 30 seconds!' );
    495         }
    496495
    497496        switch ( $this->current_action() ) {
     
    509508                break;
    510509            case 'delete':
    511 
    512            
    513                 // Detect row action click to delete a single row.
    514                 if ( 'delete' === $this->current_action() ) {
    515 
    516                     self::delete_item( absint( $_GET['item'] ) );
    517 
    518                     wp_redirect( esc_url( add_query_arg() ) );
    519                     exit;
    520            
    521                 }
    522 
     510         
    523511                // If the delete bulk action is submitted.
    524                 if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'bulk-delete' )
    525                 || ( isset( $_POST['action2'] ) && $_POST['action2'] == 'bulk-delete' )
    526                 ) {
    527 
    528                     $delete_ids = esc_sql( $_POST['bulk-delete'] );
    529 
    530                     // loop over the array of record IDs and delete them
     512                if ( ( isset( $_POST['action2'] ) && $_POST['action2'] == 'delete' ) )
     513                {
     514                    $delete_ids = esc_sql( $_POST[ $this->bulkid ] );
     515
    531516                    foreach ( $delete_ids as $id ) {
    532517                        self::delete_item( $id );
    533518                    }
    534519
    535                     wp_redirect( esc_url( add_query_arg() ) );
    536                     exit;
     520                    wp_die( __( 'Your items have been deleted.', 'multitool' ) );
    537521                }
    538  
    539              
     522
    540523                break;
    541524           default;
     
    552535    * @param int $id item ID
    553536    */
    554     public static function delete_item( $id ) {
     537    public static function delete_item( $rowid ) {
    555538        global $wpdb;
    556 
    557         /*   Perform query here for deleting record
    558         $wpdb->delete(
    559             "{$wpdb->prefix}customers",
    560             [ 'ID' => $id ],
    561             [ '%d' ]
    562         );
    563         */
     539        return MULTITOOL_DB::delete( $wpdb->webtechglobal_schedule, 'rowid = ' . $rowid );
    564540    }
    565541 
Note: See TracChangeset for help on using the changeset viewer.