Plugin Directory

Changeset 1307114


Ignore:
Timestamp:
12/13/2015 01:44:20 AM (10 years ago)
Author:
vmallder
Message:

Added default_sort keyword and default setting. Added plugin name and plugin version to Admin and Settings classes constructor.

Location:
tablemaster/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tablemaster/trunk/readme.txt

    r1296986 r1307114  
    55Requires at least: 4.3
    66Tested up to: 4.3.1
    7 Stable tag: 0.0.2
     7Stable tag: 0.0.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4949== Frequently Asked Questions ==
    5050
    51 This is the second release of TableMaster! There are still no frequently asked questions. I hope that means the TableMaster User's Guide has been very helpful to everyone. However, questions will be added here when they are received.
     51This is the third release of TableMaster! And, still, there are no frequently asked questions. I hope this means that the TableMaster User's Guide has been very helpful to everyone. However, questions will be added here when they are received.
    5252
    5353== Upgrade Notice ==
     54
     55= 0.0.3 =
     56
     57This release fixes an issue reported by megadrive16 where the DataTables jQuery plugin default column sorting was overriding the "ORDER BY" clause that was specified by the user with the 'sql' keyword.  With this release, you can use the 'default_sort' keyword to disable the default column sorting used by the DataTables jQuery plugin.
    5458
    5559= 0.0.2 =
     
    5862
    5963== Changelog ==
     64
     65= 0.0.3 =
     66
     67* Added default_sort keyword to turn off the default column sorting by DataTables.
     68* Added plugin name and plugin version to Settings and Admin constructors.
     69* Added font awesome icons to user's guide when not viewed in Wordpress admin.
    6070
    6171= 0.0.2 =
     
    6777
    6878= 0.0.1 =
     79
    6980First release.
  • tablemaster/trunk/tablemaster.php

    r1297766 r1307114  
    44 * Plugin URI:        https://wordpress.org/plugins/tablemaster/
    55 * Description:       Prints your tables using the DataTables for JQuery Plugin using a simple `[tablemaster]` shortcode.
    6  * Version:           0.0.2
     6 * Version:           0.0.3
    77 * Author:            Valerie Mallder
    88 * Author URI:        http://codehorsesoftware.com
     
    1010 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
    1111*/
    12 
     12define(TABLEMASTER_PLUGIN_VERSION, '0.0.3');
    1313
    1414// Prohibit direct script loading
    1515defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
    16 
    17 $plugin_name = 'tablemaster';
    18 $plugin_version = '0.0.2';
    1916
    2017    /**
     
    5148    define( TABLEMASTER_USER_CSS_URI, get_stylesheet_directory_uri() . '/css/tablemaster.css');
    5249   
    53 require( dirname(__FILE__) . '/admin/class-tablemaster-settings.php');
    54 require( dirname(__FILE__) . '/admin/class-tablemaster-users-guide.php');
    55 require( dirname(__FILE__) . '/admin/class-tablemaster-admin.php');
     50    require( dirname(__FILE__) . '/admin/class-tablemaster-settings.php');
     51    require( dirname(__FILE__) . '/admin/class-tablemaster-users-guide.php');
     52    require( dirname(__FILE__) . '/admin/class-tablemaster-admin.php');
    5653
    5754//file_exists(dirname(__FILE__) . '/tablemaster-pro.php') AND include dirname(__FILE__) . '/tablemaster-pro.php';
     
    6057if (!class_exists('TableMaster'))  {
    6158class TableMaster {
     59
     60    /**
     61     * The ID of this plugin.
     62     *
     63     * @access   private
     64     * @var      string    $plugin_name    The ID of this plugin.
     65     */
     66    private $plugin_name = "tablemaster";
     67
     68    /**
     69     * The version of this plugin.
     70     *
     71     * @access   private
     72     * @var      string    $version    The current version of this plugin.
     73     */
     74    private $version = TABLEMASTER_PLUGIN_VERSION;
    6275
    6376    protected $tables = array();
     
    8699        "new_window",
    87100        "pre_table_filter",
    88         "post_table_filter"
    89         );
     101        "post_table_filter",
     102        'default_sort'     
     103    );
    90104
    91105    protected $valid_buttons = array(
     
    95109        "pdf",
    96110        "print"
    97         );
     111    );
    98112       
    99113
     
    114128    function __construct() {
    115129   
    116         TableMaster_Admin::getInstance();       // Instantiate to initialize
    117         TableMaster_Settings::getInstance();    // Instantiate to initialize
     130        TableMaster_Admin::getInstance( $plugin_name, $plugin_version );        // Instantiate to initialize
     131        TableMaster_Settings::getInstance( $plugin_name, $plugin_version );     // Instantiate to initialize
    118132
    119133        register_activation_hook( __FILE__, array( &$this, 'activate' ) );
     
    127141     */
    128142    function activate() {
    129         TableMaster_Admin::getInstance()->activate();
    130         TableMaster_Settings::getInstance()->activate();
     143        TableMaster_Admin::getInstance( $plugin_name, $plugin_version )->activate();
     144        TableMaster_Settings::getInstance( $plugin_name, $plugin_version )->activate();
    131145    }
    132146
     
    135149     */
    136150    function deactivate() {
    137         TableMaster_Admin::getInstance()->deactivate();
    138         TableMaster_Settings::getInstance()->deactivate();
     151        TableMaster_Admin::getInstance( $plugin_name, $plugin_version )->deactivate();
     152        TableMaster_Settings::getInstance( $plugin_name, $plugin_version )->deactivate();
    139153    }
    140154   
     
    221235         */
    222236        $this->tables[$table_id]['table_id'] = $table_id;
    223         $this->tables[$table_id]['settings'] = get_option( TableMaster_Settings::getInstance()->get_options_name() );
     237        $this->tables[$table_id]['settings'] = get_option( TableMaster_Settings::getInstance( $this->plugin_name, $this->plugin_version )->get_options_name() );
    224238        $this->tables[$table_id]['div_tag_id'] = 'tablemaster_wrapper_' . $table_id;
    225239        $this->tables[$table_id]['table_tag_id'] = 'tablemaster_table_' . $table_id;
     
    301315         * Check the thead keyword
    302316         */
    303         if ( array_key_exists('thead', $atts ) && "false" == $atts['thead'] ) {
     317        if ( array_key_exists('thead', $atts ) && "true" == $atts['thead'] ) {
     318            $this->tables[$table_id]['settings']['thead'] = true;   
     319   
     320        } else if ( array_key_exists('thead', $atts ) && "false" == $atts['thead'] ) {
    304321            $this->tables[$table_id]['settings']['thead'] = false;     
    305322        }
     
    309326         */
    310327        if ( array_key_exists('nohead', $atts ) && "true" == $atts['nohead'] ) {
    311             $this->tables[$table_id]['settings']['nohead'] = true;     
     328            $this->tables[$table_id]['settings']['nohead'] = true; 
     329   
     330        } else if ( array_key_exists('nohead', $atts ) && "false" == $atts['nohead'] ) {
     331            $this->tables[$table_id]['settings']['nohead'] = false;     
    312332        }
    313333       
     
    316336         */
    317337        if ( array_key_exists('tfoot', $atts ) && "true" == $atts['tfoot'] ) {
    318             $this->tables[$table_id]['settings']['tfoot'] = true;       
     338            $this->tables[$table_id]['settings']['tfoot'] = true;
     339       
     340        } else if ( array_key_exists('tfoot', $atts ) && "false" == $atts['tfoot'] ) {
     341            $this->tables[$table_id]['settings']['tfoot'] = false;     
    319342        }
    320343       
     
    337360         */
    338361        if ( array_key_exists('datatables', $atts ) && "true" == $atts['datatables'] ) {
    339             if ( array_key_exists('thead', $atts ) && "false" == $atts['thead'] ) {
     362            if (( array_key_exists('thead', $atts ) && "false" == $atts['thead'] ) || ( false == $this->tables[$table_id]['settings']['thead'] )) {
    340363                return "thead must also be set to true in order to use the Jquery Datatables.";
    341364            }
    342             $this->tables[$table_id]['settings']['datatables'] = true; 
     365            $this->tables[$table_id]['settings']['datatables'] = true;
     366   
     367        } else if ( array_key_exists('datatables', $atts ) && "false" == $atts['datatables'] ) {
     368            $this->tables[$table_id]['settings']['datatables'] = false;     
    343369        }
    344370       
     
    347373         */
    348374        if ( array_key_exists('rows', $atts ) && !empty( $atts['rows'] )) {
    349             if ( !array_key_exists('datatables', $atts ) || ( array_key_exists('datatables', $atts ) && "false" == $atts['datatables'] )) {
     375            if (( array_key_exists('datatables', $atts ) && "false" == $atts['datatables'] ) || ( false == $this->tables[$table_id]['settings']['datatables'] )) {
    350376                return "Datatables must also be enabled in order to adjust the number of rows.";
    351377            }
     
    357383         */
    358384        if ( array_key_exists('buttons', $atts ) && "true" == $atts['buttons'] ) {
    359             if ( !array_key_exists('datatables', $atts ) || ( array_key_exists('datatables', $atts ) && "false" == $atts['datatables'] )) {
     385            if (( array_key_exists('datatables', $atts ) && "false" == $atts['datatables'] ) || ( false == $this->tables[$table_id]['settings']['datatables'] )) {
    360386                return "Datatables must also be enabled in order to add the buttons.";
    361387            }
    362388            $this->tables[$table_id]['settings']['buttons'] = true;
    363         }
     389           
     390        } else if ( array_key_exists('buttons', $atts ) && "false" == $atts['buttons'] ) {
     391            $this->tables[$table_id]['settings']['buttons'] = false;       
     392        }
     393       
    364394
    365395        /*
     
    367397         */
    368398        if ( array_key_exists('button_list', $atts ) && !empty( $atts['button_list'] )) {
    369             if ( !array_key_exists('buttons', $atts ) || ( array_key_exists('buttons', $atts ) && "false" == $atts['buttons'] )) {
     399       
     400            if (( !array_key_exists('buttons', $atts ) || ( array_key_exists('buttons', $atts ) && "false" == $atts['buttons'] )) ||
     401                ( false == $this->tables[$table_id]['settings']['buttons'] )) {
    370402                return "Datatables must also be enabled in order to add the buttons.";
    371403            }
     
    378410
    379411        /*
     412         * Check the default_sort keyword (requires datatables = true, datatables could be set to true by a keyword or set to true in the default settings.)
     413         */
     414        if ( array_key_exists('default_sort', $atts ) ) {
     415       
     416            if (( array_key_exists('datatables', $atts ) && "false" == $atts['datatables'] ) || ( false == $this->tables[$table_id]['settings']['datatables'] )) {
     417                return "The \'default_sort\' keyword has no effect unless \'datatables\' is enabled.";
     418            }
     419           
     420            if ( "true" == $atts['default_sort'] ) {
     421                $this->tables[$table_id]['settings']['default_sort'] = true;
     422       
     423            } else if ( "false" == $atts['default_sort'] ) {
     424                $this->tables[$table_id]['settings']['default_sort'] = false;
     425            }
     426        }
     427       
     428        /*
    380429         * Check the nowrap keyword
    381430         */
     
    388437         */
    389438         
    390         if ( array_key_exists('new_window', $atts ) && "false" == $atts['new_window'] ) {
     439        if ( array_key_exists('new_window', $atts ) && "true" == $atts['new_window'] ) {
     440            $this->tables[$table_id]['settings']['new_window'] = true;     
     441           
     442        } else if ( array_key_exists('new_window', $atts ) && "false" == $atts['new_window'] ) {
    391443            $this->tables[$table_id]['settings']['new_window'] = false;     
    392444        }
     445       
    393446        /*
    394447         * Check the col_widths keyword
     
    434487            //$this->tables[$table_id]['sql'] = mysql_real_escape_string( $this->tables[$table_id]['sql'] );
    435488        }
    436 
     489//_logMaster( print_r( $this->tables[$table_id], true ));
    437490        return null;
    438491    }
     
    717770                );
    718771
     772                // By default, DataTables will sort the data alphabetically by column 1. If the user
     773                // does not want the data sorted that way, they must set default_sort="false".
     774                if ( ( false == $t['settings']['default_sort'] ) ) {
     775                    $datatable_options['aaSorting'] = '"aaSorting":[]'; // disables default sort by column 1
     776                }
     777               
    719778                if( true == $t['settings']['buttons'] ) {
    720779                    /* Need to set the button list based on what was entered witih the shortcode */
     
    727786                        $button_list = "[";
    728787                        foreach( $button_names as $button ) {
    729                             //$button_list .= "\'".$button."\', ";
    730788                            $button_list .= "'".$button."', ";
    731789                        }
     790                       
    732791                        $button_list = rtrim($button_list);
    733792                        $button_list = substr($button_list, 0, -1)."]";
Note: See TracChangeset for help on using the changeset viewer.