diff --git a/config.php b/config.php index 6c391518d3..9964c1c155 100644 --- a/config.php +++ b/config.php @@ -1,7 +1,7 @@ directorist-woocommerce-pricing-plans - * - * Note: Plugins are mutually exclusive - only one can be active at a time. - * This method checks both class existence and admin settings. + * Priority: directorist-pricing-plans > directorist-woocommerce-pricing-plans. * - * @return string 'atbdp' or 'dwpp' or null + * @return string 'dpp' or 'dwpp' or null. */ protected function get_active_plugin_type() { if ( null !== $this->active_plugin_type ) { return $this->active_plugin_type; } - // Priority: directorist-pricing-plans first - // Check class exists AND admin setting is enabled - if ( class_exists( 'ATBDP_Pricing_Plans' ) ) { - $fee_manager_enabled = get_directorist_option( 'fee_manager_enable', 1 ); - if ( $fee_manager_enabled ) { - $this->active_plugin_type = 'atbdp'; - return $this->active_plugin_type; - } + if ( $this->is_active_pricing_plans() ) { + $this->active_plugin_type = 'dpp'; + return $this->active_plugin_type; } - // Fallback to WooCommerce pricing plans - // Check class exists AND admin setting is enabled if ( class_exists( 'DWPP_Pricing_Plans' ) ) { $woo_pricing_plans_enabled = get_directorist_option( 'woo_pricing_plans_enable', 1 ); if ( $woo_pricing_plans_enabled ) { @@ -124,18 +113,24 @@ protected function get_active_plugin_type() { return $this->active_plugin_type; } + protected function is_active_pricing_plans() { + return (bool) apply_filters( 'directorist_is_active_pricing_plans', false ); + } + public function get_items_permissions_check( $request ) { - if ( ! is_fee_manager_active() ) { - return new WP_Error( 'extension_inactive', __( 'Pricing plan extension disabled.', 'directorist' ), array( 'status' => 400 ) ); - } - $plugin_type = $this->get_active_plugin_type(); + if ( ! $plugin_type ) { return new WP_Error( 'extension_inactive', __( 'Pricing plan extension inactive.', 'directorist' ), array( 'status' => 400 ) ); } + if ( 'dpp' === $plugin_type ) { + return apply_filters( 'directorist_rest_pricing_plans_permissions_check', true, $request ); + } + // Verify post type is registered $post_type = ( 'dwpp' === $plugin_type ) ? 'product' : $this->post_type; + if ( ! post_type_exists( $post_type ) ) { return new WP_Error( 'post_type_not_registered', @@ -144,27 +139,29 @@ public function get_items_permissions_check( $request ) { ); } - return parent::get_items_permissions_check( $request ); + return true; } public function get_item_permissions_check( $request ) { - if ( ! is_fee_manager_active() ) { - return new WP_Error( 'extension_inactive', __( 'Pricing plan extension disabled.', 'directorist' ), array( 'status' => 400 ) ); - } - $plugin_type = $this->get_active_plugin_type(); + if ( ! $plugin_type ) { return new WP_Error( 'extension_inactive', __( 'Pricing plan extension inactive.', 'directorist' ), array( 'status' => 400 ) ); } + if ( 'dpp' === $plugin_type ) { + return apply_filters( 'directorist_rest_pricing_plan_permissions_check', true, $request ); + } + // Verify post type is registered $post_type = ( 'dwpp' === $plugin_type ) ? 'product' : $this->post_type; + if ( ! post_type_exists( $post_type ) ) { /* translators: %s: Post type name */ return new WP_Error( 'post_type_not_registered', sprintf( __( 'Pricing plans post type "%s" is not registered.', 'directorist' ), esc_html( $post_type ) ), array( 'status' => 500 ) ); } - return parent::get_item_permissions_check( $request ); + return true; } /** @@ -174,22 +171,26 @@ public function get_item_permissions_check( $request ) { * @return WP_Error|WP_REST_Response */ public function get_items( $request ) { + if ( 'dpp' === $this->get_active_plugin_type() ) { + return $this->get_pricing_plan_items_from_provider( $request ); + } + $query_args = $this->prepare_objects_query( $request ); do_action( 'directorist_rest_before_query', 'get_plan_items', $request, $query_args ); $query_results = $this->get_plans( $query_args ); - $objects = array(); + $objects = array(); $plugin_type = $this->get_active_plugin_type(); - $post_type = ( 'dwpp' === $plugin_type ) ? 'product' : $this->post_type; + $post_type = ( 'dwpp' === $plugin_type ) ? 'product' : $this->post_type; foreach ( $query_results['objects'] as $object ) { if ( ! $this->check_post_permissions( $post_type, 'read', $object->ID ) ) { continue; } - $data = $this->prepare_item_for_response( $object, $request ); + $data = $this->prepare_item_for_response( $object, $request ); $objects[] = $this->prepare_response_for_collection( $data ); } @@ -223,6 +224,16 @@ public function get_items( $request ) { return $response; } + protected function get_pricing_plan_items_from_provider( $request ) { + $response = apply_filters( 'directorist_rest_pricing_plans_data', null, $request ); + + if ( null === $response ) { + return new WP_Error( 'extension_inactive', __( 'Pricing plan extension inactive.', 'directorist' ), array( 'status' => 400 ) ); + } + + return rest_ensure_response( $response ); + } + protected function get_plans( $query_args ) { $query = new WP_Query(); $result = $query->query( $query_args ); @@ -251,7 +262,7 @@ protected function get_plans( $query_args ) { */ protected function prepare_objects_query( $request ) { $plugin_type = $this->get_active_plugin_type(); - $post_type = ( 'dwpp' === $plugin_type ) ? 'product' : $this->post_type; + $post_type = ( 'dwpp' === $plugin_type ) ? 'product' : $this->post_type; $args = []; $args['order'] = $request['order']; @@ -271,12 +282,12 @@ protected function prepare_objects_query( $request ) { } if ( directorist_is_multi_directory_enabled() && ! empty( $request['directory'] ) ) { - $args['meta_key'] = '_assign_to_directory'; + $args['meta_key'] = '_assign_to_directory'; $args['meta_value'] = $request['directory']; } if ( ! directorist_is_multi_directory_enabled() ) { - $args['meta_key'] = '_assign_to_directory'; + $args['meta_key'] = '_assign_to_directory'; $args['meta_value'] = directorist_get_default_directory(); } @@ -317,10 +328,14 @@ protected function add_post_meta_fields( $post, $request ) { public function get_item( $request ) { $id = (int) $request['id']; + if ( 'dpp' === $this->get_active_plugin_type() ) { + return $this->get_pricing_plan_item_from_provider( $request, $id ); + } + do_action( 'directorist_rest_before_query', 'get_plan_item', $request, $id ); - $post = get_post( $id ); - $plugin_type = $this->get_active_plugin_type(); + $post = get_post( $id ); + $plugin_type = $this->get_active_plugin_type(); $expected_post_type = ( 'dwpp' === $plugin_type ) ? 'product' : $this->post_type; if ( empty( $id ) || empty( $post->ID ) || $post->post_type !== $expected_post_type ) { @@ -335,7 +350,7 @@ public function get_item( $request ) { } } - $data = $this->prepare_item_for_response( $post, $request ); + $data = $this->prepare_item_for_response( $post, $request ); $response = rest_ensure_response( $data ); do_action( 'directorist_rest_after_query', 'get_plan_item', $request, $id ); @@ -345,6 +360,16 @@ public function get_item( $request ) { return $response; } + protected function get_pricing_plan_item_from_provider( $request, $id ) { + $response = apply_filters( 'directorist_rest_pricing_plan_data', null, $request, $id ); + + if ( null === $response ) { + return new WP_Error( "directorist_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'directorist' ), array( 'status' => 404 ) ); + } + + return rest_ensure_response( $response ); + } + /** * Prepare a single plans output for response. * @@ -358,8 +383,8 @@ public function prepare_item_for_response( $object, $request ) { $this->request = $request; $data = $this->get_plan_data( $object, $request, $context ); - $data = $this->add_additional_fields_to_object( $data, $request ); - $data = $this->filter_response_by_context( $data, $context ); + $data = $this->add_additional_fields_to_object( $data, $request ); + $data = $this->filter_response_by_context( $data, $context ); $response = rest_ensure_response( $data ); $response->add_links( $this->prepare_links( $object, $request ) ); @@ -392,8 +417,8 @@ protected function get_directory_id( $plan ) { */ protected function get_plan_meta( $plan, $meta_key, $dwpp_meta_key = null, $default = '' ) { $plugin_type = $this->get_active_plugin_type(); - $key = ( 'dwpp' === $plugin_type && null !== $dwpp_meta_key ) ? $dwpp_meta_key : $meta_key; - $value = get_post_meta( $plan->ID, $key, true ); + $key = ( 'dwpp' === $plugin_type && null !== $dwpp_meta_key ) ? $dwpp_meta_key : $meta_key; + $value = get_post_meta( $plan->ID, $key, true ); return ( '' !== $value ) ? $value : $default; } @@ -431,7 +456,7 @@ protected function get_plan_price( $plan ) { * @return array */ protected function get_plan_data( $plan, $request, $context = 'view' ) { - $fields = $this->get_fields_for_response( $request ); + $fields = $this->get_fields_for_response( $request ); $base_data = array(); foreach ( $fields as $field ) { @@ -490,7 +515,7 @@ protected function get_plan_data( $plan, $request, $context = 'view' ) { case 'is_free': $plugin_type = $this->get_active_plugin_type(); if ( 'dwpp' === $plugin_type ) { - $product = wc_get_product( $plan->ID ); + $product = wc_get_product( $plan->ID ); $base_data['is_free'] = $product ? ( (float) $product->get_price() <= 0 ) : false; } else { $base_data['is_free'] = (bool) $this->get_plan_meta( $plan, 'free_plan' ); @@ -593,13 +618,13 @@ protected function get_plan_type( $plan ) { } protected function get_features_data( $plan ) { - $features = array(); + $features = array(); $plugin_type = $this->get_active_plugin_type(); // Auto renewal - $recurring_key = ( 'dwpp' === $plugin_type ) ? '_enable_subscription' : '_atpp_recurring'; + $recurring_key = ( 'dwpp' === $plugin_type ) ? '_enable_subscription' : '_atpp_recurring'; $hide_recurring_key = ( 'dwpp' === $plugin_type ) ? '_hide_subscription' : 'hide_recurring'; - $features[] = array( + $features[] = array( 'key' => 'auto_renewal', 'label' => esc_html__( 'Auto renewing', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, '_atpp_recurring', $recurring_key ), @@ -607,7 +632,7 @@ protected function get_features_data( $plan ) { ); if ( $this->get_plan_type( $plan ) === 'package' ) { - $regular_listing_count = (int) $this->get_plan_meta( $plan, 'num_regular', 'num_regular', 0 ); + $regular_listing_count = (int) $this->get_plan_meta( $plan, 'num_regular', 'num_regular', 0 ); $unlimited_regular_listings = (bool) $this->get_plan_meta( $plan, 'num_regular_unl', 'num_regular_unl' ); if ( $unlimited_regular_listings ) { @@ -617,7 +642,7 @@ protected function get_features_data( $plan ) { } $hide_listings_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_listings' : 'hide_listings'; - $features[] = array( + $features[] = array( 'key' => 'regular_listings', 'label' => $regular_listing_label, 'is_active' => true, @@ -625,7 +650,7 @@ protected function get_features_data( $plan ) { 'limit' => $unlimited_regular_listings ? -1 : $regular_listing_count, ); - $featured_listing_count = (int) $this->get_plan_meta( $plan, 'num_featured', 'num_featured', 0 ); + $featured_listing_count = (int) $this->get_plan_meta( $plan, 'num_featured', 'num_featured', 0 ); $unlimited_featured_listings = (bool) $this->get_plan_meta( $plan, 'num_featured_unl', 'num_featured_unl' ); if ( $unlimited_featured_listings ) { @@ -635,7 +660,7 @@ protected function get_features_data( $plan ) { } $hide_featured_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_featured' : 'hide_featured'; - $features[] = array( + $features[] = array( 'key' => 'featured_listings', 'label' => $featured_listing_label, 'is_active' => true, @@ -644,7 +669,7 @@ protected function get_features_data( $plan ) { ); } else { $hide_listing_featured_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_listing_featured' : 'hide_listing_featured'; - $features[] = array( + $features[] = array( 'key' => 'featured_listing', 'label' => esc_html__( 'Listing as featured', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, 'is_featured_listing', 'is_featured_listing' ), @@ -653,7 +678,7 @@ protected function get_features_data( $plan ) { } $hide_cl_owner_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_cl_owner' : 'hide_Cowner'; - $features[] = array( + $features[] = array( 'key' => 'contact_listing_owner', 'label' => esc_html__( 'Contact Owner', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, 'cf_owner', 'cf_owner' ), @@ -661,7 +686,7 @@ protected function get_features_data( $plan ) { ); $hide_customer_review_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_customer_review' : 'hide_review'; - $features[] = array( + $features[] = array( 'key' => 'reviews_allowed', 'label' => esc_html__( 'Allow Customer Review', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, 'fm_cs_review', 'fm_cs_review' ), @@ -669,7 +694,7 @@ protected function get_features_data( $plan ) { ); $hide_claim_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_claim' : '_hide_claim'; - $features[] = array( + $features[] = array( 'key' => 'claim_badge_included', 'label' => esc_html__( 'Claim Badge Included', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, '_fm_claim', '_fm_claim' ), @@ -677,7 +702,7 @@ protected function get_features_data( $plan ) { ); $hide_booking_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_booking' : '_hide_booking'; - $features[] = array( + $features[] = array( 'key' => 'booking_included', 'label' => esc_html__( 'Booking Included', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, '_fm_booking', '_fm_booking' ), @@ -685,7 +710,7 @@ protected function get_features_data( $plan ) { ); $hide_live_chat_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_live_chat' : '_hide_live_chat'; - $features[] = array( + $features[] = array( 'key' => 'live_chat_included', 'label' => esc_html__( 'Live Chat Included', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, '_fm_live_chat', '_fm_live_chat' ), @@ -693,7 +718,7 @@ protected function get_features_data( $plan ) { ); $hide_mark_as_sold_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_mark_as_sold' : '_hide_mark_as_sold'; - $features[] = array( + $features[] = array( 'key' => 'mark_as_sold_included', 'label' => esc_html__( 'Mark as Sold Included', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, '_fm_mark_as_sold', '_fm_mark_as_sold' ), @@ -701,7 +726,7 @@ protected function get_features_data( $plan ) { ); $hide_category_key = ( 'dwpp' === $plugin_type ) ? '_dwpp_hide_category' : 'hide_categories'; - $features[] = array( + $features[] = array( 'key' => 'categories_included', 'label' => esc_html__( 'All Categories', 'directorist' ), 'is_active' => (bool) $this->get_plan_meta( $plan, 'exclude_cat', 'exclude_cat' ), @@ -723,8 +748,8 @@ protected function get_fields_data( $plan ) { 'excerpt' => _n_noop( '%s (maximum %d character)', '%s (maximum %d characters)', 'directorist' ), 'image_upload' => _n_noop( '%s (maximum %d item)', '%s (maximum %d items)', 'directorist' ), ); - $fields = array_keys( $translations ); - $field_data = array(); + $fields = array_keys( $translations ); + $field_data = array(); foreach ( $form_fields as $form_field ) { $field_key = $form_field['field_key']; @@ -749,19 +774,19 @@ protected function get_fields_data( $plan ) { continue; } - $plugin_type = $this->get_active_plugin_type(); - $active_key = '_' . $field_key; - $hide_key = '_hide_' . $field_key; + $plugin_type = $this->get_active_plugin_type(); + $active_key = '_' . $field_key; + $hide_key = '_hide_' . $field_key; $unlimited_key = '_unlimited_' . $field_key; - $max_key = '_max_' . $field_key; + $max_key = '_max_' . $field_key; // For WooCommerce, check if it uses _dwpp_ prefix if ( 'dwpp' === $plugin_type ) { // Try _dwpp_ prefix first, fallback to regular $dwpp_active = get_post_meta( $plan->ID, '_dwpp_' . $field_key, true ); - $dwpp_hide = get_post_meta( $plan->ID, '_dwpp_hide_' . $field_key, true ); - $active_key = ( '' !== $dwpp_active || '' !== $dwpp_hide ) ? '_dwpp_' . $field_key : $active_key; - $hide_key = ( '' !== $dwpp_hide ) ? '_dwpp_hide_' . $field_key : $hide_key; + $dwpp_hide = get_post_meta( $plan->ID, '_dwpp_hide_' . $field_key, true ); + $active_key = ( '' !== $dwpp_active || '' !== $dwpp_hide ) ? '_dwpp_' . $field_key : $active_key; + $hide_key = ( '' !== $dwpp_hide ) ? '_dwpp_hide_' . $field_key : $hide_key; } $data = array( @@ -823,142 +848,142 @@ protected function prepare_links( $object, $request ) { * @return array */ public function get_item_schema() { - $schema = array( + $schema = array( '$schema' => 'http://json-schema.org/draft-04/schema#', 'title' => $this->post_type, 'type' => 'object', 'properties' => array( - 'id' => array( + 'id' => array( 'description' => __( 'Unique identifier for the resource.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'name' => array( + 'name' => array( 'description' => __( 'plan name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'date_created' => array( + 'date_created' => array( 'description' => __( "The date the plan was created, in the site's timezone.", 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'date_modified' => array( + 'date_modified' => array( 'description' => __( "The date the plan was last modified, in the site's timezone.", 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'description' => array( + 'description' => array( 'description' => __( 'Plan description.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'hide_description_from_plan' => array( + 'hide_description_from_plan' => array( 'description' => __( 'Hide description from plan.', 'directorist' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), ), - 'directory' => array( + 'directory' => array( 'description' => __( 'Directory id.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), ), - 'status' => array( + 'status' => array( 'description' => __( 'Plan status.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'is_recommended' => array( + 'is_recommended' => array( 'description' => __( 'Plan recommendation status.', 'directorist' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), ), - 'is_hidden' => array( + 'is_hidden' => array( 'description' => __( 'Plan hidden during plan selection.', 'directorist' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), ), - 'type' => array( + 'type' => array( 'description' => __( 'Plan type.', 'directorist' ), 'type' => 'string', 'enum' => array( 'package', 'pay_per_listing' ), 'context' => array( 'view', 'edit' ), ), - 'type_label' => array( + 'type_label' => array( 'description' => __( 'Plan type label.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'currency' => array( + 'currency' => array( 'description' => __( 'Plan currency.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'currency_symbol' => array( + 'currency_symbol' => array( 'description' => __( 'Plan currency symbol.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'is_free' => array( + 'is_free' => array( 'description' => __( 'Is plan free?.', 'directorist' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), ), - 'price' => array( + 'price' => array( 'description' => __( 'Plan price.', 'directorist' ), 'type' => 'float', 'context' => array( 'view', 'edit' ), ), - 'is_taxable' => array( + 'is_taxable' => array( 'description' => __( 'Is plan taxable?', 'directorist' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), ), - 'tax_type' => array( + 'tax_type' => array( 'description' => __( 'Plan tax type', 'directorist' ), 'type' => 'string', 'enum' => array( 'fixed', 'percentage' ), 'context' => array( 'view', 'edit' ), ), - 'tax' => array( + 'tax' => array( 'description' => __( 'Plan tax amount.', 'directorist' ), 'type' => 'float', 'context' => array( 'view', 'edit' ), ), - 'validity_period' => array( + 'validity_period' => array( 'description' => __( 'Plan validity period.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), ), - 'validity_period_unit' => array( + 'validity_period_unit' => array( 'description' => __( 'Plan validity period unit.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'validity_period_label' => array( + 'validity_period_label' => array( 'description' => __( 'Plan validity period label.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'is_non_expiring' => array( + 'is_non_expiring' => array( 'description' => __( 'Is plan non expiring?', 'directorist' ), 'type' => 'boolean', 'context' => array( 'view', 'edit' ), ), - 'playstore_product_id' => array( + 'playstore_product_id' => array( 'description' => __( 'PlayStore product Id.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'playstore_product_price' => array( + 'playstore_product_price' => array( 'description' => __( 'PlayStore product price.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'appstore_product_id' => array( + 'appstore_product_id' => array( 'description' => __( 'AppStore product Id.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -968,25 +993,25 @@ public function get_item_schema() { 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'features' => array( + 'features' => array( 'description' => __( 'Features data.', 'directorist' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'items' => array( 'type' => 'object', 'properties' => array( - 'key' => array( + 'key' => array( 'description' => __( 'Feature key.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'label' => array( + 'label' => array( 'description' => __( 'Feature label.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'is_active' => array( + 'is_active' => array( 'description' => __( 'Feature active status.', 'directorist' ), 'type' => 'bool', 'context' => array( 'view', 'edit' ), @@ -996,7 +1021,7 @@ public function get_item_schema() { 'type' => 'bool', 'context' => array( 'view', 'edit' ), ), - 'limit' => array( + 'limit' => array( 'description' => __( 'Feature limited to number of times (-1 indicates unlimited).', 'directorist' ), 'type' => 'number', 'context' => array( 'view', 'edit' ), @@ -1004,30 +1029,30 @@ public function get_item_schema() { ), ), ), - 'fields' => array( + 'fields' => array( 'description' => __( 'Fields data.', 'directorist' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'items' => array( 'type' => 'object', 'properties' => array( - 'key' => array( + 'key' => array( 'description' => __( 'Field key.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'label' => array( + 'label' => array( 'description' => __( 'Field label.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'is_preset' => array( + 'is_preset' => array( 'description' => __( 'Preset or custom field status.', 'directorist' ), 'type' => 'bool', 'context' => array( 'view', 'edit' ), ), - 'is_active' => array( + 'is_active' => array( 'description' => __( 'Field active status.', 'directorist' ), 'type' => 'bool', 'context' => array( 'view', 'edit' ), @@ -1037,7 +1062,7 @@ public function get_item_schema() { 'type' => 'bool', 'context' => array( 'view', 'edit' ), ), - 'limit' => array( + 'limit' => array( 'description' => __( 'Feature limited to number of times (-1 indicates unlimited).', 'directorist' ), 'type' => 'number', 'context' => array( 'view', 'edit' ), @@ -1061,26 +1086,26 @@ public function get_collection_params() { $params['context']['default'] = 'view'; - $params['order'] = array( - 'default' => 'desc', - 'description' => __( 'Order sort attribute ascending or descending.', 'directorist' ), - 'enum' => array( 'asc', 'desc' ), - 'type' => 'string', - 'sanitize_callback' => 'sanitize_key', + $params['order'] = array( + 'default' => 'desc', + 'description' => __( 'Order sort attribute ascending or descending.', 'directorist' ), + 'enum' => array( 'asc', 'desc' ), + 'type' => 'string', + 'sanitize_callback' => 'sanitize_key', ); $params['orderby'] = array( - 'description' => __( 'Sort collection by object attribute.', 'directorist' ), - 'enum' => array_keys( $this->get_orderby_possibles() ), - 'default' => 'title', - 'type' => 'string', - 'sanitize_callback' => 'sanitize_key', + 'description' => __( 'Sort collection by object attribute.', 'directorist' ), + 'enum' => array_keys( $this->get_orderby_possibles() ), + 'default' => 'title', + 'type' => 'string', + 'sanitize_callback' => 'sanitize_key', ); if ( directorist_is_multi_directory_enabled() ) { $params['directory'] = array( - 'description' => __( 'Query plans by directory id.', 'directorist' ), - 'type' => 'integer', - 'sanitize_callback' => 'absint', + 'description' => __( 'Query plans by directory id.', 'directorist' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', ); } @@ -1089,8 +1114,8 @@ public function get_collection_params() { protected function get_orderby_possibles() { return array( - 'title' => 'title', - 'date' => 'date', + 'title' => 'title', + 'date' => 'date', ); } } diff --git a/languages/directorist.pot b/languages/directorist.pot index b674ade817..d22433a347 100644 --- a/languages/directorist.pot +++ b/languages/directorist.pot @@ -6,7 +6,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2026-07-26 08:17+0000\n" +"POT-Creation-Date: 2026-07-26 09:57+0000\n" "X-Poedit-Basepath: ..\n" "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" "X-Poedit-SearchPath-0: .\n" @@ -8241,7 +8241,7 @@ msgstr "" msgid "Name for the resource." msgstr "" -#: ../includes/rest-api/Version1/class-abstract-terms-controller.php:80, ../includes/rest-api/Version1/class-categories-controller.php:113, ../includes/rest-api/Version1/class-directories-controller.php:104, ../includes/rest-api/Version1/class-listing-reviews-controller.php:53, ../includes/rest-api/Version1/class-listing-reviews-controller.php:402, ../includes/rest-api/Version1/class-listings-controller.php:68, ../includes/rest-api/Version1/class-listings-controller.php:94, ../includes/rest-api/Version1/class-listings-controller.php:1091, ../includes/rest-api/Version1/class-locations-controller.php:110, ../includes/rest-api/Version1/class-plans-controller.php:832, ../includes/rest-api/Version1/class-tags-controller.php:83, ../includes/rest-api/Version1/class-users-controller.php:73, ../includes/rest-api/Version1/class-users-controller.php:756, ../includes/rest-api/Version2/class-listings-controller.php:90, ../includes/rest-api/Version2/class-listings-controller.php:1015 +#: ../includes/rest-api/Version1/class-abstract-terms-controller.php:80, ../includes/rest-api/Version1/class-categories-controller.php:113, ../includes/rest-api/Version1/class-directories-controller.php:104, ../includes/rest-api/Version1/class-listing-reviews-controller.php:53, ../includes/rest-api/Version1/class-listing-reviews-controller.php:402, ../includes/rest-api/Version1/class-listings-controller.php:68, ../includes/rest-api/Version1/class-listings-controller.php:94, ../includes/rest-api/Version1/class-listings-controller.php:1091, ../includes/rest-api/Version1/class-locations-controller.php:110, ../includes/rest-api/Version1/class-plans-controller.php:857, ../includes/rest-api/Version1/class-tags-controller.php:83, ../includes/rest-api/Version1/class-users-controller.php:73, ../includes/rest-api/Version1/class-users-controller.php:756, ../includes/rest-api/Version2/class-listings-controller.php:90, ../includes/rest-api/Version2/class-listings-controller.php:1015 msgid "Unique identifier for the resource." msgstr "" @@ -8281,7 +8281,7 @@ msgstr "" msgid "Offset the result set by a specific number of items. Applies to hierarchical taxonomies only." msgstr "" -#: ../includes/rest-api/Version1/class-abstract-terms-controller.php:775, ../includes/rest-api/Version1/class-listing-reviews-controller.php:526, ../includes/rest-api/Version1/class-listings-controller.php:1524, ../includes/rest-api/Version1/class-orders-controller.php:356, ../includes/rest-api/Version1/class-plans-controller.php:1066, ../includes/rest-api/Version1/class-users-controller.php:1025 +#: ../includes/rest-api/Version1/class-abstract-terms-controller.php:775, ../includes/rest-api/Version1/class-listing-reviews-controller.php:526, ../includes/rest-api/Version1/class-listings-controller.php:1524, ../includes/rest-api/Version1/class-orders-controller.php:356, ../includes/rest-api/Version1/class-plans-controller.php:1091, ../includes/rest-api/Version1/class-users-controller.php:1025 msgid "Order sort attribute ascending or descending." msgstr "" @@ -8333,7 +8333,7 @@ msgstr "" msgid "The value must not be empty." msgstr "" -#: ../includes/rest-api/Version1/class-builder-controller.php:39, ../includes/rest-api/Version1/class-builder-controller.php:69, ../includes/rest-api/Version1/class-plans-controller.php:865, ../includes/rest-api/Version2/class-listings-controller.php:49, ../includes/rest-api/Version2/class-listings-controller.php:1064 +#: ../includes/rest-api/Version1/class-builder-controller.php:39, ../includes/rest-api/Version1/class-builder-controller.php:69, ../includes/rest-api/Version1/class-plans-controller.php:890, ../includes/rest-api/Version2/class-listings-controller.php:49, ../includes/rest-api/Version2/class-listings-controller.php:1064 msgid "Directory id." msgstr "" @@ -8526,7 +8526,7 @@ msgstr "" msgid "Offset the result set by a specific number of items." msgstr "" -#: ../includes/rest-api/Version1/class-listing-reviews-controller.php:535, ../includes/rest-api/Version1/class-listings-controller.php:1532, ../includes/rest-api/Version1/class-orders-controller.php:363, ../includes/rest-api/Version1/class-plans-controller.php:1072, ../includes/rest-api/Version1/class-users-controller.php:1033 +#: ../includes/rest-api/Version1/class-listing-reviews-controller.php:535, ../includes/rest-api/Version1/class-listings-controller.php:1532, ../includes/rest-api/Version1/class-orders-controller.php:363, ../includes/rest-api/Version1/class-plans-controller.php:1097, ../includes/rest-api/Version1/class-users-controller.php:1033 msgid "Sort collection by object attribute." msgstr "" @@ -8602,7 +8602,7 @@ msgstr "" msgid "Sorry, you are not allowed to change this listing status." msgstr "" -#: ../includes/rest-api/Version1/class-listings-controller.php:577, ../includes/rest-api/Version1/class-orders-controller.php:208, ../includes/rest-api/Version1/class-plans-controller.php:327, ../includes/rest-api/Version1/class-plans-controller.php:334 +#: ../includes/rest-api/Version1/class-listings-controller.php:577, ../includes/rest-api/Version1/class-orders-controller.php:208, ../includes/rest-api/Version1/class-plans-controller.php:342, ../includes/rest-api/Version1/class-plans-controller.php:349, ../includes/rest-api/Version1/class-plans-controller.php:367 msgid "Invalid ID." msgstr "" @@ -8926,290 +8926,286 @@ msgstr "" msgid "Limit result set to specific customer id." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:68, ../includes/rest-api/Version2/class-listings-controller.php:55 +#: ../includes/rest-api/Version1/class-plans-controller.php:67, ../includes/rest-api/Version2/class-listings-controller.php:55 msgid "Plan id." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:129, ../includes/rest-api/Version1/class-plans-controller.php:152 -msgid "Pricing plan extension disabled." -msgstr "" - -#: ../includes/rest-api/Version1/class-plans-controller.php:134, ../includes/rest-api/Version1/class-plans-controller.php:157 +#: ../includes/rest-api/Version1/class-plans-controller.php:124, ../includes/rest-api/Version1/class-plans-controller.php:149, ../includes/rest-api/Version1/class-plans-controller.php:231 msgid "Pricing plan extension inactive." msgstr "" #. translators: %s: Post type name -#: ../includes/rest-api/Version1/class-plans-controller.php:142, ../includes/rest-api/Version1/class-plans-controller.php:164 +#: ../includes/rest-api/Version1/class-plans-controller.php:137, ../includes/rest-api/Version1/class-plans-controller.php:161 msgid "Pricing plans post type \"%s\" is not registered." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:482 +#: ../includes/rest-api/Version1/class-plans-controller.php:507 msgid "Per Package" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:482 +#: ../includes/rest-api/Version1/class-plans-controller.php:507 msgid "Per Listing" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:551 +#: ../includes/rest-api/Version1/class-plans-controller.php:576 msgid "Lifetime" msgstr "" #. translators: %d: Number of days -#: ../includes/rest-api/Version1/class-plans-controller.php:558 +#: ../includes/rest-api/Version1/class-plans-controller.php:583 msgid "%d day" msgid_plural "%d days" msgstr[0] "" msgstr[1] "" #. translators: %d: Number of weeks -#: ../includes/rest-api/Version1/class-plans-controller.php:560 +#: ../includes/rest-api/Version1/class-plans-controller.php:585 msgid "%d week" msgid_plural "%d weeks" msgstr[0] "" msgstr[1] "" #. translators: %d: Number of months -#: ../includes/rest-api/Version1/class-plans-controller.php:562 +#: ../includes/rest-api/Version1/class-plans-controller.php:587 msgid "%d month" msgid_plural "%d months" msgstr[0] "" msgstr[1] "" #. translators: %d: Number of years -#: ../includes/rest-api/Version1/class-plans-controller.php:564 +#: ../includes/rest-api/Version1/class-plans-controller.php:589 msgid "%d year" msgid_plural "%d years" msgstr[0] "" msgstr[1] "" -#: ../includes/rest-api/Version1/class-plans-controller.php:604 +#: ../includes/rest-api/Version1/class-plans-controller.php:629 msgid "Auto renewing" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:649 +#: ../includes/rest-api/Version1/class-plans-controller.php:674 msgid "Listing as featured" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:616 +#: ../includes/rest-api/Version1/class-plans-controller.php:641 msgid "%s Regular Listing" msgid_plural "%s Regular Listings" msgstr[0] "" msgstr[1] "" -#: ../includes/rest-api/Version1/class-plans-controller.php:614 +#: ../includes/rest-api/Version1/class-plans-controller.php:639 msgid "Unlimited Regular Listings" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:634 +#: ../includes/rest-api/Version1/class-plans-controller.php:659 msgid "%s Featured Listing" msgid_plural "%s Featured Listings" msgstr[0] "" msgstr[1] "" -#: ../includes/rest-api/Version1/class-plans-controller.php:632 +#: ../includes/rest-api/Version1/class-plans-controller.php:657 msgid "Unlimited Featured Listings" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:658 +#: ../includes/rest-api/Version1/class-plans-controller.php:683 msgid "Contact Owner" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:666 +#: ../includes/rest-api/Version1/class-plans-controller.php:691 msgid "Allow Customer Review" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:674 +#: ../includes/rest-api/Version1/class-plans-controller.php:699 msgid "Claim Badge Included" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:682 +#: ../includes/rest-api/Version1/class-plans-controller.php:707 msgid "Booking Included" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:690 +#: ../includes/rest-api/Version1/class-plans-controller.php:715 msgid "Live Chat Included" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:698 +#: ../includes/rest-api/Version1/class-plans-controller.php:723 msgid "Mark as Sold Included" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:706 +#: ../includes/rest-api/Version1/class-plans-controller.php:731 msgid "All Categories" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:717, ../includes/rest-api/Version1/class-plans-controller.php:718, ../includes/rest-api/Version1/class-plans-controller.php:719, ../includes/rest-api/Version1/class-plans-controller.php:724 +#: ../includes/rest-api/Version1/class-plans-controller.php:742, ../includes/rest-api/Version1/class-plans-controller.php:743, ../includes/rest-api/Version1/class-plans-controller.php:744, ../includes/rest-api/Version1/class-plans-controller.php:749 msgid "%s (maximum %d item)" msgid_plural "%s (maximum %d items)" msgstr[0] "" msgstr[1] "" -#: ../includes/rest-api/Version1/class-plans-controller.php:720 +#: ../includes/rest-api/Version1/class-plans-controller.php:745 msgid "%s (maximum %d)" msgid_plural "%s (maximum %d)" msgstr[0] "" msgstr[1] "" -#: ../includes/rest-api/Version1/class-plans-controller.php:721, ../includes/rest-api/Version1/class-plans-controller.php:722, ../includes/rest-api/Version1/class-plans-controller.php:723 +#: ../includes/rest-api/Version1/class-plans-controller.php:746, ../includes/rest-api/Version1/class-plans-controller.php:747, ../includes/rest-api/Version1/class-plans-controller.php:748 msgid "%s (maximum %d character)" msgid_plural "%s (maximum %d characters)" msgstr[0] "" msgstr[1] "" -#: ../includes/rest-api/Version1/class-plans-controller.php:777 +#: ../includes/rest-api/Version1/class-plans-controller.php:802 msgid "%s (unlimited)" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:838 +#: ../includes/rest-api/Version1/class-plans-controller.php:863 msgid "plan name." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:843 +#: ../includes/rest-api/Version1/class-plans-controller.php:868 msgid "The date the plan was created, in the site's timezone." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:849 +#: ../includes/rest-api/Version1/class-plans-controller.php:874 msgid "The date the plan was last modified, in the site's timezone." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:855 +#: ../includes/rest-api/Version1/class-plans-controller.php:880 msgid "Plan description." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:860 +#: ../includes/rest-api/Version1/class-plans-controller.php:885 msgid "Hide description from plan." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:870 +#: ../includes/rest-api/Version1/class-plans-controller.php:895 msgid "Plan status." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:875 +#: ../includes/rest-api/Version1/class-plans-controller.php:900 msgid "Plan recommendation status." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:880 +#: ../includes/rest-api/Version1/class-plans-controller.php:905 msgid "Plan hidden during plan selection." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:885 +#: ../includes/rest-api/Version1/class-plans-controller.php:910 msgid "Plan type." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:891 +#: ../includes/rest-api/Version1/class-plans-controller.php:916 msgid "Plan type label." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:896 +#: ../includes/rest-api/Version1/class-plans-controller.php:921 msgid "Plan currency." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:901 +#: ../includes/rest-api/Version1/class-plans-controller.php:926 msgid "Plan currency symbol." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:906 +#: ../includes/rest-api/Version1/class-plans-controller.php:931 msgid "Is plan free?." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:911 +#: ../includes/rest-api/Version1/class-plans-controller.php:936 msgid "Plan price." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:916 +#: ../includes/rest-api/Version1/class-plans-controller.php:941 msgid "Is plan taxable?" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:921 +#: ../includes/rest-api/Version1/class-plans-controller.php:946 msgid "Plan tax type" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:927 +#: ../includes/rest-api/Version1/class-plans-controller.php:952 msgid "Plan tax amount." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:932 +#: ../includes/rest-api/Version1/class-plans-controller.php:957 msgid "Plan validity period." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:937 +#: ../includes/rest-api/Version1/class-plans-controller.php:962 msgid "Plan validity period unit." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:942 +#: ../includes/rest-api/Version1/class-plans-controller.php:967 msgid "Plan validity period label." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:947 +#: ../includes/rest-api/Version1/class-plans-controller.php:972 msgid "Is plan non expiring?" msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:952 +#: ../includes/rest-api/Version1/class-plans-controller.php:977 msgid "PlayStore product Id." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:957 +#: ../includes/rest-api/Version1/class-plans-controller.php:982 msgid "PlayStore product price." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:962 +#: ../includes/rest-api/Version1/class-plans-controller.php:987 msgid "AppStore product Id." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:967 +#: ../includes/rest-api/Version1/class-plans-controller.php:992 msgid "AppStore product price." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:972 +#: ../includes/rest-api/Version1/class-plans-controller.php:997 msgid "Features data." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:979 +#: ../includes/rest-api/Version1/class-plans-controller.php:1004 msgid "Feature key." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:985 +#: ../includes/rest-api/Version1/class-plans-controller.php:1010 msgid "Feature label." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:990 +#: ../includes/rest-api/Version1/class-plans-controller.php:1015 msgid "Feature active status." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:995 +#: ../includes/rest-api/Version1/class-plans-controller.php:1020 msgid "Feature visibility status from plan package." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:1000, ../includes/rest-api/Version1/class-plans-controller.php:1041 +#: ../includes/rest-api/Version1/class-plans-controller.php:1025, ../includes/rest-api/Version1/class-plans-controller.php:1066 msgid "Feature limited to number of times (-1 indicates unlimited)." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:1008, ../includes/rest-api/Version2/class-listings-controller.php:1162 +#: ../includes/rest-api/Version1/class-plans-controller.php:1033, ../includes/rest-api/Version2/class-listings-controller.php:1162 msgid "Fields data." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:1015, ../includes/rest-api/Version1/class-temporary-media-upload-controller.php:278 +#: ../includes/rest-api/Version1/class-plans-controller.php:1040, ../includes/rest-api/Version1/class-temporary-media-upload-controller.php:278 msgid "Field key." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:1021 +#: ../includes/rest-api/Version1/class-plans-controller.php:1046 msgid "Field label." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:1026 +#: ../includes/rest-api/Version1/class-plans-controller.php:1051 msgid "Preset or custom field status." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:1031 +#: ../includes/rest-api/Version1/class-plans-controller.php:1056 msgid "Field active status." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:1036 +#: ../includes/rest-api/Version1/class-plans-controller.php:1061 msgid "Field visibility status from plan package." msgstr "" -#: ../includes/rest-api/Version1/class-plans-controller.php:1081 +#: ../includes/rest-api/Version1/class-plans-controller.php:1106 msgid "Query plans by directory id." msgstr "" diff --git a/readme.txt b/readme.txt index 0ba9daa6b1..2f7a8607a4 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: business directory, listings, classifieds, directory plugin, directory Requires at least: 4.6 Tested up to: 7.0 Requires PHP: 7.0 -Stable tag: 8.9 +Stable tag: 8.9.1 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -300,6 +300,11 @@ Directorist comes with an AI-powered directory builder. Use the Create with AI o == Changelog == += 8.9.1 - Jul 26, 2026 = + +**Improved** + - support new pricing plans API. (#2935) + = 8.9 - Jul 26, 2026 = **Added**