Changeset 1500694
- Timestamp:
- 09/23/2016 12:55:14 AM (9 years ago)
- Location:
- shopp-admin-extras/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
shopp-admin-extras.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shopp-admin-extras/trunk/readme.txt
r1137675 r1500694 3 3 Tags: shopp, e-commerce 4 4 Requires at least: 3.1 5 Tested up to: 4. 16 Stable tag: 1. 0.15 Tested up to: 4.6.1 6 Stable tag: 1.1 7 7 License: GPLv2 or later 8 8 9 Adds navigation links on the Orders page and allows you to edit the order status inside the Order page.9 Adds some extra functionality to the Shopp admin to make your life easier! 10 10 11 11 == Description == 12 12 13 Adds navigation links on the Orders page and allows you to edit the order status inside the Order page. 13 This 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 19 Got a feature you'd like to see added to this plugin? Let me know! 14 20 15 21 == Installation == … … 18 24 19 25 == 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!) 20 30 21 31 = 1.0.1 = -
shopp-admin-extras/trunk/shopp-admin-extras.php
r1137674 r1500694 2 2 /* 3 3 Plugin 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.14 Plugin URI: 5 Description: 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. 6 Version: 1.1 7 7 Author: Chris Runnells 8 8 Author URI: http://chrisrunnells.com … … 10 10 11 11 /* 12 This program is free software; you can redistribute it and/or13 modify it under the terms of the GNU General Public License14 as published by the Free Software Foundation; either version 215 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 of19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20 GNU General Public License for more details.21 22 You should have received a copy of the GNU General Public License23 along with this program; if not, write to the Free Software24 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. 25 25 */ 26 26 27 defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); 28 29 new ShoppAdminExtras(); 27 defined( 'ABSPATH' ) or die( 'Nope!' ); 30 28 31 29 class 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 34 51 add_action( 'shopp_order_management_scripts', array( $this, 'save_order_status' ) ); 35 52 add_action( 'shopp_order_admin_script', array( $this, 'order_number_navigation' ) ); 36 53 add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) ); 37 54 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 () { 41 59 add_meta_box( 'shopp_order_status', __( 'Order Status' ), array( $this, 'order_status_box' ), 'toplevel_page_shopp-orders', 'side', 'high' ); 42 60 } 43 61 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(); 46 69 if ( 'toplevel_page_shopp-orders' != $screen->base ) return; 47 70 … … 55 78 56 79 /* Prints the box content */ 57 function order_status_box () {80 function order_status_box () { 58 81 59 82 // snag the order status from the order object … … 73 96 74 97 } 75 98 76 99 /* 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; 79 102 80 103 // Check if the user intended to change this value. … … 91 114 92 115 } 93 94 116 117 95 118 // check the current order number, and return the next and previous order numbers 96 function order_number_navigation () { 119 function order_number_navigation () { 97 120 // We'll have to inject the links via JS since there aren't any easy hooks to insert content with 98 121 $prevlink = ''; … … 109 132 if ( ! empty( $prev ) ) { 110 133 $prevurl = add_query_arg('id',$prev,$url); 111 $prevlink = '<a href="'. esc_url($prevurl) . '" title=" View Order #' . $prev . '" class="prevlink">« Previous Order#'. $prev .'</a> ';134 $prevlink = '<a href="'. esc_url($prevurl) . '" title="' . __( 'View Order', 'shopp-admin-extras' ) . ' #' . $prev . '" class="prevlink">« ' . __( 'Previous Order', 'shopp-admin-extras' ) . ' #'. $prev .'</a> '; 112 135 } 113 136 114 137 if ( ! empty( $next ) ) { 115 138 $nexturl = add_query_arg('id',$next,$url); 116 $nextlink = ' <a href="'. esc_url($nexturl) . '" title=" View Order #' . $next . '" class="nextlink">Next Order#'. $next .' »</a>';139 $nextlink = ' <a href="'. esc_url($nexturl) . '" title="' . __( 'View Order', 'shopp-admin-extras' ) . ' #' . $next . '" class="nextlink">' . __( 'Next Order', 'shopp-admin-extras' ) . ' #'. $next .' »</a>'; 117 140 } 118 141 … … 134 157 135 158 return $next_id; 136 }137 138 function prev_order_number () {159 } 160 161 function prev_order_number () { 139 162 global $wpdb; 140 163 … … 148 171 149 172 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 } 151 209 152 210 } // end Class 211 212 ShoppAdminExtras::init();
Note: See TracChangeset
for help on using the changeset viewer.