@@ -9,32 +9,32 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | function wordlift_geo_widget_shortcode( $atts, $content = null ) { |
| 11 | 11 | |
| 12 | - // Extract attributes and set default values. |
|
| 13 | - $params = shortcode_atts( array( |
|
| 14 | - 'width' => '100%', |
|
| 15 | - 'height' => '300px', |
|
| 16 | - 'latitude' => 0.0, |
|
| 17 | - 'longitude' => 0.0, |
|
| 18 | - 'zoom' => 5, |
|
| 19 | - |
|
| 20 | - ), $atts ); |
|
| 21 | - |
|
| 22 | - // Add leaflet css and library. |
|
| 23 | - wp_enqueue_style( 'wl-leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.css', array(), '1.6.0' ); |
|
| 24 | - wp_enqueue_script( 'wl-leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.js', array(), '1.6.0', true ); |
|
| 25 | - |
|
| 26 | - ob_start(); // Collect the buffer. |
|
| 27 | - wordlift_geo_widget_html( |
|
| 28 | - $params['width'], |
|
| 29 | - $params['height'], |
|
| 30 | - $params['latitude'], |
|
| 31 | - $params['longitude'], |
|
| 32 | - $params['zoom'], |
|
| 33 | - $content |
|
| 34 | - ); |
|
| 35 | - |
|
| 36 | - // Return the accumulated buffer. |
|
| 37 | - return ob_get_clean(); |
|
| 12 | + // Extract attributes and set default values. |
|
| 13 | + $params = shortcode_atts( array( |
|
| 14 | + 'width' => '100%', |
|
| 15 | + 'height' => '300px', |
|
| 16 | + 'latitude' => 0.0, |
|
| 17 | + 'longitude' => 0.0, |
|
| 18 | + 'zoom' => 5, |
|
| 19 | + |
|
| 20 | + ), $atts ); |
|
| 21 | + |
|
| 22 | + // Add leaflet css and library. |
|
| 23 | + wp_enqueue_style( 'wl-leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.css', array(), '1.6.0' ); |
|
| 24 | + wp_enqueue_script( 'wl-leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.js', array(), '1.6.0', true ); |
|
| 25 | + |
|
| 26 | + ob_start(); // Collect the buffer. |
|
| 27 | + wordlift_geo_widget_html( |
|
| 28 | + $params['width'], |
|
| 29 | + $params['height'], |
|
| 30 | + $params['latitude'], |
|
| 31 | + $params['longitude'], |
|
| 32 | + $params['zoom'], |
|
| 33 | + $content |
|
| 34 | + ); |
|
| 35 | + |
|
| 36 | + // Return the accumulated buffer. |
|
| 37 | + return ob_get_clean(); |
|
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
@@ -42,24 +42,24 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | function wl_geo_widget_layer_shortcode( $atts ) { |
| 44 | 44 | |
| 45 | - // Extract attributes and set default values. |
|
| 46 | - $params = shortcode_atts( array( |
|
| 47 | - 'name' => '', |
|
| 48 | - 'label' => '', |
|
| 49 | - ), $atts ); |
|
| 45 | + // Extract attributes and set default values. |
|
| 46 | + $params = shortcode_atts( array( |
|
| 47 | + 'name' => '', |
|
| 48 | + 'label' => '', |
|
| 49 | + ), $atts ); |
|
| 50 | 50 | |
| 51 | - // Return if a SPARQL Query name hasn't been provided. |
|
| 52 | - if ( empty( $params['name'] ) ) { |
|
| 53 | - return; |
|
| 54 | - } |
|
| 51 | + // Return if a SPARQL Query name hasn't been provided. |
|
| 52 | + if ( empty( $params['name'] ) ) { |
|
| 53 | + return; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - // Set the layer label. |
|
| 57 | - $label_j = json_encode( empty( $params['label'] ) ? $params['name'] : $params['label'] ); |
|
| 56 | + // Set the layer label. |
|
| 57 | + $label_j = json_encode( empty( $params['label'] ) ? $params['name'] : $params['label'] ); |
|
| 58 | 58 | |
| 59 | - // Define the AJAX Url. |
|
| 60 | - $ajax_url = admin_url( 'admin-ajax.php?action=wl_sparql&format=geojson&slug=' . urlencode( $params['name'] ) ); |
|
| 59 | + // Define the AJAX Url. |
|
| 60 | + $ajax_url = admin_url( 'admin-ajax.php?action=wl_sparql&format=geojson&slug=' . urlencode( $params['name'] ) ); |
|
| 61 | 61 | |
| 62 | - echo <<<EOF |
|
| 62 | + echo <<<EOF |
|
| 63 | 63 | |
| 64 | 64 | $.ajax( '$ajax_url', { |
| 65 | 65 | success: function( data ) { |
@@ -90,21 +90,21 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | function wl_geo_widget_marker_shortcode( $atts ) { |
| 92 | 92 | |
| 93 | - // Extract attributes and set default values. |
|
| 94 | - $params = shortcode_atts( array( |
|
| 95 | - 'latitude' => null, |
|
| 96 | - 'longitude' => null, |
|
| 97 | - ), $atts ); |
|
| 93 | + // Extract attributes and set default values. |
|
| 94 | + $params = shortcode_atts( array( |
|
| 95 | + 'latitude' => null, |
|
| 96 | + 'longitude' => null, |
|
| 97 | + ), $atts ); |
|
| 98 | 98 | |
| 99 | - // Return if either latitude or longitude haven't been provided. |
|
| 100 | - if ( empty( $params['latitude'] ) || empty( $params['longitude'] ) ) { |
|
| 101 | - return; |
|
| 102 | - } |
|
| 99 | + // Return if either latitude or longitude haven't been provided. |
|
| 100 | + if ( empty( $params['latitude'] ) || empty( $params['longitude'] ) ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - $latitude_j = json_encode( $params['latitude'] ); |
|
| 105 | - $longitude_j = json_encode( $params['longitude'] ); |
|
| 104 | + $latitude_j = json_encode( $params['latitude'] ); |
|
| 105 | + $longitude_j = json_encode( $params['longitude'] ); |
|
| 106 | 106 | |
| 107 | - echo <<<EOF |
|
| 107 | + echo <<<EOF |
|
| 108 | 108 | |
| 109 | 109 | L.marker([$latitude_j, $longitude_j]).addTo(map); |
| 110 | 110 | EOF; |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | function wordlift_geo_widget_html( $width, $height, $latitude, $longitude, $zoom, $content ) { |
| 118 | 118 | |
| 119 | - // Create a unique Id for this widget. |
|
| 120 | - $div_id = uniqid( 'wl-geo-' ); |
|
| 119 | + // Create a unique Id for this widget. |
|
| 120 | + $div_id = uniqid( 'wl-geo-' ); |
|
| 121 | 121 | |
| 122 | - echo <<<EOF |
|
| 122 | + echo <<<EOF |
|
| 123 | 123 | <div id="$div_id" style="width: $width; height: $height;"></div> |
| 124 | 124 | |
| 125 | 125 | <script type="text/javascript"> |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | EOF; |
| 146 | 146 | |
| 147 | - // Run inner shortcodes. |
|
| 148 | - do_shortcode( $content ); |
|
| 147 | + // Run inner shortcodes. |
|
| 148 | + do_shortcode( $content ); |
|
| 149 | 149 | |
| 150 | - echo <<<EOF |
|
| 150 | + echo <<<EOF |
|
| 151 | 151 | |
| 152 | 152 | } ); |
| 153 | 153 | </script> |
@@ -7,21 +7,21 @@ discard block |
||
| 7 | 7 | * @subpackage Wordlift/modules/geo_widget |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -function wordlift_geo_widget_shortcode( $atts, $content = null ) { |
|
| 10 | +function wordlift_geo_widget_shortcode($atts, $content = null) { |
|
| 11 | 11 | |
| 12 | 12 | // Extract attributes and set default values. |
| 13 | - $params = shortcode_atts( array( |
|
| 13 | + $params = shortcode_atts(array( |
|
| 14 | 14 | 'width' => '100%', |
| 15 | 15 | 'height' => '300px', |
| 16 | 16 | 'latitude' => 0.0, |
| 17 | 17 | 'longitude' => 0.0, |
| 18 | 18 | 'zoom' => 5, |
| 19 | 19 | |
| 20 | - ), $atts ); |
|
| 20 | + ), $atts); |
|
| 21 | 21 | |
| 22 | 22 | // Add leaflet css and library. |
| 23 | - wp_enqueue_style( 'wl-leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.css', array(), '1.6.0' ); |
|
| 24 | - wp_enqueue_script( 'wl-leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.js', array(), '1.6.0', true ); |
|
| 23 | + wp_enqueue_style('wl-leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.css', array(), '1.6.0'); |
|
| 24 | + wp_enqueue_script('wl-leaflet', 'https://unpkg.com/[email protected]/dist/leaflet.js', array(), '1.6.0', true); |
|
| 25 | 25 | |
| 26 | 26 | ob_start(); // Collect the buffer. |
| 27 | 27 | wordlift_geo_widget_html( |
@@ -38,26 +38,26 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -add_shortcode( 'wl_geo', 'wordlift_geo_widget_shortcode' ); |
|
| 41 | +add_shortcode('wl_geo', 'wordlift_geo_widget_shortcode'); |
|
| 42 | 42 | |
| 43 | -function wl_geo_widget_layer_shortcode( $atts ) { |
|
| 43 | +function wl_geo_widget_layer_shortcode($atts) { |
|
| 44 | 44 | |
| 45 | 45 | // Extract attributes and set default values. |
| 46 | - $params = shortcode_atts( array( |
|
| 46 | + $params = shortcode_atts(array( |
|
| 47 | 47 | 'name' => '', |
| 48 | 48 | 'label' => '', |
| 49 | - ), $atts ); |
|
| 49 | + ), $atts); |
|
| 50 | 50 | |
| 51 | 51 | // Return if a SPARQL Query name hasn't been provided. |
| 52 | - if ( empty( $params['name'] ) ) { |
|
| 52 | + if (empty($params['name'])) { |
|
| 53 | 53 | return; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | // Set the layer label. |
| 57 | - $label_j = json_encode( empty( $params['label'] ) ? $params['name'] : $params['label'] ); |
|
| 57 | + $label_j = json_encode(empty($params['label']) ? $params['name'] : $params['label']); |
|
| 58 | 58 | |
| 59 | 59 | // Define the AJAX Url. |
| 60 | - $ajax_url = admin_url( 'admin-ajax.php?action=wl_sparql&format=geojson&slug=' . urlencode( $params['name'] ) ); |
|
| 60 | + $ajax_url = admin_url('admin-ajax.php?action=wl_sparql&format=geojson&slug='.urlencode($params['name'])); |
|
| 61 | 61 | |
| 62 | 62 | echo <<<EOF |
| 63 | 63 | |
@@ -85,24 +85,24 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | -add_shortcode( 'wl_geo_layer', 'wl_geo_widget_layer_shortcode' ); |
|
| 88 | +add_shortcode('wl_geo_layer', 'wl_geo_widget_layer_shortcode'); |
|
| 89 | 89 | |
| 90 | 90 | |
| 91 | -function wl_geo_widget_marker_shortcode( $atts ) { |
|
| 91 | +function wl_geo_widget_marker_shortcode($atts) { |
|
| 92 | 92 | |
| 93 | 93 | // Extract attributes and set default values. |
| 94 | - $params = shortcode_atts( array( |
|
| 94 | + $params = shortcode_atts(array( |
|
| 95 | 95 | 'latitude' => null, |
| 96 | 96 | 'longitude' => null, |
| 97 | - ), $atts ); |
|
| 97 | + ), $atts); |
|
| 98 | 98 | |
| 99 | 99 | // Return if either latitude or longitude haven't been provided. |
| 100 | - if ( empty( $params['latitude'] ) || empty( $params['longitude'] ) ) { |
|
| 100 | + if (empty($params['latitude']) || empty($params['longitude'])) { |
|
| 101 | 101 | return; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $latitude_j = json_encode( $params['latitude'] ); |
|
| 105 | - $longitude_j = json_encode( $params['longitude'] ); |
|
| 104 | + $latitude_j = json_encode($params['latitude']); |
|
| 105 | + $longitude_j = json_encode($params['longitude']); |
|
| 106 | 106 | |
| 107 | 107 | echo <<<EOF |
| 108 | 108 | |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | -add_shortcode( 'wl_geo_marker', 'wl_geo_widget_marker_shortcode' ); |
|
| 114 | +add_shortcode('wl_geo_marker', 'wl_geo_widget_marker_shortcode'); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | -function wordlift_geo_widget_html( $width, $height, $latitude, $longitude, $zoom, $content ) { |
|
| 117 | +function wordlift_geo_widget_html($width, $height, $latitude, $longitude, $zoom, $content) { |
|
| 118 | 118 | |
| 119 | 119 | // Create a unique Id for this widget. |
| 120 | - $div_id = uniqid( 'wl-geo-' ); |
|
| 120 | + $div_id = uniqid('wl-geo-'); |
|
| 121 | 121 | |
| 122 | 122 | echo <<<EOF |
| 123 | 123 | <div id="$div_id" style="width: $width; height: $height;"></div> |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | EOF; |
| 146 | 146 | |
| 147 | 147 | // Run inner shortcodes. |
| 148 | - do_shortcode( $content ); |
|
| 148 | + do_shortcode($content); |
|
| 149 | 149 | |
| 150 | 150 | echo <<<EOF |
| 151 | 151 | |
@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | <h1><?php esc_html_e( 'Tasks', 'wordlift-framework' ); ?></h1> |
| 14 | 14 | |
| 15 | 15 | <?php |
| 16 | - foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) { |
|
| 17 | - $task = $task_ajax_adapter->get_task(); |
|
| 18 | - ?> |
|
| 16 | + foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) { |
|
| 17 | + $task = $task_ajax_adapter->get_task(); |
|
| 18 | + ?> |
|
| 19 | 19 | <div class="wl-task"> |
| 20 | 20 | <h2><?php esc_html_e( $task->get_label() ); ?></h2> |
| 21 | 21 | <div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;"> |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | </div> |
| 34 | 34 | <?php |
| 35 | - } |
|
| 36 | - ?> |
|
| 35 | + } |
|
| 36 | + ?> |
|
| 37 | 37 | |
| 38 | 38 | </div> |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | ?> |
| 12 | 12 | <div class="wrap"> |
| 13 | - <h1><?php esc_html_e( 'Tasks', 'wordlift-framework' ); ?></h1> |
|
| 13 | + <h1><?php esc_html_e('Tasks', 'wordlift-framework'); ?></h1> |
|
| 14 | 14 | |
| 15 | 15 | <?php |
| 16 | - foreach ( $this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter ) { |
|
| 16 | + foreach ($this->task_ajax_adapters_registry->get_task_ajax_adapters() as $task_ajax_adapter) { |
|
| 17 | 17 | $task = $task_ajax_adapter->get_task(); |
| 18 | 18 | ?> |
| 19 | 19 | <div class="wl-task"> |
| 20 | - <h2><?php esc_html_e( $task->get_label() ); ?></h2> |
|
| 20 | + <h2><?php esc_html_e($task->get_label()); ?></h2> |
|
| 21 | 21 | <div class="wl-task__progress" style="border: 1px solid #23282D; height: 20px; margin: 8px 0;"> |
| 22 | 22 | <div class="wl-task__progress__bar" |
| 23 | 23 | style="width:0;background: #0073AA; text-align: center; height: 100%; color: #fff;"></div> |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | <button |
| 27 | 27 | type="button" |
| 28 | 28 | class="button button-large button-primary" |
| 29 | - data-action="<?php echo esc_attr( $task->get_id() ); ?>" |
|
| 30 | - data-nonce="<?php echo esc_attr( wp_create_nonce( $task->get_id() ) ); ?>" |
|
| 31 | - ><?php esc_html_e( 'Start', 'wordlift-framework' ); ?></button> |
|
| 29 | + data-action="<?php echo esc_attr($task->get_id()); ?>" |
|
| 30 | + data-nonce="<?php echo esc_attr(wp_create_nonce($task->get_id())); ?>" |
|
| 31 | + ><?php esc_html_e('Start', 'wordlift-framework'); ?></button> |
|
| 32 | 32 | |
| 33 | 33 | </div> |
| 34 | 34 | <?php |
@@ -18,66 +18,66 @@ |
||
| 18 | 18 | |
| 19 | 19 | class Tasks_Page extends Submenu_Page_Base { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The ID of this admin page. |
|
| 23 | - * |
|
| 24 | - * @since 1.0.0 |
|
| 25 | - * @access private |
|
| 26 | - * @var string $menu_slug The ID of this page. |
|
| 27 | - */ |
|
| 28 | - private $menu_slug = 'wl_tasks_page'; |
|
| 21 | + /** |
|
| 22 | + * The ID of this admin page. |
|
| 23 | + * |
|
| 24 | + * @since 1.0.0 |
|
| 25 | + * @access private |
|
| 26 | + * @var string $menu_slug The ID of this page. |
|
| 27 | + */ |
|
| 28 | + private $menu_slug = 'wl_tasks_page'; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Used when enqueueing styles or scripts as the version string. |
|
| 32 | - * |
|
| 33 | - * @since 1.0.0 |
|
| 34 | - * @access private |
|
| 35 | - * @var string |
|
| 36 | - */ |
|
| 37 | - private $asset_version = '1.0.0'; |
|
| 30 | + /** |
|
| 31 | + * Used when enqueueing styles or scripts as the version string. |
|
| 32 | + * |
|
| 33 | + * @since 1.0.0 |
|
| 34 | + * @access private |
|
| 35 | + * @var string |
|
| 36 | + */ |
|
| 37 | + private $asset_version = '1.0.0'; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @var Task_Ajax_Adapters_Registry |
|
| 41 | - */ |
|
| 42 | - private $task_ajax_adapters_registry; |
|
| 39 | + /** |
|
| 40 | + * @var Task_Ajax_Adapters_Registry |
|
| 41 | + */ |
|
| 42 | + private $task_ajax_adapters_registry; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Define the {@link Wordlift_Admin_Page} constructor. |
|
| 46 | - * |
|
| 47 | - * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry |
|
| 48 | - * |
|
| 49 | - * @since 1.0.0 |
|
| 50 | - */ |
|
| 51 | - public function __construct( $task_ajax_adapters_registry ) { |
|
| 52 | - parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift-framework' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift-framework' ) ); |
|
| 44 | + /** |
|
| 45 | + * Define the {@link Wordlift_Admin_Page} constructor. |
|
| 46 | + * |
|
| 47 | + * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry |
|
| 48 | + * |
|
| 49 | + * @since 1.0.0 |
|
| 50 | + */ |
|
| 51 | + public function __construct( $task_ajax_adapters_registry ) { |
|
| 52 | + parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift-framework' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift-framework' ) ); |
|
| 53 | 53 | |
| 54 | - $this->task_ajax_adapters_registry = $task_ajax_adapters_registry; |
|
| 54 | + $this->task_ajax_adapters_registry = $task_ajax_adapters_registry; |
|
| 55 | 55 | |
| 56 | - } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Register the stylesheets and scripts for the admin area. |
|
| 60 | - * |
|
| 61 | - * @since 1.0.0 |
|
| 62 | - */ |
|
| 63 | - public function enqueue_scripts() { |
|
| 64 | - wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' ); |
|
| 65 | - wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array( |
|
| 66 | - 'jquery', |
|
| 67 | - 'wp-util' |
|
| 68 | - ), $this->asset_version, true ); |
|
| 69 | - } |
|
| 58 | + /** |
|
| 59 | + * Register the stylesheets and scripts for the admin area. |
|
| 60 | + * |
|
| 61 | + * @since 1.0.0 |
|
| 62 | + */ |
|
| 63 | + public function enqueue_scripts() { |
|
| 64 | + wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' ); |
|
| 65 | + wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array( |
|
| 66 | + 'jquery', |
|
| 67 | + 'wp-util' |
|
| 68 | + ), $this->asset_version, true ); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Render the page. |
|
| 73 | - * |
|
| 74 | - * @since 1.0.0 |
|
| 75 | - */ |
|
| 76 | - public function render() { |
|
| 71 | + /** |
|
| 72 | + * Render the page. |
|
| 73 | + * |
|
| 74 | + * @since 1.0.0 |
|
| 75 | + */ |
|
| 76 | + public function render() { |
|
| 77 | 77 | |
| 78 | - // Include the partial. |
|
| 79 | - include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' ); |
|
| 78 | + // Include the partial. |
|
| 79 | + include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' ); |
|
| 80 | 80 | |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | } |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @since 1.0.0 |
| 50 | 50 | */ |
| 51 | - public function __construct( $task_ajax_adapters_registry ) { |
|
| 52 | - parent::__construct( $this->menu_slug, __( 'Tasks', 'wordlift-framework' ), 'manage_options', 'wl_admin_menu', __( 'Tasks', 'wordlift-framework' ) ); |
|
| 51 | + public function __construct($task_ajax_adapters_registry) { |
|
| 52 | + parent::__construct($this->menu_slug, __('Tasks', 'wordlift-framework'), 'manage_options', 'wl_admin_menu', __('Tasks', 'wordlift-framework')); |
|
| 53 | 53 | |
| 54 | 54 | $this->task_ajax_adapters_registry = $task_ajax_adapters_registry; |
| 55 | 55 | |
@@ -61,11 +61,11 @@ discard block |
||
| 61 | 61 | * @since 1.0.0 |
| 62 | 62 | */ |
| 63 | 63 | public function enqueue_scripts() { |
| 64 | - wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->asset_version, 'all' ); |
|
| 65 | - wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array( |
|
| 64 | + wp_enqueue_style($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.css', array(), $this->asset_version, 'all'); |
|
| 65 | + wp_enqueue_script($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.js', array( |
|
| 66 | 66 | 'jquery', |
| 67 | 67 | 'wp-util' |
| 68 | - ), $this->asset_version, true ); |
|
| 68 | + ), $this->asset_version, true); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | public function render() { |
| 77 | 77 | |
| 78 | 78 | // Include the partial. |
| 79 | - include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' ); |
|
| 79 | + include(plugin_dir_path(__FILE__).'assets/tasks-page.php'); |
|
| 80 | 80 | |
| 81 | 81 | } |
| 82 | 82 | |
@@ -18,71 +18,71 @@ |
||
| 18 | 18 | |
| 19 | 19 | abstract class Tasks_Page_Base extends Submenu_Page_Base { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The ID of this admin page. |
|
| 23 | - * |
|
| 24 | - * @since 1.0.0 |
|
| 25 | - * @access private |
|
| 26 | - * @var string $menu_slug The ID of this page. |
|
| 27 | - */ |
|
| 28 | - private $menu_slug; |
|
| 21 | + /** |
|
| 22 | + * The ID of this admin page. |
|
| 23 | + * |
|
| 24 | + * @since 1.0.0 |
|
| 25 | + * @access private |
|
| 26 | + * @var string $menu_slug The ID of this page. |
|
| 27 | + */ |
|
| 28 | + private $menu_slug; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @var Task_Ajax_Adapters_Registry |
|
| 32 | - */ |
|
| 33 | - private $task_ajax_adapters_registry; |
|
| 30 | + /** |
|
| 31 | + * @var Task_Ajax_Adapters_Registry |
|
| 32 | + */ |
|
| 33 | + private $task_ajax_adapters_registry; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @var string |
|
| 37 | - */ |
|
| 38 | - private $version; |
|
| 35 | + /** |
|
| 36 | + * @var string |
|
| 37 | + */ |
|
| 38 | + private $version; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Define the {@link Wordlift_Admin_Page} constructor. |
|
| 42 | - * |
|
| 43 | - * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry |
|
| 44 | - * |
|
| 45 | - * @param string $version |
|
| 46 | - * @param string $menu_slug |
|
| 47 | - * @param string $page_title |
|
| 48 | - * @param string $capability |
|
| 49 | - * @param string|null $parent_slug |
|
| 50 | - * @param string|null $menu_title |
|
| 51 | - * |
|
| 52 | - * @since 1.0.0 |
|
| 53 | - */ |
|
| 54 | - public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) { |
|
| 55 | - parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title ); |
|
| 40 | + /** |
|
| 41 | + * Define the {@link Wordlift_Admin_Page} constructor. |
|
| 42 | + * |
|
| 43 | + * @param Task_Ajax_Adapters_Registry $task_ajax_adapters_registry |
|
| 44 | + * |
|
| 45 | + * @param string $version |
|
| 46 | + * @param string $menu_slug |
|
| 47 | + * @param string $page_title |
|
| 48 | + * @param string $capability |
|
| 49 | + * @param string|null $parent_slug |
|
| 50 | + * @param string|null $menu_title |
|
| 51 | + * |
|
| 52 | + * @since 1.0.0 |
|
| 53 | + */ |
|
| 54 | + public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) { |
|
| 55 | + parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title ); |
|
| 56 | 56 | |
| 57 | - $this->task_ajax_adapters_registry = $task_ajax_adapters_registry; |
|
| 58 | - $this->version = $version; |
|
| 59 | - $this->menu_slug = $menu_slug; |
|
| 57 | + $this->task_ajax_adapters_registry = $task_ajax_adapters_registry; |
|
| 58 | + $this->version = $version; |
|
| 59 | + $this->menu_slug = $menu_slug; |
|
| 60 | 60 | |
| 61 | - } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Register the stylesheets and scripts for the admin area. |
|
| 65 | - * |
|
| 66 | - * @since 1.0.0 |
|
| 67 | - */ |
|
| 68 | - public function enqueue_scripts() { |
|
| 69 | - wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' ); |
|
| 70 | - wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array( |
|
| 71 | - 'jquery', |
|
| 72 | - 'wp-util' |
|
| 73 | - ), $this->version, true ); |
|
| 74 | - } |
|
| 63 | + /** |
|
| 64 | + * Register the stylesheets and scripts for the admin area. |
|
| 65 | + * |
|
| 66 | + * @since 1.0.0 |
|
| 67 | + */ |
|
| 68 | + public function enqueue_scripts() { |
|
| 69 | + wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' ); |
|
| 70 | + wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array( |
|
| 71 | + 'jquery', |
|
| 72 | + 'wp-util' |
|
| 73 | + ), $this->version, true ); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Render the page. |
|
| 78 | - * |
|
| 79 | - * @since 1.0.0 |
|
| 80 | - */ |
|
| 81 | - public function render() { |
|
| 76 | + /** |
|
| 77 | + * Render the page. |
|
| 78 | + * |
|
| 79 | + * @since 1.0.0 |
|
| 80 | + */ |
|
| 81 | + public function render() { |
|
| 82 | 82 | |
| 83 | - // Include the partial. |
|
| 84 | - include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' ); |
|
| 83 | + // Include the partial. |
|
| 84 | + include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' ); |
|
| 85 | 85 | |
| 86 | - } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | } |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @since 1.0.0 |
| 53 | 53 | */ |
| 54 | - public function __construct( $task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null ) { |
|
| 55 | - parent::__construct( $menu_slug, $page_title, $capability, $parent_slug, $menu_title ); |
|
| 54 | + public function __construct($task_ajax_adapters_registry, $version, $menu_slug, $page_title, $capability = 'manage_options', $parent_slug = null, $menu_title = null) { |
|
| 55 | + parent::__construct($menu_slug, $page_title, $capability, $parent_slug, $menu_title); |
|
| 56 | 56 | |
| 57 | 57 | $this->task_ajax_adapters_registry = $task_ajax_adapters_registry; |
| 58 | 58 | $this->version = $version; |
@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | * @since 1.0.0 |
| 67 | 67 | */ |
| 68 | 68 | public function enqueue_scripts() { |
| 69 | - wp_enqueue_style( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.css', array(), $this->version, 'all' ); |
|
| 70 | - wp_enqueue_script( $this->menu_slug, plugin_dir_url( __FILE__ ) . 'assets/tasks-page.js', array( |
|
| 69 | + wp_enqueue_style($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.css', array(), $this->version, 'all'); |
|
| 70 | + wp_enqueue_script($this->menu_slug, plugin_dir_url(__FILE__).'assets/tasks-page.js', array( |
|
| 71 | 71 | 'jquery', |
| 72 | 72 | 'wp-util' |
| 73 | - ), $this->version, true ); |
|
| 73 | + ), $this->version, true); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | public function render() { |
| 82 | 82 | |
| 83 | 83 | // Include the partial. |
| 84 | - include( plugin_dir_path( __FILE__ ) . 'assets/tasks-page.php' ); |
|
| 84 | + include(plugin_dir_path(__FILE__).'assets/tasks-page.php'); |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
@@ -16,30 +16,30 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | interface Task_Progress { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * The total number of elements to process. |
|
| 21 | - * |
|
| 22 | - * @param int $value The total number of elements to process. |
|
| 23 | - * |
|
| 24 | - * @since 1.0.0 |
|
| 25 | - */ |
|
| 26 | - function set_count( $value ); |
|
| 19 | + /** |
|
| 20 | + * The total number of elements to process. |
|
| 21 | + * |
|
| 22 | + * @param int $value The total number of elements to process. |
|
| 23 | + * |
|
| 24 | + * @since 1.0.0 |
|
| 25 | + */ |
|
| 26 | + function set_count( $value ); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Set the current processed item. |
|
| 30 | - * |
|
| 31 | - * @param int $counter The current item. |
|
| 32 | - * @param mixed $item The current item. |
|
| 33 | - * |
|
| 34 | - * @since 1.0.0 |
|
| 35 | - */ |
|
| 36 | - function set_progress( $counter, $item ); |
|
| 28 | + /** |
|
| 29 | + * Set the current processed item. |
|
| 30 | + * |
|
| 31 | + * @param int $counter The current item. |
|
| 32 | + * @param mixed $item The current item. |
|
| 33 | + * |
|
| 34 | + * @since 1.0.0 |
|
| 35 | + */ |
|
| 36 | + function set_progress( $counter, $item ); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Set the operation as complete. |
|
| 40 | - * |
|
| 41 | - * @since 1.0.0 |
|
| 42 | - */ |
|
| 43 | - function finish(); |
|
| 38 | + /** |
|
| 39 | + * Set the operation as complete. |
|
| 40 | + * |
|
| 41 | + * @since 1.0.0 |
|
| 42 | + */ |
|
| 43 | + function finish(); |
|
| 44 | 44 | |
| 45 | 45 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @since 1.0.0 |
| 25 | 25 | */ |
| 26 | - function set_count( $value ); |
|
| 26 | + function set_count($value); |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Set the current processed item. |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @since 1.0.0 |
| 35 | 35 | */ |
| 36 | - function set_progress( $counter, $item ); |
|
| 36 | + function set_progress($counter, $item); |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Set the operation as complete. |
@@ -4,29 +4,29 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Task_Ajax_Adapters_Registry { |
| 6 | 6 | |
| 7 | - private $task_ajax_adapters = array(); |
|
| 7 | + private $task_ajax_adapters = array(); |
|
| 8 | 8 | |
| 9 | - public function __construct( $adapters = array() ) { |
|
| 9 | + public function __construct( $adapters = array() ) { |
|
| 10 | 10 | |
| 11 | - $this->task_ajax_adapters = is_array( $adapters ) ? $adapters : array( $adapters ); |
|
| 11 | + $this->task_ajax_adapters = is_array( $adapters ) ? $adapters : array( $adapters ); |
|
| 12 | 12 | |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @param Task_Ajax_Adapter $task_ajax_adapter |
|
| 17 | - */ |
|
| 18 | - public function register( $task_ajax_adapter ) { |
|
| 15 | + /** |
|
| 16 | + * @param Task_Ajax_Adapter $task_ajax_adapter |
|
| 17 | + */ |
|
| 18 | + public function register( $task_ajax_adapter ) { |
|
| 19 | 19 | |
| 20 | - $this->task_ajax_adapters[] = $task_ajax_adapter; |
|
| 20 | + $this->task_ajax_adapters[] = $task_ajax_adapter; |
|
| 21 | 21 | |
| 22 | - } |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @return Task_Ajax_Adapter[] |
|
| 26 | - */ |
|
| 27 | - public function get_task_ajax_adapters() { |
|
| 24 | + /** |
|
| 25 | + * @return Task_Ajax_Adapter[] |
|
| 26 | + */ |
|
| 27 | + public function get_task_ajax_adapters() { |
|
| 28 | 28 | |
| 29 | - return $this->task_ajax_adapters; |
|
| 30 | - } |
|
| 29 | + return $this->task_ajax_adapters; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | } |
@@ -6,16 +6,16 @@ |
||
| 6 | 6 | |
| 7 | 7 | private $task_ajax_adapters = array(); |
| 8 | 8 | |
| 9 | - public function __construct( $adapters = array() ) { |
|
| 9 | + public function __construct($adapters = array()) { |
|
| 10 | 10 | |
| 11 | - $this->task_ajax_adapters = is_array( $adapters ) ? $adapters : array( $adapters ); |
|
| 11 | + $this->task_ajax_adapters = is_array($adapters) ? $adapters : array($adapters); |
|
| 12 | 12 | |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param Task_Ajax_Adapter $task_ajax_adapter |
| 17 | 17 | */ |
| 18 | - public function register( $task_ajax_adapter ) { |
|
| 18 | + public function register($task_ajax_adapter) { |
|
| 19 | 19 | |
| 20 | 20 | $this->task_ajax_adapters[] = $task_ajax_adapter; |
| 21 | 21 | |
@@ -18,84 +18,84 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Task_Ajax_Progress implements Task_Progress { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * The AJAX action, used to generate new nonces. |
|
| 23 | - * |
|
| 24 | - * @since 1.0.0 |
|
| 25 | - * @access private |
|
| 26 | - * @var string $action The AJAX action. |
|
| 27 | - */ |
|
| 28 | - private $action; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * The total number of items to process. |
|
| 32 | - * |
|
| 33 | - * @since 1.0.0 |
|
| 34 | - * @access private |
|
| 35 | - * @var int The total number of items to process. |
|
| 36 | - */ |
|
| 37 | - private $count; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * The current item index. |
|
| 41 | - * |
|
| 42 | - * @since 1.0.0 |
|
| 43 | - * @access private |
|
| 44 | - * @var int $index The current item index. |
|
| 45 | - */ |
|
| 46 | - private $index; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var Wordlift_Log_Service |
|
| 50 | - */ |
|
| 51 | - private $log; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Create a Task_Ajax_Progress instance with the specified |
|
| 55 | - * AJAX action. |
|
| 56 | - * |
|
| 57 | - * @param string $action The AJAX action. |
|
| 58 | - * |
|
| 59 | - * @since 1.0.0 |
|
| 60 | - * |
|
| 61 | - */ |
|
| 62 | - public function __construct( $action ) { |
|
| 63 | - |
|
| 64 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 65 | - |
|
| 66 | - $this->action = $action; |
|
| 67 | - |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * {@inheritDoc} |
|
| 72 | - */ |
|
| 73 | - function set_count( $value ) { |
|
| 74 | - |
|
| 75 | - $this->log->debug( "New count $value for action $this->action..." ); |
|
| 76 | - |
|
| 77 | - $this->count = $value; |
|
| 78 | - |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * {@inheritDoc} |
|
| 83 | - */ |
|
| 84 | - function set_progress( $index, $item ) { |
|
| 85 | - $this->index = $index; |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * {@inheritDoc} |
|
| 90 | - */ |
|
| 91 | - function finish() { |
|
| 92 | - wp_send_json_success( array( |
|
| 93 | - 'count' => $this->count, |
|
| 94 | - 'index' => $this->index, |
|
| 95 | - // $this->index is zero based. |
|
| 96 | - 'complete' => $this->index >= $this->count - 1, |
|
| 97 | - 'nonce' => wp_create_nonce( $this->action ), |
|
| 98 | - ) ); |
|
| 99 | - } |
|
| 21 | + /** |
|
| 22 | + * The AJAX action, used to generate new nonces. |
|
| 23 | + * |
|
| 24 | + * @since 1.0.0 |
|
| 25 | + * @access private |
|
| 26 | + * @var string $action The AJAX action. |
|
| 27 | + */ |
|
| 28 | + private $action; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * The total number of items to process. |
|
| 32 | + * |
|
| 33 | + * @since 1.0.0 |
|
| 34 | + * @access private |
|
| 35 | + * @var int The total number of items to process. |
|
| 36 | + */ |
|
| 37 | + private $count; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * The current item index. |
|
| 41 | + * |
|
| 42 | + * @since 1.0.0 |
|
| 43 | + * @access private |
|
| 44 | + * @var int $index The current item index. |
|
| 45 | + */ |
|
| 46 | + private $index; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var Wordlift_Log_Service |
|
| 50 | + */ |
|
| 51 | + private $log; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Create a Task_Ajax_Progress instance with the specified |
|
| 55 | + * AJAX action. |
|
| 56 | + * |
|
| 57 | + * @param string $action The AJAX action. |
|
| 58 | + * |
|
| 59 | + * @since 1.0.0 |
|
| 60 | + * |
|
| 61 | + */ |
|
| 62 | + public function __construct( $action ) { |
|
| 63 | + |
|
| 64 | + $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 65 | + |
|
| 66 | + $this->action = $action; |
|
| 67 | + |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * {@inheritDoc} |
|
| 72 | + */ |
|
| 73 | + function set_count( $value ) { |
|
| 74 | + |
|
| 75 | + $this->log->debug( "New count $value for action $this->action..." ); |
|
| 76 | + |
|
| 77 | + $this->count = $value; |
|
| 78 | + |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * {@inheritDoc} |
|
| 83 | + */ |
|
| 84 | + function set_progress( $index, $item ) { |
|
| 85 | + $this->index = $index; |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * {@inheritDoc} |
|
| 90 | + */ |
|
| 91 | + function finish() { |
|
| 92 | + wp_send_json_success( array( |
|
| 93 | + 'count' => $this->count, |
|
| 94 | + 'index' => $this->index, |
|
| 95 | + // $this->index is zero based. |
|
| 96 | + 'complete' => $this->index >= $this->count - 1, |
|
| 97 | + 'nonce' => wp_create_nonce( $this->action ), |
|
| 98 | + ) ); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | 101 | } |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | * @since 1.0.0 |
| 60 | 60 | * |
| 61 | 61 | */ |
| 62 | - public function __construct( $action ) { |
|
| 62 | + public function __construct($action) { |
|
| 63 | 63 | |
| 64 | - $this->log = Wordlift_Log_Service::get_logger( get_class() ); |
|
| 64 | + $this->log = Wordlift_Log_Service::get_logger(get_class()); |
|
| 65 | 65 | |
| 66 | 66 | $this->action = $action; |
| 67 | 67 | |
@@ -70,9 +70,9 @@ discard block |
||
| 70 | 70 | /** |
| 71 | 71 | * {@inheritDoc} |
| 72 | 72 | */ |
| 73 | - function set_count( $value ) { |
|
| 73 | + function set_count($value) { |
|
| 74 | 74 | |
| 75 | - $this->log->debug( "New count $value for action $this->action..." ); |
|
| 75 | + $this->log->debug("New count $value for action $this->action..."); |
|
| 76 | 76 | |
| 77 | 77 | $this->count = $value; |
| 78 | 78 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * {@inheritDoc} |
| 83 | 83 | */ |
| 84 | - function set_progress( $index, $item ) { |
|
| 84 | + function set_progress($index, $item) { |
|
| 85 | 85 | $this->index = $index; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | * {@inheritDoc} |
| 90 | 90 | */ |
| 91 | 91 | function finish() { |
| 92 | - wp_send_json_success( array( |
|
| 92 | + wp_send_json_success(array( |
|
| 93 | 93 | 'count' => $this->count, |
| 94 | 94 | 'index' => $this->index, |
| 95 | 95 | // $this->index is zero based. |
| 96 | 96 | 'complete' => $this->index >= $this->count - 1, |
| 97 | - 'nonce' => wp_create_nonce( $this->action ), |
|
| 98 | - ) ); |
|
| 97 | + 'nonce' => wp_create_nonce($this->action), |
|
| 98 | + )); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -15,15 +15,15 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | interface Task_Runner { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Start the task. |
|
| 20 | - * |
|
| 21 | - * @param int $limit The maximum number of items to process. |
|
| 22 | - * @param int $offset The starting offset (zero-based). |
|
| 23 | - * |
|
| 24 | - * @return mixed |
|
| 25 | - * @since 1.0.0 |
|
| 26 | - */ |
|
| 27 | - function start( $limit = 0, $offset = 0 ); |
|
| 18 | + /** |
|
| 19 | + * Start the task. |
|
| 20 | + * |
|
| 21 | + * @param int $limit The maximum number of items to process. |
|
| 22 | + * @param int $offset The starting offset (zero-based). |
|
| 23 | + * |
|
| 24 | + * @return mixed |
|
| 25 | + * @since 1.0.0 |
|
| 26 | + */ |
|
| 27 | + function start( $limit = 0, $offset = 0 ); |
|
| 28 | 28 | |
| 29 | 29 | } |
@@ -24,6 +24,6 @@ |
||
| 24 | 24 | * @return mixed |
| 25 | 25 | * @since 1.0.0 |
| 26 | 26 | */ |
| 27 | - function start( $limit = 0, $offset = 0 ); |
|
| 27 | + function start($limit = 0, $offset = 0); |
|
| 28 | 28 | |
| 29 | 29 | } |
@@ -16,60 +16,60 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Task_Ajax_Adapter { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var Task |
|
| 21 | - */ |
|
| 22 | - private $task; |
|
| 19 | + /** |
|
| 20 | + * @var Task |
|
| 21 | + */ |
|
| 22 | + private $task; |
|
| 23 | 23 | |
| 24 | - private $action_name; |
|
| 24 | + private $action_name; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Task_Ajax_Adapter constructor. |
|
| 28 | - * |
|
| 29 | - * @param Task $task |
|
| 30 | - */ |
|
| 31 | - public function __construct( $task ) { |
|
| 26 | + /** |
|
| 27 | + * Task_Ajax_Adapter constructor. |
|
| 28 | + * |
|
| 29 | + * @param Task $task |
|
| 30 | + */ |
|
| 31 | + public function __construct( $task ) { |
|
| 32 | 32 | |
| 33 | - $this->task = $task; |
|
| 33 | + $this->task = $task; |
|
| 34 | 34 | |
| 35 | - $this->action_name = $task->get_id(); |
|
| 36 | - add_action( 'wp_ajax_' . $this->action_name, array( $this, 'start' ) ); |
|
| 35 | + $this->action_name = $task->get_id(); |
|
| 36 | + add_action( 'wp_ajax_' . $this->action_name, array( $this, 'start' ) ); |
|
| 37 | 37 | |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - function start() { |
|
| 40 | + function start() { |
|
| 41 | 41 | |
| 42 | - // First check if there is a valid nonce. |
|
| 43 | - check_ajax_referer( $this->action_name ); |
|
| 42 | + // First check if there is a valid nonce. |
|
| 43 | + check_ajax_referer( $this->action_name ); |
|
| 44 | 44 | |
| 45 | - // Get the offset. |
|
| 46 | - $offset = filter_input( INPUT_POST, 'offset', FILTER_SANITIZE_NUMBER_INT ) ?: 0; |
|
| 45 | + // Get the offset. |
|
| 46 | + $offset = filter_input( INPUT_POST, 'offset', FILTER_SANITIZE_NUMBER_INT ) ?: 0; |
|
| 47 | 47 | |
| 48 | - // Compatibility fix for FacetWP, which somewhere in some filter checks for the $_POST array. |
|
| 49 | - unset( $_POST['offset'] ); |
|
| 48 | + // Compatibility fix for FacetWP, which somewhere in some filter checks for the $_POST array. |
|
| 49 | + unset( $_POST['offset'] ); |
|
| 50 | 50 | |
| 51 | - // Create an AJAX progress. The AJAX progress returns the progress data to the AJAX client, which |
|
| 52 | - // in turn calls the next batch. |
|
| 53 | - $ajax_progress = new Task_Ajax_Progress( $this->action_name ); |
|
| 51 | + // Create an AJAX progress. The AJAX progress returns the progress data to the AJAX client, which |
|
| 52 | + // in turn calls the next batch. |
|
| 53 | + $ajax_progress = new Task_Ajax_Progress( $this->action_name ); |
|
| 54 | 54 | |
| 55 | - // Finally create the task runner and start it. |
|
| 56 | - $task_runner = new Task_Single_Instance_Task_Runner( $this->task, true, array( $ajax_progress ) ); |
|
| 55 | + // Finally create the task runner and start it. |
|
| 56 | + $task_runner = new Task_Single_Instance_Task_Runner( $this->task, true, array( $ajax_progress ) ); |
|
| 57 | 57 | |
| 58 | - try { |
|
| 59 | - // Start the task runner, 1 item at a time. |
|
| 60 | - $task_runner->start( 1, $offset ); |
|
| 61 | - } catch ( Task_Another_Instance_Is_Running_Exception $e ) { |
|
| 62 | - wp_send_json_error( "A task is already running." ); |
|
| 63 | - } |
|
| 58 | + try { |
|
| 59 | + // Start the task runner, 1 item at a time. |
|
| 60 | + $task_runner->start( 1, $offset ); |
|
| 61 | + } catch ( Task_Another_Instance_Is_Running_Exception $e ) { |
|
| 62 | + wp_send_json_error( "A task is already running." ); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - } |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * @return Task |
|
| 69 | - */ |
|
| 70 | - public function get_task() { |
|
| 67 | + /** |
|
| 68 | + * @return Task |
|
| 69 | + */ |
|
| 70 | + public function get_task() { |
|
| 71 | 71 | |
| 72 | - return $this->task; |
|
| 73 | - } |
|
| 72 | + return $this->task; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | 75 | } |
@@ -28,38 +28,38 @@ |
||
| 28 | 28 | * |
| 29 | 29 | * @param Task $task |
| 30 | 30 | */ |
| 31 | - public function __construct( $task ) { |
|
| 31 | + public function __construct($task) { |
|
| 32 | 32 | |
| 33 | 33 | $this->task = $task; |
| 34 | 34 | |
| 35 | 35 | $this->action_name = $task->get_id(); |
| 36 | - add_action( 'wp_ajax_' . $this->action_name, array( $this, 'start' ) ); |
|
| 36 | + add_action('wp_ajax_'.$this->action_name, array($this, 'start')); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | function start() { |
| 41 | 41 | |
| 42 | 42 | // First check if there is a valid nonce. |
| 43 | - check_ajax_referer( $this->action_name ); |
|
| 43 | + check_ajax_referer($this->action_name); |
|
| 44 | 44 | |
| 45 | 45 | // Get the offset. |
| 46 | - $offset = filter_input( INPUT_POST, 'offset', FILTER_SANITIZE_NUMBER_INT ) ?: 0; |
|
| 46 | + $offset = filter_input(INPUT_POST, 'offset', FILTER_SANITIZE_NUMBER_INT) ?: 0; |
|
| 47 | 47 | |
| 48 | 48 | // Compatibility fix for FacetWP, which somewhere in some filter checks for the $_POST array. |
| 49 | - unset( $_POST['offset'] ); |
|
| 49 | + unset($_POST['offset']); |
|
| 50 | 50 | |
| 51 | 51 | // Create an AJAX progress. The AJAX progress returns the progress data to the AJAX client, which |
| 52 | 52 | // in turn calls the next batch. |
| 53 | - $ajax_progress = new Task_Ajax_Progress( $this->action_name ); |
|
| 53 | + $ajax_progress = new Task_Ajax_Progress($this->action_name); |
|
| 54 | 54 | |
| 55 | 55 | // Finally create the task runner and start it. |
| 56 | - $task_runner = new Task_Single_Instance_Task_Runner( $this->task, true, array( $ajax_progress ) ); |
|
| 56 | + $task_runner = new Task_Single_Instance_Task_Runner($this->task, true, array($ajax_progress)); |
|
| 57 | 57 | |
| 58 | 58 | try { |
| 59 | 59 | // Start the task runner, 1 item at a time. |
| 60 | - $task_runner->start( 1, $offset ); |
|
| 61 | - } catch ( Task_Another_Instance_Is_Running_Exception $e ) { |
|
| 62 | - wp_send_json_error( "A task is already running." ); |
|
| 60 | + $task_runner->start(1, $offset); |
|
| 61 | + } catch (Task_Another_Instance_Is_Running_Exception $e) { |
|
| 62 | + wp_send_json_error("A task is already running."); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | } |