@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -28,126 +28,126 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | class Wordlift_Admin_Setup { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 33 | - * |
|
| 34 | - * @since 3.9.0 |
|
| 35 | - * @access private |
|
| 36 | - * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 37 | - */ |
|
| 38 | - private $key_validation_service; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * A {@link Wordlift_Entity_Service} instance. |
|
| 42 | - * |
|
| 43 | - * @since 3.9.0 |
|
| 44 | - * @access private |
|
| 45 | - * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 46 | - */ |
|
| 47 | - private $entity_service; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 51 | - * |
|
| 52 | - * @since 3.20.0 |
|
| 53 | - * @access private |
|
| 54 | - * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 55 | - */ |
|
| 56 | - private $language_select_element; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 60 | - * |
|
| 61 | - * @since 3.20.0 |
|
| 62 | - * @access private |
|
| 63 | - * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 64 | - */ |
|
| 65 | - private $country_select_element; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Initialize the class and set its properties. |
|
| 69 | - * |
|
| 70 | - * @param \Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 71 | - * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 72 | - * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 73 | - * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 74 | - * |
|
| 75 | - * @since 3.9.0 |
|
| 76 | - */ |
|
| 77 | - public function __construct( $key_validation_service, $entity_service, $language_select_element, $country_select_element ) { |
|
| 78 | - |
|
| 79 | - // Set a reference to the key validation service. |
|
| 80 | - $this->key_validation_service = $key_validation_service; |
|
| 81 | - |
|
| 82 | - // Set a reference to the entity service. |
|
| 83 | - $this->entity_service = $entity_service; |
|
| 84 | - |
|
| 85 | - // Set a reference to the UI elements language and country. |
|
| 86 | - $this->language_select_element = $language_select_element; |
|
| 87 | - $this->country_select_element = $country_select_element; |
|
| 88 | - |
|
| 89 | - // Hook to some WP's events: |
|
| 90 | - // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
|
| 91 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 92 | - |
|
| 93 | - // Hook to `admin_menu` in order to add our own setup wizard page. |
|
| 94 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 95 | - |
|
| 96 | - // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
|
| 97 | - add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Filter: wl_feature__enable__notices. |
|
| 101 | - * |
|
| 102 | - * @param bool whether the notices needs to be enabled or not. |
|
| 103 | - * |
|
| 104 | - * @return bool |
|
| 105 | - * @since 3.27.6 |
|
| 106 | - */ |
|
| 107 | - if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 108 | - // Hook to `admin_notices` to display our notices. |
|
| 109 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set. |
|
| 115 | - * |
|
| 116 | - * @since 3.9.0 |
|
| 117 | - */ |
|
| 118 | - public function admin_init() { |
|
| 119 | - |
|
| 120 | - // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
|
| 121 | - if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 122 | - delete_transient( '_wl_activation_redirect' ); |
|
| 123 | - |
|
| 124 | - // If the user asked to skip the wizard then comply. |
|
| 125 | - if ( Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { |
|
| 126 | - return; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - // If we're already on the page or the user doesn't have permissions, return. |
|
| 130 | - if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 131 | - return; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - // Finally redirect to the setup page. |
|
| 135 | - wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 136 | - |
|
| 137 | - exit; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Generate an admin notice suggesting to start the wizard if there is no configuration. |
|
| 144 | - * |
|
| 145 | - * @since 3.9.0 |
|
| 146 | - */ |
|
| 147 | - public function admin_notices() { |
|
| 148 | - |
|
| 149 | - // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
|
| 150 | - if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() && ! Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { ?> |
|
| 31 | + /** |
|
| 32 | + * A {@link Wordlift_Key_Validation_Service} instance. |
|
| 33 | + * |
|
| 34 | + * @since 3.9.0 |
|
| 35 | + * @access private |
|
| 36 | + * @var Wordlift_Key_Validation_Service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 37 | + */ |
|
| 38 | + private $key_validation_service; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * A {@link Wordlift_Entity_Service} instance. |
|
| 42 | + * |
|
| 43 | + * @since 3.9.0 |
|
| 44 | + * @access private |
|
| 45 | + * @var Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 46 | + */ |
|
| 47 | + private $entity_service; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 51 | + * |
|
| 52 | + * @since 3.20.0 |
|
| 53 | + * @access private |
|
| 54 | + * @var \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 55 | + */ |
|
| 56 | + private $language_select_element; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 60 | + * |
|
| 61 | + * @since 3.20.0 |
|
| 62 | + * @access private |
|
| 63 | + * @var \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 64 | + */ |
|
| 65 | + private $country_select_element; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Initialize the class and set its properties. |
|
| 69 | + * |
|
| 70 | + * @param \Wordlift_Key_Validation_Service $key_validation_service A {@link Wordlift_Key_Validation_Service} instance. |
|
| 71 | + * @param \Wordlift_Entity_Service $entity_service A {@link Wordlift_Entity_Service} instance. |
|
| 72 | + * @param \Wordlift_Admin_Language_Select_Element $language_select_element A {@link Wordlift_Admin_Language_Select_Element} element renderer. |
|
| 73 | + * @param \Wordlift_Admin_Country_Select_Element $country_select_element A {@link Wordlift_Admin_Country_Select_Element} element renderer. |
|
| 74 | + * |
|
| 75 | + * @since 3.9.0 |
|
| 76 | + */ |
|
| 77 | + public function __construct( $key_validation_service, $entity_service, $language_select_element, $country_select_element ) { |
|
| 78 | + |
|
| 79 | + // Set a reference to the key validation service. |
|
| 80 | + $this->key_validation_service = $key_validation_service; |
|
| 81 | + |
|
| 82 | + // Set a reference to the entity service. |
|
| 83 | + $this->entity_service = $entity_service; |
|
| 84 | + |
|
| 85 | + // Set a reference to the UI elements language and country. |
|
| 86 | + $this->language_select_element = $language_select_element; |
|
| 87 | + $this->country_select_element = $country_select_element; |
|
| 88 | + |
|
| 89 | + // Hook to some WP's events: |
|
| 90 | + // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
|
| 91 | + add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 92 | + |
|
| 93 | + // Hook to `admin_menu` in order to add our own setup wizard page. |
|
| 94 | + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 95 | + |
|
| 96 | + // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
|
| 97 | + add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Filter: wl_feature__enable__notices. |
|
| 101 | + * |
|
| 102 | + * @param bool whether the notices needs to be enabled or not. |
|
| 103 | + * |
|
| 104 | + * @return bool |
|
| 105 | + * @since 3.27.6 |
|
| 106 | + */ |
|
| 107 | + if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 108 | + // Hook to `admin_notices` to display our notices. |
|
| 109 | + add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Hook to `admin_init` and redirect to WordLift's setup page if the `_wl_activation_redirect` transient flag is set. |
|
| 115 | + * |
|
| 116 | + * @since 3.9.0 |
|
| 117 | + */ |
|
| 118 | + public function admin_init() { |
|
| 119 | + |
|
| 120 | + // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
|
| 121 | + if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 122 | + delete_transient( '_wl_activation_redirect' ); |
|
| 123 | + |
|
| 124 | + // If the user asked to skip the wizard then comply. |
|
| 125 | + if ( Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { |
|
| 126 | + return; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + // If we're already on the page or the user doesn't have permissions, return. |
|
| 130 | + if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 131 | + return; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + // Finally redirect to the setup page. |
|
| 135 | + wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 136 | + |
|
| 137 | + exit; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Generate an admin notice suggesting to start the wizard if there is no configuration. |
|
| 144 | + * |
|
| 145 | + * @since 3.9.0 |
|
| 146 | + */ |
|
| 147 | + public function admin_notices() { |
|
| 148 | + |
|
| 149 | + // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
|
| 150 | + if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() && ! Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { ?> |
|
| 151 | 151 | <div id="wl-message" class="updated"> |
| 152 | 152 | <p><?php esc_html_e( 'Welcome to WordLift – You‘re almost ready to start', 'wordlift' ); ?></p> |
| 153 | 153 | <p class="submit"> |
@@ -158,141 +158,141 @@ discard block |
||
| 158 | 158 | </p> |
| 159 | 159 | </div> |
| 160 | 160 | <?php |
| 161 | - } |
|
| 162 | - |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Handle hiding the wizard notices by user request. |
|
| 167 | - * |
|
| 168 | - * @since 3.9.0 |
|
| 169 | - */ |
|
| 170 | - public function hide_notices() { |
|
| 171 | - |
|
| 172 | - // If it's not a `wl-hide-notice` or the nonce is not set, return. |
|
| 173 | - if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 174 | - return; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // If the nonce is invalid, return an error. |
|
| 178 | - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wl_notice_nonce'] ) ), 'wordlift_hide_notices_nonce' ) ) { |
|
| 179 | - wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // If the user doesn't have the right privileges, return an error. |
|
| 183 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 184 | - wp_die( esc_html__( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - // Store a flag telling to skip the wizard. |
|
| 188 | - Wordlift_Configuration_Service::get_instance()->set_skip_wizard( true ); |
|
| 189 | - |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Register the wizard page to be able to access it. |
|
| 194 | - * |
|
| 195 | - * @since 3.9.0 |
|
| 196 | - */ |
|
| 197 | - public function admin_menu() { |
|
| 198 | - /** |
|
| 199 | - * |
|
| 200 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1209 |
|
| 201 | - * @since 3.27.7 |
|
| 202 | - */ |
|
| 203 | - // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
|
| 204 | - add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Displays the wizard page. |
|
| 209 | - * |
|
| 210 | - * @since 3.9.0 |
|
| 211 | - */ |
|
| 212 | - public function show_page() { |
|
| 213 | - |
|
| 214 | - // First check if we are in the wizard page at all, if not do nothing. |
|
| 215 | - if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 216 | - return; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // Allow 3rd parties to provide alternative setups, this is useful for whitelabel setups. |
|
| 220 | - do_action( 'wl_admin_setup__pre' ); |
|
| 221 | - |
|
| 222 | - // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
|
| 223 | - if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 224 | - |
|
| 225 | - // Check the nonce and the user capabilities. |
|
| 226 | - check_admin_referer( 'wl-save-configuration' ); |
|
| 227 | - |
|
| 228 | - // Check if the user has the right privileges. |
|
| 229 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 230 | - wp_die( esc_html__( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - // Save the configuration. |
|
| 234 | - $this->save_configuration( $_POST ); |
|
| 235 | - |
|
| 236 | - // Redirect to the admin's page. |
|
| 237 | - wp_safe_redirect( admin_url() ); |
|
| 238 | - exit(); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 242 | - $language_select = $this->language_select_element; |
|
| 243 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 244 | - $country_select = $this->country_select_element; |
|
| 245 | - |
|
| 246 | - include plugin_dir_path( __DIR__ ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 247 | - |
|
| 248 | - exit; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - /** |
|
| 252 | - * Save WordLift's configuration using the provided parameters. |
|
| 253 | - * |
|
| 254 | - * @param array $params An array of configuration parameters. |
|
| 255 | - * |
|
| 256 | - * @since 3.9.0 |
|
| 257 | - */ |
|
| 258 | - public function save_configuration( $params ) { |
|
| 259 | - |
|
| 260 | - // We have the following parameters: |
|
| 261 | - // `key`, holding WL's key, |
|
| 262 | - // `vocabulary`, holding the vocabulary path, |
|
| 263 | - // `wl-country-code` with the country code (e.g. `us`), |
|
| 264 | - // `share-diagnostic`, the user preferences about sharing data with us. |
|
| 265 | - // `user_type`, the user type either `personal` or `company`, |
|
| 266 | - // `name`, with the `personal` or `company`'s name, |
|
| 267 | - // `logo`, the attachment id for the `personal` or `company` entity. |
|
| 268 | - |
|
| 269 | - // Store the key: |
|
| 270 | - Wordlift_Configuration_Service::get_instance()->set_key( $params['key'] ); |
|
| 271 | - |
|
| 272 | - // Store the vocabulary path: |
|
| 273 | - Wordlift_Configuration_Service::get_instance()->set_entity_base_path( $params['vocabulary'] ); |
|
| 274 | - |
|
| 275 | - // Store the site's country: |
|
| 276 | - Wordlift_Configuration_Service::get_instance()->set_country_code( $params['wl-country-code'] ); |
|
| 277 | - |
|
| 278 | - // Store the preferences in variable, because if the checkbox is not checked |
|
| 279 | - // the `share-diagnostic` will not exists in `$params` array. |
|
| 280 | - $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes'; |
|
| 281 | - |
|
| 282 | - // Store the diagnostic preferences: |
|
| 283 | - Wordlift_Configuration_Service::get_instance()->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 284 | - |
|
| 285 | - // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 286 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 287 | - |
|
| 288 | - // Create an entity for the publisher. |
|
| 289 | - $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 290 | - |
|
| 291 | - // Store the publisher entity post id in the configuration. |
|
| 292 | - Wordlift_Configuration_Service::get_instance()->set_publisher_id( $publisher_post_id ); |
|
| 293 | - |
|
| 294 | - flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
|
| 295 | - |
|
| 296 | - } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Handle hiding the wizard notices by user request. |
|
| 167 | + * |
|
| 168 | + * @since 3.9.0 |
|
| 169 | + */ |
|
| 170 | + public function hide_notices() { |
|
| 171 | + |
|
| 172 | + // If it's not a `wl-hide-notice` or the nonce is not set, return. |
|
| 173 | + if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 174 | + return; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // If the nonce is invalid, return an error. |
|
| 178 | + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wl_notice_nonce'] ) ), 'wordlift_hide_notices_nonce' ) ) { |
|
| 179 | + wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // If the user doesn't have the right privileges, return an error. |
|
| 183 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 184 | + wp_die( esc_html__( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + // Store a flag telling to skip the wizard. |
|
| 188 | + Wordlift_Configuration_Service::get_instance()->set_skip_wizard( true ); |
|
| 189 | + |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Register the wizard page to be able to access it. |
|
| 194 | + * |
|
| 195 | + * @since 3.9.0 |
|
| 196 | + */ |
|
| 197 | + public function admin_menu() { |
|
| 198 | + /** |
|
| 199 | + * |
|
| 200 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1209 |
|
| 201 | + * @since 3.27.7 |
|
| 202 | + */ |
|
| 203 | + // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
|
| 204 | + add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Displays the wizard page. |
|
| 209 | + * |
|
| 210 | + * @since 3.9.0 |
|
| 211 | + */ |
|
| 212 | + public function show_page() { |
|
| 213 | + |
|
| 214 | + // First check if we are in the wizard page at all, if not do nothing. |
|
| 215 | + if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 216 | + return; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // Allow 3rd parties to provide alternative setups, this is useful for whitelabel setups. |
|
| 220 | + do_action( 'wl_admin_setup__pre' ); |
|
| 221 | + |
|
| 222 | + // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
|
| 223 | + if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 224 | + |
|
| 225 | + // Check the nonce and the user capabilities. |
|
| 226 | + check_admin_referer( 'wl-save-configuration' ); |
|
| 227 | + |
|
| 228 | + // Check if the user has the right privileges. |
|
| 229 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 230 | + wp_die( esc_html__( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + // Save the configuration. |
|
| 234 | + $this->save_configuration( $_POST ); |
|
| 235 | + |
|
| 236 | + // Redirect to the admin's page. |
|
| 237 | + wp_safe_redirect( admin_url() ); |
|
| 238 | + exit(); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 242 | + $language_select = $this->language_select_element; |
|
| 243 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 244 | + $country_select = $this->country_select_element; |
|
| 245 | + |
|
| 246 | + include plugin_dir_path( __DIR__ ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 247 | + |
|
| 248 | + exit; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + /** |
|
| 252 | + * Save WordLift's configuration using the provided parameters. |
|
| 253 | + * |
|
| 254 | + * @param array $params An array of configuration parameters. |
|
| 255 | + * |
|
| 256 | + * @since 3.9.0 |
|
| 257 | + */ |
|
| 258 | + public function save_configuration( $params ) { |
|
| 259 | + |
|
| 260 | + // We have the following parameters: |
|
| 261 | + // `key`, holding WL's key, |
|
| 262 | + // `vocabulary`, holding the vocabulary path, |
|
| 263 | + // `wl-country-code` with the country code (e.g. `us`), |
|
| 264 | + // `share-diagnostic`, the user preferences about sharing data with us. |
|
| 265 | + // `user_type`, the user type either `personal` or `company`, |
|
| 266 | + // `name`, with the `personal` or `company`'s name, |
|
| 267 | + // `logo`, the attachment id for the `personal` or `company` entity. |
|
| 268 | + |
|
| 269 | + // Store the key: |
|
| 270 | + Wordlift_Configuration_Service::get_instance()->set_key( $params['key'] ); |
|
| 271 | + |
|
| 272 | + // Store the vocabulary path: |
|
| 273 | + Wordlift_Configuration_Service::get_instance()->set_entity_base_path( $params['vocabulary'] ); |
|
| 274 | + |
|
| 275 | + // Store the site's country: |
|
| 276 | + Wordlift_Configuration_Service::get_instance()->set_country_code( $params['wl-country-code'] ); |
|
| 277 | + |
|
| 278 | + // Store the preferences in variable, because if the checkbox is not checked |
|
| 279 | + // the `share-diagnostic` will not exists in `$params` array. |
|
| 280 | + $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes'; |
|
| 281 | + |
|
| 282 | + // Store the diagnostic preferences: |
|
| 283 | + Wordlift_Configuration_Service::get_instance()->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 284 | + |
|
| 285 | + // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
|
| 286 | + $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 287 | + |
|
| 288 | + // Create an entity for the publisher. |
|
| 289 | + $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 290 | + |
|
| 291 | + // Store the publisher entity post id in the configuration. |
|
| 292 | + Wordlift_Configuration_Service::get_instance()->set_publisher_id( $publisher_post_id ); |
|
| 293 | + |
|
| 294 | + flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
|
| 295 | + |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | 298 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @since 3.9.0 |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @since 3.9.0 |
| 76 | 76 | */ |
| 77 | - public function __construct( $key_validation_service, $entity_service, $language_select_element, $country_select_element ) { |
|
| 77 | + public function __construct($key_validation_service, $entity_service, $language_select_element, $country_select_element) { |
|
| 78 | 78 | |
| 79 | 79 | // Set a reference to the key validation service. |
| 80 | 80 | $this->key_validation_service = $key_validation_service; |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | // Hook to some WP's events: |
| 90 | 90 | // When WP is loaded check whether the user decided to skip the set-up, i.e. don't show us even if WL is not set up. |
| 91 | - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); |
|
| 91 | + add_action('wp_loaded', array($this, 'hide_notices')); |
|
| 92 | 92 | |
| 93 | 93 | // Hook to `admin_menu` in order to add our own setup wizard page. |
| 94 | - add_action( 'admin_menu', array( $this, 'admin_menu' ) ); |
|
| 94 | + add_action('admin_menu', array($this, 'admin_menu')); |
|
| 95 | 95 | |
| 96 | 96 | // Triggered when the user accesses the admin area, we decide whether to show our own wizard. |
| 97 | - add_action( 'admin_init', array( $this, 'show_page' ) ); |
|
| 97 | + add_action('admin_init', array($this, 'show_page')); |
|
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | 100 | * Filter: wl_feature__enable__notices. |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | * @return bool |
| 105 | 105 | * @since 3.27.6 |
| 106 | 106 | */ |
| 107 | - if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 107 | + if (apply_filters('wl_feature__enable__notices', true)) { |
|
| 108 | 108 | // Hook to `admin_notices` to display our notices. |
| 109 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 109 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | |
@@ -118,21 +118,21 @@ discard block |
||
| 118 | 118 | public function admin_init() { |
| 119 | 119 | |
| 120 | 120 | // If the `_wl_activation_redirect` is set, the redirect to the setup page. |
| 121 | - if ( get_transient( '_wl_activation_redirect' ) ) { |
|
| 122 | - delete_transient( '_wl_activation_redirect' ); |
|
| 121 | + if (get_transient('_wl_activation_redirect')) { |
|
| 122 | + delete_transient('_wl_activation_redirect'); |
|
| 123 | 123 | |
| 124 | 124 | // If the user asked to skip the wizard then comply. |
| 125 | - if ( Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { |
|
| 125 | + if (Wordlift_Configuration_Service::get_instance()->is_skip_wizard()) { |
|
| 126 | 126 | return; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // If we're already on the page or the user doesn't have permissions, return. |
| 130 | - if ( ( ! empty( $_GET['page'] ) && 'wl-setup' === $_GET['page'] ) || is_network_admin() || isset( $_GET['activate-multi'] ) || ! current_user_can( 'manage_options' ) ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 130 | + if (( ! empty($_GET['page']) && 'wl-setup' === $_GET['page']) || is_network_admin() || isset($_GET['activate-multi']) || ! current_user_can('manage_options')) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
| 131 | 131 | return; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Finally redirect to the setup page. |
| 135 | - wp_safe_redirect( admin_url( 'index.php?page=wl-setup' ) ); |
|
| 135 | + wp_safe_redirect(admin_url('index.php?page=wl-setup')); |
|
| 136 | 136 | |
| 137 | 137 | exit; |
| 138 | 138 | } |
@@ -147,14 +147,14 @@ discard block |
||
| 147 | 147 | public function admin_notices() { |
| 148 | 148 | |
| 149 | 149 | // Use `wl_configuration_get_key` to check whether WL's key is set and that the user didn't disable the wizard. |
| 150 | - if ( '' === Wordlift_Configuration_Service::get_instance()->get_key() && ! Wordlift_Configuration_Service::get_instance()->is_skip_wizard() ) { ?> |
|
| 150 | + if ('' === Wordlift_Configuration_Service::get_instance()->get_key() && ! Wordlift_Configuration_Service::get_instance()->is_skip_wizard()) { ?> |
|
| 151 | 151 | <div id="wl-message" class="updated"> |
| 152 | - <p><?php esc_html_e( 'Welcome to WordLift – You‘re almost ready to start', 'wordlift' ); ?></p> |
|
| 152 | + <p><?php esc_html_e('Welcome to WordLift – You‘re almost ready to start', 'wordlift'); ?></p> |
|
| 153 | 153 | <p class="submit"> |
| 154 | - <a href="<?php echo esc_url( admin_url( 'admin.php?page=wl-setup' ) ); ?>" |
|
| 155 | - class="button-primary"><?php esc_html_e( 'Run the Setup Wizard', 'wordlift' ); ?></a> |
|
| 154 | + <a href="<?php echo esc_url(admin_url('admin.php?page=wl-setup')); ?>" |
|
| 155 | + class="button-primary"><?php esc_html_e('Run the Setup Wizard', 'wordlift'); ?></a> |
|
| 156 | 156 | <a class="button-secondary skip" |
| 157 | - href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wl-hide-notice', 'install' ), 'wordlift_hide_notices_nonce', '_wl_notice_nonce' ) ); ?>"><?php esc_html_e( 'Skip Setup', 'wordlift' ); ?></a> |
|
| 157 | + href="<?php echo esc_url(wp_nonce_url(add_query_arg('wl-hide-notice', 'install'), 'wordlift_hide_notices_nonce', '_wl_notice_nonce')); ?>"><?php esc_html_e('Skip Setup', 'wordlift'); ?></a> |
|
| 158 | 158 | </p> |
| 159 | 159 | </div> |
| 160 | 160 | <?php |
@@ -170,22 +170,22 @@ discard block |
||
| 170 | 170 | public function hide_notices() { |
| 171 | 171 | |
| 172 | 172 | // If it's not a `wl-hide-notice` or the nonce is not set, return. |
| 173 | - if ( ! isset( $_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'] ) ) { |
|
| 173 | + if ( ! isset($_GET['wl-hide-notice'], $_GET['_wl_notice_nonce'])) { |
|
| 174 | 174 | return; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // If the nonce is invalid, return an error. |
| 178 | - if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wl_notice_nonce'] ) ), 'wordlift_hide_notices_nonce' ) ) { |
|
| 179 | - wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'wordlift' ) ); |
|
| 178 | + if ( ! wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_wl_notice_nonce'])), 'wordlift_hide_notices_nonce')) { |
|
| 179 | + wp_die(esc_html__('Action failed. Please refresh the page and retry.', 'wordlift')); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // If the user doesn't have the right privileges, return an error. |
| 183 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 184 | - wp_die( esc_html__( 'Cheatin’ huh?', 'wordlift' ) ); |
|
| 183 | + if ( ! current_user_can('manage_options')) { |
|
| 184 | + wp_die(esc_html__('Cheatin’ huh?', 'wordlift')); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | // Store a flag telling to skip the wizard. |
| 188 | - Wordlift_Configuration_Service::get_instance()->set_skip_wizard( true ); |
|
| 188 | + Wordlift_Configuration_Service::get_instance()->set_skip_wizard(true); |
|
| 189 | 189 | |
| 190 | 190 | } |
| 191 | 191 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @since 3.27.7 |
| 202 | 202 | */ |
| 203 | 203 | // @todo: find another way to do this, since this is adding an empty space in WP's dashboard menu. |
| 204 | - add_dashboard_page( '', '', 'manage_options', 'wl-setup', '' ); |
|
| 204 | + add_dashboard_page('', '', 'manage_options', 'wl-setup', ''); |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | /** |
@@ -212,29 +212,29 @@ discard block |
||
| 212 | 212 | public function show_page() { |
| 213 | 213 | |
| 214 | 214 | // First check if we are in the wizard page at all, if not do nothing. |
| 215 | - if ( empty( $_GET['page'] ) || 'wl-setup' !== $_GET['page'] ) { |
|
| 215 | + if (empty($_GET['page']) || 'wl-setup' !== $_GET['page']) { |
|
| 216 | 216 | return; |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // Allow 3rd parties to provide alternative setups, this is useful for whitelabel setups. |
| 220 | - do_action( 'wl_admin_setup__pre' ); |
|
| 220 | + do_action('wl_admin_setup__pre'); |
|
| 221 | 221 | |
| 222 | 222 | // If it's a POST and the `wl-save-configuration` action is set, save the configuration. |
| 223 | - if ( isset( $_POST['action'] ) && 'wl-save-configuration' === $_POST['action'] ) { |
|
| 223 | + if (isset($_POST['action']) && 'wl-save-configuration' === $_POST['action']) { |
|
| 224 | 224 | |
| 225 | 225 | // Check the nonce and the user capabilities. |
| 226 | - check_admin_referer( 'wl-save-configuration' ); |
|
| 226 | + check_admin_referer('wl-save-configuration'); |
|
| 227 | 227 | |
| 228 | 228 | // Check if the user has the right privileges. |
| 229 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 230 | - wp_die( esc_html__( 'Sorry, you do not have a permission to save the settings', 'wordlift' ) ); |
|
| 229 | + if ( ! current_user_can('manage_options')) { |
|
| 230 | + wp_die(esc_html__('Sorry, you do not have a permission to save the settings', 'wordlift')); |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Save the configuration. |
| 234 | - $this->save_configuration( $_POST ); |
|
| 234 | + $this->save_configuration($_POST); |
|
| 235 | 235 | |
| 236 | 236 | // Redirect to the admin's page. |
| 237 | - wp_safe_redirect( admin_url() ); |
|
| 237 | + wp_safe_redirect(admin_url()); |
|
| 238 | 238 | exit(); |
| 239 | 239 | } |
| 240 | 240 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 244 | 244 | $country_select = $this->country_select_element; |
| 245 | 245 | |
| 246 | - include plugin_dir_path( __DIR__ ) . 'admin/partials/wordlift-admin-setup.php'; |
|
| 246 | + include plugin_dir_path(__DIR__).'admin/partials/wordlift-admin-setup.php'; |
|
| 247 | 247 | |
| 248 | 248 | exit; |
| 249 | 249 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @since 3.9.0 |
| 257 | 257 | */ |
| 258 | - public function save_configuration( $params ) { |
|
| 258 | + public function save_configuration($params) { |
|
| 259 | 259 | |
| 260 | 260 | // We have the following parameters: |
| 261 | 261 | // `key`, holding WL's key, |
@@ -267,29 +267,29 @@ discard block |
||
| 267 | 267 | // `logo`, the attachment id for the `personal` or `company` entity. |
| 268 | 268 | |
| 269 | 269 | // Store the key: |
| 270 | - Wordlift_Configuration_Service::get_instance()->set_key( $params['key'] ); |
|
| 270 | + Wordlift_Configuration_Service::get_instance()->set_key($params['key']); |
|
| 271 | 271 | |
| 272 | 272 | // Store the vocabulary path: |
| 273 | - Wordlift_Configuration_Service::get_instance()->set_entity_base_path( $params['vocabulary'] ); |
|
| 273 | + Wordlift_Configuration_Service::get_instance()->set_entity_base_path($params['vocabulary']); |
|
| 274 | 274 | |
| 275 | 275 | // Store the site's country: |
| 276 | - Wordlift_Configuration_Service::get_instance()->set_country_code( $params['wl-country-code'] ); |
|
| 276 | + Wordlift_Configuration_Service::get_instance()->set_country_code($params['wl-country-code']); |
|
| 277 | 277 | |
| 278 | 278 | // Store the preferences in variable, because if the checkbox is not checked |
| 279 | 279 | // the `share-diagnostic` will not exists in `$params` array. |
| 280 | - $share_diagnostic_preferences = empty( $params['share-diagnostic'] ) ? 'no' : 'yes'; |
|
| 280 | + $share_diagnostic_preferences = empty($params['share-diagnostic']) ? 'no' : 'yes'; |
|
| 281 | 281 | |
| 282 | 282 | // Store the diagnostic preferences: |
| 283 | - Wordlift_Configuration_Service::get_instance()->set_diagnostic_preferences( $share_diagnostic_preferences ); |
|
| 283 | + Wordlift_Configuration_Service::get_instance()->set_diagnostic_preferences($share_diagnostic_preferences); |
|
| 284 | 284 | |
| 285 | 285 | // Set the type URI, either http://schema.org/Person or http://schema.org/Organization. |
| 286 | - $type_uri = sprintf( 'http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person' ); |
|
| 286 | + $type_uri = sprintf('http://schema.org/%s', 'organization' === $params['user_type'] ? 'Organization' : 'Person'); |
|
| 287 | 287 | |
| 288 | 288 | // Create an entity for the publisher. |
| 289 | - $publisher_post_id = $this->entity_service->create( $params['name'], $type_uri, $params['logo'], 'publish' ); |
|
| 289 | + $publisher_post_id = $this->entity_service->create($params['name'], $type_uri, $params['logo'], 'publish'); |
|
| 290 | 290 | |
| 291 | 291 | // Store the publisher entity post id in the configuration. |
| 292 | - Wordlift_Configuration_Service::get_instance()->set_publisher_id( $publisher_post_id ); |
|
| 292 | + Wordlift_Configuration_Service::get_instance()->set_publisher_id($publisher_post_id); |
|
| 293 | 293 | |
| 294 | 294 | flush_rewrite_rules(); // Needed because of possible change to the entity base path. |
| 295 | 295 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @since 3.33.6 |
| 49 | 49 | */ |
| 50 | 50 | if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
| 51 | - return; |
|
| 51 | + return; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
@@ -77,33 +77,33 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function activate_wordlift() { |
| 79 | 79 | |
| 80 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 80 | + $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 81 | 81 | |
| 82 | - $log->info( 'Activating WordLift...' ); |
|
| 82 | + $log->info( 'Activating WordLift...' ); |
|
| 83 | 83 | |
| 84 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 85 | - Wordlift_Activator::activate(); |
|
| 84 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 85 | + Wordlift_Activator::activate(); |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks. |
|
| 89 | - * |
|
| 90 | - * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue. |
|
| 91 | - * @since 3.19.2 |
|
| 92 | - */ |
|
| 93 | - Wordlift_Http_Api::activate(); |
|
| 87 | + /** |
|
| 88 | + * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks. |
|
| 89 | + * |
|
| 90 | + * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue. |
|
| 91 | + * @since 3.19.2 |
|
| 92 | + */ |
|
| 93 | + Wordlift_Http_Api::activate(); |
|
| 94 | 94 | |
| 95 | - // Ensure the post type is registered before flushing the rewrite rules. |
|
| 96 | - Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
| 97 | - flush_rewrite_rules(); |
|
| 98 | - /** |
|
| 99 | - * @since 3.27.7 |
|
| 100 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 101 | - */ |
|
| 102 | - Top_Entities::activate(); |
|
| 95 | + // Ensure the post type is registered before flushing the rewrite rules. |
|
| 96 | + Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
| 97 | + flush_rewrite_rules(); |
|
| 98 | + /** |
|
| 99 | + * @since 3.27.7 |
|
| 100 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 101 | + */ |
|
| 102 | + Top_Entities::activate(); |
|
| 103 | 103 | |
| 104 | - if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
| 105 | - wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
| 106 | - } |
|
| 104 | + if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
| 105 | + wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | 108 | } |
| 109 | 109 | |
@@ -113,23 +113,23 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | function deactivate_wordlift() { |
| 115 | 115 | |
| 116 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 117 | - Wordlift_Deactivator::deactivate(); |
|
| 118 | - Wordlift_Http_Api::deactivate(); |
|
| 119 | - Ttl_Cache_Cleaner::deactivate(); |
|
| 120 | - /** |
|
| 121 | - * @since 3.27.7 |
|
| 122 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 123 | - */ |
|
| 124 | - Top_Entities::deactivate(); |
|
| 125 | - /** |
|
| 126 | - * @since 3.27.8 |
|
| 127 | - * Remove notification flag on deactivation. |
|
| 128 | - */ |
|
| 129 | - Key_Validation_Notice::remove_notification_flag(); |
|
| 130 | - flush_rewrite_rules(); |
|
| 131 | - |
|
| 132 | - wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
| 116 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 117 | + Wordlift_Deactivator::deactivate(); |
|
| 118 | + Wordlift_Http_Api::deactivate(); |
|
| 119 | + Ttl_Cache_Cleaner::deactivate(); |
|
| 120 | + /** |
|
| 121 | + * @since 3.27.7 |
|
| 122 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
| 123 | + */ |
|
| 124 | + Top_Entities::deactivate(); |
|
| 125 | + /** |
|
| 126 | + * @since 3.27.8 |
|
| 127 | + * Remove notification flag on deactivation. |
|
| 128 | + */ |
|
| 129 | + Key_Validation_Notice::remove_notification_flag(); |
|
| 130 | + flush_rewrite_rules(); |
|
| 131 | + |
|
| 132 | + wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
@@ -152,84 +152,84 @@ discard block |
||
| 152 | 152 | * @since 1.0.0 |
| 153 | 153 | */ |
| 154 | 154 | function run_wordlift() { |
| 155 | - /** |
|
| 156 | - * Filter: wl_feature__enable__widgets. |
|
| 157 | - * |
|
| 158 | - * @param bool whether the widgets needed to be registered, defaults to true. |
|
| 159 | - * |
|
| 160 | - * @return bool |
|
| 161 | - * @since 3.27.6 |
|
| 162 | - */ |
|
| 163 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 164 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 165 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 166 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 167 | - } |
|
| 168 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Filter: wl_feature__enable__analysis |
|
| 172 | - * |
|
| 173 | - * @param bool Whether to send api request to analysis or not |
|
| 174 | - * |
|
| 175 | - * @return bool |
|
| 176 | - * @since 3.27.6 |
|
| 177 | - */ |
|
| 178 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 179 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 180 | - } else { |
|
| 181 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $plugin = new Wordlift(); |
|
| 185 | - $plugin->run(); |
|
| 186 | - |
|
| 187 | - // Initialize the TTL Cache Cleaner. |
|
| 188 | - new Ttl_Cache_Cleaner(); |
|
| 189 | - |
|
| 190 | - // Load the new Post Adapter. |
|
| 191 | - new Post_Adapter(); |
|
| 192 | - |
|
| 193 | - // Load the API Data Hooks. |
|
| 194 | - new Api_Data_Hooks(); |
|
| 195 | - |
|
| 196 | - add_action( |
|
| 197 | - 'plugins_loaded', |
|
| 198 | - function () { |
|
| 199 | - // All features from registry should be initialized here. |
|
| 200 | - $features_registry = Features_Registry::get_instance(); |
|
| 201 | - $features_registry->initialize_all_features(); |
|
| 202 | - }, |
|
| 203 | - 5 |
|
| 204 | - ); |
|
| 205 | - |
|
| 206 | - add_action( |
|
| 207 | - 'plugins_loaded', |
|
| 208 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 209 | - function () use ( $plugin ) { |
|
| 210 | - |
|
| 211 | - new Wordlift_Products_Navigator_Shortcode_REST(); |
|
| 212 | - |
|
| 213 | - // Register the Dataset module, requires `$api_service`. |
|
| 214 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
| 215 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php'; |
|
| 216 | - |
|
| 217 | - /* |
|
| 155 | + /** |
|
| 156 | + * Filter: wl_feature__enable__widgets. |
|
| 157 | + * |
|
| 158 | + * @param bool whether the widgets needed to be registered, defaults to true. |
|
| 159 | + * |
|
| 160 | + * @return bool |
|
| 161 | + * @since 3.27.6 |
|
| 162 | + */ |
|
| 163 | + if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 164 | + add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 165 | + add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 166 | + add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 167 | + } |
|
| 168 | + add_filter( 'widget_text', 'do_shortcode' ); |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Filter: wl_feature__enable__analysis |
|
| 172 | + * |
|
| 173 | + * @param bool Whether to send api request to analysis or not |
|
| 174 | + * |
|
| 175 | + * @return bool |
|
| 176 | + * @since 3.27.6 |
|
| 177 | + */ |
|
| 178 | + if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 179 | + add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 180 | + } else { |
|
| 181 | + add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $plugin = new Wordlift(); |
|
| 185 | + $plugin->run(); |
|
| 186 | + |
|
| 187 | + // Initialize the TTL Cache Cleaner. |
|
| 188 | + new Ttl_Cache_Cleaner(); |
|
| 189 | + |
|
| 190 | + // Load the new Post Adapter. |
|
| 191 | + new Post_Adapter(); |
|
| 192 | + |
|
| 193 | + // Load the API Data Hooks. |
|
| 194 | + new Api_Data_Hooks(); |
|
| 195 | + |
|
| 196 | + add_action( |
|
| 197 | + 'plugins_loaded', |
|
| 198 | + function () { |
|
| 199 | + // All features from registry should be initialized here. |
|
| 200 | + $features_registry = Features_Registry::get_instance(); |
|
| 201 | + $features_registry->initialize_all_features(); |
|
| 202 | + }, |
|
| 203 | + 5 |
|
| 204 | + ); |
|
| 205 | + |
|
| 206 | + add_action( |
|
| 207 | + 'plugins_loaded', |
|
| 208 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
| 209 | + function () use ( $plugin ) { |
|
| 210 | + |
|
| 211 | + new Wordlift_Products_Navigator_Shortcode_REST(); |
|
| 212 | + |
|
| 213 | + // Register the Dataset module, requires `$api_service`. |
|
| 214 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
| 215 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php'; |
|
| 216 | + |
|
| 217 | + /* |
|
| 218 | 218 | * Require the Entity annotation cleanup module. |
| 219 | 219 | * |
| 220 | 220 | * @since 3.34.6 |
| 221 | 221 | */ |
| 222 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php'; |
|
| 222 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php'; |
|
| 223 | 223 | |
| 224 | - /* |
|
| 224 | + /* |
|
| 225 | 225 | * Import LOD entities. |
| 226 | 226 | * |
| 227 | 227 | * @since 3.35.0 |
| 228 | 228 | */ |
| 229 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php'; |
|
| 229 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php'; |
|
| 230 | 230 | |
| 231 | - } |
|
| 232 | - ); |
|
| 231 | + } |
|
| 232 | + ); |
|
| 233 | 233 | |
| 234 | 234 | } |
| 235 | 235 | |
@@ -243,45 +243,45 @@ discard block |
||
| 243 | 243 | */ |
| 244 | 244 | function wordlift_plugin_autoload_register() { |
| 245 | 245 | |
| 246 | - spl_autoload_register( |
|
| 247 | - function ( $class_name ) { |
|
| 246 | + spl_autoload_register( |
|
| 247 | + function ( $class_name ) { |
|
| 248 | 248 | |
| 249 | - // Bail out if these are not our classes. |
|
| 250 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 251 | - return false; |
|
| 252 | - } |
|
| 249 | + // Bail out if these are not our classes. |
|
| 250 | + if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 251 | + return false; |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 254 | + $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 255 | 255 | |
| 256 | - preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 256 | + preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 257 | 257 | |
| 258 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 259 | - $file = 'class-' . $matches[2] . '.php'; |
|
| 258 | + $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 259 | + $file = 'class-' . $matches[2] . '.php'; |
|
| 260 | 260 | |
| 261 | - $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
| 261 | + $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
| 262 | 262 | |
| 263 | - if ( ! file_exists( $full_path ) ) { |
|
| 264 | - return false; |
|
| 265 | - } |
|
| 263 | + if ( ! file_exists( $full_path ) ) { |
|
| 264 | + return false; |
|
| 265 | + } |
|
| 266 | 266 | |
| 267 | - require_once $full_path; |
|
| 267 | + require_once $full_path; |
|
| 268 | 268 | |
| 269 | - return true; |
|
| 270 | - } |
|
| 271 | - ); |
|
| 269 | + return true; |
|
| 270 | + } |
|
| 271 | + ); |
|
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | function wl_block_categories( $categories ) { |
| 276 | - return array_merge( |
|
| 277 | - $categories, |
|
| 278 | - array( |
|
| 279 | - array( |
|
| 280 | - 'slug' => 'wordlift', |
|
| 281 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
| 282 | - ), |
|
| 283 | - ) |
|
| 284 | - ); |
|
| 276 | + return array_merge( |
|
| 277 | + $categories, |
|
| 278 | + array( |
|
| 279 | + array( |
|
| 280 | + 'slug' => 'wordlift', |
|
| 281 | + 'title' => __( 'WordLift', 'wordlift' ), |
|
| 282 | + ), |
|
| 283 | + ) |
|
| 284 | + ); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /** |
@@ -289,19 +289,19 @@ discard block |
||
| 289 | 289 | * this has to be removed when removing the legacy fields from the ui. |
| 290 | 290 | */ |
| 291 | 291 | function wl_enqueue_leaflet( $in_footer = false ) { |
| 292 | - // Leaflet. |
|
| 293 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
| 294 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
| 292 | + // Leaflet. |
|
| 293 | + wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
| 294 | + wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | add_filter( 'block_categories', 'wl_block_categories', 10 ); |
| 298 | 298 | |
| 299 | 299 | // Temporary fix for a typo in WooCommerce Extension. |
| 300 | 300 | add_filter( |
| 301 | - 'wl_feature__enable__dataset', |
|
| 302 | - function ( $value ) { |
|
| 303 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
| 304 | - } |
|
| 301 | + 'wl_feature__enable__dataset', |
|
| 302 | + function ( $value ) { |
|
| 303 | + return apply_filters( 'wl_features__enable__dataset', $value ); |
|
| 304 | + } |
|
| 305 | 305 | ); |
| 306 | 306 | |
| 307 | 307 | require_once __DIR__ . '/modules/food-kg/load.php'; |
@@ -315,35 +315,35 @@ discard block |
||
| 315 | 315 | require_once __DIR__ . '/modules/raptive-setup/load.php'; |
| 316 | 316 | |
| 317 | 317 | function _wl_update_plugins_raptive_domain( $update, $plugin_data, $plugin_file ) { |
| 318 | - // Bail out if it's not our plugin. |
|
| 319 | - $update_uri = $plugin_data['UpdateURI']; |
|
| 320 | - if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
| 321 | - return $update; |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
| 325 | - |
|
| 326 | - if ( is_wp_error( $response ) ) { |
|
| 327 | - return $update; |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - try { |
|
| 331 | - return json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 332 | - } catch ( Exception $e ) { |
|
| 333 | - return $update; |
|
| 334 | - } |
|
| 318 | + // Bail out if it's not our plugin. |
|
| 319 | + $update_uri = $plugin_data['UpdateURI']; |
|
| 320 | + if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
| 321 | + return $update; |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
| 325 | + |
|
| 326 | + if ( is_wp_error( $response ) ) { |
|
| 327 | + return $update; |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + try { |
|
| 331 | + return json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 332 | + } catch ( Exception $e ) { |
|
| 333 | + return $update; |
|
| 334 | + } |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | add_action( |
| 338 | - 'update_plugins_adthrive.wordlift.io', |
|
| 339 | - '_wl_update_plugins_raptive_domain', |
|
| 340 | - 10, |
|
| 341 | - 3 |
|
| 338 | + 'update_plugins_adthrive.wordlift.io', |
|
| 339 | + '_wl_update_plugins_raptive_domain', |
|
| 340 | + 10, |
|
| 341 | + 3 |
|
| 342 | 342 | ); |
| 343 | 343 | |
| 344 | 344 | add_action( |
| 345 | - 'update_plugins_raptive.wordlift.io', |
|
| 346 | - '_wl_update_plugins_raptive_domain', |
|
| 347 | - 10, |
|
| 348 | - 3 |
|
| 345 | + 'update_plugins_raptive.wordlift.io', |
|
| 346 | + '_wl_update_plugins_raptive_domain', |
|
| 347 | + 10, |
|
| 348 | + 3 |
|
| 349 | 349 | ); |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | use Wordlift\Features\Features_Registry; |
| 32 | 32 | use Wordlift\Post\Post_Adapter; |
| 33 | 33 | |
| 34 | -define( 'WORDLIFT_PLUGIN_FILE', __FILE__ ); |
|
| 35 | -define( 'WORDLIFT_VERSION', '3.46.0-0' ); |
|
| 34 | +define('WORDLIFT_PLUGIN_FILE', __FILE__); |
|
| 35 | +define('WORDLIFT_VERSION', '3.46.0-0'); |
|
| 36 | 36 | |
| 37 | 37 | // DO NOT REMOVE THIS LINE: WHITELABEL PLACEHOLDER ## |
| 38 | -define( 'WL_RAPTIVE', true ); |
|
| 38 | +define('WL_RAPTIVE', true); |
|
| 39 | 39 | |
| 40 | -require_once plugin_dir_path( __FILE__ ) . '/libraries/action-scheduler/action-scheduler.php'; |
|
| 41 | -require_once __DIR__ . '/modules/common/load.php'; |
|
| 42 | -require_once __DIR__ . '/modules/app/load.php'; |
|
| 43 | -require_once __DIR__ . '/modules/include-exclude/load.php'; |
|
| 40 | +require_once plugin_dir_path(__FILE__).'/libraries/action-scheduler/action-scheduler.php'; |
|
| 41 | +require_once __DIR__.'/modules/common/load.php'; |
|
| 42 | +require_once __DIR__.'/modules/app/load.php'; |
|
| 43 | +require_once __DIR__.'/modules/include-exclude/load.php'; |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Filter to disable WLP on any request, defaults to true. |
| 47 | 47 | * |
| 48 | 48 | * @since 3.33.6 |
| 49 | 49 | */ |
| 50 | -if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
|
| 50 | +if ( ! apply_filters('wl_is_enabled', true)) { |
|
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | -require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
|
| 54 | +require_once plugin_dir_path(__FILE__).'vendor/autoload.php'; |
|
| 55 | 55 | |
| 56 | 56 | /* |
| 57 | 57 | * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http. |
@@ -61,15 +61,15 @@ discard block |
||
| 61 | 61 | wordlift_plugin_autoload_register(); |
| 62 | 62 | |
| 63 | 63 | // Include WordLift constants. |
| 64 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php'; |
|
| 64 | +require_once plugin_dir_path(__FILE__).'wordlift-constants.php'; |
|
| 65 | 65 | |
| 66 | 66 | // Load modules. |
| 67 | -require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php'; |
|
| 67 | +require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php'; |
|
| 68 | 68 | |
| 69 | -require_once plugin_dir_path( __FILE__ ) . 'deprecations.php'; |
|
| 69 | +require_once plugin_dir_path(__FILE__).'deprecations.php'; |
|
| 70 | 70 | |
| 71 | 71 | // Load early to enable/disable features. |
| 72 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php'; |
|
| 72 | +require_once plugin_dir_path(__FILE__).'wordlift/features/index.php'; |
|
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * The code that runs during plugin activation. |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | function activate_wordlift() { |
| 79 | 79 | |
| 80 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 80 | + $log = Wordlift_Log_Service::get_logger('activate_wordlift'); |
|
| 81 | 81 | |
| 82 | - $log->info( 'Activating WordLift...' ); |
|
| 82 | + $log->info('Activating WordLift...'); |
|
| 83 | 83 | |
| 84 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 84 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 85 | 85 | Wordlift_Activator::activate(); |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | Top_Entities::activate(); |
| 103 | 103 | |
| 104 | - if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
| 105 | - wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
| 104 | + if ( ! wp_next_scheduled('wl_daily_cron')) { |
|
| 105 | + wp_schedule_event(time(), 'daily', 'wl_daily_cron'); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | function deactivate_wordlift() { |
| 115 | 115 | |
| 116 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 116 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 117 | 117 | Wordlift_Deactivator::deactivate(); |
| 118 | 118 | Wordlift_Http_Api::deactivate(); |
| 119 | 119 | Ttl_Cache_Cleaner::deactivate(); |
@@ -129,18 +129,18 @@ discard block |
||
| 129 | 129 | Key_Validation_Notice::remove_notification_flag(); |
| 130 | 130 | flush_rewrite_rules(); |
| 131 | 131 | |
| 132 | - wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
| 132 | + wp_clear_scheduled_hook('wl_daily_cron'); |
|
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 137 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 136 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 137 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 138 | 138 | |
| 139 | 139 | /** |
| 140 | 140 | * The core plugin class that is used to define internationalization, |
| 141 | 141 | * admin-specific hooks, and public-facing site hooks. |
| 142 | 142 | */ |
| 143 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 143 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | 146 | * Begins execution of the plugin. |
@@ -160,12 +160,12 @@ discard block |
||
| 160 | 160 | * @return bool |
| 161 | 161 | * @since 3.27.6 |
| 162 | 162 | */ |
| 163 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 164 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 165 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 166 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 163 | + if (apply_filters('wl_feature__enable__widgets', true)) { |
|
| 164 | + add_action('widgets_init', 'wl_register_chord_widget'); |
|
| 165 | + add_action('widgets_init', 'wl_register_geo_widget'); |
|
| 166 | + add_action('widgets_init', 'wl_register_timeline_widget'); |
|
| 167 | 167 | } |
| 168 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
| 168 | + add_filter('widget_text', 'do_shortcode'); |
|
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | 171 | * Filter: wl_feature__enable__analysis |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | * @return bool |
| 176 | 176 | * @since 3.27.6 |
| 177 | 177 | */ |
| 178 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 179 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 178 | + if (apply_filters('wl_feature__enable__analysis', true)) { |
|
| 179 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action'); |
|
| 180 | 180 | } else { |
| 181 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 181 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action'); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | $plugin = new Wordlift(); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | add_action( |
| 197 | 197 | 'plugins_loaded', |
| 198 | - function () { |
|
| 198 | + function() { |
|
| 199 | 199 | // All features from registry should be initialized here. |
| 200 | 200 | $features_registry = Features_Registry::get_instance(); |
| 201 | 201 | $features_registry->initialize_all_features(); |
@@ -206,27 +206,27 @@ discard block |
||
| 206 | 206 | add_action( |
| 207 | 207 | 'plugins_loaded', |
| 208 | 208 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 209 | - function () use ( $plugin ) { |
|
| 209 | + function() use ($plugin) { |
|
| 210 | 210 | |
| 211 | 211 | new Wordlift_Products_Navigator_Shortcode_REST(); |
| 212 | 212 | |
| 213 | 213 | // Register the Dataset module, requires `$api_service`. |
| 214 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
| 215 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php'; |
|
| 214 | + require_once plugin_dir_path(__FILE__).'wordlift/dataset/index.php'; |
|
| 215 | + require_once plugin_dir_path(__FILE__).'wordlift/shipping-data/index.php'; |
|
| 216 | 216 | |
| 217 | 217 | /* |
| 218 | 218 | * Require the Entity annotation cleanup module. |
| 219 | 219 | * |
| 220 | 220 | * @since 3.34.6 |
| 221 | 221 | */ |
| 222 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php'; |
|
| 222 | + require_once plugin_dir_path(__FILE__).'wordlift/cleanup/index.php'; |
|
| 223 | 223 | |
| 224 | 224 | /* |
| 225 | 225 | * Import LOD entities. |
| 226 | 226 | * |
| 227 | 227 | * @since 3.35.0 |
| 228 | 228 | */ |
| 229 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php'; |
|
| 229 | + require_once plugin_dir_path(__FILE__).'wordlift/lod-import/index.php'; |
|
| 230 | 230 | |
| 231 | 231 | } |
| 232 | 232 | ); |
@@ -244,23 +244,23 @@ discard block |
||
| 244 | 244 | function wordlift_plugin_autoload_register() { |
| 245 | 245 | |
| 246 | 246 | spl_autoload_register( |
| 247 | - function ( $class_name ) { |
|
| 247 | + function($class_name) { |
|
| 248 | 248 | |
| 249 | 249 | // Bail out if these are not our classes. |
| 250 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 250 | + if (0 !== strpos($class_name, 'Wordlift\\')) { |
|
| 251 | 251 | return false; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 254 | + $class_name_lc = strtolower(str_replace('_', '-', $class_name)); |
|
| 255 | 255 | |
| 256 | - preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 256 | + preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches); |
|
| 257 | 257 | |
| 258 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 259 | - $file = 'class-' . $matches[2] . '.php'; |
|
| 258 | + $path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]); |
|
| 259 | + $file = 'class-'.$matches[2].'.php'; |
|
| 260 | 260 | |
| 261 | - $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
| 261 | + $full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file; |
|
| 262 | 262 | |
| 263 | - if ( ! file_exists( $full_path ) ) { |
|
| 263 | + if ( ! file_exists($full_path)) { |
|
| 264 | 264 | return false; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | -function wl_block_categories( $categories ) { |
|
| 275 | +function wl_block_categories($categories) { |
|
| 276 | 276 | return array_merge( |
| 277 | 277 | $categories, |
| 278 | 278 | array( |
| 279 | 279 | array( |
| 280 | 280 | 'slug' => 'wordlift', |
| 281 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
| 281 | + 'title' => __('WordLift', 'wordlift'), |
|
| 282 | 282 | ), |
| 283 | 283 | ) |
| 284 | 284 | ); |
@@ -288,48 +288,48 @@ discard block |
||
| 288 | 288 | * This function is created temporarily to handle the legacy library, |
| 289 | 289 | * this has to be removed when removing the legacy fields from the ui. |
| 290 | 290 | */ |
| 291 | -function wl_enqueue_leaflet( $in_footer = false ) { |
|
| 291 | +function wl_enqueue_leaflet($in_footer = false) { |
|
| 292 | 292 | // Leaflet. |
| 293 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
| 294 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
| 293 | + wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0'); |
|
| 294 | + wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | -add_filter( 'block_categories', 'wl_block_categories', 10 ); |
|
| 297 | +add_filter('block_categories', 'wl_block_categories', 10); |
|
| 298 | 298 | |
| 299 | 299 | // Temporary fix for a typo in WooCommerce Extension. |
| 300 | 300 | add_filter( |
| 301 | 301 | 'wl_feature__enable__dataset', |
| 302 | - function ( $value ) { |
|
| 303 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
| 302 | + function($value) { |
|
| 303 | + return apply_filters('wl_features__enable__dataset', $value); |
|
| 304 | 304 | } |
| 305 | 305 | ); |
| 306 | 306 | |
| 307 | -require_once __DIR__ . '/modules/food-kg/load.php'; |
|
| 308 | -require_once __DIR__ . '/modules/gardening-kg/load.php'; |
|
| 309 | -require_once __DIR__ . '/modules/acf4so/load.php'; |
|
| 310 | -require_once __DIR__ . '/modules/dashboard/load.php'; |
|
| 311 | -require_once __DIR__ . '/modules/pods/load.php'; |
|
| 312 | -require_once __DIR__ . '/modules/include-exclude-push-config/load.php'; |
|
| 313 | -require_once __DIR__ . '/modules/super-resolution/load.php'; |
|
| 314 | -require_once __DIR__ . '/modules/redeem-code/load.php'; |
|
| 315 | -require_once __DIR__ . '/modules/raptive-setup/load.php'; |
|
| 316 | - |
|
| 317 | -function _wl_update_plugins_raptive_domain( $update, $plugin_data, $plugin_file ) { |
|
| 307 | +require_once __DIR__.'/modules/food-kg/load.php'; |
|
| 308 | +require_once __DIR__.'/modules/gardening-kg/load.php'; |
|
| 309 | +require_once __DIR__.'/modules/acf4so/load.php'; |
|
| 310 | +require_once __DIR__.'/modules/dashboard/load.php'; |
|
| 311 | +require_once __DIR__.'/modules/pods/load.php'; |
|
| 312 | +require_once __DIR__.'/modules/include-exclude-push-config/load.php'; |
|
| 313 | +require_once __DIR__.'/modules/super-resolution/load.php'; |
|
| 314 | +require_once __DIR__.'/modules/redeem-code/load.php'; |
|
| 315 | +require_once __DIR__.'/modules/raptive-setup/load.php'; |
|
| 316 | + |
|
| 317 | +function _wl_update_plugins_raptive_domain($update, $plugin_data, $plugin_file) { |
|
| 318 | 318 | // Bail out if it's not our plugin. |
| 319 | 319 | $update_uri = $plugin_data['UpdateURI']; |
| 320 | - if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
| 320 | + if ('wordlift/wordlift.php' !== $plugin_file || ! isset($update_uri)) { |
|
| 321 | 321 | return $update; |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
| 324 | + $response = wp_remote_get("$update_uri?nocache=".time()); |
|
| 325 | 325 | |
| 326 | - if ( is_wp_error( $response ) ) { |
|
| 326 | + if (is_wp_error($response)) { |
|
| 327 | 327 | return $update; |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | try { |
| 331 | - return json_decode( wp_remote_retrieve_body( $response ) ); |
|
| 332 | - } catch ( Exception $e ) { |
|
| 331 | + return json_decode(wp_remote_retrieve_body($response)); |
|
| 332 | + } catch (Exception $e) { |
|
| 333 | 333 | return $update; |
| 334 | 334 | } |
| 335 | 335 | } |
@@ -9,15 +9,15 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | // Exit if this is not a Raptive install. |
| 11 | 11 | if ( ! defined( 'WL_RAPTIVE' ) || ! WL_RAPTIVE ) { |
| 12 | - return; |
|
| 12 | + return; |
|
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | function __wl_raptive_admin_setup() { |
| 16 | 16 | |
| 17 | - wp_print_scripts( WL_ANGULAR_APP_SCRIPT_HANDLE ); |
|
| 18 | - $iframe_src = WL_ANGULAR_APP_URL . '#/raptive/setup/welcome'; |
|
| 19 | - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 20 | - echo " |
|
| 17 | + wp_print_scripts( WL_ANGULAR_APP_SCRIPT_HANDLE ); |
|
| 18 | + $iframe_src = WL_ANGULAR_APP_URL . '#/raptive/setup/welcome'; |
|
| 19 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
| 20 | + echo " |
|
| 21 | 21 | <style> |
| 22 | 22 | #wlx-plugin-app { |
| 23 | 23 | border: 0; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | <iframe id='wlx-plugin-app' src='$iframe_src'></iframe> |
| 34 | 34 | "; |
| 35 | 35 | |
| 36 | - exit; |
|
| 36 | + exit; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | add_action( 'wl_admin_setup__pre', '__wl_raptive_admin_setup' ); |
@@ -8,14 +8,14 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | // Exit if this is not a Raptive install. |
| 11 | -if ( ! defined( 'WL_RAPTIVE' ) || ! WL_RAPTIVE ) { |
|
| 11 | +if ( ! defined('WL_RAPTIVE') || ! WL_RAPTIVE) { |
|
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | function __wl_raptive_admin_setup() { |
| 16 | 16 | |
| 17 | - wp_print_scripts( WL_ANGULAR_APP_SCRIPT_HANDLE ); |
|
| 18 | - $iframe_src = WL_ANGULAR_APP_URL . '#/raptive/setup/welcome'; |
|
| 17 | + wp_print_scripts(WL_ANGULAR_APP_SCRIPT_HANDLE); |
|
| 18 | + $iframe_src = WL_ANGULAR_APP_URL.'#/raptive/setup/welcome'; |
|
| 19 | 19 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 20 | 20 | echo " |
| 21 | 21 | <style> |
@@ -36,4 +36,4 @@ discard block |
||
| 36 | 36 | exit; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -add_action( 'wl_admin_setup__pre', '__wl_raptive_admin_setup' ); |
|
| 39 | +add_action('wl_admin_setup__pre', '__wl_raptive_admin_setup'); |
|
@@ -14,36 +14,36 @@ |
||
| 14 | 14 | use Wordlift\Modules\Common\Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
| 15 | 15 | |
| 16 | 16 | if ( ! defined( 'WL_ANGULAR_APP_URL' ) ) { |
| 17 | - define( 'WL_ANGULAR_APP_URL', esc_url( plugin_dir_url( __DIR__ ) . 'app/app/iframe.html' ) . '?v=' . WORDLIFT_VERSION ); |
|
| 17 | + define( 'WL_ANGULAR_APP_URL', esc_url( plugin_dir_url( __DIR__ ) . 'app/app/iframe.html' ) . '?v=' . WORDLIFT_VERSION ); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | if ( ! defined( 'WL_ANGULAR_APP_SCRIPT_HANDLE' ) ) { |
| 21 | - define( 'WL_ANGULAR_APP_SCRIPT_HANDLE', 'wl-angular-app' ); |
|
| 21 | + define( 'WL_ANGULAR_APP_SCRIPT_HANDLE', 'wl-angular-app' ); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | function __wl_app__init() { |
| 25 | 25 | |
| 26 | - // Load the rest of the module only on admin calls. |
|
| 27 | - if ( ! is_admin() ) { |
|
| 28 | - return; |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - // Autoloader for plugin itself. |
|
| 32 | - if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 33 | - require_once __DIR__ . '/vendor/autoload.php'; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var $app Plugin_App |
|
| 38 | - */ |
|
| 39 | - $container_builder = new ContainerBuilder(); |
|
| 40 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 41 | - $loader->load( 'services.yml' ); |
|
| 42 | - $container_builder->compile(); |
|
| 43 | - |
|
| 44 | - /** @var Plugin_App $app */ |
|
| 45 | - $app = $container_builder->get( Plugin_App::class ); |
|
| 46 | - $app->register_handle(); |
|
| 26 | + // Load the rest of the module only on admin calls. |
|
| 27 | + if ( ! is_admin() ) { |
|
| 28 | + return; |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + // Autoloader for plugin itself. |
|
| 32 | + if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 33 | + require_once __DIR__ . '/vendor/autoload.php'; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var $app Plugin_App |
|
| 38 | + */ |
|
| 39 | + $container_builder = new ContainerBuilder(); |
|
| 40 | + $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 41 | + $loader->load( 'services.yml' ); |
|
| 42 | + $container_builder->compile(); |
|
| 43 | + |
|
| 44 | + /** @var Plugin_App $app */ |
|
| 45 | + $app = $container_builder->get( Plugin_App::class ); |
|
| 46 | + $app->register_handle(); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | add_action( 'init', '__wl_app__init' ); |
@@ -13,38 +13,38 @@ |
||
| 13 | 13 | use Wordlift\Modules\Common\Symfony\Component\DependencyInjection\ContainerBuilder; |
| 14 | 14 | use Wordlift\Modules\Common\Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
| 15 | 15 | |
| 16 | -if ( ! defined( 'WL_ANGULAR_APP_URL' ) ) { |
|
| 17 | - define( 'WL_ANGULAR_APP_URL', esc_url( plugin_dir_url( __DIR__ ) . 'app/app/iframe.html' ) . '?v=' . WORDLIFT_VERSION ); |
|
| 16 | +if ( ! defined('WL_ANGULAR_APP_URL')) { |
|
| 17 | + define('WL_ANGULAR_APP_URL', esc_url(plugin_dir_url(__DIR__).'app/app/iframe.html').'?v='.WORDLIFT_VERSION); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -if ( ! defined( 'WL_ANGULAR_APP_SCRIPT_HANDLE' ) ) { |
|
| 21 | - define( 'WL_ANGULAR_APP_SCRIPT_HANDLE', 'wl-angular-app' ); |
|
| 20 | +if ( ! defined('WL_ANGULAR_APP_SCRIPT_HANDLE')) { |
|
| 21 | + define('WL_ANGULAR_APP_SCRIPT_HANDLE', 'wl-angular-app'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | function __wl_app__init() { |
| 25 | 25 | |
| 26 | 26 | // Load the rest of the module only on admin calls. |
| 27 | - if ( ! is_admin() ) { |
|
| 27 | + if ( ! is_admin()) { |
|
| 28 | 28 | return; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // Autoloader for plugin itself. |
| 32 | - if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 33 | - require_once __DIR__ . '/vendor/autoload.php'; |
|
| 32 | + if (file_exists(__DIR__.'/vendor/autoload.php')) { |
|
| 33 | + require_once __DIR__.'/vendor/autoload.php'; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @var $app Plugin_App |
| 38 | 38 | */ |
| 39 | 39 | $container_builder = new ContainerBuilder(); |
| 40 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 41 | - $loader->load( 'services.yml' ); |
|
| 40 | + $loader = new YamlFileLoader($container_builder, new FileLocator(__DIR__)); |
|
| 41 | + $loader->load('services.yml'); |
|
| 42 | 42 | $container_builder->compile(); |
| 43 | 43 | |
| 44 | 44 | /** @var Plugin_App $app */ |
| 45 | - $app = $container_builder->get( Plugin_App::class ); |
|
| 45 | + $app = $container_builder->get(Plugin_App::class); |
|
| 46 | 46 | $app->register_handle(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | -add_action( 'init', '__wl_app__init' ); |
|
| 49 | +add_action('init', '__wl_app__init'); |
|
| 50 | 50 | |
@@ -4,41 +4,41 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Plugin_App { |
| 6 | 6 | |
| 7 | - public function register_handle() { |
|
| 7 | + public function register_handle() { |
|
| 8 | 8 | |
| 9 | - wp_register_script( |
|
| 10 | - WL_ANGULAR_APP_SCRIPT_HANDLE, |
|
| 11 | - plugin_dir_url( __DIR__ ) . 'js/app.js', |
|
| 12 | - array(), |
|
| 13 | - WORDLIFT_VERSION, |
|
| 14 | - true |
|
| 15 | - ); |
|
| 16 | - $settings = wp_json_encode( $this->get_settings() ); |
|
| 17 | - wp_add_inline_script( WL_ANGULAR_APP_SCRIPT_HANDLE, "var _wlPluginAppSettings = {$settings};" ); |
|
| 9 | + wp_register_script( |
|
| 10 | + WL_ANGULAR_APP_SCRIPT_HANDLE, |
|
| 11 | + plugin_dir_url( __DIR__ ) . 'js/app.js', |
|
| 12 | + array(), |
|
| 13 | + WORDLIFT_VERSION, |
|
| 14 | + true |
|
| 15 | + ); |
|
| 16 | + $settings = wp_json_encode( $this->get_settings() ); |
|
| 17 | + wp_add_inline_script( WL_ANGULAR_APP_SCRIPT_HANDLE, "var _wlPluginAppSettings = {$settings};" ); |
|
| 18 | 18 | |
| 19 | - // add_action( |
|
| 20 | - // 'admin_enqueue_scripts', |
|
| 21 | - // array( $this, 'print_settings' ), |
|
| 22 | - // PHP_INT_MAX // This hook is running at last because we want to check if it was enqueued. |
|
| 23 | - // ); |
|
| 24 | - } |
|
| 19 | + // add_action( |
|
| 20 | + // 'admin_enqueue_scripts', |
|
| 21 | + // array( $this, 'print_settings' ), |
|
| 22 | + // PHP_INT_MAX // This hook is running at last because we want to check if it was enqueued. |
|
| 23 | + // ); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @return mixed|null |
|
| 28 | - */ |
|
| 29 | - private function get_settings() { |
|
| 30 | - return apply_filters( |
|
| 31 | - 'wl_plugin_app_settings', |
|
| 32 | - array( |
|
| 33 | - // @see https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/ |
|
| 34 | - 'wp_api_nonce' => wp_create_nonce( 'wp_rest' ), |
|
| 35 | - 'wp_api_base' => untrailingslashit( rest_url() ), |
|
| 36 | - // Load wordlift api url and key. |
|
| 37 | - 'wl_api_base' => apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ), |
|
| 38 | - 'wl_api_key' => \Wordlift_Configuration_Service::get_instance()->get_key(), |
|
| 39 | - 'wl_dashboard_link' => admin_url( 'admin.php?page=wl_admin_menu' ), |
|
| 40 | - ) |
|
| 41 | - ); |
|
| 42 | - } |
|
| 26 | + /** |
|
| 27 | + * @return mixed|null |
|
| 28 | + */ |
|
| 29 | + private function get_settings() { |
|
| 30 | + return apply_filters( |
|
| 31 | + 'wl_plugin_app_settings', |
|
| 32 | + array( |
|
| 33 | + // @see https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/ |
|
| 34 | + 'wp_api_nonce' => wp_create_nonce( 'wp_rest' ), |
|
| 35 | + 'wp_api_base' => untrailingslashit( rest_url() ), |
|
| 36 | + // Load wordlift api url and key. |
|
| 37 | + 'wl_api_base' => apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ), |
|
| 38 | + 'wl_api_key' => \Wordlift_Configuration_Service::get_instance()->get_key(), |
|
| 39 | + 'wl_dashboard_link' => admin_url( 'admin.php?page=wl_admin_menu' ), |
|
| 40 | + ) |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | } |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | wp_register_script( |
| 10 | 10 | WL_ANGULAR_APP_SCRIPT_HANDLE, |
| 11 | - plugin_dir_url( __DIR__ ) . 'js/app.js', |
|
| 11 | + plugin_dir_url(__DIR__).'js/app.js', |
|
| 12 | 12 | array(), |
| 13 | 13 | WORDLIFT_VERSION, |
| 14 | 14 | true |
| 15 | 15 | ); |
| 16 | - $settings = wp_json_encode( $this->get_settings() ); |
|
| 17 | - wp_add_inline_script( WL_ANGULAR_APP_SCRIPT_HANDLE, "var _wlPluginAppSettings = {$settings};" ); |
|
| 16 | + $settings = wp_json_encode($this->get_settings()); |
|
| 17 | + wp_add_inline_script(WL_ANGULAR_APP_SCRIPT_HANDLE, "var _wlPluginAppSettings = {$settings};"); |
|
| 18 | 18 | |
| 19 | 19 | // add_action( |
| 20 | 20 | // 'admin_enqueue_scripts', |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | 'wl_plugin_app_settings', |
| 32 | 32 | array( |
| 33 | 33 | // @see https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/ |
| 34 | - 'wp_api_nonce' => wp_create_nonce( 'wp_rest' ), |
|
| 35 | - 'wp_api_base' => untrailingslashit( rest_url() ), |
|
| 34 | + 'wp_api_nonce' => wp_create_nonce('wp_rest'), |
|
| 35 | + 'wp_api_base' => untrailingslashit(rest_url()), |
|
| 36 | 36 | // Load wordlift api url and key. |
| 37 | - 'wl_api_base' => apply_filters( 'wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE ), |
|
| 37 | + 'wl_api_base' => apply_filters('wl_api_base_url', WL_CONFIG_WORDLIFT_API_URL_DEFAULT_VALUE), |
|
| 38 | 38 | 'wl_api_key' => \Wordlift_Configuration_Service::get_instance()->get_key(), |
| 39 | - 'wl_dashboard_link' => admin_url( 'admin.php?page=wl_admin_menu' ), |
|
| 39 | + 'wl_dashboard_link' => admin_url('admin.php?page=wl_admin_menu'), |
|
| 40 | 40 | ) |
| 41 | 41 | ); |
| 42 | 42 | } |
@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | 5 | if (PHP_VERSION_ID < 50600) { |
| 6 | - if (!headers_sent()) { |
|
| 6 | + if ( ! headers_sent()) { |
|
| 7 | 7 | header('HTTP/1.1 500 Internal Server Error'); |
| 8 | 8 | } |
| 9 | 9 | $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; |
| 10 | - if (!ini_get('display_errors')) { |
|
| 10 | + if ( ! ini_get('display_errors')) { |
|
| 11 | 11 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
| 12 | 12 | fwrite(STDERR, $err); |
| 13 | - } elseif (!headers_sent()) { |
|
| 13 | + } elseif ( ! headers_sent()) { |
|
| 14 | 14 | echo $err; |
| 15 | 15 | } |
| 16 | 16 | } |
@@ -20,6 +20,6 @@ discard block |
||
| 20 | 20 | ); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 23 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 24 | 24 | |
| 25 | 25 | return ComposerAutoloaderInit74415885e7c3fa89b174bf8bc3b1fc6d::getLoader(); |
@@ -4,23 +4,23 @@ |
||
| 4 | 4 | |
| 5 | 5 | $issues = array(); |
| 6 | 6 | |
| 7 | -if (!(PHP_VERSION_ID >= 50600)) { |
|
| 8 | - $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.'; |
|
| 7 | +if ( ! (PHP_VERSION_ID >= 50600)) { |
|
| 8 | + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running '.PHP_VERSION.'.'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | if ($issues) { |
| 12 | - if (!headers_sent()) { |
|
| 12 | + if ( ! headers_sent()) { |
|
| 13 | 13 | header('HTTP/1.1 500 Internal Server Error'); |
| 14 | 14 | } |
| 15 | - if (!ini_get('display_errors')) { |
|
| 15 | + if ( ! ini_get('display_errors')) { |
|
| 16 | 16 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
| 17 | - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); |
|
| 18 | - } elseif (!headers_sent()) { |
|
| 19 | - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; |
|
| 17 | + fwrite(STDERR, 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.implode(PHP_EOL, $issues).PHP_EOL.PHP_EOL); |
|
| 18 | + } elseif ( ! headers_sent()) { |
|
| 19 | + echo 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)).PHP_EOL.PHP_EOL; |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | trigger_error( |
| 23 | - 'Composer detected issues in your platform: ' . implode(' ', $issues), |
|
| 23 | + 'Composer detected issues in your platform: '.implode(' ', $issues), |
|
| 24 | 24 | E_USER_ERROR |
| 25 | 25 | ); |
| 26 | 26 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getPrefixes() |
| 115 | 115 | { |
| 116 | - if (!empty($this->prefixesPsr0)) { |
|
| 116 | + if ( ! empty($this->prefixesPsr0)) { |
|
| 117 | 117 | return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function add($prefix, $paths, $prepend = false) |
| 185 | 185 | { |
| 186 | - if (!$prefix) { |
|
| 186 | + if ( ! $prefix) { |
|
| 187 | 187 | if ($prepend) { |
| 188 | 188 | $this->fallbackDirsPsr0 = array_merge( |
| 189 | 189 | (array) $paths, |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $first = $prefix[0]; |
| 203 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 203 | + if ( ! isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 204 | 204 | $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
| 205 | 205 | |
| 206 | 206 | return; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function addPsr4($prefix, $paths, $prepend = false) |
| 234 | 234 | { |
| 235 | - if (!$prefix) { |
|
| 235 | + if ( ! $prefix) { |
|
| 236 | 236 | // Register directories for the root namespace. |
| 237 | 237 | if ($prepend) { |
| 238 | 238 | $this->fallbackDirsPsr4 = array_merge( |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | (array) $paths |
| 246 | 246 | ); |
| 247 | 247 | } |
| 248 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
| 248 | + } elseif ( ! isset($this->prefixDirsPsr4[$prefix])) { |
|
| 249 | 249 | // Register directories for a new namespace. |
| 250 | 250 | $length = strlen($prefix); |
| 251 | 251 | if ('\\' !== $prefix[$length - 1]) { |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public function set($prefix, $paths) |
| 281 | 281 | { |
| 282 | - if (!$prefix) { |
|
| 282 | + if ( ! $prefix) { |
|
| 283 | 283 | $this->fallbackDirsPsr0 = (array) $paths; |
| 284 | 284 | } else { |
| 285 | 285 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | public function setPsr4($prefix, $paths) |
| 301 | 301 | { |
| 302 | - if (!$prefix) { |
|
| 302 | + if ( ! $prefix) { |
|
| 303 | 303 | $this->fallbackDirsPsr4 = (array) $paths; |
| 304 | 304 | } else { |
| 305 | 305 | $length = strlen($prefix); |
@@ -493,18 +493,18 @@ discard block |
||
| 493 | 493 | private function findFileWithExtension($class, $ext) |
| 494 | 494 | { |
| 495 | 495 | // PSR-4 lookup |
| 496 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 496 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 497 | 497 | |
| 498 | 498 | $first = $class[0]; |
| 499 | 499 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 500 | 500 | $subPath = $class; |
| 501 | 501 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 502 | 502 | $subPath = substr($subPath, 0, $lastPos); |
| 503 | - $search = $subPath . '\\'; |
|
| 503 | + $search = $subPath.'\\'; |
|
| 504 | 504 | if (isset($this->prefixDirsPsr4[$search])) { |
| 505 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 505 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 506 | 506 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 507 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 507 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 508 | 508 | return $file; |
| 509 | 509 | } |
| 510 | 510 | } |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | // PSR-4 fallback dirs |
| 516 | 516 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 517 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 517 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 518 | 518 | return $file; |
| 519 | 519 | } |
| 520 | 520 | } |
@@ -526,14 +526,14 @@ discard block |
||
| 526 | 526 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 527 | 527 | } else { |
| 528 | 528 | // PEAR-like class name |
| 529 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 529 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | if (isset($this->prefixesPsr0[$first])) { |
| 533 | 533 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 534 | 534 | if (0 === strpos($class, $prefix)) { |
| 535 | 535 | foreach ($dirs as $dir) { |
| 536 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 536 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 537 | 537 | return $file; |
| 538 | 538 | } |
| 539 | 539 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | // PSR-0 fallback dirs |
| 545 | 545 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 546 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 546 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 547 | 547 | return $file; |
| 548 | 548 | } |
| 549 | 549 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | 'version' => 'dev-develop', |
| 6 | 6 | 'reference' => '342dc6c9834a4b69989f21261c9e3f1df5707a66', |
| 7 | 7 | 'type' => 'wordpress-plugin', |
| 8 | - 'install_path' => __DIR__ . '/../../', |
|
| 8 | + 'install_path' => __DIR__.'/../../', |
|
| 9 | 9 | 'aliases' => array(), |
| 10 | 10 | 'dev' => true, |
| 11 | 11 | ), |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | 'version' => 'dev-develop', |
| 16 | 16 | 'reference' => '342dc6c9834a4b69989f21261c9e3f1df5707a66', |
| 17 | 17 | 'type' => 'wordpress-plugin', |
| 18 | - 'install_path' => __DIR__ . '/../../', |
|
| 18 | + 'install_path' => __DIR__.'/../../', |
|
| 19 | 19 | 'aliases' => array(), |
| 20 | 20 | 'dev_requirement' => false, |
| 21 | 21 | ), |