@@ -16,78 +16,78 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class Plugin_Enabled { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Register hooks. |
|
| 21 | - */ |
|
| 22 | - public function register_hooks() { |
|
| 23 | - add_filter( 'wl_is_enabled', array( $this, 'wl_is_enabled' ) ); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * Enable/Disable WordLift Plugin. |
|
| 28 | - * |
|
| 29 | - * @param $enabled |
|
| 30 | - * |
|
| 31 | - * @return bool|mixed |
|
| 32 | - */ |
|
| 33 | - public function wl_is_enabled( $enabled ) { |
|
| 34 | - |
|
| 35 | - // Always enable wordlift on admin and rest api pages. |
|
| 36 | - if ( is_admin() || $this->is_rest_request() ) { |
|
| 37 | - return $enabled; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - $path = strtok( (string) $_SERVER['REQUEST_URI'], '?' ); // phpcs:ignore |
|
| 41 | - $options = get_option( 'wl_exclude_include_urls_settings' ); |
|
| 42 | - $current_url = trailingslashit( home_url( $path ) ); |
|
| 43 | - |
|
| 44 | - // Bail out if URLs are not set. |
|
| 45 | - if ( empty( $options['urls'] ) ) { |
|
| 46 | - return $enabled; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - // Set a default state. |
|
| 50 | - $default_state = ( $options['include_exclude'] === 'exclude' ); |
|
| 51 | - |
|
| 52 | - // Get URLs into an array from settings, trim them and make absolute if needed. |
|
| 53 | - $urls = array_map( |
|
| 54 | - function ( $url ) { |
|
| 55 | - $url = trim( $url ); |
|
| 56 | - if ( substr( $url, 0, 4 ) !== 'http' ) { |
|
| 57 | - return trailingslashit( home_url( $url ) ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - // Add a trailing slash and return the url |
|
| 61 | - return trailingslashit( $url ); |
|
| 62 | - }, |
|
| 63 | - explode( PHP_EOL, $options['urls'] ) |
|
| 64 | - ); |
|
| 65 | - |
|
| 66 | - foreach ( $urls as $url ) { |
|
| 67 | - if ( $url === $current_url ) { |
|
| 68 | - return ! $default_state; |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return $default_state; |
|
| 73 | - |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * We cant rely on WP_REST_REQUEST constant here since it is loaded after init hook |
|
| 78 | - * |
|
| 79 | - * @return bool |
|
| 80 | - */ |
|
| 81 | - protected function is_rest_request() { |
|
| 82 | - if ( empty( $_SERVER['REQUEST_URI'] ) ) { |
|
| 83 | - // Probably a CLI request. |
|
| 84 | - return false; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $rest_prefix = trailingslashit( rest_get_url_prefix() ); |
|
| 88 | - $path = strtok( (string) $_SERVER['REQUEST_URI'], '?' ); // phpcs:ignore |
|
| 89 | - |
|
| 90 | - return strpos( $path, $rest_prefix ) !== false; |
|
| 91 | - } |
|
| 19 | + /** |
|
| 20 | + * Register hooks. |
|
| 21 | + */ |
|
| 22 | + public function register_hooks() { |
|
| 23 | + add_filter( 'wl_is_enabled', array( $this, 'wl_is_enabled' ) ); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * Enable/Disable WordLift Plugin. |
|
| 28 | + * |
|
| 29 | + * @param $enabled |
|
| 30 | + * |
|
| 31 | + * @return bool|mixed |
|
| 32 | + */ |
|
| 33 | + public function wl_is_enabled( $enabled ) { |
|
| 34 | + |
|
| 35 | + // Always enable wordlift on admin and rest api pages. |
|
| 36 | + if ( is_admin() || $this->is_rest_request() ) { |
|
| 37 | + return $enabled; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + $path = strtok( (string) $_SERVER['REQUEST_URI'], '?' ); // phpcs:ignore |
|
| 41 | + $options = get_option( 'wl_exclude_include_urls_settings' ); |
|
| 42 | + $current_url = trailingslashit( home_url( $path ) ); |
|
| 43 | + |
|
| 44 | + // Bail out if URLs are not set. |
|
| 45 | + if ( empty( $options['urls'] ) ) { |
|
| 46 | + return $enabled; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + // Set a default state. |
|
| 50 | + $default_state = ( $options['include_exclude'] === 'exclude' ); |
|
| 51 | + |
|
| 52 | + // Get URLs into an array from settings, trim them and make absolute if needed. |
|
| 53 | + $urls = array_map( |
|
| 54 | + function ( $url ) { |
|
| 55 | + $url = trim( $url ); |
|
| 56 | + if ( substr( $url, 0, 4 ) !== 'http' ) { |
|
| 57 | + return trailingslashit( home_url( $url ) ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + // Add a trailing slash and return the url |
|
| 61 | + return trailingslashit( $url ); |
|
| 62 | + }, |
|
| 63 | + explode( PHP_EOL, $options['urls'] ) |
|
| 64 | + ); |
|
| 65 | + |
|
| 66 | + foreach ( $urls as $url ) { |
|
| 67 | + if ( $url === $current_url ) { |
|
| 68 | + return ! $default_state; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return $default_state; |
|
| 73 | + |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * We cant rely on WP_REST_REQUEST constant here since it is loaded after init hook |
|
| 78 | + * |
|
| 79 | + * @return bool |
|
| 80 | + */ |
|
| 81 | + protected function is_rest_request() { |
|
| 82 | + if ( empty( $_SERVER['REQUEST_URI'] ) ) { |
|
| 83 | + // Probably a CLI request. |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $rest_prefix = trailingslashit( rest_get_url_prefix() ); |
|
| 88 | + $path = strtok( (string) $_SERVER['REQUEST_URI'], '?' ); // phpcs:ignore |
|
| 89 | + |
|
| 90 | + return strpos( $path, $rest_prefix ) !== false; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * Register hooks. |
| 21 | 21 | */ |
| 22 | 22 | public function register_hooks() { |
| 23 | - add_filter( 'wl_is_enabled', array( $this, 'wl_is_enabled' ) ); |
|
| 23 | + add_filter('wl_is_enabled', array($this, 'wl_is_enabled')); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -30,41 +30,41 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return bool|mixed |
| 32 | 32 | */ |
| 33 | - public function wl_is_enabled( $enabled ) { |
|
| 33 | + public function wl_is_enabled($enabled) { |
|
| 34 | 34 | |
| 35 | 35 | // Always enable wordlift on admin and rest api pages. |
| 36 | - if ( is_admin() || $this->is_rest_request() ) { |
|
| 36 | + if (is_admin() || $this->is_rest_request()) { |
|
| 37 | 37 | return $enabled; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - $path = strtok( (string) $_SERVER['REQUEST_URI'], '?' ); // phpcs:ignore |
|
| 41 | - $options = get_option( 'wl_exclude_include_urls_settings' ); |
|
| 42 | - $current_url = trailingslashit( home_url( $path ) ); |
|
| 40 | + $path = strtok((string) $_SERVER['REQUEST_URI'], '?'); // phpcs:ignore |
|
| 41 | + $options = get_option('wl_exclude_include_urls_settings'); |
|
| 42 | + $current_url = trailingslashit(home_url($path)); |
|
| 43 | 43 | |
| 44 | 44 | // Bail out if URLs are not set. |
| 45 | - if ( empty( $options['urls'] ) ) { |
|
| 45 | + if (empty($options['urls'])) { |
|
| 46 | 46 | return $enabled; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // Set a default state. |
| 50 | - $default_state = ( $options['include_exclude'] === 'exclude' ); |
|
| 50 | + $default_state = ($options['include_exclude'] === 'exclude'); |
|
| 51 | 51 | |
| 52 | 52 | // Get URLs into an array from settings, trim them and make absolute if needed. |
| 53 | 53 | $urls = array_map( |
| 54 | - function ( $url ) { |
|
| 55 | - $url = trim( $url ); |
|
| 56 | - if ( substr( $url, 0, 4 ) !== 'http' ) { |
|
| 57 | - return trailingslashit( home_url( $url ) ); |
|
| 54 | + function($url) { |
|
| 55 | + $url = trim($url); |
|
| 56 | + if (substr($url, 0, 4) !== 'http') { |
|
| 57 | + return trailingslashit(home_url($url)); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // Add a trailing slash and return the url |
| 61 | - return trailingslashit( $url ); |
|
| 61 | + return trailingslashit($url); |
|
| 62 | 62 | }, |
| 63 | - explode( PHP_EOL, $options['urls'] ) |
|
| 63 | + explode(PHP_EOL, $options['urls']) |
|
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | - foreach ( $urls as $url ) { |
|
| 67 | - if ( $url === $current_url ) { |
|
| 66 | + foreach ($urls as $url) { |
|
| 67 | + if ($url === $current_url) { |
|
| 68 | 68 | return ! $default_state; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -79,15 +79,15 @@ discard block |
||
| 79 | 79 | * @return bool |
| 80 | 80 | */ |
| 81 | 81 | protected function is_rest_request() { |
| 82 | - if ( empty( $_SERVER['REQUEST_URI'] ) ) { |
|
| 82 | + if (empty($_SERVER['REQUEST_URI'])) { |
|
| 83 | 83 | // Probably a CLI request. |
| 84 | 84 | return false; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - $rest_prefix = trailingslashit( rest_get_url_prefix() ); |
|
| 88 | - $path = strtok( (string) $_SERVER['REQUEST_URI'], '?' ); // phpcs:ignore |
|
| 87 | + $rest_prefix = trailingslashit(rest_get_url_prefix()); |
|
| 88 | + $path = strtok((string) $_SERVER['REQUEST_URI'], '?'); // phpcs:ignore |
|
| 89 | 89 | |
| 90 | - return strpos( $path, $rest_prefix ) !== false; |
|
| 90 | + return strpos($path, $rest_prefix) !== false; |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | } |
@@ -4,80 +4,80 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Ingredients_API { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * Ingredients Service. |
|
| 9 | - * |
|
| 10 | - * @var \Wordlift\Modules\Food_Kg\Services\Ingredients $ingredients_service The Ingredients Service. |
|
| 11 | - */ |
|
| 12 | - public $ingredients_service; |
|
| 7 | + /** |
|
| 8 | + * Ingredients Service. |
|
| 9 | + * |
|
| 10 | + * @var \Wordlift\Modules\Food_Kg\Services\Ingredients $ingredients_service The Ingredients Service. |
|
| 11 | + */ |
|
| 12 | + public $ingredients_service; |
|
| 13 | 13 | |
| 14 | - public function __construct( $ingredients_service ) { |
|
| 15 | - $this->ingredients_service = $ingredients_service; |
|
| 16 | - } |
|
| 14 | + public function __construct( $ingredients_service ) { |
|
| 15 | + $this->ingredients_service = $ingredients_service; |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Register Hooks. |
|
| 20 | - */ |
|
| 21 | - public function register_hooks() { |
|
| 22 | - add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
| 23 | - } |
|
| 18 | + /** |
|
| 19 | + * Register Hooks. |
|
| 20 | + */ |
|
| 21 | + public function register_hooks() { |
|
| 22 | + add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Register Routes. |
|
| 27 | - */ |
|
| 28 | - public function register_routes() { |
|
| 29 | - register_rest_route( |
|
| 30 | - WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 31 | - '/ingredients', |
|
| 32 | - array( |
|
| 33 | - 'methods' => \WP_REST_Server::READABLE, |
|
| 34 | - 'callback' => array( $this, 'get_ingredients' ), |
|
| 35 | - 'permission_callback' => function () { |
|
| 36 | - return current_user_can( 'manage_options' ); |
|
| 37 | - }, |
|
| 38 | - 'args' => array( |
|
| 39 | - 'per_page' => array( |
|
| 40 | - 'type' => 'integer', |
|
| 41 | - 'validate_callback' => 'rest_validate_request_arg', |
|
| 42 | - 'default' => 20, |
|
| 43 | - 'minimum' => 1, |
|
| 44 | - 'maximum' => 100, |
|
| 45 | - 'sanitize_callback' => 'absint', |
|
| 46 | - ), |
|
| 47 | - 'page' => array( |
|
| 48 | - 'type' => 'integer', |
|
| 49 | - 'validate_callback' => 'rest_validate_request_arg', |
|
| 50 | - 'default' => 1, |
|
| 51 | - 'sanitize_callback' => 'absint', |
|
| 52 | - ), |
|
| 53 | - 'offset' => array( |
|
| 54 | - 'type' => 'integer', |
|
| 55 | - 'validate_callback' => 'rest_validate_request_arg', |
|
| 56 | - 'sanitize_callback' => 'absint', |
|
| 57 | - ), |
|
| 58 | - ), |
|
| 59 | - ) |
|
| 60 | - ); |
|
| 61 | - } |
|
| 25 | + /** |
|
| 26 | + * Register Routes. |
|
| 27 | + */ |
|
| 28 | + public function register_routes() { |
|
| 29 | + register_rest_route( |
|
| 30 | + WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 31 | + '/ingredients', |
|
| 32 | + array( |
|
| 33 | + 'methods' => \WP_REST_Server::READABLE, |
|
| 34 | + 'callback' => array( $this, 'get_ingredients' ), |
|
| 35 | + 'permission_callback' => function () { |
|
| 36 | + return current_user_can( 'manage_options' ); |
|
| 37 | + }, |
|
| 38 | + 'args' => array( |
|
| 39 | + 'per_page' => array( |
|
| 40 | + 'type' => 'integer', |
|
| 41 | + 'validate_callback' => 'rest_validate_request_arg', |
|
| 42 | + 'default' => 20, |
|
| 43 | + 'minimum' => 1, |
|
| 44 | + 'maximum' => 100, |
|
| 45 | + 'sanitize_callback' => 'absint', |
|
| 46 | + ), |
|
| 47 | + 'page' => array( |
|
| 48 | + 'type' => 'integer', |
|
| 49 | + 'validate_callback' => 'rest_validate_request_arg', |
|
| 50 | + 'default' => 1, |
|
| 51 | + 'sanitize_callback' => 'absint', |
|
| 52 | + ), |
|
| 53 | + 'offset' => array( |
|
| 54 | + 'type' => 'integer', |
|
| 55 | + 'validate_callback' => 'rest_validate_request_arg', |
|
| 56 | + 'sanitize_callback' => 'absint', |
|
| 57 | + ), |
|
| 58 | + ), |
|
| 59 | + ) |
|
| 60 | + ); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Get Ingredients Data. |
|
| 65 | - * |
|
| 66 | - * @param \WP_REST_Request $request The request. |
|
| 67 | - * |
|
| 68 | - * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
|
| 69 | - */ |
|
| 70 | - public function get_ingredients( \WP_REST_Request $request ) { |
|
| 71 | - $per_page = $request['per_page']; |
|
| 72 | - $page = $request['page']; |
|
| 73 | - $offset = $request['offset']; |
|
| 63 | + /** |
|
| 64 | + * Get Ingredients Data. |
|
| 65 | + * |
|
| 66 | + * @param \WP_REST_Request $request The request. |
|
| 67 | + * |
|
| 68 | + * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
|
| 69 | + */ |
|
| 70 | + public function get_ingredients( \WP_REST_Request $request ) { |
|
| 71 | + $per_page = $request['per_page']; |
|
| 72 | + $page = $request['page']; |
|
| 73 | + $offset = $request['offset']; |
|
| 74 | 74 | |
| 75 | - if ( ! isset( $offset ) ) { |
|
| 76 | - $offset = ( $page - 1 ) * $per_page; |
|
| 77 | - } |
|
| 75 | + if ( ! isset( $offset ) ) { |
|
| 76 | + $offset = ( $page - 1 ) * $per_page; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $data = $this->ingredients_service->get_data( $per_page, $offset ); |
|
| 79 | + $data = $this->ingredients_service->get_data( $per_page, $offset ); |
|
| 80 | 80 | |
| 81 | - return rest_ensure_response( $data ); |
|
| 82 | - } |
|
| 81 | + return rest_ensure_response( $data ); |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public $ingredients_service; |
| 13 | 13 | |
| 14 | - public function __construct( $ingredients_service ) { |
|
| 14 | + public function __construct($ingredients_service) { |
|
| 15 | 15 | $this->ingredients_service = $ingredients_service; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * Register Hooks. |
| 20 | 20 | */ |
| 21 | 21 | public function register_hooks() { |
| 22 | - add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
| 22 | + add_action('rest_api_init', array($this, 'register_routes')); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | '/ingredients', |
| 32 | 32 | array( |
| 33 | 33 | 'methods' => \WP_REST_Server::READABLE, |
| 34 | - 'callback' => array( $this, 'get_ingredients' ), |
|
| 35 | - 'permission_callback' => function () { |
|
| 36 | - return current_user_can( 'manage_options' ); |
|
| 34 | + 'callback' => array($this, 'get_ingredients'), |
|
| 35 | + 'permission_callback' => function() { |
|
| 36 | + return current_user_can('manage_options'); |
|
| 37 | 37 | }, |
| 38 | 38 | 'args' => array( |
| 39 | 39 | 'per_page' => array( |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
| 69 | 69 | */ |
| 70 | - public function get_ingredients( \WP_REST_Request $request ) { |
|
| 70 | + public function get_ingredients(\WP_REST_Request $request) { |
|
| 71 | 71 | $per_page = $request['per_page']; |
| 72 | 72 | $page = $request['page']; |
| 73 | 73 | $offset = $request['offset']; |
| 74 | 74 | |
| 75 | - if ( ! isset( $offset ) ) { |
|
| 76 | - $offset = ( $page - 1 ) * $per_page; |
|
| 75 | + if ( ! isset($offset)) { |
|
| 76 | + $offset = ($page - 1) * $per_page; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $data = $this->ingredients_service->get_data( $per_page, $offset ); |
|
| 79 | + $data = $this->ingredients_service->get_data($per_page, $offset); |
|
| 80 | 80 | |
| 81 | - return rest_ensure_response( $data ); |
|
| 81 | + return rest_ensure_response($data); |
|
| 82 | 82 | } |
| 83 | 83 | } |
@@ -4,22 +4,22 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class Download_Ingredients_Data { |
| 6 | 6 | |
| 7 | - public function register_hooks() { |
|
| 8 | - add_action( 'wp_ajax_wl_download_ingredients_data', array( $this, 'wl_download_ingredients_data' ) ); |
|
| 9 | - } |
|
| 7 | + public function register_hooks() { |
|
| 8 | + add_action( 'wp_ajax_wl_download_ingredients_data', array( $this, 'wl_download_ingredients_data' ) ); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function wl_download_ingredients_data() { |
|
| 11 | + public function wl_download_ingredients_data() { |
|
| 12 | 12 | |
| 13 | - check_ajax_referer( 'wl-dl-ingredients-data-nonce' ); |
|
| 13 | + check_ajax_referer( 'wl-dl-ingredients-data-nonce' ); |
|
| 14 | 14 | |
| 15 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
| 16 | - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wordlift' ) ); |
|
| 17 | - } |
|
| 15 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
| 16 | + wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'wordlift' ) ); |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - global $wpdb; |
|
| 19 | + global $wpdb; |
|
| 20 | 20 | |
| 21 | - $items = $wpdb->get_results( |
|
| 22 | - "SELECT p1.ID AS recipe_ID, |
|
| 21 | + $items = $wpdb->get_results( |
|
| 22 | + "SELECT p1.ID AS recipe_ID, |
|
| 23 | 23 | p1.post_title AS recipe_name, |
| 24 | 24 | p2.ID AS post_ID, |
| 25 | 25 | p2.post_title |
@@ -29,62 +29,62 @@ discard block |
||
| 29 | 29 | INNER JOIN $wpdb->postmeta pm2 |
| 30 | 30 | ON pm2.post_ID = pm1.post_ID AND pm2.meta_key = 'wprm_parent_post_id' |
| 31 | 31 | INNER JOIN $wpdb->posts p2" |
| 32 | - // The following ignore rule is used against the `LIKE CONCAT`. We only have const values. |
|
| 33 | - // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery |
|
| 34 | - . " ON p2.post_status = 'publish' AND p2.ID = pm2.meta_value |
|
| 32 | + // The following ignore rule is used against the `LIKE CONCAT`. We only have const values. |
|
| 33 | + // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery |
|
| 34 | + . " ON p2.post_status = 'publish' AND p2.ID = pm2.meta_value |
|
| 35 | 35 | WHERE pm1.meta_key = '_wl_main_ingredient_jsonld'" |
| 36 | - ); |
|
| 37 | - |
|
| 38 | - if ( ! $items ) { |
|
| 39 | - wp_send_json_error( __( 'No main ingredients found.', 'wordlift' ) ); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - // Generate unique filename using current timestamp. |
|
| 43 | - $filename = 'wl-main-ingredients-data-' . gmdate( 'Y-m-d-H-i-s' ) . '.tsv'; |
|
| 44 | - |
|
| 45 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 46 | - header( 'Content-Type: text/text/tab-separated-values; charset=' . get_bloginfo( 'charset' ) ); |
|
| 47 | - |
|
| 48 | - // Do not cache the file. |
|
| 49 | - header( 'Pragma: no-cache' ); |
|
| 50 | - header( 'Expires: 0' ); |
|
| 51 | - |
|
| 52 | - $output = fopen( 'php://output', 'w' ); |
|
| 53 | - |
|
| 54 | - // Insert Header. |
|
| 55 | - fputcsv( |
|
| 56 | - $output, |
|
| 57 | - array( |
|
| 58 | - __( 'Ingredient Name', 'wordlift' ), |
|
| 59 | - __( 'Recipe Name', 'wordlift' ), |
|
| 60 | - __( 'Recipe ID', 'wordlift' ), |
|
| 61 | - __( 'Post Name', 'wordlift' ), |
|
| 62 | - __( 'Post ID', 'wordlift' ), |
|
| 63 | - __( 'Post URL', 'wordlift' ), |
|
| 64 | - ), |
|
| 65 | - "\t" |
|
| 66 | - ); |
|
| 67 | - |
|
| 68 | - // Insert Data. |
|
| 69 | - foreach ( $items as $item ) { |
|
| 70 | - $recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 71 | - $recipe = json_decode( $recipe_json_ld, true ); |
|
| 72 | - fputcsv( |
|
| 73 | - $output, |
|
| 74 | - array( |
|
| 75 | - $recipe ? $recipe['name'] : 'null', |
|
| 76 | - $item->recipe_name, |
|
| 77 | - // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 78 | - $item->recipe_ID, |
|
| 79 | - $item->post_title, |
|
| 80 | - $item->post_ID, |
|
| 81 | - esc_url( get_the_permalink( $item->post_ID ) ), |
|
| 82 | - ), |
|
| 83 | - "\t" |
|
| 84 | - ); |
|
| 85 | - ob_flush(); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - wp_die(); |
|
| 89 | - } |
|
| 36 | + ); |
|
| 37 | + |
|
| 38 | + if ( ! $items ) { |
|
| 39 | + wp_send_json_error( __( 'No main ingredients found.', 'wordlift' ) ); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + // Generate unique filename using current timestamp. |
|
| 43 | + $filename = 'wl-main-ingredients-data-' . gmdate( 'Y-m-d-H-i-s' ) . '.tsv'; |
|
| 44 | + |
|
| 45 | + header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 46 | + header( 'Content-Type: text/text/tab-separated-values; charset=' . get_bloginfo( 'charset' ) ); |
|
| 47 | + |
|
| 48 | + // Do not cache the file. |
|
| 49 | + header( 'Pragma: no-cache' ); |
|
| 50 | + header( 'Expires: 0' ); |
|
| 51 | + |
|
| 52 | + $output = fopen( 'php://output', 'w' ); |
|
| 53 | + |
|
| 54 | + // Insert Header. |
|
| 55 | + fputcsv( |
|
| 56 | + $output, |
|
| 57 | + array( |
|
| 58 | + __( 'Ingredient Name', 'wordlift' ), |
|
| 59 | + __( 'Recipe Name', 'wordlift' ), |
|
| 60 | + __( 'Recipe ID', 'wordlift' ), |
|
| 61 | + __( 'Post Name', 'wordlift' ), |
|
| 62 | + __( 'Post ID', 'wordlift' ), |
|
| 63 | + __( 'Post URL', 'wordlift' ), |
|
| 64 | + ), |
|
| 65 | + "\t" |
|
| 66 | + ); |
|
| 67 | + |
|
| 68 | + // Insert Data. |
|
| 69 | + foreach ( $items as $item ) { |
|
| 70 | + $recipe_json_ld = get_post_meta( $item->recipe_ID, '_wl_main_ingredient_jsonld', true ); // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 71 | + $recipe = json_decode( $recipe_json_ld, true ); |
|
| 72 | + fputcsv( |
|
| 73 | + $output, |
|
| 74 | + array( |
|
| 75 | + $recipe ? $recipe['name'] : 'null', |
|
| 76 | + $item->recipe_name, |
|
| 77 | + // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase |
|
| 78 | + $item->recipe_ID, |
|
| 79 | + $item->post_title, |
|
| 80 | + $item->post_ID, |
|
| 81 | + esc_url( get_the_permalink( $item->post_ID ) ), |
|
| 82 | + ), |
|
| 83 | + "\t" |
|
| 84 | + ); |
|
| 85 | + ob_flush(); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + wp_die(); |
|
| 89 | + } |
|
| 90 | 90 | } |
@@ -4,99 +4,99 @@ |
||
| 4 | 4 | |
| 5 | 5 | class API { |
| 6 | 6 | |
| 7 | - public function register_hooks() { |
|
| 8 | - add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
| 9 | - } |
|
| 7 | + public function register_hooks() { |
|
| 8 | + add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - public function register_routes() { |
|
| 12 | - register_rest_route( |
|
| 13 | - WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 14 | - '/include-exclude/config', |
|
| 15 | - array( |
|
| 16 | - 'methods' => \WP_REST_Server::READABLE, |
|
| 17 | - 'callback' => array( $this, 'get_include_exclude_data' ), |
|
| 18 | - 'permission_callback' => function () { |
|
| 19 | - return current_user_can( 'manage_options' ); |
|
| 20 | - }, |
|
| 21 | - ) |
|
| 22 | - ); |
|
| 11 | + public function register_routes() { |
|
| 12 | + register_rest_route( |
|
| 13 | + WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 14 | + '/include-exclude/config', |
|
| 15 | + array( |
|
| 16 | + 'methods' => \WP_REST_Server::READABLE, |
|
| 17 | + 'callback' => array( $this, 'get_include_exclude_data' ), |
|
| 18 | + 'permission_callback' => function () { |
|
| 19 | + return current_user_can( 'manage_options' ); |
|
| 20 | + }, |
|
| 21 | + ) |
|
| 22 | + ); |
|
| 23 | 23 | |
| 24 | - register_rest_route( |
|
| 25 | - WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 26 | - '/include-exclude/config', |
|
| 27 | - array( |
|
| 28 | - 'methods' => \WP_REST_Server::EDITABLE, |
|
| 29 | - 'callback' => array( $this, 'update_include_exclude_data' ), |
|
| 30 | - 'args' => array( |
|
| 31 | - 'type' => array( |
|
| 32 | - 'required' => true, |
|
| 33 | - 'type' => 'string', |
|
| 34 | - 'validate_callback' => function ( $param ) { |
|
| 35 | - if ( empty( $param ) || ! in_array( $param, array( 'include', 'exclude' ), true ) ) { |
|
| 36 | - return new \WP_Error( |
|
| 37 | - 'wordlift_invalid_include_exclude_type', |
|
| 38 | - __( 'type can be either include or exclude.', 'wordlift' ), |
|
| 39 | - array( |
|
| 40 | - 'status' => 400, |
|
| 41 | - ) |
|
| 42 | - ); |
|
| 43 | - } |
|
| 44 | - }, |
|
| 45 | - ), |
|
| 46 | - 'urls' => array( |
|
| 47 | - 'required' => true, |
|
| 48 | - 'type' => 'string', |
|
| 49 | - 'validate_callback' => function ( $param ) { |
|
| 50 | - return is_string( $param ) && ! empty( $param ); |
|
| 51 | - }, |
|
| 52 | - ), |
|
| 53 | - ), |
|
| 54 | - 'permission_callback' => function () { |
|
| 55 | - return current_user_can( 'manage_options' ); |
|
| 56 | - }, |
|
| 57 | - ) |
|
| 58 | - ); |
|
| 59 | - } |
|
| 24 | + register_rest_route( |
|
| 25 | + WL_REST_ROUTE_DEFAULT_NAMESPACE, |
|
| 26 | + '/include-exclude/config', |
|
| 27 | + array( |
|
| 28 | + 'methods' => \WP_REST_Server::EDITABLE, |
|
| 29 | + 'callback' => array( $this, 'update_include_exclude_data' ), |
|
| 30 | + 'args' => array( |
|
| 31 | + 'type' => array( |
|
| 32 | + 'required' => true, |
|
| 33 | + 'type' => 'string', |
|
| 34 | + 'validate_callback' => function ( $param ) { |
|
| 35 | + if ( empty( $param ) || ! in_array( $param, array( 'include', 'exclude' ), true ) ) { |
|
| 36 | + return new \WP_Error( |
|
| 37 | + 'wordlift_invalid_include_exclude_type', |
|
| 38 | + __( 'type can be either include or exclude.', 'wordlift' ), |
|
| 39 | + array( |
|
| 40 | + 'status' => 400, |
|
| 41 | + ) |
|
| 42 | + ); |
|
| 43 | + } |
|
| 44 | + }, |
|
| 45 | + ), |
|
| 46 | + 'urls' => array( |
|
| 47 | + 'required' => true, |
|
| 48 | + 'type' => 'string', |
|
| 49 | + 'validate_callback' => function ( $param ) { |
|
| 50 | + return is_string( $param ) && ! empty( $param ); |
|
| 51 | + }, |
|
| 52 | + ), |
|
| 53 | + ), |
|
| 54 | + 'permission_callback' => function () { |
|
| 55 | + return current_user_can( 'manage_options' ); |
|
| 56 | + }, |
|
| 57 | + ) |
|
| 58 | + ); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function get_include_exclude_data() { |
|
| 62 | - $include_exclude_data = get_option( 'wl_exclude_include_urls_settings', array() ); |
|
| 63 | - if ( empty( $include_exclude_data ) || empty( $include_exclude_data['urls'] ) ) { |
|
| 64 | - return new \WP_Error( |
|
| 65 | - 'wl_include_exclude_data_not_found', |
|
| 66 | - __( 'Include/Exclude data not found', 'wordlift' ), |
|
| 67 | - array( |
|
| 68 | - 'status' => 404, |
|
| 69 | - ) |
|
| 70 | - ); |
|
| 71 | - } |
|
| 72 | - $data = array( |
|
| 73 | - 'type' => $include_exclude_data['include_exclude'], |
|
| 74 | - 'urls' => $include_exclude_data['urls'], |
|
| 75 | - ); |
|
| 61 | + public function get_include_exclude_data() { |
|
| 62 | + $include_exclude_data = get_option( 'wl_exclude_include_urls_settings', array() ); |
|
| 63 | + if ( empty( $include_exclude_data ) || empty( $include_exclude_data['urls'] ) ) { |
|
| 64 | + return new \WP_Error( |
|
| 65 | + 'wl_include_exclude_data_not_found', |
|
| 66 | + __( 'Include/Exclude data not found', 'wordlift' ), |
|
| 67 | + array( |
|
| 68 | + 'status' => 404, |
|
| 69 | + ) |
|
| 70 | + ); |
|
| 71 | + } |
|
| 72 | + $data = array( |
|
| 73 | + 'type' => $include_exclude_data['include_exclude'], |
|
| 74 | + 'urls' => $include_exclude_data['urls'], |
|
| 75 | + ); |
|
| 76 | 76 | |
| 77 | - return rest_ensure_response( $data ); |
|
| 78 | - } |
|
| 77 | + return rest_ensure_response( $data ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - public function update_include_exclude_data( \WP_REST_Request $request ) { |
|
| 81 | - $data = $request->get_params(); |
|
| 80 | + public function update_include_exclude_data( \WP_REST_Request $request ) { |
|
| 81 | + $data = $request->get_params(); |
|
| 82 | 82 | |
| 83 | - $include_exclude_data = array( |
|
| 84 | - 'include_exclude' => $data['type'], |
|
| 85 | - 'urls' => $data['urls'], |
|
| 86 | - ); |
|
| 83 | + $include_exclude_data = array( |
|
| 84 | + 'include_exclude' => $data['type'], |
|
| 85 | + 'urls' => $data['urls'], |
|
| 86 | + ); |
|
| 87 | 87 | |
| 88 | - $updated = update_option( 'wl_exclude_include_urls_settings', $include_exclude_data ); |
|
| 88 | + $updated = update_option( 'wl_exclude_include_urls_settings', $include_exclude_data ); |
|
| 89 | 89 | |
| 90 | - if ( $updated ) { |
|
| 91 | - return new \WP_REST_Response( null, 204 ); |
|
| 92 | - } else { |
|
| 93 | - return new \WP_Error( |
|
| 94 | - 'wl_include_exclude_data_update_failed', |
|
| 95 | - __( 'Include/Exclude data update failed.', 'wordlift' ), |
|
| 96 | - array( |
|
| 97 | - 'status' => 400, |
|
| 98 | - ) |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - } |
|
| 90 | + if ( $updated ) { |
|
| 91 | + return new \WP_REST_Response( null, 204 ); |
|
| 92 | + } else { |
|
| 93 | + return new \WP_Error( |
|
| 94 | + 'wl_include_exclude_data_update_failed', |
|
| 95 | + __( 'Include/Exclude data update failed.', 'wordlift' ), |
|
| 96 | + array( |
|
| 97 | + 'status' => 400, |
|
| 98 | + ) |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | 102 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | class API { |
| 6 | 6 | |
| 7 | 7 | public function register_hooks() { |
| 8 | - add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
| 8 | + add_action('rest_api_init', array($this, 'register_routes')); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | public function register_routes() { |
@@ -14,9 +14,9 @@ discard block |
||
| 14 | 14 | '/include-exclude/config', |
| 15 | 15 | array( |
| 16 | 16 | 'methods' => \WP_REST_Server::READABLE, |
| 17 | - 'callback' => array( $this, 'get_include_exclude_data' ), |
|
| 18 | - 'permission_callback' => function () { |
|
| 19 | - return current_user_can( 'manage_options' ); |
|
| 17 | + 'callback' => array($this, 'get_include_exclude_data'), |
|
| 18 | + 'permission_callback' => function() { |
|
| 19 | + return current_user_can('manage_options'); |
|
| 20 | 20 | }, |
| 21 | 21 | ) |
| 22 | 22 | ); |
@@ -26,16 +26,16 @@ discard block |
||
| 26 | 26 | '/include-exclude/config', |
| 27 | 27 | array( |
| 28 | 28 | 'methods' => \WP_REST_Server::EDITABLE, |
| 29 | - 'callback' => array( $this, 'update_include_exclude_data' ), |
|
| 29 | + 'callback' => array($this, 'update_include_exclude_data'), |
|
| 30 | 30 | 'args' => array( |
| 31 | 31 | 'type' => array( |
| 32 | 32 | 'required' => true, |
| 33 | 33 | 'type' => 'string', |
| 34 | - 'validate_callback' => function ( $param ) { |
|
| 35 | - if ( empty( $param ) || ! in_array( $param, array( 'include', 'exclude' ), true ) ) { |
|
| 34 | + 'validate_callback' => function($param) { |
|
| 35 | + if (empty($param) || ! in_array($param, array('include', 'exclude'), true)) { |
|
| 36 | 36 | return new \WP_Error( |
| 37 | 37 | 'wordlift_invalid_include_exclude_type', |
| 38 | - __( 'type can be either include or exclude.', 'wordlift' ), |
|
| 38 | + __('type can be either include or exclude.', 'wordlift'), |
|
| 39 | 39 | array( |
| 40 | 40 | 'status' => 400, |
| 41 | 41 | ) |
@@ -46,24 +46,24 @@ discard block |
||
| 46 | 46 | 'urls' => array( |
| 47 | 47 | 'required' => true, |
| 48 | 48 | 'type' => 'string', |
| 49 | - 'validate_callback' => function ( $param ) { |
|
| 50 | - return is_string( $param ) && ! empty( $param ); |
|
| 49 | + 'validate_callback' => function($param) { |
|
| 50 | + return is_string($param) && ! empty($param); |
|
| 51 | 51 | }, |
| 52 | 52 | ), |
| 53 | 53 | ), |
| 54 | - 'permission_callback' => function () { |
|
| 55 | - return current_user_can( 'manage_options' ); |
|
| 54 | + 'permission_callback' => function() { |
|
| 55 | + return current_user_can('manage_options'); |
|
| 56 | 56 | }, |
| 57 | 57 | ) |
| 58 | 58 | ); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | public function get_include_exclude_data() { |
| 62 | - $include_exclude_data = get_option( 'wl_exclude_include_urls_settings', array() ); |
|
| 63 | - if ( empty( $include_exclude_data ) || empty( $include_exclude_data['urls'] ) ) { |
|
| 62 | + $include_exclude_data = get_option('wl_exclude_include_urls_settings', array()); |
|
| 63 | + if (empty($include_exclude_data) || empty($include_exclude_data['urls'])) { |
|
| 64 | 64 | return new \WP_Error( |
| 65 | 65 | 'wl_include_exclude_data_not_found', |
| 66 | - __( 'Include/Exclude data not found', 'wordlift' ), |
|
| 66 | + __('Include/Exclude data not found', 'wordlift'), |
|
| 67 | 67 | array( |
| 68 | 68 | 'status' => 404, |
| 69 | 69 | ) |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | 'urls' => $include_exclude_data['urls'], |
| 75 | 75 | ); |
| 76 | 76 | |
| 77 | - return rest_ensure_response( $data ); |
|
| 77 | + return rest_ensure_response($data); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function update_include_exclude_data( \WP_REST_Request $request ) { |
|
| 80 | + public function update_include_exclude_data(\WP_REST_Request $request) { |
|
| 81 | 81 | $data = $request->get_params(); |
| 82 | 82 | |
| 83 | 83 | $include_exclude_data = array( |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | 'urls' => $data['urls'], |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | - $updated = update_option( 'wl_exclude_include_urls_settings', $include_exclude_data ); |
|
| 88 | + $updated = update_option('wl_exclude_include_urls_settings', $include_exclude_data); |
|
| 89 | 89 | |
| 90 | - if ( $updated ) { |
|
| 91 | - return new \WP_REST_Response( null, 204 ); |
|
| 90 | + if ($updated) { |
|
| 91 | + return new \WP_REST_Response(null, 204); |
|
| 92 | 92 | } else { |
| 93 | 93 | return new \WP_Error( |
| 94 | 94 | 'wl_include_exclude_data_update_failed', |
| 95 | - __( 'Include/Exclude data update failed.', 'wordlift' ), |
|
| 95 | + __('Include/Exclude data update failed.', 'wordlift'), |
|
| 96 | 96 | array( |
| 97 | 97 | 'status' => 400, |
| 98 | 98 | ) |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | use Wordlift\Modules\Common\Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
| 14 | 14 | |
| 15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 16 | - exit; |
|
| 16 | + exit; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | $wl_features = get_option( '_wl_features', array() ); |
| 24 | 24 | if ( ! apply_filters( 'wl_feature__enable__include-exclude', isset( $wl_features['include-exclude'] ) && $wl_features['include-exclude'] ) ) { // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 25 | - return; |
|
| 25 | + return; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
@@ -32,26 +32,26 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function __wl_include_exclude__load() { |
| 34 | 34 | |
| 35 | - // Autoloader for plugin itself. |
|
| 36 | - if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 37 | - require_once __DIR__ . '/vendor/autoload.php'; |
|
| 38 | - } |
|
| 35 | + // Autoloader for plugin itself. |
|
| 36 | + if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 37 | + require_once __DIR__ . '/vendor/autoload.php'; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $container_builder = new ContainerBuilder(); |
|
| 41 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 42 | - $loader->load( 'services.yml' ); |
|
| 43 | - $container_builder->compile(); |
|
| 40 | + $container_builder = new ContainerBuilder(); |
|
| 41 | + $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 42 | + $loader->load( 'services.yml' ); |
|
| 43 | + $container_builder->compile(); |
|
| 44 | 44 | |
| 45 | - $enabled = $container_builder->get( 'Wordlift\Modules\Include_Exclude\Plugin_Enabled' ); |
|
| 46 | - $enabled->register_hooks(); |
|
| 45 | + $enabled = $container_builder->get( 'Wordlift\Modules\Include_Exclude\Plugin_Enabled' ); |
|
| 46 | + $enabled->register_hooks(); |
|
| 47 | 47 | |
| 48 | - if ( apply_filters( 'wl_is_enabled', true ) ) { |
|
| 49 | - $settings = $container_builder->get( 'Wordlift\Modules\Include_Exclude\Admin\Settings' ); |
|
| 50 | - $settings->register_hooks(); |
|
| 48 | + if ( apply_filters( 'wl_is_enabled', true ) ) { |
|
| 49 | + $settings = $container_builder->get( 'Wordlift\Modules\Include_Exclude\Admin\Settings' ); |
|
| 50 | + $settings->register_hooks(); |
|
| 51 | 51 | |
| 52 | - $api = $container_builder->get( 'Wordlift\Modules\Include_Exclude\API' ); |
|
| 53 | - $api->register_hooks(); |
|
| 54 | - } |
|
| 52 | + $api = $container_builder->get( 'Wordlift\Modules\Include_Exclude\API' ); |
|
| 53 | + $api->register_hooks(); |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | __wl_include_exclude__load(); |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | use Wordlift\Modules\Common\Symfony\Component\DependencyInjection\ContainerBuilder; |
| 13 | 13 | use Wordlift\Modules\Common\Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 15 | +if ( ! defined('ABSPATH')) { |
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -20,8 +20,8 @@ discard block |
||
| 20 | 20 | * This module loads very early since it needs to tell WLP whether to load itself or not. Therefore we need to load the |
| 21 | 21 | * feature settings by ourselves. |
| 22 | 22 | */ |
| 23 | -$wl_features = get_option( '_wl_features', array() ); |
|
| 24 | -if ( ! apply_filters( 'wl_feature__enable__include-exclude', isset( $wl_features['include-exclude'] ) && $wl_features['include-exclude'] ) ) { // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
| 23 | +$wl_features = get_option('_wl_features', array()); |
|
| 24 | +if ( ! apply_filters('wl_feature__enable__include-exclude', isset($wl_features['include-exclude']) && $wl_features['include-exclude'])) { // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
@@ -33,23 +33,23 @@ discard block |
||
| 33 | 33 | function __wl_include_exclude__load() { |
| 34 | 34 | |
| 35 | 35 | // Autoloader for plugin itself. |
| 36 | - if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { |
|
| 37 | - require_once __DIR__ . '/vendor/autoload.php'; |
|
| 36 | + if (file_exists(__DIR__.'/vendor/autoload.php')) { |
|
| 37 | + require_once __DIR__.'/vendor/autoload.php'; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $container_builder = new ContainerBuilder(); |
| 41 | - $loader = new YamlFileLoader( $container_builder, new FileLocator( __DIR__ ) ); |
|
| 42 | - $loader->load( 'services.yml' ); |
|
| 41 | + $loader = new YamlFileLoader($container_builder, new FileLocator(__DIR__)); |
|
| 42 | + $loader->load('services.yml'); |
|
| 43 | 43 | $container_builder->compile(); |
| 44 | 44 | |
| 45 | - $enabled = $container_builder->get( 'Wordlift\Modules\Include_Exclude\Plugin_Enabled' ); |
|
| 45 | + $enabled = $container_builder->get('Wordlift\Modules\Include_Exclude\Plugin_Enabled'); |
|
| 46 | 46 | $enabled->register_hooks(); |
| 47 | 47 | |
| 48 | - if ( apply_filters( 'wl_is_enabled', true ) ) { |
|
| 49 | - $settings = $container_builder->get( 'Wordlift\Modules\Include_Exclude\Admin\Settings' ); |
|
| 48 | + if (apply_filters('wl_is_enabled', true)) { |
|
| 49 | + $settings = $container_builder->get('Wordlift\Modules\Include_Exclude\Admin\Settings'); |
|
| 50 | 50 | $settings->register_hooks(); |
| 51 | 51 | |
| 52 | - $api = $container_builder->get( 'Wordlift\Modules\Include_Exclude\API' ); |
|
| 52 | + $api = $container_builder->get('Wordlift\Modules\Include_Exclude\API'); |
|
| 53 | 53 | $api->register_hooks(); |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -7,6 +7,6 @@ |
||
| 7 | 7 | exit(1); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 10 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 11 | 11 | |
| 12 | 12 | return ComposerAutoloaderInitce8393fe837d1222bf35cfeea65d9876::getLoader(); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | 'version' => 'dev-develop', |
| 6 | 6 | 'reference' => '4318cca4abfea06968be19ff0dd526bab3e1d8c4', |
| 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' => '4318cca4abfea06968be19ff0dd526bab3e1d8c4', |
| 17 | 17 | 'type' => 'wordpress-plugin', |
| 18 | - 'install_path' => __DIR__ . '/../../', |
|
| 18 | + 'install_path' => __DIR__.'/../../', |
|
| 19 | 19 | 'aliases' => array(), |
| 20 | 20 | 'dev_requirement' => false, |
| 21 | 21 | ), |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitce8393fe837d1222bf35cfeea65d9876 |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'W' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'Wordlift\\Modules\\Include_Exclude\\' => 33, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'Wordlift\\Modules\\Include_Exclude\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/../..' . '/includes', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/../..'.'/includes', |
|
| 20 | 20 | ), |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public static $classMap = array ( |
|
| 24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
| 23 | + public static $classMap = array( |
|
| 24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | 27 | public static function getInitializer(ClassLoader $loader) |
| 28 | 28 | { |
| 29 | - return \Closure::bind(function () use ($loader) { |
|
| 29 | + return \Closure::bind(function() use ($loader) { |
|
| 30 | 30 | $loader->prefixLengthsPsr4 = ComposerStaticInitce8393fe837d1222bf35cfeea65d9876::$prefixLengthsPsr4; |
| 31 | 31 | $loader->prefixDirsPsr4 = ComposerStaticInitce8393fe837d1222bf35cfeea65d9876::$prefixDirsPsr4; |
| 32 | 32 | $loader->classMap = ComposerStaticInitce8393fe837d1222bf35cfeea65d9876::$classMap; |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | public static function loadClassLoader($class) |
| 10 | 10 | { |
| 11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
| 12 | - require __DIR__ . '/ClassLoader.php'; |
|
| 12 | + require __DIR__.'/ClassLoader.php'; |
|
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | 15 | |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | return self::$loader; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - require __DIR__ . '/platform_check.php'; |
|
| 25 | + require __DIR__.'/platform_check.php'; |
|
| 26 | 26 | |
| 27 | 27 | spl_autoload_register(array('ComposerAutoloaderInitce8393fe837d1222bf35cfeea65d9876', 'loadClassLoader'), true, true); |
| 28 | 28 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
| 29 | 29 | spl_autoload_unregister(array('ComposerAutoloaderInitce8393fe837d1222bf35cfeea65d9876', 'loadClassLoader')); |
| 30 | 30 | |
| 31 | - require __DIR__ . '/autoload_static.php'; |
|
| 31 | + require __DIR__.'/autoload_static.php'; |
|
| 32 | 32 | call_user_func(\Composer\Autoload\ComposerStaticInitce8393fe837d1222bf35cfeea65d9876::getInitializer($loader)); |
| 33 | 33 | |
| 34 | 34 | $loader->register(true); |