@@ -12,55 +12,55 @@ |
||
| 12 | 12 | * @author Naveen Muthusamy <[email protected]> |
| 13 | 13 | */ |
| 14 | 14 | class Match_Terms { |
| 15 | - /** |
|
| 16 | - * @var Term_Count |
|
| 17 | - */ |
|
| 18 | - private $term_count; |
|
| 15 | + /** |
|
| 16 | + * @var Term_Count |
|
| 17 | + */ |
|
| 18 | + private $term_count; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Match_Terms constructor. |
|
| 22 | - * |
|
| 23 | - * @param $term_count Term_Count |
|
| 24 | - */ |
|
| 25 | - public function __construct( $term_count ) { |
|
| 20 | + /** |
|
| 21 | + * Match_Terms constructor. |
|
| 22 | + * |
|
| 23 | + * @param $term_count Term_Count |
|
| 24 | + */ |
|
| 25 | + public function __construct( $term_count ) { |
|
| 26 | 26 | |
| 27 | - $this->term_count = $term_count; |
|
| 28 | - add_action( 'admin_menu', array( $this, 'admin_menu', ) ); |
|
| 27 | + $this->term_count = $term_count; |
|
| 28 | + add_action( 'admin_menu', array( $this, 'admin_menu', ) ); |
|
| 29 | 29 | |
| 30 | - } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - public function admin_menu() { |
|
| 33 | - $number = $this->term_count->get_term_count(); |
|
| 34 | - add_submenu_page( |
|
| 35 | - 'wl_admin_menu', |
|
| 36 | - __( 'Match Terms', 'wordlift' ), |
|
| 37 | - __( 'Match Terms', 'wordlift' ) . " " . Badge_Generator::generate_html($number), |
|
| 38 | - 'manage_options', |
|
| 39 | - 'wl-vocabulary-match-terms', |
|
| 40 | - array( $this, 'submenu_page_callback' ) |
|
| 41 | - ); |
|
| 42 | - remove_submenu_page( 'wl_admin_menu', 'wl_admin_menu' ); |
|
| 43 | - } |
|
| 32 | + public function admin_menu() { |
|
| 33 | + $number = $this->term_count->get_term_count(); |
|
| 34 | + add_submenu_page( |
|
| 35 | + 'wl_admin_menu', |
|
| 36 | + __( 'Match Terms', 'wordlift' ), |
|
| 37 | + __( 'Match Terms', 'wordlift' ) . " " . Badge_Generator::generate_html($number), |
|
| 38 | + 'manage_options', |
|
| 39 | + 'wl-vocabulary-match-terms', |
|
| 40 | + array( $this, 'submenu_page_callback' ) |
|
| 41 | + ); |
|
| 42 | + remove_submenu_page( 'wl_admin_menu', 'wl_admin_menu' ); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - public function submenu_page_callback() { |
|
| 49 | + public function submenu_page_callback() { |
|
| 50 | 50 | |
| 51 | - Scripts_Helper::enqueue_based_on_wordpress_version( |
|
| 52 | - 'wl-vocabulary-reconcile-script', |
|
| 53 | - plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary', |
|
| 54 | - array( 'react', 'react-dom', 'wp-polyfill' ), |
|
| 55 | - true |
|
| 56 | - ); |
|
| 51 | + Scripts_Helper::enqueue_based_on_wordpress_version( |
|
| 52 | + 'wl-vocabulary-reconcile-script', |
|
| 53 | + plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary', |
|
| 54 | + array( 'react', 'react-dom', 'wp-polyfill' ), |
|
| 55 | + true |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - wp_enqueue_style( 'wl-vocabulary-reconcile-script', |
|
| 60 | - plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . "js/dist/vocabulary.full.css" ); |
|
| 61 | - wp_localize_script( 'wl-vocabulary-reconcile-script', '_wlVocabularyMatchTermsConfig', Api_Config::get_api_config() ); |
|
| 62 | - echo "<div id='wl_cmkg_reconcile_progress' class='wrap'></div>"; |
|
| 63 | - echo "<div id='wl_cmkg_table' class='wrap'></div>"; |
|
| 64 | - } |
|
| 59 | + wp_enqueue_style( 'wl-vocabulary-reconcile-script', |
|
| 60 | + plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . "js/dist/vocabulary.full.css" ); |
|
| 61 | + wp_localize_script( 'wl-vocabulary-reconcile-script', '_wlVocabularyMatchTermsConfig', Api_Config::get_api_config() ); |
|
| 62 | + echo "<div id='wl_cmkg_reconcile_progress' class='wrap'></div>"; |
|
| 63 | + echo "<div id='wl_cmkg_table' class='wrap'></div>"; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | } |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | * |
| 23 | 23 | * @param $term_count Term_Count |
| 24 | 24 | */ |
| 25 | - public function __construct( $term_count ) { |
|
| 25 | + public function __construct($term_count) { |
|
| 26 | 26 | |
| 27 | 27 | $this->term_count = $term_count; |
| 28 | - add_action( 'admin_menu', array( $this, 'admin_menu', ) ); |
|
| 28 | + add_action('admin_menu', array($this, 'admin_menu',)); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | $number = $this->term_count->get_term_count(); |
| 34 | 34 | add_submenu_page( |
| 35 | 35 | 'wl_admin_menu', |
| 36 | - __( 'Match Terms', 'wordlift' ), |
|
| 37 | - __( 'Match Terms', 'wordlift' ) . " " . Badge_Generator::generate_html($number), |
|
| 36 | + __('Match Terms', 'wordlift'), |
|
| 37 | + __('Match Terms', 'wordlift')." ".Badge_Generator::generate_html($number), |
|
| 38 | 38 | 'manage_options', |
| 39 | 39 | 'wl-vocabulary-match-terms', |
| 40 | - array( $this, 'submenu_page_callback' ) |
|
| 40 | + array($this, 'submenu_page_callback') |
|
| 41 | 41 | ); |
| 42 | - remove_submenu_page( 'wl_admin_menu', 'wl_admin_menu' ); |
|
| 42 | + remove_submenu_page('wl_admin_menu', 'wl_admin_menu'); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -50,15 +50,15 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | Scripts_Helper::enqueue_based_on_wordpress_version( |
| 52 | 52 | 'wl-vocabulary-reconcile-script', |
| 53 | - plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . 'js/dist/vocabulary', |
|
| 54 | - array( 'react', 'react-dom', 'wp-polyfill' ), |
|
| 53 | + plugin_dir_url(dirname(dirname(__DIR__))).'js/dist/vocabulary', |
|
| 54 | + array('react', 'react-dom', 'wp-polyfill'), |
|
| 55 | 55 | true |
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | 58 | |
| 59 | - wp_enqueue_style( 'wl-vocabulary-reconcile-script', |
|
| 60 | - plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . "js/dist/vocabulary.full.css" ); |
|
| 61 | - wp_localize_script( 'wl-vocabulary-reconcile-script', '_wlVocabularyMatchTermsConfig', Api_Config::get_api_config() ); |
|
| 59 | + wp_enqueue_style('wl-vocabulary-reconcile-script', |
|
| 60 | + plugin_dir_url(dirname(dirname(__DIR__)))."js/dist/vocabulary.full.css"); |
|
| 61 | + wp_localize_script('wl-vocabulary-reconcile-script', '_wlVocabularyMatchTermsConfig', Api_Config::get_api_config()); |
|
| 62 | 62 | echo "<div id='wl_cmkg_reconcile_progress' class='wrap'></div>"; |
| 63 | 63 | echo "<div id='wl_cmkg_table' class='wrap'></div>"; |
| 64 | 64 | } |
@@ -8,81 +8,81 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Shipping_Zones { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var Shipping_Zone[] |
|
| 13 | - */ |
|
| 14 | - private $zones; |
|
| 11 | + /** |
|
| 12 | + * @var Shipping_Zone[] |
|
| 13 | + */ |
|
| 14 | + private $zones; |
|
| 15 | 15 | |
| 16 | - public function __construct() { |
|
| 17 | - $this->zones = array(); |
|
| 18 | - } |
|
| 16 | + public function __construct() { |
|
| 17 | + $this->zones = array(); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - private function load_zones() { |
|
| 20 | + private function load_zones() { |
|
| 21 | 21 | |
| 22 | - $zone_ids = array_keys( WC_Shipping_Zones::get_zones() ); |
|
| 23 | - $wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) ); |
|
| 24 | - foreach ( $zone_ids as $zone_id ) { |
|
| 25 | - $wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id ); |
|
| 26 | - } |
|
| 22 | + $zone_ids = array_keys( WC_Shipping_Zones::get_zones() ); |
|
| 23 | + $wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) ); |
|
| 24 | + foreach ( $zone_ids as $zone_id ) { |
|
| 25 | + $wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id ); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - $zones = array(); |
|
| 29 | - foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 30 | - $country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() ); |
|
| 28 | + $zones = array(); |
|
| 29 | + foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 30 | + $country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() ); |
|
| 31 | 31 | |
| 32 | - if ( empty( $country_codes ) ) { |
|
| 33 | - $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone ); |
|
| 34 | - } else { |
|
| 35 | - foreach ( $country_codes as $country_code ) { |
|
| 36 | - $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code ); |
|
| 37 | - } |
|
| 38 | - } |
|
| 39 | - } |
|
| 32 | + if ( empty( $country_codes ) ) { |
|
| 33 | + $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone ); |
|
| 34 | + } else { |
|
| 35 | + foreach ( $country_codes as $country_code ) { |
|
| 36 | + $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code ); |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $this->zones = $zones; |
|
| 41 | + $this->zones = $zones; |
|
| 42 | 42 | |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 45 | + public function add_available_delivery_method( &$jsonld ) { |
|
| 46 | 46 | |
| 47 | - $this->load_zones(); |
|
| 47 | + $this->load_zones(); |
|
| 48 | 48 | |
| 49 | - foreach ( $this->zones as $zone ) { |
|
| 50 | - $zone->add_available_delivery_method( $jsonld ); |
|
| 51 | - } |
|
| 49 | + foreach ( $this->zones as $zone ) { |
|
| 50 | + $zone->add_available_delivery_method( $jsonld ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @param array $jsonld |
|
| 57 | - * @param Product $product |
|
| 58 | - */ |
|
| 59 | - public function add_offer_shipping_details( &$jsonld, $product ) { |
|
| 55 | + /** |
|
| 56 | + * @param array $jsonld |
|
| 57 | + * @param Product $product |
|
| 58 | + */ |
|
| 59 | + public function add_offer_shipping_details( &$jsonld, $product ) { |
|
| 60 | 60 | |
| 61 | - $this->load_zones(); |
|
| 61 | + $this->load_zones(); |
|
| 62 | 62 | |
| 63 | - foreach ( $this->zones as $zone ) { |
|
| 64 | - $zone->add_offer_shipping_details( $jsonld, $product ); |
|
| 65 | - } |
|
| 63 | + foreach ( $this->zones as $zone ) { |
|
| 64 | + $zone->add_offer_shipping_details( $jsonld, $product ); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - private function get_country_codes( $wc_shipping_zones ) { |
|
| 70 | - $countries = array(); |
|
| 69 | + private function get_country_codes( $wc_shipping_zones ) { |
|
| 70 | + $countries = array(); |
|
| 71 | 71 | |
| 72 | - foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 73 | - if ( ! isset( $wc_shipping_zone->type ) |
|
| 74 | - || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) { |
|
| 75 | - continue; |
|
| 76 | - } |
|
| 72 | + foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 73 | + if ( ! isset( $wc_shipping_zone->type ) |
|
| 74 | + || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) { |
|
| 75 | + continue; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $country = substr( $wc_shipping_zone->code, 0, 2 ); |
|
| 78 | + $country = substr( $wc_shipping_zone->code, 0, 2 ); |
|
| 79 | 79 | |
| 80 | - if ( ! in_array( $country, $countries ) ) { |
|
| 81 | - $countries[] = $country; |
|
| 82 | - } |
|
| 83 | - } |
|
| 80 | + if ( ! in_array( $country, $countries ) ) { |
|
| 81 | + $countries[] = $country; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - return $countries; |
|
| 86 | - } |
|
| 85 | + return $countries; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | } |
@@ -19,21 +19,21 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | private function load_zones() { |
| 21 | 21 | |
| 22 | - $zone_ids = array_keys( WC_Shipping_Zones::get_zones() ); |
|
| 23 | - $wc_shipping_zones = array( WC_Shipping_Zones::get_zone( 0 ) ); |
|
| 24 | - foreach ( $zone_ids as $zone_id ) { |
|
| 25 | - $wc_shipping_zones[] = WC_Shipping_Zones::get_zone( $zone_id ); |
|
| 22 | + $zone_ids = array_keys(WC_Shipping_Zones::get_zones()); |
|
| 23 | + $wc_shipping_zones = array(WC_Shipping_Zones::get_zone(0)); |
|
| 24 | + foreach ($zone_ids as $zone_id) { |
|
| 25 | + $wc_shipping_zones[] = WC_Shipping_Zones::get_zone($zone_id); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | $zones = array(); |
| 29 | - foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 30 | - $country_codes = $this->get_country_codes( $wc_shipping_zone->get_zone_locations() ); |
|
| 29 | + foreach ($wc_shipping_zones as $wc_shipping_zone) { |
|
| 30 | + $country_codes = $this->get_country_codes($wc_shipping_zone->get_zone_locations()); |
|
| 31 | 31 | |
| 32 | - if ( empty( $country_codes ) ) { |
|
| 33 | - $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone ); |
|
| 32 | + if (empty($country_codes)) { |
|
| 33 | + $zones[] = Shipping_Zone::from_wc_shipping_zone($wc_shipping_zone); |
|
| 34 | 34 | } else { |
| 35 | - foreach ( $country_codes as $country_code ) { |
|
| 36 | - $zones[] = Shipping_Zone::from_wc_shipping_zone( $wc_shipping_zone, $country_code ); |
|
| 35 | + foreach ($country_codes as $country_code) { |
|
| 36 | + $zones[] = Shipping_Zone::from_wc_shipping_zone($wc_shipping_zone, $country_code); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -42,12 +42,12 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function add_available_delivery_method( &$jsonld ) { |
|
| 45 | + public function add_available_delivery_method(&$jsonld) { |
|
| 46 | 46 | |
| 47 | 47 | $this->load_zones(); |
| 48 | 48 | |
| 49 | - foreach ( $this->zones as $zone ) { |
|
| 50 | - $zone->add_available_delivery_method( $jsonld ); |
|
| 49 | + foreach ($this->zones as $zone) { |
|
| 50 | + $zone->add_available_delivery_method($jsonld); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
@@ -56,28 +56,28 @@ discard block |
||
| 56 | 56 | * @param array $jsonld |
| 57 | 57 | * @param Product $product |
| 58 | 58 | */ |
| 59 | - public function add_offer_shipping_details( &$jsonld, $product ) { |
|
| 59 | + public function add_offer_shipping_details(&$jsonld, $product) { |
|
| 60 | 60 | |
| 61 | 61 | $this->load_zones(); |
| 62 | 62 | |
| 63 | - foreach ( $this->zones as $zone ) { |
|
| 64 | - $zone->add_offer_shipping_details( $jsonld, $product ); |
|
| 63 | + foreach ($this->zones as $zone) { |
|
| 64 | + $zone->add_offer_shipping_details($jsonld, $product); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - private function get_country_codes( $wc_shipping_zones ) { |
|
| 69 | + private function get_country_codes($wc_shipping_zones) { |
|
| 70 | 70 | $countries = array(); |
| 71 | 71 | |
| 72 | - foreach ( $wc_shipping_zones as $wc_shipping_zone ) { |
|
| 73 | - if ( ! isset( $wc_shipping_zone->type ) |
|
| 74 | - || ( 'country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type ) ) { |
|
| 72 | + foreach ($wc_shipping_zones as $wc_shipping_zone) { |
|
| 73 | + if ( ! isset($wc_shipping_zone->type) |
|
| 74 | + || ('country' !== $wc_shipping_zone->type && 'state' !== $wc_shipping_zone->type)) { |
|
| 75 | 75 | continue; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $country = substr( $wc_shipping_zone->code, 0, 2 ); |
|
| 78 | + $country = substr($wc_shipping_zone->code, 0, 2); |
|
| 79 | 79 | |
| 80 | - if ( ! in_array( $country, $countries ) ) { |
|
| 80 | + if ( ! in_array($country, $countries)) { |
|
| 81 | 81 | $countries[] = $country; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -4,43 +4,43 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Offer_Structured_Data { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @var Shipping_Zones |
|
| 9 | - */ |
|
| 10 | - private $shipping_zones; |
|
| 7 | + /** |
|
| 8 | + * @var Shipping_Zones |
|
| 9 | + */ |
|
| 10 | + private $shipping_zones; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Offer_Structured_Data constructor. |
|
| 14 | - * |
|
| 15 | - * @param Shipping_Zones $shipping_zones |
|
| 16 | - */ |
|
| 17 | - public function __construct( $shipping_zones ) { |
|
| 12 | + /** |
|
| 13 | + * Offer_Structured_Data constructor. |
|
| 14 | + * |
|
| 15 | + * @param Shipping_Zones $shipping_zones |
|
| 16 | + */ |
|
| 17 | + public function __construct( $shipping_zones ) { |
|
| 18 | 18 | |
| 19 | - $this->shipping_zones = $shipping_zones; |
|
| 19 | + $this->shipping_zones = $shipping_zones; |
|
| 20 | 20 | |
| 21 | - add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 ); |
|
| 21 | + add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 ); |
|
| 22 | 22 | |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function entity_jsonld( $jsonld, $post_id ) { |
|
| 25 | + public function entity_jsonld( $jsonld, $post_id ) { |
|
| 26 | 26 | |
| 27 | - // Bail out if it's not a Product or the offers property isn't set. |
|
| 28 | - if ( ! in_array( 'Product', (array) $jsonld['@type'] ) || ! isset( $jsonld['offers'] ) ) { |
|
| 29 | - return $jsonld; |
|
| 30 | - } |
|
| 27 | + // Bail out if it's not a Product or the offers property isn't set. |
|
| 28 | + if ( ! in_array( 'Product', (array) $jsonld['@type'] ) || ! isset( $jsonld['offers'] ) ) { |
|
| 29 | + return $jsonld; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) { |
|
| 33 | - $jsonld['offers'] = array( $jsonld['offers'] ); |
|
| 34 | - } |
|
| 32 | + if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) { |
|
| 33 | + $jsonld['offers'] = array( $jsonld['offers'] ); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $product = new Product( $post_id ); |
|
| 36 | + $product = new Product( $post_id ); |
|
| 37 | 37 | |
| 38 | - foreach ( $jsonld['offers'] as &$offer ) { |
|
| 39 | - $this->shipping_zones->add_available_delivery_method( $offer ); |
|
| 40 | - $this->shipping_zones->add_offer_shipping_details( $offer, $product ); |
|
| 41 | - } |
|
| 38 | + foreach ( $jsonld['offers'] as &$offer ) { |
|
| 39 | + $this->shipping_zones->add_available_delivery_method( $offer ); |
|
| 40 | + $this->shipping_zones->add_offer_shipping_details( $offer, $product ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - return $jsonld; |
|
| 44 | - } |
|
| 43 | + return $jsonld; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | } |
@@ -14,30 +14,30 @@ |
||
| 14 | 14 | * |
| 15 | 15 | * @param Shipping_Zones $shipping_zones |
| 16 | 16 | */ |
| 17 | - public function __construct( $shipping_zones ) { |
|
| 17 | + public function __construct($shipping_zones) { |
|
| 18 | 18 | |
| 19 | 19 | $this->shipping_zones = $shipping_zones; |
| 20 | 20 | |
| 21 | - add_filter( 'wl_entity_jsonld', array( $this, 'entity_jsonld' ), 10, 2 ); |
|
| 21 | + add_filter('wl_entity_jsonld', array($this, 'entity_jsonld'), 10, 2); |
|
| 22 | 22 | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function entity_jsonld( $jsonld, $post_id ) { |
|
| 25 | + public function entity_jsonld($jsonld, $post_id) { |
|
| 26 | 26 | |
| 27 | 27 | // Bail out if it's not a Product or the offers property isn't set. |
| 28 | - if ( ! in_array( 'Product', (array) $jsonld['@type'] ) || ! isset( $jsonld['offers'] ) ) { |
|
| 28 | + if ( ! in_array('Product', (array) $jsonld['@type']) || ! isset($jsonld['offers'])) { |
|
| 29 | 29 | return $jsonld; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - if ( ! is_array( $jsonld['offers'] ) || ! is_numeric( key( $jsonld['offers'] ) ) ) { |
|
| 33 | - $jsonld['offers'] = array( $jsonld['offers'] ); |
|
| 32 | + if ( ! is_array($jsonld['offers']) || ! is_numeric(key($jsonld['offers']))) { |
|
| 33 | + $jsonld['offers'] = array($jsonld['offers']); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $product = new Product( $post_id ); |
|
| 36 | + $product = new Product($post_id); |
|
| 37 | 37 | |
| 38 | - foreach ( $jsonld['offers'] as &$offer ) { |
|
| 39 | - $this->shipping_zones->add_available_delivery_method( $offer ); |
|
| 40 | - $this->shipping_zones->add_offer_shipping_details( $offer, $product ); |
|
| 38 | + foreach ($jsonld['offers'] as &$offer) { |
|
| 39 | + $this->shipping_zones->add_available_delivery_method($offer); |
|
| 40 | + $this->shipping_zones->add_offer_shipping_details($offer, $product); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | return $jsonld; |
@@ -4,59 +4,59 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Product { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @var false|\WC_Product|null |
|
| 9 | - */ |
|
| 10 | - private $wc_product; |
|
| 7 | + /** |
|
| 8 | + * @var false|\WC_Product|null |
|
| 9 | + */ |
|
| 10 | + private $wc_product; |
|
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * Product constructor. |
|
| 14 | - * |
|
| 15 | - * @param $post_id |
|
| 16 | - */ |
|
| 17 | - public function __construct( $post_id ) { |
|
| 12 | + /** |
|
| 13 | + * Product constructor. |
|
| 14 | + * |
|
| 15 | + * @param $post_id |
|
| 16 | + */ |
|
| 17 | + public function __construct( $post_id ) { |
|
| 18 | 18 | |
| 19 | - $this->wc_product = wc_get_product( $post_id ); |
|
| 19 | + $this->wc_product = wc_get_product( $post_id ); |
|
| 20 | 20 | |
| 21 | - } |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public function add_handling_time( &$shipping_delivery_time ) { |
|
| 23 | + public function add_handling_time( &$shipping_delivery_time ) { |
|
| 24 | 24 | |
| 25 | - // Bail out if there's no product. |
|
| 26 | - if ( empty( $this->wc_product ) ) { |
|
| 27 | - return; |
|
| 28 | - } |
|
| 25 | + // Bail out if there's no product. |
|
| 26 | + if ( empty( $this->wc_product ) ) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - $shipping_class_id = $this->wc_product->get_shipping_class_id(); |
|
| 30 | + $shipping_class_id = $this->wc_product->get_shipping_class_id(); |
|
| 31 | 31 | |
| 32 | - $option = get_option( 'wpsso_options' ); |
|
| 32 | + $option = get_option( 'wpsso_options' ); |
|
| 33 | 33 | |
| 34 | - if ( empty( $option["wcsdt_handling_c{$shipping_class_id}_unit_code"] ) |
|
| 35 | - || empty( $option["wcsdt_handling_c{$shipping_class_id}_minimum"] ) |
|
| 36 | - || empty( $option["wcsdt_handling_c{$shipping_class_id}_maximum"] ) ) { |
|
| 37 | - return; |
|
| 38 | - } |
|
| 34 | + if ( empty( $option["wcsdt_handling_c{$shipping_class_id}_unit_code"] ) |
|
| 35 | + || empty( $option["wcsdt_handling_c{$shipping_class_id}_minimum"] ) |
|
| 36 | + || empty( $option["wcsdt_handling_c{$shipping_class_id}_maximum"] ) ) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $unit_code = $option["wcsdt_handling_c{$shipping_class_id}_unit_code"]; |
|
| 41 | - $minimum = $option["wcsdt_handling_c{$shipping_class_id}_minimum"]; |
|
| 42 | - $maximum = $option["wcsdt_handling_c{$shipping_class_id}_maximum"]; |
|
| 40 | + $unit_code = $option["wcsdt_handling_c{$shipping_class_id}_unit_code"]; |
|
| 41 | + $minimum = $option["wcsdt_handling_c{$shipping_class_id}_minimum"]; |
|
| 42 | + $maximum = $option["wcsdt_handling_c{$shipping_class_id}_maximum"]; |
|
| 43 | 43 | |
| 44 | - if ( 'HUR' === $unit_code ) { |
|
| 45 | - $minimum = floor( $minimum / 24.0 ); |
|
| 46 | - $maximum = ceil( $maximum / 24.0 ); |
|
| 47 | - } |
|
| 44 | + if ( 'HUR' === $unit_code ) { |
|
| 45 | + $minimum = floor( $minimum / 24.0 ); |
|
| 46 | + $maximum = ceil( $maximum / 24.0 ); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $shipping_delivery_time['handlingTime'] = array( |
|
| 50 | - '@type' => 'QuantitativeValue', |
|
| 51 | - 'minValue' => $minimum, |
|
| 52 | - 'maxValue' => $maximum, |
|
| 53 | - ); |
|
| 49 | + $shipping_delivery_time['handlingTime'] = array( |
|
| 50 | + '@type' => 'QuantitativeValue', |
|
| 51 | + 'minValue' => $minimum, |
|
| 52 | + 'maxValue' => $maximum, |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - private function get_handling_time() { |
|
| 57 | + private function get_handling_time() { |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | } |
@@ -14,26 +14,26 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @param $post_id |
| 16 | 16 | */ |
| 17 | - public function __construct( $post_id ) { |
|
| 17 | + public function __construct($post_id) { |
|
| 18 | 18 | |
| 19 | - $this->wc_product = wc_get_product( $post_id ); |
|
| 19 | + $this->wc_product = wc_get_product($post_id); |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function add_handling_time( &$shipping_delivery_time ) { |
|
| 23 | + public function add_handling_time(&$shipping_delivery_time) { |
|
| 24 | 24 | |
| 25 | 25 | // Bail out if there's no product. |
| 26 | - if ( empty( $this->wc_product ) ) { |
|
| 26 | + if (empty($this->wc_product)) { |
|
| 27 | 27 | return; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | $shipping_class_id = $this->wc_product->get_shipping_class_id(); |
| 31 | 31 | |
| 32 | - $option = get_option( 'wpsso_options' ); |
|
| 32 | + $option = get_option('wpsso_options'); |
|
| 33 | 33 | |
| 34 | - if ( empty( $option["wcsdt_handling_c{$shipping_class_id}_unit_code"] ) |
|
| 35 | - || empty( $option["wcsdt_handling_c{$shipping_class_id}_minimum"] ) |
|
| 36 | - || empty( $option["wcsdt_handling_c{$shipping_class_id}_maximum"] ) ) { |
|
| 34 | + if (empty($option["wcsdt_handling_c{$shipping_class_id}_unit_code"]) |
|
| 35 | + || empty($option["wcsdt_handling_c{$shipping_class_id}_minimum"]) |
|
| 36 | + || empty($option["wcsdt_handling_c{$shipping_class_id}_maximum"])) { |
|
| 37 | 37 | return; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | $minimum = $option["wcsdt_handling_c{$shipping_class_id}_minimum"]; |
| 42 | 42 | $maximum = $option["wcsdt_handling_c{$shipping_class_id}_maximum"]; |
| 43 | 43 | |
| 44 | - if ( 'HUR' === $unit_code ) { |
|
| 45 | - $minimum = floor( $minimum / 24.0 ); |
|
| 46 | - $maximum = ceil( $maximum / 24.0 ); |
|
| 44 | + if ('HUR' === $unit_code) { |
|
| 45 | + $minimum = floor($minimum / 24.0); |
|
| 46 | + $maximum = ceil($maximum / 24.0); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $shipping_delivery_time['handlingTime'] = array( |
@@ -9,11 +9,11 @@ |
||
| 9 | 9 | || ! class_exists( '\WC_Shipping_Method' ) |
| 10 | 10 | || ! function_exists( 'get_woocommerce_currency' ) |
| 11 | 11 | || ! function_exists( 'wc_get_product' ) ) { |
| 12 | - return; |
|
| 12 | + return; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | if ( ! apply_filters( 'wl_feature__enable__shipping-sd', false ) ) { |
| 16 | - return; |
|
| 16 | + return; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | $shipping_zones = new Shipping_Zones(); |
@@ -4,17 +4,17 @@ |
||
| 4 | 4 | use Wordlift\Shipping_Data\Offer_Structured_Data; |
| 5 | 5 | use Wordlift\Shipping_Data\Shipping_Zones; |
| 6 | 6 | |
| 7 | -if ( ! class_exists( '\WC_Shipping_Zones' ) |
|
| 8 | - || ! class_exists( '\WC_Shipping_Zone' ) |
|
| 9 | - || ! class_exists( '\WC_Shipping_Method' ) |
|
| 10 | - || ! function_exists( 'get_woocommerce_currency' ) |
|
| 11 | - || ! function_exists( 'wc_get_product' ) ) { |
|
| 7 | +if ( ! class_exists('\WC_Shipping_Zones') |
|
| 8 | + || ! class_exists('\WC_Shipping_Zone') |
|
| 9 | + || ! class_exists('\WC_Shipping_Method') |
|
| 10 | + || ! function_exists('get_woocommerce_currency') |
|
| 11 | + || ! function_exists('wc_get_product')) { |
|
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | -if ( ! apply_filters( 'wl_feature__enable__shipping-sd', false ) ) { |
|
| 15 | +if ( ! apply_filters('wl_feature__enable__shipping-sd', false)) { |
|
| 16 | 16 | return; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | $shipping_zones = new Shipping_Zones(); |
| 20 | -$offer_structured_data = new Offer_Structured_Data( $shipping_zones ); |
|
| 20 | +$offer_structured_data = new Offer_Structured_Data($shipping_zones); |
|
@@ -4,18 +4,18 @@ |
||
| 4 | 4 | |
| 5 | 5 | abstract class Singleton { |
| 6 | 6 | |
| 7 | - static $instances = array(); |
|
| 7 | + static $instances = array(); |
|
| 8 | 8 | |
| 9 | - protected function __construct() { |
|
| 10 | - } |
|
| 9 | + protected function __construct() { |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public static function get_instance() { |
|
| 13 | - $child_class_name = get_called_class(); |
|
| 14 | - if ( ! array_key_exists( $child_class_name, self::$instances ) ) { |
|
| 15 | - self::$instances[ $child_class_name ] = new $child_class_name(); |
|
| 16 | - } |
|
| 12 | + public static function get_instance() { |
|
| 13 | + $child_class_name = get_called_class(); |
|
| 14 | + if ( ! array_key_exists( $child_class_name, self::$instances ) ) { |
|
| 15 | + self::$instances[ $child_class_name ] = new $child_class_name(); |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - return self::$instances[ $child_class_name ]; |
|
| 19 | - } |
|
| 18 | + return self::$instances[ $child_class_name ]; |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | } |
@@ -11,11 +11,11 @@ |
||
| 11 | 11 | |
| 12 | 12 | public static function get_instance() { |
| 13 | 13 | $child_class_name = get_called_class(); |
| 14 | - if ( ! array_key_exists( $child_class_name, self::$instances ) ) { |
|
| 15 | - self::$instances[ $child_class_name ] = new $child_class_name(); |
|
| 14 | + if ( ! array_key_exists($child_class_name, self::$instances)) { |
|
| 15 | + self::$instances[$child_class_name] = new $child_class_name(); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - return self::$instances[ $child_class_name ]; |
|
| 18 | + return self::$instances[$child_class_name]; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | $this->features_registry->register_feature_from_slug( |
| 44 | 44 | $this->get_feature_slug(), |
| 45 | 45 | $this->get_feature_default_value(), |
| 46 | - array( $this, 'init_all_dependencies' ) |
|
| 46 | + array($this, 'init_all_dependencies') |
|
| 47 | 47 | ); |
| 48 | 48 | |
| 49 | 49 | } |
@@ -10,42 +10,42 @@ |
||
| 10 | 10 | use Wordlift\Features\Features_Registry; |
| 11 | 11 | |
| 12 | 12 | abstract class Default_Loader implements Loader { |
| 13 | - /** |
|
| 14 | - * @var Features_Registry |
|
| 15 | - */ |
|
| 16 | - private $features_registry; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * Default_Loader constructor. |
|
| 20 | - */ |
|
| 21 | - public function __construct() { |
|
| 22 | - $this->features_registry = Features_Registry::get_instance(); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Initialize all the dependencies needed by the feature inside this method. |
|
| 27 | - * @return void |
|
| 28 | - */ |
|
| 29 | - public abstract function init_all_dependencies(); |
|
| 30 | - |
|
| 31 | - protected abstract function get_feature_slug(); |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return bool true if the feature wants to be enabled by default |
|
| 35 | - */ |
|
| 36 | - protected abstract function get_feature_default_value(); |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Register feature to registry. |
|
| 40 | - */ |
|
| 41 | - public function init_feature() { |
|
| 42 | - $this->features_registry->register_feature_from_slug( |
|
| 43 | - $this->get_feature_slug(), |
|
| 44 | - $this->get_feature_default_value(), |
|
| 45 | - array( $this, 'init_all_dependencies' ) |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - } |
|
| 13 | + /** |
|
| 14 | + * @var Features_Registry |
|
| 15 | + */ |
|
| 16 | + private $features_registry; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * Default_Loader constructor. |
|
| 20 | + */ |
|
| 21 | + public function __construct() { |
|
| 22 | + $this->features_registry = Features_Registry::get_instance(); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Initialize all the dependencies needed by the feature inside this method. |
|
| 27 | + * @return void |
|
| 28 | + */ |
|
| 29 | + public abstract function init_all_dependencies(); |
|
| 30 | + |
|
| 31 | + protected abstract function get_feature_slug(); |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return bool true if the feature wants to be enabled by default |
|
| 35 | + */ |
|
| 36 | + protected abstract function get_feature_default_value(); |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Register feature to registry. |
|
| 40 | + */ |
|
| 41 | + public function init_feature() { |
|
| 42 | + $this->features_registry->register_feature_from_slug( |
|
| 43 | + $this->get_feature_slug(), |
|
| 44 | + $this->get_feature_default_value(), |
|
| 45 | + array( $this, 'init_all_dependencies' ) |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | \ No newline at end of file |
@@ -8,10 +8,10 @@ |
||
| 8 | 8 | |
| 9 | 9 | interface Loader { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * The loader should register the feature to feature registry. |
|
| 13 | - * @return void |
|
| 14 | - */ |
|
| 15 | - public function init_feature(); |
|
| 11 | + /** |
|
| 12 | + * The loader should register the feature to feature registry. |
|
| 13 | + * @return void |
|
| 14 | + */ |
|
| 15 | + public function init_feature(); |
|
| 16 | 16 | |
| 17 | 17 | } |
@@ -7,16 +7,16 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Settings_Tab { |
| 9 | 9 | |
| 10 | - public function init() { |
|
| 10 | + public function init() { |
|
| 11 | 11 | |
| 12 | - add_filter( 'wl_admin_page_tabs', function ( $tabs ) { |
|
| 13 | - $tabs[] = array( |
|
| 14 | - 'slug' => 'videoobject-settings', |
|
| 15 | - 'title' => __( 'Video Settings', 'wordlift' ) |
|
| 16 | - ); |
|
| 17 | - return $tabs; |
|
| 18 | - } ); |
|
| 12 | + add_filter( 'wl_admin_page_tabs', function ( $tabs ) { |
|
| 13 | + $tabs[] = array( |
|
| 14 | + 'slug' => 'videoobject-settings', |
|
| 15 | + 'title' => __( 'Video Settings', 'wordlift' ) |
|
| 16 | + ); |
|
| 17 | + return $tabs; |
|
| 18 | + } ); |
|
| 19 | 19 | |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | 22 | } |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | |
| 10 | 10 | public function init() { |
| 11 | 11 | |
| 12 | - add_filter( 'wl_admin_page_tabs', function ( $tabs ) { |
|
| 12 | + add_filter('wl_admin_page_tabs', function($tabs) { |
|
| 13 | 13 | $tabs[] = array( |
| 14 | 14 | 'slug' => 'videoobject-settings', |
| 15 | - 'title' => __( 'Video Settings', 'wordlift' ) |
|
| 15 | + 'title' => __('Video Settings', 'wordlift') |
|
| 16 | 16 | ); |
| 17 | 17 | return $tabs; |
| 18 | 18 | } ); |