Changeset 2137995
- Timestamp:
- 08/12/2019 09:57:39 AM (7 years ago)
- Location:
- edd-hideshow-product/trunk
- Files:
-
- 3 edited
-
hide_show_edd_downloads.php (modified) (9 diffs)
-
readme.txt (modified) (3 diffs)
-
scripts/hsedd_admin_edit.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
edd-hideshow-product/trunk/hide_show_edd_downloads.php
r2084158 r2137995 12 12 * Plugin URI: https://marketools.io 13 13 * Description: Easily hide/show your Easy Digital Downloads product/download from the frontend display with just a click. 14 * Version: 1.0. 014 * Version: 1.0.1 15 15 * Author: marketools10 16 16 * Author URI: https://profiles.wordpress.org/marketools10/ … … 117 117 $args = array( 118 118 'post_type' => 'download', 119 'meta_key' => '_hsedd_meta_box_check_produk', 119 'meta_query' => array( 120 array( 121 'key' => '_hsedd_meta_box_check_produk', 122 'value' => 1, 123 'compare' => '=', 124 ), 125 ), 120 126 'posts_per_page' => -1, 121 127 ); 122 128 123 129 $downloads = get_posts( $args ); 124 125 130 $hidden_downloads = array(); 126 131 127 132 if ( $downloads ) { 128 133 foreach ( $downloads as $download ) { 134 129 135 $hidden_downloads[] = $download->ID; 130 136 } … … 146 152 function hsedd_columns($download_columns) 147 153 { 154 hsedd_query_hidden_downloads(); 148 155 $download_columns = array_merge( 149 156 $download_columns, array( 150 ' hsedd_meta_box_check_produk' => __('Hide/Show EDD Download', 'easy-digital-downloads')157 '_hsedd_meta_box_check_produk' => __('Hide/Show EDD Download', 'easy-digital-downloads') 151 158 )); 152 159 … … 157 164 function hsedd_column_content($column_name, $post_id) 158 165 { 159 if (' hsedd_meta_box_check_produk' != $column_name)166 if ('_hsedd_meta_box_check_produk' != $column_name) 160 167 return; 161 168 //Get number of slices from post meta 162 $hsedd_meta_box_check_produk = get_post_meta($post_id, 'hsedd_meta_box_check_produk', true);169 $hsedd_meta_box_check_produk = (boolean) get_post_meta( $post_id, '_hsedd_meta_box_check_produk', true ); 163 170 $check = "Show Product"; 164 171 if (isset($hsedd_meta_box_check_produk)) { 165 if ($hsedd_meta_box_check_produk == 'on') {172 if ($hsedd_meta_box_check_produk) { 166 173 $check = "Hide Product"; 167 174 } … … 174 181 function sortable_hsedd_column($columns) 175 182 { 176 $columns[' hsedd_meta_box_check_produk'] = 'hsedd_meta_box_check_produk';183 $columns['_hsedd_meta_box_check_produk'] = '_hsedd_meta_box_check_produk'; 177 184 178 185 //To make a column 'un-sortable' remove it from the array … … 190 197 * @return void 191 198 */ 192 function edd_price_field_quick_edit_hsedd($column_name, $post_type) 193 { 194 if ($column_name != 'hsedd_meta_box_check_produk' || $post_type != 'download') return; 199 function hsedd_price_field_quick_edit($column_name, $post_type) 200 { 201 global $post; 202 if ($column_name != '_hsedd_meta_box_check_produk' || $post_type != 'download') return; 195 203 // We'll use this nonce field later on when saving. 196 wp_nonce_field('meta_box_nonce_hsedd', 'hsedd_meta_box_nonce');204 $checked = (boolean) get_post_meta( $post->ID, '_hsedd_meta_box_check_produk', true ); 197 205 ?> 198 206 <fieldset class="inline-edit-col-left"> … … 202 210 <span class="title"><?php _e('Hide Product', 'easy-digital-downloads'); ?></span> 203 211 <span class="input-text-wrap"> 204 <input type="checkbox" name="hsedd_meta_box_check_produk" class="hsedd-meta_box_check_produk"/> 212 <input type="checkbox" name="_hsedd_meta_box_check_produk" 213 value="1" <?php checked( true, $checked ); ?> class="hsedd-meta_box_check_produk"/> 205 214 </span> 206 215 </label> … … 211 220 } 212 221 213 add_action('quick_edit_custom_box', ' edd_price_field_quick_edit_hsedd', 10, 2);214 add_action('bulk_edit_custom_box', ' edd_price_field_quick_edit_hsedd', 10, 2);222 add_action('quick_edit_custom_box', 'hsedd_price_field_quick_edit', 10, 2); 223 add_action('bulk_edit_custom_box', 'hsedd_price_field_quick_edit', 10, 2); 215 224 216 225 add_action('admin_enqueue_scripts', 'misha_enqueue_quick_edit_population'); … … 232 241 // get our variables 233 242 $post_ids = (isset($_POST['post_ids']) && !empty($_POST['post_ids'])) ? $_POST['post_ids'] : array(); 234 $hide_product = (isset($_POST['hide_product']) && !empty($_POST['hide_product'])) ? 'on' : 'off'; 243 235 244 // if everything is in order 236 if (!empty($post_ids) && is_array($post_ids) && !empty($hide_product)) {245 if (!empty($post_ids) && is_array($post_ids)) { 237 246 foreach ($post_ids as $post_id) { 238 update_post_meta($post_id, 'hsedd_meta_box_check_produk', $hide_product); 239 } 240 } 241 } 247 delete_post_meta($post_id,"_hsedd_meta_box_check_produk"); 248 if(isset($_POST['hide_product'])){ 249 update_post_meta($post_id, '_hsedd_meta_box_check_produk', 1); 250 } 251 252 253 } 254 } 255 } 256 257 /** 258 * Save quick edit data 259 * 260 * @param int $post_id 261 * 262 * @return void|int 263 */ 264 function hsedd_save_quick_edit_data( $post_id ) { 265 if ( ! isset( $_POST['post_type']) || 'download' !== $_POST['post_type'] ) return; 266 if ( ! current_user_can( 'edit_post', $post_id ) ) return $post_id; 267 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id; 268 269 delete_post_meta($post_id,"_hsedd_meta_box_check_produk"); 270 if(isset( $_REQUEST['_hsedd_meta_box_check_produk'] )){ 271 update_post_meta( $post_id, '_hsedd_meta_box_check_produk', 1); 272 } 273 } 274 add_action( 'save_post', 'hsedd_save_quick_edit_data' ); -
edd-hideshow-product/trunk/readme.txt
r2084173 r2137995 6 6 Tested up to: 5.2 7 7 Requires PHP: 5.4 8 Stable tag: 1.0. 08 Stable tag: 1.0.1 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 39 39 == Changelog == 40 40 41 = 1.0.1 = 42 * Fix quick edit and bulk edit 43 41 44 = 1.0.0 = 42 45 * Initial release … … 44 47 == Upgrade Notice == 45 48 49 = 1.0.1 = 50 Version 1.0.1 is fix quick edit and bulk edit. 51 46 52 = 1.0.0 = 47 53 Version 1.0.0 is a recommended update for performance improvements. -
edd-hideshow-product/trunk/scripts/hsedd_admin_edit.js
r2081893 r2137995 25 25 26 26 // get the data 27 var $hsedd_meta_box_check_produk = $post_row.find('.column-hsedd_meta_box_check_produk .hsedd_meta_box_check_produk-' + $post_id).val(); 27 var $hsedd_meta_box_check_produk = $post_row.find('.column-_hsedd_meta_box_check_produk' + 28 ' .hsedd_meta_box_check_produk-' + $post_id).val(); 29 28 30 // Hide Show Product data 29 31 $edit_row.find('.hsedd-meta_box_check_produk').prop('checked', false); 30 if ($hsedd_meta_box_check_produk == " on") {32 if ($hsedd_meta_box_check_produk == "1") { 31 33 $edit_row.find('.hsedd-meta_box_check_produk').prop('checked', true); 32 34 } … … 43 45 }); 44 46 // get the release date 45 var $hide_product = $bulk_row.find('.hsedd-meta_box_check_produk').prop('checked'); 47 // var $hide_product = $bulk_row.find('.hsedd-meta_box_check_produk').prop('checked'); 48 var $hide_product = $bulk_row.find('.hsedd-meta_box_check_produk:checked').val(); 49 // var $hide_product = $('#edd-download-data input[name="_hsedd-meta_box_check_produk"]:checked').val(); 46 50 // save the data 47 51 $.ajax({
Note: See TracChangeset
for help on using the changeset viewer.