Exemplo n.º 1
0
 /**
  * Register any CSS and JS used by the plugin.
  * @since    1.0.0
  * @access 	 public
  * @param    string $hook Used for determining which page(s) to load our scripts.
  */
 public function enqueue_scripts($hook)
 {
     if ('tools_page_better-search-replace' === $hook) {
         wp_enqueue_style('better-search-replace', BSR_URL . 'assets/css/better-search-replace.css', array(), $this->version, 'all');
         wp_enqueue_style('jquery-style', BSR_URL . 'assets/css/jquery-ui.min.css', array(), $this->version, 'all');
         wp_enqueue_script('jquery-ui-slider');
         wp_enqueue_script('better-search-replace', BSR_URL . 'assets/js/better-search-replace.min.js', array('jquery'), $this->version, true);
         wp_enqueue_style('thickbox');
         wp_enqueue_script('thickbox');
         wp_localize_script('better-search-replace', 'bsr_object_vars', array('page_size' => get_option('bsr_page_size') ? get_option('bsr_page_size') : 20000, 'endpoint' => BSR_AJAX::get_endpoint(), 'ajax_nonce' => wp_create_nonce('bsr_ajax_nonce'), 'no_search' => __('No search string was defined, please enter a URL or string to search for.', 'better-search-replace'), 'no_tables' => __('Please select the tables that you want to update.', 'better-search-replace'), 'unknown' => __('An error occurred processing your request. Try decreasing the "Max Page Size", or contact support.', 'better-search-replace')));
     }
 }
        }
        // Retrieve the existing transient.
        $results = get_transient('bsr_results') ? get_transient('bsr_results') : array();
        // Grab any values from the run args.
        $results['search_for'] = isset($args['search_for']) ? $args['search_for'] : '';
        $results['replace_with'] = isset($args['replace_with']) ? $args['replace_with'] : '';
        $results['dry_run'] = isset($args['dry_run']) ? $args['dry_run'] : 'off';
        $results['case_insensitive'] = isset($args['case_insensitive']) ? $args['case_insensitive'] : 'off';
        $results['replace_guids'] = isset($args['replace_guids']) ? $args['replace_guids'] : 'off';
        // Sum the values of the new and existing reports.
        $results['change'] = isset($results['change']) ? $results['change'] + $report['change'] : $report['change'];
        $results['updates'] = isset($results['updates']) ? $results['updates'] + $report['updates'] : $report['updates'];
        // Append the table report, or create a new one if necessary.
        if (isset($results['table_reports']) && isset($results['table_reports'][$table])) {
            $results['table_reports'][$table]['change'] = $results['table_reports'][$table]['change'] + $report['change'];
            $results['table_reports'][$table]['updates'] = $results['table_reports'][$table]['updates'] + $report['updates'];
            $results['table_reports'][$table]['end'] = $report['end'];
        } else {
            $results['table_reports'][$table] = $report;
        }
        // Count the number of tables.
        $results['tables'] = count($results['table_reports']);
        // Update the transient.
        if (!set_transient('bsr_results', $results, DAY_IN_SECONDS)) {
            return false;
        }
        return true;
    }
}
$bsr_ajax = new BSR_AJAX();
$bsr_ajax->init();