@@ -18,50 +18,50 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Input_Element implements Wordlift_Admin_Element { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Output the HTML for an input box type settings_page |
|
| 23 | - * |
|
| 24 | - * @param array $args An array with the following keys: |
|
| 25 | - * Parameters controlling the result. |
|
| 26 | - * |
|
| 27 | - * @type string name The name attribute of the input element. Mandatory. |
|
| 28 | - * |
|
| 29 | - * @type string id The id attribute of the input element. Optional. |
|
| 30 | - * @type string id The id attribute of the input element. |
|
| 31 | - * Optional, randomly generated one is used if not supplied. |
|
| 32 | - * @type string value The value of the input element. |
|
| 33 | - * Optional, defaults to empty string. |
|
| 34 | - * @type bool readonly Indicates whether the input is read only. |
|
| 35 | - * Optional, defaults to read-write |
|
| 36 | - * @type string css_class The class attribute for the input element. |
|
| 37 | - * If empty string no class attribute will be added. |
|
| 38 | - * Optional, defaults to empty string. |
|
| 39 | - * @type string description The descriptio text to be displayed below the element. |
|
| 40 | - * Can include some HTML element. |
|
| 41 | - * If empty string no description will be displayed. |
|
| 42 | - * Optional, defaults to empty string. |
|
| 43 | - * @since 3.21.0 added the ability to use a $type arg. |
|
| 44 | - * |
|
| 45 | - * @return $this|Wordlift_Admin_Element |
|
| 46 | - */ |
|
| 47 | - public function render( $args ) { |
|
| 21 | + /** |
|
| 22 | + * Output the HTML for an input box type settings_page |
|
| 23 | + * |
|
| 24 | + * @param array $args An array with the following keys: |
|
| 25 | + * Parameters controlling the result. |
|
| 26 | + * |
|
| 27 | + * @type string name The name attribute of the input element. Mandatory. |
|
| 28 | + * |
|
| 29 | + * @type string id The id attribute of the input element. Optional. |
|
| 30 | + * @type string id The id attribute of the input element. |
|
| 31 | + * Optional, randomly generated one is used if not supplied. |
|
| 32 | + * @type string value The value of the input element. |
|
| 33 | + * Optional, defaults to empty string. |
|
| 34 | + * @type bool readonly Indicates whether the input is read only. |
|
| 35 | + * Optional, defaults to read-write |
|
| 36 | + * @type string css_class The class attribute for the input element. |
|
| 37 | + * If empty string no class attribute will be added. |
|
| 38 | + * Optional, defaults to empty string. |
|
| 39 | + * @type string description The descriptio text to be displayed below the element. |
|
| 40 | + * Can include some HTML element. |
|
| 41 | + * If empty string no description will be displayed. |
|
| 42 | + * Optional, defaults to empty string. |
|
| 43 | + * @since 3.21.0 added the ability to use a $type arg. |
|
| 44 | + * |
|
| 45 | + * @return $this|Wordlift_Admin_Element |
|
| 46 | + */ |
|
| 47 | + public function render( $args ) { |
|
| 48 | 48 | |
| 49 | - /* |
|
| 49 | + /* |
|
| 50 | 50 | * Parse the arguments and merge with default values. |
| 51 | 51 | * Name intentionally do not have a default as it has to be in SyncEvent |
| 52 | 52 | * with form handling code |
| 53 | 53 | */ |
| 54 | - $pre_params = wp_parse_args( $args, array( |
|
| 55 | - 'id' => uniqid( 'wl-input-' ), |
|
| 56 | - 'value' => '', |
|
| 57 | - 'readonly' => false, |
|
| 58 | - 'css_class' => '', |
|
| 59 | - 'description' => '', |
|
| 60 | - ) ); |
|
| 61 | - $params = apply_filters( 'wl_admin_input_element_params', $pre_params ); |
|
| 62 | - // allow different types of input - default to 'text'. |
|
| 63 | - $input_type = ! empty( $params['type'] ) ? $params['type'] : 'text'; |
|
| 64 | - ?> |
|
| 54 | + $pre_params = wp_parse_args( $args, array( |
|
| 55 | + 'id' => uniqid( 'wl-input-' ), |
|
| 56 | + 'value' => '', |
|
| 57 | + 'readonly' => false, |
|
| 58 | + 'css_class' => '', |
|
| 59 | + 'description' => '', |
|
| 60 | + ) ); |
|
| 61 | + $params = apply_filters( 'wl_admin_input_element_params', $pre_params ); |
|
| 62 | + // allow different types of input - default to 'text'. |
|
| 63 | + $input_type = ! empty( $params['type'] ) ? $params['type'] : 'text'; |
|
| 64 | + ?> |
|
| 65 | 65 | |
| 66 | 66 | <input type="<?php echo esc_attr( $input_type ); ?>" |
| 67 | 67 | id="<?php echo esc_attr( $params['id'] ); ?>" |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | <?php |
| 76 | 76 | |
| 77 | - return $this; |
|
| 78 | - } |
|
| 77 | + return $this; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | } |
@@ -44,33 +44,33 @@ |
||
| 44 | 44 | * |
| 45 | 45 | * @return $this|Wordlift_Admin_Element |
| 46 | 46 | */ |
| 47 | - public function render( $args ) { |
|
| 47 | + public function render($args) { |
|
| 48 | 48 | |
| 49 | 49 | /* |
| 50 | 50 | * Parse the arguments and merge with default values. |
| 51 | 51 | * Name intentionally do not have a default as it has to be in SyncEvent |
| 52 | 52 | * with form handling code |
| 53 | 53 | */ |
| 54 | - $pre_params = wp_parse_args( $args, array( |
|
| 55 | - 'id' => uniqid( 'wl-input-' ), |
|
| 54 | + $pre_params = wp_parse_args($args, array( |
|
| 55 | + 'id' => uniqid('wl-input-'), |
|
| 56 | 56 | 'value' => '', |
| 57 | 57 | 'readonly' => false, |
| 58 | 58 | 'css_class' => '', |
| 59 | 59 | 'description' => '', |
| 60 | - ) ); |
|
| 61 | - $params = apply_filters( 'wl_admin_input_element_params', $pre_params ); |
|
| 60 | + )); |
|
| 61 | + $params = apply_filters('wl_admin_input_element_params', $pre_params); |
|
| 62 | 62 | // allow different types of input - default to 'text'. |
| 63 | - $input_type = ! empty( $params['type'] ) ? $params['type'] : 'text'; |
|
| 63 | + $input_type = ! empty($params['type']) ? $params['type'] : 'text'; |
|
| 64 | 64 | ?> |
| 65 | 65 | |
| 66 | - <input type="<?php echo esc_attr( $input_type ); ?>" |
|
| 67 | - id="<?php echo esc_attr( $params['id'] ); ?>" |
|
| 68 | - name="<?php echo esc_attr( $params['name'] ); ?>" |
|
| 69 | - value="<?php echo esc_attr( $params['value'] ); ?>" |
|
| 70 | - <?php if ( ! empty( $params['readonly'] ) ) { ?> readonly="readonly" <?php } ?> |
|
| 71 | - <?php if ( ! empty( $params['css_class'] ) ) { ?> class="<?php echo esc_attr( $params['css_class'] ) ?>" <?php } ?> |
|
| 66 | + <input type="<?php echo esc_attr($input_type); ?>" |
|
| 67 | + id="<?php echo esc_attr($params['id']); ?>" |
|
| 68 | + name="<?php echo esc_attr($params['name']); ?>" |
|
| 69 | + value="<?php echo esc_attr($params['value']); ?>" |
|
| 70 | + <?php if ( ! empty($params['readonly'])) { ?> readonly="readonly" <?php } ?> |
|
| 71 | + <?php if ( ! empty($params['css_class'])) { ?> class="<?php echo esc_attr($params['css_class']) ?>" <?php } ?> |
|
| 72 | 72 | /> |
| 73 | - <?php if ( ! empty( $params['description'] ) ) { ?><p><?php echo wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ); ?></p><?php } ?> |
|
| 73 | + <?php if ( ! empty($params['description'])) { ?><p><?php echo wp_kses($params['description'], array('a' => array('href' => array()))); ?></p><?php } ?> |
|
| 74 | 74 | |
| 75 | 75 | <?php |
| 76 | 76 | |
@@ -18,45 +18,45 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | class Wordlift_Admin_Radio_Input_Element implements Wordlift_Admin_Element { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Output the HTML for an input box type settings_page. |
|
| 23 | - * |
|
| 24 | - * @param array $args { |
|
| 25 | - * An array of arguments. |
|
| 26 | - * |
|
| 27 | - * @type string $name The name attribute of the input element. Mandatory. |
|
| 28 | - * @type string $id The id attribute of the input element. Optional, |
|
| 29 | - * randomly generated one is used if not supplied. |
|
| 30 | - * @type string $value The value of the input element. Optional, defaults |
|
| 31 | - * to empty string. |
|
| 32 | - * @type string $css_class The class attribute for the input element. If empty |
|
| 33 | - * string no class attribute will be added. Optional, |
|
| 34 | - * defaults to empty string. |
|
| 35 | - * @type string $description The description text to be displayed below the element. |
|
| 36 | - * Can include some HTML element. If empty string no |
|
| 37 | - * description will be displayed. Optional, defaults to |
|
| 38 | - * empty string. |
|
| 39 | - * } |
|
| 40 | - * @return $this|Wordlift_Admin_Element |
|
| 41 | - * @since 3.13.0 |
|
| 42 | - * |
|
| 43 | - */ |
|
| 44 | - public function render( $args ) { |
|
| 45 | - /* |
|
| 21 | + /** |
|
| 22 | + * Output the HTML for an input box type settings_page. |
|
| 23 | + * |
|
| 24 | + * @param array $args { |
|
| 25 | + * An array of arguments. |
|
| 26 | + * |
|
| 27 | + * @type string $name The name attribute of the input element. Mandatory. |
|
| 28 | + * @type string $id The id attribute of the input element. Optional, |
|
| 29 | + * randomly generated one is used if not supplied. |
|
| 30 | + * @type string $value The value of the input element. Optional, defaults |
|
| 31 | + * to empty string. |
|
| 32 | + * @type string $css_class The class attribute for the input element. If empty |
|
| 33 | + * string no class attribute will be added. Optional, |
|
| 34 | + * defaults to empty string. |
|
| 35 | + * @type string $description The description text to be displayed below the element. |
|
| 36 | + * Can include some HTML element. If empty string no |
|
| 37 | + * description will be displayed. Optional, defaults to |
|
| 38 | + * empty string. |
|
| 39 | + * } |
|
| 40 | + * @return $this|Wordlift_Admin_Element |
|
| 41 | + * @since 3.13.0 |
|
| 42 | + * |
|
| 43 | + */ |
|
| 44 | + public function render( $args ) { |
|
| 45 | + /* |
|
| 46 | 46 | * Parse the arguments and merge with default values. |
| 47 | 47 | * Name intentionally do not have a default as it has to be in SyncEvent |
| 48 | 48 | * with form handling code |
| 49 | 49 | */ |
| 50 | - $params = wp_parse_args( $args, array( |
|
| 51 | - 'id' => uniqid( 'wl-input-' ), |
|
| 52 | - 'value' => '', |
|
| 53 | - 'css_class' => '', |
|
| 54 | - 'description' => '', |
|
| 55 | - ) ); |
|
| 50 | + $params = wp_parse_args( $args, array( |
|
| 51 | + 'id' => uniqid( 'wl-input-' ), |
|
| 52 | + 'value' => '', |
|
| 53 | + 'css_class' => '', |
|
| 54 | + 'description' => '', |
|
| 55 | + ) ); |
|
| 56 | 56 | |
| 57 | - // Set the readonly and class attributes and the description. |
|
| 58 | - $value = $params['value']; |
|
| 59 | - ?> |
|
| 57 | + // Set the readonly and class attributes and the description. |
|
| 58 | + $value = $params['value']; |
|
| 59 | + ?> |
|
| 60 | 60 | |
| 61 | 61 | <input type="radio" id="<?php echo esc_attr( $params['id'] ); ?>" |
| 62 | 62 | name="<?php echo esc_attr( $params['name'] ); ?>" |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | <p><?php echo wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ); ?></p><?php } ?> |
| 73 | 73 | <?php |
| 74 | 74 | |
| 75 | - return $this; |
|
| 76 | - } |
|
| 75 | + return $this; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | 78 | } |
@@ -41,35 +41,35 @@ |
||
| 41 | 41 | * @since 3.13.0 |
| 42 | 42 | * |
| 43 | 43 | */ |
| 44 | - public function render( $args ) { |
|
| 44 | + public function render($args) { |
|
| 45 | 45 | /* |
| 46 | 46 | * Parse the arguments and merge with default values. |
| 47 | 47 | * Name intentionally do not have a default as it has to be in SyncEvent |
| 48 | 48 | * with form handling code |
| 49 | 49 | */ |
| 50 | - $params = wp_parse_args( $args, array( |
|
| 51 | - 'id' => uniqid( 'wl-input-' ), |
|
| 50 | + $params = wp_parse_args($args, array( |
|
| 51 | + 'id' => uniqid('wl-input-'), |
|
| 52 | 52 | 'value' => '', |
| 53 | 53 | 'css_class' => '', |
| 54 | 54 | 'description' => '', |
| 55 | - ) ); |
|
| 55 | + )); |
|
| 56 | 56 | |
| 57 | 57 | // Set the readonly and class attributes and the description. |
| 58 | 58 | $value = $params['value']; |
| 59 | 59 | ?> |
| 60 | 60 | |
| 61 | - <input type="radio" id="<?php echo esc_attr( $params['id'] ); ?>" |
|
| 62 | - name="<?php echo esc_attr( $params['name'] ); ?>" |
|
| 63 | - value="yes" <?php if ( ! empty( $params['css_class'] ) ) { ?> class="<?php echo esc_attr( $params['css_class'] ) ?>" <?php } ?> |
|
| 64 | - <?php checked( $value, 'yes' ); ?> |
|
| 61 | + <input type="radio" id="<?php echo esc_attr($params['id']); ?>" |
|
| 62 | + name="<?php echo esc_attr($params['name']); ?>" |
|
| 63 | + value="yes" <?php if ( ! empty($params['css_class'])) { ?> class="<?php echo esc_attr($params['css_class']) ?>" <?php } ?> |
|
| 64 | + <?php checked($value, 'yes'); ?> |
|
| 65 | 65 | /> Yes |
| 66 | - <input type="radio" id="<?php echo esc_attr( $params['id'] ); ?>" |
|
| 67 | - name="<?php echo esc_attr( $params['name'] ); ?>" |
|
| 68 | - value="no" <?php if ( ! empty( $params['css_class'] ) ) { ?> class="<?php echo esc_attr( $params['css_class'] ) ?>" <?php } ?> |
|
| 69 | - <?php checked( $value, 'no' ); ?> |
|
| 66 | + <input type="radio" id="<?php echo esc_attr($params['id']); ?>" |
|
| 67 | + name="<?php echo esc_attr($params['name']); ?>" |
|
| 68 | + value="no" <?php if ( ! empty($params['css_class'])) { ?> class="<?php echo esc_attr($params['css_class']) ?>" <?php } ?> |
|
| 69 | + <?php checked($value, 'no'); ?> |
|
| 70 | 70 | /> No |
| 71 | - <?php if ( ! empty( $params['description'] ) ) { ?> |
|
| 72 | - <p><?php echo wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ); ?></p><?php } ?> |
|
| 71 | + <?php if ( ! empty($params['description'])) { ?> |
|
| 72 | + <p><?php echo wp_kses($params['description'], array('a' => array('href' => array()))); ?></p><?php } ?> |
|
| 73 | 73 | <?php |
| 74 | 74 | |
| 75 | 75 | return $this; |
@@ -4,73 +4,73 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Notices { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @var Plugin |
|
| 9 | - */ |
|
| 10 | - private $acf4so_plugin; |
|
| 7 | + /** |
|
| 8 | + * @var Plugin |
|
| 9 | + */ |
|
| 10 | + private $acf4so_plugin; |
|
| 11 | 11 | |
| 12 | - function __construct( Plugin $plugin ) { |
|
| 13 | - $this->acf4so_plugin = $plugin; |
|
| 14 | - } |
|
| 12 | + function __construct( Plugin $plugin ) { |
|
| 13 | + $this->acf4so_plugin = $plugin; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - public function register_hooks() { |
|
| 17 | - add_action( 'admin_notices', [ $this, 'admin_notices' ] ); |
|
| 18 | - } |
|
| 16 | + public function register_hooks() { |
|
| 17 | + add_action( 'admin_notices', [ $this, 'admin_notices' ] ); |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public function admin_notices() { |
|
| 20 | + public function admin_notices() { |
|
| 21 | 21 | |
| 22 | - $is_package_type_supported = $this->is_package_type_supported(); |
|
| 22 | + $is_package_type_supported = $this->is_package_type_supported(); |
|
| 23 | 23 | |
| 24 | - $is_woocommerce_plugin_installed = defined( 'WL_WOO_VERSION' ); |
|
| 24 | + $is_woocommerce_plugin_installed = defined( 'WL_WOO_VERSION' ); |
|
| 25 | 25 | |
| 26 | - if ( ! $is_package_type_supported && ! $is_woocommerce_plugin_installed ) { |
|
| 27 | - // Dont display notice. |
|
| 28 | - return; |
|
| 29 | - } |
|
| 26 | + if ( ! $is_package_type_supported && ! $is_woocommerce_plugin_installed ) { |
|
| 27 | + // Dont display notice. |
|
| 28 | + return; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * 1. When package type is supported and acf4so not installed or activated then the notice should appear. |
|
| 33 | - * 2. When woocommerce plugin installed and acf4so not installed or activated then the notice should appear. |
|
| 34 | - */ |
|
| 35 | - if ( ! $this->acf4so_plugin->is_plugin_installed() ) { |
|
| 36 | - $this->display_notice( |
|
| 37 | - __( "WordLift detected that <b>Advanced Custom Fields for Schema.org</b> is not installed and, you're loosing out on full Schema.org support.", 'wordlift' ), |
|
| 38 | - __( 'Reinstall & Activate', 'wordlift' ) |
|
| 39 | - ); |
|
| 31 | + /** |
|
| 32 | + * 1. When package type is supported and acf4so not installed or activated then the notice should appear. |
|
| 33 | + * 2. When woocommerce plugin installed and acf4so not installed or activated then the notice should appear. |
|
| 34 | + */ |
|
| 35 | + if ( ! $this->acf4so_plugin->is_plugin_installed() ) { |
|
| 36 | + $this->display_notice( |
|
| 37 | + __( "WordLift detected that <b>Advanced Custom Fields for Schema.org</b> is not installed and, you're loosing out on full Schema.org support.", 'wordlift' ), |
|
| 38 | + __( 'Reinstall & Activate', 'wordlift' ) |
|
| 39 | + ); |
|
| 40 | 40 | |
| 41 | - // Dont display notice. |
|
| 42 | - return; |
|
| 43 | - } |
|
| 41 | + // Dont display notice. |
|
| 42 | + return; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - if ( ! $this->acf4so_plugin->is_plugin_activated() ) { |
|
| 46 | - $this->display_notice( |
|
| 47 | - __( "WordLift detected that <b>Advanced Custom Fields for Schema.org</b> is deactivated and, you're loosing out on full Schema.org support.", 'wordlift' ), |
|
| 48 | - __( 'Reactivate', 'wordlift' ) |
|
| 49 | - ); |
|
| 45 | + if ( ! $this->acf4so_plugin->is_plugin_activated() ) { |
|
| 46 | + $this->display_notice( |
|
| 47 | + __( "WordLift detected that <b>Advanced Custom Fields for Schema.org</b> is deactivated and, you're loosing out on full Schema.org support.", 'wordlift' ), |
|
| 48 | + __( 'Reactivate', 'wordlift' ) |
|
| 49 | + ); |
|
| 50 | 50 | |
| 51 | - return; |
|
| 52 | - } |
|
| 51 | + return; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - } |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - private function display_notice( $message, $button_text ) { |
|
| 57 | + private function display_notice( $message, $button_text ) { |
|
| 58 | 58 | |
| 59 | - $kses_options = array( |
|
| 60 | - 'p' => array(), |
|
| 61 | - 'b' => array(), |
|
| 62 | - 'button' => array( 'class' => array(), 'onclick' => array() ) |
|
| 63 | - ); |
|
| 64 | - $installation_success_message = __( |
|
| 65 | - '</p>WordLift: <b>Advanced Custom Fields for Schema.org</b> plugin installed and activated.</p>', |
|
| 66 | - 'wordlift' |
|
| 67 | - ); |
|
| 59 | + $kses_options = array( |
|
| 60 | + 'p' => array(), |
|
| 61 | + 'b' => array(), |
|
| 62 | + 'button' => array( 'class' => array(), 'onclick' => array() ) |
|
| 63 | + ); |
|
| 64 | + $installation_success_message = __( |
|
| 65 | + '</p>WordLift: <b>Advanced Custom Fields for Schema.org</b> plugin installed and activated.</p>', |
|
| 66 | + 'wordlift' |
|
| 67 | + ); |
|
| 68 | 68 | |
| 69 | - $installing_message = __( 'Installing <span class="spinner is-active"></span>', 'wordlift' ); |
|
| 70 | - $installation_failed_message = __( '<p>Wordlift: Advanced Custom Fields for Schema.org</b> Installation failed, please retry or contact [email protected]</p>' . |
|
| 71 | - '<button class="button action" onclick="wordliftInstallAcf4so(this)">Retry</button>', 'wordlift' ); |
|
| 69 | + $installing_message = __( 'Installing <span class="spinner is-active"></span>', 'wordlift' ); |
|
| 70 | + $installation_failed_message = __( '<p>Wordlift: Advanced Custom Fields for Schema.org</b> Installation failed, please retry or contact [email protected]</p>' . |
|
| 71 | + '<button class="button action" onclick="wordliftInstallAcf4so(this)">Retry</button>', 'wordlift' ); |
|
| 72 | 72 | |
| 73 | - ?> |
|
| 73 | + ?> |
|
| 74 | 74 | |
| 75 | 75 | <script> |
| 76 | 76 | window.addEventListener("load", function () { |
@@ -106,14 +106,14 @@ discard block |
||
| 106 | 106 | <br/> |
| 107 | 107 | </div> |
| 108 | 108 | <?php |
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * @return bool |
|
| 113 | - */ |
|
| 114 | - private function is_package_type_supported() { |
|
| 115 | - return apply_filters( 'wl_feature__enable__entity-types-professional', false ) || |
|
| 116 | - apply_filters( 'wl_feature__enable__entity-types-business', false ); |
|
| 117 | - } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * @return bool |
|
| 113 | + */ |
|
| 114 | + private function is_package_type_supported() { |
|
| 115 | + return apply_filters( 'wl_feature__enable__entity-types-professional', false ) || |
|
| 116 | + apply_filters( 'wl_feature__enable__entity-types-business', false ); |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | \ No newline at end of file |
@@ -9,21 +9,21 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | private $acf4so_plugin; |
| 11 | 11 | |
| 12 | - function __construct( Plugin $plugin ) { |
|
| 12 | + function __construct(Plugin $plugin) { |
|
| 13 | 13 | $this->acf4so_plugin = $plugin; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function register_hooks() { |
| 17 | - add_action( 'admin_notices', [ $this, 'admin_notices' ] ); |
|
| 17 | + add_action('admin_notices', [$this, 'admin_notices']); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function admin_notices() { |
| 21 | 21 | |
| 22 | 22 | $is_package_type_supported = $this->is_package_type_supported(); |
| 23 | 23 | |
| 24 | - $is_woocommerce_plugin_installed = defined( 'WL_WOO_VERSION' ); |
|
| 24 | + $is_woocommerce_plugin_installed = defined('WL_WOO_VERSION'); |
|
| 25 | 25 | |
| 26 | - if ( ! $is_package_type_supported && ! $is_woocommerce_plugin_installed ) { |
|
| 26 | + if ( ! $is_package_type_supported && ! $is_woocommerce_plugin_installed) { |
|
| 27 | 27 | // Dont display notice. |
| 28 | 28 | return; |
| 29 | 29 | } |
@@ -32,20 +32,20 @@ discard block |
||
| 32 | 32 | * 1. When package type is supported and acf4so not installed or activated then the notice should appear. |
| 33 | 33 | * 2. When woocommerce plugin installed and acf4so not installed or activated then the notice should appear. |
| 34 | 34 | */ |
| 35 | - if ( ! $this->acf4so_plugin->is_plugin_installed() ) { |
|
| 35 | + if ( ! $this->acf4so_plugin->is_plugin_installed()) { |
|
| 36 | 36 | $this->display_notice( |
| 37 | - __( "WordLift detected that <b>Advanced Custom Fields for Schema.org</b> is not installed and, you're loosing out on full Schema.org support.", 'wordlift' ), |
|
| 38 | - __( 'Reinstall & Activate', 'wordlift' ) |
|
| 37 | + __("WordLift detected that <b>Advanced Custom Fields for Schema.org</b> is not installed and, you're loosing out on full Schema.org support.", 'wordlift'), |
|
| 38 | + __('Reinstall & Activate', 'wordlift') |
|
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | // Dont display notice. |
| 42 | 42 | return; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if ( ! $this->acf4so_plugin->is_plugin_activated() ) { |
|
| 45 | + if ( ! $this->acf4so_plugin->is_plugin_activated()) { |
|
| 46 | 46 | $this->display_notice( |
| 47 | - __( "WordLift detected that <b>Advanced Custom Fields for Schema.org</b> is deactivated and, you're loosing out on full Schema.org support.", 'wordlift' ), |
|
| 48 | - __( 'Reactivate', 'wordlift' ) |
|
| 47 | + __("WordLift detected that <b>Advanced Custom Fields for Schema.org</b> is deactivated and, you're loosing out on full Schema.org support.", 'wordlift'), |
|
| 48 | + __('Reactivate', 'wordlift') |
|
| 49 | 49 | ); |
| 50 | 50 | |
| 51 | 51 | return; |
@@ -54,21 +54,21 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
| 57 | - private function display_notice( $message, $button_text ) { |
|
| 57 | + private function display_notice($message, $button_text) { |
|
| 58 | 58 | |
| 59 | - $kses_options = array( |
|
| 59 | + $kses_options = array( |
|
| 60 | 60 | 'p' => array(), |
| 61 | 61 | 'b' => array(), |
| 62 | - 'button' => array( 'class' => array(), 'onclick' => array() ) |
|
| 62 | + 'button' => array('class' => array(), 'onclick' => array()) |
|
| 63 | 63 | ); |
| 64 | 64 | $installation_success_message = __( |
| 65 | 65 | '</p>WordLift: <b>Advanced Custom Fields for Schema.org</b> plugin installed and activated.</p>', |
| 66 | 66 | 'wordlift' |
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | - $installing_message = __( 'Installing <span class="spinner is-active"></span>', 'wordlift' ); |
|
| 70 | - $installation_failed_message = __( '<p>Wordlift: Advanced Custom Fields for Schema.org</b> Installation failed, please retry or contact [email protected]</p>' . |
|
| 71 | - '<button class="button action" onclick="wordliftInstallAcf4so(this)">Retry</button>', 'wordlift' ); |
|
| 69 | + $installing_message = __('Installing <span class="spinner is-active"></span>', 'wordlift'); |
|
| 70 | + $installation_failed_message = __('<p>Wordlift: Advanced Custom Fields for Schema.org</b> Installation failed, please retry or contact [email protected]</p>'. |
|
| 71 | + '<button class="button action" onclick="wordliftInstallAcf4so(this)">Retry</button>', 'wordlift'); |
|
| 72 | 72 | |
| 73 | 73 | ?> |
| 74 | 74 | |
@@ -77,15 +77,15 @@ discard block |
||
| 77 | 77 | const pluginInstallationNotice = document.getElementById("wordlift_acf4so_plugin_installation_notice") |
| 78 | 78 | const installPlugin = (ajaxUrl) => fetch(`${ajaxUrl}?action=wl_install_and_activate_advanced-custom-fields-for-schema-org`) |
| 79 | 79 | .then(response => response.ok ? response.json() : Promise.reject()) |
| 80 | - const ajaxUrl = "<?php echo esc_html( parse_url( admin_url( 'admin-ajax.php' ), PHP_URL_PATH ) ); ?>" |
|
| 80 | + const ajaxUrl = "<?php echo esc_html(parse_url(admin_url('admin-ajax.php'), PHP_URL_PATH)); ?>" |
|
| 81 | 81 | window.wordliftInstallAcf4so = function (installBtn) { |
| 82 | - installBtn.innerHTML = `<?php echo wp_kses( $installing_message, array( 'span' => array( 'class' => array() ) ) ) ?>` |
|
| 82 | + installBtn.innerHTML = `<?php echo wp_kses($installing_message, array('span' => array('class' => array()))) ?>` |
|
| 83 | 83 | installPlugin(ajaxUrl) |
| 84 | 84 | .catch(e => { |
| 85 | - pluginInstallationNotice.innerHTML = `<?php echo wp_kses( $installation_failed_message, $kses_options); ?>` |
|
| 85 | + pluginInstallationNotice.innerHTML = `<?php echo wp_kses($installation_failed_message, $kses_options); ?>` |
|
| 86 | 86 | }) |
| 87 | 87 | .then(() => { |
| 88 | - pluginInstallationNotice.innerHTML = `<?php echo wp_kses( $installation_success_message, $kses_options); ?>` |
|
| 88 | + pluginInstallationNotice.innerHTML = `<?php echo wp_kses($installation_success_message, $kses_options); ?>` |
|
| 89 | 89 | pluginInstallationNotice.classList.remove('notice-error') |
| 90 | 90 | pluginInstallationNotice.classList.add('notice-success') |
| 91 | 91 | }) |
@@ -97,9 +97,9 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | <div class="notice notice-error" id="wordlift_acf4so_plugin_installation_notice"> |
| 99 | 99 | <p> |
| 100 | - <?php echo wp_kses( $message, array( 'b' => array() ) ); ?> |
|
| 100 | + <?php echo wp_kses($message, array('b' => array())); ?> |
|
| 101 | 101 | <button class="button action right" onclick="wordliftInstallAcf4so(this)"> |
| 102 | - <?php esc_html_e( $button_text ); ?> |
|
| 102 | + <?php esc_html_e($button_text); ?> |
|
| 103 | 103 | |
| 104 | 104 | </button> |
| 105 | 105 | </p> |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * @return bool |
| 113 | 113 | */ |
| 114 | 114 | private function is_package_type_supported() { |
| 115 | - return apply_filters( 'wl_feature__enable__entity-types-professional', false ) || |
|
| 116 | - apply_filters( 'wl_feature__enable__entity-types-business', false ); |
|
| 115 | + return apply_filters('wl_feature__enable__entity-types-professional', false) || |
|
| 116 | + apply_filters('wl_feature__enable__entity-types-business', false); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | } |
| 120 | 120 | \ No newline at end of file |