Plugin Directory

Changeset 1500694


Ignore:
Timestamp:
09/23/2016 12:55:14 AM (9 years ago)
Author:
crunnells
Message:

Added enable/disable comments and pings functionality

Location:
shopp-admin-extras/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • shopp-admin-extras/trunk/readme.txt

    r1137675 r1500694  
    33Tags: shopp, e-commerce
    44Requires at least: 3.1
    5 Tested up to: 4.1
    6 Stable tag: 1.0.1
     5Tested up to: 4.6.1
     6Stable tag: 1.1
    77License: GPLv2 or later
    88
    9 Adds navigation links on the Orders page and allows you to edit the order status inside the Order page.
     9Adds some extra functionality to the Shopp admin to make your life easier!
    1010
    1111== Description ==
    1212
    13 Adds navigation links on the Orders page and allows you to edit the order status inside the Order page.
     13This plugin tries to help with a few admin tasks that can be time consuming otherwise. It allows you to:
     14
     15* Navigate between pending orders easily
     16* Change the order status on the order page
     17* Enable/Disable Comments and Pings on all Shopp Products
     18
     19Got a feature you'd like to see added to this plugin? Let me know!
    1420
    1521== Installation ==
     
    1824
    1925== Changelog ==
     26
     27= 1.0.2 =
     28
     29* Added a page to enable or disable Comments and Pings for Shopp products. Find it under Shopp > Setup > Extras (Hopefully useful for more than just myself!)
    2030
    2131= 1.0.1 =
  • shopp-admin-extras/trunk/shopp-admin-extras.php

    r1137674 r1500694  
    22/*
    33Plugin Name: Shopp Admin Extras
    4 Plugin URI: 
    5 Description: Adds navigation links on the Orders page and allows you to edit the order status inside the Order page.
    6 Version: 1.0.1
     4Plugin URI:
     5Description: Adds navigation links on the Orders page and allows you to edit the order status inside the Order page. Also allows you to change the comment and ping status of all Shopp products.
     6Version: 1.1
    77Author: Chris Runnells
    88Author URI: http://chrisrunnells.com
     
    1010
    1111/*
    12 This program is free software; you can redistribute it and/or
    13 modify it under the terms of the GNU General Public License
    14 as published by the Free Software Foundation; either version 2
    15 of the License, or (at your option) any later version.
    16 
    17 This program is distributed in the hope that it will be useful,
    18 but WITHOUT ANY WARRANTY; without even the implied warranty of
    19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    20 GNU General Public License for more details.
    21 
    22 You should have received a copy of the GNU General Public License
    23 along with this program; if not, write to the Free Software
    24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     12    This program is free software; you can redistribute it and/or
     13    modify it under the terms of the GNU General Public License
     14    as published by the Free Software Foundation; either version 2
     15    of the License, or (at your option) any later version.
     16
     17    This program is distributed in the hope that it will be useful,
     18    but WITHOUT ANY WARRANTY; without even the implied warranty of
     19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20    GNU General Public License for more details.
     21
     22    You should have received a copy of the GNU General Public License
     23    along with this program; if not, write to the Free Software
     24    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    2525*/
    2626
    27 defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
    28 
    29 new ShoppAdminExtras();
     27defined( 'ABSPATH' ) or die( 'Nope!' );
    3028
    3129class ShoppAdminExtras {
    32 
    33     function __construct() {
     30    public $dir = '';
     31    public static $url = '';
     32
     33    public static function init () {
     34        add_action( 'plugins_loaded', array( __CLASS__, 'loader' ) );
     35    }
     36
     37    public static function loader () {
     38        if (defined('SHOPP_VERSION') and version_compare(SHOPP_VERSION, '1.2') >= 0)
     39            new ShoppAdminExtras;
     40    }
     41
     42    function __construct () {
     43
     44        if ( ! is_admin() ) return;
     45
     46        $this->dir = dirname(__FILE__);
     47        self::$url = WP_PLUGIN_URL.'/'.basename($this->dir);
     48
     49        require $this->dir.'/inc/admin.php';
     50
    3451        add_action( 'shopp_order_management_scripts', array( $this, 'save_order_status' ) );
    3552        add_action( 'shopp_order_admin_script', array( $this, 'order_number_navigation' ) );
    3653        add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
    3754        add_action( 'admin_init', array( $this, 'meta_box' ) );
    38     }
    39 
    40     function  meta_box() {
     55        add_filter( 'admin_menu', array( $this, 'register_setting_page'), 50);
     56    }
     57
     58    function  meta_box () {
    4159        add_meta_box( 'shopp_order_status', __( 'Order Status' ), array( $this, 'order_status_box' ), 'toplevel_page_shopp-orders', 'side', 'high' );
    4260    }
    4361
    44     function admin_styles() {
    45         $screen = get_current_screen();     
     62    function register_setting_page() {
     63        shopp_admin_add_submenu( 'Extras', 'shopp-admin-extras', 'shopp-setup',
     64            array( 'ShoppExtrasAdmin', 'controller' ), 'shopp_settings' );
     65    }
     66
     67    function admin_styles () {
     68        $screen = get_current_screen();
    4669        if ( 'toplevel_page_shopp-orders' != $screen->base ) return;
    4770
     
    5578
    5679    /* Prints the box content */
    57     function order_status_box() {
     80    function order_status_box () {
    5881
    5982        // snag the order status from the order object
     
    7396
    7497    }
    75    
     98
    7699    /* When the post is saved, saves our custom data */
    77     function save_order_status() {
    78         if ( ! current_user_can('shopp_products') ) return; 
     100    function save_order_status () {
     101        if ( ! current_user_can('shopp_products') ) return;
    79102
    80103        // Check if the user intended to change this value.
     
    91114
    92115    }
    93    
    94    
     116
     117
    95118    // check the current order number, and return the next and previous order numbers
    96     function order_number_navigation () {   
     119    function order_number_navigation () {
    97120        // We'll have to inject the links via JS since there aren't any easy hooks to insert content with
    98121        $prevlink = '';
     
    109132        if ( ! empty( $prev ) ) {
    110133            $prevurl = add_query_arg('id',$prev,$url);
    111             $prevlink = '<a href="'. esc_url($prevurl) . '" title="View Order #' . $prev . '" class="prevlink">&laquo; Previous Order #'. $prev .'</a> ';
     134            $prevlink = '<a href="'. esc_url($prevurl) . '" title="' . __( 'View Order', 'shopp-admin-extras' ) . ' #' . $prev . '" class="prevlink">&laquo; ' . __( 'Previous Order', 'shopp-admin-extras' ) . ' #'. $prev .'</a> ';
    112135        }
    113136
    114137        if ( ! empty( $next ) ) {
    115138            $nexturl = add_query_arg('id',$next,$url);
    116             $nextlink = ' <a href="'. esc_url($nexturl) . '" title="View Order #' . $next . '" class="nextlink">Next Order #'. $next .' &raquo;</a>';
     139            $nextlink = ' <a href="'. esc_url($nexturl) . '" title="' . __( 'View Order', 'shopp-admin-extras' ) . ' #' . $next . '" class="nextlink">' . __( 'Next Order', 'shopp-admin-extras' ) . ' #'. $next .' &raquo;</a>';
    117140        }
    118141
     
    134157
    135158        return $next_id;
    136    }
    137 
    138     function prev_order_number (){
     159    }
     160
     161    function prev_order_number () {
    139162        global $wpdb;
    140163
     
    148171
    149172        return $prev_id;
    150    }
     173    }
     174
     175    // Updates comment and ping statuses for Shopp products
     176    function change_status () {
     177
     178        $shopp_comments = $_POST['shopp_comments'];
     179        $shopp_pings = $_POST['shopp_pings'];
     180
     181        $changes = array();
     182
     183        if ( 'Enable' == $shopp_comments ){
     184            $changes[] = 'comment_status = "open"';
     185        } else if ( 'Disable' == $shopp_comments ) {
     186            $changes[] = 'comment_status = "closed"';
     187        }
     188
     189        if ( 'Enable' == $shopp_pings ){
     190            $changes[] = 'ping_status = "open"';
     191        } else if ( 'Disable' == $shopp_pings ) {
     192            $changes[] = 'ping_status = "closed"';
     193        }
     194
     195        if ( ! empty( $changes ) ){
     196            global $wpdb;
     197
     198            $change_status = implode(', ', $changes);
     199
     200            $product_table = WPDatabaseObject::tablename(ShoppProduct::$table);
     201            $query = "UPDATE $product_table SET $change_status WHERE post_type = \"shopp_product\"";
     202            $result = $wpdb->query( $query );
     203            return $result;
     204        } else {
     205            return;
     206        }
     207
     208    }
    151209
    152210} // end Class
     211
     212ShoppAdminExtras::init();
Note: See TracChangeset for help on using the changeset viewer.