Plugin Directory

Changeset 2862820


Ignore:
Timestamp:
02/09/2023 04:19:34 PM (3 years ago)
Author:
arstudios
Message:

Release 1.5.4.

Location:
constellation-client-portal/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • constellation-client-portal/trunk/README.txt

    r2845715 r2862820  
    8989* **list_id** this can be useful for development when you have multiple lists on the same page (ex. this could be helpful when creatig paginated lists on the same page). Accepted Values: any whole positive number that is unique on the page. Default: null
    9090* **categories** Accepted Values: this can be entered as an Invoice Category Slug or ID, or a combination of those. Separate multiple values with a comma (ex. “21, category-a”). Default: null.
     91* **link_title** Accepted Values: “no_link”.  Adding this parameter and setting the value to "no_link" will remove the href from post titles in the list and make them unclickable. Default: null.
     92* **id** Accepted Values: any valid HTML ID attribute name. Default: null.
     93* **class** Accepted Values: any valid HTML class attribute name or names (separate multiple class names with a space). Default: null.
     94
    9195
    9296= Pro Invoice Shortcode Parameters =
     
    115119* **align_thumbnail** this allows the thumbnail image alignment to be set if the “show_thumbnail” attribute is set to “true”. Accepted Values: “center”, “left”, “right”, “float-left”, or “float-right”. Default: null.
    116120* **show_post_date** this allows for the WordPress post date to be displayed with each item in a list. Accepted Values: “true” or “false”. Default: “false”.
    117 * **list_id** this can be useful for development when you have multiple lists on the same page (ex. this could be helpful when creatig paginated lists on the same page). Accepted Values: any whole positive number that is unique on the page. Default: null
     121* **list_id** this can be useful for development when you have multiple lists on the same page (ex. this could be helpful when creatig paginated lists on the same page). Accepted Values: any whole positive number that is unique on the page. Default: null.
     122* **link_title** Accepted Values: “no_link”.  Adding this parameter and setting the value to "no_link" will remove the href from post titles in the list and make them unclickable. Default: null.
     123* **id** Accepted Values: any valid HTML ID attribute name. Default: null.
     124* **class** Accepted Values: any valid HTML class attribute name or names (separate multiple class names with a space). Default: null.
    118125
    119126= Pro File Shortcode Parameters =
     
    196203
    197204== Changelog ==
     205= 1.5.4 (Pro) - 2023-2-9 =
     206* Update: Corrected typo in the pro email settings section.
     207* Improvement: Updated the CSV import functionality to verify that the assigned company ID is associated with a valid company and return a warning if not.
     208* Improvement: Updated the CSV import functionality to assign a default post status of draft if none was provided and post a warning to the import log.
     209
     210= 1.5.4 (Core) - 2023-2-9 =
     211* Improvement: Added new id param to the file and invoice shortcodes to allow an ID attribute to be added to the list container div.
     212* Improvement: Added new class param to the file and invoice shortcodes to allow additional classes to be added to the list container div.
     213* Update: Updated the parameter order in the accp_update_dir_name_in_file_attachments function to clear optional parameter warnings in PHP 8.
     214* Update: Updated the parameter order in the accp_load_requested_file function to clear optional parameter warnings in PHP 8.
     215* Update: Updated the file shortcode to accept the file_status param and adjust the output accordingly.
     216
    198217= 1.5.3 (Pro) - 2023-1-9 =
    199218* Update: Updated the deactivate function to clear the accp_automated_email_cron cron job if it is scheduled on plugin deactivation.
     
    206225* Improvement: Added functionality to display a product_total column within invoice CSV exports.
    207226* Update: Relocated accp_save_invoice_cart_item_meta_as_order_item_meta, accp_change_invoice_status_on_woocommerce_payment_complete, accp_change_invoice_status_on_woocommerce_order_status_complete, and accp_change_invoice_status_to_completed functions and hooks from public to admin files.
    208 * Improvement - Added functionality to add the Woocommerce order number as attribution within invoice notes when they are automatically marked as paid by Woocommerce.
     227* Improvement: Added functionality to add the Woocommerce order number as attribution within invoice notes when they are automatically marked as paid by Woocommerce.
    209228
    210229= 1.5.3 (Core) - 2023-1-9 =
     
    212231* Improvement: Added new link_title file and invoice shortcode attribute that removes the link from post titles in the loop if the attribute is set to nolink.
    213232* Improvement: Added a role select field to the new primary user create form in the Company UI and updated the AJAX function to assign the role on user creation.
    214 * Improvement: Added a "Company ID" column the the Company WP list table for easy access to the Company/post ID.s
     233* Improvement: Added a "Company ID" column to the Company WP list table for easy access to the Company/post ID.
    215234* Improvement: Extended login and WP capability checks for admin settings pages.
    216235
  • constellation-client-portal/trunk/admin/class-ars-constellation-client-portal-admin.php

    r2798490 r2862820  
    108108        global $wp, $wp_rewrite;       
    109109
    110         // Don't specify the plugin directory name to account for different
    111         // dir names based on the plugin tier - Basic, Pro, Premium     
    112        
    113         // Account for WP being installed in a sub directory, and the wp-content
    114         // and/or /uploads directories being renamed.       
     110        /**
     111         * Don't specify the plugin directory name to account for different
     112         * dir names based on the plugin tier - Basic, Pro, etc.
     113         *
     114         * Account for WP being installed in a sub directory, and the wp-content
     115         * and/or /uploads directories being renamed.
     116         */
    115117        $page_with_query_string = 'index.php/?accp_direct_access=1';
    116118        $wp_content_dir_name = $this->accp_utility_functions->accp_get_wp_content_dir_name();
    117119        $accp_clientfiles_full_dir_path = $this->accp_utility_functions->accp_get_clientfiles_path();
    118120
    119         // Constrain path to start with 'wp-content/...' as an example, but this is dynamic based on the environment.
     121
     122        /**
     123         * Constrain path to start with 'wp-content/...' as an example, but this is dynamic based on the environment.
     124         */
    120125        $accp_clientfiles_partial_dir_path = strstr($accp_clientfiles_full_dir_path, $wp_content_dir_name);
    121126        $accp_clientfiles_partial_dir_path_slashed = str_replace('/', '\/', $accp_clientfiles_partial_dir_path);
    122127
    123         // Prep the regex (Example: value should look like - '^wp-content\/uploads\/accp-clientfiles\/.*?\/.*?\..*?$').
    124         $regex_path = '^'.$accp_clientfiles_partial_dir_path_slashed.'\/.*?\/.*?\..*?$';       
    125            
     128
     129        /**
     130         * Prep the regex (Example: value should look like - '^wp-content\/uploads\/accp-clientfiles\/.*?\/.*?\..*?$').
     131         */
     132        $regex_path = '^'.$accp_clientfiles_partial_dir_path_slashed.'\/.*?\/.*?\..*?$';
     133
     134       
     135        /**
     136         * Add the rewrite rule for direct file access.
     137         */
    126138        add_rewrite_rule( $regex_path, $page_with_query_string, 'top' );
    127139               
    128     }   
     140    }
     141
    129142
    130143    /**
     
    134147
    135148        $query_vars[] = 'accp_direct_access';
     149
    136150        return $query_vars;
    137151
    138152    }
     153
    139154
    140155    /**
     
    149164            $base_checks = $this->accp_direct_file_access_base_checks($request_uri);
    150165           
    151             // If this is the Basic tier, serve the file here if the base checks passed.
     166            /**
     167             * If this is the Basic tier, serve the file here if the base checks passed.
     168             */
    152169            if( $this->plugin_name != 'ars-constellation-client-portal-premium' && $this->plugin_name != 'ars-constellation-client-portal-pro'){
    153170               
     
    156173                    $checks_passed = true;
    157174
    158                     // Serve the requested file.
    159                     $this->accp_load_requested_file($checks_passed, $request_uri);
     175                    /**
     176                     * Serve the requested file.
     177                     */
     178                    $this->accp_load_requested_file($request_uri, $checks_passed);
    160179                    exit;
    161180
    162181                }else{
    163182
    164                     // Redirect to the home page.
     183                    /**
     184                     * Redirect to the home page.
     185                     */
    165186                    wp_redirect('/');
    166187                    exit;
     
    189210                    $checks_passed = true;
    190211
    191                     // Serve the requested file.
    192                     $this->accp_load_requested_file($checks_passed, $request_uri);
     212                    /**
     213                     * Serve the requested file.
     214                     */
     215                    $this->accp_load_requested_file($request_uri, $checks_passed);
    193216                    exit();
    194217
    195218                }else{
    196219
    197                     // Redirect to the home page.
     220                    /**
     221                     * Redirect to the home page.
     222                     */
    198223                    wp_redirect('/');
    199224                    exit;
     
    217242       
    218243        global $current_user;
     244
    219245        $current_user = wp_get_current_user();
    220246        $current_user_id = $current_user->ID;
    221247        $plugin_name = $this->plugin_name;
    222248       
    223         // Return false if the user is not logged in.
    224         if ( !is_user_logged_in() || $current_user_id === 0) return false;
     249        /**
     250         * Return false if the user is not logged in.
     251         */
     252        if ( !is_user_logged_in() || $current_user_id === 0)
     253            return false;
    225254       
    226255        // Get the company that the current user is assigned to
     
    233262       
    234263        }else{
     264
    235265            $company_directory = NULL;
     266
    236267        }
    237268
     
    301332     * Serves the requested file after checks have passed.
    302333     */
    303     private function accp_load_requested_file($checks_passed = false, $request_uri){
     334    private function accp_load_requested_file($request_uri, $checks_passed = false){
    304335
    305336        if($checks_passed == false) return;
     
    13431374            if($update_links == 'update'){             
    13441375
    1345                 $process_link_updates = $this->accp_update_dir_name_in_file_attachments($company_id, array('accp_clientinvoice', 'accp_clientfile'), $new_dir_name);
     1376                $process_link_updates = $this->accp_update_dir_name_in_file_attachments($company_id, $new_dir_name, array('accp_clientinvoice', 'accp_clientfile'));
    13461377
    13471378                /**
     
    14611492     * or false if no post ID's were returned in the query.
    14621493     */
    1463     function accp_update_dir_name_in_file_attachments($company_id, $post_types = array('accp_clientinvoice', 'accp_clientfile'), $new_dir_name){
     1494    function accp_update_dir_name_in_file_attachments($company_id, $new_dir_name, $post_types = array('accp_clientinvoice', 'accp_clientfile')){
    14641495
    14651496        if(!is_admin() || !current_user_can('manage_options'))
     
    16511682        if($update_links == 'update'){             
    16521683
    1653             $process_link_updates = $this->accp_update_dir_name_in_file_attachments($company_id, array('accp_clientinvoice', 'accp_clientfile'), $new_dir_name);
     1684            $process_link_updates = $this->accp_update_dir_name_in_file_attachments($company_id, $new_dir_name, array('accp_clientinvoice', 'accp_clientfile'));
    16541685
    16551686            /**
  • constellation-client-portal/trunk/ars-constellation-client-portal.php

    r2845715 r2862820  
    55 * Plugin URI:        https://adrianrodriguezstudios.com/constellation-client-portal/
    66 * Description:       Create private pages for each of your clients, post private files, and protect your client files from unauthorized users and search engines.  <strong>Important:</strong> All Site-level File Protection features will cease to function if the plugin is disabled or uninstalled.
    7  * Version:           1.5.3
     7 * Version:           1.5.4
    88 * Author:            ARS
    99 * Author URI:        https://adrianrodriguezstudios.com
     
    4141 */
    4242define('ACCP_PLUGIN_NAME', 'ARS_CONSTELLATION_CLIENT_PORTAL');
    43 define('ACCP_PLUGIN_VERSION', '1.5.3'); // Change the version in the header as well.
     43define('ACCP_PLUGIN_VERSION', '1.5.4'); // Change the version in the header as well.
    4444define( ACCP_PLUGIN_NAME, ACCP_PLUGIN_VERSION );
    4545
  • constellation-client-portal/trunk/public/class-ars-constellation-client-portal-public.php

    r2845715 r2862820  
    8989        $roles = array_map('strtolower', $roles_array);
    9090        $list_instance = filter_var( $this->accp_generate_list_instance_id(), FILTER_SANITIZE_NUMBER_INT);
     91        $paged_param = 'paged' . $list_instance;
     92        $paged = isset( $_GET[$paged_param] ) ? (int)$_GET[$paged_param] : 1;
     93       
     94        // Get the Company ID associated with the current user
     95        $curr_user_company_id = get_user_meta( $user_id, 'client_company', true );
     96
     97        // Get the Company id of the current page
     98        $page_company = get_post_meta($post_id, 'accp_user', true);
     99
     100        // Get additonal assigned companies
     101        $additional_assigned_companies = get_user_meta($user_id, 'client_additional_company', true);
     102
     103        if ( $additional_assigned_companies != null && in_array($page_company, $additional_assigned_companies) ){
     104
     105            $additional_company_id = $page_company;
     106
     107        }else{
     108
     109            $additional_company_id = null;
     110            $additional_assigned_companies = array();
     111        }
     112
     113        if ( $additional_company_id != null){
     114           
     115            $authorized_company_id = $additional_company_id;
     116
     117        }else{
     118           
     119            $authorized_company_id = $curr_user_company_id;
     120        }
     121
     122        // Admins have access to all companies
     123        if( current_user_can('manage_options') ){
     124
     125            $authorized_company_id = $page_company;
     126            $additional_assigned_companies = array();
     127
     128        }
     129
     130        $current_date = date('Y-m-d');
    91131       
    92132       
     
    107147         * Output the shortcode attributes.
    108148         */
    109         $atts = shortcode_atts($atts_list_array, $atts);
    110        
    111         ob_start();
    112 
    113         $cur_date = date('m/d/Y');
     149        $atts = shortcode_atts($atts_list_array, $atts);       
     150
    114151
    115152        /**
     
    117154         */
    118155
     156        // File Status
     157        if( $atts['file_status'] != null){
     158
     159            $file_status = strtolower($atts['file_status']);   
     160
     161        }else{
     162
     163            $file_status = '';
     164           
     165        }
     166
    119167        // List ID
    120168        $list_id = $this->accp_list_id_var($atts);   
     
    141189        // Thumbnail alignment     
    142190        $align_thumbnail = $this->accp_align_thumbnail_var($atts);     
    143        
    144         // Get the Company ID associated with the current user
    145         $curr_user_company_id = get_user_meta( $user_id, 'client_company', true );
    146191
    147192        // Link title
     
    154199
    155200            $link_title = 'nolink';
     201
     202        }
     203
     204        // Container ID
     205        $container_id = '';
     206
     207        if( isset($atts['id']) && !empty($atts['id']) ){
     208
     209            $container_id = trim($atts['id']);
     210            $container_id = str_replace(' ', '', $container_id);
     211
     212        }
     213
     214        // Container Classes
     215        $container_classes = '';
     216
     217        if( isset($atts['class']) && !empty($atts['class']) ){
     218
     219            $container_classes = trim($atts['class']);
    156220
    157221        }
     
    177241        }
    178242
    179         ?>
    180        
    181        
    182        
    183         <?php // File List ?>
    184        
    185         <div class="accp_documents_filelist" <?php echo ( $list_id != null ? ' data-accp-rel-list="' . esc_attr($list_id) . '"' : '' ); ?> data-list-id="<?php echo esc_attr($list_instance); ?>">
    186         <?php
    187        
    188             $paged_param = 'paged' . $list_instance;
    189             $paged = isset( $_GET[$paged_param] ) ? (int)$_GET[$paged_param] : 1;       
    190 
    191             // Get the Company id of the current page
    192             $page_company = get_post_meta($post_id, 'accp_user', true);
    193 
    194             // Get additonal assigned companies
    195             $additional_assigned_companies = get_user_meta($user_id, 'client_additional_company', true);
    196 
    197             if ( $additional_assigned_companies != null && in_array($page_company, $additional_assigned_companies) ){
    198 
    199                 $additional_company_id = $page_company;
    200 
    201             }else{
    202 
    203                 $additional_company_id = null;
    204                 $additional_assigned_companies = array();
    205             }
    206 
    207             if ( $additional_company_id != null){
    208                
    209                 $authorized_company_id = $additional_company_id;
    210 
    211             }else{
    212                
    213                 $authorized_company_id = $curr_user_company_id;
    214             }
    215 
    216             // Admins have access to all companies
    217             if( current_user_can('manage_options') ){
    218 
    219                 $authorized_company_id = $page_company;
    220                 $additional_assigned_companies = array();
    221 
    222             }
    223            
    224             // Add a tax_query if the 'categories' att is not empty.
    225             $tax_query = array();
    226            
    227             if(!empty($categories)){           
    228 
    229                 $tax_query[] = array(
    230                     'taxonomy' => 'accp_file_categories',
    231                     'field' => 'slug',
    232                     'terms' => $categories,             
    233                 );
    234                
    235             }
    236            
    237             $args = array(
    238                 'post_type' => 'accp_clientfile',
    239                 'posts_per_page' => $number_of_posts,       
    240                 'paged' => $paged, 
    241                 'orderby' => $order_by,           
    242                 'order' => $order,
    243                 'meta_query' => array(               
    244                     'relation' => 'AND',             
    245                     array(         
    246                         'key' => 'accp_user',
    247                         'value' => $authorized_company_id             
    248                     )           
    249                 ),
    250                 'tax_query' => $tax_query,             
    251             );
     243        ob_start();
     244
     245        ?>     
     246       
     247        <?php // File List ?>       
     248       
     249        <div <?php echo !empty($container_id) ? 'id="'. esc_attr($container_id).'"' : ''; ?> class="accp_documents_filelist <?php echo !empty($container_classes) ? esc_attr($container_classes) : ''; ?>" <?php echo ( $list_id != null ? ' data-accp-rel-list="' . esc_attr($list_id) . '"' : '' ); ?> data-list-id="<?php echo esc_attr($list_instance); ?>">
     250        <?php           
     251           
     252            /**
     253             * Generate file query args.
     254             */
     255            $args = $this->accp_generate_file_query_args($categories, $number_of_posts, $paged, $order_by, $order, $authorized_company_id, $file_status);
    252256                   
    253257            $query = new WP_Query( $args );
    254258
    255             $html = '';
    256             $current_year = '';
    257             $current_date = date('m/d/Y');
     259            $html = '';     
    258260           
    259261            if ($query->have_posts()):         
     
    261263                while ( $query->have_posts() ):
    262264                   
    263                     $query->the_post();     
    264                    
    265                     $year = get_the_date('Y');
    266 
    267                     if ($year != $current_year){
    268                        
    269                         $current_year = $year;
    270 
    271                     }
     265                    $query->the_post();             
    272266
    273267                    $accp_file = get_post_meta($post->ID, 'accp_file', true);   
     
    435429                            </div>
    436430
     431
    437432                            <?php
    438433                            /**
     
    531526    }
    532527
     528
     529    /**
     530     * Generate file query args.
     531     *
     532     * @return array $args - array of file query args.
     533     */
     534    function accp_generate_file_query_args($categories, $number_of_posts, $paged, $order_by, $order, $authorized_company_id, $file_status){
     535
     536        /**
     537         * Add a tax_query if the 'categories' att is not empty.
     538         */
     539        $tax_query = array();
     540           
     541        if(!empty($categories)){           
     542
     543            $tax_query[] = array(
     544                'taxonomy' => 'accp_file_categories',
     545                'field' => 'slug',
     546                'terms' => $categories,             
     547            );
     548           
     549        }
     550
     551        $meta_query = array();
     552       
     553        /**
     554         * Add the file status to the meta_query
     555         * if it's not empty.
     556         */
     557        if(!empty($file_status)){       
     558
     559            $meta_query['relation'] = 'AND';
     560
     561            $meta_query[] = array(         
     562                'key' => 'file_status',
     563                'value' => $file_status         
     564            );
     565
     566        }
     567
     568        $meta_query[] = array(         
     569            'key' => 'accp_user',
     570            'value' => $authorized_company_id             
     571        );
     572       
     573        $args = array(
     574            'post_type' => 'accp_clientfile',
     575            'posts_per_page' => $number_of_posts,       
     576            'paged' => $paged, 
     577            'orderby' => $order_by,           
     578            'order' => $order,
     579            'meta_query' => $meta_query,
     580            'tax_query' => $tax_query,             
     581        );     
     582
     583        return $args;
     584
     585    }
     586
    533587    /**
    534588     * Set up the core atts for the clientfile shortcode.
     
    537591
    538592        $atts_list_array  = array(
     593            'id' => '', // Optional ID for the accp_documents_filelist list div.  Defaults to null.
     594            'class' => '', // Optional additional class(es) for the accp_documents_filelist list div.  Defaults to null.
    539595            'categories' => '', // Category atts can be entered as the Slug or ID in the shortcode
     596            'file_status' => '', // File status to show - file status slug or null. Defaults to null.
    540597            'display_number' => '', // This is the number of posts per page
    541598            'order_by' => '', // This allows ordering by post title - default is post date - options "title" or "date"
     
    572629        $roles_array = ( array ) $user->roles;
    573630        $roles = array_map('strtolower', $roles_array);
    574         $list_instance = filter_var( $this->accp_generate_list_instance_id(), FILTER_SANITIZE_NUMBER_INT);     
     631        $list_instance = filter_var( $this->accp_generate_list_instance_id(), FILTER_SANITIZE_NUMBER_INT);
     632        $paged_param = 'paged' . $list_instance;
     633        $paged = isset( $_GET[$paged_param] ) ? (int)$_GET[$paged_param] : 1;
     634
     635        // Get the Company ID associated with the current user
     636        $curr_user_company_id = get_user_meta( $user_id, 'client_company', true );
     637
     638        // Get the Company id of the current page
     639        $page_company = get_post_meta($post_id, 'accp_user', true);
     640
     641        // Get additonal assigned companies
     642        $additional_assigned_companies = get_user_meta($user_id, 'client_additional_company', true);
     643
     644        if ( $additional_assigned_companies != null && in_array($page_company, $additional_assigned_companies) ){
     645
     646            $additional_company_id = $page_company;
     647
     648        }else{
     649
     650            $additional_company_id = null;
     651            $additional_assigned_companies = array();
     652        }
     653
     654        if ( $additional_company_id != null){
     655           
     656            $authorized_company_id = $additional_company_id;
     657
     658        }else{
     659           
     660            $authorized_company_id = $curr_user_company_id;
     661        }
     662
     663        // Admins have access to all companies
     664        if( current_user_can('manage_options') ){
     665
     666            $authorized_company_id = $page_company;
     667            $additional_assigned_companies = array();
     668
     669        }
     670
     671        $current_date = date('Y-m-d');
    575672       
    576673       
     
    592689         * Output the shortcode attributes
    593690         */
    594         $atts = shortcode_atts($atts_list_array, $atts);
    595        
    596         ob_start();
    597 
    598         $cur_date = date('m/d/Y');
     691        $atts = shortcode_atts($atts_list_array, $atts);       
     692   
    599693
    600694        /**
     
    610704
    611705            $invoice_status = 'unpaid';
     706
    612707        } 
    613708
     
    635730       
    636731        // Thumbnail alignment
    637         $align_thumbnail = $this->accp_align_thumbnail_var($atts);
    638        
    639         // Get the Company ID associated with the current user
    640         $curr_user_company_id = get_user_meta( $user_id, 'client_company', true );
     732        $align_thumbnail = $this->accp_align_thumbnail_var($atts); 
    641733
    642734        // Link title
     
    649741
    650742            $link_title = 'nolink';
     743
     744        }
     745
     746        // Container ID
     747        $container_id = '';
     748
     749        if( isset($atts['id']) && !empty($atts['id']) ){
     750
     751            $container_id = trim($atts['id']);
     752            $container_id = str_replace(' ', '', $container_id);
     753
     754        }
     755
     756        // Container Classes
     757        $container_classes = '';
     758
     759        if( isset($atts['class']) && !empty($atts['class']) ){
     760
     761            $container_classes = trim($atts['class']);
    651762
    652763        }
     
    671782            echo wp_kses_post($before_loop_content);
    672783        }
     784
     785        ob_start();
    673786        ?>     
    674787       
    675788        <?php // Invoice List ?>
    676789       
    677         <div class="accp_documents_filelist" <?php echo ( $list_id != null ? ' data-accp-rel-list="' . esc_attr($list_id) . '"' : '' ); ?> data-list-id="<?php echo esc_attr($list_instance); ?>">
    678         <?php
    679        
    680             $paged_param = 'paged' . $list_instance;
    681             $paged = isset( $_GET[$paged_param] ) ? (int)$_GET[$paged_param] : 1; 
    682 
    683             // Get the Company id of the current page
    684             $page_company = get_post_meta($post_id, 'accp_user', true);
    685 
    686             // Get additonal assigned companies
    687             $additional_assigned_companies = get_user_meta($user_id, 'client_additional_company', true);
    688 
    689             if ( $additional_assigned_companies != null && in_array($page_company, $additional_assigned_companies) ){
    690 
    691                 $additional_company_id = $page_company;
    692 
    693             }else{
    694 
    695                 $additional_company_id = null;
    696                 $additional_assigned_companies = array();
    697             }
    698 
    699             if ( $additional_company_id != null){
    700                
    701                 $authorized_company_id = $additional_company_id;
    702 
    703             }else{
    704                
    705                 $authorized_company_id = $curr_user_company_id;
    706             }
    707 
    708             // Admins have access to all companies
    709             if( current_user_can('manage_options') ){
    710 
    711                 $authorized_company_id = $page_company;
    712                 $additional_assigned_companies = array();
    713 
    714             }           
    715 
    716             // Add a tax_query if the 'categories' att is not empty.
    717             $tax_query = array();
    718            
    719             if(!empty($categories)){
    720 
    721                 $tax_query[] = array(
    722                     'taxonomy' => 'accp_invoice_categories',
    723                     'field' => 'slug',
    724                     'terms' => $categories,             
    725                 );
    726 
    727             }
    728            
    729             $args = array(
    730                 'post_type' => 'accp_clientinvoice',
    731                 'posts_per_page' => $number_of_posts,       
    732                 'paged' => $paged, 
    733                 'orderby' => $order_by,           
    734                 'order' => $order,
    735                 'meta_query' => array(               
    736                     'relation' => 'AND',             
    737                     array(         
    738                         'key' => 'accp_user',
    739                         'value' => $authorized_company_id                         
    740                     ),             
    741                     array(         
    742                         'key' => 'invoice_status',
    743                         'value' => $invoice_status           
    744                     )           
    745                 ),
    746                 'tax_query' => $tax_query               
    747             );         
    748            
     790        <div <?php echo !empty($container_id) ? 'id="'. esc_attr($container_id).'"' : ''; ?> class="accp_documents_filelist <?php echo !empty($container_classes) ? esc_attr($container_classes) : ''; ?>" <?php echo ( $list_id != null ? ' data-accp-rel-list="' . esc_attr($list_id) . '"' : '' ); ?> data-list-id="<?php echo esc_attr($list_instance); ?>">
     791        <?php                       
     792
     793            /**
     794             * Generate invoice query args.
     795             */
     796            $args = $this->accp_generate_invoice_query_args($categories, $number_of_posts, $paged, $order_by, $order, $authorized_company_id, $invoice_status);     
    749797            $query = new WP_Query( $args );     
    750798
    751             $html = '';
    752             $current_year = '';
    753             $current_date = date('m/d/Y');     
     799            $html = '';             
    754800
    755801            // The Loop
     
    760806                while ( $query->have_posts()):
    761807
    762                     $query->the_post();         
    763                    
    764                     $year = get_the_date('Y');
    765 
    766                     if ($year != $current_year) {                   
    767                         $current_year = $year;
    768                     }
     808                    $query->the_post();                             
    769809
    770810                    $accp_file = get_post_meta($post->ID, 'accp_file', true);   
     
    10761116
    10771117    /**
     1118     * Generate invoice query args.
     1119     *
     1120     * @return array - array of args for the invoice query.
     1121     */
     1122    function accp_generate_invoice_query_args($categories, $number_of_posts, $paged, $order_by, $order, $authorized_company_id, $invoice_status){
     1123   
     1124        /**
     1125         * Add a tax_query if the 'categories' att is not empty.
     1126         */
     1127        $tax_query = array();
     1128       
     1129        if(!empty($categories)){
     1130
     1131            $tax_query[] = array(
     1132                'taxonomy' => 'accp_invoice_categories',
     1133                'field' => 'slug',
     1134                'terms' => $categories,             
     1135            );
     1136
     1137        }
     1138       
     1139        $args = array(
     1140            'post_type' => 'accp_clientinvoice',
     1141            'posts_per_page' => $number_of_posts,       
     1142            'paged' => $paged, 
     1143            'orderby' => $order_by,           
     1144            'order' => $order,
     1145            'meta_query' => array(               
     1146                'relation' => 'AND',             
     1147                array(         
     1148                    'key' => 'accp_user',
     1149                    'value' => $authorized_company_id                         
     1150                ),             
     1151                array(         
     1152                    'key' => 'invoice_status',
     1153                    'value' => $invoice_status           
     1154                )           
     1155            ),
     1156            'tax_query' => $tax_query               
     1157        );
     1158
     1159        return $args;
     1160
     1161    }
     1162
     1163
     1164    /**
    10781165     * Set up the core atts for the clientinvoice shortcode.
    10791166     */
     
    10811168
    10821169        $atts_list_array  = array(
     1170            'id' => '', // Optional ID for the accp_documents_filelist list div.  Defaults to null.
     1171            'class' => '', // Optional additional class(es) for the accp_documents_filelist list div.  Defaults to null.
    10831172            'categories' => '', // Category atts can be entered as the Slug or ID in the shortcode
    10841173            'invoice_status' => '', // Invoice status to show - 'paid' or 'unpaid'. Defaults to 'unpaid.'
     
    14731562
    14741563
     1564    /**
     1565     * Generate a list instance ID by posting
     1566     * and incrementing a number that can be assigned
     1567     * to lists that are added to the page via file and
     1568     * invoice shortcodes.
     1569     *
     1570     * This allows for accurate pagination functionality
     1571     * when multiple lists are added to the same page, and
     1572     * can allow for better css and/or script targetting.
     1573     *
     1574     * @return int $list_instance_id - a unique number to be used
     1575     * for a file or invoice list.
     1576     */
    14751577    function accp_generate_list_instance_id(){
    14761578
     1579        /**
     1580         * If $_POST['accp_list_count'] is not set,
     1581         * this should be the first (or only) list on the page,
     1582         * so let's set $_POST['accp_list_count'] to "1".
     1583         */
    14771584        if( !isset($_POST['accp_list_count'])){
    14781585
     
    14811588        }else{
    14821589
     1590            /**
     1591             * If we've gotten this far and $_POST['accp_list_count']
     1592             * is already set, There's more than one list on the page.
     1593             * So, let's increment $_POST['accp_list_count'] by 1 and
     1594             * use that for the current list's ID (and repeat until
     1595             * all lists on the page have a unique list ID).             *
     1596             */
    14831597            $_POST['accp_list_count'] = (int)$_POST['accp_list_count'] + 1;
    14841598
     
    14871601        $list_instance_id = filter_var($_POST['accp_list_count'], FILTER_SANITIZE_NUMBER_INT);
    14881602
    1489         return $list_instance_id;
     1603        return $list_instance_id;   
    14901604
    14911605    }
  • constellation-client-portal/trunk/uninstall.php

    r2663884 r2862820  
    33/**
    44 * Fired when the plugin is uninstalled.
    5  * For more information, see the following discussion:
    6  * https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
    75 *
    86 * @link       https://adrianrodriguezstudios.com
     
    1210 */
    1311
    14 // If uninstall not called from WordPress, then exit.
     12// Exit if not called from WordPress.
    1513if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    1614    exit;
Note: See TracChangeset for help on using the changeset viewer.