Plugin Directory

Changeset 1201891


Ignore:
Timestamp:
07/19/2015 11:23:03 AM (11 years ago)
Author:
krozero199
Message:

db table upgrade and form bug fixes

Location:
wp-custom-widget-area/trunk
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • wp-custom-widget-area/trunk/README.txt

    r1201275 r1201891  
    44Requires at least: 3.0.1
    55Tested up to: 4.2.2
    6 Stable tag: 1.1.3
     6Stable tag: 1.1.4
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7373== Changelog ==
    7474
     75= 1.1.4 =
     76* database table upgrade bug fix
     77* form and js bug fix
     78
    7579= 1.1.3 =
    7680* widget area bug fix
     
    109113== Upgrade Notice ==
    110114
     115= 1.1.4 =
     116* database table upgrade bug fix
     117* form and js bug fix
     118
    111119= 1.1.3 =
    112120* widget area bug fix
  • wp-custom-widget-area/trunk/admin/class-wp-custom-widget-area-admin.php

    r1201274 r1201891  
    55 *
    66 * @link       http://example.com
    7  * @since      1.1.3
     7 * @since      1.1.4
    88 *
    99 * @package    Custom_Widget_Area
     
    3030     * The ID of this plugin.
    3131     *
    32      * @since    1.1.3
     32     * @since    1.1.4
    3333     * @access   private
    3434     * @var      string    $plugin_name    The ID of this plugin.
     
    3939     * The version of this plugin.
    4040     *
    41      * @since    1.1.3
     41     * @since    1.1.4
    4242     * @access   private
    4343     * @var      string    $version    The current version of this plugin.
     
    4848     * Initialize the class and set its properties.
    4949     *
    50      * @since    1.1.3
     50     * @since    1.1.4
    5151     * @var      string    $plugin_name       The name of this plugin.
    5252     * @var      string    $version    The version of this plugin.
     
    6565    public function menu_setup(){
    6666       
    67         add_menu_page('CWA Settings', 'CWA Settings', 'administrator', 'custom_widget_area',    array($this->view, 'cwa_settings_page'),''/*plugins_url('/images/icon.png', __FILE__)*/);
    68         add_submenu_page( 'custom_widget_area', 'Custom Widget Area', 'Custom Widget Area', 'administrator', 'custom_widget_area', array($this->view, 'cwa_settings_page') );
    69         add_submenu_page( 'custom_widget_area', 'Menu Locations', 'Menu Locations', 'administrator', 'custom_menu_location', array($this->menuView, 'menu_settings_page') );
     67        add_menu_page('CWA Settings', 'CWA Settings', 'administrator', 'custom_widget_area',    array($this->view, 'displayView'),''/*plugins_url('/images/icon.png', __FILE__)*/);
     68        add_submenu_page( 'custom_widget_area', 'Custom Widget Area', 'Custom Widget Area', 'administrator', 'custom_widget_area', array($this->view, 'displayView') );
     69        add_submenu_page( 'custom_widget_area', 'Menu Locations', 'Menu Locations', 'administrator', 'custom_menu_location', array($this->menuView, 'displayView') );
    7070        add_submenu_page( 'custom_widget_area', 'Help', 'Help', 'manage_options', 'cwa_help', 'help_page');
    7171        //self::setuo_ajax_request();       
     
    150150        $valid = self::checSpecialChar($cwa_id);
    151151       
    152         if($valid){
     152        if($valid && !empty($cwa_id)){
    153153
    154154            $sql = "SELECT * FROM $this->table_name WHERE cwa_id='$cwa_id' AND cwa_type='widget'";
     
    170170                    return true;   
    171171            }   
     172        }
     173        elseif (empty($cwa_id)) {
     174            # code...
     175            if(empty($id)){
     176                wp_send_json(array('code' => 0, 'message' => 'Please enter a Widget id '));
     177            }
     178            else{
     179                return false;
     180            }
    172181        }
    173182        else{
     
    279288        $valid = self::checSpecialChar($cwa_id);
    280289       
    281         if($valid){
     290        if($valid && !empty($cwa_id)){
    282291
    283292            $sql = "SELECT * FROM $this->table_name WHERE cwa_id='$cwa_id' AND cwa_type='menu'";
     
    285294           
    286295            $row = $wpdb->get_row( $sql, 'OBJECT');
    287            
     296            //wp_send_json(!!$cwa_id);die();
    288297            if(empty($id)){
    289298                if($row)
     
    300309            }   
    301310        }
     311        elseif(empty($cwa_id)){
     312            if(empty($id)){
     313                wp_send_json(array('code' => 0, 'message' => 'Please enter a Menu Location id'));
     314            }
     315            else{
     316                return false;
     317            }
     318        }
    302319        else{
    303320            if(empty($id)){
     
    308325            }
    309326        }
     327        die;
    310328    }
    311329    public function get_menu(){
     
    349367    }
    350368    public function checSpecialChar($string){
    351         if(!preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬]/', $string)){
     369        if(!preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬ ]/', $string)){
    352370            return true;
    353371        }
     
    359377     * Register the stylesheets for the Dashboard.
    360378     *
    361      * @since    1.1.3
     379     * @since    1.1.4
    362380     */
    363381    public function enqueue_styles() {
     
    382400     * Register the JavaScript for the dashboard.
    383401     *
    384      * @since    1.1.3
     402     * @since    1.1.4
    385403     */
    386404    public function enqueue_scripts() {
  • wp-custom-widget-area/trunk/admin/css/wp-custom-widget-area-admin.css

    r1201274 r1201891  
    161161 }
    162162 .tabs{
    163     margin-bottom: 0;
     163    margin-bottom: -1px;
    164164 }
    165165 .tabs li a{
     
    196196    min-width:  500px;
    197197}
    198 
     198.no-data{
     199    color: #999;
     200}
  • wp-custom-widget-area/trunk/admin/js/wp-custom-widget-area-admin.js

    r1201274 r1201891  
    1 
    2 
    3 
    4 
    5 
    6 
    71(function( $ ) {
    82    'use strict';
     
    7266               
    7367        });
    74         $('#cwa-form input[name=cwa_id]').on('change', function(){
     68        $('#cwa-form input[name=cwa_id]').on('keyup', function(){
    7569            var self = this;
    76             checkId(self, $(self).val());
     70            checkId(self, $(self).val(), 'widget');
    7771        });
    7872       
     
    150144        });
    151145
    152 
     146        $('#cwa-menu-form input[name=cwa_id]').on('keyup', function(){
     147            console.log("hey");
     148            var self = this;
     149            checkId(self, $(self).val(), 'menu');
     150        });
    153151       
    154152
     
    182180                }
    183181
    184                 //console.log(data);
     182                console.log(data);
    185183             });
    186184    };
     
    213211    function resetForm(){
    214212        $('.cwa-form input[type="text"]' ).val('');
    215         $('.cwa-form  cwa-form-message' ).empty();
     213        $('.cwa-form  .cwa-form-message' ).empty();
    216214    }
    217215    function runTooltip(){
  • wp-custom-widget-area/trunk/admin/partials/cwa-admin-display.php

    r1201274 r1201891  
    77 *
    88 * @link       http://example.com
    9  * @since      1.1.3
     9 * @since      1.1.4
    1010 *
    1111 * @package    Custom_Widget_Area
     
    2222        # code...
    2323    }
    24     public function cwa_settings_page(){
    25         add_action( 'add_meta_boxes', self::displayView());
    26     }
     24   
    2725    public function displayView(){
    2826
     
    144142                <?php
    145143                $count = 1;
     144                if(empty($data)){
     145                    ?>
     146                    <tr>
     147                        <td colspan="8" class="no-data">There is no data. create a new Widget area by filling above form.</td>
     148                    </tr>
     149                    <?php
     150                }
    146151                foreach ($data as $table) {
    147152                    # code...
  • wp-custom-widget-area/trunk/admin/partials/cwa-menu-admin-display.php

    r1201274 r1201891  
    77 *
    88 * @link       http://example.com
    9  * @since      1.1.3
     9 * @since      1.1.4
    1010 *
    1111 * @package    Custom_Widget_Area
     
    2222        # code...
    2323    }
    24     public function menu_settings_page(){
    25         add_action( 'add_meta_boxes', self::displayView());
    26     }
     24   
    2725    public function displayView(){
    2826
     
    104102                <?php
    105103                $count = 1;
     104                if(empty($data)){
     105                    ?>
     106                    <tr>
     107                        <td colspan="8" class="no-data">There is no data. create a new Menu location by filling above form.</td>
     108                    </tr>
     109                    <?php
     110                }
    106111                foreach ($data as $table) {
    107112                    # code...
  • wp-custom-widget-area/trunk/includes/class-custom-widget-area.php

    r1201274 r1201891  
    88 *
    99 * @link       http://example.com
    10  * @since      1.1.3
     10 * @since      1.1.4
    1111 *
    1212 * @package    Custom_Widget_Area
     
    2323 * version of the plugin.
    2424 *
    25  * @since      1.1.3
     25 * @since      1.1.4
    2626 * @package    Custom_Widget_Area
    2727 * @subpackage Custom_Widget_Area/includes
     
    3434     * the plugin.
    3535     *
    36      * @since    1.1.3
     36     * @since    1.1.4
    3737     * @access   protected
    3838     * @var      Custom_Widget_Area_Loader    $loader    Maintains and registers all hooks for the plugin.
     
    4343     * The unique identifier of this plugin.
    4444     *
    45      * @since    1.1.3
     45     * @since    1.1.4
    4646     * @access   protected
    4747     * @var      string    $plugin_name    The string used to uniquely identify this plugin.
     
    5252     * The current version of the plugin.
    5353     *
    54      * @since    1.1.3
     54     * @since    1.1.4
    5555     * @access   protected
    5656     * @var      string    $version    The current version of the plugin.
     
    6565     * the public-facing side of the site.
    6666     *
    67      * @since    1.1.3
     67     * @since    1.1.4
    6868     */
    6969    public function __construct() {
    7070
    7171        $this->plugin_name = 'wp-custom-widget-area';
    72         $this->version = '1.1.3';
     72        $this->version = '1.1.4';
    7373
    7474        $this->load_dependencies();
     
    9292     * with WordPress.
    9393     *
    94      * @since    1.1.3
     94     * @since    1.1.4
    9595     * @access   private
    9696     */
     
    126126     * with WordPress.
    127127     *
    128      * @since    1.1.3
     128     * @since    1.1.4
    129129     * @access   private
    130130     */
     
    142142     * of the plugin.
    143143     *
    144      * @since    1.1.3
     144     * @since    1.1.4
    145145     * @access   private
    146146     */
     
    189189     * Run the loader to execute all of the hooks with WordPress.
    190190     *
    191      * @since    1.1.3
     191     * @since    1.1.4
    192192     */
    193193    public function run() {
     
    199199     * WordPress and to define internationalization functionality.
    200200     *
    201      * @since     1.1.3
     201     * @since     1.1.4
    202202     * @return    string    The name of the plugin.
    203203     */
     
    209209     * The reference to the class that orchestrates the hooks with the plugin.
    210210     *
    211      * @since     1.1.3
     211     * @since     1.1.4
    212212     * @return    Custom_Widget_Area_Loader    Orchestrates the hooks of the plugin.
    213213     */
     
    219219     * Retrieve the version number of the plugin.
    220220     *
    221      * @since     1.1.3
     221     * @since     1.1.4
    222222     * @return    string    The version number of the plugin.
    223223     */
  • wp-custom-widget-area/trunk/includes/class-wp-custom-widget-area-activator.php

    r1201274 r1201891  
    55 *
    66 * @link       http://example.com
    7  * @since      1.1.3
     7 * @since      1.1.4
    88 *
    99 * @package    Custom_Widget_Area
     
    1616 * This class defines all code necessary to run during the plugin's activation.
    1717 *
    18  * @since      1.1.3
     18 * @since      1.1.4
    1919 * @package    Custom_Widget_Area
    2020 * @subpackage Custom_Widget_Area/includes
     
    2828     * Long Description.
    2929     *
    30      * @since    1.1.3
     30     * @since    1.1.4
    3131     */
    3232    public static function activate() {
    3333
    34         self::install_db();
    35 
    36     }
    37 
    38     private function install_db(){
    39         global $wpdb, $kz_db_version, $table_name, $charset_collate;
     34        global $wpdb;
     35        $kz_db_version = '1.1.4';
     36        $table_name = $wpdb->prefix . 'cwa';
     37        $charset_collate = '';
    4038
    4139        if ( ! empty( $wpdb->charset ) ) {
     
    6967            add_option( 'kz_db_version', $kz_db_version );
    7068        }
     69
    7170    }
    7271
     72
    7373}
  • wp-custom-widget-area/trunk/includes/class-wp-custom-widget-area-deactivator.php

    r1201274 r1201891  
    55 *
    66 * @link       http://example.com
    7  * @since      1.1.3
     7 * @since      1.1.4
    88 *
    99 * @package    Custom_Widget_Area
     
    1616 * This class defines all code necessary to run during the plugin's deactivation.
    1717 *
    18  * @since      1.1.3
     18 * @since      1.1.4
    1919 * @package    Custom_Widget_Area
    2020 * @subpackage Custom_Widget_Area/includes
     
    2828     * Long Description.
    2929     *
    30      * @since    1.1.3
     30     * @since    1.1.4
    3131     */
    3232    public static function deactivate() {
  • wp-custom-widget-area/trunk/includes/class-wp-custom-widget-area-i18n.php

    r1201274 r1201891  
    88 *
    99 * @link       http://example.com
    10  * @since      1.1.3
     10 * @since      1.1.4
    1111 *
    1212 * @package    Custom_Widget_Area
     
    2020 * so that its ready for translation.
    2121 *
    22  * @since      1.1.3
     22 * @since      1.1.4
    2323 * @package    Custom_Widget_Area
    2424 * @subpackage Custom_Widget_Area/includes
     
    3030     * The domain specified for this plugin.
    3131     *
    32      * @since    1.1.3
     32     * @since    1.1.4
    3333     * @access   private
    3434     * @var      string    $domain    The domain identifier for this plugin.
     
    3939     * Load the plugin text domain for translation.
    4040     *
    41      * @since    1.1.3
     41     * @since    1.1.4
    4242     */
    4343    public function load_plugin_textdomain() {
     
    5454     * Set the domain equal to that of the specified domain.
    5555     *
    56      * @since    1.1.3
     56     * @since    1.1.4
    5757     * @param    string    $domain    The domain that represents the locale of this plugin.
    5858     */
  • wp-custom-widget-area/trunk/includes/class-wp-custom-widget-area-loader.php

    r1201274 r1201891  
    55 *
    66 * @link       http://example.com
    7  * @since      1.1.3
     7 * @since      1.1.4
    88 *
    99 * @package    Custom_Widget_Area
     
    2727     * The array of actions registered with WordPress.
    2828     *
    29      * @since    1.1.3
     29     * @since    1.1.4
    3030     * @access   protected
    3131     * @var      array    $actions    The actions registered with WordPress to fire when the plugin loads.
     
    3636     * The array of filters registered with WordPress.
    3737     *
    38      * @since    1.1.3
     38     * @since    1.1.4
    3939     * @access   protected
    4040     * @var      array    $filters    The filters registered with WordPress to fire when the plugin loads.
     
    4545     * Initialize the collections used to maintain the actions and filters.
    4646     *
    47      * @since    1.1.3
     47     * @since    1.1.4
    4848     */
    4949    public function __construct() {
     
    5757     * Add a new action to the collection to be registered with WordPress.
    5858     *
    59      * @since    1.1.3
     59     * @since    1.1.4
    6060     * @var      string               $hook             The name of the WordPress action that is being registered.
    6161     * @var      object               $component        A reference to the instance of the object on which the action is defined.
     
    7171     * Add a new filter to the collection to be registered with WordPress.
    7272     *
    73      * @since    1.1.3
     73     * @since    1.1.4
    7474     * @var      string               $hook             The name of the WordPress filter that is being registered.
    7575     * @var      object               $component        A reference to the instance of the object on which the filter is defined.
     
    8686     * collection.
    8787     *
    88      * @since    1.1.3
     88     * @since    1.1.4
    8989     * @access   private
    9090     * @var      array                $hooks            The collection of hooks that is being registered (that is, actions or filters).
     
    113113     * Register the filters and actions with WordPress.
    114114     *
    115      * @since    1.1.3
     115     * @since    1.1.4
    116116     */
    117117    public function run() {
  • wp-custom-widget-area/trunk/includes/config.php

    r1201274 r1201891  
    11<?php
    22/*plugin configs*/
    3 $kz_db_version = '1.1.3';
     3global $wpdb;
     4$kz_db_version = '1.1.4';
    45$table_name = $wpdb->prefix . 'cwa';
    56$charset_collate = '';
  • wp-custom-widget-area/trunk/uninstall.php

    r1201274 r1201891  
    2121 *
    2222 * @link       http://example.com
    23  * @since      1.1.3
     23 * @since      1.1.4
    2424 *
    2525 * @package    Custom_Widget_Area
  • wp-custom-widget-area/trunk/wp-custom-widget-area.php

    r1201274 r1201891  
    1717 * Plugin URI:        http://kishorkhambu.com.np/plugins/
    1818 * Description:       A wordpress plugin to create custom dynamic widget area.
    19  * Version:           1.1.3
     19 * Version:           1.1.4
    2020 * Author:            Kishor Khambu
    2121 * Author URI:        http://kishorkhambu.com.np
     
    6666 * not affect the page life cycle.
    6767 *
    68  * @since    1.1.3
     68 * @since    1.1.4
    6969 */
    7070function run_plugin_name() {
     
    7373
    7474}
    75 run_plugin_name();
     75
    7676
    7777function cb(){
     
    8080
    8181
    82 // db fix for new version
    83 /*function db_update(){
    84     global $wpdb;
    85     $table_name = 'wp_cwa';
    86     if( (phpversion() < 5.4 && !!! session_id()) || (phpversion() > 5.3 && !!!session_status() == PHP_SESSION_NONE))
    87         session_start();
    88 
    89     if(!isset($_SESSION['db_update'])){
    90         $row = $wpdb->get_results(  "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
    91         WHERE table_name = '$table_name' AND column_name = 'cwa_type'"  );
    92        
    93         if(empty($row)){
    94            $wpdb->query("ALTER TABLE $table_name ADD cwa_type varchar (10) ");
    95            $updaterow = $wpdb->get_results(  "SELECT id FROM $table_name");
    96            foreach ($updaterow as $data) {
    97             # code...
    98             $up = $wpdb->update($table_name, array('cwa_type'=> 'widget'), array('id'=>$data->id));
    99            }
    100         }
    101         $_SESSION['db_update'] = true;
    102     }
    103    
    104 }
    105 
    106 db_update();*/
    107 
    10882
    10983function myplugin_update_db_check() {
    11084    global $kz_db_version, $wpdb, $table_name;
     85    $current_version = get_site_option( 'kz_db_version' );
     86    //update_site_option('kz_db_version', '1.0.4'); exit;
     87   // var_dump($table_name); exit;
    11188    if ( get_site_option( 'kz_db_version' ) != $kz_db_version ) {
    11289        Custom_Widget_Area_Activator::activate();
    113        $x = $wpdb->query("ALTER TABLE $table_name ADD cwa_type varchar (10) ");
    114        $updaterow = $wpdb->get_results(  "SELECT id FROM $table_name");
    115        foreach ($updaterow as $data) {
    116             # code...
    117             $up = $wpdb->update($table_name, array('cwa_type'=> 'widget'), array('id'=>$data->id));
    118         }
     90       if(!!$current_version && $current_version < '1.1.0'){
     91            $row = $wpdb->get_results(  "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '$table_name' AND column_name = 'cwa_type'"  );
     92            if(empty($row)){
     93                $x = $wpdb->query("ALTER TABLE $table_name ADD cwa_type varchar (10) ");
     94               $updaterow = $wpdb->get_results(  "SELECT id FROM $table_name");
     95               foreach ($updaterow as $data) {
     96                    # code...
     97                    $up = $wpdb->update($table_name, array('cwa_type'=> 'widget'), array('id'=>$data->id));
     98                }
     99            }
     100           
     101       }
     102       
    119103    }
     104
     105    run_plugin_name();
    120106}
    121107add_action( 'plugins_loaded', 'myplugin_update_db_check' );
Note: See TracChangeset for help on using the changeset viewer.