@@ -23,108 +23,108 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Jsonld_By_Id_Endpoint { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The {@link Wordlift_Jsonld_Service} instance. |
|
| 28 | - * |
|
| 29 | - * @var Wordlift_Jsonld_Service The {@link Wordlift_Jsonld_Service} instance. |
|
| 30 | - */ |
|
| 31 | - private $jsonld_service; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var \Wordlift_Entity_Uri_Service |
|
| 35 | - */ |
|
| 36 | - private $entity_uri_service; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Jsonld_Endpoint constructor. |
|
| 40 | - * |
|
| 41 | - * @param \Wordlift_Jsonld_Service $jsonld_service |
|
| 42 | - * @param \Wordlift_Entity_Uri_Service $entity_uri_service |
|
| 43 | - */ |
|
| 44 | - public function __construct( $jsonld_service, $entity_uri_service ) { |
|
| 45 | - |
|
| 46 | - $this->jsonld_service = $jsonld_service; |
|
| 47 | - $this->entity_uri_service = $entity_uri_service; |
|
| 48 | - |
|
| 49 | - add_action( 'rest_api_init', array( $this, 'register_routes', ) ); |
|
| 50 | - |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Get the JSON-LD. |
|
| 55 | - * |
|
| 56 | - * @param \WP_REST_Request $request The incoming {@link \WP_REST_Request}. |
|
| 57 | - * |
|
| 58 | - * @return WP_REST_Response The outgoing {@link WP_REST_Response}. |
|
| 59 | - * @throws \Exception |
|
| 60 | - */ |
|
| 61 | - public function jsonld_by_id( $request ) { |
|
| 62 | - |
|
| 63 | - // Get the ids. |
|
| 64 | - $ids = (array) $request->get_param( 'id' ); |
|
| 65 | - |
|
| 66 | - // Preload the URIs to reduce the number of DB roundtrips. |
|
| 67 | - $this->entity_uri_service->preload_uris( array_map( 'urldecode', $ids ) ); |
|
| 68 | - |
|
| 69 | - $that = $this; |
|
| 70 | - |
|
| 71 | - // Get the posts, filtering out those not found. |
|
| 72 | - $posts = array_filter( array_map( function ( $item ) use ( $that ) { |
|
| 73 | - return $that->entity_uri_service->get_entity( urldecode( $item ) ); |
|
| 74 | - }, $ids ) ); |
|
| 75 | - |
|
| 76 | - // Get the posts' IDs and make the unique. |
|
| 77 | - $post_ids = array_unique( array_map( function ( $item ) { |
|
| 78 | - return $item->ID; |
|
| 79 | - }, $posts ) ); |
|
| 80 | - |
|
| 81 | - // Get the JSON-LD. |
|
| 82 | - $data = array(); |
|
| 83 | - foreach ( $post_ids as $post_id ) { |
|
| 84 | - $data = array_merge( $data, $that->jsonld_service->get_jsonld( false, $post_id ) ); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // Add the WebSite fragment if requested. |
|
| 88 | - if ( $request->get_param( 'website' ) ) { |
|
| 89 | - $data[] = $this->jsonld_service->get_jsonld( true ); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - return Jsonld_Response_Helper::to_response( $data ); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - public function register_routes() { |
|
| 96 | - |
|
| 97 | - register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld', array( |
|
| 98 | - 'methods' => WP_REST_Server::READABLE, |
|
| 99 | - 'callback' => array( $this, 'jsonld_by_id' ), |
|
| 100 | - 'permission_callback' => '__return_true', |
|
| 101 | - 'args' => array( |
|
| 102 | - 'id' => array( |
|
| 103 | - 'description' => __( 'One ore more itemids (e.g. http://data.wordlift.io/wordlift).', 'wordlift' ), |
|
| 104 | - // We expect an array of strings. |
|
| 105 | - 'type' => 'array', |
|
| 106 | - 'items' => array( |
|
| 107 | - 'type' => 'string' |
|
| 108 | - ), |
|
| 109 | - 'validate_callback' => function ( $values, $request, $param ) { |
|
| 110 | - |
|
| 111 | - if ( ! is_array( $values ) ) { |
|
| 112 | - return new WP_Error( 'rest_invalid_param', esc_html__( 'The id argument must be an array (try passing `id[]=...`.', 'wordlift' ), array( 'status' => 400 ) ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - foreach ( $values as $value ) { |
|
| 116 | - if ( 0 !== strpos( $value, 'http' ) ) { |
|
| 117 | - return new WP_Error( 'rest_invalid_param', esc_html__( 'Ids must start with http.', 'wordlift' ), array( 'status' => 400 ) ); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - ), |
|
| 122 | - 'website' => array( |
|
| 123 | - 'description' => __( 'Whether to include the WebSite markup.', 'wordlift' ), |
|
| 124 | - ) |
|
| 125 | - ) |
|
| 126 | - ) ); |
|
| 127 | - |
|
| 128 | - } |
|
| 26 | + /** |
|
| 27 | + * The {@link Wordlift_Jsonld_Service} instance. |
|
| 28 | + * |
|
| 29 | + * @var Wordlift_Jsonld_Service The {@link Wordlift_Jsonld_Service} instance. |
|
| 30 | + */ |
|
| 31 | + private $jsonld_service; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var \Wordlift_Entity_Uri_Service |
|
| 35 | + */ |
|
| 36 | + private $entity_uri_service; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Jsonld_Endpoint constructor. |
|
| 40 | + * |
|
| 41 | + * @param \Wordlift_Jsonld_Service $jsonld_service |
|
| 42 | + * @param \Wordlift_Entity_Uri_Service $entity_uri_service |
|
| 43 | + */ |
|
| 44 | + public function __construct( $jsonld_service, $entity_uri_service ) { |
|
| 45 | + |
|
| 46 | + $this->jsonld_service = $jsonld_service; |
|
| 47 | + $this->entity_uri_service = $entity_uri_service; |
|
| 48 | + |
|
| 49 | + add_action( 'rest_api_init', array( $this, 'register_routes', ) ); |
|
| 50 | + |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Get the JSON-LD. |
|
| 55 | + * |
|
| 56 | + * @param \WP_REST_Request $request The incoming {@link \WP_REST_Request}. |
|
| 57 | + * |
|
| 58 | + * @return WP_REST_Response The outgoing {@link WP_REST_Response}. |
|
| 59 | + * @throws \Exception |
|
| 60 | + */ |
|
| 61 | + public function jsonld_by_id( $request ) { |
|
| 62 | + |
|
| 63 | + // Get the ids. |
|
| 64 | + $ids = (array) $request->get_param( 'id' ); |
|
| 65 | + |
|
| 66 | + // Preload the URIs to reduce the number of DB roundtrips. |
|
| 67 | + $this->entity_uri_service->preload_uris( array_map( 'urldecode', $ids ) ); |
|
| 68 | + |
|
| 69 | + $that = $this; |
|
| 70 | + |
|
| 71 | + // Get the posts, filtering out those not found. |
|
| 72 | + $posts = array_filter( array_map( function ( $item ) use ( $that ) { |
|
| 73 | + return $that->entity_uri_service->get_entity( urldecode( $item ) ); |
|
| 74 | + }, $ids ) ); |
|
| 75 | + |
|
| 76 | + // Get the posts' IDs and make the unique. |
|
| 77 | + $post_ids = array_unique( array_map( function ( $item ) { |
|
| 78 | + return $item->ID; |
|
| 79 | + }, $posts ) ); |
|
| 80 | + |
|
| 81 | + // Get the JSON-LD. |
|
| 82 | + $data = array(); |
|
| 83 | + foreach ( $post_ids as $post_id ) { |
|
| 84 | + $data = array_merge( $data, $that->jsonld_service->get_jsonld( false, $post_id ) ); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // Add the WebSite fragment if requested. |
|
| 88 | + if ( $request->get_param( 'website' ) ) { |
|
| 89 | + $data[] = $this->jsonld_service->get_jsonld( true ); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + return Jsonld_Response_Helper::to_response( $data ); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + public function register_routes() { |
|
| 96 | + |
|
| 97 | + register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld', array( |
|
| 98 | + 'methods' => WP_REST_Server::READABLE, |
|
| 99 | + 'callback' => array( $this, 'jsonld_by_id' ), |
|
| 100 | + 'permission_callback' => '__return_true', |
|
| 101 | + 'args' => array( |
|
| 102 | + 'id' => array( |
|
| 103 | + 'description' => __( 'One ore more itemids (e.g. http://data.wordlift.io/wordlift).', 'wordlift' ), |
|
| 104 | + // We expect an array of strings. |
|
| 105 | + 'type' => 'array', |
|
| 106 | + 'items' => array( |
|
| 107 | + 'type' => 'string' |
|
| 108 | + ), |
|
| 109 | + 'validate_callback' => function ( $values, $request, $param ) { |
|
| 110 | + |
|
| 111 | + if ( ! is_array( $values ) ) { |
|
| 112 | + return new WP_Error( 'rest_invalid_param', esc_html__( 'The id argument must be an array (try passing `id[]=...`.', 'wordlift' ), array( 'status' => 400 ) ); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + foreach ( $values as $value ) { |
|
| 116 | + if ( 0 !== strpos( $value, 'http' ) ) { |
|
| 117 | + return new WP_Error( 'rest_invalid_param', esc_html__( 'Ids must start with http.', 'wordlift' ), array( 'status' => 400 ) ); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + ), |
|
| 122 | + 'website' => array( |
|
| 123 | + 'description' => __( 'Whether to include the WebSite markup.', 'wordlift' ), |
|
| 124 | + ) |
|
| 125 | + ) |
|
| 126 | + ) ); |
|
| 127 | + |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | } |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | * @param \Wordlift_Jsonld_Service $jsonld_service |
| 42 | 42 | * @param \Wordlift_Entity_Uri_Service $entity_uri_service |
| 43 | 43 | */ |
| 44 | - public function __construct( $jsonld_service, $entity_uri_service ) { |
|
| 44 | + public function __construct($jsonld_service, $entity_uri_service) { |
|
| 45 | 45 | |
| 46 | 46 | $this->jsonld_service = $jsonld_service; |
| 47 | 47 | $this->entity_uri_service = $entity_uri_service; |
| 48 | 48 | |
| 49 | - add_action( 'rest_api_init', array( $this, 'register_routes', ) ); |
|
| 49 | + add_action('rest_api_init', array($this, 'register_routes',)); |
|
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
@@ -58,72 +58,72 @@ discard block |
||
| 58 | 58 | * @return WP_REST_Response The outgoing {@link WP_REST_Response}. |
| 59 | 59 | * @throws \Exception |
| 60 | 60 | */ |
| 61 | - public function jsonld_by_id( $request ) { |
|
| 61 | + public function jsonld_by_id($request) { |
|
| 62 | 62 | |
| 63 | 63 | // Get the ids. |
| 64 | - $ids = (array) $request->get_param( 'id' ); |
|
| 64 | + $ids = (array) $request->get_param('id'); |
|
| 65 | 65 | |
| 66 | 66 | // Preload the URIs to reduce the number of DB roundtrips. |
| 67 | - $this->entity_uri_service->preload_uris( array_map( 'urldecode', $ids ) ); |
|
| 67 | + $this->entity_uri_service->preload_uris(array_map('urldecode', $ids)); |
|
| 68 | 68 | |
| 69 | 69 | $that = $this; |
| 70 | 70 | |
| 71 | 71 | // Get the posts, filtering out those not found. |
| 72 | - $posts = array_filter( array_map( function ( $item ) use ( $that ) { |
|
| 73 | - return $that->entity_uri_service->get_entity( urldecode( $item ) ); |
|
| 74 | - }, $ids ) ); |
|
| 72 | + $posts = array_filter(array_map(function($item) use ($that) { |
|
| 73 | + return $that->entity_uri_service->get_entity(urldecode($item)); |
|
| 74 | + }, $ids)); |
|
| 75 | 75 | |
| 76 | 76 | // Get the posts' IDs and make the unique. |
| 77 | - $post_ids = array_unique( array_map( function ( $item ) { |
|
| 77 | + $post_ids = array_unique(array_map(function($item) { |
|
| 78 | 78 | return $item->ID; |
| 79 | - }, $posts ) ); |
|
| 79 | + }, $posts)); |
|
| 80 | 80 | |
| 81 | 81 | // Get the JSON-LD. |
| 82 | 82 | $data = array(); |
| 83 | - foreach ( $post_ids as $post_id ) { |
|
| 84 | - $data = array_merge( $data, $that->jsonld_service->get_jsonld( false, $post_id ) ); |
|
| 83 | + foreach ($post_ids as $post_id) { |
|
| 84 | + $data = array_merge($data, $that->jsonld_service->get_jsonld(false, $post_id)); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | // Add the WebSite fragment if requested. |
| 88 | - if ( $request->get_param( 'website' ) ) { |
|
| 89 | - $data[] = $this->jsonld_service->get_jsonld( true ); |
|
| 88 | + if ($request->get_param('website')) { |
|
| 89 | + $data[] = $this->jsonld_service->get_jsonld(true); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - return Jsonld_Response_Helper::to_response( $data ); |
|
| 92 | + return Jsonld_Response_Helper::to_response($data); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | public function register_routes() { |
| 96 | 96 | |
| 97 | - register_rest_route( WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld', array( |
|
| 97 | + register_rest_route(WL_REST_ROUTE_DEFAULT_NAMESPACE, '/jsonld', array( |
|
| 98 | 98 | 'methods' => WP_REST_Server::READABLE, |
| 99 | - 'callback' => array( $this, 'jsonld_by_id' ), |
|
| 99 | + 'callback' => array($this, 'jsonld_by_id'), |
|
| 100 | 100 | 'permission_callback' => '__return_true', |
| 101 | 101 | 'args' => array( |
| 102 | 102 | 'id' => array( |
| 103 | - 'description' => __( 'One ore more itemids (e.g. http://data.wordlift.io/wordlift).', 'wordlift' ), |
|
| 103 | + 'description' => __('One ore more itemids (e.g. http://data.wordlift.io/wordlift).', 'wordlift'), |
|
| 104 | 104 | // We expect an array of strings. |
| 105 | 105 | 'type' => 'array', |
| 106 | 106 | 'items' => array( |
| 107 | 107 | 'type' => 'string' |
| 108 | 108 | ), |
| 109 | - 'validate_callback' => function ( $values, $request, $param ) { |
|
| 109 | + 'validate_callback' => function($values, $request, $param) { |
|
| 110 | 110 | |
| 111 | - if ( ! is_array( $values ) ) { |
|
| 112 | - return new WP_Error( 'rest_invalid_param', esc_html__( 'The id argument must be an array (try passing `id[]=...`.', 'wordlift' ), array( 'status' => 400 ) ); |
|
| 111 | + if ( ! is_array($values)) { |
|
| 112 | + return new WP_Error('rest_invalid_param', esc_html__('The id argument must be an array (try passing `id[]=...`.', 'wordlift'), array('status' => 400)); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - foreach ( $values as $value ) { |
|
| 116 | - if ( 0 !== strpos( $value, 'http' ) ) { |
|
| 117 | - return new WP_Error( 'rest_invalid_param', esc_html__( 'Ids must start with http.', 'wordlift' ), array( 'status' => 400 ) ); |
|
| 115 | + foreach ($values as $value) { |
|
| 116 | + if (0 !== strpos($value, 'http')) { |
|
| 117 | + return new WP_Error('rest_invalid_param', esc_html__('Ids must start with http.', 'wordlift'), array('status' => 400)); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | ), |
| 122 | 122 | 'website' => array( |
| 123 | - 'description' => __( 'Whether to include the WebSite markup.', 'wordlift' ), |
|
| 123 | + 'description' => __('Whether to include the WebSite markup.', 'wordlift'), |
|
| 124 | 124 | ) |
| 125 | 125 | ) |
| 126 | - ) ); |
|
| 126 | + )); |
|
| 127 | 127 | |
| 128 | 128 | } |
| 129 | 129 | |
@@ -7,194 +7,194 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | class Wordlift_Notice_Service { |
| 9 | 9 | |
| 10 | - /** |
|
| 11 | - * The template used to display notices. The <em>notice dismissible</em> style classes make this notice dismissible |
|
| 12 | - * on the WordPress UI (via a small X button on the right side of the notice). |
|
| 13 | - * |
|
| 14 | - * @since 3.2.0 |
|
| 15 | - */ |
|
| 16 | - const TEMPLATE = '<div class="wl-notice notice is-dismissible %s"><p>%s</p></div>'; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * The standard WordPress <em>update</em> style class. |
|
| 20 | - * |
|
| 21 | - * @since 3.2.0 |
|
| 22 | - */ |
|
| 23 | - const UPDATE = 'update'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * The standard WordPress <em>update-nag</em> style class. |
|
| 27 | - * |
|
| 28 | - * @since 3.2.0 |
|
| 29 | - */ |
|
| 30 | - const UPDATE_NAG = 'update-nag'; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * The standard WordPress <em>error</em> style class. |
|
| 34 | - * |
|
| 35 | - * @since 3.2.0 |
|
| 36 | - */ |
|
| 37 | - const ERROR = 'error'; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * A custom WordLift css style class used for WordLift suggestions. |
|
| 41 | - * |
|
| 42 | - * @since 3.3.0 |
|
| 43 | - */ |
|
| 44 | - const SUGGESTION = 'wl-suggestion'; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * The array of notices. |
|
| 48 | - * |
|
| 49 | - * @since 3.2.0 |
|
| 50 | - * @access private |
|
| 51 | - * @var array $notices The array of notices. |
|
| 52 | - */ |
|
| 53 | - private $notices = array(); |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * A singleton instance of the Notice service. |
|
| 57 | - * |
|
| 58 | - * @since 3.2.0 |
|
| 59 | - * @access private |
|
| 60 | - * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service. |
|
| 61 | - */ |
|
| 62 | - private static $instance; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Create an instance of the Notice service. |
|
| 66 | - * |
|
| 67 | - * @since 3.2.0 |
|
| 68 | - */ |
|
| 69 | - public function __construct() { |
|
| 70 | - /** |
|
| 71 | - * Filter: wl_feature__enable__notices. |
|
| 72 | - * |
|
| 73 | - * @param bool whether the notices needs to be enabled or not. |
|
| 74 | - * |
|
| 75 | - * @return bool |
|
| 76 | - * @since 3.27.6 |
|
| 77 | - */ |
|
| 78 | - if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 79 | - // Hook to be called when to display notices. |
|
| 80 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 81 | - } |
|
| 82 | - self::$instance = $this; |
|
| 83 | - |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Get the singleton instance of the Notice service. |
|
| 88 | - * |
|
| 89 | - * @return \Wordlift_Notice_Service The singleton instance of the Notice service. |
|
| 90 | - * @since 3.2.0 |
|
| 91 | - */ |
|
| 92 | - public static function get_instance() { |
|
| 93 | - |
|
| 94 | - return self::$instance; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Add a notice. |
|
| 99 | - * |
|
| 100 | - * @param string $class The css class. |
|
| 101 | - * @param string $message The message. |
|
| 102 | - * |
|
| 103 | - * @since 3.2.0 |
|
| 104 | - * |
|
| 105 | - */ |
|
| 106 | - public function add( $class, $message ) { |
|
| 107 | - |
|
| 108 | - $this->notices[] = sprintf( self::TEMPLATE, $class, $this->transform( $message ) ); |
|
| 109 | - |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Add an update notice (message with a white background and a green left border). |
|
| 114 | - * |
|
| 115 | - * @param string $message The message to display. |
|
| 116 | - * |
|
| 117 | - * @since 3.2.0 |
|
| 118 | - * |
|
| 119 | - */ |
|
| 120 | - public function add_update( $message ) { |
|
| 121 | - |
|
| 122 | - $this->add( self::UPDATE, $message ); |
|
| 123 | - |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Add an update nag notice (message with a white background and a yellow left border). |
|
| 128 | - * |
|
| 129 | - * @param string $message The message to display. |
|
| 130 | - * |
|
| 131 | - * @since 3.2.0 |
|
| 132 | - * |
|
| 133 | - */ |
|
| 134 | - public function add_update_nag( $message ) { |
|
| 135 | - |
|
| 136 | - $this->add( self::UPDATE_NAG, $message ); |
|
| 137 | - |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - /** |
|
| 141 | - * Add an error notice (message with a white background and a red left border). |
|
| 142 | - * |
|
| 143 | - * @param string $message The message to display. |
|
| 144 | - * |
|
| 145 | - * @since 3.2.0 |
|
| 146 | - * |
|
| 147 | - */ |
|
| 148 | - public function add_error( $message ) { |
|
| 149 | - |
|
| 150 | - $this->add( self::ERROR, $message ); |
|
| 151 | - |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Add a suggestion notice (message with a white background and a WordLift brand colored left border). |
|
| 156 | - * |
|
| 157 | - * @param string $message The message to display. |
|
| 158 | - * |
|
| 159 | - * @since 3.3.0 |
|
| 160 | - * |
|
| 161 | - */ |
|
| 162 | - public function add_suggestion( $message ) { |
|
| 163 | - |
|
| 164 | - $this->add( self::SUGGESTION, $message ); |
|
| 165 | - |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Print out the notices when the admin_notices action is called. |
|
| 170 | - * |
|
| 171 | - * @since 3.2.0 |
|
| 172 | - */ |
|
| 173 | - public function admin_notices() { |
|
| 174 | - |
|
| 175 | - foreach ( $this->notices as $notice ) { |
|
| 176 | - echo( $notice ); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * Transform message depending on message type. Return a string |
|
| 183 | - * |
|
| 184 | - * @param string $message The message. |
|
| 185 | - * |
|
| 186 | - * @since 3.3.0 |
|
| 187 | - * |
|
| 188 | - */ |
|
| 189 | - private function transform( $message ) { |
|
| 190 | - |
|
| 191 | - switch ( gettype( $message ) ) { |
|
| 192 | - case 'array': |
|
| 193 | - return implode('<br />', $message ); |
|
| 194 | - default: |
|
| 195 | - return $message; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - } |
|
| 10 | + /** |
|
| 11 | + * The template used to display notices. The <em>notice dismissible</em> style classes make this notice dismissible |
|
| 12 | + * on the WordPress UI (via a small X button on the right side of the notice). |
|
| 13 | + * |
|
| 14 | + * @since 3.2.0 |
|
| 15 | + */ |
|
| 16 | + const TEMPLATE = '<div class="wl-notice notice is-dismissible %s"><p>%s</p></div>'; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * The standard WordPress <em>update</em> style class. |
|
| 20 | + * |
|
| 21 | + * @since 3.2.0 |
|
| 22 | + */ |
|
| 23 | + const UPDATE = 'update'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * The standard WordPress <em>update-nag</em> style class. |
|
| 27 | + * |
|
| 28 | + * @since 3.2.0 |
|
| 29 | + */ |
|
| 30 | + const UPDATE_NAG = 'update-nag'; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * The standard WordPress <em>error</em> style class. |
|
| 34 | + * |
|
| 35 | + * @since 3.2.0 |
|
| 36 | + */ |
|
| 37 | + const ERROR = 'error'; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * A custom WordLift css style class used for WordLift suggestions. |
|
| 41 | + * |
|
| 42 | + * @since 3.3.0 |
|
| 43 | + */ |
|
| 44 | + const SUGGESTION = 'wl-suggestion'; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * The array of notices. |
|
| 48 | + * |
|
| 49 | + * @since 3.2.0 |
|
| 50 | + * @access private |
|
| 51 | + * @var array $notices The array of notices. |
|
| 52 | + */ |
|
| 53 | + private $notices = array(); |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * A singleton instance of the Notice service. |
|
| 57 | + * |
|
| 58 | + * @since 3.2.0 |
|
| 59 | + * @access private |
|
| 60 | + * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service. |
|
| 61 | + */ |
|
| 62 | + private static $instance; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Create an instance of the Notice service. |
|
| 66 | + * |
|
| 67 | + * @since 3.2.0 |
|
| 68 | + */ |
|
| 69 | + public function __construct() { |
|
| 70 | + /** |
|
| 71 | + * Filter: wl_feature__enable__notices. |
|
| 72 | + * |
|
| 73 | + * @param bool whether the notices needs to be enabled or not. |
|
| 74 | + * |
|
| 75 | + * @return bool |
|
| 76 | + * @since 3.27.6 |
|
| 77 | + */ |
|
| 78 | + if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 79 | + // Hook to be called when to display notices. |
|
| 80 | + add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 81 | + } |
|
| 82 | + self::$instance = $this; |
|
| 83 | + |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Get the singleton instance of the Notice service. |
|
| 88 | + * |
|
| 89 | + * @return \Wordlift_Notice_Service The singleton instance of the Notice service. |
|
| 90 | + * @since 3.2.0 |
|
| 91 | + */ |
|
| 92 | + public static function get_instance() { |
|
| 93 | + |
|
| 94 | + return self::$instance; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Add a notice. |
|
| 99 | + * |
|
| 100 | + * @param string $class The css class. |
|
| 101 | + * @param string $message The message. |
|
| 102 | + * |
|
| 103 | + * @since 3.2.0 |
|
| 104 | + * |
|
| 105 | + */ |
|
| 106 | + public function add( $class, $message ) { |
|
| 107 | + |
|
| 108 | + $this->notices[] = sprintf( self::TEMPLATE, $class, $this->transform( $message ) ); |
|
| 109 | + |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Add an update notice (message with a white background and a green left border). |
|
| 114 | + * |
|
| 115 | + * @param string $message The message to display. |
|
| 116 | + * |
|
| 117 | + * @since 3.2.0 |
|
| 118 | + * |
|
| 119 | + */ |
|
| 120 | + public function add_update( $message ) { |
|
| 121 | + |
|
| 122 | + $this->add( self::UPDATE, $message ); |
|
| 123 | + |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Add an update nag notice (message with a white background and a yellow left border). |
|
| 128 | + * |
|
| 129 | + * @param string $message The message to display. |
|
| 130 | + * |
|
| 131 | + * @since 3.2.0 |
|
| 132 | + * |
|
| 133 | + */ |
|
| 134 | + public function add_update_nag( $message ) { |
|
| 135 | + |
|
| 136 | + $this->add( self::UPDATE_NAG, $message ); |
|
| 137 | + |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + /** |
|
| 141 | + * Add an error notice (message with a white background and a red left border). |
|
| 142 | + * |
|
| 143 | + * @param string $message The message to display. |
|
| 144 | + * |
|
| 145 | + * @since 3.2.0 |
|
| 146 | + * |
|
| 147 | + */ |
|
| 148 | + public function add_error( $message ) { |
|
| 149 | + |
|
| 150 | + $this->add( self::ERROR, $message ); |
|
| 151 | + |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Add a suggestion notice (message with a white background and a WordLift brand colored left border). |
|
| 156 | + * |
|
| 157 | + * @param string $message The message to display. |
|
| 158 | + * |
|
| 159 | + * @since 3.3.0 |
|
| 160 | + * |
|
| 161 | + */ |
|
| 162 | + public function add_suggestion( $message ) { |
|
| 163 | + |
|
| 164 | + $this->add( self::SUGGESTION, $message ); |
|
| 165 | + |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Print out the notices when the admin_notices action is called. |
|
| 170 | + * |
|
| 171 | + * @since 3.2.0 |
|
| 172 | + */ |
|
| 173 | + public function admin_notices() { |
|
| 174 | + |
|
| 175 | + foreach ( $this->notices as $notice ) { |
|
| 176 | + echo( $notice ); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * Transform message depending on message type. Return a string |
|
| 183 | + * |
|
| 184 | + * @param string $message The message. |
|
| 185 | + * |
|
| 186 | + * @since 3.3.0 |
|
| 187 | + * |
|
| 188 | + */ |
|
| 189 | + private function transform( $message ) { |
|
| 190 | + |
|
| 191 | + switch ( gettype( $message ) ) { |
|
| 192 | + case 'array': |
|
| 193 | + return implode('<br />', $message ); |
|
| 194 | + default: |
|
| 195 | + return $message; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | 200 | } |
@@ -75,9 +75,9 @@ discard block |
||
| 75 | 75 | * @return bool |
| 76 | 76 | * @since 3.27.6 |
| 77 | 77 | */ |
| 78 | - if ( apply_filters( 'wl_feature__enable__notices', true ) ) { |
|
| 78 | + if (apply_filters('wl_feature__enable__notices', true)) { |
|
| 79 | 79 | // Hook to be called when to display notices. |
| 80 | - add_action( 'admin_notices', array( $this, 'admin_notices' ) ); |
|
| 80 | + add_action('admin_notices', array($this, 'admin_notices')); |
|
| 81 | 81 | } |
| 82 | 82 | self::$instance = $this; |
| 83 | 83 | |
@@ -103,9 +103,9 @@ discard block |
||
| 103 | 103 | * @since 3.2.0 |
| 104 | 104 | * |
| 105 | 105 | */ |
| 106 | - public function add( $class, $message ) { |
|
| 106 | + public function add($class, $message) { |
|
| 107 | 107 | |
| 108 | - $this->notices[] = sprintf( self::TEMPLATE, $class, $this->transform( $message ) ); |
|
| 108 | + $this->notices[] = sprintf(self::TEMPLATE, $class, $this->transform($message)); |
|
| 109 | 109 | |
| 110 | 110 | } |
| 111 | 111 | |
@@ -117,9 +117,9 @@ discard block |
||
| 117 | 117 | * @since 3.2.0 |
| 118 | 118 | * |
| 119 | 119 | */ |
| 120 | - public function add_update( $message ) { |
|
| 120 | + public function add_update($message) { |
|
| 121 | 121 | |
| 122 | - $this->add( self::UPDATE, $message ); |
|
| 122 | + $this->add(self::UPDATE, $message); |
|
| 123 | 123 | |
| 124 | 124 | } |
| 125 | 125 | |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | * @since 3.2.0 |
| 132 | 132 | * |
| 133 | 133 | */ |
| 134 | - public function add_update_nag( $message ) { |
|
| 134 | + public function add_update_nag($message) { |
|
| 135 | 135 | |
| 136 | - $this->add( self::UPDATE_NAG, $message ); |
|
| 136 | + $this->add(self::UPDATE_NAG, $message); |
|
| 137 | 137 | |
| 138 | 138 | } |
| 139 | 139 | |
@@ -145,9 +145,9 @@ discard block |
||
| 145 | 145 | * @since 3.2.0 |
| 146 | 146 | * |
| 147 | 147 | */ |
| 148 | - public function add_error( $message ) { |
|
| 148 | + public function add_error($message) { |
|
| 149 | 149 | |
| 150 | - $this->add( self::ERROR, $message ); |
|
| 150 | + $this->add(self::ERROR, $message); |
|
| 151 | 151 | |
| 152 | 152 | } |
| 153 | 153 | |
@@ -159,9 +159,9 @@ discard block |
||
| 159 | 159 | * @since 3.3.0 |
| 160 | 160 | * |
| 161 | 161 | */ |
| 162 | - public function add_suggestion( $message ) { |
|
| 162 | + public function add_suggestion($message) { |
|
| 163 | 163 | |
| 164 | - $this->add( self::SUGGESTION, $message ); |
|
| 164 | + $this->add(self::SUGGESTION, $message); |
|
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | */ |
| 173 | 173 | public function admin_notices() { |
| 174 | 174 | |
| 175 | - foreach ( $this->notices as $notice ) { |
|
| 176 | - echo( $notice ); |
|
| 175 | + foreach ($this->notices as $notice) { |
|
| 176 | + echo($notice); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | } |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | * @since 3.3.0 |
| 187 | 187 | * |
| 188 | 188 | */ |
| 189 | - private function transform( $message ) { |
|
| 189 | + private function transform($message) { |
|
| 190 | 190 | |
| 191 | - switch ( gettype( $message ) ) { |
|
| 191 | + switch (gettype($message)) { |
|
| 192 | 192 | case 'array': |
| 193 | - return implode('<br />', $message ); |
|
| 193 | + return implode('<br />', $message); |
|
| 194 | 194 | default: |
| 195 | 195 | return $message; |
| 196 | 196 | } |
@@ -2,6 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | // autoload.php @generated by Composer |
| 4 | 4 | |
| 5 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 5 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 6 | 6 | |
| 7 | 7 | return ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b::getLoader(); |
@@ -4,23 +4,23 @@ |
||
| 4 | 4 | |
| 5 | 5 | $issues = array(); |
| 6 | 6 | |
| 7 | -if (!(PHP_VERSION_ID >= 50200)) { |
|
| 8 | - $issues[] = 'Your Composer dependencies require a PHP version ">= 5.2.0". You are running ' . PHP_VERSION . '.'; |
|
| 7 | +if ( ! (PHP_VERSION_ID >= 50200)) { |
|
| 8 | + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.2.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 | } |
@@ -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,29 +22,29 @@ 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('ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader'), true, true); |
| 28 | 28 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(); |
| 29 | 29 | spl_autoload_unregister(array('ComposerAutoloaderInit30c84c47a44576eaa4b38cc478d5e11b', 'loadClassLoader')); |
| 30 | 30 | |
| 31 | - $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
|
| 31 | + $useStaticLoader = PHP_VERSION_ID >= 50600 && ! defined('HHVM_VERSION') && ( ! function_exists('zend_loader_file_encoded') || ! zend_loader_file_encoded()); |
|
| 32 | 32 | if ($useStaticLoader) { |
| 33 | - require __DIR__ . '/autoload_static.php'; |
|
| 33 | + require __DIR__.'/autoload_static.php'; |
|
| 34 | 34 | |
| 35 | 35 | call_user_func(\Composer\Autoload\ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::getInitializer($loader)); |
| 36 | 36 | } else { |
| 37 | - $map = require __DIR__ . '/autoload_namespaces.php'; |
|
| 37 | + $map = require __DIR__.'/autoload_namespaces.php'; |
|
| 38 | 38 | foreach ($map as $namespace => $path) { |
| 39 | 39 | $loader->set($namespace, $path); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - $map = require __DIR__ . '/autoload_psr4.php'; |
|
| 42 | + $map = require __DIR__.'/autoload_psr4.php'; |
|
| 43 | 43 | foreach ($map as $namespace => $path) { |
| 44 | 44 | $loader->setPsr4($namespace, $path); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - $classMap = require __DIR__ . '/autoload_classmap.php'; |
|
| 47 | + $classMap = require __DIR__.'/autoload_classmap.php'; |
|
| 48 | 48 | if ($classMap) { |
| 49 | 49 | $loader->addClassMap($classMap); |
| 50 | 50 | } |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | class InstalledVersions |
| 13 | 13 | { |
| 14 | 14 | private static $installed = array ( |
| 15 | - 'root' => |
|
| 16 | - array ( |
|
| 15 | + 'root' => |
|
| 16 | + array ( |
|
| 17 | 17 | 'pretty_version' => 'dev-develop', |
| 18 | 18 | 'version' => 'dev-develop', |
| 19 | 19 | 'aliases' => |
@@ -21,28 +21,28 @@ discard block |
||
| 21 | 21 | ), |
| 22 | 22 | 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
| 23 | 23 | 'name' => '__root__', |
| 24 | - ), |
|
| 25 | - 'versions' => |
|
| 26 | - array ( |
|
| 24 | + ), |
|
| 25 | + 'versions' => |
|
| 26 | + array ( |
|
| 27 | 27 | '__root__' => |
| 28 | 28 | array ( |
| 29 | - 'pretty_version' => 'dev-develop', |
|
| 30 | - 'version' => 'dev-develop', |
|
| 31 | - 'aliases' => |
|
| 32 | - array ( |
|
| 33 | - ), |
|
| 34 | - 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
| 29 | + 'pretty_version' => 'dev-develop', |
|
| 30 | + 'version' => 'dev-develop', |
|
| 31 | + 'aliases' => |
|
| 32 | + array ( |
|
| 33 | + ), |
|
| 34 | + 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
| 35 | 35 | ), |
| 36 | 36 | 'deliciousbrains/wp-background-processing' => |
| 37 | 37 | array ( |
| 38 | - 'pretty_version' => '1.0.2', |
|
| 39 | - 'version' => '1.0.2.0', |
|
| 40 | - 'aliases' => |
|
| 41 | - array ( |
|
| 42 | - ), |
|
| 43 | - 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
|
| 38 | + 'pretty_version' => '1.0.2', |
|
| 39 | + 'version' => '1.0.2.0', |
|
| 40 | + 'aliases' => |
|
| 41 | + array ( |
|
| 42 | + ), |
|
| 43 | + 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
|
| 44 | + ), |
|
| 44 | 45 | ), |
| 45 | - ), |
|
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | 48 | |
@@ -11,34 +11,34 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class InstalledVersions |
| 13 | 13 | { |
| 14 | -private static $installed = array ( |
|
| 14 | +private static $installed = array( |
|
| 15 | 15 | 'root' => |
| 16 | - array ( |
|
| 16 | + array( |
|
| 17 | 17 | 'pretty_version' => 'dev-develop', |
| 18 | 18 | 'version' => 'dev-develop', |
| 19 | 19 | 'aliases' => |
| 20 | - array ( |
|
| 20 | + array( |
|
| 21 | 21 | ), |
| 22 | 22 | 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
| 23 | 23 | 'name' => '__root__', |
| 24 | 24 | ), |
| 25 | 25 | 'versions' => |
| 26 | - array ( |
|
| 26 | + array( |
|
| 27 | 27 | '__root__' => |
| 28 | - array ( |
|
| 28 | + array( |
|
| 29 | 29 | 'pretty_version' => 'dev-develop', |
| 30 | 30 | 'version' => 'dev-develop', |
| 31 | 31 | 'aliases' => |
| 32 | - array ( |
|
| 32 | + array( |
|
| 33 | 33 | ), |
| 34 | 34 | 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
| 35 | 35 | ), |
| 36 | 36 | 'deliciousbrains/wp-background-processing' => |
| 37 | - array ( |
|
| 37 | + array( |
|
| 38 | 38 | 'pretty_version' => '1.0.2', |
| 39 | 39 | 'version' => '1.0.2.0', |
| 40 | 40 | 'aliases' => |
| 41 | - array ( |
|
| 41 | + array( |
|
| 42 | 42 | ), |
| 43 | 43 | 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
| 44 | 44 | ), |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public static function getVersionRanges($packageName) |
| 103 | 103 | { |
| 104 | -if (!isset(self::$installed['versions'][$packageName])) { |
|
| 105 | -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
| 104 | +if ( ! isset(self::$installed['versions'][$packageName])) { |
|
| 105 | +throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $ranges = array(); |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | public static function getVersion($packageName) |
| 130 | 130 | { |
| 131 | -if (!isset(self::$installed['versions'][$packageName])) { |
|
| 132 | -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
| 131 | +if ( ! isset(self::$installed['versions'][$packageName])) { |
|
| 132 | +throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | -if (!isset(self::$installed['versions'][$packageName]['version'])) { |
|
| 135 | +if ( ! isset(self::$installed['versions'][$packageName]['version'])) { |
|
| 136 | 136 | return null; |
| 137 | 137 | } |
| 138 | 138 | |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | public static function getPrettyVersion($packageName) |
| 147 | 147 | { |
| 148 | -if (!isset(self::$installed['versions'][$packageName])) { |
|
| 149 | -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
| 148 | +if ( ! isset(self::$installed['versions'][$packageName])) { |
|
| 149 | +throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | -if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) { |
|
| 152 | +if ( ! isset(self::$installed['versions'][$packageName]['pretty_version'])) { |
|
| 153 | 153 | return null; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -162,11 +162,11 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | public static function getReference($packageName) |
| 164 | 164 | { |
| 165 | -if (!isset(self::$installed['versions'][$packageName])) { |
|
| 166 | -throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); |
|
| 165 | +if ( ! isset(self::$installed['versions'][$packageName])) { |
|
| 166 | +throw new \OutOfBoundsException('Package "'.$packageName.'" is not installed'); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | -if (!isset(self::$installed['versions'][$packageName]['reference'])) { |
|
| 169 | +if ( ! isset(self::$installed['versions'][$packageName]['reference'])) { |
|
| 170 | 170 | return null; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -6,17 +6,17 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b |
| 8 | 8 | { |
| 9 | - public static $classMap = array ( |
|
| 10 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
| 11 | - 'WP_Async_Request' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
| 12 | - 'WP_Background_Process' => __DIR__ . '/..' . '/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
| 13 | - 'Wordlift_Plugin_WP_Async_Request' => __DIR__ . '/../..' . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
| 14 | - 'Wordlift_Plugin_WP_Background_Process' => __DIR__ . '/../..' . '/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
| 9 | + public static $classMap = array( |
|
| 10 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
| 11 | + 'WP_Async_Request' => __DIR__.'/..'.'/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
| 12 | + 'WP_Background_Process' => __DIR__.'/..'.'/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
| 13 | + 'Wordlift_Plugin_WP_Async_Request' => __DIR__.'/../..'.'/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-async-request.php', |
|
| 14 | + 'Wordlift_Plugin_WP_Background_Process' => __DIR__.'/../..'.'/ext/dependencies/deliciousbrains/wp-background-processing/classes/wp-background-process.php', |
|
| 15 | 15 | ); |
| 16 | 16 | |
| 17 | 17 | public static function getInitializer(ClassLoader $loader) |
| 18 | 18 | { |
| 19 | - return \Closure::bind(function () use ($loader) { |
|
| 19 | + return \Closure::bind(function() use ($loader) { |
|
| 20 | 20 | $loader->classMap = ComposerStaticInit30c84c47a44576eaa4b38cc478d5e11b::$classMap; |
| 21 | 21 | |
| 22 | 22 | }, null, ClassLoader::class); |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php return array ( |
| 2 | - 'root' => |
|
| 3 | - array ( |
|
| 2 | + 'root' => |
|
| 3 | + array ( |
|
| 4 | 4 | 'pretty_version' => 'dev-develop', |
| 5 | 5 | 'version' => 'dev-develop', |
| 6 | 6 | 'aliases' => |
@@ -8,26 +8,26 @@ discard block |
||
| 8 | 8 | ), |
| 9 | 9 | 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
| 10 | 10 | 'name' => '__root__', |
| 11 | - ), |
|
| 12 | - 'versions' => |
|
| 13 | - array ( |
|
| 11 | + ), |
|
| 12 | + 'versions' => |
|
| 13 | + array ( |
|
| 14 | 14 | '__root__' => |
| 15 | 15 | array ( |
| 16 | - 'pretty_version' => 'dev-develop', |
|
| 17 | - 'version' => 'dev-develop', |
|
| 18 | - 'aliases' => |
|
| 19 | - array ( |
|
| 20 | - ), |
|
| 21 | - 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
| 16 | + 'pretty_version' => 'dev-develop', |
|
| 17 | + 'version' => 'dev-develop', |
|
| 18 | + 'aliases' => |
|
| 19 | + array ( |
|
| 20 | + ), |
|
| 21 | + 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
|
| 22 | 22 | ), |
| 23 | 23 | 'deliciousbrains/wp-background-processing' => |
| 24 | 24 | array ( |
| 25 | - 'pretty_version' => '1.0.2', |
|
| 26 | - 'version' => '1.0.2.0', |
|
| 27 | - 'aliases' => |
|
| 28 | - array ( |
|
| 29 | - ), |
|
| 30 | - 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
|
| 25 | + 'pretty_version' => '1.0.2', |
|
| 26 | + 'version' => '1.0.2.0', |
|
| 27 | + 'aliases' => |
|
| 28 | + array ( |
|
| 29 | + ), |
|
| 30 | + 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
|
| 31 | + ), |
|
| 31 | 32 | ), |
| 32 | - ), |
|
| 33 | 33 | ); |
@@ -1,31 +1,31 @@ |
||
| 1 | -<?php return array ( |
|
| 1 | +<?php return array( |
|
| 2 | 2 | 'root' => |
| 3 | - array ( |
|
| 3 | + array( |
|
| 4 | 4 | 'pretty_version' => 'dev-develop', |
| 5 | 5 | 'version' => 'dev-develop', |
| 6 | 6 | 'aliases' => |
| 7 | - array ( |
|
| 7 | + array( |
|
| 8 | 8 | ), |
| 9 | 9 | 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
| 10 | 10 | 'name' => '__root__', |
| 11 | 11 | ), |
| 12 | 12 | 'versions' => |
| 13 | - array ( |
|
| 13 | + array( |
|
| 14 | 14 | '__root__' => |
| 15 | - array ( |
|
| 15 | + array( |
|
| 16 | 16 | 'pretty_version' => 'dev-develop', |
| 17 | 17 | 'version' => 'dev-develop', |
| 18 | 18 | 'aliases' => |
| 19 | - array ( |
|
| 19 | + array( |
|
| 20 | 20 | ), |
| 21 | 21 | 'reference' => '2b5035defcc45dcd4370a5865ba4fe5e91035435', |
| 22 | 22 | ), |
| 23 | 23 | 'deliciousbrains/wp-background-processing' => |
| 24 | - array ( |
|
| 24 | + array( |
|
| 25 | 25 | 'pretty_version' => '1.0.2', |
| 26 | 26 | 'version' => '1.0.2.0', |
| 27 | 27 | 'aliases' => |
| 28 | - array ( |
|
| 28 | + array( |
|
| 29 | 29 | ), |
| 30 | 30 | 'reference' => '2cbee1abd1b49e1133cd8f611df4d4fc5a8b9800', |
| 31 | 31 | ), |
@@ -4,29 +4,29 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface Api_Service { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @param $method |
|
| 9 | - * @param $path |
|
| 10 | - * @param array $headers |
|
| 11 | - * @param null $body |
|
| 12 | - * @param null $timeout |
|
| 13 | - * @param null $user_agent |
|
| 14 | - * @param array $args |
|
| 15 | - * |
|
| 16 | - * @return Response |
|
| 17 | - */ |
|
| 18 | - public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
| 7 | + /** |
|
| 8 | + * @param $method |
|
| 9 | + * @param $path |
|
| 10 | + * @param array $headers |
|
| 11 | + * @param null $body |
|
| 12 | + * @param null $timeout |
|
| 13 | + * @param null $user_agent |
|
| 14 | + * @param array $args |
|
| 15 | + * |
|
| 16 | + * @return Response |
|
| 17 | + */ |
|
| 18 | + public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @param $path |
|
| 22 | - * @param array $headers |
|
| 23 | - * @param null $body |
|
| 24 | - * @param null $timeout |
|
| 25 | - * @param null $user_agent |
|
| 26 | - * @param array $args |
|
| 27 | - * |
|
| 28 | - * @return Response |
|
| 29 | - */ |
|
| 30 | - public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
| 20 | + /** |
|
| 21 | + * @param $path |
|
| 22 | + * @param array $headers |
|
| 23 | + * @param null $body |
|
| 24 | + * @param null $timeout |
|
| 25 | + * @param null $user_agent |
|
| 26 | + * @param array $args |
|
| 27 | + * |
|
| 28 | + * @return Response |
|
| 29 | + */ |
|
| 30 | + public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
| 31 | 31 | |
| 32 | 32 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @return Response |
| 17 | 17 | */ |
| 18 | - public function request( $method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
| 18 | + public function request($method, $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()); |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @param $path |
@@ -27,6 +27,6 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return Response |
| 29 | 29 | */ |
| 30 | - public function get( $path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array() ); |
|
| 30 | + public function get($path, $headers = array(), $body = null, $timeout = null, $user_agent = null, $args = array()); |
|
| 31 | 31 | |
| 32 | 32 | } |