@@ -4,43 +4,43 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Flat_Rate_Shipping_Method extends Shipping_Method { |
| 6 | 6 | |
| 7 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 7 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 8 | 8 | |
| 9 | - if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 10 | - $jsonld['availableDeliveryMethod'] = array(); |
|
| 11 | - } |
|
| 9 | + if ( ! isset( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 10 | + $jsonld['availableDeliveryMethod'] = array(); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 14 | - $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | - } |
|
| 13 | + if ( ! is_array( $jsonld['availableDeliveryMethod'] ) ) { |
|
| 14 | + $jsonld['availableDeliveryMethod'] = array( $jsonld['availableDeliveryMethod'] ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) { |
|
| 18 | - array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 19 | - } |
|
| 17 | + if ( ! in_array( 'ParcelDelivery', $jsonld['availableDeliveryMethod'], true ) ) { |
|
| 18 | + array_push( $jsonld['availableDeliveryMethod'], 'ParcelDelivery' ); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 23 | + public function add_shipping_rate( &$offer_shipping_details ) { |
|
| 24 | 24 | |
| 25 | - if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 26 | - $offer_shipping_details['shippingRate'] = array(); |
|
| 27 | - } |
|
| 25 | + if ( ! isset( $offer_shipping_details['shippingRate'] ) ) { |
|
| 26 | + $offer_shipping_details['shippingRate'] = array(); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - $description = isset( $this->wc_shipping_method->instance_settings['description'] ) |
|
| 30 | - ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : ''; |
|
| 29 | + $description = isset( $this->wc_shipping_method->instance_settings['description'] ) |
|
| 30 | + ? wp_strip_all_tags( $this->wc_shipping_method->instance_settings['description'] ) : ''; |
|
| 31 | 31 | |
| 32 | - $shipping_rate = array( |
|
| 33 | - '@type' => 'MonetaryAmount', |
|
| 34 | - 'name' => $this->wc_shipping_method->get_title(), |
|
| 35 | - 'description' => $description, |
|
| 36 | - 'value' => $this->wc_shipping_method->get_option( 'cost' ), |
|
| 37 | - 'currency' => get_woocommerce_currency(), |
|
| 38 | - ); |
|
| 32 | + $shipping_rate = array( |
|
| 33 | + '@type' => 'MonetaryAmount', |
|
| 34 | + 'name' => $this->wc_shipping_method->get_title(), |
|
| 35 | + 'description' => $description, |
|
| 36 | + 'value' => $this->wc_shipping_method->get_option( 'cost' ), |
|
| 37 | + 'currency' => get_woocommerce_currency(), |
|
| 38 | + ); |
|
| 39 | 39 | |
| 40 | - $this->change_to_manual_currency( $shipping_rate ); |
|
| 40 | + $this->change_to_manual_currency( $shipping_rate ); |
|
| 41 | 41 | |
| 42 | - $offer_shipping_details['shippingRate'][] = $shipping_rate; |
|
| 42 | + $offer_shipping_details['shippingRate'][] = $shipping_rate; |
|
| 43 | 43 | |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | } |
@@ -4,22 +4,22 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Download_Ingredients_Data { |
| 6 | 6 | |
| 7 | - public function register_hooks() { |
|
| 8 | - add_action( 'wp_ajax_wl_download_ingredients_data', array( $this, 'wl_download_ingredients_data' ) ); |
|
| 9 | - } |
|
| 7 | + public function register_hooks() { |
|
| 8 | + add_action( 'wp_ajax_wl_download_ingredients_data', array( $this, 'wl_download_ingredients_data' ) ); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function wl_download_ingredients_data() { |
|
| 11 | + public function wl_download_ingredients_data() { |
|
| 12 | 12 | |
| 13 | - check_ajax_referer( 'wl-dl-ingredients-data-nonce' ); |
|
| 13 | + check_ajax_referer( 'wl-dl-ingredients-data-nonce' ); |
|
| 14 | 14 | |
| 15 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 16 | - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wordlift' ) ); |
|
| 17 | - } |
|
| 15 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 16 | + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wordlift' ) ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - global $wpdb; |
|
| 19 | + global $wpdb; |
|
| 20 | 20 | |
| 21 | - $items = $wpdb->get_results( |
|
| 22 | - "SELECT p1.ID AS recipe_ID, |
|
| 21 | + $items = $wpdb->get_results( |
|
| 22 | + "SELECT p1.ID AS recipe_ID, |
|
| 23 | 23 | p1.post_title AS recipe_name, |
| 24 | 24 | p2.ID AS post_ID, |
| 25 | 25 | p2.post_title |
@@ -29,62 +29,62 @@ discard block |
||
| 29 | 29 | INNER JOIN $wpdb->postmeta pm2 |
| 30 | 30 | ON pm2.post_ID = pm1.post_ID AND pm2.meta_key = 'wprm_parent_post_id' |
| 31 | 31 | INNER JOIN $wpdb->posts p2" |
| 32 | - // The following ignore rule is used against the `LIKE CONCAT`. We only have const values. |
|
| 33 | - // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery |
|
| 34 | - . " ON p2.post_status = 'publish' AND p2.ID = pm2.post_ID |
|
| 32 | + // The following ignore rule is used against the `LIKE CONCAT`. We only have const values. |
|
| 33 | + // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery |
|
| 34 | + . " ON p2.post_status = 'publish' AND p2.ID = pm2.post_ID |
|
| 35 | 35 | WHERE pm1.meta_key = '_wl_main_ingredient_jsonld'" |
| 36 | - ); |
|
| 37 | - |
|
| 38 | - if ( ! $items ) { |
|
| 39 | - wp_send_json_error( __( 'No main ingredients found.', 'wordlift' ) ); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - // Generate unique filename using current timestamp. |
|
| 43 | - $filename = 'wl-main-ingredients-data-' . gmdate( 'Y-m-d-H-i-s' ) . '.tsv'; |
|
| 44 | - |
|
| 45 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 46 | - header( 'Content-Type: text/text/tab-separated-values; charset=' . get_bloginfo( 'charset' ) ); |
|
| 47 | - |
|
| 48 | - // Do not cache the file. |
|
| 49 | - header( 'Pragma: no-cache' ); |
|
| 50 | - header( 'Expires: 0' ); |
|
| 51 | - |
|
| 52 | - $output = fopen( 'php://output', 'w' ); |
|
| 53 | - |
|
| 54 | - // Insert Header. |
|
| 55 | - fputcsv( |
|
| 56 | - $output, |
|
| 57 | - array( |
|
| 58 | - __( 'Ingredient Name', 'wordlift' ), |
|
| 59 | - __( 'Recipe Name', 'wordlift' ), |
|
| 60 | - __( 'Recipe ID', 'wordlift' ), |
|
| 61 | - __( 'Post Name', 'wordlift' ), |
|
| 62 | - __( 'Post ID', 'wordlift' ), |
|
| 63 | - __( 'Post URL', 'wordlift' ), |
|
| 64 | - ), |
|
| 65 | - "\t" |
|
| 66 | - ); |
|
| 67 | - |
|
| 68 | - // Insert Data. |
|
| 69 | - foreach ( $items as $item ) { |
|
| 70 | - $recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 71 | - $recipe = json_decode( $recipe_json_ld, true ); |
|
| 72 | - fputcsv( |
|
| 73 | - $output, |
|
| 74 | - array( |
|
| 75 | - $recipe ? $recipe['name'] : 'null', |
|
| 76 | - $item->recipe_name, |
|
| 77 | - // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 78 | - $item->recipe_ID, |
|
| 79 | - $item->post_title, |
|
| 80 | - $item->post_ID, |
|
| 81 | - esc_url( get_the_permalink( $item->post_ID ) ), |
|
| 82 | - ), |
|
| 83 | - "\t" |
|
| 84 | - ); |
|
| 85 | - ob_flush(); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - wp_die(); |
|
| 89 | - } |
|
| 36 | + ); |
|
| 37 | + |
|
| 38 | + if ( ! $items ) { |
|
| 39 | + wp_send_json_error( __( 'No main ingredients found.', 'wordlift' ) ); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + // Generate unique filename using current timestamp. |
|
| 43 | + $filename = 'wl-main-ingredients-data-' . gmdate( 'Y-m-d-H-i-s' ) . '.tsv'; |
|
| 44 | + |
|
| 45 | + header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 46 | + header( 'Content-Type: text/text/tab-separated-values; charset=' . get_bloginfo( 'charset' ) ); |
|
| 47 | + |
|
| 48 | + // Do not cache the file. |
|
| 49 | + header( 'Pragma: no-cache' ); |
|
| 50 | + header( 'Expires: 0' ); |
|
| 51 | + |
|
| 52 | + $output = fopen( 'php://output', 'w' ); |
|
| 53 | + |
|
| 54 | + // Insert Header. |
|
| 55 | + fputcsv( |
|
| 56 | + $output, |
|
| 57 | + array( |
|
| 58 | + __( 'Ingredient Name', 'wordlift' ), |
|
| 59 | + __( 'Recipe Name', 'wordlift' ), |
|
| 60 | + __( 'Recipe ID', 'wordlift' ), |
|
| 61 | + __( 'Post Name', 'wordlift' ), |
|
| 62 | + __( 'Post ID', 'wordlift' ), |
|
| 63 | + __( 'Post URL', 'wordlift' ), |
|
| 64 | + ), |
|
| 65 | + "\t" |
|
| 66 | + ); |
|
| 67 | + |
|
| 68 | + // Insert Data. |
|
| 69 | + foreach ( $items as $item ) { |
|
| 70 | + $recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 71 | + $recipe = json_decode( $recipe_json_ld, true ); |
|
| 72 | + fputcsv( |
|
| 73 | + $output, |
|
| 74 | + array( |
|
| 75 | + $recipe ? $recipe['name'] : 'null', |
|
| 76 | + $item->recipe_name, |
|
| 77 | + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 78 | + $item->recipe_ID, |
|
| 79 | + $item->post_title, |
|
| 80 | + $item->post_ID, |
|
| 81 | + esc_url( get_the_permalink( $item->post_ID ) ), |
|
| 82 | + ), |
|
| 83 | + "\t" |
|
| 84 | + ); |
|
| 85 | + ob_flush(); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + wp_die(); |
|
| 89 | + } |
|
| 90 | 90 | } |
@@ -5,15 +5,15 @@ discard block |
||
| 5 | 5 | class Download_Ingredients_Data { |
| 6 | 6 | |
| 7 | 7 | public function register_hooks() { |
| 8 | - add_action( 'wp_ajax_wl_download_ingredients_data', array( $this, 'wl_download_ingredients_data' ) ); |
|
| 8 | + add_action('wp_ajax_wl_download_ingredients_data', array($this, 'wl_download_ingredients_data')); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | public function wl_download_ingredients_data() { |
| 12 | 12 | |
| 13 | - check_ajax_referer( 'wl-dl-ingredients-data-nonce' ); |
|
| 13 | + check_ajax_referer('wl-dl-ingredients-data-nonce'); |
|
| 14 | 14 | |
| 15 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 16 | - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wordlift' ) ); |
|
| 15 | + if ( ! current_user_can('manage_options')) { |
|
| 16 | + wp_die(esc_html__('You do not have sufficient permissions to access this page.', 'wordlift')); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | global $wpdb; |
@@ -35,40 +35,40 @@ discard block |
||
| 35 | 35 | WHERE pm1.meta_key = '_wl_main_ingredient_jsonld'" |
| 36 | 36 | ); |
| 37 | 37 | |
| 38 | - if ( ! $items ) { |
|
| 39 | - wp_send_json_error( __( 'No main ingredients found.', 'wordlift' ) ); |
|
| 38 | + if ( ! $items) { |
|
| 39 | + wp_send_json_error(__('No main ingredients found.', 'wordlift')); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // Generate unique filename using current timestamp. |
| 43 | - $filename = 'wl-main-ingredients-data-' . gmdate( 'Y-m-d-H-i-s' ) . '.tsv'; |
|
| 43 | + $filename = 'wl-main-ingredients-data-'.gmdate('Y-m-d-H-i-s').'.tsv'; |
|
| 44 | 44 | |
| 45 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 46 | - header( 'Content-Type: text/text/tab-separated-values; charset=' . get_bloginfo( 'charset' ) ); |
|
| 45 | + header('Content-Disposition: attachment; filename='.$filename); |
|
| 46 | + header('Content-Type: text/text/tab-separated-values; charset='.get_bloginfo('charset')); |
|
| 47 | 47 | |
| 48 | 48 | // Do not cache the file. |
| 49 | - header( 'Pragma: no-cache' ); |
|
| 50 | - header( 'Expires: 0' ); |
|
| 49 | + header('Pragma: no-cache'); |
|
| 50 | + header('Expires: 0'); |
|
| 51 | 51 | |
| 52 | - $output = fopen( 'php://output', 'w' ); |
|
| 52 | + $output = fopen('php://output', 'w'); |
|
| 53 | 53 | |
| 54 | 54 | // Insert Header. |
| 55 | 55 | fputcsv( |
| 56 | 56 | $output, |
| 57 | 57 | array( |
| 58 | - __( 'Ingredient Name', 'wordlift' ), |
|
| 59 | - __( 'Recipe Name', 'wordlift' ), |
|
| 60 | - __( 'Recipe ID', 'wordlift' ), |
|
| 61 | - __( 'Post Name', 'wordlift' ), |
|
| 62 | - __( 'Post ID', 'wordlift' ), |
|
| 63 | - __( 'Post URL', 'wordlift' ), |
|
| 58 | + __('Ingredient Name', 'wordlift'), |
|
| 59 | + __('Recipe Name', 'wordlift'), |
|
| 60 | + __('Recipe ID', 'wordlift'), |
|
| 61 | + __('Post Name', 'wordlift'), |
|
| 62 | + __('Post ID', 'wordlift'), |
|
| 63 | + __('Post URL', 'wordlift'), |
|
| 64 | 64 | ), |
| 65 | 65 | "\t" |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | 68 | // Insert Data. |
| 69 | - foreach ( $items as $item ) { |
|
| 70 | - $recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 71 | - $recipe = json_decode( $recipe_json_ld, true ); |
|
| 69 | + foreach ($items as $item) { |
|
| 70 | + $recipe_json_ld = get_post_meta($item->recipe_ID, '_wl_main_ingredient_jsonld', true); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 71 | + $recipe = json_decode($recipe_json_ld, true); |
|
| 72 | 72 | fputcsv( |
| 73 | 73 | $output, |
| 74 | 74 | array( |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $item->recipe_ID, |
| 79 | 79 | $item->post_title, |
| 80 | 80 | $item->post_ID, |
| 81 | - esc_url( get_the_permalink( $item->post_ID ) ), |
|
| 81 | + esc_url(get_the_permalink($item->post_ID)), |
|
| 82 | 82 | ), |
| 83 | 83 | "\t" |
| 84 | 84 | ); |