@@ -14,84 +14,84 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class LSX_WETU_Importer_Settings { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Holds instance of the class |
|
| 19 | - * |
|
| 20 | - * @var object |
|
| 21 | - */ |
|
| 22 | - private static $instance; |
|
| 17 | + /** |
|
| 18 | + * Holds instance of the class |
|
| 19 | + * |
|
| 20 | + * @var object |
|
| 21 | + */ |
|
| 22 | + private static $instance; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Holds the default settings. |
|
| 26 | - * |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - public $defaults = array(); |
|
| 24 | + /** |
|
| 25 | + * Holds the default settings. |
|
| 26 | + * |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + public $defaults = array(); |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * Holds the settings fields available. |
|
| 33 | - * |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - public $fields = array(); |
|
| 31 | + /** |
|
| 32 | + * Holds the settings fields available. |
|
| 33 | + * |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + public $fields = array(); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Initialize the plugin by setting localization, filters, and administration functions. |
|
| 40 | - * |
|
| 41 | - * @since 1.0.0 |
|
| 42 | - * |
|
| 43 | - * @access private |
|
| 44 | - */ |
|
| 45 | - public function __construct() { |
|
| 46 | - $this->defaults = array( |
|
| 47 | - 'api_key' => '', |
|
| 48 | - 'disable_tour_title' => '', |
|
| 49 | - 'disable_tour_descriptions' => '', |
|
| 50 | - 'disable_tour_tags' => 'on', |
|
| 51 | - 'enable_tour_featured_random' => '', |
|
| 52 | - 'disable_accommodation_title' => '', |
|
| 53 | - 'disable_accommodation_descriptions' => '', |
|
| 54 | - 'disable_accommodation_filtering' => '', |
|
| 55 | - 'disable_accommodation_excerpts' => '', |
|
| 56 | - 'disable_destination_title' => '', |
|
| 57 | - 'disable_destination_descriptions' => '', |
|
| 58 | - 'image_replacing' => 'on', |
|
| 59 | - 'image_limit' => '15', |
|
| 60 | - 'image_scaling' => 'on', |
|
| 61 | - 'width' => '800', |
|
| 62 | - 'height' => '600', |
|
| 63 | - 'scaling' => 'h', |
|
| 64 | - 'enable_tour_ref_column' => '', |
|
| 65 | - 'cron_schedule' => 'daily', |
|
| 66 | - 'accommodation_images_cron' => '', |
|
| 67 | - ); |
|
| 68 | - $this->fields = array_keys( $this->defaults ); |
|
| 69 | - add_action( 'admin_init', array( $this, 'save_options' ) ); |
|
| 70 | - } |
|
| 38 | + /** |
|
| 39 | + * Initialize the plugin by setting localization, filters, and administration functions. |
|
| 40 | + * |
|
| 41 | + * @since 1.0.0 |
|
| 42 | + * |
|
| 43 | + * @access private |
|
| 44 | + */ |
|
| 45 | + public function __construct() { |
|
| 46 | + $this->defaults = array( |
|
| 47 | + 'api_key' => '', |
|
| 48 | + 'disable_tour_title' => '', |
|
| 49 | + 'disable_tour_descriptions' => '', |
|
| 50 | + 'disable_tour_tags' => 'on', |
|
| 51 | + 'enable_tour_featured_random' => '', |
|
| 52 | + 'disable_accommodation_title' => '', |
|
| 53 | + 'disable_accommodation_descriptions' => '', |
|
| 54 | + 'disable_accommodation_filtering' => '', |
|
| 55 | + 'disable_accommodation_excerpts' => '', |
|
| 56 | + 'disable_destination_title' => '', |
|
| 57 | + 'disable_destination_descriptions' => '', |
|
| 58 | + 'image_replacing' => 'on', |
|
| 59 | + 'image_limit' => '15', |
|
| 60 | + 'image_scaling' => 'on', |
|
| 61 | + 'width' => '800', |
|
| 62 | + 'height' => '600', |
|
| 63 | + 'scaling' => 'h', |
|
| 64 | + 'enable_tour_ref_column' => '', |
|
| 65 | + 'cron_schedule' => 'daily', |
|
| 66 | + 'accommodation_images_cron' => '', |
|
| 67 | + ); |
|
| 68 | + $this->fields = array_keys( $this->defaults ); |
|
| 69 | + add_action( 'admin_init', array( $this, 'save_options' ) ); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Return an instance of this class. |
|
| 74 | - * |
|
| 75 | - * @return object |
|
| 76 | - */ |
|
| 77 | - public static function get_instance() { |
|
| 78 | - // If the single instance hasn't been set, set it now. |
|
| 79 | - if ( ! isset( self::$instance ) ) { |
|
| 80 | - self::$instance = new self(); |
|
| 81 | - } |
|
| 82 | - return self::$instance; |
|
| 83 | - } |
|
| 72 | + /** |
|
| 73 | + * Return an instance of this class. |
|
| 74 | + * |
|
| 75 | + * @return object |
|
| 76 | + */ |
|
| 77 | + public static function get_instance() { |
|
| 78 | + // If the single instance hasn't been set, set it now. |
|
| 79 | + if ( ! isset( self::$instance ) ) { |
|
| 80 | + self::$instance = new self(); |
|
| 81 | + } |
|
| 82 | + return self::$instance; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * Display the importer welcome screen |
|
| 87 | - */ |
|
| 88 | - public function display_page() { |
|
| 89 | - $options = lsx_wetu_get_options(); |
|
| 90 | - foreach ( $options as $key => $value ) { |
|
| 91 | - $value = trim( $value ); |
|
| 92 | - } |
|
| 93 | - $options = wp_parse_args( $options, $this->defaults ); |
|
| 94 | - ?> |
|
| 85 | + /** |
|
| 86 | + * Display the importer welcome screen |
|
| 87 | + */ |
|
| 88 | + public function display_page() { |
|
| 89 | + $options = lsx_wetu_get_options(); |
|
| 90 | + foreach ( $options as $key => $value ) { |
|
| 91 | + $value = trim( $value ); |
|
| 92 | + } |
|
| 93 | + $options = wp_parse_args( $options, $this->defaults ); |
|
| 94 | + ?> |
|
| 95 | 95 | <div class="wrap"> |
| 96 | 96 | <form method="post" class=""> |
| 97 | 97 | <?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?> |
@@ -106,10 +106,10 @@ discard block |
||
| 106 | 106 | <td> |
| 107 | 107 | <input data-toggle="tooltip" data-placement="top" title="The API key can be found on your My Account page of your WETU account." type="text" value=" |
| 108 | 108 | <?php |
| 109 | - if ( isset( $options['api_key'] ) ) { |
|
| 110 | - echo esc_attr( $options['api_key'] ); |
|
| 111 | - } |
|
| 112 | - ?> |
|
| 109 | + if ( isset( $options['api_key'] ) ) { |
|
| 110 | + echo esc_attr( $options['api_key'] ); |
|
| 111 | + } |
|
| 112 | + ?> |
|
| 113 | 113 | " name="api_key" /> |
| 114 | 114 | </td> |
| 115 | 115 | </tr> |
@@ -126,10 +126,10 @@ discard block |
||
| 126 | 126 | <td> |
| 127 | 127 | <input type="checkbox" |
| 128 | 128 | <?php |
| 129 | - if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) { |
|
| 130 | - echo esc_attr( 'checked="checked"' ); |
|
| 131 | - } |
|
| 132 | - ?> |
|
| 129 | + if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) { |
|
| 130 | + echo esc_attr( 'checked="checked"' ); |
|
| 131 | + } |
|
| 132 | + ?> |
|
| 133 | 133 | name="disable_tour_title" /> |
| 134 | 134 | |
| 135 | 135 | <small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | <td> |
| 143 | 143 | <input type="checkbox" |
| 144 | 144 | <?php |
| 145 | - if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) { |
|
| 146 | - echo esc_attr( 'checked="checked"' ); |
|
| 147 | - } |
|
| 148 | - ?> |
|
| 145 | + if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) { |
|
| 146 | + echo esc_attr( 'checked="checked"' ); |
|
| 147 | + } |
|
| 148 | + ?> |
|
| 149 | 149 | name="disable_tour_descriptions" /> |
| 150 | 150 | |
| 151 | 151 | <small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | <td> |
| 159 | 159 | <input type="checkbox" |
| 160 | 160 | <?php |
| 161 | - if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) { |
|
| 162 | - echo esc_attr( 'checked="checked"' ); |
|
| 163 | - } |
|
| 164 | - ?> |
|
| 161 | + if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) { |
|
| 162 | + echo esc_attr( 'checked="checked"' ); |
|
| 163 | + } |
|
| 164 | + ?> |
|
| 165 | 165 | name="disable_tour_tags" /> |
| 166 | 166 | |
| 167 | 167 | <small><?php esc_html_e( 'Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer' ); ?></small> |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | <td> |
| 176 | 176 | <input type="checkbox" |
| 177 | 177 | <?php |
| 178 | - if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) { |
|
| 179 | - echo esc_attr( 'checked="checked"' ); |
|
| 180 | - } |
|
| 181 | - ?> |
|
| 178 | + if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) { |
|
| 179 | + echo esc_attr( 'checked="checked"' ); |
|
| 180 | + } |
|
| 181 | + ?> |
|
| 182 | 182 | name="enable_tour_ref_column" /> |
| 183 | 183 | <small><?php esc_html_e( 'Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer' ); ?></small> |
| 184 | 184 | </td> |
@@ -191,10 +191,10 @@ discard block |
||
| 191 | 191 | <td> |
| 192 | 192 | <input type="checkbox" |
| 193 | 193 | <?php |
| 194 | - if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) { |
|
| 195 | - echo esc_attr( 'checked="checked"' ); |
|
| 196 | - } |
|
| 197 | - ?> |
|
| 194 | + if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) { |
|
| 195 | + echo esc_attr( 'checked="checked"' ); |
|
| 196 | + } |
|
| 197 | + ?> |
|
| 198 | 198 | name="enable_tour_featured_random" /> |
| 199 | 199 | <small><?php esc_html_e( 'This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer' ); ?></small> |
| 200 | 200 | </td> |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | <td> |
| 214 | 214 | <input type="checkbox" |
| 215 | 215 | <?php |
| 216 | - if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) { |
|
| 217 | - echo esc_attr( 'checked="checked"' ); |
|
| 218 | - } |
|
| 219 | - ?> |
|
| 216 | + if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) { |
|
| 217 | + echo esc_attr( 'checked="checked"' ); |
|
| 218 | + } |
|
| 219 | + ?> |
|
| 220 | 220 | name="disable_accommodation_title" /> |
| 221 | 221 | |
| 222 | 222 | <small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
@@ -229,10 +229,10 @@ discard block |
||
| 229 | 229 | <td> |
| 230 | 230 | <input type="checkbox" |
| 231 | 231 | <?php |
| 232 | - if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) { |
|
| 233 | - echo esc_attr( 'checked="checked"' ); |
|
| 234 | - } |
|
| 235 | - ?> |
|
| 232 | + if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) { |
|
| 233 | + echo esc_attr( 'checked="checked"' ); |
|
| 234 | + } |
|
| 235 | + ?> |
|
| 236 | 236 | name="disable_accommodation_descriptions" /> |
| 237 | 237 | <small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
| 238 | 238 | </td> |
@@ -244,10 +244,10 @@ discard block |
||
| 244 | 244 | <td> |
| 245 | 245 | <input type="checkbox" |
| 246 | 246 | <?php |
| 247 | - if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) { |
|
| 248 | - echo esc_attr( 'checked="checked"' ); |
|
| 249 | - } |
|
| 250 | - ?> |
|
| 247 | + if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) { |
|
| 248 | + echo esc_attr( 'checked="checked"' ); |
|
| 249 | + } |
|
| 250 | + ?> |
|
| 251 | 251 | name="disable_accommodation_filtering" /> |
| 252 | 252 | <small><?php esc_html_e( 'This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer' ); ?></small> |
| 253 | 253 | </td> |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | <td> |
| 261 | 261 | <input type="checkbox" |
| 262 | 262 | <?php |
| 263 | - if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) { |
|
| 264 | - echo esc_attr( 'checked="checked"' ); |
|
| 265 | - } |
|
| 266 | - ?> |
|
| 263 | + if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) { |
|
| 264 | + echo esc_attr( 'checked="checked"' ); |
|
| 265 | + } |
|
| 266 | + ?> |
|
| 267 | 267 | name="disable_accommodation_excerpts" /> |
| 268 | 268 | <small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
| 269 | 269 | </td> |
@@ -282,10 +282,10 @@ discard block |
||
| 282 | 282 | <td> |
| 283 | 283 | <input type="checkbox" |
| 284 | 284 | <?php |
| 285 | - if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) { |
|
| 286 | - echo esc_attr( 'checked="checked"' ); |
|
| 287 | - } |
|
| 288 | - ?> |
|
| 285 | + if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) { |
|
| 286 | + echo esc_attr( 'checked="checked"' ); |
|
| 287 | + } |
|
| 288 | + ?> |
|
| 289 | 289 | name="disable_destination_title" /> |
| 290 | 290 | |
| 291 | 291 | <small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | <td> |
| 299 | 299 | <input type="checkbox" |
| 300 | 300 | <?php |
| 301 | - if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) { |
|
| 302 | - echo esc_attr( 'checked="checked"' ); |
|
| 303 | - } |
|
| 304 | - ?> |
|
| 301 | + if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) { |
|
| 302 | + echo esc_attr( 'checked="checked"' ); |
|
| 303 | + } |
|
| 304 | + ?> |
|
| 305 | 305 | name="disable_destination_descriptions" /> |
| 306 | 306 | <small><?php esc_html_e( 'If you are going to edit the destination descriptions on this site then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
| 307 | 307 | </td> |
@@ -320,10 +320,10 @@ discard block |
||
| 320 | 320 | <td> |
| 321 | 321 | <input type="checkbox" |
| 322 | 322 | <?php |
| 323 | - if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) { |
|
| 324 | - echo esc_attr( 'checked="checked"' ); |
|
| 325 | - } |
|
| 326 | - ?> |
|
| 323 | + if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) { |
|
| 324 | + echo esc_attr( 'checked="checked"' ); |
|
| 325 | + } |
|
| 326 | + ?> |
|
| 327 | 327 | name="image_replacing" /> |
| 328 | 328 | <p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p> |
| 329 | 329 | </td> |
@@ -335,10 +335,10 @@ discard block |
||
| 335 | 335 | <td> |
| 336 | 336 | <input placeholder="" type="text" value=" |
| 337 | 337 | <?php |
| 338 | - if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) { |
|
| 339 | - echo esc_attr( $options['image_limit'] ); |
|
| 340 | - } |
|
| 341 | - ?> |
|
| 338 | + if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) { |
|
| 339 | + echo esc_attr( $options['image_limit'] ); |
|
| 340 | + } |
|
| 341 | + ?> |
|
| 342 | 342 | " |
| 343 | 343 | name="image_limit" /> |
| 344 | 344 | </td> |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | <td> |
| 352 | 352 | <input type="checkbox" |
| 353 | 353 | <?php |
| 354 | - if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) { |
|
| 355 | - echo esc_attr( 'checked="checked"' ); |
|
| 356 | - } |
|
| 357 | - ?> |
|
| 354 | + if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) { |
|
| 355 | + echo esc_attr( 'checked="checked"' ); |
|
| 356 | + } |
|
| 357 | + ?> |
|
| 358 | 358 | name="image_scaling" /> |
| 359 | 359 | </td> |
| 360 | 360 | </tr> |
@@ -365,10 +365,10 @@ discard block |
||
| 365 | 365 | <td> |
| 366 | 366 | <input placeholder="800" type="text" value=" |
| 367 | 367 | <?php |
| 368 | - if ( isset( $options['width'] ) && '' !== $options['width'] ) { |
|
| 369 | - echo esc_attr( $options['width'] ); |
|
| 370 | - } |
|
| 371 | - ?> |
|
| 368 | + if ( isset( $options['width'] ) && '' !== $options['width'] ) { |
|
| 369 | + echo esc_attr( $options['width'] ); |
|
| 370 | + } |
|
| 371 | + ?> |
|
| 372 | 372 | " |
| 373 | 373 | name="width" /> |
| 374 | 374 | </td> |
@@ -380,10 +380,10 @@ discard block |
||
| 380 | 380 | <td> |
| 381 | 381 | <input placeholder="600" type="text" value=" |
| 382 | 382 | <?php |
| 383 | - if ( isset( $options['height'] ) && '' !== $options['height'] ) { |
|
| 384 | - echo esc_attr( $options['height'] ); |
|
| 385 | - } |
|
| 386 | - ?> |
|
| 383 | + if ( isset( $options['height'] ) && '' !== $options['height'] ) { |
|
| 384 | + echo esc_attr( $options['height'] ); |
|
| 385 | + } |
|
| 386 | + ?> |
|
| 387 | 387 | " |
| 388 | 388 | name="height" /> |
| 389 | 389 | </td> |
@@ -396,52 +396,52 @@ discard block |
||
| 396 | 396 | <td> |
| 397 | 397 | <input type="radio" |
| 398 | 398 | <?php |
| 399 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) { |
|
| 400 | - echo esc_attr( 'checked="checked"' ); |
|
| 401 | - } |
|
| 402 | - ?> |
|
| 399 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) { |
|
| 400 | + echo esc_attr( 'checked="checked"' ); |
|
| 401 | + } |
|
| 402 | + ?> |
|
| 403 | 403 | name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br /> |
| 404 | 404 | <input type="radio" |
| 405 | 405 | <?php |
| 406 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) { |
|
| 407 | - echo esc_attr( 'checked="checked"' ); |
|
| 408 | - } |
|
| 409 | - ?> |
|
| 406 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) { |
|
| 407 | + echo esc_attr( 'checked="checked"' ); |
|
| 408 | + } |
|
| 409 | + ?> |
|
| 410 | 410 | name="scaling" value="c" /> <?php esc_html_e( 'Crop image to fit fully into the frame, Crop is taken from middle, preserving as much of the image as possible.', 'lsx-wetu-importer' ); ?><br /> |
| 411 | 411 | <input type="radio" |
| 412 | 412 | <?php |
| 413 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) { |
|
| 414 | - echo esc_attr( 'checked="checked"' ); |
|
| 415 | - } |
|
| 416 | - ?> |
|
| 413 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) { |
|
| 414 | + echo esc_attr( 'checked="checked"' ); |
|
| 415 | + } |
|
| 416 | + ?> |
|
| 417 | 417 | name="scaling" value="h" /> <?php esc_html_e( 'Crop image to fit fully into the frame, but resize to height first, then crop on width if needed', 'lsx-wetu-importer' ); ?><br /> |
| 418 | 418 | <input type="radio" |
| 419 | 419 | <?php |
| 420 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) { |
|
| 421 | - echo esc_attr( 'checked="checked"' ); |
|
| 422 | - } |
|
| 423 | - ?> |
|
| 420 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) { |
|
| 421 | + echo esc_attr( 'checked="checked"' ); |
|
| 422 | + } |
|
| 423 | + ?> |
|
| 424 | 424 | name="scaling" value="w" /> <?php esc_html_e( 'Crop image to fit fully into the frame, but resize to width first, then crop on height if needed', 'lsx-wetu-importer' ); ?><br /> |
| 425 | 425 | <input type="radio" |
| 426 | 426 | <?php |
| 427 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) { |
|
| 428 | - echo esc_attr( 'checked="checked"' ); |
|
| 429 | - } |
|
| 430 | - ?> |
|
| 427 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) { |
|
| 428 | + echo esc_attr( 'checked="checked"' ); |
|
| 429 | + } |
|
| 430 | + ?> |
|
| 431 | 431 | name="scaling" value="nf" /> <?php esc_html_e( 'Resize the image to fit within the frame. but pad the image with white to ensure the resolution matches the frame', 'lsx-wetu-importer' ); ?><br /> |
| 432 | 432 | <input type="radio" |
| 433 | 433 | <?php |
| 434 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) { |
|
| 435 | - echo esc_attr( 'checked="checked"' ); |
|
| 436 | - } |
|
| 437 | - ?> |
|
| 434 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) { |
|
| 435 | + echo esc_attr( 'checked="checked"' ); |
|
| 436 | + } |
|
| 437 | + ?> |
|
| 438 | 438 | name="scaling" value="n" /> <?php esc_html_e( 'Resize the image to fit within the frame. but do not upscale the image.', 'lsx-wetu-importer' ); ?><br /> |
| 439 | 439 | <input type="radio" |
| 440 | 440 | <?php |
| 441 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) { |
|
| 442 | - echo esc_attr( 'checked="checked"' ); |
|
| 443 | - } |
|
| 444 | - ?> |
|
| 441 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) { |
|
| 442 | + echo esc_attr( 'checked="checked"' ); |
|
| 443 | + } |
|
| 444 | + ?> |
|
| 445 | 445 | name="scaling" value="W" /> <?php esc_html_e( 'Resize the image to fit within the frame. Image will not exceed specified dimensions', 'lsx-wetu-importer' ); ?> |
| 446 | 446 | </td> |
| 447 | 447 | </tr> |
@@ -459,28 +459,28 @@ discard block |
||
| 459 | 459 | <td> |
| 460 | 460 | <select name="cron_schedule" id="cron_schedule" class="widefat layout"> |
| 461 | 461 | <?php |
| 462 | - if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) { |
|
| 463 | - $schedule = $options['cron_schedule']; |
|
| 464 | - } else { |
|
| 465 | - $schedule = 'daily'; |
|
| 466 | - } |
|
| 467 | - $timeslots = array( |
|
| 468 | - 'daily' => __( 'Daily', 'lsx-wetu-importer' ), |
|
| 469 | - 'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ), |
|
| 470 | - 'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ), |
|
| 471 | - 'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ), |
|
| 472 | - 'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ), |
|
| 473 | - 'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ), |
|
| 474 | - 'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ), |
|
| 475 | - 'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ), |
|
| 476 | - ); |
|
| 477 | - foreach ( $timeslots as $key => $name ) { |
|
| 478 | - $selected = ( $schedule == $key ) ? ' selected="selected"' : ''; |
|
| 479 | - ?> |
|
| 462 | + if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) { |
|
| 463 | + $schedule = $options['cron_schedule']; |
|
| 464 | + } else { |
|
| 465 | + $schedule = 'daily'; |
|
| 466 | + } |
|
| 467 | + $timeslots = array( |
|
| 468 | + 'daily' => __( 'Daily', 'lsx-wetu-importer' ), |
|
| 469 | + 'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ), |
|
| 470 | + 'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ), |
|
| 471 | + 'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ), |
|
| 472 | + 'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ), |
|
| 473 | + 'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ), |
|
| 474 | + 'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ), |
|
| 475 | + 'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ), |
|
| 476 | + ); |
|
| 477 | + foreach ( $timeslots as $key => $name ) { |
|
| 478 | + $selected = ( $schedule == $key ) ? ' selected="selected"' : ''; |
|
| 479 | + ?> |
|
| 480 | 480 | <option value="<?php echo wp_kses_post( $key ); ?>" id="<?php echo wp_kses_post( $key ); ?>" <?php echo wp_kses_post( $selected ); ?>><?php echo wp_kses_post( $name ); ?></option> |
| 481 | 481 | <?php |
| 482 | - } |
|
| 483 | - ?> |
|
| 482 | + } |
|
| 483 | + ?> |
|
| 484 | 484 | </select> |
| 485 | 485 | </td> |
| 486 | 486 | </tr> |
@@ -491,10 +491,10 @@ discard block |
||
| 491 | 491 | <td> |
| 492 | 492 | <input type="checkbox" |
| 493 | 493 | <?php |
| 494 | - if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) { |
|
| 495 | - echo esc_attr( 'checked="checked"' ); |
|
| 496 | - } |
|
| 497 | - ?> |
|
| 494 | + if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) { |
|
| 495 | + echo esc_attr( 'checked="checked"' ); |
|
| 496 | + } |
|
| 497 | + ?> |
|
| 498 | 498 | name="accommodation_images_cron" /> |
| 499 | 499 | <p><?php esc_html_e( 'Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer' ); ?></p> |
| 500 | 500 | </td> |
@@ -506,25 +506,25 @@ discard block |
||
| 506 | 506 | </form> |
| 507 | 507 | </div> |
| 508 | 508 | <?php |
| 509 | - } |
|
| 509 | + } |
|
| 510 | 510 | |
| 511 | - /** |
|
| 512 | - * Save the options fields |
|
| 513 | - * |
|
| 514 | - * @return void |
|
| 515 | - */ |
|
| 516 | - public function save_options() { |
|
| 517 | - if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) { |
|
| 518 | - return; |
|
| 519 | - } |
|
| 520 | - $data_to_save = array(); |
|
| 521 | - foreach ( $this->defaults as $key => $field ) { |
|
| 522 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 523 | - $data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] ); |
|
| 524 | - } else { |
|
| 525 | - $data_to_save[ $key ] = ''; |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - update_option( 'lsx_wetu_importer_settings', $data_to_save ); |
|
| 529 | - } |
|
| 511 | + /** |
|
| 512 | + * Save the options fields |
|
| 513 | + * |
|
| 514 | + * @return void |
|
| 515 | + */ |
|
| 516 | + public function save_options() { |
|
| 517 | + if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) { |
|
| 518 | + return; |
|
| 519 | + } |
|
| 520 | + $data_to_save = array(); |
|
| 521 | + foreach ( $this->defaults as $key => $field ) { |
|
| 522 | + if ( isset( $_POST[ $key ] ) ) { |
|
| 523 | + $data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] ); |
|
| 524 | + } else { |
|
| 525 | + $data_to_save[ $key ] = ''; |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + update_option( 'lsx_wetu_importer_settings', $data_to_save ); |
|
| 529 | + } |
|
| 530 | 530 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | 'cron_schedule' => 'daily', |
| 66 | 66 | 'accommodation_images_cron' => '', |
| 67 | 67 | ); |
| 68 | - $this->fields = array_keys( $this->defaults ); |
|
| 69 | - add_action( 'admin_init', array( $this, 'save_options' ) ); |
|
| 68 | + $this->fields = array_keys($this->defaults); |
|
| 69 | + add_action('admin_init', array($this, 'save_options')); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | public static function get_instance() { |
| 78 | 78 | // If the single instance hasn't been set, set it now. |
| 79 | - if ( ! isset( self::$instance ) ) { |
|
| 79 | + if (!isset(self::$instance)) { |
|
| 80 | 80 | self::$instance = new self(); |
| 81 | 81 | } |
| 82 | 82 | return self::$instance; |
@@ -87,27 +87,27 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function display_page() { |
| 89 | 89 | $options = lsx_wetu_get_options(); |
| 90 | - foreach ( $options as $key => $value ) { |
|
| 91 | - $value = trim( $value ); |
|
| 90 | + foreach ($options as $key => $value) { |
|
| 91 | + $value = trim($value); |
|
| 92 | 92 | } |
| 93 | - $options = wp_parse_args( $options, $this->defaults ); |
|
| 93 | + $options = wp_parse_args($options, $this->defaults); |
|
| 94 | 94 | ?> |
| 95 | 95 | <div class="wrap"> |
| 96 | 96 | <form method="post" class=""> |
| 97 | - <?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?> |
|
| 98 | - <?php do_action( 'lsx_wetu_importer_settings_before' ); ?> |
|
| 99 | - <h1><?php esc_html_e( 'General', 'lsx-wetu-importer' ); ?></h1> |
|
| 97 | + <?php wp_nonce_field('lsx_wetu_importer_save', 'lsx_wetu_importer_save_options'); ?> |
|
| 98 | + <?php do_action('lsx_wetu_importer_settings_before'); ?> |
|
| 99 | + <h1><?php esc_html_e('General', 'lsx-wetu-importer'); ?></h1> |
|
| 100 | 100 | <table class="form-table"> |
| 101 | 101 | <tbody> |
| 102 | 102 | <tr class="form-field"> |
| 103 | 103 | <th scope="row"> |
| 104 | - <label for="wetu_api_key"><span title="The API key can be found on your My Account page of your WETU account." id="doc-tooltip" class="dashicons dashicons-editor-help tooltip"></span> <?php esc_html_e( 'API Key', 'lsx-wetu-importer' ); ?></label> |
|
| 104 | + <label for="wetu_api_key"><span title="The API key can be found on your My Account page of your WETU account." id="doc-tooltip" class="dashicons dashicons-editor-help tooltip"></span> <?php esc_html_e('API Key', 'lsx-wetu-importer'); ?></label> |
|
| 105 | 105 | </th> |
| 106 | 106 | <td> |
| 107 | 107 | <input data-toggle="tooltip" data-placement="top" title="The API key can be found on your My Account page of your WETU account." type="text" value=" |
| 108 | 108 | <?php |
| 109 | - if ( isset( $options['api_key'] ) ) { |
|
| 110 | - echo esc_attr( $options['api_key'] ); |
|
| 109 | + if (isset($options['api_key'])) { |
|
| 110 | + echo esc_attr($options['api_key']); |
|
| 111 | 111 | } |
| 112 | 112 | ?> |
| 113 | 113 | " name="api_key" /> |
@@ -116,227 +116,227 @@ discard block |
||
| 116 | 116 | </tbody> |
| 117 | 117 | </table> |
| 118 | 118 | |
| 119 | - <h1><?php esc_html_e( 'Tours', 'lsx-wetu-importer' ); ?></h1> |
|
| 119 | + <h1><?php esc_html_e('Tours', 'lsx-wetu-importer'); ?></h1> |
|
| 120 | 120 | <table class="form-table"> |
| 121 | 121 | <tbody> |
| 122 | 122 | <tr class="form-field -wrap"> |
| 123 | 123 | <th scope="row"> |
| 124 | - <label for="disable_tour_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label> |
|
| 124 | + <label for="disable_tour_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label> |
|
| 125 | 125 | </th> |
| 126 | 126 | <td> |
| 127 | 127 | <input type="checkbox" |
| 128 | 128 | <?php |
| 129 | - if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) { |
|
| 130 | - echo esc_attr( 'checked="checked"' ); |
|
| 129 | + if (isset($options['disable_tour_title']) && '' !== $options['disable_tour_title']) { |
|
| 130 | + echo esc_attr('checked="checked"'); |
|
| 131 | 131 | } |
| 132 | 132 | ?> |
| 133 | 133 | name="disable_tour_title" /> |
| 134 | 134 | |
| 135 | - <small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
|
| 135 | + <small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small> |
|
| 136 | 136 | </td> |
| 137 | 137 | </tr> |
| 138 | 138 | <tr class="form-field -wrap"> |
| 139 | 139 | <th scope="row"> |
| 140 | - <label for="disable_tour_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label> |
|
| 140 | + <label for="disable_tour_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label> |
|
| 141 | 141 | </th> |
| 142 | 142 | <td> |
| 143 | 143 | <input type="checkbox" |
| 144 | 144 | <?php |
| 145 | - if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) { |
|
| 146 | - echo esc_attr( 'checked="checked"' ); |
|
| 145 | + if (isset($options['disable_tour_descriptions']) && '' !== $options['disable_tour_descriptions']) { |
|
| 146 | + echo esc_attr('checked="checked"'); |
|
| 147 | 147 | } |
| 148 | 148 | ?> |
| 149 | 149 | name="disable_tour_descriptions" /> |
| 150 | 150 | |
| 151 | - <small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
|
| 151 | + <small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small> |
|
| 152 | 152 | </td> |
| 153 | 153 | </tr> |
| 154 | 154 | <tr class="form-field -wrap"> |
| 155 | 155 | <th scope="row"> |
| 156 | - <label for="disable_tour_tags"><?php esc_html_e( 'Disable Tags / Travel Styles', 'lsx-wetu-importer' ); ?></label> |
|
| 156 | + <label for="disable_tour_tags"><?php esc_html_e('Disable Tags / Travel Styles', 'lsx-wetu-importer'); ?></label> |
|
| 157 | 157 | </th> |
| 158 | 158 | <td> |
| 159 | 159 | <input type="checkbox" |
| 160 | 160 | <?php |
| 161 | - if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) { |
|
| 162 | - echo esc_attr( 'checked="checked"' ); |
|
| 161 | + if (isset($options['disable_tour_tags']) && '' !== $options['disable_tour_tags']) { |
|
| 162 | + echo esc_attr('checked="checked"'); |
|
| 163 | 163 | } |
| 164 | 164 | ?> |
| 165 | 165 | name="disable_tour_tags" /> |
| 166 | 166 | |
| 167 | - <small><?php esc_html_e( 'Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer' ); ?></small> |
|
| 167 | + <small><?php esc_html_e('Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer'); ?></small> |
|
| 168 | 168 | </td> |
| 169 | 169 | </tr> |
| 170 | 170 | |
| 171 | 171 | <tr class="form-field -wrap"> |
| 172 | 172 | <th scope="row"> |
| 173 | - <label for="enable_tour_ref_column"><?php esc_html_e( 'Enable Reference Column', 'lsx-wetu-importer' ); ?></label> |
|
| 173 | + <label for="enable_tour_ref_column"><?php esc_html_e('Enable Reference Column', 'lsx-wetu-importer'); ?></label> |
|
| 174 | 174 | </th> |
| 175 | 175 | <td> |
| 176 | 176 | <input type="checkbox" |
| 177 | 177 | <?php |
| 178 | - if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) { |
|
| 179 | - echo esc_attr( 'checked="checked"' ); |
|
| 178 | + if (isset($options['enable_tour_ref_column']) && '' !== $options['enable_tour_ref_column']) { |
|
| 179 | + echo esc_attr('checked="checked"'); |
|
| 180 | 180 | } |
| 181 | 181 | ?> |
| 182 | 182 | name="enable_tour_ref_column" /> |
| 183 | - <small><?php esc_html_e( 'Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer' ); ?></small> |
|
| 183 | + <small><?php esc_html_e('Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer'); ?></small> |
|
| 184 | 184 | </td> |
| 185 | 185 | </tr> |
| 186 | 186 | |
| 187 | 187 | <tr class="form-field -wrap"> |
| 188 | 188 | <th scope="row"> |
| 189 | - <label for="enable_tour_featured_random"><?php esc_html_e( 'Randomize Featured Image', 'lsx-wetu-importer' ); ?></label> |
|
| 189 | + <label for="enable_tour_featured_random"><?php esc_html_e('Randomize Featured Image', 'lsx-wetu-importer'); ?></label> |
|
| 190 | 190 | </th> |
| 191 | 191 | <td> |
| 192 | 192 | <input type="checkbox" |
| 193 | 193 | <?php |
| 194 | - if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) { |
|
| 195 | - echo esc_attr( 'checked="checked"' ); |
|
| 194 | + if (isset($options['enable_tour_featured_random']) && '' !== $options['enable_tour_featured_random']) { |
|
| 195 | + echo esc_attr('checked="checked"'); |
|
| 196 | 196 | } |
| 197 | 197 | ?> |
| 198 | 198 | name="enable_tour_featured_random" /> |
| 199 | - <small><?php esc_html_e( 'This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer' ); ?></small> |
|
| 199 | + <small><?php esc_html_e('This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer'); ?></small> |
|
| 200 | 200 | </td> |
| 201 | 201 | </tr> |
| 202 | 202 | </tbody> |
| 203 | 203 | </table> |
| 204 | 204 | |
| 205 | - <h1><?php esc_html_e( 'Accommodation', 'lsx-wetu-importer' ); ?></h1> |
|
| 205 | + <h1><?php esc_html_e('Accommodation', 'lsx-wetu-importer'); ?></h1> |
|
| 206 | 206 | |
| 207 | 207 | <table class="form-table"> |
| 208 | 208 | <tbody> |
| 209 | 209 | <tr class="form-field -wrap"> |
| 210 | 210 | <th scope="row"> |
| 211 | - <label for="disable_accommodation_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label> |
|
| 211 | + <label for="disable_accommodation_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label> |
|
| 212 | 212 | </th> |
| 213 | 213 | <td> |
| 214 | 214 | <input type="checkbox" |
| 215 | 215 | <?php |
| 216 | - if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) { |
|
| 217 | - echo esc_attr( 'checked="checked"' ); |
|
| 216 | + if (isset($options['disable_accommodation_title']) && '' !== $options['disable_accommodation_title']) { |
|
| 217 | + echo esc_attr('checked="checked"'); |
|
| 218 | 218 | } |
| 219 | 219 | ?> |
| 220 | 220 | name="disable_accommodation_title" /> |
| 221 | 221 | |
| 222 | - <small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
|
| 222 | + <small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small> |
|
| 223 | 223 | </td> |
| 224 | 224 | </tr> |
| 225 | 225 | <tr class="form-field -wrap"> |
| 226 | 226 | <th scope="row"> |
| 227 | - <label for="disable_accommodation_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label> |
|
| 227 | + <label for="disable_accommodation_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label> |
|
| 228 | 228 | </th> |
| 229 | 229 | <td> |
| 230 | 230 | <input type="checkbox" |
| 231 | 231 | <?php |
| 232 | - if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) { |
|
| 233 | - echo esc_attr( 'checked="checked"' ); |
|
| 232 | + if (isset($options['disable_accommodation_descriptions']) && '' !== $options['disable_accommodation_descriptions']) { |
|
| 233 | + echo esc_attr('checked="checked"'); |
|
| 234 | 234 | } |
| 235 | 235 | ?> |
| 236 | 236 | name="disable_accommodation_descriptions" /> |
| 237 | - <small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
|
| 237 | + <small><?php esc_html_e('If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer'); ?></small> |
|
| 238 | 238 | </td> |
| 239 | 239 | </tr> |
| 240 | 240 | <tr class="form-field -wrap"> |
| 241 | 241 | <th scope="row"> |
| 242 | - <label for="disable_accommodation_filtering"><?php esc_html_e( 'Disable Description Filtering', 'lsx-wetu-importer' ); ?></label> |
|
| 242 | + <label for="disable_accommodation_filtering"><?php esc_html_e('Disable Description Filtering', 'lsx-wetu-importer'); ?></label> |
|
| 243 | 243 | </th> |
| 244 | 244 | <td> |
| 245 | 245 | <input type="checkbox" |
| 246 | 246 | <?php |
| 247 | - if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) { |
|
| 248 | - echo esc_attr( 'checked="checked"' ); |
|
| 247 | + if (isset($options['disable_accommodation_filtering']) && '' !== $options['disable_accommodation_filtering']) { |
|
| 248 | + echo esc_attr('checked="checked"'); |
|
| 249 | 249 | } |
| 250 | 250 | ?> |
| 251 | 251 | name="disable_accommodation_filtering" /> |
| 252 | - <small><?php esc_html_e( 'This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer' ); ?></small> |
|
| 252 | + <small><?php esc_html_e('This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer'); ?></small> |
|
| 253 | 253 | </td> |
| 254 | 254 | </tr> |
| 255 | 255 | |
| 256 | 256 | <tr class="form-field -wrap"> |
| 257 | 257 | <th scope="row"> |
| 258 | - <label for="disable_accommodation_excerpts"><?php esc_html_e( 'Disable Excerpts', 'lsx-wetu-importer' ); ?></label> |
|
| 258 | + <label for="disable_accommodation_excerpts"><?php esc_html_e('Disable Excerpts', 'lsx-wetu-importer'); ?></label> |
|
| 259 | 259 | </th> |
| 260 | 260 | <td> |
| 261 | 261 | <input type="checkbox" |
| 262 | 262 | <?php |
| 263 | - if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) { |
|
| 264 | - echo esc_attr( 'checked="checked"' ); |
|
| 263 | + if (isset($options['disable_accommodation_excerpts']) && '' !== $options['disable_accommodation_excerpts']) { |
|
| 264 | + echo esc_attr('checked="checked"'); |
|
| 265 | 265 | } |
| 266 | 266 | ?> |
| 267 | 267 | name="disable_accommodation_excerpts" /> |
| 268 | - <small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
|
| 268 | + <small><?php esc_html_e('If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer'); ?></small> |
|
| 269 | 269 | </td> |
| 270 | 270 | </tr> |
| 271 | 271 | </tbody> |
| 272 | 272 | </table> |
| 273 | 273 | |
| 274 | - <h1><?php esc_html_e( 'Destinations', 'lsx-wetu-importer' ); ?></h1> |
|
| 274 | + <h1><?php esc_html_e('Destinations', 'lsx-wetu-importer'); ?></h1> |
|
| 275 | 275 | |
| 276 | 276 | <table class="form-table"> |
| 277 | 277 | <tbody> |
| 278 | 278 | <tr class="form-field -wrap"> |
| 279 | 279 | <th scope="row"> |
| 280 | - <label for="disable_destination_title"><?php esc_html_e( 'Enable Custom Titles', 'lsx-wetu-importer' ); ?></label> |
|
| 280 | + <label for="disable_destination_title"><?php esc_html_e('Enable Custom Titles', 'lsx-wetu-importer'); ?></label> |
|
| 281 | 281 | </th> |
| 282 | 282 | <td> |
| 283 | 283 | <input type="checkbox" |
| 284 | 284 | <?php |
| 285 | - if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) { |
|
| 286 | - echo esc_attr( 'checked="checked"' ); |
|
| 285 | + if (isset($options['disable_destination_title']) && '' !== $options['disable_destination_title']) { |
|
| 286 | + echo esc_attr('checked="checked"'); |
|
| 287 | 287 | } |
| 288 | 288 | ?> |
| 289 | 289 | name="disable_destination_title" /> |
| 290 | 290 | |
| 291 | - <small><?php esc_html_e( 'If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
|
| 291 | + <small><?php esc_html_e('If you are going to manage your tour descriptions on this site and not on WETU then enable this setting.', 'lsx-wetu-importer'); ?></small> |
|
| 292 | 292 | </td> |
| 293 | 293 | </tr> |
| 294 | 294 | <tr class="form-field -wrap"> |
| 295 | 295 | <th scope="row"> |
| 296 | - <label for="disable_destination_descriptions"><?php esc_html_e( 'Disable Descriptions', 'lsx-wetu-importer' ); ?></label> |
|
| 296 | + <label for="disable_destination_descriptions"><?php esc_html_e('Disable Descriptions', 'lsx-wetu-importer'); ?></label> |
|
| 297 | 297 | </th> |
| 298 | 298 | <td> |
| 299 | 299 | <input type="checkbox" |
| 300 | 300 | <?php |
| 301 | - if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) { |
|
| 302 | - echo esc_attr( 'checked="checked"' ); |
|
| 301 | + if (isset($options['disable_destination_descriptions']) && '' !== $options['disable_destination_descriptions']) { |
|
| 302 | + echo esc_attr('checked="checked"'); |
|
| 303 | 303 | } |
| 304 | 304 | ?> |
| 305 | 305 | name="disable_destination_descriptions" /> |
| 306 | - <small><?php esc_html_e( 'If you are going to edit the destination descriptions on this site then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
|
| 306 | + <small><?php esc_html_e('If you are going to edit the destination descriptions on this site then enable this setting.', 'lsx-wetu-importer'); ?></small> |
|
| 307 | 307 | </td> |
| 308 | 308 | </tr> |
| 309 | 309 | </tbody> |
| 310 | 310 | </table> |
| 311 | 311 | |
| 312 | - <h1><?php esc_html_e( 'Images', 'lsx-wetu-importer' ); ?></h1> |
|
| 312 | + <h1><?php esc_html_e('Images', 'lsx-wetu-importer'); ?></h1> |
|
| 313 | 313 | |
| 314 | 314 | <table class="form-table"> |
| 315 | 315 | <tbody> |
| 316 | 316 | <tr class="form-field -wrap"> |
| 317 | 317 | <th scope="row"> |
| 318 | - <label for="image_replacing"><?php esc_html_e( 'Replace Images', 'lsx-wetu-importer' ); ?></label> |
|
| 318 | + <label for="image_replacing"><?php esc_html_e('Replace Images', 'lsx-wetu-importer'); ?></label> |
|
| 319 | 319 | </th> |
| 320 | 320 | <td> |
| 321 | 321 | <input type="checkbox" |
| 322 | 322 | <?php |
| 323 | - if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) { |
|
| 324 | - echo esc_attr( 'checked="checked"' ); |
|
| 323 | + if (isset($options['image_replacing']) && '' !== $options['image_replacing']) { |
|
| 324 | + echo esc_attr('checked="checked"'); |
|
| 325 | 325 | } |
| 326 | 326 | ?> |
| 327 | 327 | name="image_replacing" /> |
| 328 | - <p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p> |
|
| 328 | + <p><?php esc_html_e('Do you want your images to be replaced on each import.', 'lsx-wetu-importer'); ?></p> |
|
| 329 | 329 | </td> |
| 330 | 330 | </tr> |
| 331 | 331 | <tr class="form-field -wrap"> |
| 332 | 332 | <th scope="row"> |
| 333 | - <label for="image_limit"> <?php esc_html_e( 'Limit the amount of images imported to the gallery', 'lsx-wetu-importer' ); ?></label> |
|
| 333 | + <label for="image_limit"> <?php esc_html_e('Limit the amount of images imported to the gallery', 'lsx-wetu-importer'); ?></label> |
|
| 334 | 334 | </th> |
| 335 | 335 | <td> |
| 336 | 336 | <input placeholder="" type="text" value=" |
| 337 | 337 | <?php |
| 338 | - if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) { |
|
| 339 | - echo esc_attr( $options['image_limit'] ); |
|
| 338 | + if (isset($options['image_limit']) && '' !== $options['image_limit']) { |
|
| 339 | + echo esc_attr($options['image_limit']); |
|
| 340 | 340 | } |
| 341 | 341 | ?> |
| 342 | 342 | " |
@@ -346,13 +346,13 @@ discard block |
||
| 346 | 346 | |
| 347 | 347 | <tr class="form-field -wrap"> |
| 348 | 348 | <th scope="row"> |
| 349 | - <label for="image_scaling"><?php esc_html_e( 'Enable Image Scaling', 'lsx-wetu-importer' ); ?></label> |
|
| 349 | + <label for="image_scaling"><?php esc_html_e('Enable Image Scaling', 'lsx-wetu-importer'); ?></label> |
|
| 350 | 350 | </th> |
| 351 | 351 | <td> |
| 352 | 352 | <input type="checkbox" |
| 353 | 353 | <?php |
| 354 | - if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) { |
|
| 355 | - echo esc_attr( 'checked="checked"' ); |
|
| 354 | + if (isset($options['image_scaling']) && '' !== $options['image_scaling']) { |
|
| 355 | + echo esc_attr('checked="checked"'); |
|
| 356 | 356 | } |
| 357 | 357 | ?> |
| 358 | 358 | name="image_scaling" /> |
@@ -360,13 +360,13 @@ discard block |
||
| 360 | 360 | </tr> |
| 361 | 361 | <tr class="form-field -wrap"> |
| 362 | 362 | <th scope="row"> |
| 363 | - <label for="width"> <?php esc_html_e( 'Width (px)', 'lsx-wetu-importer' ); ?></label> |
|
| 363 | + <label for="width"> <?php esc_html_e('Width (px)', 'lsx-wetu-importer'); ?></label> |
|
| 364 | 364 | </th> |
| 365 | 365 | <td> |
| 366 | 366 | <input placeholder="800" type="text" value=" |
| 367 | 367 | <?php |
| 368 | - if ( isset( $options['width'] ) && '' !== $options['width'] ) { |
|
| 369 | - echo esc_attr( $options['width'] ); |
|
| 368 | + if (isset($options['width']) && '' !== $options['width']) { |
|
| 369 | + echo esc_attr($options['width']); |
|
| 370 | 370 | } |
| 371 | 371 | ?> |
| 372 | 372 | " |
@@ -375,13 +375,13 @@ discard block |
||
| 375 | 375 | </tr> |
| 376 | 376 | <tr class="form-field -wrap"> |
| 377 | 377 | <th scope="row"> |
| 378 | - <label for="height"> <?php esc_html_e( 'Height (px)', 'lsx-wetu-importer' ); ?></label> |
|
| 378 | + <label for="height"> <?php esc_html_e('Height (px)', 'lsx-wetu-importer'); ?></label> |
|
| 379 | 379 | </th> |
| 380 | 380 | <td> |
| 381 | 381 | <input placeholder="600" type="text" value=" |
| 382 | 382 | <?php |
| 383 | - if ( isset( $options['height'] ) && '' !== $options['height'] ) { |
|
| 384 | - echo esc_attr( $options['height'] ); |
|
| 383 | + if (isset($options['height']) && '' !== $options['height']) { |
|
| 384 | + echo esc_attr($options['height']); |
|
| 385 | 385 | } |
| 386 | 386 | ?> |
| 387 | 387 | " |
@@ -391,93 +391,93 @@ discard block |
||
| 391 | 391 | |
| 392 | 392 | <tr class="form-field -wrap image-settings"> |
| 393 | 393 | <th scope="row"> |
| 394 | - <label for="scaling"> <?php esc_html_e( 'Scaling', 'lsx-wetu-importer' ); ?></label> |
|
| 394 | + <label for="scaling"> <?php esc_html_e('Scaling', 'lsx-wetu-importer'); ?></label> |
|
| 395 | 395 | </th> |
| 396 | 396 | <td> |
| 397 | 397 | <input type="radio" |
| 398 | 398 | <?php |
| 399 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) { |
|
| 400 | - echo esc_attr( 'checked="checked"' ); |
|
| 399 | + if (isset($options['scaling']) && '' !== $options['scaling'] && 'raw' === $options['scaling']) { |
|
| 400 | + echo esc_attr('checked="checked"'); |
|
| 401 | 401 | } |
| 402 | 402 | ?> |
| 403 | - name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br /> |
|
| 403 | + name="scaling" value="raw" /> <?php esc_html_e('Get the Full size image, no cropping takes place.', 'lsx-wetu-importer'); ?><br /> |
|
| 404 | 404 | <input type="radio" |
| 405 | 405 | <?php |
| 406 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) { |
|
| 407 | - echo esc_attr( 'checked="checked"' ); |
|
| 406 | + if (isset($options['scaling']) && '' !== $options['scaling'] && 'c' === $options['scaling']) { |
|
| 407 | + echo esc_attr('checked="checked"'); |
|
| 408 | 408 | } |
| 409 | 409 | ?> |
| 410 | - name="scaling" value="c" /> <?php esc_html_e( 'Crop image to fit fully into the frame, Crop is taken from middle, preserving as much of the image as possible.', 'lsx-wetu-importer' ); ?><br /> |
|
| 410 | + name="scaling" value="c" /> <?php esc_html_e('Crop image to fit fully into the frame, Crop is taken from middle, preserving as much of the image as possible.', 'lsx-wetu-importer'); ?><br /> |
|
| 411 | 411 | <input type="radio" |
| 412 | 412 | <?php |
| 413 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) { |
|
| 414 | - echo esc_attr( 'checked="checked"' ); |
|
| 413 | + if (isset($options['scaling']) && '' !== $options['scaling'] && 'h' === $options['scaling']) { |
|
| 414 | + echo esc_attr('checked="checked"'); |
|
| 415 | 415 | } |
| 416 | 416 | ?> |
| 417 | - name="scaling" value="h" /> <?php esc_html_e( 'Crop image to fit fully into the frame, but resize to height first, then crop on width if needed', 'lsx-wetu-importer' ); ?><br /> |
|
| 417 | + name="scaling" value="h" /> <?php esc_html_e('Crop image to fit fully into the frame, but resize to height first, then crop on width if needed', 'lsx-wetu-importer'); ?><br /> |
|
| 418 | 418 | <input type="radio" |
| 419 | 419 | <?php |
| 420 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) { |
|
| 421 | - echo esc_attr( 'checked="checked"' ); |
|
| 420 | + if (isset($options['scaling']) && '' !== $options['scaling'] && 'w' === $options['scaling']) { |
|
| 421 | + echo esc_attr('checked="checked"'); |
|
| 422 | 422 | } |
| 423 | 423 | ?> |
| 424 | - name="scaling" value="w" /> <?php esc_html_e( 'Crop image to fit fully into the frame, but resize to width first, then crop on height if needed', 'lsx-wetu-importer' ); ?><br /> |
|
| 424 | + name="scaling" value="w" /> <?php esc_html_e('Crop image to fit fully into the frame, but resize to width first, then crop on height if needed', 'lsx-wetu-importer'); ?><br /> |
|
| 425 | 425 | <input type="radio" |
| 426 | 426 | <?php |
| 427 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) { |
|
| 428 | - echo esc_attr( 'checked="checked"' ); |
|
| 427 | + if (isset($options['scaling']) && '' !== $options['scaling'] && 'nf' === $options['scaling']) { |
|
| 428 | + echo esc_attr('checked="checked"'); |
|
| 429 | 429 | } |
| 430 | 430 | ?> |
| 431 | - name="scaling" value="nf" /> <?php esc_html_e( 'Resize the image to fit within the frame. but pad the image with white to ensure the resolution matches the frame', 'lsx-wetu-importer' ); ?><br /> |
|
| 431 | + name="scaling" value="nf" /> <?php esc_html_e('Resize the image to fit within the frame. but pad the image with white to ensure the resolution matches the frame', 'lsx-wetu-importer'); ?><br /> |
|
| 432 | 432 | <input type="radio" |
| 433 | 433 | <?php |
| 434 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) { |
|
| 435 | - echo esc_attr( 'checked="checked"' ); |
|
| 434 | + if (isset($options['scaling']) && '' !== $options['scaling'] && 'n' === $options['scaling']) { |
|
| 435 | + echo esc_attr('checked="checked"'); |
|
| 436 | 436 | } |
| 437 | 437 | ?> |
| 438 | - name="scaling" value="n" /> <?php esc_html_e( 'Resize the image to fit within the frame. but do not upscale the image.', 'lsx-wetu-importer' ); ?><br /> |
|
| 438 | + name="scaling" value="n" /> <?php esc_html_e('Resize the image to fit within the frame. but do not upscale the image.', 'lsx-wetu-importer'); ?><br /> |
|
| 439 | 439 | <input type="radio" |
| 440 | 440 | <?php |
| 441 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) { |
|
| 442 | - echo esc_attr( 'checked="checked"' ); |
|
| 441 | + if (isset($options['scaling']) && '' !== $options['scaling'] && 'W' === $options['scaling']) { |
|
| 442 | + echo esc_attr('checked="checked"'); |
|
| 443 | 443 | } |
| 444 | 444 | ?> |
| 445 | - name="scaling" value="W" /> <?php esc_html_e( 'Resize the image to fit within the frame. Image will not exceed specified dimensions', 'lsx-wetu-importer' ); ?> |
|
| 445 | + name="scaling" value="W" /> <?php esc_html_e('Resize the image to fit within the frame. Image will not exceed specified dimensions', 'lsx-wetu-importer'); ?> |
|
| 446 | 446 | </td> |
| 447 | 447 | </tr> |
| 448 | 448 | </tbody> |
| 449 | 449 | </table> |
| 450 | 450 | |
| 451 | - <h1><?php esc_html_e( 'Sync', 'lsx-wetu-importer' ); ?></h1> |
|
| 451 | + <h1><?php esc_html_e('Sync', 'lsx-wetu-importer'); ?></h1> |
|
| 452 | 452 | |
| 453 | 453 | <table class="form-table"> |
| 454 | 454 | <tbody> |
| 455 | 455 | <tr class="form-field -wrap"> |
| 456 | 456 | <th scope="row"> |
| 457 | - <label for="cron_schedule"><?php esc_html_e( 'Schedule', 'lsx-wetu-importer' ); ?></label> |
|
| 457 | + <label for="cron_schedule"><?php esc_html_e('Schedule', 'lsx-wetu-importer'); ?></label> |
|
| 458 | 458 | </th> |
| 459 | 459 | <td> |
| 460 | 460 | <select name="cron_schedule" id="cron_schedule" class="widefat layout"> |
| 461 | 461 | <?php |
| 462 | - if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) { |
|
| 462 | + if (isset($options['cron_schedule']) && '' !== $options['cron_schedule']) { |
|
| 463 | 463 | $schedule = $options['cron_schedule']; |
| 464 | - } else { |
|
| 464 | + }else { |
|
| 465 | 465 | $schedule = 'daily'; |
| 466 | 466 | } |
| 467 | 467 | $timeslots = array( |
| 468 | - 'daily' => __( 'Daily', 'lsx-wetu-importer' ), |
|
| 469 | - 'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ), |
|
| 470 | - 'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ), |
|
| 471 | - 'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ), |
|
| 472 | - 'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ), |
|
| 473 | - 'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ), |
|
| 474 | - 'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ), |
|
| 475 | - 'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ), |
|
| 468 | + 'daily' => __('Daily', 'lsx-wetu-importer'), |
|
| 469 | + 'weekly-mon' => __('Weekly (Monday)', 'lsx-wetu-importer'), |
|
| 470 | + 'weekly-tue' => __('Weekly (Tuesday)', 'lsx-wetu-importer'), |
|
| 471 | + 'weekly-wed' => __('Weekly (Wednesday)', 'lsx-wetu-importer'), |
|
| 472 | + 'weekly-thu' => __('Weekly (Thursday)', 'lsx-wetu-importer'), |
|
| 473 | + 'weekly-fri' => __('Weekly (Friday)', 'lsx-wetu-importer'), |
|
| 474 | + 'weekly-sat' => __('Weekly (Saturday)', 'lsx-wetu-importer'), |
|
| 475 | + 'weekly-sun' => __('Weekly (Sunday)', 'lsx-wetu-importer'), |
|
| 476 | 476 | ); |
| 477 | - foreach ( $timeslots as $key => $name ) { |
|
| 478 | - $selected = ( $schedule == $key ) ? ' selected="selected"' : ''; |
|
| 477 | + foreach ($timeslots as $key => $name) { |
|
| 478 | + $selected = ($schedule == $key) ? ' selected="selected"' : ''; |
|
| 479 | 479 | ?> |
| 480 | - <option value="<?php echo wp_kses_post( $key ); ?>" id="<?php echo wp_kses_post( $key ); ?>" <?php echo wp_kses_post( $selected ); ?>><?php echo wp_kses_post( $name ); ?></option> |
|
| 480 | + <option value="<?php echo wp_kses_post($key); ?>" id="<?php echo wp_kses_post($key); ?>" <?php echo wp_kses_post($selected); ?>><?php echo wp_kses_post($name); ?></option> |
|
| 481 | 481 | <?php |
| 482 | 482 | } |
| 483 | 483 | ?> |
@@ -486,23 +486,23 @@ discard block |
||
| 486 | 486 | </tr> |
| 487 | 487 | <tr class="form-field -wrap"> |
| 488 | 488 | <th scope="row"> |
| 489 | - <label for="accommodation_images_cron"><?php esc_html_e( 'Accommodation Images', 'lsx-wetu-importer' ); ?></label> |
|
| 489 | + <label for="accommodation_images_cron"><?php esc_html_e('Accommodation Images', 'lsx-wetu-importer'); ?></label> |
|
| 490 | 490 | </th> |
| 491 | 491 | <td> |
| 492 | 492 | <input type="checkbox" |
| 493 | 493 | <?php |
| 494 | - if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) { |
|
| 495 | - echo esc_attr( 'checked="checked"' ); |
|
| 494 | + if (isset($options['accommodation_images_cron']) && '' !== $options['accommodation_images_cron']) { |
|
| 495 | + echo esc_attr('checked="checked"'); |
|
| 496 | 496 | } |
| 497 | 497 | ?> |
| 498 | 498 | name="accommodation_images_cron" /> |
| 499 | - <p><?php esc_html_e( 'Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer' ); ?></p> |
|
| 499 | + <p><?php esc_html_e('Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer'); ?></p> |
|
| 500 | 500 | </td> |
| 501 | 501 | </tr> |
| 502 | 502 | </tbody> |
| 503 | 503 | </table> |
| 504 | 504 | |
| 505 | - <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_html_e( 'Save Changes', 'lsx-wetu-importer' ); ?>"></p> |
|
| 505 | + <p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_html_e('Save Changes', 'lsx-wetu-importer'); ?>"></p> |
|
| 506 | 506 | </form> |
| 507 | 507 | </div> |
| 508 | 508 | <?php |
@@ -514,17 +514,17 @@ discard block |
||
| 514 | 514 | * @return void |
| 515 | 515 | */ |
| 516 | 516 | public function save_options() { |
| 517 | - if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) { |
|
| 517 | + if (!isset($_POST['lsx_wetu_importer_save_options']) || !wp_verify_nonce($_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save')) { |
|
| 518 | 518 | return; |
| 519 | 519 | } |
| 520 | 520 | $data_to_save = array(); |
| 521 | - foreach ( $this->defaults as $key => $field ) { |
|
| 522 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 523 | - $data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] ); |
|
| 524 | - } else { |
|
| 525 | - $data_to_save[ $key ] = ''; |
|
| 521 | + foreach ($this->defaults as $key => $field) { |
|
| 522 | + if (isset($_POST[$key])) { |
|
| 523 | + $data_to_save[$key] = sanitize_text_field($_POST[$key]); |
|
| 524 | + }else { |
|
| 525 | + $data_to_save[$key] = ''; |
|
| 526 | 526 | } |
| 527 | 527 | } |
| 528 | - update_option( 'lsx_wetu_importer_settings', $data_to_save ); |
|
| 528 | + update_option('lsx_wetu_importer_settings', $data_to_save); |
|
| 529 | 529 | } |
| 530 | 530 | } |
@@ -16,234 +16,234 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Cron { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Holds class instance |
|
| 21 | - * |
|
| 22 | - * @since 1.0.0 |
|
| 23 | - * |
|
| 24 | - * @var object|Module_Template |
|
| 25 | - */ |
|
| 26 | - protected static $instance = null; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Initialize the plugin by setting localization, filters, and administration functions. |
|
| 30 | - * |
|
| 31 | - * @since 1.0.0 |
|
| 32 | - * |
|
| 33 | - * @access private |
|
| 34 | - */ |
|
| 35 | - public function __construct() { |
|
| 36 | - add_filter( 'cron_schedules', array( $this, 'register_schedule' ), 10, 1 ); |
|
| 37 | - add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 ); |
|
| 38 | - add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 ); |
|
| 39 | - add_action( 'lsx_wetu_accommodation_images_sync', array( $this, 'cron_callback' ), 10, 1 ); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Return an instance of this class. |
|
| 44 | - * |
|
| 45 | - * @since 1.0.0 |
|
| 46 | - * |
|
| 47 | - * @return object Cron() A single instance of this class. |
|
| 48 | - */ |
|
| 49 | - public static function get_instance() { |
|
| 50 | - // If the single instance hasn't been set, set it now. |
|
| 51 | - if ( null === self::$instance ) { |
|
| 52 | - self::$instance = new self(); |
|
| 53 | - } |
|
| 54 | - return self::$instance; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Registers a 5 min schedule for us to use. |
|
| 59 | - * |
|
| 60 | - * @param array $schedules |
|
| 61 | - * @return array |
|
| 62 | - */ |
|
| 63 | - public function register_schedule( $schedules ) { |
|
| 64 | - $schedules['wetu-5-minutes'] = array( |
|
| 65 | - 'interval' => 5 * MINUTE_IN_SECONDS, |
|
| 66 | - 'display' => __( 'Every 5 minutes', 'lsx-wetu-importer' ), |
|
| 67 | - ); |
|
| 68 | - return $schedules; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Watches for changes in the button triggers. |
|
| 73 | - * |
|
| 74 | - * @return void |
|
| 75 | - */ |
|
| 76 | - public function watch_for_trigger() { |
|
| 77 | - |
|
| 78 | - if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) { |
|
| 79 | - $options = lsx_wetu_get_options(); |
|
| 80 | - |
|
| 81 | - // Check what state the option is in. |
|
| 82 | - $accommodation_cron = 'deactivate'; |
|
| 83 | - if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) { |
|
| 84 | - $accommodation_cron = 'activate'; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // Check what state the cron is in. |
|
| 88 | - $scheduled = false; |
|
| 89 | - if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) { |
|
| 90 | - $scheduled = true; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - // If activate and its not running. |
|
| 94 | - if ( false === $scheduled && 'activate' === $accommodation_cron ) { |
|
| 95 | - $schedule = 'weekly'; |
|
| 96 | - $this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule ); |
|
| 97 | - } elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) { |
|
| 98 | - $this->deactivate(); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Remove our cron from the shedule. |
|
| 105 | - * |
|
| 106 | - * @return void |
|
| 107 | - */ |
|
| 108 | - public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) { |
|
| 109 | - wp_clear_scheduled_hook( $task, array( $task ) ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * This function will schedule the cron event. |
|
| 114 | - * |
|
| 115 | - * @param string $task |
|
| 116 | - * @param string $schedule |
|
| 117 | - * @param string $time |
|
| 118 | - * @return void |
|
| 119 | - */ |
|
| 120 | - public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) { |
|
| 121 | - if ( '' === $time ) { |
|
| 122 | - $time = time(); |
|
| 123 | - } |
|
| 124 | - wp_schedule_event( $time, $schedule, $task, array( $task ) ); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * This is the function that will be triggered by the cron event. |
|
| 129 | - * |
|
| 130 | - * @return void |
|
| 131 | - */ |
|
| 132 | - public function process( $task = '' ) { |
|
| 133 | - switch ( $task ) { |
|
| 134 | - case 'lsx_wetu_accommodation_images_cron': |
|
| 135 | - $this->register_accommodation_images_sync(); |
|
| 136 | - break; |
|
| 137 | - |
|
| 138 | - default: |
|
| 139 | - break; |
|
| 140 | - } |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * This is the function that will be triggered by the cron event. |
|
| 145 | - * |
|
| 146 | - * @return void |
|
| 147 | - */ |
|
| 148 | - public function register_accommodation_images_sync() { |
|
| 149 | - $time = strtotime( '+5 min' ); |
|
| 150 | - if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) { |
|
| 151 | - $this->load_items_to_sync( 'accommodation_images' ); |
|
| 152 | - $this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time ); |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * This is the function that will be triggered by the cron event. |
|
| 158 | - * |
|
| 159 | - * @return void |
|
| 160 | - */ |
|
| 161 | - public function cron_callback( $task = '' ) { |
|
| 162 | - $has_accommodation = get_option( $task ); |
|
| 163 | - if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) { |
|
| 164 | - $next_time = array_slice( $has_accommodation, 5 ); |
|
| 165 | - $this_time = array_slice( $has_accommodation, 0, 4 ); |
|
| 166 | - |
|
| 167 | - $api_key = $this->get_api_key(); |
|
| 168 | - $url = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids='; |
|
| 169 | - |
|
| 170 | - // Run through the current items. |
|
| 171 | - foreach ( $this_time as $accommodation ) { |
|
| 172 | - $wetu_id = get_post_meta( $accommodation, 'lsx_wetu_id', true ); |
|
| 173 | - $last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true ); |
|
| 174 | - |
|
| 175 | - $accommodation_info = wp_remote_get( $url . $wetu_id ); |
|
| 176 | - if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) { |
|
| 177 | - $adata = json_decode( $accommodation_info['body'], true ); |
|
| 178 | - |
|
| 179 | - if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) { |
|
| 180 | - $modified_time = strtotime( $adata[0]['last_modified'] ); |
|
| 181 | - if ( $modified_time > $last_date ) { |
|
| 182 | - $accommodation_importer = new \LSX_WETU_Importer_Accommodation(); |
|
| 183 | - $accommodation_importer->create_main_gallery( $adata, $accommodation ); |
|
| 184 | - update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date ); |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - // Save the values for next time. |
|
| 191 | - if ( ! empty( $next_time ) ) { |
|
| 192 | - update_option( $task, $next_time ); |
|
| 193 | - } else { |
|
| 194 | - delete_option( $task ); |
|
| 195 | - $this->deactivate( $task ); |
|
| 196 | - } |
|
| 197 | - } else { |
|
| 198 | - $this->deactivate( $task ); |
|
| 199 | - update_option( 'lsx_wetu_nexttime', $task ); |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * This will grab the accommodation ids and load them up into an option field. |
|
| 205 | - * |
|
| 206 | - * @param string $task |
|
| 207 | - * @return void |
|
| 208 | - */ |
|
| 209 | - public function load_items_to_sync( $task = 'accommodation_images' ) { |
|
| 210 | - $args = array( |
|
| 211 | - 'post_status' => 'publish', |
|
| 212 | - 'posts_per_page' => -1, |
|
| 213 | - 'nopagin' => true, |
|
| 214 | - 'fields' => 'ids', |
|
| 215 | - ); |
|
| 216 | - switch ( $task ) { |
|
| 217 | - case 'accommodation_images': |
|
| 218 | - $args['post_type'] = 'accommodation'; |
|
| 219 | - break; |
|
| 220 | - |
|
| 221 | - default: |
|
| 222 | - break; |
|
| 223 | - } |
|
| 224 | - $items = new \WP_Query( $args ); |
|
| 225 | - if ( $items->have_posts() ) { |
|
| 226 | - update_option( 'lsx_wetu_' . $task . '_sync', $items->posts ); |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Gets the API key stored in the options table. |
|
| 232 | - * |
|
| 233 | - * @return string |
|
| 234 | - */ |
|
| 235 | - public function get_api_key() { |
|
| 236 | - $api_key = false; |
|
| 237 | - $options = lsx_wetu_get_options(); |
|
| 238 | - |
|
| 239 | - if ( ! defined( 'WETU_API_KEY' ) ) { |
|
| 240 | - if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) { |
|
| 241 | - $api_key = $options['api_key']; |
|
| 242 | - } |
|
| 243 | - } else { |
|
| 244 | - $api_key = WETU_API_KEY; |
|
| 245 | - } |
|
| 246 | - return $api_key; |
|
| 247 | - } |
|
| 19 | + /** |
|
| 20 | + * Holds class instance |
|
| 21 | + * |
|
| 22 | + * @since 1.0.0 |
|
| 23 | + * |
|
| 24 | + * @var object|Module_Template |
|
| 25 | + */ |
|
| 26 | + protected static $instance = null; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Initialize the plugin by setting localization, filters, and administration functions. |
|
| 30 | + * |
|
| 31 | + * @since 1.0.0 |
|
| 32 | + * |
|
| 33 | + * @access private |
|
| 34 | + */ |
|
| 35 | + public function __construct() { |
|
| 36 | + add_filter( 'cron_schedules', array( $this, 'register_schedule' ), 10, 1 ); |
|
| 37 | + add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 ); |
|
| 38 | + add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 ); |
|
| 39 | + add_action( 'lsx_wetu_accommodation_images_sync', array( $this, 'cron_callback' ), 10, 1 ); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Return an instance of this class. |
|
| 44 | + * |
|
| 45 | + * @since 1.0.0 |
|
| 46 | + * |
|
| 47 | + * @return object Cron() A single instance of this class. |
|
| 48 | + */ |
|
| 49 | + public static function get_instance() { |
|
| 50 | + // If the single instance hasn't been set, set it now. |
|
| 51 | + if ( null === self::$instance ) { |
|
| 52 | + self::$instance = new self(); |
|
| 53 | + } |
|
| 54 | + return self::$instance; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Registers a 5 min schedule for us to use. |
|
| 59 | + * |
|
| 60 | + * @param array $schedules |
|
| 61 | + * @return array |
|
| 62 | + */ |
|
| 63 | + public function register_schedule( $schedules ) { |
|
| 64 | + $schedules['wetu-5-minutes'] = array( |
|
| 65 | + 'interval' => 5 * MINUTE_IN_SECONDS, |
|
| 66 | + 'display' => __( 'Every 5 minutes', 'lsx-wetu-importer' ), |
|
| 67 | + ); |
|
| 68 | + return $schedules; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Watches for changes in the button triggers. |
|
| 73 | + * |
|
| 74 | + * @return void |
|
| 75 | + */ |
|
| 76 | + public function watch_for_trigger() { |
|
| 77 | + |
|
| 78 | + if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) { |
|
| 79 | + $options = lsx_wetu_get_options(); |
|
| 80 | + |
|
| 81 | + // Check what state the option is in. |
|
| 82 | + $accommodation_cron = 'deactivate'; |
|
| 83 | + if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) { |
|
| 84 | + $accommodation_cron = 'activate'; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // Check what state the cron is in. |
|
| 88 | + $scheduled = false; |
|
| 89 | + if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) { |
|
| 90 | + $scheduled = true; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + // If activate and its not running. |
|
| 94 | + if ( false === $scheduled && 'activate' === $accommodation_cron ) { |
|
| 95 | + $schedule = 'weekly'; |
|
| 96 | + $this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule ); |
|
| 97 | + } elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) { |
|
| 98 | + $this->deactivate(); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Remove our cron from the shedule. |
|
| 105 | + * |
|
| 106 | + * @return void |
|
| 107 | + */ |
|
| 108 | + public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) { |
|
| 109 | + wp_clear_scheduled_hook( $task, array( $task ) ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * This function will schedule the cron event. |
|
| 114 | + * |
|
| 115 | + * @param string $task |
|
| 116 | + * @param string $schedule |
|
| 117 | + * @param string $time |
|
| 118 | + * @return void |
|
| 119 | + */ |
|
| 120 | + public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) { |
|
| 121 | + if ( '' === $time ) { |
|
| 122 | + $time = time(); |
|
| 123 | + } |
|
| 124 | + wp_schedule_event( $time, $schedule, $task, array( $task ) ); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * This is the function that will be triggered by the cron event. |
|
| 129 | + * |
|
| 130 | + * @return void |
|
| 131 | + */ |
|
| 132 | + public function process( $task = '' ) { |
|
| 133 | + switch ( $task ) { |
|
| 134 | + case 'lsx_wetu_accommodation_images_cron': |
|
| 135 | + $this->register_accommodation_images_sync(); |
|
| 136 | + break; |
|
| 137 | + |
|
| 138 | + default: |
|
| 139 | + break; |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * This is the function that will be triggered by the cron event. |
|
| 145 | + * |
|
| 146 | + * @return void |
|
| 147 | + */ |
|
| 148 | + public function register_accommodation_images_sync() { |
|
| 149 | + $time = strtotime( '+5 min' ); |
|
| 150 | + if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) { |
|
| 151 | + $this->load_items_to_sync( 'accommodation_images' ); |
|
| 152 | + $this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time ); |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * This is the function that will be triggered by the cron event. |
|
| 158 | + * |
|
| 159 | + * @return void |
|
| 160 | + */ |
|
| 161 | + public function cron_callback( $task = '' ) { |
|
| 162 | + $has_accommodation = get_option( $task ); |
|
| 163 | + if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) { |
|
| 164 | + $next_time = array_slice( $has_accommodation, 5 ); |
|
| 165 | + $this_time = array_slice( $has_accommodation, 0, 4 ); |
|
| 166 | + |
|
| 167 | + $api_key = $this->get_api_key(); |
|
| 168 | + $url = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids='; |
|
| 169 | + |
|
| 170 | + // Run through the current items. |
|
| 171 | + foreach ( $this_time as $accommodation ) { |
|
| 172 | + $wetu_id = get_post_meta( $accommodation, 'lsx_wetu_id', true ); |
|
| 173 | + $last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true ); |
|
| 174 | + |
|
| 175 | + $accommodation_info = wp_remote_get( $url . $wetu_id ); |
|
| 176 | + if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) { |
|
| 177 | + $adata = json_decode( $accommodation_info['body'], true ); |
|
| 178 | + |
|
| 179 | + if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) { |
|
| 180 | + $modified_time = strtotime( $adata[0]['last_modified'] ); |
|
| 181 | + if ( $modified_time > $last_date ) { |
|
| 182 | + $accommodation_importer = new \LSX_WETU_Importer_Accommodation(); |
|
| 183 | + $accommodation_importer->create_main_gallery( $adata, $accommodation ); |
|
| 184 | + update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date ); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + // Save the values for next time. |
|
| 191 | + if ( ! empty( $next_time ) ) { |
|
| 192 | + update_option( $task, $next_time ); |
|
| 193 | + } else { |
|
| 194 | + delete_option( $task ); |
|
| 195 | + $this->deactivate( $task ); |
|
| 196 | + } |
|
| 197 | + } else { |
|
| 198 | + $this->deactivate( $task ); |
|
| 199 | + update_option( 'lsx_wetu_nexttime', $task ); |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * This will grab the accommodation ids and load them up into an option field. |
|
| 205 | + * |
|
| 206 | + * @param string $task |
|
| 207 | + * @return void |
|
| 208 | + */ |
|
| 209 | + public function load_items_to_sync( $task = 'accommodation_images' ) { |
|
| 210 | + $args = array( |
|
| 211 | + 'post_status' => 'publish', |
|
| 212 | + 'posts_per_page' => -1, |
|
| 213 | + 'nopagin' => true, |
|
| 214 | + 'fields' => 'ids', |
|
| 215 | + ); |
|
| 216 | + switch ( $task ) { |
|
| 217 | + case 'accommodation_images': |
|
| 218 | + $args['post_type'] = 'accommodation'; |
|
| 219 | + break; |
|
| 220 | + |
|
| 221 | + default: |
|
| 222 | + break; |
|
| 223 | + } |
|
| 224 | + $items = new \WP_Query( $args ); |
|
| 225 | + if ( $items->have_posts() ) { |
|
| 226 | + update_option( 'lsx_wetu_' . $task . '_sync', $items->posts ); |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Gets the API key stored in the options table. |
|
| 232 | + * |
|
| 233 | + * @return string |
|
| 234 | + */ |
|
| 235 | + public function get_api_key() { |
|
| 236 | + $api_key = false; |
|
| 237 | + $options = lsx_wetu_get_options(); |
|
| 238 | + |
|
| 239 | + if ( ! defined( 'WETU_API_KEY' ) ) { |
|
| 240 | + if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) { |
|
| 241 | + $api_key = $options['api_key']; |
|
| 242 | + } |
|
| 243 | + } else { |
|
| 244 | + $api_key = WETU_API_KEY; |
|
| 245 | + } |
|
| 246 | + return $api_key; |
|
| 247 | + } |
|
| 248 | 248 | } |
| 249 | 249 | Cron::get_instance(); |
@@ -33,10 +33,10 @@ discard block |
||
| 33 | 33 | * @access private |
| 34 | 34 | */ |
| 35 | 35 | public function __construct() { |
| 36 | - add_filter( 'cron_schedules', array( $this, 'register_schedule' ), 10, 1 ); |
|
| 37 | - add_action( 'lsx_wetu_importer_settings_before', array( $this, 'watch_for_trigger' ), 200 ); |
|
| 38 | - add_action( 'lsx_wetu_accommodation_images_cron', array( $this, 'process' ), 10, 1 ); |
|
| 39 | - add_action( 'lsx_wetu_accommodation_images_sync', array( $this, 'cron_callback' ), 10, 1 ); |
|
| 36 | + add_filter('cron_schedules', array($this, 'register_schedule'), 10, 1); |
|
| 37 | + add_action('lsx_wetu_importer_settings_before', array($this, 'watch_for_trigger'), 200); |
|
| 38 | + add_action('lsx_wetu_accommodation_images_cron', array($this, 'process'), 10, 1); |
|
| 39 | + add_action('lsx_wetu_accommodation_images_sync', array($this, 'cron_callback'), 10, 1); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public static function get_instance() { |
| 50 | 50 | // If the single instance hasn't been set, set it now. |
| 51 | - if ( null === self::$instance ) { |
|
| 51 | + if (null === self::$instance) { |
|
| 52 | 52 | self::$instance = new self(); |
| 53 | 53 | } |
| 54 | 54 | return self::$instance; |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | * @param array $schedules |
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | - public function register_schedule( $schedules ) { |
|
| 63 | + public function register_schedule($schedules) { |
|
| 64 | 64 | $schedules['wetu-5-minutes'] = array( |
| 65 | 65 | 'interval' => 5 * MINUTE_IN_SECONDS, |
| 66 | - 'display' => __( 'Every 5 minutes', 'lsx-wetu-importer' ), |
|
| 66 | + 'display' => __('Every 5 minutes', 'lsx-wetu-importer'), |
|
| 67 | 67 | ); |
| 68 | 68 | return $schedules; |
| 69 | 69 | } |
@@ -75,26 +75,26 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public function watch_for_trigger() { |
| 77 | 77 | |
| 78 | - if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) { |
|
| 78 | + if (isset($_GET['page']) && 'lsx-wetu-importer' === $_GET['page'] && isset($_GET['tab']) && 'settings' === $_GET['tab']) { |
|
| 79 | 79 | $options = lsx_wetu_get_options(); |
| 80 | 80 | |
| 81 | 81 | // Check what state the option is in. |
| 82 | 82 | $accommodation_cron = 'deactivate'; |
| 83 | - if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) { |
|
| 83 | + if (isset($options['accommodation_images_cron']) && '' !== $options['accommodation_images_cron']) { |
|
| 84 | 84 | $accommodation_cron = 'activate'; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // Check what state the cron is in. |
| 88 | 88 | $scheduled = false; |
| 89 | - if ( wp_next_scheduled( 'lsx_wetu_accommodation_images_cron' ) ) { |
|
| 89 | + if (wp_next_scheduled('lsx_wetu_accommodation_images_cron')) { |
|
| 90 | 90 | $scheduled = true; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | // If activate and its not running. |
| 94 | - if ( false === $scheduled && 'activate' === $accommodation_cron ) { |
|
| 94 | + if (false === $scheduled && 'activate' === $accommodation_cron) { |
|
| 95 | 95 | $schedule = 'weekly'; |
| 96 | - $this->schedule( 'lsx_wetu_accommodation_images_cron', $schedule ); |
|
| 97 | - } elseif ( true === $scheduled && 'deactivate' === $accommodation_cron ) { |
|
| 96 | + $this->schedule('lsx_wetu_accommodation_images_cron', $schedule); |
|
| 97 | + } elseif (true === $scheduled && 'deactivate' === $accommodation_cron) { |
|
| 98 | 98 | $this->deactivate(); |
| 99 | 99 | } |
| 100 | 100 | } |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @return void |
| 107 | 107 | */ |
| 108 | - public function deactivate( $task = 'lsx_wetu_accommodation_images_cron' ) { |
|
| 109 | - wp_clear_scheduled_hook( $task, array( $task ) ); |
|
| 108 | + public function deactivate($task = 'lsx_wetu_accommodation_images_cron') { |
|
| 109 | + wp_clear_scheduled_hook($task, array($task)); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | * @param string $time |
| 118 | 118 | * @return void |
| 119 | 119 | */ |
| 120 | - public function schedule( $task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm' ) { |
|
| 121 | - if ( '' === $time ) { |
|
| 120 | + public function schedule($task = 'lsx_wetu_accommodation_images_cron', $schedule = 'weekly', $time = 'Sunday 10pm') { |
|
| 121 | + if ('' === $time) { |
|
| 122 | 122 | $time = time(); |
| 123 | 123 | } |
| 124 | - wp_schedule_event( $time, $schedule, $task, array( $task ) ); |
|
| 124 | + wp_schedule_event($time, $schedule, $task, array($task)); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -129,8 +129,8 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return void |
| 131 | 131 | */ |
| 132 | - public function process( $task = '' ) { |
|
| 133 | - switch ( $task ) { |
|
| 132 | + public function process($task = '') { |
|
| 133 | + switch ($task) { |
|
| 134 | 134 | case 'lsx_wetu_accommodation_images_cron': |
| 135 | 135 | $this->register_accommodation_images_sync(); |
| 136 | 136 | break; |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | * @return void |
| 147 | 147 | */ |
| 148 | 148 | public function register_accommodation_images_sync() { |
| 149 | - $time = strtotime( '+5 min' ); |
|
| 150 | - if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) { |
|
| 151 | - $this->load_items_to_sync( 'accommodation_images' ); |
|
| 152 | - $this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time ); |
|
| 149 | + $time = strtotime('+5 min'); |
|
| 150 | + if (!wp_next_scheduled('lsx_wetu_accommodation_images_sync')) { |
|
| 151 | + $this->load_items_to_sync('accommodation_images'); |
|
| 152 | + $this->schedule('lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |
@@ -158,45 +158,45 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return void |
| 160 | 160 | */ |
| 161 | - public function cron_callback( $task = '' ) { |
|
| 162 | - $has_accommodation = get_option( $task ); |
|
| 163 | - if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) { |
|
| 164 | - $next_time = array_slice( $has_accommodation, 5 ); |
|
| 165 | - $this_time = array_slice( $has_accommodation, 0, 4 ); |
|
| 161 | + public function cron_callback($task = '') { |
|
| 162 | + $has_accommodation = get_option($task); |
|
| 163 | + if (false !== $has_accommodation && !empty($has_accommodation)) { |
|
| 164 | + $next_time = array_slice($has_accommodation, 5); |
|
| 165 | + $this_time = array_slice($has_accommodation, 0, 4); |
|
| 166 | 166 | |
| 167 | 167 | $api_key = $this->get_api_key(); |
| 168 | - $url = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids='; |
|
| 168 | + $url = 'https://wetu.com/API/Pins/'.$api_key.'/Get?all=include&ids='; |
|
| 169 | 169 | |
| 170 | 170 | // Run through the current items. |
| 171 | - foreach ( $this_time as $accommodation ) { |
|
| 172 | - $wetu_id = get_post_meta( $accommodation, 'lsx_wetu_id', true ); |
|
| 173 | - $last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true ); |
|
| 171 | + foreach ($this_time as $accommodation) { |
|
| 172 | + $wetu_id = get_post_meta($accommodation, 'lsx_wetu_id', true); |
|
| 173 | + $last_date = get_post_meta($accommodation, 'lsx_wetu_modified_date', true); |
|
| 174 | 174 | |
| 175 | - $accommodation_info = wp_remote_get( $url . $wetu_id ); |
|
| 176 | - if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) { |
|
| 177 | - $adata = json_decode( $accommodation_info['body'], true ); |
|
| 175 | + $accommodation_info = wp_remote_get($url.$wetu_id); |
|
| 176 | + if (!empty($accommodation_info) && isset($accommodation_info['response']) && isset($accommodation_info['response']['code']) && 200 === $accommodation_info['response']['code']) { |
|
| 177 | + $adata = json_decode($accommodation_info['body'], true); |
|
| 178 | 178 | |
| 179 | - if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) { |
|
| 180 | - $modified_time = strtotime( $adata[0]['last_modified'] ); |
|
| 181 | - if ( $modified_time > $last_date ) { |
|
| 179 | + if (isset($adata[0]) && isset($adata[0]['last_modified']) && '' !== $adata[0]['last_modified']) { |
|
| 180 | + $modified_time = strtotime($adata[0]['last_modified']); |
|
| 181 | + if ($modified_time > $last_date) { |
|
| 182 | 182 | $accommodation_importer = new \LSX_WETU_Importer_Accommodation(); |
| 183 | - $accommodation_importer->create_main_gallery( $adata, $accommodation ); |
|
| 184 | - update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date ); |
|
| 183 | + $accommodation_importer->create_main_gallery($adata, $accommodation); |
|
| 184 | + update_post_meta($accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date); |
|
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Save the values for next time. |
| 191 | - if ( ! empty( $next_time ) ) { |
|
| 192 | - update_option( $task, $next_time ); |
|
| 193 | - } else { |
|
| 194 | - delete_option( $task ); |
|
| 195 | - $this->deactivate( $task ); |
|
| 191 | + if (!empty($next_time)) { |
|
| 192 | + update_option($task, $next_time); |
|
| 193 | + }else { |
|
| 194 | + delete_option($task); |
|
| 195 | + $this->deactivate($task); |
|
| 196 | 196 | } |
| 197 | - } else { |
|
| 198 | - $this->deactivate( $task ); |
|
| 199 | - update_option( 'lsx_wetu_nexttime', $task ); |
|
| 197 | + }else { |
|
| 198 | + $this->deactivate($task); |
|
| 199 | + update_option('lsx_wetu_nexttime', $task); |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | * @param string $task |
| 207 | 207 | * @return void |
| 208 | 208 | */ |
| 209 | - public function load_items_to_sync( $task = 'accommodation_images' ) { |
|
| 209 | + public function load_items_to_sync($task = 'accommodation_images') { |
|
| 210 | 210 | $args = array( |
| 211 | 211 | 'post_status' => 'publish', |
| 212 | 212 | 'posts_per_page' => -1, |
| 213 | 213 | 'nopagin' => true, |
| 214 | 214 | 'fields' => 'ids', |
| 215 | 215 | ); |
| 216 | - switch ( $task ) { |
|
| 216 | + switch ($task) { |
|
| 217 | 217 | case 'accommodation_images': |
| 218 | 218 | $args['post_type'] = 'accommodation'; |
| 219 | 219 | break; |
@@ -221,9 +221,9 @@ discard block |
||
| 221 | 221 | default: |
| 222 | 222 | break; |
| 223 | 223 | } |
| 224 | - $items = new \WP_Query( $args ); |
|
| 225 | - if ( $items->have_posts() ) { |
|
| 226 | - update_option( 'lsx_wetu_' . $task . '_sync', $items->posts ); |
|
| 224 | + $items = new \WP_Query($args); |
|
| 225 | + if ($items->have_posts()) { |
|
| 226 | + update_option('lsx_wetu_'.$task.'_sync', $items->posts); |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
@@ -236,11 +236,11 @@ discard block |
||
| 236 | 236 | $api_key = false; |
| 237 | 237 | $options = lsx_wetu_get_options(); |
| 238 | 238 | |
| 239 | - if ( ! defined( 'WETU_API_KEY' ) ) { |
|
| 240 | - if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) { |
|
| 239 | + if (!defined('WETU_API_KEY')) { |
|
| 240 | + if (isset($options['api_key']) && '' !== $options['api_key']) { |
|
| 241 | 241 | $api_key = $options['api_key']; |
| 242 | 242 | } |
| 243 | - } else { |
|
| 243 | + }else { |
|
| 244 | 244 | $api_key = WETU_API_KEY; |
| 245 | 245 | } |
| 246 | 246 | return $api_key; |