Plugin Directory

Changeset 2567602


Ignore:
Timestamp:
07/19/2021 08:02:45 PM (5 years ago)
Author:
Designed4Pixels
Message:

updated core functions

Location:
wp-cloud-server/trunk/includes/admin/functions
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • wp-cloud-server/trunk/includes/admin/functions/ajax-functions.php

    r2433251 r2567602  
    1919 */     
    2020function wpcs_ajax_load_scripts() {
     21
     22    // Load the JavaScript for the dashboard tabs & set-up the related Ajax script
     23    $dashboard_tabs_args = array(
     24        'ajaxurl' => admin_url( 'admin-ajax.php' ),
     25        'ajax_settings_dashboard_tabs_nonce' => wp_create_nonce( 'settings_dashboard_ui_tabs_nonce' ),
     26    );
     27   
     28    wp_enqueue_script( 'settings_dashboard-tabs-update', WPCS_PLUGIN_URL . 'includes/admin/assets/js/dashboard-tab.js', array( 'jquery' ), '1.0.0', false );
     29    wp_localize_script( 'settings_dashboard-tabs-update', 'wpcs_settings_dashboard_tabs_ajax_script', $dashboard_tabs_args );
     30   
    2131
    2232    // Load the JavaScript for the dashboard & set-up the related Ajax script
     
    6979}
    7080add_action( 'wp_ajax_dashboard_update', 'wpcs_ajax_process_dashboard_update' );
     81
     82/**
     83 *  Create the Option for the Dashboard Tabs Update
     84 *
     85 *  @since  3.0.6
     86 */         
     87function wpcs_ajax_process_dashboard_tabs_update() {
     88
     89    // Check the nonce for the admin notice data
     90    check_ajax_referer( 'settings_dashboard_ui_tabs_nonce', 'settings_dashboard_tabs_nonce' );
     91
     92    // Pick up the notice "admin_type" - passed via the "data-tab" attribute
     93    if ( isset( $_POST['settings_dashboard_tabs_type'] ) ) {
     94        $position   = $_POST['settings_dashboard_tabs_type'];
     95        $tab_id     = $_POST['settings_dashboard_tabs_id'];
     96        update_option( "wpcs_{$tab_id}_current_tab", $position );
     97    }       
     98}
     99add_action( 'wp_ajax_settings_dashboard_tabs', 'wpcs_ajax_process_dashboard_tabs_update' );
    71100       
    72101/**
  • wp-cloud-server/trunk/includes/admin/functions/misc-functions.php

    r2492109 r2567602  
    319319}
    320320
    321 function wpcs_delete_server_template( $provider, $template) {
     321function wpcs_delete_template( $provider, $template, $type = 'server') {
    322322   
    323323    $module_data        = get_option( 'wpcs_module_list' );
    324324    $template_data      = get_option( 'wpcs_template_data_backup' );
    325325    $completed_tasks    = get_option( 'wpcs_tasks_completed', array());
    326    
     326       
    327327    foreach ( $module_data[$provider]['templates'] as $key => $templates ) {
     328
    328329        if ( $template == $templates['name'] ) {
     330
    329331            unset( $module_data[$provider]['templates'][$key] );
    330332            unset( $template_data[$provider]['templates'][$key] );
    331                 $completed_tasks[]=$template;
    332                 $delete_complete = true;
    333             }   
    334         }
     333
     334            $template_count = ( isset( $module_data[ $provider ][ "{$type}_template_count" ] ) ) ? $module_data[ $provider ][ "{$type}_template_count" ] : 0;
     335            $template_count = ( $template_count > 0 ) ? --$template_count : $template_count;
     336
     337            $module_data[ $provider ][ "{$type}_template_count" ]   = $template_count;
     338            $template_data[ $provider ][ "{$type}_template_count" ] = $template_count;
     339
     340            $completed_tasks[]=$template;
     341            $delete_complete = true;
     342        }   
     343    }
    335344    update_option( 'wpcs_tasks_completed', $completed_tasks);
    336345    update_option( 'wpcs_module_list', $module_data );
     
    356365    <?php
    357366}
     367
     368/**
     369 *  Check module is Active
     370 *
     371 *  @since  3.0.6
     372 *  @return boolean  module active
     373 */
     374function wpcs_check_module_active( $module = null ) {
     375
     376    $module_list = get_option( 'wpcs_module_list' );
     377
     378    return ( 'active' == $module_list[$module]['status'] ) ? true : false;
     379
     380}
Note: See TracChangeset for help on using the changeset viewer.