@@ -16,242 +16,242 @@ |
||
| 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; |
|
| 19 | + /** |
|
| 20 | + * Holds class instance |
|
| 21 | + * |
|
| 22 | + * @since 1.0.0 |
|
| 23 | + * |
|
| 24 | + * @var object|Module_Template |
|
| 25 | + */ |
|
| 26 | + protected static $instance = null; |
|
| 27 | 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 | - } |
|
| 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 | 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 | - } |
|
| 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 | 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 | - } |
|
| 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 | 70 | |
| 71 | - /** |
|
| 72 | - * Watches for changes in the button triggers. |
|
| 73 | - * |
|
| 74 | - * @return void |
|
| 75 | - */ |
|
| 76 | - public function watch_for_trigger() { |
|
| 71 | + /** |
|
| 72 | + * Watches for changes in the button triggers. |
|
| 73 | + * |
|
| 74 | + * @return void |
|
| 75 | + */ |
|
| 76 | + public function watch_for_trigger() { |
|
| 77 | 77 | |
| 78 | - if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) { |
|
| 79 | - $options = lsx_wetu_get_options(); |
|
| 78 | + if ( isset( $_GET['page'] ) && 'lsx-wetu-importer' === $_GET['page'] && isset( $_GET['tab'] ) && 'settings' === $_GET['tab'] ) { |
|
| 79 | + $options = lsx_wetu_get_options(); |
|
| 80 | 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 | - } |
|
| 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 | 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 | - } |
|
| 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 | 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 | - } |
|
| 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 | 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 | - } |
|
| 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 | 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 | - $args = array( $task ); |
|
| 122 | - if ( '' === $time ) { |
|
| 123 | - $time = time(); |
|
| 124 | - } |
|
| 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 | + $args = array( $task ); |
|
| 122 | + if ( '' === $time ) { |
|
| 123 | + $time = time(); |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) { |
|
| 127 | - $args[] = 'featured_image'; |
|
| 128 | - } |
|
| 129 | - wp_schedule_event( $time, $schedule, $task, $args ); |
|
| 130 | - } |
|
| 126 | + if ( isset( $_GET['accommodation_images_cron_featured'] ) && '' !== $_GET['accommodation_images_cron_featured'] ) { |
|
| 127 | + $args[] = 'featured_image'; |
|
| 128 | + } |
|
| 129 | + wp_schedule_event( $time, $schedule, $task, $args ); |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - /** |
|
| 133 | - * This is the function that will be triggered by the cron event. |
|
| 134 | - * |
|
| 135 | - * @return void |
|
| 136 | - */ |
|
| 137 | - public function process( $task = '' ) { |
|
| 138 | - switch ( $task ) { |
|
| 139 | - case 'lsx_wetu_accommodation_images_cron': |
|
| 140 | - $this->register_accommodation_images_sync(); |
|
| 141 | - break; |
|
| 132 | + /** |
|
| 133 | + * This is the function that will be triggered by the cron event. |
|
| 134 | + * |
|
| 135 | + * @return void |
|
| 136 | + */ |
|
| 137 | + public function process( $task = '' ) { |
|
| 138 | + switch ( $task ) { |
|
| 139 | + case 'lsx_wetu_accommodation_images_cron': |
|
| 140 | + $this->register_accommodation_images_sync(); |
|
| 141 | + break; |
|
| 142 | 142 | |
| 143 | - default: |
|
| 144 | - break; |
|
| 145 | - } |
|
| 146 | - } |
|
| 143 | + default: |
|
| 144 | + break; |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * This is the function that will be triggered by the cron event. |
|
| 150 | - * |
|
| 151 | - * @return void |
|
| 152 | - */ |
|
| 153 | - public function register_accommodation_images_sync() { |
|
| 154 | - $time = strtotime( '+5 min' ); |
|
| 155 | - if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) { |
|
| 156 | - $this->load_items_to_sync( 'accommodation_images' ); |
|
| 157 | - $this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time ); |
|
| 158 | - } |
|
| 159 | - } |
|
| 148 | + /** |
|
| 149 | + * This is the function that will be triggered by the cron event. |
|
| 150 | + * |
|
| 151 | + * @return void |
|
| 152 | + */ |
|
| 153 | + public function register_accommodation_images_sync() { |
|
| 154 | + $time = strtotime( '+5 min' ); |
|
| 155 | + if ( ! wp_next_scheduled( 'lsx_wetu_accommodation_images_sync' ) ) { |
|
| 156 | + $this->load_items_to_sync( 'accommodation_images' ); |
|
| 157 | + $this->schedule( 'lsx_wetu_accommodation_images_sync', 'wetu-5-minutes', $time ); |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - /** |
|
| 162 | - * This is the function that will be triggered by the cron event. |
|
| 163 | - * |
|
| 164 | - * @return void |
|
| 165 | - */ |
|
| 166 | - public function cron_callback( $task = '', $featured_image = '' ) { |
|
| 167 | - $has_accommodation = get_option( $task ); |
|
| 168 | - if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) { |
|
| 169 | - $next_time = array_slice( $has_accommodation, 10 ); |
|
| 170 | - $this_time = array_slice( $has_accommodation, 0, 9 ); |
|
| 161 | + /** |
|
| 162 | + * This is the function that will be triggered by the cron event. |
|
| 163 | + * |
|
| 164 | + * @return void |
|
| 165 | + */ |
|
| 166 | + public function cron_callback( $task = '', $featured_image = '' ) { |
|
| 167 | + $has_accommodation = get_option( $task ); |
|
| 168 | + if ( false !== $has_accommodation && ! empty( $has_accommodation ) ) { |
|
| 169 | + $next_time = array_slice( $has_accommodation, 10 ); |
|
| 170 | + $this_time = array_slice( $has_accommodation, 0, 9 ); |
|
| 171 | 171 | |
| 172 | - $api_key = $this->get_api_key(); |
|
| 173 | - $url = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids='; |
|
| 172 | + $api_key = $this->get_api_key(); |
|
| 173 | + $url = 'https://wetu.com/API/Pins/' . $api_key . '/Get?all=include&ids='; |
|
| 174 | 174 | |
| 175 | - // Run through the current items. |
|
| 176 | - foreach ( $this_time as $accommodation ) { |
|
| 177 | - $wetu_id = get_post_meta( $accommodation, 'lsx_wetu_id', true ); |
|
| 178 | - $last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true ); |
|
| 175 | + // Run through the current items. |
|
| 176 | + foreach ( $this_time as $accommodation ) { |
|
| 177 | + $wetu_id = get_post_meta( $accommodation, 'lsx_wetu_id', true ); |
|
| 178 | + $last_date = get_post_meta( $accommodation, 'lsx_wetu_modified_date', true ); |
|
| 179 | 179 | |
| 180 | - $accommodation_info = wp_remote_get( $url . $wetu_id ); |
|
| 181 | - if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) { |
|
| 182 | - $adata = json_decode( $accommodation_info['body'], true ); |
|
| 180 | + $accommodation_info = wp_remote_get( $url . $wetu_id ); |
|
| 181 | + if ( ! empty( $accommodation_info ) && isset( $accommodation_info['response'] ) && isset( $accommodation_info['response']['code'] ) && 200 === $accommodation_info['response']['code'] ) { |
|
| 182 | + $adata = json_decode( $accommodation_info['body'], true ); |
|
| 183 | 183 | |
| 184 | - if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) { |
|
| 185 | - $modified_time = strtotime( $adata[0]['last_modified'] ); |
|
| 186 | - if ( $modified_time > $last_date ) { |
|
| 187 | - $accommodation_importer = new \LSX_WETU_Importer_Accommodation(); |
|
| 188 | - $accommodation_importer->create_main_gallery( $adata, $accommodation ); |
|
| 189 | - if ( '' !== $featured_image ) { |
|
| 190 | - $accommodation_importer->set_featured_image( $adata, $accommodation ); |
|
| 191 | - } |
|
| 192 | - update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date ); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 184 | + if ( isset( $adata[0] ) && isset( $adata[0]['last_modified'] ) && '' !== $adata[0]['last_modified'] ) { |
|
| 185 | + $modified_time = strtotime( $adata[0]['last_modified'] ); |
|
| 186 | + if ( $modified_time > $last_date ) { |
|
| 187 | + $accommodation_importer = new \LSX_WETU_Importer_Accommodation(); |
|
| 188 | + $accommodation_importer->create_main_gallery( $adata, $accommodation ); |
|
| 189 | + if ( '' !== $featured_image ) { |
|
| 190 | + $accommodation_importer->set_featured_image( $adata, $accommodation ); |
|
| 191 | + } |
|
| 192 | + update_post_meta( $accommodation, 'lsx_wetu_modified_date', $modified_time, $last_date ); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - // Save the values for next time. |
|
| 199 | - if ( ! empty( $next_time ) ) { |
|
| 200 | - update_option( $task, $next_time ); |
|
| 201 | - } else { |
|
| 202 | - delete_option( $task ); |
|
| 203 | - $this->deactivate( $task ); |
|
| 204 | - } |
|
| 205 | - } else { |
|
| 206 | - $this->deactivate( $task ); |
|
| 207 | - update_option( 'lsx_wetu_nexttime', $task ); |
|
| 208 | - } |
|
| 209 | - } |
|
| 198 | + // Save the values for next time. |
|
| 199 | + if ( ! empty( $next_time ) ) { |
|
| 200 | + update_option( $task, $next_time ); |
|
| 201 | + } else { |
|
| 202 | + delete_option( $task ); |
|
| 203 | + $this->deactivate( $task ); |
|
| 204 | + } |
|
| 205 | + } else { |
|
| 206 | + $this->deactivate( $task ); |
|
| 207 | + update_option( 'lsx_wetu_nexttime', $task ); |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | 210 | |
| 211 | - /** |
|
| 212 | - * This will grab the accommodation ids and load them up into an option field. |
|
| 213 | - * |
|
| 214 | - * @param string $task |
|
| 215 | - * @return void |
|
| 216 | - */ |
|
| 217 | - public function load_items_to_sync( $task = 'accommodation_images' ) { |
|
| 218 | - $args = array( |
|
| 219 | - 'post_status' => 'publish', |
|
| 220 | - 'posts_per_page' => -1, |
|
| 221 | - 'nopagin' => true, |
|
| 222 | - 'fields' => 'ids', |
|
| 223 | - ); |
|
| 224 | - switch ( $task ) { |
|
| 225 | - case 'accommodation_images': |
|
| 226 | - $args['post_type'] = 'accommodation'; |
|
| 227 | - break; |
|
| 211 | + /** |
|
| 212 | + * This will grab the accommodation ids and load them up into an option field. |
|
| 213 | + * |
|
| 214 | + * @param string $task |
|
| 215 | + * @return void |
|
| 216 | + */ |
|
| 217 | + public function load_items_to_sync( $task = 'accommodation_images' ) { |
|
| 218 | + $args = array( |
|
| 219 | + 'post_status' => 'publish', |
|
| 220 | + 'posts_per_page' => -1, |
|
| 221 | + 'nopagin' => true, |
|
| 222 | + 'fields' => 'ids', |
|
| 223 | + ); |
|
| 224 | + switch ( $task ) { |
|
| 225 | + case 'accommodation_images': |
|
| 226 | + $args['post_type'] = 'accommodation'; |
|
| 227 | + break; |
|
| 228 | 228 | |
| 229 | - default: |
|
| 230 | - break; |
|
| 231 | - } |
|
| 232 | - $items = new \WP_Query( $args ); |
|
| 233 | - if ( $items->have_posts() ) { |
|
| 234 | - update_option( 'lsx_wetu_' . $task . '_sync', $items->posts ); |
|
| 235 | - } |
|
| 236 | - } |
|
| 229 | + default: |
|
| 230 | + break; |
|
| 231 | + } |
|
| 232 | + $items = new \WP_Query( $args ); |
|
| 233 | + if ( $items->have_posts() ) { |
|
| 234 | + update_option( 'lsx_wetu_' . $task . '_sync', $items->posts ); |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | |
| 238 | - /** |
|
| 239 | - * Gets the API key stored in the options table. |
|
| 240 | - * |
|
| 241 | - * @return string |
|
| 242 | - */ |
|
| 243 | - public function get_api_key() { |
|
| 244 | - $api_key = false; |
|
| 245 | - $options = lsx_wetu_get_options(); |
|
| 238 | + /** |
|
| 239 | + * Gets the API key stored in the options table. |
|
| 240 | + * |
|
| 241 | + * @return string |
|
| 242 | + */ |
|
| 243 | + public function get_api_key() { |
|
| 244 | + $api_key = false; |
|
| 245 | + $options = lsx_wetu_get_options(); |
|
| 246 | 246 | |
| 247 | - if ( ! defined( 'WETU_API_KEY' ) ) { |
|
| 248 | - if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) { |
|
| 249 | - $api_key = $options['api_key']; |
|
| 250 | - } |
|
| 251 | - } else { |
|
| 252 | - $api_key = WETU_API_KEY; |
|
| 253 | - } |
|
| 254 | - return $api_key; |
|
| 255 | - } |
|
| 247 | + if ( ! defined( 'WETU_API_KEY' ) ) { |
|
| 248 | + if ( isset( $options['api_key'] ) && '' !== $options['api_key'] ) { |
|
| 249 | + $api_key = $options['api_key']; |
|
| 250 | + } |
|
| 251 | + } else { |
|
| 252 | + $api_key = WETU_API_KEY; |
|
| 253 | + } |
|
| 254 | + return $api_key; |
|
| 255 | + } |
|
| 256 | 256 | } |
| 257 | 257 | Cron::get_instance(); |
@@ -14,85 +14,85 @@ 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 | - 'accommodation_images_cron_featured' => '', |
|
| 68 | - ); |
|
| 69 | - $this->fields = array_keys( $this->defaults ); |
|
| 70 | - add_action( 'admin_init', array( $this, 'save_options' ) ); |
|
| 71 | - } |
|
| 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 | + 'accommodation_images_cron_featured' => '', |
|
| 68 | + ); |
|
| 69 | + $this->fields = array_keys( $this->defaults ); |
|
| 70 | + add_action( 'admin_init', array( $this, 'save_options' ) ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * Return an instance of this class. |
|
| 75 | - * |
|
| 76 | - * @return object |
|
| 77 | - */ |
|
| 78 | - public static function get_instance() { |
|
| 79 | - // If the single instance hasn't been set, set it now. |
|
| 80 | - if ( ! isset( self::$instance ) ) { |
|
| 81 | - self::$instance = new self(); |
|
| 82 | - } |
|
| 83 | - return self::$instance; |
|
| 84 | - } |
|
| 73 | + /** |
|
| 74 | + * Return an instance of this class. |
|
| 75 | + * |
|
| 76 | + * @return object |
|
| 77 | + */ |
|
| 78 | + public static function get_instance() { |
|
| 79 | + // If the single instance hasn't been set, set it now. |
|
| 80 | + if ( ! isset( self::$instance ) ) { |
|
| 81 | + self::$instance = new self(); |
|
| 82 | + } |
|
| 83 | + return self::$instance; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Display the importer welcome screen |
|
| 88 | - */ |
|
| 89 | - public function display_page() { |
|
| 90 | - $options = lsx_wetu_get_options(); |
|
| 91 | - foreach ( $options as $key => $value ) { |
|
| 92 | - $value = trim( $value ); |
|
| 93 | - } |
|
| 94 | - $options = wp_parse_args( $options, $this->defaults ); |
|
| 95 | - ?> |
|
| 86 | + /** |
|
| 87 | + * Display the importer welcome screen |
|
| 88 | + */ |
|
| 89 | + public function display_page() { |
|
| 90 | + $options = lsx_wetu_get_options(); |
|
| 91 | + foreach ( $options as $key => $value ) { |
|
| 92 | + $value = trim( $value ); |
|
| 93 | + } |
|
| 94 | + $options = wp_parse_args( $options, $this->defaults ); |
|
| 95 | + ?> |
|
| 96 | 96 | <div class="wrap"> |
| 97 | 97 | <form method="post" class=""> |
| 98 | 98 | <?php wp_nonce_field( 'lsx_wetu_importer_save', 'lsx_wetu_importer_save_options' ); ?> |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | <td> |
| 108 | 108 | <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=" |
| 109 | 109 | <?php |
| 110 | - if ( isset( $options['api_key'] ) ) { |
|
| 111 | - echo esc_attr( $options['api_key'] ); |
|
| 112 | - } |
|
| 113 | - ?> |
|
| 110 | + if ( isset( $options['api_key'] ) ) { |
|
| 111 | + echo esc_attr( $options['api_key'] ); |
|
| 112 | + } |
|
| 113 | + ?> |
|
| 114 | 114 | " name="api_key" /> |
| 115 | 115 | </td> |
| 116 | 116 | </tr> |
@@ -127,10 +127,10 @@ discard block |
||
| 127 | 127 | <td> |
| 128 | 128 | <input type="checkbox" |
| 129 | 129 | <?php |
| 130 | - if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) { |
|
| 131 | - echo esc_attr( 'checked="checked"' ); |
|
| 132 | - } |
|
| 133 | - ?> |
|
| 130 | + if ( isset( $options['disable_tour_title'] ) && '' !== $options['disable_tour_title'] ) { |
|
| 131 | + echo esc_attr( 'checked="checked"' ); |
|
| 132 | + } |
|
| 133 | + ?> |
|
| 134 | 134 | name="disable_tour_title" /> |
| 135 | 135 | |
| 136 | 136 | <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> |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | <td> |
| 144 | 144 | <input type="checkbox" |
| 145 | 145 | <?php |
| 146 | - if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) { |
|
| 147 | - echo esc_attr( 'checked="checked"' ); |
|
| 148 | - } |
|
| 149 | - ?> |
|
| 146 | + if ( isset( $options['disable_tour_descriptions'] ) && '' !== $options['disable_tour_descriptions'] ) { |
|
| 147 | + echo esc_attr( 'checked="checked"' ); |
|
| 148 | + } |
|
| 149 | + ?> |
|
| 150 | 150 | name="disable_tour_descriptions" /> |
| 151 | 151 | |
| 152 | 152 | <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> |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | <td> |
| 160 | 160 | <input type="checkbox" |
| 161 | 161 | <?php |
| 162 | - if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) { |
|
| 163 | - echo esc_attr( 'checked="checked"' ); |
|
| 164 | - } |
|
| 165 | - ?> |
|
| 162 | + if ( isset( $options['disable_tour_tags'] ) && '' !== $options['disable_tour_tags'] ) { |
|
| 163 | + echo esc_attr( 'checked="checked"' ); |
|
| 164 | + } |
|
| 165 | + ?> |
|
| 166 | 166 | name="disable_tour_tags" /> |
| 167 | 167 | |
| 168 | 168 | <small><?php esc_html_e( 'Disable this is you dont want the option available on the import screen.', 'lsx-wetu-importer' ); ?></small> |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | <td> |
| 177 | 177 | <input type="checkbox" |
| 178 | 178 | <?php |
| 179 | - if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) { |
|
| 180 | - echo esc_attr( 'checked="checked"' ); |
|
| 181 | - } |
|
| 182 | - ?> |
|
| 179 | + if ( isset( $options['enable_tour_ref_column'] ) && '' !== $options['enable_tour_ref_column'] ) { |
|
| 180 | + echo esc_attr( 'checked="checked"' ); |
|
| 181 | + } |
|
| 182 | + ?> |
|
| 183 | 183 | name="enable_tour_ref_column" /> |
| 184 | 184 | <small><?php esc_html_e( 'Enables the use of the WETU Reference Column for better tours management.', 'lsx-wetu-importer' ); ?></small> |
| 185 | 185 | </td> |
@@ -192,10 +192,10 @@ discard block |
||
| 192 | 192 | <td> |
| 193 | 193 | <input type="checkbox" |
| 194 | 194 | <?php |
| 195 | - if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) { |
|
| 196 | - echo esc_attr( 'checked="checked"' ); |
|
| 197 | - } |
|
| 198 | - ?> |
|
| 195 | + if ( isset( $options['enable_tour_featured_random'] ) && '' !== $options['enable_tour_featured_random'] ) { |
|
| 196 | + echo esc_attr( 'checked="checked"' ); |
|
| 197 | + } |
|
| 198 | + ?> |
|
| 199 | 199 | name="enable_tour_featured_random" /> |
| 200 | 200 | <small><?php esc_html_e( 'This will randomize the featured image from the destination gallery.', 'lsx-wetu-importer' ); ?></small> |
| 201 | 201 | </td> |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | <td> |
| 215 | 215 | <input type="checkbox" |
| 216 | 216 | <?php |
| 217 | - if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) { |
|
| 218 | - echo esc_attr( 'checked="checked"' ); |
|
| 219 | - } |
|
| 220 | - ?> |
|
| 217 | + if ( isset( $options['disable_accommodation_title'] ) && '' !== $options['disable_accommodation_title'] ) { |
|
| 218 | + echo esc_attr( 'checked="checked"' ); |
|
| 219 | + } |
|
| 220 | + ?> |
|
| 221 | 221 | name="disable_accommodation_title" /> |
| 222 | 222 | |
| 223 | 223 | <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> |
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | <td> |
| 231 | 231 | <input type="checkbox" |
| 232 | 232 | <?php |
| 233 | - if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) { |
|
| 234 | - echo esc_attr( 'checked="checked"' ); |
|
| 235 | - } |
|
| 236 | - ?> |
|
| 233 | + if ( isset( $options['disable_accommodation_descriptions'] ) && '' !== $options['disable_accommodation_descriptions'] ) { |
|
| 234 | + echo esc_attr( 'checked="checked"' ); |
|
| 235 | + } |
|
| 236 | + ?> |
|
| 237 | 237 | name="disable_accommodation_descriptions" /> |
| 238 | 238 | <small><?php esc_html_e( 'If you are going to edit the accommodation descriptions imported then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
| 239 | 239 | </td> |
@@ -245,10 +245,10 @@ discard block |
||
| 245 | 245 | <td> |
| 246 | 246 | <input type="checkbox" |
| 247 | 247 | <?php |
| 248 | - if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) { |
|
| 249 | - echo esc_attr( 'checked="checked"' ); |
|
| 250 | - } |
|
| 251 | - ?> |
|
| 248 | + if ( isset( $options['disable_accommodation_filtering'] ) && '' !== $options['disable_accommodation_filtering'] ) { |
|
| 249 | + echo esc_attr( 'checked="checked"' ); |
|
| 250 | + } |
|
| 251 | + ?> |
|
| 252 | 252 | name="disable_accommodation_filtering" /> |
| 253 | 253 | <small><?php esc_html_e( 'This will stop the HTML from being stripped out of the description.', 'lsx-wetu-importer' ); ?></small> |
| 254 | 254 | </td> |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | <td> |
| 262 | 262 | <input type="checkbox" |
| 263 | 263 | <?php |
| 264 | - if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) { |
|
| 265 | - echo esc_attr( 'checked="checked"' ); |
|
| 266 | - } |
|
| 267 | - ?> |
|
| 264 | + if ( isset( $options['disable_accommodation_excerpts'] ) && '' !== $options['disable_accommodation_excerpts'] ) { |
|
| 265 | + echo esc_attr( 'checked="checked"' ); |
|
| 266 | + } |
|
| 267 | + ?> |
|
| 268 | 268 | name="disable_accommodation_excerpts" /> |
| 269 | 269 | <small><?php esc_html_e( 'If you are going to edit the accommodation excerpts then enable this setting.', 'lsx-wetu-importer' ); ?></small> |
| 270 | 270 | </td> |
@@ -283,10 +283,10 @@ discard block |
||
| 283 | 283 | <td> |
| 284 | 284 | <input type="checkbox" |
| 285 | 285 | <?php |
| 286 | - if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) { |
|
| 287 | - echo esc_attr( 'checked="checked"' ); |
|
| 288 | - } |
|
| 289 | - ?> |
|
| 286 | + if ( isset( $options['disable_destination_title'] ) && '' !== $options['disable_destination_title'] ) { |
|
| 287 | + echo esc_attr( 'checked="checked"' ); |
|
| 288 | + } |
|
| 289 | + ?> |
|
| 290 | 290 | name="disable_destination_title" /> |
| 291 | 291 | |
| 292 | 292 | <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> |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | <td> |
| 300 | 300 | <input type="checkbox" |
| 301 | 301 | <?php |
| 302 | - if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) { |
|
| 303 | - echo esc_attr( 'checked="checked"' ); |
|
| 304 | - } |
|
| 305 | - ?> |
|
| 302 | + if ( isset( $options['disable_destination_descriptions'] ) && '' !== $options['disable_destination_descriptions'] ) { |
|
| 303 | + echo esc_attr( 'checked="checked"' ); |
|
| 304 | + } |
|
| 305 | + ?> |
|
| 306 | 306 | name="disable_destination_descriptions" /> |
| 307 | 307 | <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> |
| 308 | 308 | </td> |
@@ -321,10 +321,10 @@ discard block |
||
| 321 | 321 | <td> |
| 322 | 322 | <input type="checkbox" |
| 323 | 323 | <?php |
| 324 | - if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) { |
|
| 325 | - echo esc_attr( 'checked="checked"' ); |
|
| 326 | - } |
|
| 327 | - ?> |
|
| 324 | + if ( isset( $options['image_replacing'] ) && '' !== $options['image_replacing'] ) { |
|
| 325 | + echo esc_attr( 'checked="checked"' ); |
|
| 326 | + } |
|
| 327 | + ?> |
|
| 328 | 328 | name="image_replacing" /> |
| 329 | 329 | <p><?php esc_html_e( 'Do you want your images to be replaced on each import.', 'lsx-wetu-importer' ); ?></p> |
| 330 | 330 | </td> |
@@ -336,10 +336,10 @@ discard block |
||
| 336 | 336 | <td> |
| 337 | 337 | <input placeholder="" type="text" value=" |
| 338 | 338 | <?php |
| 339 | - if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) { |
|
| 340 | - echo esc_attr( $options['image_limit'] ); |
|
| 341 | - } |
|
| 342 | - ?> |
|
| 339 | + if ( isset( $options['image_limit'] ) && '' !== $options['image_limit'] ) { |
|
| 340 | + echo esc_attr( $options['image_limit'] ); |
|
| 341 | + } |
|
| 342 | + ?> |
|
| 343 | 343 | " |
| 344 | 344 | name="image_limit" /> |
| 345 | 345 | </td> |
@@ -352,10 +352,10 @@ discard block |
||
| 352 | 352 | <td> |
| 353 | 353 | <input type="checkbox" |
| 354 | 354 | <?php |
| 355 | - if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) { |
|
| 356 | - echo esc_attr( 'checked="checked"' ); |
|
| 357 | - } |
|
| 358 | - ?> |
|
| 355 | + if ( isset( $options['image_scaling'] ) && '' !== $options['image_scaling'] ) { |
|
| 356 | + echo esc_attr( 'checked="checked"' ); |
|
| 357 | + } |
|
| 358 | + ?> |
|
| 359 | 359 | name="image_scaling" /> |
| 360 | 360 | </td> |
| 361 | 361 | </tr> |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | <td> |
| 367 | 367 | <input placeholder="800" type="text" value=" |
| 368 | 368 | <?php |
| 369 | - if ( isset( $options['width'] ) && '' !== $options['width'] ) { |
|
| 370 | - echo esc_attr( $options['width'] ); |
|
| 371 | - } |
|
| 372 | - ?> |
|
| 369 | + if ( isset( $options['width'] ) && '' !== $options['width'] ) { |
|
| 370 | + echo esc_attr( $options['width'] ); |
|
| 371 | + } |
|
| 372 | + ?> |
|
| 373 | 373 | " |
| 374 | 374 | name="width" /> |
| 375 | 375 | </td> |
@@ -381,10 +381,10 @@ discard block |
||
| 381 | 381 | <td> |
| 382 | 382 | <input placeholder="600" type="text" value=" |
| 383 | 383 | <?php |
| 384 | - if ( isset( $options['height'] ) && '' !== $options['height'] ) { |
|
| 385 | - echo esc_attr( $options['height'] ); |
|
| 386 | - } |
|
| 387 | - ?> |
|
| 384 | + if ( isset( $options['height'] ) && '' !== $options['height'] ) { |
|
| 385 | + echo esc_attr( $options['height'] ); |
|
| 386 | + } |
|
| 387 | + ?> |
|
| 388 | 388 | " |
| 389 | 389 | name="height" /> |
| 390 | 390 | </td> |
@@ -397,52 +397,52 @@ discard block |
||
| 397 | 397 | <td> |
| 398 | 398 | <input type="radio" |
| 399 | 399 | <?php |
| 400 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) { |
|
| 401 | - echo esc_attr( 'checked="checked"' ); |
|
| 402 | - } |
|
| 403 | - ?> |
|
| 400 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'raw' === $options['scaling'] ) { |
|
| 401 | + echo esc_attr( 'checked="checked"' ); |
|
| 402 | + } |
|
| 403 | + ?> |
|
| 404 | 404 | name="scaling" value="raw" /> <?php esc_html_e( 'Get the Full size image, no cropping takes place.', 'lsx-wetu-importer' ); ?><br /> |
| 405 | 405 | <input type="radio" |
| 406 | 406 | <?php |
| 407 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) { |
|
| 408 | - echo esc_attr( 'checked="checked"' ); |
|
| 409 | - } |
|
| 410 | - ?> |
|
| 407 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'c' === $options['scaling'] ) { |
|
| 408 | + echo esc_attr( 'checked="checked"' ); |
|
| 409 | + } |
|
| 410 | + ?> |
|
| 411 | 411 | 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 /> |
| 412 | 412 | <input type="radio" |
| 413 | 413 | <?php |
| 414 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) { |
|
| 415 | - echo esc_attr( 'checked="checked"' ); |
|
| 416 | - } |
|
| 417 | - ?> |
|
| 414 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'h' === $options['scaling'] ) { |
|
| 415 | + echo esc_attr( 'checked="checked"' ); |
|
| 416 | + } |
|
| 417 | + ?> |
|
| 418 | 418 | 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 /> |
| 419 | 419 | <input type="radio" |
| 420 | 420 | <?php |
| 421 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) { |
|
| 422 | - echo esc_attr( 'checked="checked"' ); |
|
| 423 | - } |
|
| 424 | - ?> |
|
| 421 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'w' === $options['scaling'] ) { |
|
| 422 | + echo esc_attr( 'checked="checked"' ); |
|
| 423 | + } |
|
| 424 | + ?> |
|
| 425 | 425 | 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 /> |
| 426 | 426 | <input type="radio" |
| 427 | 427 | <?php |
| 428 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) { |
|
| 429 | - echo esc_attr( 'checked="checked"' ); |
|
| 430 | - } |
|
| 431 | - ?> |
|
| 428 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'nf' === $options['scaling'] ) { |
|
| 429 | + echo esc_attr( 'checked="checked"' ); |
|
| 430 | + } |
|
| 431 | + ?> |
|
| 432 | 432 | 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 /> |
| 433 | 433 | <input type="radio" |
| 434 | 434 | <?php |
| 435 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) { |
|
| 436 | - echo esc_attr( 'checked="checked"' ); |
|
| 437 | - } |
|
| 438 | - ?> |
|
| 435 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'n' === $options['scaling'] ) { |
|
| 436 | + echo esc_attr( 'checked="checked"' ); |
|
| 437 | + } |
|
| 438 | + ?> |
|
| 439 | 439 | 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 /> |
| 440 | 440 | <input type="radio" |
| 441 | 441 | <?php |
| 442 | - if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) { |
|
| 443 | - echo esc_attr( 'checked="checked"' ); |
|
| 444 | - } |
|
| 445 | - ?> |
|
| 442 | + if ( isset( $options['scaling'] ) && '' !== $options['scaling'] && 'W' === $options['scaling'] ) { |
|
| 443 | + echo esc_attr( 'checked="checked"' ); |
|
| 444 | + } |
|
| 445 | + ?> |
|
| 446 | 446 | 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' ); ?> |
| 447 | 447 | </td> |
| 448 | 448 | </tr> |
@@ -460,28 +460,28 @@ discard block |
||
| 460 | 460 | <td> |
| 461 | 461 | <select name="cron_schedule" id="cron_schedule" class="widefat layout"> |
| 462 | 462 | <?php |
| 463 | - if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) { |
|
| 464 | - $schedule = $options['cron_schedule']; |
|
| 465 | - } else { |
|
| 466 | - $schedule = 'daily'; |
|
| 467 | - } |
|
| 468 | - $timeslots = array( |
|
| 469 | - 'daily' => __( 'Daily', 'lsx-wetu-importer' ), |
|
| 470 | - 'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ), |
|
| 471 | - 'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ), |
|
| 472 | - 'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ), |
|
| 473 | - 'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ), |
|
| 474 | - 'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ), |
|
| 475 | - 'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ), |
|
| 476 | - 'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ), |
|
| 477 | - ); |
|
| 478 | - foreach ( $timeslots as $key => $name ) { |
|
| 479 | - $selected = ( $schedule == $key ) ? ' selected="selected"' : ''; |
|
| 480 | - ?> |
|
| 463 | + if ( isset( $options['cron_schedule'] ) && '' !== $options['cron_schedule'] ) { |
|
| 464 | + $schedule = $options['cron_schedule']; |
|
| 465 | + } else { |
|
| 466 | + $schedule = 'daily'; |
|
| 467 | + } |
|
| 468 | + $timeslots = array( |
|
| 469 | + 'daily' => __( 'Daily', 'lsx-wetu-importer' ), |
|
| 470 | + 'weekly-mon' => __( 'Weekly (Monday)', 'lsx-wetu-importer' ), |
|
| 471 | + 'weekly-tue' => __( 'Weekly (Tuesday)', 'lsx-wetu-importer' ), |
|
| 472 | + 'weekly-wed' => __( 'Weekly (Wednesday)', 'lsx-wetu-importer' ), |
|
| 473 | + 'weekly-thu' => __( 'Weekly (Thursday)', 'lsx-wetu-importer' ), |
|
| 474 | + 'weekly-fri' => __( 'Weekly (Friday)', 'lsx-wetu-importer' ), |
|
| 475 | + 'weekly-sat' => __( 'Weekly (Saturday)', 'lsx-wetu-importer' ), |
|
| 476 | + 'weekly-sun' => __( 'Weekly (Sunday)', 'lsx-wetu-importer' ), |
|
| 477 | + ); |
|
| 478 | + foreach ( $timeslots as $key => $name ) { |
|
| 479 | + $selected = ( $schedule == $key ) ? ' selected="selected"' : ''; |
|
| 480 | + ?> |
|
| 481 | 481 | <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> |
| 482 | 482 | <?php |
| 483 | - } |
|
| 484 | - ?> |
|
| 483 | + } |
|
| 484 | + ?> |
|
| 485 | 485 | </select> |
| 486 | 486 | </td> |
| 487 | 487 | </tr> |
@@ -492,10 +492,10 @@ discard block |
||
| 492 | 492 | <td> |
| 493 | 493 | <input type="checkbox" |
| 494 | 494 | <?php |
| 495 | - if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) { |
|
| 496 | - echo esc_attr( 'checked="checked"' ); |
|
| 497 | - } |
|
| 498 | - ?> |
|
| 495 | + if ( isset( $options['accommodation_images_cron'] ) && '' !== $options['accommodation_images_cron'] ) { |
|
| 496 | + echo esc_attr( 'checked="checked"' ); |
|
| 497 | + } |
|
| 498 | + ?> |
|
| 499 | 499 | name="accommodation_images_cron" /> |
| 500 | 500 | <p><?php esc_html_e( 'Update the accommodation images accodring to the schedule above.', 'lsx-wetu-importer' ); ?></p> |
| 501 | 501 | </td> |
@@ -507,10 +507,10 @@ discard block |
||
| 507 | 507 | <td> |
| 508 | 508 | <input type="checkbox" |
| 509 | 509 | <?php |
| 510 | - if ( isset( $options['accommodation_images_cron_featured'] ) && '' !== $options['accommodation_images_cron_featured'] ) { |
|
| 511 | - echo esc_attr( 'checked="checked"' ); |
|
| 512 | - } |
|
| 513 | - ?> |
|
| 510 | + if ( isset( $options['accommodation_images_cron_featured'] ) && '' !== $options['accommodation_images_cron_featured'] ) { |
|
| 511 | + echo esc_attr( 'checked="checked"' ); |
|
| 512 | + } |
|
| 513 | + ?> |
|
| 514 | 514 | name="accommodation_images_cron_featured" /> |
| 515 | 515 | <p><?php esc_html_e( 'Set the featured image when the gallery is created.', 'lsx-wetu-importer' ); ?></p> |
| 516 | 516 | </td> |
@@ -522,25 +522,25 @@ discard block |
||
| 522 | 522 | </form> |
| 523 | 523 | </div> |
| 524 | 524 | <?php |
| 525 | - } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | - /** |
|
| 528 | - * Save the options fields |
|
| 529 | - * |
|
| 530 | - * @return void |
|
| 531 | - */ |
|
| 532 | - public function save_options() { |
|
| 533 | - if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) { |
|
| 534 | - return; |
|
| 535 | - } |
|
| 536 | - $data_to_save = array(); |
|
| 537 | - foreach ( $this->defaults as $key => $field ) { |
|
| 538 | - if ( isset( $_POST[ $key ] ) ) { |
|
| 539 | - $data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] ); |
|
| 540 | - } else { |
|
| 541 | - $data_to_save[ $key ] = ''; |
|
| 542 | - } |
|
| 543 | - } |
|
| 544 | - update_option( 'lsx_wetu_importer_settings', $data_to_save ); |
|
| 545 | - } |
|
| 527 | + /** |
|
| 528 | + * Save the options fields |
|
| 529 | + * |
|
| 530 | + * @return void |
|
| 531 | + */ |
|
| 532 | + public function save_options() { |
|
| 533 | + if ( ! isset( $_POST['lsx_wetu_importer_save_options'] ) || ! wp_verify_nonce( $_POST['lsx_wetu_importer_save_options'], 'lsx_wetu_importer_save' ) ) { |
|
| 534 | + return; |
|
| 535 | + } |
|
| 536 | + $data_to_save = array(); |
|
| 537 | + foreach ( $this->defaults as $key => $field ) { |
|
| 538 | + if ( isset( $_POST[ $key ] ) ) { |
|
| 539 | + $data_to_save[ $key ] = sanitize_text_field( $_POST[ $key ] ); |
|
| 540 | + } else { |
|
| 541 | + $data_to_save[ $key ] = ''; |
|
| 542 | + } |
|
| 543 | + } |
|
| 544 | + update_option( 'lsx_wetu_importer_settings', $data_to_save ); |
|
| 545 | + } |
|
| 546 | 546 | } |