Plugin Directory

Changeset 2137995


Ignore:
Timestamp:
08/12/2019 09:57:39 AM (7 years ago)
Author:
marketools10
Message:

fix quick edit and bulk edit

Location:
edd-hideshow-product/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • edd-hideshow-product/trunk/hide_show_edd_downloads.php

    r2084158 r2137995  
    1212 * Plugin URI:        https://marketools.io
    1313 * Description:      Easily hide/show your Easy Digital Downloads product/download from the frontend display with just a click.
    14  * Version:           1.0.0
     14 * Version:           1.0.1
    1515 * Author:            marketools10
    1616 * Author URI:        https://profiles.wordpress.org/marketools10/
     
    117117    $args = array(
    118118        '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        ),
    120126        'posts_per_page' => -1,
    121127    );
    122128
    123129    $downloads = get_posts( $args );
    124 
    125130    $hidden_downloads = array();
    126131
    127132    if ( $downloads ) {
    128133        foreach ( $downloads as $download ) {
     134
    129135            $hidden_downloads[] = $download->ID;
    130136        }
     
    146152function hsedd_columns($download_columns)
    147153{
     154    hsedd_query_hidden_downloads();
    148155    $download_columns = array_merge(
    149156        $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')
    151158    ));
    152159
     
    157164function hsedd_column_content($column_name, $post_id)
    158165{
    159     if ('hsedd_meta_box_check_produk' != $column_name)
     166    if ('_hsedd_meta_box_check_produk' != $column_name)
    160167        return;
    161168    //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 );
    163170    $check = "Show Product";
    164171    if (isset($hsedd_meta_box_check_produk)) {
    165         if ($hsedd_meta_box_check_produk == 'on') {
     172        if ($hsedd_meta_box_check_produk) {
    166173            $check = "Hide Product";
    167174        }
     
    174181function sortable_hsedd_column($columns)
    175182{
    176     $columns['hsedd_meta_box_check_produk'] = 'hsedd_meta_box_check_produk';
     183    $columns['_hsedd_meta_box_check_produk'] = '_hsedd_meta_box_check_produk';
    177184
    178185    //To make a column 'un-sortable' remove it from the array
     
    190197 * @return void
    191198 */
    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;
     199function 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;
    195203// 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 );
    197205    ?>
    198206    <fieldset class="inline-edit-col-left">
     
    202210                <span class="title"><?php _e('Hide Product', 'easy-digital-downloads'); ?></span>
    203211                <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"/>
    205214                </span>
    206215            </label>
     
    211220}
    212221
    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);
     222add_action('quick_edit_custom_box', 'hsedd_price_field_quick_edit', 10, 2);
     223add_action('bulk_edit_custom_box', 'hsedd_price_field_quick_edit', 10, 2);
    215224
    216225add_action('admin_enqueue_scripts', 'misha_enqueue_quick_edit_population');
     
    232241    // get our variables
    233242    $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
    235244    // 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)) {
    237246        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 */
     264function 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}
     274add_action( 'save_post', 'hsedd_save_quick_edit_data' );
  • edd-hideshow-product/trunk/readme.txt

    r2084173 r2137995  
    66Tested up to: 5.2
    77Requires PHP: 5.4
    8 Stable tag: 1.0.0
     8Stable tag: 1.0.1
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3939== Changelog ==
    4040
     41= 1.0.1 =
     42* Fix quick edit and bulk edit
     43
    4144= 1.0.0 =
    4245* Initial release
     
    4447== Upgrade Notice ==
    4548
     49= 1.0.1 =
     50Version 1.0.1 is fix quick edit and bulk edit.
     51
    4652= 1.0.0 =
    4753Version 1.0.0 is a recommended update for performance improvements.
  • edd-hideshow-product/trunk/scripts/hsedd_admin_edit.js

    r2081893 r2137995  
    2525
    2626            // 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
    2830            // Hide Show Product data
    2931            $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") {
    3133                $edit_row.find('.hsedd-meta_box_check_produk').prop('checked', true);
    3234            }
     
    4345        });
    4446        // 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();
    4650        // save the data
    4751        $.ajax({
Note: See TracChangeset for help on using the changeset viewer.