diff --git a/blocks/build/account-button/index.asset.php b/blocks/build/account-button/index.asset.php index 78f995e5cb..bae651ab13 100644 --- a/blocks/build/account-button/index.asset.php +++ b/blocks/build/account-button/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-keycodes'), 'version' => 'dd42fbbaf3fc7df0ddff'); +<?php return array( + 'dependencies' => array( 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-keycodes' ), + 'version' => 'dd42fbbaf3fc7df0ddff', +); diff --git a/blocks/build/account-button/render.php b/blocks/build/account-button/render.php index 7e69dfaaa4..226e420599 100644 --- a/blocks/build/account-button/render.php +++ b/blocks/build/account-button/render.php @@ -28,4 +28,5 @@ <?php include_once DIRECTORIST_BLOCK_TEMPLATE_PATH . '/account.php'; ?> <div class="directorist-account-block-logout-mode"><?php echo $content; ?></div> -<?php endif; \ No newline at end of file + <?php +endif; \ No newline at end of file diff --git a/blocks/build/account-button/script.asset.php b/blocks/build/account-button/script.asset.php index 561c3d5eef..056d35483e 100644 --- a/blocks/build/account-button/script.asset.php +++ b/blocks/build/account-button/script.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array(), 'version' => '93f86b38a6ce0b51422d'); +<?php return array( + 'dependencies' => array(), + 'version' => '93f86b38a6ce0b51422d', +); diff --git a/blocks/build/author-profile/index.asset.php b/blocks/build/author-profile/index.asset.php index a411562d60..3886eeba05 100644 --- a/blocks/build/author-profile/index.asset.php +++ b/blocks/build/author-profile/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => 'd02582c13e8b63c4b6c4'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render' ), + 'version' => 'd02582c13e8b63c4b6c4', +); diff --git a/blocks/build/authors/index.asset.php b/blocks/build/authors/index.asset.php index ddcde548d3..44bc0f8152 100644 --- a/blocks/build/authors/index.asset.php +++ b/blocks/build/authors/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '64123f42355293acd6c8'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-element', 'wp-i18n', 'wp-server-side-render' ), + 'version' => '64123f42355293acd6c8', +); diff --git a/blocks/build/categories/index.asset.php b/blocks/build/categories/index.asset.php index 52a027b0e3..2911ba90b3 100644 --- a/blocks/build/categories/index.asset.php +++ b/blocks/build/categories/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render'), 'version' => 'a222aa93019f853ebf1c'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render' ), + 'version' => 'a222aa93019f853ebf1c', +); diff --git a/blocks/build/checkout/index.asset.php b/blocks/build/checkout/index.asset.php index 80f2ac172e..a7f98da466 100644 --- a/blocks/build/checkout/index.asset.php +++ b/blocks/build/checkout/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n', 'wp-server-side-render'), 'version' => '3534b5470c02053ab185'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n', 'wp-server-side-render' ), + 'version' => '3534b5470c02053ab185', +); diff --git a/blocks/build/dashboard/index.asset.php b/blocks/build/dashboard/index.asset.php index d259964c72..95fdacea1b 100644 --- a/blocks/build/dashboard/index.asset.php +++ b/blocks/build/dashboard/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n', 'wp-server-side-render'), 'version' => 'ed7973f11e0ee5305a06'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n', 'wp-server-side-render' ), + 'version' => 'ed7973f11e0ee5305a06', +); diff --git a/blocks/build/listing-form/index.asset.php b/blocks/build/listing-form/index.asset.php index 7c131f885c..473829ff37 100644 --- a/blocks/build/listing-form/index.asset.php +++ b/blocks/build/listing-form/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render'), 'version' => '5de5e7492bcfa940ef4b'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render' ), + 'version' => '5de5e7492bcfa940ef4b', +); diff --git a/blocks/build/listings/index.asset.php b/blocks/build/listings/index.asset.php index fed8bf9b33..92d8b6b20e 100644 --- a/blocks/build/listings/index.asset.php +++ b/blocks/build/listings/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render'), 'version' => 'cbdba0744d31f46daf5d'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render' ), + 'version' => 'cbdba0744d31f46daf5d', +); diff --git a/blocks/build/locations/index.asset.php b/blocks/build/locations/index.asset.php index 6a27ae955a..17229d37d9 100644 --- a/blocks/build/locations/index.asset.php +++ b/blocks/build/locations/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render'), 'version' => '4fe812edfafb4751808a'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render' ), + 'version' => '4fe812edfafb4751808a', +); diff --git a/blocks/build/payment-receipt/index.asset.php b/blocks/build/payment-receipt/index.asset.php index 6265db0bb5..de711c3a1b 100644 --- a/blocks/build/payment-receipt/index.asset.php +++ b/blocks/build/payment-receipt/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => '4e3ec001363d608cc6b5'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n' ), + 'version' => '4e3ec001363d608cc6b5', +); diff --git a/blocks/build/registration/index.asset.php b/blocks/build/registration/index.asset.php index b072db4c38..015a92b76c 100644 --- a/blocks/build/registration/index.asset.php +++ b/blocks/build/registration/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => '5ada7ca16ba1f2a105c4'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n' ), + 'version' => '5ada7ca16ba1f2a105c4', +); diff --git a/blocks/build/search-form/index.asset.php b/blocks/build/search-form/index.asset.php index 4d75837958..5c4fb67af1 100644 --- a/blocks/build/search-form/index.asset.php +++ b/blocks/build/search-form/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render'), 'version' => '810b7c87661d255d276b'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-is-shallow-equal', 'wp-keycodes', 'wp-primitives', 'wp-server-side-render' ), + 'version' => '810b7c87661d255d276b', +); diff --git a/blocks/build/search-modal/index.asset.php b/blocks/build/search-modal/index.asset.php index 2632db7864..7d01b21d5e 100644 --- a/blocks/build/search-modal/index.asset.php +++ b/blocks/build/search-modal/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-keycodes'), 'version' => '374352cbd74ee31cea13'); +<?php return array( + 'dependencies' => array( 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n', 'wp-keycodes' ), + 'version' => '374352cbd74ee31cea13', +); diff --git a/blocks/build/search-modal/render.php b/blocks/build/search-modal/render.php index ab0f06318e..af093398f6 100644 --- a/blocks/build/search-modal/render.php +++ b/blocks/build/search-modal/render.php @@ -1,16 +1,16 @@ <div class="directorist-search-popup-block"> - <div class="directorist-search-popup-block__button"> - <?php + <div class="directorist-search-popup-block__button"> + <?php if ( 'icon' === $attributes['styleDisplay'] ) { directorist_icon( 'fa fa-search' ); } elseif ( 'text' === $attributes['styleDisplay'] ) { directorist_icon( 'fa fa-search' ); - echo $content; - } elseif ( 'icon_and_text' === $attributes['styleDisplay'] ) { - echo $content; + echo $content; + } elseif ( 'icon_and_text' === $attributes['styleDisplay'] ) { + echo $content; } ?> - </div> + </div> - <?php include_once DIRECTORIST_BLOCK_TEMPLATE_PATH . '/popup.php'; ?> + <?php require_once DIRECTORIST_BLOCK_TEMPLATE_PATH . '/popup.php'; ?> </div> diff --git a/blocks/build/search-modal/script.asset.php b/blocks/build/search-modal/script.asset.php index f9d422c0e0..41a7c9c0a1 100644 --- a/blocks/build/search-modal/script.asset.php +++ b/blocks/build/search-modal/script.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array(), 'version' => 'b6da3778689ecffd1cd5'); +<?php return array( + 'dependencies' => array(), + 'version' => 'b6da3778689ecffd1cd5', +); diff --git a/blocks/build/search-result/index.asset.php b/blocks/build/search-result/index.asset.php index ef43464fb7..f5cc6e70b5 100644 --- a/blocks/build/search-result/index.asset.php +++ b/blocks/build/search-result/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render'), 'version' => 'a3762b315f712b932f0c'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render' ), + 'version' => 'a3762b315f712b932f0c', +); diff --git a/blocks/build/signin-signup/index.asset.php b/blocks/build/signin-signup/index.asset.php index 0841d571e8..0ddafe06c6 100644 --- a/blocks/build/signin-signup/index.asset.php +++ b/blocks/build/signin-signup/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render'), 'version' => '29760bdf91c3979b5ab1'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-server-side-render' ), + 'version' => '29760bdf91c3979b5ab1', +); diff --git a/blocks/build/single-category/index.asset.php b/blocks/build/single-category/index.asset.php index bca7386e8f..4db6747bd5 100644 --- a/blocks/build/single-category/index.asset.php +++ b/blocks/build/single-category/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render'), 'version' => 'fde5d815460869da1af1'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render' ), + 'version' => 'fde5d815460869da1af1', +); diff --git a/blocks/build/single-listing/index.asset.php b/blocks/build/single-listing/index.asset.php index 0de88859dd..dc716f9c06 100644 --- a/blocks/build/single-listing/index.asset.php +++ b/blocks/build/single-listing/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n', 'wp-server-side-render'), 'version' => 'bc73354bbb1bd58c0813'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n', 'wp-server-side-render' ), + 'version' => 'bc73354bbb1bd58c0813', +); diff --git a/blocks/build/single-location/index.asset.php b/blocks/build/single-location/index.asset.php index c9fde800cb..1cda8cba2f 100644 --- a/blocks/build/single-location/index.asset.php +++ b/blocks/build/single-location/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render'), 'version' => '30acc1c616e98b1dbf19'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render' ), + 'version' => '30acc1c616e98b1dbf19', +); diff --git a/blocks/build/single-tag/index.asset.php b/blocks/build/single-tag/index.asset.php index 14ab47f894..97a086403c 100644 --- a/blocks/build/single-tag/index.asset.php +++ b/blocks/build/single-tag/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render'), 'version' => '2753fcee656dcf6ea92c'); +<?php return array( + 'dependencies' => array( 'lodash', 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-primitives', 'wp-server-side-render' ), + 'version' => '2753fcee656dcf6ea92c', +); diff --git a/blocks/build/transaction-failure/index.asset.php b/blocks/build/transaction-failure/index.asset.php index c49941e122..5552dd5a61 100644 --- a/blocks/build/transaction-failure/index.asset.php +++ b/blocks/build/transaction-failure/index.asset.php @@ -1 +1,4 @@ -<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n'), 'version' => '6dccb32e78f873a8991a'); +<?php return array( + 'dependencies' => array( 'react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-i18n' ), + 'version' => '6dccb32e78f873a8991a', +); diff --git a/blocks/includes/class-block-templates-controller.php b/blocks/includes/class-block-templates-controller.php index 944c3ae579..6be049db8f 100644 --- a/blocks/includes/class-block-templates-controller.php +++ b/blocks/includes/class-block-templates-controller.php @@ -177,7 +177,7 @@ public function add_block_templates( $query_result, $query, $template_type ) { if ( array_filter( $query_result, - static function( $query_result_template ) use ( $template_file ) { + static function ( $query_result_template ) use ( $template_file ) { return $query_result_template->slug === $template_file->slug && $query_result_template->theme === $template_file->theme; } @@ -236,13 +236,13 @@ public function remove_theme_templates_with_custom_alternative( $templates ) { // Get the slugs of all templates that have been customised and saved in the database. $customised_template_slugs = array_map( - static function( $template ) { + static function ( $template ) { return $template->slug; }, array_values( array_filter( $templates, - static function( $template ) { + static function ( $template ) { // This template has been customised and saved as a post. return 'custom' === $template->source; } @@ -257,7 +257,7 @@ static function( $template ) { return array_values( array_filter( $templates, - static function( $template ) use ( $customised_template_slugs ) { + static function ( $template ) use ( $customised_template_slugs ) { // This template has been customised and saved as a post, so return it. return ! ( 'theme' === $template->source && in_array( $template->slug, $customised_template_slugs, true ) ); } @@ -291,11 +291,11 @@ public function get_block_templates_from_db( $slugs = array(), $template_type = $check_query_args['post_name__in'] = $slugs; } - $check_query = new \WP_Query( $check_query_args ); + $check_query = new \WP_Query( $check_query_args ); $saved_directorist_templates = $check_query->posts; return array_map( - static function( $saved_directorist_template ) { + static function ( $saved_directorist_template ) { return Block_Template_Utils::gutenberg_build_template_result_from_post( $saved_directorist_template ); }, $saved_directorist_templates @@ -421,4 +421,4 @@ public function render_block_template() { } } -new Block_Templates_Controller(); \ No newline at end of file +new Block_Templates_Controller(); diff --git a/blocks/init.php b/blocks/init.php index f7650ead8c..4649b69e38 100644 --- a/blocks/init.php +++ b/blocks/init.php @@ -17,8 +17,8 @@ // Check if the current theme is a block theme if ( wp_is_block_theme() ) { - // Enable widgets support - add_theme_support( 'widgets' ); + // Enable widgets support + add_theme_support( 'widgets' ); } /** @@ -44,13 +44,13 @@ function directorist_register_blocks() { // wp_set_script_translations( 'directorist-block-editor', 'directorist' ); - $styles = [ + $styles = array( 'directorist-main-style', 'directorist-select2-style', 'directorist-ez-media-uploader-style', 'directorist-swiper-style', - 'directorist-sweetalert-style' - ]; + 'directorist-sweetalert-style', + ); if ( AssetHelper::map_type() === 'openstreet' ) { $styles[] = 'directorist-openstreet-map-leaflet'; @@ -126,7 +126,7 @@ function directorist_register_block_category( $categories ) { /** * Single listing dynamic render callback. * - * @param array $atts + * @param array $atts * @param string $content * * @return string @@ -158,7 +158,7 @@ function directorist_block_render_callback( $attributes, $content, $instance ) { } $attributes['is_block_editor'] = true; - $output = directorist_do_shortcode_callback( $shortcode, $attributes, $content ); + $output = directorist_do_shortcode_callback( $shortcode, $attributes, $content ); if ( empty( $output ) && current_user_can( 'edit_posts' ) ) { return sprintf( @@ -195,7 +195,7 @@ function directorist_do_shortcode_callback( $tag, array $atts = array(), $conten /** * Enable rest api for all directorist taxonomies. * - * @param array $args Taxonomy arguments + * @param array $args Taxonomy arguments * @param string $name Taxonomy slug * * @return array Modified $args @@ -212,7 +212,7 @@ function directorist_tax_show_in_rest( $args, $name ) { /** * Enable rest api for directorist post type. * - * @param array $args Post type arguments + * @param array $args Post type arguments * @param string $name Post type slug * * @return array Modified $args @@ -229,16 +229,16 @@ function directorist_post_type_show_in_rest( $args, $name ) { /** * Disable gutenberg editor or block editor for our directory post type. * - * @param bool $current_status + * @param bool $current_status * @param string $post_type * * @return bool */ function directorist_disable_block_editor( $current_status, $post_type ) { - if ( $post_type === ATBDP_POST_TYPE ) { + if ( $post_type === ATBDP_POST_TYPE ) { return false; } - return $current_status; + return $current_status; } add_filter( 'use_block_editor_for_post_type', 'directorist_disable_block_editor', 10, 2 ); @@ -263,7 +263,7 @@ function directorist_add_single_listing_shortcode( $atts = array() ) { } return Helper::get_template_contents( 'single-contents' ); - } catch( Exception $e ) { + } catch ( Exception $e ) { if ( current_user_can( 'edit_posts' ) ) { return '<p class="directorist-alert directorist-alert-info" style="text-align:center">' . $e->getMessage() . '</p>'; } @@ -283,12 +283,12 @@ function directorist_account_block_avatar_image( $size = 40 ) { $size, null, null, - [ - 'class' => 'rounded-circle' - ] + array( + 'class' => 'rounded-circle', + ) ); } else { - echo sprintf( + printf( '<img width="%1$s" src="%2$s" alt="%2$s" class="avatar rounded-circle"/>', $size, esc_url( $image_url ), @@ -305,8 +305,8 @@ function directorist_register_blocks_common_assets() { wp_enqueue_style( 'directorist-blocks-common', - plugin_dir_url( __FILE__ ) . 'assets/index' . ( is_rtl() ? '-rtl.css' : '.css' ), - [], + plugin_dir_url( __FILE__ ) . 'assets/index' . ( is_rtl() ? '-rtl.css' : '.css' ), + array(), isset( $asset['version'] ) ?? ATBDP_VERSION ); } diff --git a/blocks/src/account-button/render.php b/blocks/src/account-button/render.php index 7e69dfaaa4..226e420599 100644 --- a/blocks/src/account-button/render.php +++ b/blocks/src/account-button/render.php @@ -28,4 +28,5 @@ <?php include_once DIRECTORIST_BLOCK_TEMPLATE_PATH . '/account.php'; ?> <div class="directorist-account-block-logout-mode"><?php echo $content; ?></div> -<?php endif; \ No newline at end of file + <?php +endif; \ No newline at end of file diff --git a/blocks/src/search-modal/render.php b/blocks/src/search-modal/render.php index ab0f06318e..af093398f6 100644 --- a/blocks/src/search-modal/render.php +++ b/blocks/src/search-modal/render.php @@ -1,16 +1,16 @@ <div class="directorist-search-popup-block"> - <div class="directorist-search-popup-block__button"> - <?php + <div class="directorist-search-popup-block__button"> + <?php if ( 'icon' === $attributes['styleDisplay'] ) { directorist_icon( 'fa fa-search' ); } elseif ( 'text' === $attributes['styleDisplay'] ) { directorist_icon( 'fa fa-search' ); - echo $content; - } elseif ( 'icon_and_text' === $attributes['styleDisplay'] ) { - echo $content; + echo $content; + } elseif ( 'icon_and_text' === $attributes['styleDisplay'] ) { + echo $content; } ?> - </div> + </div> - <?php include_once DIRECTORIST_BLOCK_TEMPLATE_PATH . '/popup.php'; ?> + <?php require_once DIRECTORIST_BLOCK_TEMPLATE_PATH . '/popup.php'; ?> </div> diff --git a/blocks/templates/account.php b/blocks/templates/account.php index 7987180445..8353ce2c44 100755 --- a/blocks/templates/account.php +++ b/blocks/templates/account.php @@ -27,7 +27,7 @@ <div class="modal-header"> - <div class="modal-title" id="login_modal_label"><?php esc_html_e( 'Sign In', 'directorist' );?></div> + <div class="modal-title" id="login_modal_label"><?php esc_html_e( 'Sign In', 'directorist' ); ?></div> <button type="button" class="directorist-account-block-close" data-bs-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span> </button> @@ -35,7 +35,7 @@ <div class="modal-body"> - <?php include_once 'login.php';?> + <?php require_once 'login.php'; ?> </div> @@ -53,7 +53,7 @@ <div class="modal-header"> - <div class="modal-title"><?php esc_attr_e( 'Registration', 'directorist' );?></div> + <div class="modal-title"><?php esc_attr_e( 'Registration', 'directorist' ); ?></div> <button type="button" class="directorist-account-block-close" data-bs-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span> </button> @@ -61,7 +61,7 @@ <div class="modal-body"> - <?php include_once 'registration.php';?> + <?php require_once 'registration.php'; ?> </div> diff --git a/blocks/templates/login.php b/blocks/templates/login.php index bd0ff1a250..626d48060e 100644 --- a/blocks/templates/login.php +++ b/blocks/templates/login.php @@ -9,7 +9,7 @@ $key = isset( $_GET['key'] ) ? sanitize_text_field( wp_unslash( $_GET['key'] ) ) : ''; -$login_args = [ +$login_args = array( 'log_username' => get_directorist_option( 'log_username', __( 'Username or Email Address', 'directorist' ) ), 'log_password' => get_directorist_option( 'log_password', __( 'Password', 'directorist' ) ), 'display_rememberMe' => get_directorist_option( 'display_rememberme', 1 ), @@ -26,7 +26,7 @@ 'reg_linktxt' => get_directorist_option( 'reg_linktxt', __( 'Sign Up', 'directorist' ) ), 'display_signup' => get_directorist_option( 'display_signup', 1 ), 'new_user_registration' => directorist_is_user_registration_enabled(), -]; +); extract( $login_args ); ?> @@ -35,13 +35,22 @@ <?php if ( directorist_is_email_verification_enabled() && ! empty( $_GET['verification'] ) && is_email( $user_email ) ) : ?> <p class="directorist-alert directorist-alert-success"><span class="p-0 m-0"> <?php - $send_confirm_mail_url = add_query_arg( array( - 'action' => 'directorist_send_confirmation_email', - 'user' => $user_email, - 'directorist_nonce' => wp_create_nonce( 'directorist_nonce' ), - ), admin_url( 'admin-ajax.php' ) ); + $send_confirm_mail_url = add_query_arg( + array( + 'action' => 'directorist_send_confirmation_email', + 'user' => $user_email, + 'directorist_nonce' => wp_create_nonce( 'directorist_nonce' ), + ), + admin_url( 'admin-ajax.php' ) + ); - echo wp_kses( sprintf( __( "Thank you for signing up! To complete the registration, please verify your email address by clicking on the link we have sent to your email.<br><br>If you didn't find the verification email, please check your spam folder. If you still can't find it, click on the <a href='%s'>Resend confirmation email</a> to have a new email sent to you.", 'directorist' ), esc_url( $send_confirm_mail_url ) ), array( 'a' => array( 'href' => array() ), 'br' => array() ) ); + echo wp_kses( + sprintf( __( "Thank you for signing up! To complete the registration, please verify your email address by clicking on the link we have sent to your email.<br><br>If you didn't find the verification email, please check your spam folder. If you still can't find it, click on the <a href='%s'>Resend confirmation email</a> to have a new email sent to you.", 'directorist' ), esc_url( $send_confirm_mail_url ) ), + array( + 'a' => array( 'href' => array() ), + 'br' => array(), + ) + ); ?> </span></p> <?php endif; ?> @@ -57,37 +66,51 @@ if ( is_email( $user_email ) && ! empty( $key ) ) { $user = get_user_by( 'email', $user_email ); - if ( ! $user ) { ?> + if ( ! $user ) { + ?> <p class="directorist-alert directorist-alert-danger"> <?php esc_html_e( 'Sorry! user not found', 'directorist' ); ?> </p> - <?php } else { + <?php + } else { $is_valid_password_reset_key = check_password_reset_key( $key, $user->user_login ); if ( is_wp_error( $is_valid_password_reset_key ) ) { - ?><p class="directorist-alert directorist-alert-danger"> + ?> + <p class="directorist-alert directorist-alert-danger"> <?php echo $is_valid_password_reset_key->get_error_message(); ?> - </p><?php + </p> + <?php } else { if ( ! empty( $_POST['directorist_reset_password'] ) && directorist_verify_nonce( 'directorist-reset-password-nonce', 'reset_password' ) ) : // Ignore password sanitization $password_1 = isset( $_POST['password_1'] ) ? $_POST['password_1'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $password_2 = isset( $_POST['password_2'] ) ? $_POST['password_2'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - if ( empty( $password_1 ) || empty( $password_2 ) ) : ?> + if ( empty( $password_1 ) || empty( $password_2 ) ) : + ?> <p class="atbd_reset_warning directorist-alert directorist-alert-danger"><?php echo esc_html__( 'Passwords cannot be empty.', 'directorist' ); ?></p> <?php elseif ( $password_1 !== $password_2 ) : ?> <p class="atbd_reset_error directorist-alert directorist-alert-danger"><?php echo esc_html__( 'Passwords do not match!', 'directorist' ); ?></p> - <?php else : + <?php + else : wp_set_password( $password_2, $user->ID ); // Since password reset is handled through email, so we can consider it verified! delete_user_meta( $user->ID, 'directorist_user_email_unverified' ); ?> - <p class="atbd_reset_success directorist-alert directorist-alert-success"><?php echo wp_kses( sprintf( - __( 'Password changed successfully. Please <a href="%s">click here to login</a>.', 'directorist' ), - esc_url( ATBDP_Permalink::get_login_page_url() ) - ), array( 'a' => array( 'href' => array() ) ) ); ?></p> - <?php endif; + <p class="atbd_reset_success directorist-alert directorist-alert-success"> + <?php + echo wp_kses( + sprintf( + __( 'Password changed successfully. Please <a href="%s">click here to login</a>.', 'directorist' ), + esc_url( ATBDP_Permalink::get_login_page_url() ) + ), + array( 'a' => array( 'href' => array() ) ) + ); + ?> + </p> + <?php + endif; endif; if ( ! empty( $_GET['password_reset'] ) ) { @@ -102,10 +125,15 @@ ATBDP()->email->custom_wp_new_user_notification_email( $user->ID ); ?> <div class="directorist-alert directorist-alert-success"> - <?php echo wp_kses( sprintf( - __( 'Email verification successful. Please <a href="%s">click here to login</a>.', 'directorist' ), - esc_url( ATBDP_Permalink::get_login_page_url() ) - ), array( 'a' => array( 'href' => array() ) ) ); ?> + <?php + echo wp_kses( + sprintf( + __( 'Email verification successful. Please <a href="%s">click here to login</a>.', 'directorist' ), + esc_url( ATBDP_Permalink::get_login_page_url() ) + ), + array( 'a' => array( 'href' => array() ) ) + ); + ?> </div> <?php } @@ -149,19 +177,21 @@ <?php echo esc_html( $log_rememberMe ); ?> </label> <?php endif; ?> - <?php if ( $display_recpass ) : + <?php + if ( $display_recpass ) : printf( '<p><a href="" class="atbdp_recovery_pass">%s</a></p>', esc_html( $recpass_text ) ); - endif; ?> + endif; + ?> </div> <div class="directorist-form-group atbd_login_btn_wrapper"> <button class="directorist-btn directorist-btn-block" type="submit" value="<?php echo esc_attr( $log_button ); ?>" name="submit"><?php echo esc_html( $log_button ); ?></button> - <?php wp_nonce_field( 'ajax-login-nonce', 'security' );?> + <?php wp_nonce_field( 'ajax-login-nonce', 'security' ); ?> </div> </form> <div class="directorist-account-block-social-login"> - <?php do_action( 'atbdp_before_login_form_end' );?> + <?php do_action( 'atbdp_before_login_form_end' ); ?> </div> </div> @@ -190,8 +220,8 @@ </div> <?php - //stuff to recover password start - $error = ''; + // stuff to recover password start + $error = ''; $success = ''; // check if we're in reset form if ( isset( $_POST['action'] ) && 'reset' === $_POST['action'] && directorist_verify_nonce() ) : @@ -200,36 +230,42 @@ if ( empty( $email ) ) { $error = __( 'Email address cannot be empty.', 'directorist' ); - } else if ( ! is_email( $email ) ) { + } elseif ( ! is_email( $email ) ) { $error = __( 'Invalid e-mail address.', 'directorist' ); - } else if ( ! email_exists( $email ) ) { + } elseif ( ! email_exists( $email ) ) { $error = __( 'There is no user registered with that email address.', 'directorist' ); } else { - $user = get_user_by( 'email', $email ); + $user = get_user_by( 'email', $email ); /* translators: %s: site name */ - $subject = esc_html( sprintf( __( '[%s] Reset Your Password', 'directorist' ), get_option( 'blogname', 'display' ) )); + $subject = esc_html( sprintf( __( '[%s] Reset Your Password', 'directorist' ), get_option( 'blogname', 'display' ) ) ); $title = esc_html__( 'Password Reset Request', 'directorist' ); $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); /* translators: %1$s: site name, %1$s: user name, %3$s: password reset link */ - $message = sprintf( __( 'Someone has requested a password reset for the following account: + $message = sprintf( + __( + 'Someone has requested a password reset for the following account: <strong>Site name:</strong> %1$s <strong>User name:</strong> %2$s To reset your password, please click on the <a href="%3$s">Reset Password</a>.<br> - If this was a mistake, just ignore this email and nothing will happen.', 'directorist' + If this was a mistake, just ignore this email and nothing will happen.', + 'directorist' ), $site_name, $user->user_login, esc_url( directorist_password_reset_url( $user, true ) ) ); - $message = wp_kses( $message, array( - 'br' => array(), - 'strong' => array(), - 'a' => array( - 'href' => array() + $message = wp_kses( + $message, + array( + 'br' => array(), + 'strong' => array(), + 'a' => array( + 'href' => array(), + ), ) - ) ); + ); $message = atbdp_email_html( $title, nl2br( $message ) ); @@ -240,7 +276,6 @@ } else { $error = __( 'Something went wrong, unable to send the password reset email. If the issue persists please contact with the site administrator.', 'directorist' ); } - } if ( ! empty( $error ) ) { @@ -251,7 +286,8 @@ echo '<div class="error_login"><p class="success directorist-alert directorist-alert-success">' . esc_html( $success ) . '</p></div>'; } - endif; ?> - <?php }; ?> + endif; + ?> + <?php } ?> </div><!-- /.atbdp_login_form_shortcode --> </div> \ No newline at end of file diff --git a/blocks/templates/navigation.php b/blocks/templates/navigation.php index 4d9a22417a..9c7405408f 100644 --- a/blocks/templates/navigation.php +++ b/blocks/templates/navigation.php @@ -1,74 +1,74 @@ -<?php -/** - * @author wpWax - * @since 1.0 - * @version 1.0 - */ - -use Directorist\Directorist_Listing_Dashboard; - -if ( ! defined( 'ABSPATH' ) ) { - exit; -} - -if ( atbdp_is_page( 'dashboard' ) ) { - return; -} - -$dashboard = Directorist_Listing_Dashboard::instance(); -$dashboard_url = get_permalink( get_directorist_option( 'user_dashboard' ) ); -?> - -<div class="directorist-account-block-logged-mode__navigation"> - - <ul> - - <?php foreach ( $dashboard->dashboard_tabs() as $key => $value ): ?> - - <li> - - <a href="<?php echo esc_url( $dashboard_url ) . '#' . $key; ?>"> - - <span class="directorist_menuItem-icon"> - <?php directorist_icon( $value['icon'] );?> - </span> - - <?php echo wp_kses_post( $value['title'] ); ?> - - </a> - - </li> - - <?php endforeach;?> - - <?php if ( $dashboard->user_can_submit() ): ?> - - <li> - - <a href="<?php echo esc_url( ATBDP_Permalink::get_add_listing_page_link() ); ?>"> - - <span class="directorist_menuItem-icon"><?php directorist_icon( 'las la-plus' );?> </span> - - <?php esc_html_e( 'Add Listing', 'directorist' );?> - - </a> - - </li> - - <?php endif;?> - - <li> - - <a href="<?php echo esc_url( wp_logout_url( home_url() ) ); ?>"> - - <span class="directorist_menuItem-icon"><?php directorist_icon( 'las la-sign-out-alt' );?> </span> - - <?php esc_html_e( 'Log Out', 'directorist' );?> - - </a> - - </li> - - </ul> - -</div> \ No newline at end of file +<?php +/** + * @author wpWax + * @since 1.0 + * @version 1.0 + */ + +use Directorist\Directorist_Listing_Dashboard; + +if ( ! defined( 'ABSPATH' ) ) { + exit; +} + +if ( atbdp_is_page( 'dashboard' ) ) { + return; +} + +$dashboard = Directorist_Listing_Dashboard::instance(); +$dashboard_url = get_permalink( get_directorist_option( 'user_dashboard' ) ); +?> + +<div class="directorist-account-block-logged-mode__navigation"> + + <ul> + + <?php foreach ( $dashboard->dashboard_tabs() as $key => $value ) : ?> + + <li> + + <a href="<?php echo esc_url( $dashboard_url ) . '#' . $key; ?>"> + + <span class="directorist_menuItem-icon"> + <?php directorist_icon( $value['icon'] ); ?> + </span> + + <?php echo wp_kses_post( $value['title'] ); ?> + + </a> + + </li> + + <?php endforeach; ?> + + <?php if ( $dashboard->user_can_submit() ) : ?> + + <li> + + <a href="<?php echo esc_url( ATBDP_Permalink::get_add_listing_page_link() ); ?>"> + + <span class="directorist_menuItem-icon"><?php directorist_icon( 'las la-plus' ); ?> </span> + + <?php esc_html_e( 'Add Listing', 'directorist' ); ?> + + </a> + + </li> + + <?php endif; ?> + + <li> + + <a href="<?php echo esc_url( wp_logout_url( home_url() ) ); ?>"> + + <span class="directorist_menuItem-icon"><?php directorist_icon( 'las la-sign-out-alt' ); ?> </span> + + <?php esc_html_e( 'Log Out', 'directorist' ); ?> + + </a> + + </li> + + </ul> + +</div> diff --git a/blocks/templates/popup.php b/blocks/templates/popup.php index 00334f0a02..08399128ae 100644 --- a/blocks/templates/popup.php +++ b/blocks/templates/popup.php @@ -1,6 +1,6 @@ <div class="directorist-search-popup-block__popup"> <div class="directorist-search-popup-block__form-close"> - <?php directorist_icon( 'la times' );?> + <?php directorist_icon( 'la times' ); ?> </div> <div class="dspb-container"> <div class="dspb-row"> diff --git a/blocks/templates/registration.php b/blocks/templates/registration.php index cad02b387e..737becb14c 100644 --- a/blocks/templates/registration.php +++ b/blocks/templates/registration.php @@ -10,7 +10,7 @@ die(); } -$reg_args = [ +$reg_args = array( 'parent' => 0, 'container_fluid' => is_directoria_active() ? 'container' : 'container-fluid', 'username' => get_directorist_option( 'reg_username', __( 'Username', 'directorist' ) ), @@ -44,7 +44,7 @@ 'user_type' => $user_type, 'author_checked' => ( 'general' !== $user_type ) ? 'checked' : '', 'general_checked' => ( 'general' === $user_type ) ? 'checked' : '', -]; +); extract( $reg_args ); ?> @@ -54,7 +54,7 @@ if ( ! empty( $_GET['registration_status'] ) && true == $_GET['registration_status'] ) { if ( empty( $display_password_reg ) ) { ?> - <p style="padding: 20px" class="alert-success"><?php directorist_icon( 'las la-check' ); ?><?php esc_html_e(' Go to your inbox or spam/junk and get your password.', 'directorist'); ?> + <p style="padding: 20px" class="alert-success"><?php directorist_icon( 'las la-check' ); ?><?php esc_html_e( ' Go to your inbox or spam/junk and get your password.', 'directorist' ); ?> <?php $output = sprintf( __( 'Click %s to login.', 'directorist' ), '<a href="' . ATBDP_Permalink::get_login_page_link() . '"><span style="color: red">' . __( 'Here', 'directorist' ) . '</span></a>' ); echo wp_kses_post( $output ); @@ -62,13 +62,13 @@ </p> <?php } else { ?> <!--registration succeeded, so show notification --> - <p style="padding: 20px" class="alert-success"><?php directorist_icon( 'las la-check' ); ?><?php esc_html_e(' Registration completed. Please check your email for confirmation.', 'directorist'); ?> + <p style="padding: 20px" class="alert-success"><?php directorist_icon( 'las la-check' ); ?><?php esc_html_e( ' Registration completed. Please check your email for confirmation.', 'directorist' ); ?> <?php - $output = sprintf( __('Or click %s to login.', 'directorist' ), '<a href="' . ATBDP_Permalink::get_login_page_link() . '"><span style="color: red">' . __( 'Here', 'directorist' ) . '</span></a>' ); + $output = sprintf( __( 'Or click %s to login.', 'directorist' ), '<a href="' . ATBDP_Permalink::get_login_page_link() . '"><span style="color: red">' . __( 'Here', 'directorist' ) . '</span></a>' ); echo wp_kses_post( $output ); ?> </p> - <?php + <?php } } ?> @@ -90,52 +90,63 @@ </div> <?php if ( ! empty( $display_password_reg ) ) { ?> <div class="directorist-form-group directorist-mb-15"> - <label for="password"><?php + <label for="password"> + <?php echo esc_html( $password ); echo ( ! empty( $require_password ) ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> + ?> + </label> <input id="password" class="directorist-form-element" type="password" name="password" value="" <?php echo ( ! empty( $require_password ) ? 'required' : '' ); ?>> </div> <?php } ?> <?php if ( ! empty( $display_fname ) ) { ?> <div class="directorist-form-group directorist-mb-15"> - <label for="fname"><?php + <label for="fname"> + <?php echo esc_html( $first_name ); echo ( ! empty( $require_fname ) ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> - <input id="fname" class="directorist-form-element" type="text" name="fname" value="<?php echo isset( $_REQUEST['fname']) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['fname'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_fname ) ? 'required' : '' ); ?>> + ?> + </label> + <input id="fname" class="directorist-form-element" type="text" name="fname" value="<?php echo isset( $_REQUEST['fname'] ) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['fname'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_fname ) ? 'required' : '' ); ?>> </div> <?php } ?> <?php if ( ! empty( $display_lname ) ) { ?> <div class="directorist-form-group directorist-mb-15"> - <label for="lname"><?php + <label for="lname"> + <?php echo esc_html( $last_name ); echo ( ! empty( $require_lname ) ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> - <input class="directorist-form-element" id="lname" type="text" name="lname" value="<?php echo isset( $_REQUEST['lname']) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['lname'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_lname ) ? 'required' : '' ); ?>> + ?> + </label> + <input class="directorist-form-element" id="lname" type="text" name="lname" value="<?php echo isset( $_REQUEST['lname'] ) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['lname'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_lname ) ? 'required' : '' ); ?>> </div> <?php } ?> - <?php if ( ! empty( $display_website ) ) { ?> + <?php if ( ! empty( $display_website ) ) { ?> <div class="directorist-form-group directorist-mb-15"> - <label for="website"><?php + <label for="website"> + <?php echo esc_html( $website ); echo ( ! empty( $require_website ) ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> - <input id="website" class="directorist-form-element" type="text" name="website" value="<?php echo isset( $_REQUEST['website']) ? esc_url( sanitize_text_field( wp_unslash( $_REQUEST['website'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_website ) ? 'required' : '' ); ?>> + ?> + </label> + <input id="website" class="directorist-form-element" type="text" name="website" value="<?php echo isset( $_REQUEST['website'] ) ? esc_url( sanitize_text_field( wp_unslash( $_REQUEST['website'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_website ) ? 'required' : '' ); ?>> </div> <?php } ?> <?php if ( ! empty( $display_bio ) ) { ?> <div class="directorist-form-group directorist-mb-15"> - <label for="bio"><?php + <label for="bio"> + <?php echo esc_html( $bio ); echo ( ! empty( $require_bio ) ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> - <textarea id="bio" class="directorist-form-element" name="bio" rows="10" <?php echo ( ! empty( $require_bio ) ? 'required' : '' ); ?>><?php echo isset( $_REQUEST['bio']) ? esc_textarea( sanitize_text_field( wp_unslash( $_REQUEST['bio'] ) ) ) : ''; ?></textarea> + ?> + </label> + <textarea id="bio" class="directorist-form-element" name="bio" rows="10" <?php echo ( ! empty( $require_bio ) ? 'required' : '' ); ?>><?php echo isset( $_REQUEST['bio'] ) ? esc_textarea( sanitize_text_field( wp_unslash( $_REQUEST['bio'] ) ) ) : ''; ?></textarea> </div> <?php } ?> - <?php if ( ! empty( get_directorist_option( 'display_user_type' ) ) ) { + <?php + if ( ! empty( get_directorist_option( 'display_user_type' ) ) ) { if ( empty( $user_type ) || 'author' === $user_type ) { - ?> + ?> <div class="atbd_user_type_area directory_regi_btn directorist-radio directorist-radio-circle directorist-mb-15"> <input id="author_type" type="radio" name="user_type" value="author" <?php echo esc_attr( $author_checked ); ?>><label for="author_type" class="directorist-radio__label"><?php esc_html_e( 'I am an author', 'directorist' ); ?> </div> @@ -153,11 +164,11 @@ <label for="privacy_policy" class="directorist-checkbox__label"><?php echo esc_html( $privacy_label ); ?> <a style="color: red" target="_blank" href="<?php echo esc_url( $privacy_page_link ); ?>"><?php echo esc_html( $privacy_label_link ); ?></a> <span class="directorist-form-required">*</span></label> </div> <?php } ?> - <?php if ( ! empty( get_directorist_option('regi_terms_condition', 1 ) ) ) { ?> + <?php if ( ! empty( get_directorist_option( 'regi_terms_condition', 1 ) ) ) { ?> <div class="atbd_term_and_condition_area directory_regi_btn directorist-checkbox directorist-mb-15"> <input id="listing_t" type="checkbox" name="t_c_check" <?php echo( ( isset( $t_c_check ) && 'on' === $t_c_check ) ? 'checked="checked"' : '' ); ?>> - <label for="listing_t" class="directorist-checkbox__label"><?php echo esc_attr($terms_label); ?> - <a style="color: red" target="_blank" href="<?php echo esc_url($t_C_page_link)?>"><?php echo esc_attr($terms_label_link); ?></a> <span class="directorist-form-required">*</span></label> + <label for="listing_t" class="directorist-checkbox__label"><?php echo esc_attr( $terms_label ); ?> + <a style="color: red" target="_blank" href="<?php echo esc_url( $t_C_page_link ); ?>"><?php echo esc_attr( $terms_label_link ); ?></a> <span class="directorist-form-required">*</span></label> </div> <?php } ?> @@ -167,9 +178,9 @@ */ do_action( 'atbdp_before_user_registration_submit' ); ?> - <?php if(!$display_password_reg) {?> + <?php if ( ! $display_password_reg ) { ?> <div class="directory_regi_btn"> - <p><?php esc_html_e('Password will be e-mailed to you.','account-block');?></p> + <p><?php esc_html_e( 'Password will be e-mailed to you.', 'account-block' ); ?></p> </div> <?php } ?> <div class="directorist-account-block-register-btn"> diff --git a/blocks/templates/signin-signup.php b/blocks/templates/signin-signup.php index f65f828e14..a1ad19839c 100644 --- a/blocks/templates/signin-signup.php +++ b/blocks/templates/signin-signup.php @@ -1,54 +1,57 @@ <?php use Directorist\Helper; -$atts = wp_parse_args( $attributes, array( - 'user_role' => get_directorist_option( 'display_user_type', false ) ? 'yes' : 'no', - 'author_role_label' => __( 'I am an author', 'directorist' ), - 'user_role_label' => __( 'I am a user', 'directorist' ), - 'registration' => get_directorist_option( 'new_user_registration', true ) ? 'yes' : 'no', - 'username_label' => get_directorist_option( 'reg_username', __( 'Username', 'directorist' ) ), - 'password' => get_directorist_option( 'display_password_reg', true ) ? 'yes' : 'no', - 'password_label' => get_directorist_option( 'reg_password', __( 'Password', 'directorist' ) ), - 'email_label' => get_directorist_option( 'reg_email', __( 'Email ', 'directorist' ) ), - 'website' => get_directorist_option( 'display_website_reg', false ) ? 'yes' : 'no', - 'website_label' => get_directorist_option( 'reg_website', __( 'Website', 'directorist' ) ), - 'website_required' => get_directorist_option( 'require_website_reg', false ) ? 'yes' : 'no', - 'firstname' => get_directorist_option( 'display_fname_reg', false ) ? 'yes' : 'no', - 'firstname_label' => get_directorist_option( 'reg_fname', __( 'First Name', 'directorist' ) ), - 'firstname_required' => get_directorist_option( 'require_fname_reg', false ) ? 'yes' : 'no', - 'lastname' => get_directorist_option( 'display_lname_reg', false ) ? 'yes' : 'no', - 'lastname_label' => get_directorist_option( 'reg_lname', __( 'Last Name', 'directorist' ) ), - 'lastname_required' => get_directorist_option( 'require_lname_reg', false ) ? 'yes' : 'no', - 'bio' => get_directorist_option( 'display_bio_reg', 0 ) ? 'yes' : 'no', - 'bio_label' => get_directorist_option( 'reg_bio', __( 'About/bio', 'directorist' ) ), - 'bio_required' => get_directorist_option( 'require_bio_reg', 0 ) ? 'yes' : 'no', - 'privacy' => get_directorist_option( 'registration_privacy', 1 ) ? 'yes' : 'no', - 'privacy_label' => get_directorist_option( 'registration_privacy_label', __( 'I agree to the', 'directorist' ) ), - 'privacy_linking_text' => get_directorist_option( 'registration_privacy_label_link', __('Privacy & Policy', 'directorist') ), - 'terms' => get_directorist_option( 'regi_terms_condition', 1 ) ? 'yes' : 'no', - 'terms_label' => get_directorist_option( 'regi_terms_label', __( 'I agree with all', 'directorist' ) ), - 'terms_linking_text' => get_directorist_option( 'regi_terms_label_link', 'terms & conditions' ), - 'signup_button_label' => get_directorist_option( 'reg_signup', __( 'Sign Up', 'directorist' ) ), - 'signin_message' => get_directorist_option( 'login_text', __( 'Already have an account? Please Sign in', 'directorist' ) ), - 'signin_linking_text' => get_directorist_option( 'log_linkingmsg', __( 'Here', 'directorist' ) ), - 'signin_after_signup' => get_directorist_option( 'auto_login', 0 ) ? 'yes' : 'no', - 'signup_redirect_url' => '', - // login atts - 'signin_username_label' => get_directorist_option( 'log_username', __( 'Username or Email Address', 'directorist' ) ), - 'signin_button_label' => get_directorist_option( 'log_button', __( 'Sign In', 'directorist' ) ), - 'signup_label' => get_directorist_option( 'reg_text', __( "Don't have an account?", 'directorist' ) ), - 'signup_linking_text' => get_directorist_option( 'reg_linktxt', __( 'Sign Up', 'directorist' ) ), - // recover password atts - 'enable_recovery_password' => get_directorist_option( 'display_recpass', 1 ) ? 'yes' : 'no', - 'recovery_password_label' => get_directorist_option( 'recpass_text', __( 'Forgot Password?', 'directorist' ) ), - 'recovery_password_description' => get_directorist_option( 'recpass_desc', __( 'Lost your password? Please enter your email address. You will receive a link to create a new password via email.', 'directorist' ) ), - 'recovery_password_email_label' => get_directorist_option( 'recpass_username', __( 'E-mail:', 'directorist' ) ), - 'recovery_password_email_placeholder' => get_directorist_option( 'recpass_placeholder', __( 'eg. mail@example.com', 'directorist' ) ), - 'recovery_password_button_label' => get_directorist_option( 'recpass_button', __( 'Get New Password', 'directorist' ) ), - 'user_type' => '' -) ); +$atts = wp_parse_args( + $attributes, + array( + 'user_role' => get_directorist_option( 'display_user_type', false ) ? 'yes' : 'no', + 'author_role_label' => __( 'I am an author', 'directorist' ), + 'user_role_label' => __( 'I am a user', 'directorist' ), + 'registration' => get_directorist_option( 'new_user_registration', true ) ? 'yes' : 'no', + 'username_label' => get_directorist_option( 'reg_username', __( 'Username', 'directorist' ) ), + 'password' => get_directorist_option( 'display_password_reg', true ) ? 'yes' : 'no', + 'password_label' => get_directorist_option( 'reg_password', __( 'Password', 'directorist' ) ), + 'email_label' => get_directorist_option( 'reg_email', __( 'Email ', 'directorist' ) ), + 'website' => get_directorist_option( 'display_website_reg', false ) ? 'yes' : 'no', + 'website_label' => get_directorist_option( 'reg_website', __( 'Website', 'directorist' ) ), + 'website_required' => get_directorist_option( 'require_website_reg', false ) ? 'yes' : 'no', + 'firstname' => get_directorist_option( 'display_fname_reg', false ) ? 'yes' : 'no', + 'firstname_label' => get_directorist_option( 'reg_fname', __( 'First Name', 'directorist' ) ), + 'firstname_required' => get_directorist_option( 'require_fname_reg', false ) ? 'yes' : 'no', + 'lastname' => get_directorist_option( 'display_lname_reg', false ) ? 'yes' : 'no', + 'lastname_label' => get_directorist_option( 'reg_lname', __( 'Last Name', 'directorist' ) ), + 'lastname_required' => get_directorist_option( 'require_lname_reg', false ) ? 'yes' : 'no', + 'bio' => get_directorist_option( 'display_bio_reg', 0 ) ? 'yes' : 'no', + 'bio_label' => get_directorist_option( 'reg_bio', __( 'About/bio', 'directorist' ) ), + 'bio_required' => get_directorist_option( 'require_bio_reg', 0 ) ? 'yes' : 'no', + 'privacy' => get_directorist_option( 'registration_privacy', 1 ) ? 'yes' : 'no', + 'privacy_label' => get_directorist_option( 'registration_privacy_label', __( 'I agree to the', 'directorist' ) ), + 'privacy_linking_text' => get_directorist_option( 'registration_privacy_label_link', __( 'Privacy & Policy', 'directorist' ) ), + 'terms' => get_directorist_option( 'regi_terms_condition', 1 ) ? 'yes' : 'no', + 'terms_label' => get_directorist_option( 'regi_terms_label', __( 'I agree with all', 'directorist' ) ), + 'terms_linking_text' => get_directorist_option( 'regi_terms_label_link', 'terms & conditions' ), + 'signup_button_label' => get_directorist_option( 'reg_signup', __( 'Sign Up', 'directorist' ) ), + 'signin_message' => get_directorist_option( 'login_text', __( 'Already have an account? Please Sign in', 'directorist' ) ), + 'signin_linking_text' => get_directorist_option( 'log_linkingmsg', __( 'Here', 'directorist' ) ), + 'signin_after_signup' => get_directorist_option( 'auto_login', 0 ) ? 'yes' : 'no', + 'signup_redirect_url' => '', + // login atts + 'signin_username_label' => get_directorist_option( 'log_username', __( 'Username or Email Address', 'directorist' ) ), + 'signin_button_label' => get_directorist_option( 'log_button', __( 'Sign In', 'directorist' ) ), + 'signup_label' => get_directorist_option( 'reg_text', __( "Don't have an account?", 'directorist' ) ), + 'signup_linking_text' => get_directorist_option( 'reg_linktxt', __( 'Sign Up', 'directorist' ) ), + // recover password atts + 'enable_recovery_password' => get_directorist_option( 'display_recpass', 1 ) ? 'yes' : 'no', + 'recovery_password_label' => get_directorist_option( 'recpass_text', __( 'Forgot Password?', 'directorist' ) ), + 'recovery_password_description' => get_directorist_option( 'recpass_desc', __( 'Lost your password? Please enter your email address. You will receive a link to create a new password via email.', 'directorist' ) ), + 'recovery_password_email_label' => get_directorist_option( 'recpass_username', __( 'E-mail:', 'directorist' ) ), + 'recovery_password_email_placeholder' => get_directorist_option( 'recpass_placeholder', __( 'eg. mail@example.com', 'directorist' ) ), + 'recovery_password_button_label' => get_directorist_option( 'recpass_button', __( 'Get New Password', 'directorist' ) ), + 'user_type' => '', + ) +); -$args = [ +$args = array( 'log_username' => $atts['signin_username_label'], 'log_password' => $atts['password_label'], 'log_button' => $atts['signin_button_label'], @@ -98,6 +101,6 @@ 'enable_user_type' => $atts['user_role'], 'author_role_label' => $atts['author_role_label'], 'user_role_label' => $atts['user_role_label'], -]; +); -Helper::get_template( 'account/login-registration-form', $args ); \ No newline at end of file +Helper::get_template( 'account/login-registration-form', $args ); diff --git a/composer.json b/composer.json index 1516255c2e..113db86975 100644 --- a/composer.json +++ b/composer.json @@ -6,12 +6,6 @@ "email": "support@wpWax.com" } ], - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", - "squizlabs/php_codesniffer": "3.6.0", - "wp-coding-standards/wpcs": "~2.3.0", - "phpcompatibility/phpcompatibility-wp": "~2.1.3" - }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true @@ -21,5 +15,8 @@ "report": "@php ./vendor/bin/phpcs --report=summary,source", "format": "@php ./vendor/bin/phpcbf", "sniffer:php8.1": "./vendor/bin/phpcs -p . --standard=PHPCompatibilityWP --severity=1 --runtime-set testVersion 8.1- --extensions=php" - } + }, + "require-dev": { + "wp-coding-standards/wpcs": "^3.1" + } } diff --git a/composer.lock b/composer.lock index a25629d4c1..726d6a6d34 100644 --- a/composer.lock +++ b/composer.lock @@ -4,40 +4,43 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8f3b01ee6a2c8a8fb5928f91625c71df", + "content-hash": "90d067f6a8e90b671e0ab7f532c35cd7", "packages": [], "packages-dev": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", "shasum": "" }, "require": { "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", + "php": ">=5.4", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -53,7 +56,7 @@ }, { "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", @@ -77,50 +80,49 @@ "tests" ], "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2022-02-04T12:51:07+00:00" + "time": "2023-01-05T11:28:13+00:00" }, { - "name": "phpcompatibility/php-compatibility", - "version": "9.3.5", + "name": "phpcsstandards/phpcsextra", + "version": "1.2.1", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", - "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", + "reference": "11d387c6642b6e4acaf0bd9bf5203b8cca1ec489", "shasum": "" }, "require": { - "php": ">=5.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" - }, - "conflict": { - "squizlabs/php_codesniffer": "2.6.2" + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.0.9", + "squizlabs/php_codesniffer": "^3.8.0" }, "require-dev": { - "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, "notification-url": "https://packagist.org/downloads/", "license": [ "LGPL-3.0-or-later" ], "authors": [ - { - "name": "Wim Godden", - "homepage": "https://github.com/wimg", - "role": "lead" - }, { "name": "Juliette Reinders Folmer", "homepage": "https://github.com/jrfnl", @@ -128,144 +130,139 @@ }, { "name": "Contributors", - "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" } ], - "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", - "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", "keywords": [ - "compatibility", + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", "phpcs", - "standards" + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibility/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibility" - }, - "time": "2019-12-27T09:44:58+00:00" - }, - { - "name": "phpcompatibility/phpcompatibility-paragonie", - "version": "1.3.1", - "source": { - "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43" + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/ddabec839cc003651f2ce695c938686d1086cf43", - "reference": "ddabec839cc003651f2ce695c938686d1086cf43", - "shasum": "" - }, - "require": { - "phpcompatibility/php-compatibility": "^9.0" - }, - "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7", - "paragonie/random_compat": "dev-master", - "paragonie/sodium_compat": "dev-master" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." - }, - "type": "phpcodesniffer-standard", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-or-later" - ], - "authors": [ + "funding": [ { - "name": "Wim Godden", - "role": "lead" + "url": "https://github.com/PHPCSStandards", + "type": "github" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" } ], - "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", - "homepage": "http://phpcompatibility.com/", - "keywords": [ - "compatibility", - "paragonie", - "phpcs", - "polyfill", - "standards" - ], - "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie" - }, - "time": "2021-02-15T10:24:51+00:00" + "time": "2023-12-08T16:49:07+00:00" }, { - "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.3", + "name": "phpcsstandards/phpcsutils", + "version": "1.0.12", "source": { "type": "git", - "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308" + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/d55de55f88697b9cdb94bccf04f14eb3b11cf308", - "reference": "d55de55f88697b9cdb94bccf04f14eb3b11cf308", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/87b233b00daf83fb70f40c9a28692be017ea7c6c", + "reference": "87b233b00daf83fb70f40c9a28692be017ea7c6c", "shasum": "" }, "require": { - "phpcompatibility/php-compatibility": "^9.0", - "phpcompatibility/phpcompatibility-paragonie": "^1.0" + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.10.0 || 4.0.x-dev@dev" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7" - }, - "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", - "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0" }, "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, "notification-url": "https://packagist.org/downloads/", "license": [ "LGPL-3.0-or-later" ], "authors": [ { - "name": "Wim Godden", + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", "role": "lead" }, { - "name": "Juliette Reinders Folmer", - "role": "lead" + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" } ], - "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", - "homepage": "http://phpcompatibility.com/", + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", "keywords": [ - "compatibility", + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", "phpcs", + "phpcs3", "standards", - "wordpress" + "static analysis", + "tokens", + "utility" ], "support": { - "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", - "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" }, - "time": "2021-12-30T16:37:40+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-05-20T13:34:27+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.6.0", + "version": "3.11.3", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ffced0d2c8fa8e6cdc4d695a743271fab6c38625", - "reference": "ffced0d2c8fa8e6cdc4d695a743271fab6c38625", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", "shasum": "" }, "require": { @@ -275,11 +272,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -294,48 +291,84 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2021-04-09T00:54:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2025-01-23T17:04:15+00:00" }, { "name": "wp-coding-standards/wpcs", - "version": "2.3.0", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "7da1894633f168fe244afc6de00d141f27517b62" + "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", - "reference": "7da1894633f168fe244afc6de00d141f27517b62", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/9333efcbff231f10dfd9c56bb7b65818b4733ca7", + "reference": "9333efcbff231f10dfd9c56bb7b65818b4733ca7", "shasum": "" }, "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.3.1" + "phpcsstandards/phpcsextra": "^1.2.1", + "phpcsstandards/phpcsutils": "^1.0.10", + "squizlabs/php_codesniffer": "^3.9.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcompatibility/php-compatibility": "^9.0", - "phpcsstandards/phpcsdevtools": "^1.0", - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -352,6 +385,7 @@ "keywords": [ "phpcs", "standards", + "static analysis", "wordpress" ], "support": { @@ -359,15 +393,21 @@ "source": "https://github.com/WordPress/WordPress-Coding-Standards", "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, - "time": "2020-05-13T23:57:56+00:00" + "funding": [ + { + "url": "https://opencollective.com/php_codesniffer", + "type": "custom" + } + ], + "time": "2024-03-25T16:39:00+00:00" } ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, - "platform": [], - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/config.php b/config.php index 3452cae4f6..db9dd40ae4 100644 --- a/config.php +++ b/config.php @@ -1,71 +1,108 @@ <?php // Plugin version. -if ( ! defined( 'ATBDP_VERSION' ) ) {define( 'ATBDP_VERSION', '8.0.12' );} +if ( ! defined( 'ATBDP_VERSION' ) ) { + define( 'ATBDP_VERSION', '8.0.12' );} // Plugin Folder Path. -if ( ! defined( 'ATBDP_DIR' ) ) { define( 'ATBDP_DIR', plugin_dir_path( __FILE__ ) ); } +if ( ! defined( 'ATBDP_DIR' ) ) { + define( 'ATBDP_DIR', plugin_dir_path( __FILE__ ) ); } // Plugin Folder URL. -if ( ! defined( 'ATBDP_URL' ) ) { define( 'ATBDP_URL', plugin_dir_url( __FILE__ ) ); } +if ( ! defined( 'ATBDP_URL' ) ) { + define( 'ATBDP_URL', plugin_dir_url( __FILE__ ) ); } // Plugin Root File. -if ( ! defined( 'ATBDP_FILE' ) ) { define( 'ATBDP_FILE', __FILE__ ); } -if ( ! defined( 'ATBDP_BASE' ) ) { define( 'ATBDP_BASE', plugin_basename( __FILE__ ) ); } +if ( ! defined( 'ATBDP_FILE' ) ) { + define( 'ATBDP_FILE', __FILE__ ); } +if ( ! defined( 'ATBDP_BASE' ) ) { + define( 'ATBDP_BASE', plugin_basename( __FILE__ ) ); } // Plugin Text domain File. -if ( ! defined( 'ATBDP_TEXTDOMAIN' ) ) { define( 'ATBDP_TEXTDOMAIN' , 'directorist' ); } +if ( ! defined( 'ATBDP_TEXTDOMAIN' ) ) { + define( 'ATBDP_TEXTDOMAIN', 'directorist' ); } // Plugin Includes Path -if ( !defined('ATBDP_INC_DIR') ) { define('ATBDP_INC_DIR', ATBDP_DIR.'includes/'); } +if ( ! defined( 'ATBDP_INC_DIR' ) ) { + define( 'ATBDP_INC_DIR', ATBDP_DIR . 'includes/' ); } // Plugin Class Path -if ( !defined('ATBDP_CLASS_DIR') ) { define('ATBDP_CLASS_DIR', ATBDP_DIR.'includes/classes/'); } +if ( ! defined( 'ATBDP_CLASS_DIR' ) ) { + define( 'ATBDP_CLASS_DIR', ATBDP_DIR . 'includes/classes/' ); } // Plugin Model Path -if ( !defined('ATBDP_MODEL_DIR') ) { define('ATBDP_MODEL_DIR', ATBDP_DIR.'includes/model/'); } +if ( ! defined( 'ATBDP_MODEL_DIR' ) ) { + define( 'ATBDP_MODEL_DIR', ATBDP_DIR . 'includes/model/' ); } // Plugin Assets Path -if ( !defined('DIRECTORIST_ASSETS_DIR') ) { define('DIRECTORIST_ASSETS_DIR', ATBDP_DIR.'assets/'); } +if ( ! defined( 'DIRECTORIST_ASSETS_DIR' ) ) { + define( 'DIRECTORIST_ASSETS_DIR', ATBDP_DIR . 'assets/' ); } // Plugin Template Path -if ( !defined('ATBDP_VIEWS_DIR') ) { define('ATBDP_VIEWS_DIR', ATBDP_DIR.'views/'); } +if ( ! defined( 'ATBDP_VIEWS_DIR' ) ) { + define( 'ATBDP_VIEWS_DIR', ATBDP_DIR . 'views/' ); } -if ( ! defined( 'DIRECTORIST_LOAD_MIN_FILES' ) ) { define( 'DIRECTORIST_LOAD_MIN_FILES', true ); } -if ( ! defined( 'DIRECTORIST_SCRIPT_VERSION' ) ) { define( 'DIRECTORIST_SCRIPT_VERSION', ATBDP_VERSION ); } -if ( ! defined( 'DIRECTORIST_DISABLE_SHORTCODE_RESTRICTION_ON_SCRIPTS' ) ) { define( 'DIRECTORIST_DISABLE_SHORTCODE_RESTRICTION_ON_SCRIPTS', false ); } -if ( ! defined( 'DIRECTORIST_DEBUG_SHORTCODE_SCRIPTS' ) ) { define( 'DIRECTORIST_DEBUG_SHORTCODE_SCRIPTS', false ); } -if ( ! defined( 'DIRECTORIST_DEBUG_SHORTCODE_SCRIPTS_SHOW_ALL' ) ) { define( 'DIRECTORIST_DEBUG_SHORTCODE_SCRIPTS_SHOW_ALL', false ); } +if ( ! defined( 'DIRECTORIST_LOAD_MIN_FILES' ) ) { + define( 'DIRECTORIST_LOAD_MIN_FILES', true ); } +if ( ! defined( 'DIRECTORIST_SCRIPT_VERSION' ) ) { + define( 'DIRECTORIST_SCRIPT_VERSION', ATBDP_VERSION ); } +if ( ! defined( 'DIRECTORIST_DISABLE_SHORTCODE_RESTRICTION_ON_SCRIPTS' ) ) { + define( 'DIRECTORIST_DISABLE_SHORTCODE_RESTRICTION_ON_SCRIPTS', false ); } +if ( ! defined( 'DIRECTORIST_DEBUG_SHORTCODE_SCRIPTS' ) ) { + define( 'DIRECTORIST_DEBUG_SHORTCODE_SCRIPTS', false ); } +if ( ! defined( 'DIRECTORIST_DEBUG_SHORTCODE_SCRIPTS_SHOW_ALL' ) ) { + define( 'DIRECTORIST_DEBUG_SHORTCODE_SCRIPTS_SHOW_ALL', false ); } // Public Assets Path -if ( ! defined( 'DIRECTORIST_ASSETS' ) ) { define('DIRECTORIST_ASSETS', ATBDP_URL . 'assets/'); } -if ( ! defined( 'ATBDP_PUBLIC_ASSETS') ) { define('ATBDP_PUBLIC_ASSETS', DIRECTORIST_ASSETS ); } -if ( ! defined( 'DIRECTORIST_CSS' ) ) { define('DIRECTORIST_CSS', DIRECTORIST_ASSETS . 'css/'); } -if ( ! defined( 'DIRECTORIST_JS' ) ) { define('DIRECTORIST_JS', DIRECTORIST_ASSETS . 'js/'); } -if ( ! defined( 'DIRECTORIST_ICON_PATH' ) ) { define('DIRECTORIST_ICON_PATH', ATBDP_DIR . 'assets/icons/'); } -if ( ! defined( 'DIRECTORIST_ICON_URL' ) ) { define('DIRECTORIST_ICON_URL', DIRECTORIST_ASSETS . 'icons/'); } +if ( ! defined( 'DIRECTORIST_ASSETS' ) ) { + define( 'DIRECTORIST_ASSETS', ATBDP_URL . 'assets/' ); } +if ( ! defined( 'ATBDP_PUBLIC_ASSETS' ) ) { + define( 'ATBDP_PUBLIC_ASSETS', DIRECTORIST_ASSETS ); } +if ( ! defined( 'DIRECTORIST_CSS' ) ) { + define( 'DIRECTORIST_CSS', DIRECTORIST_ASSETS . 'css/' ); } +if ( ! defined( 'DIRECTORIST_JS' ) ) { + define( 'DIRECTORIST_JS', DIRECTORIST_ASSETS . 'js/' ); } +if ( ! defined( 'DIRECTORIST_ICON_PATH' ) ) { + define( 'DIRECTORIST_ICON_PATH', ATBDP_DIR . 'assets/icons/' ); } +if ( ! defined( 'DIRECTORIST_ICON_URL' ) ) { + define( 'DIRECTORIST_ICON_URL', DIRECTORIST_ASSETS . 'icons/' ); } // Vendor Assets Path -if ( ! defined( 'DIRECTORIST_VENDOR_CSS' ) ) { define('DIRECTORIST_VENDOR_CSS', DIRECTORIST_ASSETS . 'vendor-css/'); } -if ( ! defined( 'DIRECTORIST_VENDOR_JS' ) ) { define('DIRECTORIST_VENDOR_JS', DIRECTORIST_ASSETS . 'vendor-js/'); } +if ( ! defined( 'DIRECTORIST_VENDOR_CSS' ) ) { + define( 'DIRECTORIST_VENDOR_CSS', DIRECTORIST_ASSETS . 'vendor-css/' ); } +if ( ! defined( 'DIRECTORIST_VENDOR_JS' ) ) { + define( 'DIRECTORIST_VENDOR_JS', DIRECTORIST_ASSETS . 'vendor-js/' ); } // Plugin Admin Assets Path -if ( !defined('ATBDP_ADMIN_ASSETS') ) { define('ATBDP_ADMIN_ASSETS', DIRECTORIST_ASSETS ); } +if ( ! defined( 'ATBDP_ADMIN_ASSETS' ) ) { + define( 'ATBDP_ADMIN_ASSETS', DIRECTORIST_ASSETS ); } // Plugin Language File Path -if ( !defined('ATBDP_LANG_DIR') ) { define('ATBDP_LANG_DIR', dirname(plugin_basename( __FILE__ ) ) . '/languages'); } +if ( ! defined( 'ATBDP_LANG_DIR' ) ) { + define( 'ATBDP_LANG_DIR', dirname( plugin_basename( __FILE__ ) ) . '/languages' ); } // Plugin Name -if ( !defined('ATBDP_NAME') ) { define('ATBDP_NAME', 'Directorist'); } +if ( ! defined( 'ATBDP_NAME' ) ) { + define( 'ATBDP_NAME', 'Directorist' ); } // Plugin Post Type -if ( !defined('ATBDP_POST_TYPE') ) { define('ATBDP_POST_TYPE', 'at_biz_dir'); } -if ( !defined('ATBDP_ORDER_POST_TYPE') ) { define('ATBDP_ORDER_POST_TYPE', 'atbdp_orders'); } -if ( !defined('ATBDP_CUSTOM_FIELD_POST_TYPE') ) { define('ATBDP_CUSTOM_FIELD_POST_TYPE', 'atbdp_fields'); } +if ( ! defined( 'ATBDP_POST_TYPE' ) ) { + define( 'ATBDP_POST_TYPE', 'at_biz_dir' ); } +if ( ! defined( 'ATBDP_ORDER_POST_TYPE' ) ) { + define( 'ATBDP_ORDER_POST_TYPE', 'atbdp_orders' ); } +if ( ! defined( 'ATBDP_CUSTOM_FIELD_POST_TYPE' ) ) { + define( 'ATBDP_CUSTOM_FIELD_POST_TYPE', 'atbdp_fields' ); } // Plugin Category Taxonomy -if ( !defined('ATBDP_CATEGORY') ) { define('ATBDP_CATEGORY', ATBDP_POST_TYPE.'-category'); } +if ( ! defined( 'ATBDP_CATEGORY' ) ) { + define( 'ATBDP_CATEGORY', ATBDP_POST_TYPE . '-category' ); } // Plugin Location Taxonomy -if ( !defined('ATBDP_LOCATION') ) { define('ATBDP_LOCATION', ATBDP_POST_TYPE.'-location'); } +if ( ! defined( 'ATBDP_LOCATION' ) ) { + define( 'ATBDP_LOCATION', ATBDP_POST_TYPE . '-location' ); } // Plugin Tag Taxonomy -if ( !defined('ATBDP_TAGS') ) { define('ATBDP_TAGS', ATBDP_POST_TYPE.'-tags'); } +if ( ! defined( 'ATBDP_TAGS' ) ) { + define( 'ATBDP_TAGS', ATBDP_POST_TYPE . '-tags' ); } // Plugin Type Taxonomy -if ( ! defined( 'ATBDP_DIRECTORY_TYPE' ) ) { define( 'ATBDP_DIRECTORY_TYPE', 'atbdp_listing_types' ); } -if ( ! defined('ATBDP_TYPE') ) { define('ATBDP_TYPE', ATBDP_DIRECTORY_TYPE); } +if ( ! defined( 'ATBDP_DIRECTORY_TYPE' ) ) { + define( 'ATBDP_DIRECTORY_TYPE', 'atbdp_listing_types' ); } +if ( ! defined( 'ATBDP_TYPE' ) ) { + define( 'ATBDP_TYPE', ATBDP_DIRECTORY_TYPE ); } // Plugin Alert Message -if ( !defined('ATBDP_ALERT_MSG') ) { define('ATBDP_ALERT_MSG', __('You do not have the right to access this file directly', 'directorist')); } +if ( ! defined( 'ATBDP_ALERT_MSG' ) ) { + define( 'ATBDP_ALERT_MSG', __( 'You do not have the right to access this file directly', 'directorist' ) ); } // Plugin Veiw Path -if ( !defined('ATBDP_VIEW_DIR') ) { define('ATBDP_VIEW_DIR', ATBDP_DIR.'includes/view/'); } +if ( ! defined( 'ATBDP_VIEW_DIR' ) ) { + define( 'ATBDP_VIEW_DIR', ATBDP_DIR . 'includes/view/' ); } define( 'DIRECTORIST_VENDOR', DIRECTORIST_ASSETS . 'vendor/' ); diff --git a/directorist-base.php b/directorist-base.php index 5765559fe9..23e5f7700c 100644 --- a/directorist-base.php +++ b/directorist-base.php @@ -11,15 +11,15 @@ */ // prevent direct access to the file -defined('ABSPATH') || die('No direct script access allowed!'); +defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); /** * Main Directorist_Base Class. * * @since 1.0 */ -final class Directorist_Base -{ +final class Directorist_Base { + /** Singleton *************************************************************/ /** @@ -149,12 +149,12 @@ final class Directorist_Base public $tools; /** - * Insights class - * - * @var Insights + * Insights class + * + * @var Insights * @since 8.0 - */ - public $insights = null; + */ + public $insights = null; /** * ATBDP_Single_Templates Object. @@ -188,28 +188,27 @@ final class Directorist_Base * @see ATBDP() * @return object|Directorist_Base The one true Directorist_Base */ - public static function instance() - { - if (!isset(self::$instance) && !(self::$instance instanceof Directorist_Base)) { + public static function instance() { + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof Directorist_Base ) ) { self::$instance = new Directorist_Base(); self::$instance->setup_constants(); add_action( 'plugins_loaded', array( self::$instance, 'redirect_to_setup_wizard' ) ); - add_action('init', array(self::$instance, 'load_textdomain')); - add_action('init', array(self::$instance, 'add_polylang_swicher_support') ); - add_action('widgets_init', array(self::$instance, 'register_widgets')); - add_filter('widget_display_callback', array(self::$instance, 'custom_widget_body_wrapper'), 10, 3); - add_action('after_setup_theme', array(self::$instance, 'add_image_sizes')); + add_action( 'init', array( self::$instance, 'load_textdomain' ) ); + add_action( 'init', array( self::$instance, 'add_polylang_swicher_support' ) ); + add_action( 'widgets_init', array( self::$instance, 'register_widgets' ) ); + add_filter( 'widget_display_callback', array( self::$instance, 'custom_widget_body_wrapper' ), 10, 3 ); + add_action( 'after_setup_theme', array( self::$instance, 'add_image_sizes' ) ); - add_action( 'template_redirect', [ self::$instance, 'check_single_listing_page_restrictions' ] ); - add_action( 'atbdp_show_flush_messages', [ self::$instance, 'show_flush_messages' ] ); + add_action( 'template_redirect', array( self::$instance, 'check_single_listing_page_restrictions' ) ); + add_action( 'atbdp_show_flush_messages', array( self::$instance, 'show_flush_messages' ) ); self::$instance->includes(); self::$instance->custom_post = new ATBDP_Custom_Post(); // create custom post - self::$instance->taxonomy = new ATBDP_Custom_Taxonomy(); + self::$instance->taxonomy = new ATBDP_Custom_Taxonomy(); - add_action('init', array( self::$instance, 'on_install_update_actions' ) ); + add_action( 'init', array( self::$instance, 'on_install_update_actions' ) ); Directorist\Asset_Loader\Asset_Loader::init(); @@ -220,23 +219,23 @@ public static function instance() self::$instance->settings_panel = new ATBDP_Settings_Panel(); self::$instance->settings_panel->run(); - self::$instance->hooks = new ATBDP_Hooks(); - self::$instance->metabox = new ATBDP_Metabox(); + self::$instance->hooks = new ATBDP_Hooks(); + self::$instance->metabox = new ATBDP_Metabox(); self::$instance->ajax_handler = new ATBDP_Ajax_Handler(); - self::$instance->helper = new ATBDP_Helper(); - self::$instance->listing = new ATBDP_Listing(); - self::$instance->user = new ATBDP_User(); - self::$instance->roles = new ATBDP_Roles(); - if( class_exists( 'ATBDP_Gateway' ) ) { + self::$instance->helper = new ATBDP_Helper(); + self::$instance->listing = new ATBDP_Listing(); + self::$instance->user = new ATBDP_User(); + self::$instance->roles = new ATBDP_Roles(); + if ( class_exists( 'ATBDP_Gateway' ) ) { self::$instance->gateway = new ATBDP_Gateway(); } - self::$instance->order = new ATBDP_Order(); + self::$instance->order = new ATBDP_Order(); self::$instance->shortcode = new \Directorist\ATBDP_Shortcode(); - self::$instance->email = new ATBDP_Email(); - self::$instance->seo = new ATBDP_SEO(); + self::$instance->email = new ATBDP_Email(); + self::$instance->seo = new ATBDP_SEO(); // self::$instance->validator = new ATBDP_Validator; // self::$instance->ATBDP_Single_Templates = new ATBDP_Single_Templates; - self::$instance->tools = new ATBDP_Tools(); + self::$instance->tools = new ATBDP_Tools(); self::$instance->announcement = new ATBDP_Announcement(); self::$instance->background_image_process = new \Directorist\Background_Image_Process(); @@ -247,10 +246,11 @@ public static function instance() // Load widgets Directorist\Widgets\Init::instance(); - /*Extensions Link*/ + /* + Extensions Link*/ /*initiate extensions link*/ - if( is_admin() ){ + if ( is_admin() ) { new ATBDP_Extensions(); } @@ -261,19 +261,19 @@ public static function instance() include_once ATBDP_INC_DIR . 'review/class-bc-review-rating.php'; self::$instance->review = new ATBDP_Review_Rating(); - //activate rewrite api + // activate rewrite api new ATBDP_Rewrite(); - //map custom capabilities - add_filter('map_meta_cap', array(self::$instance->roles, 'meta_caps'), 10, 4); - //add dtbdp custom body class - add_filter('body_class', array(self::$instance, 'atbdp_body_class'), 99); + // map custom capabilities + add_filter( 'map_meta_cap', array( self::$instance->roles, 'meta_caps' ), 10, 4 ); + // add dtbdp custom body class + add_filter( 'body_class', array( self::$instance, 'atbdp_body_class' ), 99 ); // Attempt to create listing related custom pages with plugin's custom shortcode to give user best experience. // we can check the database if our custom pages have been installed correctly or not here first. // This way we can minimize the adding of our custom function to the WordPress hooks. - if (get_option('atbdp_pages_version') < 1) { - add_action('wp_loaded', array(self::$instance, 'add_custom_directorist_pages')); + if ( get_option( 'atbdp_pages_version' ) < 1 ) { + add_action( 'wp_loaded', array( self::$instance, 'add_custom_directorist_pages' ) ); } // init offline gateway @@ -283,8 +283,8 @@ public static function instance() // add upgrade feature new ATBDP_Upgrade(); // add uninstall menu - add_filter('atbdp_settings_menus', array(self::$instance, 'add_uninstall_menu')); - add_filter( 'display_post_states', array(self::$instance, 'add_page_states'), 10, 2 ); + add_filter( 'atbdp_settings_menus', array( self::$instance, 'add_uninstall_menu' ) ); + add_filter( 'display_post_states', array( self::$instance, 'add_page_states' ), 10, 2 ); self::init_hooks(); // Initialize appsero tracking @@ -361,36 +361,46 @@ public function add_polylang_swicher_support() { // beta plugin lookup $plugin_data = get_plugin_data( plugin_dir_path( __FILE__ ) . 'directorist-base.php' ); - if( ! empty( $plugin_data['Version'] ) ) { + if ( ! empty( $plugin_data['Version'] ) ) { self::$instance->beta = strpos( $plugin_data['Version'], 'Beta' ) ? true : false; } - - add_filter('pll_the_language_link', function($url, $current_lang) { - // Adjust the category link - $category_url = $this->get_polylang_swicher_link_for_term([ - 'term_type' => 'category', - 'term_default_page_id' => get_directorist_option('single_category_page'), - 'term_query_var' => ( ! empty( $_GET['category'] ) ) ? sanitize_text_field( wp_unslash( $_GET['category'] ) ) : get_query_var('atbdp_category'), - 'current_lang' => $current_lang, - 'url' => $url, - ]); - - if ( ! empty( $category_url ) ) { return $category_url; } - - // Adjust the location link - $location_url = $this->get_polylang_swicher_link_for_term([ - 'term_type' => 'location', - 'term_default_page_id' => get_directorist_option('single_location_page'), - 'term_query_var' => ( ! empty( $_GET['location'] ) ) ? sanitize_text_field( wp_unslash( $_GET['location'] ) ) : get_query_var('atbdp_location'), - 'current_lang' => $current_lang, - 'url' => $url, - ]); - - if ( ! empty( $location_url ) ) { return $location_url; } - - return $url; - }, 10, 2); + add_filter( + 'pll_the_language_link', + function ( $url, $current_lang ) { + // Adjust the category link + $category_url = $this->get_polylang_swicher_link_for_term( + array( + 'term_type' => 'category', + 'term_default_page_id' => get_directorist_option( 'single_category_page' ), + 'term_query_var' => ( ! empty( $_GET['category'] ) ) ? sanitize_text_field( wp_unslash( $_GET['category'] ) ) : get_query_var( 'atbdp_category' ), + 'current_lang' => $current_lang, + 'url' => $url, + ) + ); + + if ( ! empty( $category_url ) ) { + return $category_url; } + + // Adjust the location link + $location_url = $this->get_polylang_swicher_link_for_term( + array( + 'term_type' => 'location', + 'term_default_page_id' => get_directorist_option( 'single_location_page' ), + 'term_query_var' => ( ! empty( $_GET['location'] ) ) ? sanitize_text_field( wp_unslash( $_GET['location'] ) ) : get_query_var( 'atbdp_location' ), + 'current_lang' => $current_lang, + 'url' => $url, + ) + ); + + if ( ! empty( $location_url ) ) { + return $location_url; } + + return $url; + }, + 10, + 2 + ); } // get_polylang_swicher_link_for_term @@ -399,28 +409,29 @@ public function get_polylang_swicher_link_for_term( $args ) { return; } - $default = [ + $default = array( 'term_type' => '', 'term_query_var' => '', 'term_default_page_id' => '', 'current_lang' => '', 'url' => '', - ]; + ); $args = array_merge( $default, $args ); - if ( empty( $args[ 'term_query_var' ] ) ) { return false; } + if ( empty( $args['term_query_var'] ) ) { + return false; } // Get language slug of the default page - $page_lang = pll_get_post_language( $args[ 'term_default_page_id' ] ); + $page_lang = pll_get_post_language( $args['term_default_page_id'] ); // If current lang slug != default page // modyfy the url - if ( $args[ 'current_lang' ] !== $page_lang ) { - return $args['url'] ."?". $args['term_type'] ."=". $args['term_query_var']; + if ( $args['current_lang'] !== $page_lang ) { + return $args['url'] . '?' . $args['term_type'] . '=' . $args['term_query_var']; } - if ( $args[ 'current_lang' ] === $page_lang ) { + if ( $args['current_lang'] === $page_lang ) { return $args['url'] . $args['term_query_var']; } @@ -434,8 +445,7 @@ public function get_polylang_swicher_link_for_term( $args ) { * @since 6.4.5 * @return void */ - public static function init_hooks() - { + public static function init_hooks() { ATBDP_Cache_Helper::reset_cache(); } @@ -446,17 +456,18 @@ public static function init_hooks() * @since 1.0 * @return void */ - private function setup_constants() - { + private function setup_constants() { // test - require_once plugin_dir_path(__FILE__) . '/config.php'; // loads constant from a file so that it can be available on all files. + require_once plugin_dir_path( __FILE__ ) . '/config.php'; // loads constant from a file so that it can be available on all files. } private function autoload( $dir = '' ) { - if ( !file_exists( $dir ) ) return; + if ( ! file_exists( $dir ) ) { + return; + } foreach ( scandir( $dir ) as $file ) { - if ( preg_match( "/.php$/i", $file ) ) { - require_once( $dir . $file ); + if ( preg_match( '/.php$/i', $file ) ) { + require_once $dir . $file; } } } @@ -468,52 +479,53 @@ private function autoload( $dir = '' ) { * @since 1.0 * @return void */ - private function includes() - { + private function includes() { $this->autoload( ATBDP_INC_DIR . 'helpers/' ); $this->autoload( ATBDP_INC_DIR . 'asset-loader/' ); $this->autoload( ATBDP_INC_DIR . 'widgets/' ); - self::require_files([ - ATBDP_INC_DIR . 'directorist-core-functions', - ATBDP_INC_DIR . 'directorist-directory-functions', - ATBDP_INC_DIR . 'class-helper', - ATBDP_INC_DIR . 'helper-functions', - ATBDP_INC_DIR . 'template-functions', - ATBDP_INC_DIR . 'custom-actions', - ATBDP_INC_DIR . 'custom-filters', - ATBDP_INC_DIR . 'elementor/init', - ATBDP_INC_DIR . 'system-status/class-system-status', - ATBDP_INC_DIR . 'review/init', - ATBDP_INC_DIR . 'rest-api/init', - ATBDP_INC_DIR . 'fields/init', - ATBDP_INC_DIR . 'modules/multi-directory-setup/class-builder-data', - ATBDP_INC_DIR . 'modules/multi-directory-setup/trait-multi-directory-helper', - ATBDP_INC_DIR . 'modules/multi-directory-setup/class-multi-directory-migration', - ATBDP_INC_DIR . 'modules/multi-directory-setup/class-multi-directory-manager', - ATBDP_INC_DIR . 'modules/multi-directory-setup/class-ai-builder', - ]); + self::require_files( + array( + ATBDP_INC_DIR . 'directorist-core-functions', + ATBDP_INC_DIR . 'directorist-directory-functions', + ATBDP_INC_DIR . 'class-helper', + ATBDP_INC_DIR . 'helper-functions', + ATBDP_INC_DIR . 'template-functions', + ATBDP_INC_DIR . 'custom-actions', + ATBDP_INC_DIR . 'custom-filters', + ATBDP_INC_DIR . 'elementor/init', + ATBDP_INC_DIR . 'system-status/class-system-status', + ATBDP_INC_DIR . 'review/init', + ATBDP_INC_DIR . 'rest-api/init', + ATBDP_INC_DIR . 'fields/init', + ATBDP_INC_DIR . 'modules/multi-directory-setup/class-builder-data', + ATBDP_INC_DIR . 'modules/multi-directory-setup/trait-multi-directory-helper', + ATBDP_INC_DIR . 'modules/multi-directory-setup/class-multi-directory-migration', + ATBDP_INC_DIR . 'modules/multi-directory-setup/class-multi-directory-manager', + ATBDP_INC_DIR . 'modules/multi-directory-setup/class-ai-builder', + ) + ); $this->autoload( ATBDP_INC_DIR . 'database/' ); - load_dependencies('all', ATBDP_INC_DIR . 'data-store/'); - load_dependencies('all', ATBDP_INC_DIR . 'model/'); - load_dependencies('all', ATBDP_INC_DIR . 'hooks/'); - load_dependencies('all', ATBDP_INC_DIR . 'modules/'); + load_dependencies( 'all', ATBDP_INC_DIR . 'data-store/' ); + load_dependencies( 'all', ATBDP_INC_DIR . 'model/' ); + load_dependencies( 'all', ATBDP_INC_DIR . 'hooks/' ); + load_dependencies( 'all', ATBDP_INC_DIR . 'modules/' ); - load_dependencies('all', ATBDP_CLASS_DIR); // load all php files from ATBDP_CLASS_DIR + load_dependencies( 'all', ATBDP_CLASS_DIR ); // load all php files from ATBDP_CLASS_DIR /*Load gateway related stuff*/ - load_dependencies('all', ATBDP_INC_DIR . 'gateways/'); + load_dependencies( 'all', ATBDP_INC_DIR . 'gateways/' ); /*Load payment related stuff*/ - load_dependencies('all', ATBDP_INC_DIR . 'payments/'); - load_dependencies('all', ATBDP_INC_DIR . 'checkout/'); + load_dependencies( 'all', ATBDP_INC_DIR . 'payments/' ); + load_dependencies( 'all', ATBDP_INC_DIR . 'checkout/' ); $this->autoload( ATBDP_INC_DIR . 'deprecated/' ); } // require_files - public static function require_files( array $files = [] ) { + public static function require_files( array $files = array() ) { foreach ( $files as $file ) { if ( file_exists( "{$file}.php" ) ) { require_once "{$file}.php"; @@ -521,8 +533,7 @@ public static function require_files( array $files = [] ) { } } - public static function prepare_plugin() - { + public static function prepare_plugin() { include ATBDP_INC_DIR . 'classes/class-installation.php'; ATBDP_Installation::install(); } @@ -537,8 +548,7 @@ public static function prepare_plugin() * @access public * @return void */ - public function __clone() - { + public function __clone() { // Cloning instances of the class is forbidden. _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'directorist'), '1.0'); // @codingStandardsIgnoreLine. } @@ -550,8 +560,7 @@ public function __clone() * @access public * @return void */ - public function __wakeup() - { + public function __wakeup() { // Unserializing instances of the class is forbidden. _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'directorist' ), '1.0'); // @codingStandardsIgnoreLine. } @@ -563,18 +572,19 @@ public function __wakeup() * @access public * @return void */ - public function register_widgets() - { - if (!is_registered_sidebar('right-sidebar-listing')) { - register_sidebar(array( - 'name' => apply_filters('atbdp_right_sidebar_name', __('Directorist - Listing Right Sidebar', 'directorist')), - 'id' => 'right-sidebar-listing', - 'description' => __('Add widgets for the right sidebar on single listing page', 'directorist'), - 'before_widget' => '<div class="directorist-card %2$s">', - 'after_widget' => '</div>', - 'before_title' => '<div class="directorist-card__header directorist-widget__header"><h3 class="directorist-card__header__title directorist-widget__header__title">', - 'after_title' => '</h3></div>', - )); + public function register_widgets() { + if ( ! is_registered_sidebar( 'right-sidebar-listing' ) ) { + register_sidebar( + array( + 'name' => apply_filters( 'atbdp_right_sidebar_name', __( 'Directorist - Listing Right Sidebar', 'directorist' ) ), + 'id' => 'right-sidebar-listing', + 'description' => __( 'Add widgets for the right sidebar on single listing page', 'directorist' ), + 'before_widget' => '<div class="directorist-card %2$s">', + 'after_widget' => '</div>', + 'before_title' => '<div class="directorist-card__header directorist-widget__header"><h3 class="directorist-card__header__title directorist-widget__header__title">', + 'after_title' => '</h3></div>', + ) + ); } } @@ -662,14 +672,14 @@ public function load_textdomain() { /** * It loads a template file from the Default template directory. + * * @todo; Improve this method in future so that it lets user/developers to change/override any templates this plugin uses * @param string $name Name of the file that should be loaded from the template directory. - * @param array $args Additional arguments that should be passed to the template file for rendering dynamic data. - * @param bool $return_path Whether to return the path instead of including it + * @param array $args Additional arguments that should be passed to the template file for rendering dynamic data. + * @param bool $return_path Whether to return the path instead of including it * @return string|void */ - public function load_template( $template_name, $args = array(), $return_path = false ) - { + public function load_template( $template_name, $args = array(), $return_path = false ) { $path = ATBDP_VIEWS_DIR . $template_name . '.php'; $path = apply_filters( 'directorist_admin_template', $path, $template_name, $args ); @@ -677,107 +687,112 @@ public function load_template( $template_name, $args = array(), $return_path = f return $path; } - include($path); + include $path; } - public function add_custom_directorist_pages() - { - $create_permission = apply_filters('atbdp_create_required_pages', true); - if ($create_permission){ + public function add_custom_directorist_pages() { + $create_permission = apply_filters( 'atbdp_create_required_pages', true ); + if ( $create_permission ) { atbdp_create_required_pages(); } } /** - * Add a post display state for special Directorist pages in the page list table. - * - * @param array $post_states An array of post display states. - * @param WP_Post $post The current post object. - */ + * Add a post display state for special Directorist pages in the page list table. + * + * @param array $post_states An array of post display states. + * @param WP_Post $post The current post object. + */ public function add_page_states( $post_states, $post ) { if ( get_directorist_option( 'add_listing_page' ) === $post->ID ) { - $post_states['directorist_add_listing'] = __( 'Directorist Add Listing', 'directorist' ); - } + $post_states['directorist_add_listing'] = __( 'Directorist Add Listing', 'directorist' ); + } if ( get_directorist_option( 'all_listing_page' ) === $post->ID ) { - $post_states['directorist_all_listing'] = __( 'Directorist All Listings', 'directorist' ); - } + $post_states['directorist_all_listing'] = __( 'Directorist All Listings', 'directorist' ); + } if ( get_directorist_option( 'user_dashboard' ) === $post->ID ) { - $post_states['directorist_user_dashboard'] = __( 'Directorist Dashboard', 'directorist' ); - } + $post_states['directorist_user_dashboard'] = __( 'Directorist Dashboard', 'directorist' ); + } if ( get_directorist_option( 'author_profile_page' ) === $post->ID ) { - $post_states['directorist_author_profile_page'] = __( 'Directorist Author Profile', 'directorist' ); - } + $post_states['directorist_author_profile_page'] = __( 'Directorist Author Profile', 'directorist' ); + } if ( get_directorist_option( 'all_categories_page' ) === $post->ID ) { - $post_states['directorist_all_categories_page'] = __( 'Directorist All Categories', 'directorist' ); - } + $post_states['directorist_all_categories_page'] = __( 'Directorist All Categories', 'directorist' ); + } if ( get_directorist_option( 'single_category_page' ) === $post->ID ) { - $post_states['directorist_single_category_page'] = __( 'Directorist Single Category', 'directorist' ); - } + $post_states['directorist_single_category_page'] = __( 'Directorist Single Category', 'directorist' ); + } if ( get_directorist_option( 'all_locations_page' ) === $post->ID ) { - $post_states['directorist_all_locations_page'] = __( 'Directorist All Locations', 'directorist' ); - } + $post_states['directorist_all_locations_page'] = __( 'Directorist All Locations', 'directorist' ); + } if ( get_directorist_option( 'single_location_page' ) === $post->ID ) { - $post_states['directorist_single_location_page'] = __( 'Directorist Single Location', 'directorist' ); - } + $post_states['directorist_single_location_page'] = __( 'Directorist Single Location', 'directorist' ); + } if ( get_directorist_option( 'single_tag_page' ) === $post->ID ) { - $post_states['directorist_single_tag_page'] = __( 'Directorist Single Tag', 'directorist' ); - } + $post_states['directorist_single_tag_page'] = __( 'Directorist Single Tag', 'directorist' ); + } if ( get_directorist_option( 'search_listing' ) === $post->ID ) { - $post_states['directorist_search_listing'] = __( 'Directorist Listing Search Form', 'directorist' ); - } + $post_states['directorist_search_listing'] = __( 'Directorist Listing Search Form', 'directorist' ); + } if ( get_directorist_option( 'search_result_page' ) === $post->ID ) { - $post_states['directorist_search_result_page'] = __( 'Directorist Search Result', 'directorist' ); - } + $post_states['directorist_search_result_page'] = __( 'Directorist Search Result', 'directorist' ); + } if ( get_directorist_option( 'checkout_page' ) === $post->ID ) { - $post_states['directorist_checkout_page'] = __( 'Directorist Checkout', 'directorist' ); - } + $post_states['directorist_checkout_page'] = __( 'Directorist Checkout', 'directorist' ); + } if ( get_directorist_option( 'payment_receipt_page' ) === $post->ID ) { - $post_states['directorist_payment_receipt_page'] = __( 'Directorist Payment Receipt', 'directorist' ); - } + $post_states['directorist_payment_receipt_page'] = __( 'Directorist Payment Receipt', 'directorist' ); + } if ( get_directorist_option( 'transaction_failure_page' ) === $post->ID ) { - $post_states['directorist_transaction_failure_page'] = __( 'Directorist Payment Failure', 'directorist' ); - } + $post_states['directorist_transaction_failure_page'] = __( 'Directorist Payment Failure', 'directorist' ); + } if ( get_directorist_option( 'privacy_policy' ) === $post->ID ) { - $post_states['directorist_privacy_policy'] = __( 'Directorist Privacy Policy', 'directorist' ); - } + $post_states['directorist_privacy_policy'] = __( 'Directorist Privacy Policy', 'directorist' ); + } if ( get_directorist_option( 'terms_conditions' ) === $post->ID ) { - $post_states['directorist_terms_conditions'] = __( 'Directorist Terms & Conditions', 'directorist' ); - } + $post_states['directorist_terms_conditions'] = __( 'Directorist Terms & Conditions', 'directorist' ); + } if ( get_directorist_option( 'pricing_plans' ) === $post->ID ) { - $post_states['directorist_pricing_plans'] = __( 'Directorist Pricing Plan', 'directorist' ); - } + $post_states['directorist_pricing_plans'] = __( 'Directorist Pricing Plan', 'directorist' ); + } if ( get_directorist_option( 'signin_signup_page' ) === $post->ID ) { - $post_states['directorist_signin_signup'] = __( 'Directorist Sign In', 'directorist' ); - } + $post_states['directorist_signin_signup'] = __( 'Directorist Sign In', 'directorist' ); + } - return $post_states; - } + return $post_states; + } - public function add_uninstall_menu($menus) { + public function add_uninstall_menu( $menus ) { $menus['uninstall_menu'] = array( - 'title' => __('Uninstall', 'directorist'), - 'name' => 'uninstall_menu', - 'icon' => 'font-awesome:fa-window-close', - 'controls' => apply_filters('atbdp_uninstall_settings_controls', array( - 'currency_section' => array( - 'type' => 'section', - 'title' => __('Uninstall Settings', 'directorist'), - 'fields' => get_uninstall_settings_submenus(), - ), - )), + 'title' => __( 'Uninstall', 'directorist' ), + 'name' => 'uninstall_menu', + 'icon' => 'font-awesome:fa-window-close', + 'controls' => apply_filters( + 'atbdp_uninstall_settings_controls', + array( + 'currency_section' => array( + 'type' => 'section', + 'title' => __( 'Uninstall Settings', 'directorist' ), + 'fields' => get_uninstall_settings_submenus(), + ), + ) + ), ); - $menus['csv_import'] = array( - 'title' => __('Listings Import', 'directorist'), - 'name' => 'csv_import', - 'icon' => 'font-awesome:fa-upload', - 'controls' => apply_filters('atbdp_csv_import_settings_controls', array( - 'currency_section' => array( - 'type' => 'section', - 'title' => __('Listings Import', 'directorist'), - 'fields' => get_csv_import_settings_submenus(), - ), - )), + $menus['csv_import'] = array( + 'title' => __( 'Listings Import', 'directorist' ), + 'name' => 'csv_import', + 'icon' => 'font-awesome:fa-upload', + 'controls' => apply_filters( + 'atbdp_csv_import_settings_controls', + array( + 'currency_section' => array( + 'type' => 'section', + 'title' => __( 'Listings Import', 'directorist' ), + 'fields' => get_csv_import_settings_submenus(), + ), + ) + ), ); return $menus; } @@ -787,7 +802,7 @@ public function show_popular_listing() { return; } - public function show_static_rating($post) { + public function show_static_rating( $post ) { if ( ! directorist_is_review_enabled() ) { return; } @@ -809,7 +824,7 @@ public function show_static_rating($post) { * * @return object WP_Query */ - public function get_related_listings($post) { + public function get_related_listings( $post ) { _deprecated_function( __METHOD__, '7.4.3' ); return new WP_Query(); } @@ -843,10 +858,9 @@ public function atbdp_parse_videos( $url ) { return \Directorist\Helper::parse_video( $url ); } - public function atbdp_body_class($c_classes) - { - $c_classes[] = 'directorist-content-active';//class name goes here - $c_classes[] = 'directorist-preload';//class name goes here + public function atbdp_body_class( $c_classes ) { + $c_classes[] = 'directorist-content-active';// class name goes here + $c_classes[] = 'directorist-preload';// class name goes here return $c_classes; } @@ -866,7 +880,7 @@ public function init_appsero() { require_once ATBDP_INC_DIR . 'modules/appsero/src/Client.php'; } - $client = new \Directorist\Appsero\Client( 'd9f81baf-2b03-49b1-b899-b4ee71c1d1b1', 'Directorist', __FILE__ ); + $client = new \Directorist\Appsero\Client( 'd9f81baf-2b03-49b1-b899-b4ee71c1d1b1', 'Directorist', __FILE__ ); $this->insights = $client->insights(); // Active insights @@ -877,7 +891,6 @@ public function init_appsero() { public function init_blocks() { require_once ATBDP_DIR . 'blocks/init.php'; } - } // ends Directorist_Base @@ -890,14 +903,12 @@ public function init_blocks() { * Use this function like you would a global variable, except without needing * to declare the global. * - * * @since 1.0 * @return object|Directorist_Base The one true Directorist_Base Instance. */ -function ATBDP() -{ +function ATBDP() { return Directorist_Base::instance(); } ATBDP(); -register_activation_hook(__FILE__, array('Directorist_Base', 'prepare_plugin')); \ No newline at end of file +register_activation_hook( __FILE__, array( 'Directorist_Base', 'prepare_plugin' ) ); \ No newline at end of file diff --git a/includes/asset-loader/helper.php b/includes/asset-loader/helper.php index da4abc3935..54f0dd48a7 100644 --- a/includes/asset-loader/helper.php +++ b/includes/asset-loader/helper.php @@ -5,7 +5,9 @@ namespace Directorist\Asset_Loader; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Helper { @@ -25,16 +27,16 @@ public static function instant_search_enabled() { /** * Register all scripts. * - * @param array $script single item of Scripts::get_all_scripts() array. + * @param array $script single item of Scripts::get_all_scripts() array. * @param string $version */ public static function register_all_scripts( $scripts, $version = '' ) { - if ( !$version ) { + if ( ! $version ) { $version = self::get_script_version(); } foreach ( $scripts as $handle => $script ) { - Helper::register_single_script( $handle, $script, $version ); + self::register_single_script( $handle, $script, $version ); } } @@ -42,25 +44,23 @@ public static function register_all_scripts( $scripts, $version = '' ) { * Register a script. * * @param string $handle - * @param array $script single item of Scripts::get_all_scripts() array. + * @param array $script single item of Scripts::get_all_scripts() array. * @param string $version */ public static function register_single_script( $handle, $script, $version = '' ) { - $url = self::script_file_url( $script ); - - if ( !empty( $script['dep'] ) ) { - $dep = $script['dep']; - } - else { - $dep = ( $script['type'] == 'js' ) ? ['jquery'] : []; - } - - if ( $script['type'] == 'css' ) { - wp_register_style( $handle, $url, $dep, $version ); - } - else { - wp_register_script( $handle, $url, $dep, $version, true ); - } + $url = self::script_file_url( $script ); + + if ( ! empty( $script['dep'] ) ) { + $dep = $script['dep']; + } else { + $dep = ( $script['type'] == 'js' ) ? array( 'jquery' ) : array(); + } + + if ( $script['type'] == 'css' ) { + wp_register_style( $handle, $url, $dep, $version ); + } else { + wp_register_script( $handle, $url, $dep, $version, true ); + } } /** @@ -83,7 +83,7 @@ public static function dynamic_style() { ob_start(); include $style_path; $style = ob_get_clean(); - $style = str_replace( ['<style>', '</style>'], '', $style ); + $style = str_replace( array( '<style>', '</style>' ), '', $style ); $style = self::minify_css( $style ); return $style; } @@ -96,13 +96,13 @@ public static function dynamic_style() { * @return string URL string. */ public static function script_file_url( $script ) { - if ( !empty( $script['ext'] ) ) { + if ( ! empty( $script['ext'] ) ) { return $script['ext']; } - $min = self::debug_enabled() ? '' : '.min'; - $rtl = ( !empty( $script['rtl'] ) && is_rtl() ) ? '.rtl' : ''; - $ext = $script['type'] == 'css' ? '.css' : '.js'; + $min = self::debug_enabled() ? '' : '.min'; + $rtl = ( ! empty( $script['rtl'] ) && is_rtl() ) ? '.rtl' : ''; + $ext = $script['type'] == 'css' ? '.css' : '.js'; $url = $script['path'] . $rtl . $min . $ext; return $url; } @@ -117,7 +117,9 @@ public static function script_file_url( $script ) { * @return string */ public static function minify_css( $input ) { - if(trim($input) === "") return $input; + if ( trim( $input ) === '' ) { + return $input; + } return preg_replace( array( // Remove comment(s) @@ -140,7 +142,7 @@ public static function minify_css( $input ) { // Replace `(border|outline):none` with `(border|outline):0` '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', // Remove empty selector(s) - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s', ), array( '$1', @@ -153,9 +155,10 @@ public static function minify_css( $input ) { '$1$2$4$5', '$1$2$3', '$1:0', - '$1$2' + '$1$2', ), - $input); + $input + ); } /** @@ -178,7 +181,7 @@ public static function is_widget_template( $template ) { if ( empty( $template ) ) { return false; } - + return str_starts_with( $template, 'widgets/' ); } @@ -204,7 +207,7 @@ public static function is_admin_page( $page ) { case 'builder-edit': if ( $screen == 'at_biz_dir_page_atbdp-directory-types' ) { // Multi-directory enabled - if ( !empty( $_GET['action'] ) && ( $_GET['action'] == 'edit' || $_GET['action'] == 'add_new' ) ) { + if ( ! empty( $_GET['action'] ) && ( $_GET['action'] == 'edit' || $_GET['action'] == 'add_new' ) ) { $status = true; } } elseif ( $screen == 'at_biz_dir_page_atbdp-layout-builder' ) { @@ -220,7 +223,7 @@ public static function is_admin_page( $page ) { break; case 'all_listings': - if ( $screen == 'edit' && !empty( $_GET['post_type'] ) && $_GET['post_type'] == 'at_biz_dir' ) { + if ( $screen == 'edit' && ! empty( $_GET['post_type'] ) && $_GET['post_type'] == 'at_biz_dir' ) { $status = true; } break; @@ -235,7 +238,7 @@ public static function is_admin_page( $page ) { case 'taxonomy': if ( $screen == 'term' || $screen == 'edit-tags' ) { - $taxonomies = [ 'at_biz_dir-category', 'at_biz_dir-location', 'at_biz_dir-tags' ]; + $taxonomies = array( 'at_biz_dir-category', 'at_biz_dir-location', 'at_biz_dir-tags' ); if ( isset( $_GET['taxonomy'] ) && in_array( $_GET['taxonomy'], $taxonomies ) ) { $status = true; } @@ -275,4 +278,4 @@ public static function is_admin_page( $page ) { return $status; } -} \ No newline at end of file +} diff --git a/includes/asset-loader/init.php b/includes/asset-loader/init.php index 64b3483e84..1f15baeafd 100644 --- a/includes/asset-loader/init.php +++ b/includes/asset-loader/init.php @@ -53,7 +53,7 @@ public static function enqueue_styles() { // CSS wp_enqueue_style( 'directorist-main-style' ); - //wp_enqueue_style( 'directorist-support-v7-style' ); + // wp_enqueue_style( 'directorist-support-v7-style' ); wp_enqueue_style( 'directorist-select2-style' ); wp_enqueue_style( 'directorist-ez-media-uploader-style' ); wp_enqueue_style( 'directorist-swiper-style' ); @@ -249,8 +249,8 @@ public static function admin_scripts() { wp_enqueue_script( 'directorist-icon-picker' ); wp_enqueue_style( 'directorist-unicons' ); wp_enqueue_script( 'directorist-multi-directory-builder' ); - wp_enqueue_script('wp-tinymce'); - wp_enqueue_script('wp-media'); + wp_enqueue_script( 'wp-tinymce' ); + wp_enqueue_script( 'wp-media' ); wp_enqueue_media(); } elseif ( Helper::is_admin_page( 'settings' ) ) { wp_enqueue_style( 'directorist-admin-style' ); diff --git a/includes/asset-loader/localized_data.php b/includes/asset-loader/localized_data.php index 927b4d39ae..bf901bc539 100644 --- a/includes/asset-loader/localized_data.php +++ b/includes/asset-loader/localized_data.php @@ -5,7 +5,9 @@ namespace Directorist\Asset_Loader; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Localized_Data { @@ -32,25 +34,29 @@ public static function admin_data() { } private static function search_listing_data() { - $data = [ - 'ajaxnonce' => wp_create_nonce('bdas_ajax_nonce'), - 'ajax_url' => admin_url('admin-ajax.php'), - ]; + $data = array( + 'ajaxnonce' => wp_create_nonce( 'bdas_ajax_nonce' ), + 'ajax_url' => admin_url( 'admin-ajax.php' ), + ); return $data; } private static function search_listing_localized_data() { - return self::get_search_script_data([ - 'directory_type_id' => get_post_meta( '_directory_type', get_the_ID(), true ), - ]); + return self::get_search_script_data( + array( + 'directory_type_id' => get_post_meta( '_directory_type', get_the_ID(), true ), + ) + ); } private static function search_form_localized_data() { $directory_type_id = ( isset( $args['directory_type_id'] ) ) ? $args['directory_type_id'] : ''; - $data = self::get_search_script_data([ - 'directory_type_id' => $directory_type_id, - 'search_max_radius_distance' => apply_filters( 'directorist_search_max_radius_distance', get_directorist_option( 'search_max_radius_distance', 1000 ) ) - ]); + $data = self::get_search_script_data( + array( + 'directory_type_id' => $directory_type_id, + 'search_max_radius_distance' => apply_filters( 'directorist_search_max_radius_distance', get_directorist_option( 'search_max_radius_distance', 1000 ) ), + ) + ); return $data; } @@ -59,64 +65,64 @@ private static function directorist_options_data() { } private static function admin_ajax_localized_data() { - return [ 'ajax_url' => admin_url('admin-ajax.php') ]; + return array( 'ajax_url' => admin_url( 'admin-ajax.php' ) ); } public static function get_listings_data() { // listings data - $review_approval = get_directorist_option( 'review_approval_text', __( 'Your review has been received. It requires admin approval to publish.', 'directorist' ) ); + $review_approval = get_directorist_option( 'review_approval_text', __( 'Your review has been received. It requires admin approval to publish.', 'directorist' ) ); $enable_reviewer_content = get_directorist_option( 'enable_reviewer_content', 1 ); $data = array( - 'nonce' => wp_create_nonce( 'atbdp_nonce_action_js' ), - 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ), - 'ajax_nonce' => wp_create_nonce( 'bdas_ajax_nonce' ), - 'is_admin' => is_admin(), - 'ajaxurl' => admin_url( 'admin-ajax.php' ), - 'assets_url' => DIRECTORIST_ASSETS, - 'home_url' => home_url(), - 'rest_url' => rest_url(), - 'nonceName' => 'atbdp_nonce_js', - 'login_alert_message' => __( 'Sorry, you need to login first.', 'directorist' ), - 'rtl' => is_rtl() ? 'true' : 'false', - 'warning' => __( 'WARNING!', 'directorist' ), - 'success' => __( 'SUCCESS!', 'directorist' ), - 'not_add_more_than_one' => __( 'You can not add more than one review. Refresh the page to edit or delete your review!,', 'directorist' ), - 'duplicate_review_error' => __( 'Sorry! your review already in process.', 'directorist' ), - 'review_success' => __( 'Reviews Saved Successfully!', 'directorist' ), - 'review_approval_text' => $review_approval, - 'review_error' => __( 'Something went wrong. Check the form and try again!!!', 'directorist' ), - 'review_loaded' => __( 'Reviews Loaded!', 'directorist' ), - 'review_not_available' => __( 'NO MORE REVIEWS AVAILABLE!,', 'directorist' ), - 'review_have_not_for_delete' => __( 'You do not have any review to delete. Refresh the page to submit new review!!!,', 'directorist' ), - 'review_sure_msg' => __( 'Are you sure?', 'directorist' ), - 'review_want_to_remove' => __( 'Do you really want to remove this review!', 'directorist' ), - 'review_delete_msg' => __( 'Yes, Delete it!', 'directorist' ), - 'review_cancel_btn_text' => __( 'Cancel', 'directorist' ), - 'review_wrong_msg' => __( 'Something went wrong!, Try again', 'directorist' ), - 'listing_remove_title' => __( 'Are you sure?', 'directorist' ), - 'listing_remove_text' => __( 'Do you really want to delete this item?!', 'directorist' ), - 'listing_remove_confirm_text' => __( 'Yes, Delete it!', 'directorist' ), - 'listing_delete' => __( 'Deleted!!', 'directorist' ), - 'listing_error_title' => __( 'ERROR!!', 'directorist' ), - 'listing_error_text' => __( 'Something went wrong!!!, Try again', 'directorist' ), - 'upload_pro_pic_title' => __( 'Select or Upload a profile picture', 'directorist' ), - 'upload_pro_pic_text' => __( 'Use this Image', 'directorist' ), - 'payNow' => __( 'Pay Now', 'directorist' ), - 'completeSubmission' => __( 'Complete Submission', 'directorist' ), - 'waiting_msg' => __( 'Sending the message, please wait...', 'directorist' ), - 'plugin_url' => ATBDP_URL, - 'currentDate' => get_the_date(), - 'enable_reviewer_content' => $enable_reviewer_content, - 'add_listing_data' => self::get_add_listings_data(), - 'lazy_load_taxonomy_fields' => get_directorist_option( 'lazy_load_taxonomy_fields', false, true ), - 'current_page_id' => get_the_ID(), - 'icon_markup' => '<i class="directorist-icon-mask ##CLASS##" aria-hidden="true" style="--directorist-icon: url(##URL##)"></i>', - 'search_form_default_label' => __( 'Label', 'directorist' ), - 'search_form_default_placeholder' => __( 'Placeholder', 'directorist' ), - 'add_listing_url' => \ATBDP_Permalink::get_add_listing_page_link(), - 'enabled_multi_directory' => directorist_is_multi_directory_enabled(), - 'site_name' => get_bloginfo( 'name' ), + 'nonce' => wp_create_nonce( 'atbdp_nonce_action_js' ), + 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ), + 'ajax_nonce' => wp_create_nonce( 'bdas_ajax_nonce' ), + 'is_admin' => is_admin(), + 'ajaxurl' => admin_url( 'admin-ajax.php' ), + 'assets_url' => DIRECTORIST_ASSETS, + 'home_url' => home_url(), + 'rest_url' => rest_url(), + 'nonceName' => 'atbdp_nonce_js', + 'login_alert_message' => __( 'Sorry, you need to login first.', 'directorist' ), + 'rtl' => is_rtl() ? 'true' : 'false', + 'warning' => __( 'WARNING!', 'directorist' ), + 'success' => __( 'SUCCESS!', 'directorist' ), + 'not_add_more_than_one' => __( 'You can not add more than one review. Refresh the page to edit or delete your review!,', 'directorist' ), + 'duplicate_review_error' => __( 'Sorry! your review already in process.', 'directorist' ), + 'review_success' => __( 'Reviews Saved Successfully!', 'directorist' ), + 'review_approval_text' => $review_approval, + 'review_error' => __( 'Something went wrong. Check the form and try again!!!', 'directorist' ), + 'review_loaded' => __( 'Reviews Loaded!', 'directorist' ), + 'review_not_available' => __( 'NO MORE REVIEWS AVAILABLE!,', 'directorist' ), + 'review_have_not_for_delete' => __( 'You do not have any review to delete. Refresh the page to submit new review!!!,', 'directorist' ), + 'review_sure_msg' => __( 'Are you sure?', 'directorist' ), + 'review_want_to_remove' => __( 'Do you really want to remove this review!', 'directorist' ), + 'review_delete_msg' => __( 'Yes, Delete it!', 'directorist' ), + 'review_cancel_btn_text' => __( 'Cancel', 'directorist' ), + 'review_wrong_msg' => __( 'Something went wrong!, Try again', 'directorist' ), + 'listing_remove_title' => __( 'Are you sure?', 'directorist' ), + 'listing_remove_text' => __( 'Do you really want to delete this item?!', 'directorist' ), + 'listing_remove_confirm_text' => __( 'Yes, Delete it!', 'directorist' ), + 'listing_delete' => __( 'Deleted!!', 'directorist' ), + 'listing_error_title' => __( 'ERROR!!', 'directorist' ), + 'listing_error_text' => __( 'Something went wrong!!!, Try again', 'directorist' ), + 'upload_pro_pic_title' => __( 'Select or Upload a profile picture', 'directorist' ), + 'upload_pro_pic_text' => __( 'Use this Image', 'directorist' ), + 'payNow' => __( 'Pay Now', 'directorist' ), + 'completeSubmission' => __( 'Complete Submission', 'directorist' ), + 'waiting_msg' => __( 'Sending the message, please wait...', 'directorist' ), + 'plugin_url' => ATBDP_URL, + 'currentDate' => get_the_date(), + 'enable_reviewer_content' => $enable_reviewer_content, + 'add_listing_data' => self::get_add_listings_data(), + 'lazy_load_taxonomy_fields' => get_directorist_option( 'lazy_load_taxonomy_fields', false, true ), + 'current_page_id' => get_the_ID(), + 'icon_markup' => '<i class="directorist-icon-mask ##CLASS##" aria-hidden="true" style="--directorist-icon: url(##URL##)"></i>', + 'search_form_default_label' => __( 'Label', 'directorist' ), + 'search_form_default_placeholder' => __( 'Placeholder', 'directorist' ), + 'add_listing_url' => \ATBDP_Permalink::get_add_listing_page_link(), + 'enabled_multi_directory' => directorist_is_multi_directory_enabled(), + 'site_name' => get_bloginfo( 'name' ), ); return $data; @@ -128,60 +134,62 @@ public static function get_add_listings_data() { $current_url = ( ! empty( $_SERVER['REQUEST_URI'] ) ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; $current_listing_type = isset( $_GET['directory_type'] ) ? sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ) : directorist_get_listing_directory( $listing_id ); - if( ! empty( $current_listing_type ) && ! is_numeric( $current_listing_type ) ) { - $term = get_term_by( 'slug', $current_listing_type, ATBDP_TYPE ); + if ( ! empty( $current_listing_type ) && ! is_numeric( $current_listing_type ) ) { + $term = get_term_by( 'slug', $current_listing_type, ATBDP_TYPE ); $current_listing_type = ! empty( $term ) ? $term->term_id : ''; } - if ( ( strpos( $current_url, '/edit/' ) !== false ) && ( $pagenow = 'at_biz_dir' ) ) { - $arr = explode('/edit/', $current_url); - $important = $arr[1]; + if ( ( strpos( $current_url, '/edit/' ) !== false ) && ( $pagenow = 'at_biz_dir' ) ) { + $arr = explode( '/edit/', $current_url ); + $important = $arr[1]; $listing_id = (int) $important; } $submission_form = get_term_meta( $current_listing_type, 'submission_form_fields', true ); - $new_tag = !empty( $submission_form['fields']['tag']['allow_new'] ) ? $submission_form['fields']['tag']['allow_new'] : ''; - $new_loc = !empty( $submission_form['fields']['location']['create_new_loc'] ) ? $submission_form['fields']['location']['create_new_loc'] : ''; - $new_cat = !empty( $submission_form['fields']['category']['create_new_cat'] ) ? $submission_form['fields']['category']['create_new_cat'] : ''; - $max_loc_creation = !empty( $submission_form['fields']['location']['max_location_creation'] ) ? $submission_form['fields']['location']['max_location_creation'] : ''; + $new_tag = ! empty( $submission_form['fields']['tag']['allow_new'] ) ? $submission_form['fields']['tag']['allow_new'] : ''; + $new_loc = ! empty( $submission_form['fields']['location']['create_new_loc'] ) ? $submission_form['fields']['location']['create_new_loc'] : ''; + $new_cat = ! empty( $submission_form['fields']['category']['create_new_cat'] ) ? $submission_form['fields']['category']['create_new_cat'] : ''; + $max_loc_creation = ! empty( $submission_form['fields']['location']['max_location_creation'] ) ? $submission_form['fields']['location']['max_location_creation'] : ''; // Internationalization text for javascript file especially add-listing.js $i18n_text = array( - 'see_more_text' => __( 'See More', 'directorist' ), - 'see_less_text' => __( 'See Less', 'directorist' ), + 'see_more_text' => __( 'See More', 'directorist' ), + 'see_less_text' => __( 'See Less', 'directorist' ), 'confirmation_text' => __( 'Are you sure', 'directorist' ), 'ask_conf_sl_lnk_del_txt' => __( 'Do you really want to remove this Social Link!', 'directorist' ), 'ask_conf_faqs_del_txt' => __( 'Do you really want to remove this FAQ!', 'directorist' ), 'confirm_delete' => __( 'Yes, Delete it!', 'directorist' ), 'deleted' => __( 'Deleted!', 'directorist' ), 'max_location_creation' => esc_attr( $max_loc_creation ), - 'max_location_msg' => sprintf( __('You can only use %s', 'directorist'), $max_loc_creation ), + 'max_location_msg' => sprintf( __( 'You can only use %s', 'directorist' ), $max_loc_creation ), 'submission_wait_msg' => esc_html__( 'Please wait, your submission is being processed.', 'directorist' ), - 'image_uploading_msg' => esc_html__( 'Please wait, your selected images being uploaded.', 'directorist' ) + 'image_uploading_msg' => esc_html__( 'Please wait, your selected images being uploaded.', 'directorist' ), ); - //get listing is if the screen in edit listing + // get listing is if the screen in edit listing $data = array( - 'nonce' => wp_create_nonce( 'atbdp_nonce_action_js' ), - 'ajaxurl' => admin_url( 'admin-ajax.php' ), - 'nonceName' => 'atbdp_nonce_js', - 'is_admin' => is_admin(), - 'media_uploader' => apply_filters( 'atbdp_media_uploader', [ - [ - 'element_id' => 'directorist-image-upload', - 'meta_name' => 'listing_img', - 'files_meta_name' => 'files_meta', - 'error_msg' => __('Listing gallery has invalid files', 'directorist'), - ] - ]), - 'i18n_text' => $i18n_text, - 'create_new_tag' => $new_tag, - 'create_new_loc' => $new_loc, - 'create_new_cat' => $new_cat, - 'image_notice' => __( 'Sorry! You have crossed the maximum image limit', 'directorist' ), + 'nonce' => wp_create_nonce( 'atbdp_nonce_action_js' ), + 'ajaxurl' => admin_url( 'admin-ajax.php' ), + 'nonceName' => 'atbdp_nonce_js', + 'is_admin' => is_admin(), + 'media_uploader' => apply_filters( + 'atbdp_media_uploader', + array( + array( + 'element_id' => 'directorist-image-upload', + 'meta_name' => 'listing_img', + 'files_meta_name' => 'files_meta', + 'error_msg' => __( 'Listing gallery has invalid files', 'directorist' ), + ), + ) + ), + 'i18n_text' => $i18n_text, + 'create_new_tag' => $new_tag, + 'create_new_loc' => $new_loc, + 'create_new_cat' => $new_cat, + 'image_notice' => __( 'Sorry! You have crossed the maximum image limit', 'directorist' ), ); - return $data; } @@ -200,18 +208,18 @@ public static function get_admin_script_data() { 'add_listing_url' => \ATBDP_Permalink::get_add_listing_page_link(), ); - $icon_picker_labels = [ - 'changeIconButtonLabel' => __( 'Change Icon', 'directorist' ), - 'changeIconButtonPlaceholder' => __( 'Click to select icon', 'directorist' ), - 'filterByNameInputLabel' => __( 'Filter By Name', 'directorist' ), - 'filterByNameInputPlaceholder' => __( 'Search', 'directorist' ), - 'filterByGroupInputLabel' => __( 'Filter By Icon Pack', 'directorist' ), - 'doneButtonLabel' => __( 'Done', 'directorist' ), - 'iconGroupLabels' => [ + $icon_picker_labels = array( + 'changeIconButtonLabel' => __( 'Change Icon', 'directorist' ), + 'changeIconButtonPlaceholder' => __( 'Click to select icon', 'directorist' ), + 'filterByNameInputLabel' => __( 'Filter By Name', 'directorist' ), + 'filterByNameInputPlaceholder' => __( 'Search', 'directorist' ), + 'filterByGroupInputLabel' => __( 'Filter By Icon Pack', 'directorist' ), + 'doneButtonLabel' => __( 'Done', 'directorist' ), + 'iconGroupLabels' => array( 'fontAwesome' => __( 'Font Awesome', 'directorist' ), - 'lineAwesome' => __( 'Line Awesome', 'directorist' ), - ], - ]; + 'lineAwesome' => __( 'Line Awesome', 'directorist' ), + ), + ); // is MI extension enabled and active? $data = array( @@ -227,17 +235,15 @@ public static function get_admin_script_data() { 'icon_picker_labels' => $icon_picker_labels, ); - - return $data; } - public static function get_search_script_data( $args = [] ) { - $directory_type = ( is_array( $args ) && isset( $args['directory_type_id'] ) ) ? $args['directory_type_id'] : default_directory_type(); - $directory_type_term_data = [ + public static function get_search_script_data( $args = array() ) { + $directory_type = ( is_array( $args ) && isset( $args['directory_type_id'] ) ) ? $args['directory_type_id'] : default_directory_type(); + $directory_type_term_data = array( 'submission_form_fields' => get_term_meta( $directory_type, 'submission_form_fields', true ), - 'search_form_fields' => get_term_meta( $directory_type, 'search_form_fields', true ), - ]; + 'search_form_fields' => get_term_meta( $directory_type, 'search_form_fields', true ), + ); /*Internationalization*/ $category_placeholder = ( isset( $directory_type_term_data['submission_form_fields']['fields']['category']['placeholder'] ) ) ? $directory_type_term_data['submission_form_fields']['fields']['category']['placeholder'] : __( 'Select a category', 'directorist' ); @@ -253,7 +259,7 @@ public static function get_search_script_data( $args = [] ) { } $data = array( - 'i18n_text' => array( + 'i18n_text' => array( 'category_selection' => ! empty( $category_placeholder ) ? $category_placeholder : __( 'Select a category', 'directorist' ), 'location_selection' => ! empty( $location_placeholder ) ? $location_placeholder : __( 'Select a location', 'directorist' ), 'show_more' => __( 'Show More', 'directorist' ), @@ -261,14 +267,14 @@ public static function get_search_script_data( $args = [] ) { 'added_favourite' => __( 'Added to favorite', 'directorist' ), 'please_login' => __( 'Please login first', 'directorist' ), 'select_listing_map' => $select_listing_map, - 'Miles' => !empty( $_GET['miles'] ) ? absint( $_GET['miles'] ) : $miles, + 'Miles' => ! empty( $_GET['miles'] ) ? absint( $_GET['miles'] ) : $miles, ), 'args' => $args, 'directory_type' => $directory_type, 'default_directory_type' => directorist_get_default_directory( 'slug' ), 'directory_type_term_data' => $directory_type_term_data, 'ajax_url' => admin_url( 'admin-ajax.php' ), - 'miles' => !empty( $_GET['miles'] ) ? absint( $_GET['miles'] ) : $miles, + 'miles' => ! empty( $_GET['miles'] ) ? absint( $_GET['miles'] ) : $miles, 'default_val' => $default_radius_distance, 'countryRestriction' => get_directorist_option( 'country_restriction' ), 'restricted_countries' => get_directorist_option( 'restricted_countries' ), @@ -278,7 +284,7 @@ public static function get_search_script_data( $args = [] ) { } public static function get_option_data() { - $options = []; + $options = array(); $options['script_debugging'] = get_directorist_option( 'script_debugging', DIRECTORIST_LOAD_MIN_FILES, true ); @@ -286,24 +292,23 @@ public static function get_option_data() { } public static function login_data() { - $redirection = \ATBDP_Permalink::get_login_redirection_page_link(); + $redirection = \ATBDP_Permalink::get_login_redirection_page_link(); $redirection_url = $redirection ? $redirection : \ATBDP_Permalink::get_dashboard_page_link(); - $current_time = time(); + $current_time = time(); $redirection_url = strpos( $redirection_url, '?' ) !== false ? $redirection . '&rand=' . $current_time : $redirection . '?rand=' . $current_time; - - if( strpos( $redirection_url, '?' ) !== false ) { + + if ( strpos( $redirection_url, '?' ) !== false ) { $redirection_url = $redirection_url . '&rand=' . $current_time; } else { $redirection_url = $redirection_url . '?rand=' . $current_time; } - - $data = [ + + $data = array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'redirect_url' => $redirection_url, 'loading_message' => esc_html__( 'Sending user info, please wait...', 'directorist' ), 'login_error_message' => esc_html__( 'Wrong username or password.', 'directorist' ), - ]; + ); return $data; } - } diff --git a/includes/asset-loader/scripts.php b/includes/asset-loader/scripts.php index daeacaf0e9..e67041ff03 100644 --- a/includes/asset-loader/scripts.php +++ b/includes/asset-loader/scripts.php @@ -5,7 +5,9 @@ namespace Directorist\Asset_Loader; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Scripts { @@ -13,137 +15,137 @@ class Scripts { * Scripts array. * * Each item may contain following arguments: - * $scripts['handle'] => [ - * 'type' => String, // Accepts css, js - * 'path' => String, // Absolute url, without the min/rtl/js extension - * 'ext' => String, // External url, in case the path is absent - * 'dep' => Array [], // Dependency list eg. [jquery] - * 'rtl' => Boolean false, // RTL exists or not - * ]; + * $scripts['handle'] => [ + * 'type' => String, // Accepts css, js + * 'path' => String, // Absolute url, without the min/rtl/js extension + * 'ext' => String, // External url, in case the path is absent + * 'dep' => Array [], // Dependency list eg. [jquery] + * 'rtl' => Boolean false, // RTL exists or not + * ]; */ public static function get_all_scripts() { - $scripts = [ + $scripts = array( // Vendor CSS - 'directorist-openstreet-map-leaflet' => [ + 'directorist-openstreet-map-leaflet' => array( 'type' => 'css', 'path' => DIRECTORIST_VENDOR_CSS . 'openstreet-map/leaflet', - ], - 'directorist-openstreet-map-openstreet' => [ + ), + 'directorist-openstreet-map-openstreet' => array( 'type' => 'css', 'path' => DIRECTORIST_VENDOR_CSS . 'openstreet-map/openstreet', - ], - 'directorist-select2-style' => [ + ), + 'directorist-select2-style' => array( 'type' => 'css', 'path' => DIRECTORIST_VENDOR_CSS . 'select2', - ], - 'directorist-unicons' => [ + ), + 'directorist-unicons' => array( 'type' => 'css', 'path' => DIRECTORIST_ICON_URL . 'unicons/css/line', - ], - 'directorist-font-awesome' => [ + ), + 'directorist-font-awesome' => array( 'type' => 'css', 'path' => DIRECTORIST_ICON_URL . 'font-awesome/css/all', - ], - 'directorist-line-awesome' => [ + ), + 'directorist-line-awesome' => array( 'type' => 'css', 'path' => DIRECTORIST_ICON_URL . 'line-awesome/css/line-awesome', - ], - 'directorist-ez-media-uploader-style' => [ + ), + 'directorist-ez-media-uploader-style' => array( 'type' => 'css', 'path' => DIRECTORIST_VENDOR_CSS . 'ez-media-uploader', - 'rtl' => true, - ], - 'directorist-swiper-style' => [ + 'rtl' => true, + ), + 'directorist-swiper-style' => array( 'type' => 'css', 'path' => DIRECTORIST_VENDOR_CSS . 'swiper', - ], - 'directorist-sweetalert-style' => [ + ), + 'directorist-sweetalert-style' => array( 'type' => 'css', 'path' => DIRECTORIST_VENDOR_CSS . 'sweetalert', - ], + ), // Public CSS - 'directorist-main-style' => [ + 'directorist-main-style' => array( 'type' => 'css', 'path' => DIRECTORIST_CSS . 'public-main', - 'rtl' => true, - ], + 'rtl' => true, + ), // Support v7 CSS - 'directorist-support-v7-style' => [ + 'directorist-support-v7-style' => array( 'type' => 'css', 'path' => DIRECTORIST_CSS . 'support-v7-style', - 'rtl' => true, - ], + 'rtl' => true, + ), // Admin CSS - 'directorist-admin-style' => [ + 'directorist-admin-style' => array( 'type' => 'css', 'path' => DIRECTORIST_CSS . 'admin-main', 'rtl' => true, - 'dep' => [ + 'dep' => array( 'directorist-font-awesome', 'directorist-line-awesome', - ], - ], + ), + ), // Vendor JS - 'directorist-no-script' => [ + 'directorist-no-script' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'no-script', - ], - 'directorist-swiper' => [ + ), + 'directorist-swiper' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'swiper', - ], - 'directorist-openstreet-layers' => [ + ), + 'directorist-openstreet-layers' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/openstreetlayers', - ], - 'directorist-openstreet-unpkg' => [ + ), + 'directorist-openstreet-unpkg' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/unpkg-min', - ], - 'directorist-openstreet-unpkg-index' => [ + ), + 'directorist-openstreet-unpkg-index' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/unpkg-index', - ], - 'directorist-openstreet-unpkg-libs' => [ + ), + 'directorist-openstreet-unpkg-libs' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/unpkg-libs', - ], - 'directorist-openstreet-leaflet-versions' => [ + ), + 'directorist-openstreet-leaflet-versions' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/leaflet-versions', - ], - 'directorist-openstreet-libs-setup' => [ + ), + 'directorist-openstreet-libs-setup' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/libs-setup', - ], - 'directorist-openstreet-open-layers' => [ + ), + 'directorist-openstreet-open-layers' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/openlayers/openlayers', - ], - 'directorist-openstreet-crosshairs' => [ + ), + 'directorist-openstreet-crosshairs' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/openlayers4jgsi/crosshairs', - ], - 'directorist-openstreet-leaflet-markercluster-versions' => [ + ), + 'directorist-openstreet-leaflet-markercluster-versions' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'openstreet-map/leaflet.markercluster-versions', - ], - 'google-map-api' => [ + ), + 'google-map-api' => array( 'type' => 'js', 'ext' => self::gmap_url(), - ], - 'directorist-markerclusterer' => [ + ), + 'directorist-markerclusterer' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'markerclusterer', - ], - 'directorist-openstreet-map' => [ + ), + 'directorist-openstreet-map' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'openstreet-map', - 'dep' => [ + 'dep' => array( 'jquery', 'directorist-openstreet-layers', 'directorist-openstreet-unpkg', @@ -154,201 +156,201 @@ public static function get_all_scripts() { 'directorist-openstreet-libs-setup', 'directorist-openstreet-open-layers', 'directorist-openstreet-crosshairs', - ], - ], - 'directorist-google-map' => [ + ), + ), + 'directorist-google-map' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'google-map', - 'dep' => [ + 'dep' => array( 'jquery', 'google-map-api', 'directorist-markerclusterer', - ], - ], - 'directorist-select2-script' => [ + ), + ), + 'directorist-select2-script' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'select2', - ], - 'directorist-sweetalert' => [ + ), + 'directorist-sweetalert' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'sweetalert', - ], - 'directorist-popper' => [ + ), + 'directorist-popper' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'popper', - ], - 'directorist-tooltip' => [ + ), + 'directorist-tooltip' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'tooltip', - ], - 'directorist-ez-media-uploader' => [ + ), + 'directorist-ez-media-uploader' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'ez-media-uploader', - ], - 'directorist-jquery-barrating' => [ + ), + 'directorist-jquery-barrating' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'jquery.barrating', - ], - 'directorist-uikit' => [ + ), + 'directorist-uikit' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'uikit', - ], - 'directorist-validator' => [ + ), + 'directorist-validator' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'validator', - ], - 'directorist-font-awesome-icons' => [ + ), + 'directorist-font-awesome-icons' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'icon-picker/font-awesome', - ], - 'directorist-line-awesome-icons' => [ + ), + 'directorist-line-awesome-icons' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'icon-picker/line-awesome', - ], - 'directorist-icon-picker' => [ + ), + 'directorist-icon-picker' => array( 'type' => 'js', 'path' => DIRECTORIST_VENDOR_JS . 'icon-picker/icon-picker', - 'dep' => [ + 'dep' => array( 'directorist-font-awesome-icons', 'directorist-line-awesome-icons', - ], - ], + ), + ), // Global JS - 'directorist-global-script' => [ + 'directorist-global-script' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'global-main', - ], + ), // Public JS - 'directorist-widgets' => [ + 'directorist-widgets' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'widgets', - ], - 'directorist-all-listings' => [ + ), + 'directorist-all-listings' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'all-listings', - ], - 'directorist-search-form' => [ + ), + 'directorist-search-form' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'search-form', - ], - 'directorist-listing-slider' => [ + ), + 'directorist-listing-slider' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'listing-slider', - ], - 'directorist-dashboard' => [ + ), + 'directorist-dashboard' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'directorist-dashboard', - ], - 'directorist-all-authors' => [ + ), + 'directorist-all-authors' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'all-authors', - ], - 'directorist-author-profile' => [ + ), + 'directorist-author-profile' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'author-profile', - ], - 'directorist-all-location-category' => [ + ), + 'directorist-all-location-category' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'all-location-category', - ], - 'directorist-account' => [ + ), + 'directorist-account' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'account', - ], - 'directorist-range-slider' => [ + ), + 'directorist-range-slider' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'range-slider', - ], - 'directorist-releated-listings-slider' => [ + ), + 'directorist-releated-listings-slider' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-releated-listings-slider', - ], - 'directorist-atmodal' => [ + ), + 'directorist-atmodal' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-atmodal', - ], - 'directorist-geolocation' => [ + ), + 'directorist-geolocation' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'global-geolocation', - ], - 'directorist-geolocation-widget' => [ + ), + 'directorist-geolocation-widget' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-geolocation-widget', - ], - 'directorist-search-listing' => [ + ), + 'directorist-search-listing' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-search-listing', - ], - 'directorist-search-form-listing' => [ + ), + 'directorist-search-form-listing' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-search-form-listing', - ], - 'directorist-checkout' => [ + ), + 'directorist-checkout' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'checkout', - ], - 'directorist-single-listing-openstreet-map-custom-script' => [ + ), + 'directorist-single-listing-openstreet-map-custom-script' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-single-listing-openstreet-map-custom-script', - ], - 'directorist-single-listing-openstreet-map-widget-custom-script' => [ + ), + 'directorist-single-listing-openstreet-map-widget-custom-script' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-single-listing-openstreet-map-widget-custom-script', - ], - 'directorist-single-listing-gmap-custom-script' => [ + ), + 'directorist-single-listing-gmap-custom-script' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-single-listing-gmap-custom-script', - ], - 'directorist-single-listing-gmap-widget-custom-script' => [ + ), + 'directorist-single-listing-gmap-widget-custom-script' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'public-single-listing-gmap-custom-script', - ], - 'directorist-add-listing' => [ + ), + 'directorist-add-listing' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'add-listing', - ], - 'directorist-single-listing' => [ + ), + 'directorist-single-listing' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'single-listing', - ], - 'directorist-plupload' => [ + ), + 'directorist-plupload' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'directorist-plupload', - 'dep' => ['jquery', 'plupload-handlers'], - ], + 'dep' => array( 'jquery', 'plupload-handlers' ), + ), // Admin JS - 'directorist-admin-script' => [ + 'directorist-admin-script' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'admin-main', - ], - 'directorist-admin-builder-archive' => [ + ), + 'directorist-admin-builder-archive' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'admin-builder-archive', - ], - 'directorist-multi-directory-builder' => [ + ), + 'directorist-multi-directory-builder' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'admin-multi-directory-builder', - 'dep' => [ 'lodash' ] - ], - 'directorist-settings-manager' => [ + 'dep' => array( 'lodash' ), + ), + 'directorist-settings-manager' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'admin-settings-manager', - 'dep' => [ 'lodash' ] - ], - 'directorist-plugins' => [ + 'dep' => array( 'lodash' ), + ), + 'directorist-plugins' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'admin-plugins', - ], - 'directorist-import-export' => [ + ), + 'directorist-import-export' => array( 'type' => 'js', 'path' => DIRECTORIST_JS . 'admin-import-export', - ], - ]; + ), + ); - return apply_filters( 'directorist_scripts', $scripts ); + return apply_filters( 'directorist_scripts', $scripts ); } private static function gmap_url() { @@ -356,4 +358,4 @@ private static function gmap_url() { $url = '//maps.googleapis.com/maps/api/js?key=' . $api . '&libraries=places&callback=Function.prototype'; return $url; } -} \ No newline at end of file +} diff --git a/includes/checkout/class-checkout.php b/includes/checkout/class-checkout.php index 9a0843bd00..01df9a08a3 100644 --- a/includes/checkout/class-checkout.php +++ b/includes/checkout/class-checkout.php @@ -9,7 +9,9 @@ * @since 3.1.0 */ // Exit if accessed directly -if (!defined('ABSPATH')) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** * ATBDP_Checkout Class @@ -17,348 +19,356 @@ * @since 3.1.0 * @access public */ -class ATBDP_Checkout -{ - /** - * @var string - */ - public $nonce = 'checkout_nonce'; - /** - * @var string - */ - public $nonce_action = 'checkout_action'; - - public function __construct() - { - add_action('init', array($this, 'buffer_to_fix_redirection')); - } - - /** - * - */ - public static function ajax_atbdp_format_total_amount() - { - if (valid_js_nonce()) { +class ATBDP_Checkout { + + /** + * @var string + */ + public $nonce = 'checkout_nonce'; + /** + * @var string + */ + public $nonce_action = 'checkout_action'; + + public function __construct() { + add_action( 'init', array( $this, 'buffer_to_fix_redirection' ) ); + } + + /** + * + */ + public static function ajax_atbdp_format_total_amount() { + if ( valid_js_nonce() ) { if (!empty($_POST['amount'])) { // @codingStandardsIgnoreLine. $price = atbdp_format_payment_amount( sanitize_text_field( wp_unslash( $_POST['amount'] ) ) ); // @codingStandardsIgnoreLine. - echo esc_html( $price ); - } - } - wp_die(); - } - - /** - * @return string - */ - public function display_checkout_content() - { - // vail out showing a friendly-message, if user is not logged in. No need to run further code - if (!atbdp_is_user_logged_in()) return null; - - ob_start(); - $enable_monetization = apply_filters('atbdp_enable_monetization_checkout', directorist_is_monetization_enabled() ); - // vail if monetization is not active. - if (!$enable_monetization) { - return __('Monetization is not active on this site. if you are an admin, you can enable it from the settings panel.', 'directorist'); - } - // user logged in & monetization is active, so lets continue - // get the listing id from the url query var - $listing_id = get_query_var('atbdp_listing_id'); + echo esc_html( $price ); + } + } + wp_die(); + } + + /** + * @return string + */ + public function display_checkout_content() { + // vail out showing a friendly-message, if user is not logged in. No need to run further code + if ( ! atbdp_is_user_logged_in() ) { + return null; + } + + ob_start(); + $enable_monetization = apply_filters( 'atbdp_enable_monetization_checkout', directorist_is_monetization_enabled() ); + // vail if monetization is not active. + if ( ! $enable_monetization ) { + return __( 'Monetization is not active on this site. if you are an admin, you can enable it from the settings panel.', 'directorist' ); + } + // user logged in & monetization is active, so lets continue + // get the listing id from the url query var + $listing_id = get_query_var( 'atbdp_listing_id' ); if ( empty( $listing_id ) && isset( $_GET['submit'] ) ) { $listing_id = sanitize_text_field( wp_unslash( $_GET['submit'] ) ); } - // vail if the id is empty or post type is not our post type. - if ( directorist_payment_guard() ) { - return __('Sorry, Something went wrong. Listing ID is missing. Please try again.', 'directorist'); - } - // if the checkout form is submitted, then process placing order + // vail if the id is empty or post type is not our post type. + if ( directorist_payment_guard() ) { + return __( 'Sorry, Something went wrong. Listing ID is missing. Please try again.', 'directorist' ); + } + // if the checkout form is submitted, then process placing order if ( isset( $_SERVER['REQUEST_METHOD'] ) && ( 'POST' == $_SERVER['REQUEST_METHOD'] ) && ATBDP()->helper->verify_nonce($this->nonce, $this->nonce_action)) { // @codingStandardsIgnoreLine. - // Process the order + // Process the order $this->create_order($listing_id, $_POST); // @codingStandardsIgnoreLine. - } else { - // Checkout form is not submitted, so show the content of the checkout items here - $form_data = apply_filters('atbdp_checkout_form_data', array(), $listing_id); // this is the hook that an extension can hook to, to add new items on checkout page.eg. plan - // let's add featured listing data - $featured_active = apply_filters('atbdp_featured_active_checkout', directorist_is_featured_listing_enabled() ); - if ($featured_active && !is_fee_manager_active()) { - $title = get_the_title( $listing_id ); - $desc = get_directorist_option('featured_listing_desc'); - $price = get_directorist_option('featured_listing_price'); - $form_data[] = array( - 'type' => 'header', - 'title' => $title, - 'name' => 'feature', - 'value' => 1, - 'selected' => 1, - 'desc' => $desc, - 'price' => $price, - ); - $form_data[] = array( - 'type' => 'checkbox', - 'name' => 'feature', - 'value' => 1, - 'selected' => 1, - 'title' => $title, - 'desc' => $desc, - 'price' => $price, - ); - } - // if data is empty then vail, - if (empty($form_data)) { - return __('Sorry, Nothing is available to buy. Please try again.', 'directorist'); - } - // pass the data using a data var, so that we can add to it more item later. - $data = array( - 'form_data' => apply_filters('atbdp_checkout_form_final_data', $form_data, $listing_id), - 'listing_id' => $listing_id, - ); - // prepare all the variables required by the checkout page. - $form_data = !empty($data['form_data']) ? $data['form_data'] : array(); - $listing_id = !empty($data['listing_id']) ? $data['listing_id'] : 0; - $c_position = get_directorist_option('payment_currency_position'); - $currency = atbdp_get_payment_currency(); - $symbol = atbdp_currency_symbol($currency); - $before = ''; - $after = ''; - $args = array( - 'form_data' => $form_data, - 'listing_id' => $listing_id, - 'c_position' => $c_position, - 'currency' => $currency, - 'symbol' => $symbol, - 'before' => $before, - 'after' => $after, - ); - - \Directorist\Helper::add_shortcode_comment( 'directorist_checkout' ); - - //displaying data for checkout - \Directorist\Helper::get_template( 'payment/checkout', array( 'checkout' => $args ) ); - } - return ob_get_clean(); - } - - /** - * @return string - */ - public function payment_receipt() - { - if (!atbdp_is_user_logged_in()) return null; // vail out showing a friendly-message, if user is not logged in. - //content of order receipt should be outputted here. - $order_id = (int)get_query_var('atbdp_order_id'); - - if ( empty( $order_id ) && ! empty( $_REQUEST['order'] ) ) { - $order_id = sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ); - } - - if (empty($order_id)) { - return __('Sorry! No order id has been provided.', 'directorist'); - } - - $meta = get_post_meta($order_id); - - if ( empty($meta['_listing_id']) ) { - return __('Sorry! order not found.', 'directorist'); - } - - $listing_id = $meta['_listing_id']; - - $data = apply_filters('atbdp_payment_receipt_data', array(), $order_id, $listing_id); - $data = !empty($data) ? $data : array(); - $order = get_post($order_id); // we need that order to use its time - $data = array_merge($data, array( - 'order' => $order, - 'order_id' => $order_id, - 'o_metas' => $meta, - )); - - // we need to provide payment receipt shortcode with the order details array as we passed in the order checkout form page. - $order_items = apply_filters('atbdp_order_items', array(), $order_id, $listing_id, $data); // this is the hook that an extension can hook to, to add new items on checkout page.eg. plan - // let's add featured listing data if the order has featured listing in it - if ( directorist_is_featured_listing_enabled() && !empty($meta['_featured'])) { - $title = get_directorist_option('featured_listing_title', __('Featured', 'directorist')); - $desc = get_directorist_option('featured_listing_desc'); - $price = get_directorist_option('featured_listing_price'); - $order_items[] = array( - 'title' => $title, - 'desc' => $desc, - 'price' => $price, - ); - } - $data['order_items'] = $order_items; - - ob_start(); - $data['c_position'] = get_directorist_option('payment_currency_position'); - $data['currency'] = atbdp_get_payment_currency(); - $data['symbol'] = atbdp_currency_symbol( atbdp_get_payment_currency() ); - $data['container_fluid'] = 'container-fluid'; - $data['order_id'] = (!empty($order_id)) ? $order_id : ''; - - \Directorist\Helper::add_shortcode_comment( 'directorist_payment_receipt' ); - \Directorist\Helper::get_template( 'payment/payment-receipt', apply_filters( 'directorist_payment_receipt_data', $data, $order_id) ); - - return ob_get_clean(); - } - - /** - * It creates an order for the given listing id - * @param int $listing_id Listing ID - * @param array $data Optional Data - */ - private function create_order($listing_id = 0, $data = array()) - { - if ( directorist_payment_guard() ) return; // vail if not listing id is provided - // create an order - $order_id = wp_insert_post(array( - 'post_content' => '', - 'post_title' => sprintf('Order for the listing ID #%d', $listing_id), - 'post_status' => 'publish', - 'post_type' => 'atbdp_orders', - 'comment_status' => false, - )); - // if order is created successfully then process the order - apply_filters('atbdp_before_order_recipt', array(), $listing_id); - if ($order_id) { - /*@todo; Find a better way to search for a order with a given ID*/ - /*wp_update_post(array( - 'ID'=> (int) $order_id, - 'post_type' => 'atbdp_orders', - 'post_title' => sprintf('Order #%d for the listing ID #%d', $order_id, $listing_id) - ));*/ - $order_details = apply_filters('atbdp_order_details', array(), $order_id, $listing_id); - //If featured item is bought, attach it to the order. - if (!empty($data['feature'])) { - update_post_meta($order_id, '_featured', 1); - //lets add the settings of featured listing to the order details - $order_details[] = atbdp_get_featured_settings_array(); - } - // now lets calculate the total price of all order item's price - $amount = 0.00; - foreach ($order_details as $detail) { - if (isset($detail['price'])) { - $amount = $detail['price']; - } - } - - /** - * Filter the order amount before tax calculation - * - * @since v7.4.3 - */ - $amount = apply_filters( 'directorist_order_amount_before_tax_calculation', $amount, $order_id, $data ); - - /*Lowercase alphanumeric characters, dashes and underscores are allowed.*/ - $gateway = !empty($amount) && !empty($data['payment_gateway']) ? sanitize_key($data['payment_gateway']) : 'free'; - // save required data as order post meta - - $amount = apply_filters( 'atbdp_order_amount', $amount, $order_id ); - update_post_meta($order_id, '_listing_id', $listing_id); - update_post_meta($order_id, '_amount', $amount); - update_post_meta($order_id, '_payment_gateway', $gateway); - update_post_meta($order_id, '_payment_status', 'created'); - // Hook for developer - do_action('atbdp_order_created', $order_id, $listing_id); /*@todo; do something to prevent multiple order creation when user try to repeat failed payment*/ - $this->process_payment($amount, $gateway, $order_id, $listing_id, $data); - } - } - - /** - * It process the payment of the order - * - * @param float $amount The order amount - * @param string $gateway The name of the gateway - * @param int $order_id The order ID - * @param int $listing_id The Listing ID for which the order has been created. - * @param array $data The $_POST data basically - */ - private function process_payment($amount, $gateway, $order_id, $listing_id, $data = array()) - { - /*Process paid listing*/ - if ($amount > 0) { - if ('bank_transfer' == $gateway) { - update_post_meta($order_id, '_transaction_id', wp_generate_password(15, false)); - //hook for developer - do_action('atbdp_offline_payment_created', $order_id, $listing_id); - // admin will mark the order completed manually once he get the payment on his bank. - // let's redirect the user to the payment receipt page. - $redirect_url = apply_filters('atbdp_payment_receipt_page_link', ATBDP_Permalink::get_payment_receipt_page_link($order_id), $order_id); - wp_safe_redirect($redirect_url); - exit(); - } else { - /** - * fires 'atbdp_process_gateway_name_payment', it helps extensions and other payment plugin to process the payment - * atbdp_orders post has all the required information in its meta data like listing id and featured data etc. - * - * @param string $gateway The name of the gateway - * @param int $order_id The Order ID - * @param int $listing_id The Listing ID - * @param array $data The $_POST data basically - */ - do_action('atbdp_process_' . $gateway . '_payment', $order_id, $listing_id, $data); - do_action('atbdp_online_order_processed', $order_id, $listing_id); - } - } else { - /*@todo; Notify owner based on admin settings that order CREATED*/ - /*complete Free listing Order */ - $this->complete_free_order( - array( - 'ID' => $order_id, - 'transaction_id' => wp_generate_password(15, false), - 'listing_id' => $listing_id - ) - ); - $redirect_url = apply_filters('atbdp_payment_receipt_page_link', ATBDP_Permalink::get_payment_receipt_page_link($order_id), $order_id); - wp_safe_redirect($redirect_url); - exit; - } - } - - /** - * /** - * It completes order that are free of charge - * @param array $order_data The array of order data - */ - private function complete_free_order($order_data) - { - // add payment status, tnx_id etc. - update_post_meta($order_data['ID'], '_payment_status', 'completed'); - update_post_meta($order_data['ID'], '_transaction_id', $order_data['transaction_id']); - // If the order has featured, make the related listing featured. - $featured = get_post_meta($order_data['ID'], '_featured', true); - if (!empty($featured)) { - update_post_meta($order_data['listing_id'], '_featured', 1); - } - // Order has been completed. Let's fire a hook for a developer to extend if they wish - do_action('atbdp_order_completed', $order_data['ID'], $order_data['listing_id']); - } - - /** - * It starts output buffering if the checkout form has been submitted in order to fix redirection problem. - */ - public function buffer_to_fix_redirection() - { - // if the checkout form is submitted, then init buffering to solve redirection problem because of header already sent - if ( isset( $_SERVER['REQUEST_METHOD'] ) && ( 'POST' == $_SERVER['REQUEST_METHOD'] ) && ATBDP()->helper->verify_nonce($this->nonce, $this->nonce_action)) { - ob_start(); - } - } - - /** - * It output content for payment failure page - * @return string - * @since 3.1.2 - * @todo; improve this content or page later. - */ - public function transaction_failure() - { - - ob_start(); - - \Directorist\Helper::add_shortcode_comment( 'directorist_transaction_failure' ); - \Directorist\Helper::get_template( 'payment/transaction-failure' ); - - return ob_get_clean(); - } -} // ends class \ No newline at end of file + } else { + // Checkout form is not submitted, so show the content of the checkout items here + $form_data = apply_filters( 'atbdp_checkout_form_data', array(), $listing_id ); // this is the hook that an extension can hook to, to add new items on checkout page.eg. plan + // let's add featured listing data + $featured_active = apply_filters( 'atbdp_featured_active_checkout', directorist_is_featured_listing_enabled() ); + if ( $featured_active && ! is_fee_manager_active() ) { + $title = get_the_title( $listing_id ); + $desc = get_directorist_option( 'featured_listing_desc' ); + $price = get_directorist_option( 'featured_listing_price' ); + $form_data[] = array( + 'type' => 'header', + 'title' => $title, + 'name' => 'feature', + 'value' => 1, + 'selected' => 1, + 'desc' => $desc, + 'price' => $price, + ); + $form_data[] = array( + 'type' => 'checkbox', + 'name' => 'feature', + 'value' => 1, + 'selected' => 1, + 'title' => $title, + 'desc' => $desc, + 'price' => $price, + ); + } + // if data is empty then vail, + if ( empty( $form_data ) ) { + return __( 'Sorry, Nothing is available to buy. Please try again.', 'directorist' ); + } + // pass the data using a data var, so that we can add to it more item later. + $data = array( + 'form_data' => apply_filters( 'atbdp_checkout_form_final_data', $form_data, $listing_id ), + 'listing_id' => $listing_id, + ); + // prepare all the variables required by the checkout page. + $form_data = ! empty( $data['form_data'] ) ? $data['form_data'] : array(); + $listing_id = ! empty( $data['listing_id'] ) ? $data['listing_id'] : 0; + $c_position = get_directorist_option( 'payment_currency_position' ); + $currency = atbdp_get_payment_currency(); + $symbol = atbdp_currency_symbol( $currency ); + $before = ''; + $after = ''; + $args = array( + 'form_data' => $form_data, + 'listing_id' => $listing_id, + 'c_position' => $c_position, + 'currency' => $currency, + 'symbol' => $symbol, + 'before' => $before, + 'after' => $after, + ); + + \Directorist\Helper::add_shortcode_comment( 'directorist_checkout' ); + + // displaying data for checkout + \Directorist\Helper::get_template( 'payment/checkout', array( 'checkout' => $args ) ); + } + return ob_get_clean(); + } + + /** + * @return string + */ + public function payment_receipt() { + if ( ! atbdp_is_user_logged_in() ) { + return null; // vail out showing a friendly-message, if user is not logged in. + } + // content of order receipt should be outputted here. + $order_id = (int) get_query_var( 'atbdp_order_id' ); + + if ( empty( $order_id ) && ! empty( $_REQUEST['order'] ) ) { + $order_id = sanitize_text_field( wp_unslash( $_REQUEST['order'] ) ); + } + + if ( empty( $order_id ) ) { + return __( 'Sorry! No order id has been provided.', 'directorist' ); + } + + $meta = get_post_meta( $order_id ); + + if ( empty( $meta['_listing_id'] ) ) { + return __( 'Sorry! order not found.', 'directorist' ); + } + + $listing_id = $meta['_listing_id']; + + $data = apply_filters( 'atbdp_payment_receipt_data', array(), $order_id, $listing_id ); + $data = ! empty( $data ) ? $data : array(); + $order = get_post( $order_id ); // we need that order to use its time + $data = array_merge( + $data, + array( + 'order' => $order, + 'order_id' => $order_id, + 'o_metas' => $meta, + ) + ); + + // we need to provide payment receipt shortcode with the order details array as we passed in the order checkout form page. + $order_items = apply_filters( 'atbdp_order_items', array(), $order_id, $listing_id, $data ); // this is the hook that an extension can hook to, to add new items on checkout page.eg. plan + // let's add featured listing data if the order has featured listing in it + if ( directorist_is_featured_listing_enabled() && ! empty( $meta['_featured'] ) ) { + $title = get_directorist_option( 'featured_listing_title', __( 'Featured', 'directorist' ) ); + $desc = get_directorist_option( 'featured_listing_desc' ); + $price = get_directorist_option( 'featured_listing_price' ); + $order_items[] = array( + 'title' => $title, + 'desc' => $desc, + 'price' => $price, + ); + } + $data['order_items'] = $order_items; + + ob_start(); + $data['c_position'] = get_directorist_option( 'payment_currency_position' ); + $data['currency'] = atbdp_get_payment_currency(); + $data['symbol'] = atbdp_currency_symbol( atbdp_get_payment_currency() ); + $data['container_fluid'] = 'container-fluid'; + $data['order_id'] = ( ! empty( $order_id ) ) ? $order_id : ''; + + \Directorist\Helper::add_shortcode_comment( 'directorist_payment_receipt' ); + \Directorist\Helper::get_template( 'payment/payment-receipt', apply_filters( 'directorist_payment_receipt_data', $data, $order_id ) ); + + return ob_get_clean(); + } + + /** + * It creates an order for the given listing id + * + * @param int $listing_id Listing ID + * @param array $data Optional Data + */ + private function create_order( $listing_id = 0, $data = array() ) { + if ( directorist_payment_guard() ) { + return; // vail if not listing id is provided + } + // create an order + $order_id = wp_insert_post( + array( + 'post_content' => '', + 'post_title' => sprintf( 'Order for the listing ID #%d', $listing_id ), + 'post_status' => 'publish', + 'post_type' => 'atbdp_orders', + 'comment_status' => false, + ) + ); + // if order is created successfully then process the order + apply_filters( 'atbdp_before_order_recipt', array(), $listing_id ); + if ( $order_id ) { + /* + @todo; Find a better way to search for a order with a given ID*/ + /* + wp_update_post(array( + 'ID'=> (int) $order_id, + 'post_type' => 'atbdp_orders', + 'post_title' => sprintf('Order #%d for the listing ID #%d', $order_id, $listing_id) + ));*/ + $order_details = apply_filters( 'atbdp_order_details', array(), $order_id, $listing_id ); + // If featured item is bought, attach it to the order. + if ( ! empty( $data['feature'] ) ) { + update_post_meta( $order_id, '_featured', 1 ); + // lets add the settings of featured listing to the order details + $order_details[] = atbdp_get_featured_settings_array(); + } + // now lets calculate the total price of all order item's price + $amount = 0.00; + foreach ( $order_details as $detail ) { + if ( isset( $detail['price'] ) ) { + $amount = $detail['price']; + } + } + + /** + * Filter the order amount before tax calculation + * + * @since v7.4.3 + */ + $amount = apply_filters( 'directorist_order_amount_before_tax_calculation', $amount, $order_id, $data ); + + /*Lowercase alphanumeric characters, dashes and underscores are allowed.*/ + $gateway = ! empty( $amount ) && ! empty( $data['payment_gateway'] ) ? sanitize_key( $data['payment_gateway'] ) : 'free'; + // save required data as order post meta + + $amount = apply_filters( 'atbdp_order_amount', $amount, $order_id ); + update_post_meta( $order_id, '_listing_id', $listing_id ); + update_post_meta( $order_id, '_amount', $amount ); + update_post_meta( $order_id, '_payment_gateway', $gateway ); + update_post_meta( $order_id, '_payment_status', 'created' ); + // Hook for developer + do_action( 'atbdp_order_created', $order_id, $listing_id ); /*@todo; do something to prevent multiple order creation when user try to repeat failed payment*/ + $this->process_payment( $amount, $gateway, $order_id, $listing_id, $data ); + } + } + + /** + * It process the payment of the order + * + * @param float $amount The order amount + * @param string $gateway The name of the gateway + * @param int $order_id The order ID + * @param int $listing_id The Listing ID for which the order has been created. + * @param array $data The $_POST data basically + */ + private function process_payment( $amount, $gateway, $order_id, $listing_id, $data = array() ) { + /*Process paid listing*/ + if ( $amount > 0 ) { + if ( 'bank_transfer' == $gateway ) { + update_post_meta( $order_id, '_transaction_id', wp_generate_password( 15, false ) ); + // hook for developer + do_action( 'atbdp_offline_payment_created', $order_id, $listing_id ); + // admin will mark the order completed manually once he get the payment on his bank. + // let's redirect the user to the payment receipt page. + $redirect_url = apply_filters( 'atbdp_payment_receipt_page_link', ATBDP_Permalink::get_payment_receipt_page_link( $order_id ), $order_id ); + wp_safe_redirect( $redirect_url ); + exit(); + } else { + /** + * fires 'atbdp_process_gateway_name_payment', it helps extensions and other payment plugin to process the payment + * atbdp_orders post has all the required information in its meta data like listing id and featured data etc. + * + * @param string $gateway The name of the gateway + * @param int $order_id The Order ID + * @param int $listing_id The Listing ID + * @param array $data The $_POST data basically + */ + do_action( 'atbdp_process_' . $gateway . '_payment', $order_id, $listing_id, $data ); + do_action( 'atbdp_online_order_processed', $order_id, $listing_id ); + } + } else { + /* + @todo; Notify owner based on admin settings that order CREATED*/ + /*complete Free listing Order */ + $this->complete_free_order( + array( + 'ID' => $order_id, + 'transaction_id' => wp_generate_password( 15, false ), + 'listing_id' => $listing_id, + ) + ); + $redirect_url = apply_filters( 'atbdp_payment_receipt_page_link', ATBDP_Permalink::get_payment_receipt_page_link( $order_id ), $order_id ); + wp_safe_redirect( $redirect_url ); + exit; + } + } + + /** + * /** + * It completes order that are free of charge + * + * @param array $order_data The array of order data + */ + private function complete_free_order( $order_data ) { + // add payment status, tnx_id etc. + update_post_meta( $order_data['ID'], '_payment_status', 'completed' ); + update_post_meta( $order_data['ID'], '_transaction_id', $order_data['transaction_id'] ); + // If the order has featured, make the related listing featured. + $featured = get_post_meta( $order_data['ID'], '_featured', true ); + if ( ! empty( $featured ) ) { + update_post_meta( $order_data['listing_id'], '_featured', 1 ); + } + // Order has been completed. Let's fire a hook for a developer to extend if they wish + do_action( 'atbdp_order_completed', $order_data['ID'], $order_data['listing_id'] ); + } + + /** + * It starts output buffering if the checkout form has been submitted in order to fix redirection problem. + */ + public function buffer_to_fix_redirection() { + // if the checkout form is submitted, then init buffering to solve redirection problem because of header already sent + if ( isset( $_SERVER['REQUEST_METHOD'] ) && ( 'POST' == $_SERVER['REQUEST_METHOD'] ) && ATBDP()->helper->verify_nonce( $this->nonce, $this->nonce_action ) ) { + ob_start(); + } + } + + /** + * It output content for payment failure page + * + * @return string + * @since 3.1.2 + * @todo; improve this content or page later. + */ + public function transaction_failure() { + + ob_start(); + + \Directorist\Helper::add_shortcode_comment( 'directorist_transaction_failure' ); + \Directorist\Helper::get_template( 'payment/transaction-failure' ); + + return ob_get_clean(); + } +} // ends class diff --git a/includes/checkout/functions.php b/includes/checkout/functions.php index 1642dce6d5..edf1541ecb 100644 --- a/includes/checkout/functions.php +++ b/includes/checkout/functions.php @@ -10,7 +10,9 @@ */ // Exit if accessed directly -if (!defined('ABSPATH')) die('You do not have permission to access this page directly.'); +if ( ! defined( 'ABSPATH' ) ) { + die( 'You do not have permission to access this page directly.' ); +} /** * Determines if we're currently on the Checkout page @@ -18,28 +20,27 @@ * @return bool True if on the Checkout page, false otherwise * @since 3.0.0 */ -function atbdp_is_checkout() -{ +function atbdp_is_checkout() { - global $wp_query; + global $wp_query; - $is_object_set = isset($wp_query->queried_object); - $is_object_id_set = isset($wp_query->queried_object_id); - $is_checkout = is_page(get_directorist_option('purchase_page')); + $is_object_set = isset( $wp_query->queried_object ); + $is_object_id_set = isset( $wp_query->queried_object_id ); + $is_checkout = is_page( get_directorist_option( 'purchase_page' ) ); - if (!$is_object_set) { + if ( ! $is_object_set ) { - unset($wp_query->queried_object); + unset( $wp_query->queried_object ); - } + } - if (!$is_object_id_set) { + if ( ! $is_object_id_set ) { - unset($wp_query->queried_object_id); + unset( $wp_query->queried_object_id ); - } + } - return apply_filters('atbdp_is_checkout', $is_checkout); + return apply_filters( 'atbdp_is_checkout', $is_checkout ); } /** @@ -48,11 +49,10 @@ function atbdp_is_checkout() * @return bool Can user checkout? * @since 3.0.0 */ -function atbdp_can_checkout() -{ - $can_checkout = true; // Always true for now +function atbdp_can_checkout() { + $can_checkout = true; // Always true for now - return (bool)apply_filters('atbdp_can_checkout', $can_checkout); + return (bool) apply_filters( 'atbdp_can_checkout', $can_checkout ); } /** @@ -63,18 +63,17 @@ function atbdp_can_checkout() * @return string * @since 3.0.0 */ -function atbdp_get_success_page_uri($query_string = null) -{ - $page_id = get_directorist_option('success_page', 0); - $page_id = absint($page_id); +function atbdp_get_success_page_uri( $query_string = null ) { + $page_id = get_directorist_option( 'success_page', 0 ); + $page_id = absint( $page_id ); - $success_page = get_permalink($page_id); + $success_page = get_permalink( $page_id ); - if ($query_string) { - $success_page .= $query_string; - } + if ( $query_string ) { + $success_page .= $query_string; + } - return apply_filters('atbdp_get_success_page_uri', $success_page); + return apply_filters( 'atbdp_get_success_page_uri', $success_page ); } /** @@ -83,12 +82,11 @@ function atbdp_get_success_page_uri($query_string = null) * @return bool True if on the Success page, false otherwise. * @since 3.0.0 */ -function atbdp_is_success_page() -{ - $is_success_page = get_directorist_option('success_page'); - $is_success_page = isset($is_success_page) ? is_page($is_success_page) : false; +function atbdp_is_success_page() { + $is_success_page = get_directorist_option( 'success_page' ); + $is_success_page = isset( $is_success_page ) ? is_page( $is_success_page ) : false; - return apply_filters('atbdp_is_success_page', $is_success_page); + return apply_filters( 'atbdp_is_success_page', $is_success_page ); } /** @@ -101,17 +99,17 @@ function atbdp_is_success_page() * @return void * @since 3.0.0 */ -function atbdp_send_to_success_page($query_string = null) -{ - $redirect = atbdp_get_success_page_uri(); +function atbdp_send_to_success_page( $query_string = null ) { + $redirect = atbdp_get_success_page_uri(); - if ($query_string) - $redirect .= $query_string; + if ( $query_string ) { + $redirect .= $query_string; + } - $gateway = isset($_REQUEST['atbdp-gateway']) ? sanitize_text_field( wp_unslash( $_REQUEST['atbdp-gateway'] ) ) : ''; + $gateway = isset( $_REQUEST['atbdp-gateway'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['atbdp-gateway'] ) ) : ''; - wp_redirect(apply_filters('atbdp_success_page_redirect', $redirect, $gateway, $query_string)); - wp_die(); + wp_redirect( apply_filters( 'atbdp_success_page_redirect', $redirect, $gateway, $query_string ) ); + wp_die(); } /** @@ -121,29 +119,28 @@ function atbdp_send_to_success_page($query_string = null) * @return mixed Full URL to the checkout page, if present | null if it doesn't exist * @since 3.0.0 */ -function atbdp_get_checkout_uri($args = array()) -{ - $uri = get_directorist_option('purchase_page'); - $uri = isset( $uri ) ? trailingslashit( get_permalink( $uri ) ) : null; - - if (!empty($args)) { - // Check for backward compatibility - if (is_string($args)) - $args = str_replace('?', '', $args); +function atbdp_get_checkout_uri( $args = array() ) { + $uri = get_directorist_option( 'purchase_page' ); + $uri = isset( $uri ) ? trailingslashit( get_permalink( $uri ) ) : null; - $args = wp_parse_args($args); + if ( ! empty( $args ) ) { + // Check for backward compatibility + if ( is_string( $args ) ) { + $args = str_replace( '?', '', $args ); + } - $uri = add_query_arg($args, $uri); - } + $args = wp_parse_args( $args ); - $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; + $uri = add_query_arg( $args, $uri ); + } - $ajax_url = admin_url('admin-ajax.php', $scheme); + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; - /*@todo; work on this to complete*/ + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); + /*@todo; work on this to complete*/ - return apply_filters('atbdp_get_checkout_uri', $uri); + return apply_filters( 'atbdp_get_checkout_uri', $uri ); } /** @@ -157,21 +154,21 @@ function atbdp_get_checkout_uri($args = array()) * @return Void * @since 3.0.0 */ -function atbdp_send_back_to_checkout($args = array()) -{ - $redirect = atbdp_get_checkout_uri(); +function atbdp_send_back_to_checkout( $args = array() ) { + $redirect = atbdp_get_checkout_uri(); - if (!empty($args)) { - // Check for backward compatibility - if (is_string($args)) - $args = str_replace('?', '', $args); + if ( ! empty( $args ) ) { + // Check for backward compatibility + if ( is_string( $args ) ) { + $args = str_replace( '?', '', $args ); + } - $args = wp_parse_args($args); + $args = wp_parse_args( $args ); - $redirect = add_query_arg($args, $redirect); - } - wp_redirect(apply_filters('atbdp_send_back_to_checkout', $redirect, $args)); - wp_die(); + $redirect = add_query_arg( $args, $redirect ); + } + wp_redirect( apply_filters( 'atbdp_send_back_to_checkout', $redirect, $args ) ); + wp_die(); } /** @@ -181,15 +178,15 @@ function atbdp_send_back_to_checkout($args = array()) * @return mixed Full URL to the Transaction Failed page, if present, home page if it doesn't exist * @since 3.0.0 */ -function atbdp_get_failed_transaction_uri($extras = false) -{ - $uri = get_directorist_option('failure_page', ''); - $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); +function atbdp_get_failed_transaction_uri( $extras = false ) { + $uri = get_directorist_option( 'failure_page', '' ); + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); - if ($extras) - $uri .= $extras; + if ( $extras ) { + $uri .= $extras; + } - return apply_filters('atbdp_get_failed_transaction_uri', $uri); + return apply_filters( 'atbdp_get_failed_transaction_uri', $uri ); } /** @@ -198,12 +195,11 @@ function atbdp_get_failed_transaction_uri($extras = false) * @return bool True if on the Failed Transaction page, false otherwise. * @since 2.1 */ -function atbdp_is_failed_transaction_page() -{ - $ret = get_directorist_option('failure_page', false); - $ret = isset($ret) ? is_page($ret) : false; +function atbdp_is_failed_transaction_page() { + $ret = get_directorist_option( 'failure_page', false ); + $ret = isset( $ret ) ? is_page( $ret ) : false; - return apply_filters('atbdp_is_failure_page', $ret); + return apply_filters( 'atbdp_is_failure_page', $ret ); } /** @@ -213,28 +209,25 @@ function atbdp_is_failed_transaction_page() * @return void * @since 3.0.0 */ -function atbdp_listen_for_failed_payments() -{ - - $failed_page = get_directorist_option('failure_page', 0); - - if (!empty($failed_page) && is_page($failed_page) && !empty($_GET['payment-id'])) { +function atbdp_listen_for_failed_payments() { - $payment_id = absint( wp_unslash( $_GET['payment-id'] ) ); - $payment = get_post($payment_id); - $status = atbdp_get_payment_status($payment); + $failed_page = get_directorist_option( 'failure_page', 0 ); - if ($status && 'pending' === strtolower($status)) { + if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { - atbdp_update_payment_status($payment_id, 'failed'); + $payment_id = absint( wp_unslash( $_GET['payment-id'] ) ); + $payment = get_post( $payment_id ); + $status = atbdp_get_payment_status( $payment ); - } + if ( $status && 'pending' === strtolower( $status ) ) { - } + atbdp_update_payment_status( $payment_id, 'failed' ); + } + } } -add_action('template_redirect', 'atbdp_listen_for_failed_payments'); +add_action( 'template_redirect', 'atbdp_listen_for_failed_payments' ); /** @@ -245,10 +238,9 @@ function atbdp_listen_for_failed_payments() * @return bool * @since 3.0.0* */ -function atbdp_field_is_required($field = '') -{ - $required_fields = atbdp_purchase_form_required_fields(); - return array_key_exists($field, $required_fields); +function atbdp_field_is_required( $field = '' ) { + $required_fields = atbdp_purchase_form_required_fields(); + return array_key_exists( $field, $required_fields ); } /** @@ -257,11 +249,10 @@ function atbdp_field_is_required($field = '') * @return array * @since 3.0.0 */ -function atbdp_get_banned_emails() -{ - $emails = array_map('trim', get_directorist_option('banned_emails', array())); +function atbdp_get_banned_emails() { + $emails = array_map( 'trim', get_directorist_option( 'banned_emails', array() ) ); - return apply_filters('atbdp_get_banned_emails', $emails); + return apply_filters( 'atbdp_get_banned_emails', $emails ); } /** @@ -271,49 +262,48 @@ function atbdp_get_banned_emails() * @return bool * @since 3.0.0 */ -function atbdp_is_email_banned($email = '') -{ +function atbdp_is_email_banned( $email = '' ) { - $email = trim($email); - if (empty($email)) { - return false; - } + $email = trim( $email ); + if ( empty( $email ) ) { + return false; + } - $email = strtolower($email); - $banned_emails = atbdp_get_banned_emails(); + $email = strtolower( $email ); + $banned_emails = atbdp_get_banned_emails(); - if (!is_array($banned_emails) || empty($banned_emails)) { - return false; - } + if ( ! is_array( $banned_emails ) || empty( $banned_emails ) ) { + return false; + } - $return = false; - foreach ($banned_emails as $banned_email) { + $return = false; + foreach ( $banned_emails as $banned_email ) { - $banned_email = strtolower($banned_email); + $banned_email = strtolower( $banned_email ); - if (is_email($banned_email)) { + if ( is_email( $banned_email ) ) { - // Complete email address - $return = ($banned_email == $email ? true : false); + // Complete email address + $return = ( $banned_email == $email ? true : false ); - } elseif (strpos($banned_email, '.') === 0) { + } elseif ( strpos( $banned_email, '.' ) === 0 ) { - // TLD block - $return = (substr($email, (strlen($banned_email) * -1)) == $banned_email) ? true : false; + // TLD block + $return = ( substr( $email, ( strlen( $banned_email ) * -1 ) ) == $banned_email ) ? true : false; - } else { + } else { - // Domain block - $return = (stristr($email, $banned_email) ? true : false); + // Domain block + $return = ( stristr( $email, $banned_email ) ? true : false ); - } + } - if (true === $return) { - break; - } - } + if ( true === $return ) { + break; + } + } - return apply_filters('atbdp_is_email_banned', $return, $email); + return apply_filters( 'atbdp_is_email_banned', $return, $email ); } /** @@ -323,45 +313,44 @@ function atbdp_is_email_banned($email = '') * @return bool If the card number provided matches a specific format of a valid card * @since 3.0.0 */ -function atbdp_validate_card_number_format($number = 0) -{ +function atbdp_validate_card_number_format( $number = 0 ) { - $number = trim($number); - if (empty($number)) { - return false; - } + $number = trim( $number ); + if ( empty( $number ) ) { + return false; + } - if (!is_numeric($number)) { - return false; - } + if ( ! is_numeric( $number ) ) { + return false; + } - $is_valid_format = false; + $is_valid_format = false; - // First check if it passes with the passed method, Luhn by default - $is_valid_format = atbdp_validate_card_number_format_luhn($number); + // First check if it passes with the passed method, Luhn by default + $is_valid_format = atbdp_validate_card_number_format_luhn( $number ); - // Run additional checks before we start the regexing and looping by type - $is_valid_format = apply_filters('atbdp_valiate_card_format_pre_type', $is_valid_format, $number); + // Run additional checks before we start the regexing and looping by type + $is_valid_format = apply_filters( 'atbdp_valiate_card_format_pre_type', $is_valid_format, $number ); - if (true === $is_valid_format) { - // We've passed our method check, onto card specific checks - $card_type = atbdp_detect_cc_type($number); - $is_valid_format = !empty($card_type) ? true : false; - } + if ( true === $is_valid_format ) { + // We've passed our method check, onto card specific checks + $card_type = atbdp_detect_cc_type( $number ); + $is_valid_format = ! empty( $card_type ) ? true : false; + } - return apply_filters('atbdp_cc_is_valid_format', $is_valid_format, $number); + return apply_filters( 'atbdp_cc_is_valid_format', $is_valid_format, $number ); } -function directorist_payment_guard(){ - $listing_id = get_query_var('atbdp_listing_id'); +function directorist_payment_guard() { + $listing_id = get_query_var( 'atbdp_listing_id' ); if ( empty( $listing_id ) && isset( $_GET['submit'] ) ) { $listing_id = sanitize_text_field( wp_unslash( $_GET['submit'] ) ); } - // vail if the id is empty or post type is not our post type. - $guard = empty($listing_id) || (!empty($listing_id) && ATBDP_POST_TYPE != get_post_type($listing_id)); - return apply_filters( 'directorist_checkout_guard', $guard ); + // vail if the id is empty or post type is not our post type. + $guard = empty( $listing_id ) || ( ! empty( $listing_id ) && ATBDP_POST_TYPE != get_post_type( $listing_id ) ); + return apply_filters( 'directorist_checkout_guard', $guard ); } /** @@ -371,38 +360,36 @@ function directorist_payment_guard(){ * @return bool * @since 3.0.0 */ -function atbdp_validate_card_number_format_luhn($number) -{ +function atbdp_validate_card_number_format_luhn( $number ) { - // Strip any non-digits (useful for credit card numbers with spaces and hyphens) - $number = preg_replace('/\D/', '', $number); + // Strip any non-digits (useful for credit card numbers with spaces and hyphens) + $number = preg_replace( '/\D/', '', $number ); - // Set the string length and parity - $length = strlen($number); - $parity = $length % 2; + // Set the string length and parity + $length = strlen( $number ); + $parity = $length % 2; - // Loop through each digit and do the math - $total = 0; - for ($i = 0; $i < $length; $i++) { - $digit = $number[$i]; + // Loop through each digit and do the math + $total = 0; + for ( $i = 0; $i < $length; $i++ ) { + $digit = $number[ $i ]; - // Multiply alternate digits by two - if ($i % 2 == $parity) { - $digit *= 2; + // Multiply alternate digits by two + if ( $i % 2 == $parity ) { + $digit *= 2; - // If the sum is two digits, add them together (in effect) - if ($digit > 9) { - $digit -= 9; - } - } + // If the sum is two digits, add them together (in effect) + if ( $digit > 9 ) { + $digit -= 9; + } + } - // Total up the digits - $total += $digit; - } - - // If the total mod 10 equals 0, the number is valid - return ($total % 10 == 0) ? true : false; + // Total up the digits + $total += $digit; + } + // If the total mod 10 equals 0, the number is valid + return ( $total % 10 == 0 ) ? true : false; } /** @@ -413,85 +400,82 @@ function atbdp_validate_card_number_format_luhn($number) * @return string|bool * @since 3.0.0 */ -function atbdp_detect_cc_type($number) -{ - - $return = false; - - $card_types = array( - array( - 'name' => 'amex', - 'pattern' => '/^3[4|7]/', - 'valid_length' => array(15), - ), - array( - 'name' => 'diners_club_carte_blanche', - 'pattern' => '/^30[0-5]/', - 'valid_length' => array(14), - ), - array( - 'name' => 'diners_club_international', - 'pattern' => '/^36/', - 'valid_length' => array(14), - ), - array( - 'name' => 'jcb', - 'pattern' => '/^35(2[89]|[3-8][0-9])/', - 'valid_length' => array(16), - ), - array( - 'name' => 'laser', - 'pattern' => '/^(6304|670[69]|6771)/', - 'valid_length' => array(16, 17, 18, 19), - ), - array( - 'name' => 'visa_electron', - 'pattern' => '/^(4026|417500|4508|4844|491(3|7))/', - 'valid_length' => array(16), - ), - array( - 'name' => 'visa', - 'pattern' => '/^4/', - 'valid_length' => array(16), - ), - array( - 'name' => 'mastercard', - 'pattern' => '/^5[1-5]/', - 'valid_length' => array(16), - ), - array( - 'name' => 'maestro', - 'pattern' => '/^(5018|5020|5038|6304|6759|676[1-3])/', - 'valid_length' => array(12, 13, 14, 15, 16, 17, 18, 19), - ), - array( - 'name' => 'discover', - 'pattern' => '/^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/', - 'valid_length' => array(16), - ), - ); - - $card_types = apply_filters('atbdp_cc_card_types', $card_types); - - if (!is_array($card_types)) { - return false; - } - - foreach ($card_types as $card_type) { - - if (preg_match($card_type['pattern'], $number)) { - - $number_length = strlen($number); - if (in_array($number_length, $card_type['valid_length'])) { - $return = $card_type['name']; - break; - } - - } - - } - - return apply_filters('atbdp_cc_found_card_type', $return, $number, $card_types); +function atbdp_detect_cc_type( $number ) { + + $return = false; + + $card_types = array( + array( + 'name' => 'amex', + 'pattern' => '/^3[4|7]/', + 'valid_length' => array( 15 ), + ), + array( + 'name' => 'diners_club_carte_blanche', + 'pattern' => '/^30[0-5]/', + 'valid_length' => array( 14 ), + ), + array( + 'name' => 'diners_club_international', + 'pattern' => '/^36/', + 'valid_length' => array( 14 ), + ), + array( + 'name' => 'jcb', + 'pattern' => '/^35(2[89]|[3-8][0-9])/', + 'valid_length' => array( 16 ), + ), + array( + 'name' => 'laser', + 'pattern' => '/^(6304|670[69]|6771)/', + 'valid_length' => array( 16, 17, 18, 19 ), + ), + array( + 'name' => 'visa_electron', + 'pattern' => '/^(4026|417500|4508|4844|491(3|7))/', + 'valid_length' => array( 16 ), + ), + array( + 'name' => 'visa', + 'pattern' => '/^4/', + 'valid_length' => array( 16 ), + ), + array( + 'name' => 'mastercard', + 'pattern' => '/^5[1-5]/', + 'valid_length' => array( 16 ), + ), + array( + 'name' => 'maestro', + 'pattern' => '/^(5018|5020|5038|6304|6759|676[1-3])/', + 'valid_length' => array( 12, 13, 14, 15, 16, 17, 18, 19 ), + ), + array( + 'name' => 'discover', + 'pattern' => '/^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/', + 'valid_length' => array( 16 ), + ), + ); + + $card_types = apply_filters( 'atbdp_cc_card_types', $card_types ); + + if ( ! is_array( $card_types ) ) { + return false; + } + + foreach ( $card_types as $card_type ) { + + if ( preg_match( $card_type['pattern'], $number ) ) { + + $number_length = strlen( $number ); + if ( in_array( $number_length, $card_type['valid_length'] ) ) { + $return = $card_type['name']; + break; + } + } + } + + return apply_filters( 'atbdp_cc_found_card_type', $return, $number, $card_types ); } /** @@ -502,12 +486,10 @@ function atbdp_detect_cc_type($number) * @return bool * @since 3.0.0 */ -function atbdp_purchase_form_validate_cc_exp_date($exp_month, $exp_year) -{ - - $month_name = date('M', mktime(0, 0, 0, $exp_month, 10)); - $expiration = strtotime(date('t', strtotime($month_name . ' ' . $exp_year)) . ' ' . $month_name . ' ' . $exp_year . ' 11:59:59PM'); +function atbdp_purchase_form_validate_cc_exp_date( $exp_month, $exp_year ) { - return $expiration >= time(); + $month_name = date( 'M', mktime( 0, 0, 0, $exp_month, 10 ) ); + $expiration = strtotime( date( 't', strtotime( $month_name . ' ' . $exp_year ) ) . ' ' . $month_name . ' ' . $exp_year . ' 11:59:59PM' ); -} \ No newline at end of file + return $expiration >= time(); +} diff --git a/includes/class-helper.php b/includes/class-helper.php index 28e5414e53..2ba0e3e873 100644 --- a/includes/class-helper.php +++ b/includes/class-helper.php @@ -7,7 +7,9 @@ use Exception; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Helper { @@ -38,7 +40,7 @@ public static function get_first_wp_error_message( $wp_error ) { return ''; } - $error_keys = ( is_array( $wp_error->errors ) ) ? array_keys( $wp_error->errors ) : []; + $error_keys = ( is_array( $wp_error->errors ) ) ? array_keys( $wp_error->errors ) : array(); $error_key = ( ! empty( $error_keys ) ) ? $error_keys[0] : ''; $message = ( ! empty( $error_key ) && is_array( $wp_error->errors[ $error_key ] ) && ! empty( $wp_error->errors[ $error_key ] ) ) ? $wp_error->errors[ $error_key ][0] : ''; @@ -50,13 +52,14 @@ public static function get_first_wp_error_message( $wp_error ) { * * This function is only available on operating * systems that support the gettimeofday() system call. + * * @link https://www.php.net/manual/en/function.microtime.php * * @return int */ public static function getTimeInMillisecond() { try { - return ( int ) ( microtime( true ) * 1000 ); + return (int) ( microtime( true ) * 1000 ); } catch ( Exception $e ) { return 0; } @@ -93,7 +96,7 @@ public static function maybe_json( $input_data = '', $return_first_item = false } // JSON Decode from Base64 - $decode_base64 = base64_decode( $input_data ); + $decode_base64 = base64_decode( $input_data ); $decode_base64_json = json_decode( $decode_base64, true ); if ( ! is_null( $decode_base64_json ) ) { @@ -104,15 +107,16 @@ public static function maybe_json( $input_data = '', $return_first_item = false } // get_widget_value - public static function get_widget_value( $post_id = 0, $widget = [] ) { + public static function get_widget_value( $post_id = 0, $widget = array() ) { $value = ''; // directorist_console_log( $widget ); - if ( ! is_array( $widget ) ) { return ''; } + if ( ! is_array( $widget ) ) { + return ''; } if ( isset( $widget['field_key'] ) ) { - $value = get_post_meta( $post_id, '_'.$widget['field_key'], true ); + $value = get_post_meta( $post_id, '_' . $widget['field_key'], true ); if ( empty( $value ) ) { $value = get_post_meta( $post_id, $widget['field_key'], true ); @@ -131,18 +135,24 @@ public static function get_widget_value( $post_id = 0, $widget = [] ) { } // add_listings_review_meta - public static function add_listings_review_meta( array $args = [] ) { + public static function add_listings_review_meta( array $args = array() ) { - if ( empty( $args['post_id'] ) ) { return false; } + if ( empty( $args['post_id'] ) ) { + return false; } $reviews = get_post_meta( $args['post_id'], '_directorist_reviews', true ); - if ( ! is_array( $reviews ) ) { $reviews = []; } + if ( ! is_array( $reviews ) ) { + $reviews = array(); } - if ( empty( $args['reviewer_id'] ) ) { return false; } - if ( empty( $args['status'] ) ) { return false; } - if ( empty( $args['rating'] ) ) { return false; } - if ( ! is_numeric( $args['rating'] ) ) { return false; } + if ( empty( $args['reviewer_id'] ) ) { + return false; } + if ( empty( $args['status'] ) ) { + return false; } + if ( empty( $args['rating'] ) ) { + return false; } + if ( ! is_numeric( $args['rating'] ) ) { + return false; } $reviews[ $args['reviewer_id'] ] = $args; @@ -152,26 +162,31 @@ public static function add_listings_review_meta( array $args = [] ) { } // update_listings_review_meta - public static function update_listings_review_meta( array $args = [] ) { + public static function update_listings_review_meta( array $args = array() ) { - if ( empty( $args['post_id'] ) ) { return false; } + if ( empty( $args['post_id'] ) ) { + return false; } $reviews = get_post_meta( $args['post_id'], '_directorist_reviews', true ); - if ( ! is_array( $reviews ) ) { return false; } + if ( ! is_array( $reviews ) ) { + return false; } - if ( empty( $args['field_key'] ) ) { return false; } - if ( empty( $args['value'] ) ) { return false; } - if ( empty( $args['reviewer_id'] ) ) { return false; } + if ( empty( $args['field_key'] ) ) { + return false; } + if ( empty( $args['value'] ) ) { + return false; } + if ( empty( $args['reviewer_id'] ) ) { + return false; } - - if ( 'rating' === $args['field_key'] && ! is_numeric( $args['value'] ) ) { + if ( 'rating' === $args['field_key'] && ! is_numeric( $args['value'] ) ) { return false; } - if ( empty( $reviews[ $args['reviewer_id'] ] ) ) { return false; } - if ( empty( $reviews[ $args['reviewer_id'] ][ $args['field_key'] ] ) ) { return false; } - + if ( empty( $reviews[ $args['reviewer_id'] ] ) ) { + return false; } + if ( empty( $reviews[ $args['reviewer_id'] ][ $args['field_key'] ] ) ) { + return false; } $reviewer_id = $args['reviewer_id']; $field_key = $args['field_key']; @@ -187,23 +202,30 @@ public static function update_listings_review_meta( array $args = [] ) { // update_listings_ratings_meta public static function update_listings_ratings_meta( $post_id = 0 ) { - if ( empty( $post_id ) ) { return false; } + if ( empty( $post_id ) ) { + return false; } $reviews = get_post_meta( $post_id, '_directorist_reviews', true ); - if ( empty( $reviews ) ) { return false; } - if ( ! is_array( $reviews ) ) { return false; } + if ( empty( $reviews ) ) { + return false; } + if ( ! is_array( $reviews ) ) { + return false; } $total_ratings = 0; foreach ( $reviews as $id => $review ) { - if ( empty( $review[ 'rating' ] ) ) { continue; } - if ( ! is_numeric( $review[ 'rating' ] ) ) { continue; } - if ( empty( $review[ 'status' ] ) ) { continue; } - if ( 'published' !== $review[ 'status' ] ) { continue; } + if ( empty( $review['rating'] ) ) { + continue; } + if ( ! is_numeric( $review['rating'] ) ) { + continue; } + if ( empty( $review['status'] ) ) { + continue; } + if ( 'published' !== $review['status'] ) { + continue; } - $total_ratings = $total_ratings + ( float ) $review[ 'rating' ]; + $total_ratings = $total_ratings + (float) $review['rating']; } $avg_ratings = $total_ratings / count( $reviews ); @@ -212,43 +234,42 @@ public static function update_listings_ratings_meta( $post_id = 0 ) { return true; } - public static function listing_price( $id='' ) { - if ( !$id ) { + public static function listing_price( $id = '' ) { + if ( ! $id ) { $id = get_the_ID(); } - if ( !self::has_price_range( $id ) && !self::has_price( $id ) ) { + if ( ! self::has_price_range( $id ) && ! self::has_price( $id ) ) { return; } - if ( 'range' == Helper::pricing_type( $id ) ) { + if ( 'range' == self::pricing_type( $id ) ) { self::price_range_template( $id ); - } - else { + } else { self::price_template( $id ); } } public static function socials() { - $socials = [ - 'facebook' => __('Facebook', 'directorist'), - 'twitter' => __('Twitter', 'directorist'), - 'linkedin' => __('LinkedIn', 'directorist'), - 'pinterest' => __('Pinterest', 'directorist'), - 'instagram' => __('Instagram', 'directorist'), - 'tumblr' => __('Tumblr', 'directorist'), - 'flickr' => __('Flickr', 'directorist'), - 'snapchat' => __('Snapchat', 'directorist'), - 'reddit' => __('Reddit', 'directorist'), - 'youtube' => __('Youtube', 'directorist'), - 'vimeo' => __('Vimeo', 'directorist'), - 'vine' => __('Vine', 'directorist'), - 'github' => __('Github', 'directorist'), - 'dribbble' => __('Dribbble', 'directorist'), - 'behance' => __('Behance', 'directorist'), - 'soundcloud' => __('SoundCloud', 'directorist'), - 'stack-overflow' => __('StackOverFLow', 'directorist'), - ]; + $socials = array( + 'facebook' => __( 'Facebook', 'directorist' ), + 'twitter' => __( 'Twitter', 'directorist' ), + 'linkedin' => __( 'LinkedIn', 'directorist' ), + 'pinterest' => __( 'Pinterest', 'directorist' ), + 'instagram' => __( 'Instagram', 'directorist' ), + 'tumblr' => __( 'Tumblr', 'directorist' ), + 'flickr' => __( 'Flickr', 'directorist' ), + 'snapchat' => __( 'Snapchat', 'directorist' ), + 'reddit' => __( 'Reddit', 'directorist' ), + 'youtube' => __( 'Youtube', 'directorist' ), + 'vimeo' => __( 'Vimeo', 'directorist' ), + 'vine' => __( 'Vine', 'directorist' ), + 'github' => __( 'Github', 'directorist' ), + 'dribbble' => __( 'Dribbble', 'directorist' ), + 'behance' => __( 'Behance', 'directorist' ), + 'soundcloud' => __( 'SoundCloud', 'directorist' ), + 'stack-overflow' => __( 'StackOverFLow', 'directorist' ), + ); asort( $socials ); @@ -277,51 +298,50 @@ public static function price_template( $listing_id ) { public static function price_range_template( $listing_id ) { $price_range = get_post_meta( $listing_id, '_price_range', true ); - $currency = directorist_get_currency(); - $currency = atbdp_currency_symbol( $currency ); + $currency = directorist_get_currency(); + $currency = atbdp_currency_symbol( $currency ); switch ( $price_range ) { case 'skimming': - $active_items = 4; - $price_range_text = __( 'Skimming', 'directorist' ); - break; + $active_items = 4; + $price_range_text = __( 'Skimming', 'directorist' ); + break; case 'moderate': - $active_items = 3; - $price_range_text = __( 'Moderate', 'directorist' ); - break; + $active_items = 3; + $price_range_text = __( 'Moderate', 'directorist' ); + break; case 'economy': - $active_items = 2; - $price_range_text = __( 'Economy', 'directorist' ); - break; + $active_items = 2; + $price_range_text = __( 'Economy', 'directorist' ); + break; case 'bellow_economy': - $active_items = 1; - $price_range_text = __( 'Cheap', 'directorist' ); - break; + $active_items = 1; + $price_range_text = __( 'Cheap', 'directorist' ); + break; default: - $active_items = 4; - $price_range_text = __( 'Skimming', 'directorist' ); - break; + $active_items = 4; + $price_range_text = __( 'Skimming', 'directorist' ); + break; } self::get_template( 'global/price-range', compact( 'active_items', 'currency', 'price_range_text' ) ); } public static function formatted_price( $price ) { - $allow_decimal = get_directorist_option('allow_decimal', 1); + $allow_decimal = get_directorist_option( 'allow_decimal', 1 ); $c_position = directorist_get_currency_position(); $currency = directorist_get_currency(); - $symbol = atbdp_currency_symbol($currency); + $symbol = atbdp_currency_symbol( $currency ); $before = ''; $after = ''; - if ('after' == $c_position) { + if ( 'after' == $c_position ) { $after = $symbol; - } - else { + } else { $before = $symbol; } @@ -340,10 +360,13 @@ public static function formatted_tel( $tel_number = '', $echo = true ) { } public static function phone_link( $args ) { - $args = array_merge( array( - 'number' => '', - 'whatsapp' => false, - ), $args ); + $args = array_merge( + array( + 'number' => '', + 'whatsapp' => false, + ), + $args + ); $number = self::formatted_tel( $args['number'], false ); @@ -358,10 +381,9 @@ public static function user_info( $user_id_or_obj, $meta ) { if ( is_integer( $user_id_or_obj ) ) { $user_id = $user_id_or_obj; - $user = get_userdata( $user_id ); - } - else { - $user = $user_id_or_obj; + $user = get_userdata( $user_id ); + } else { + $user = $user_id_or_obj; $user_id = $user->data->ID; } @@ -369,49 +391,49 @@ public static function user_info( $user_id_or_obj, $meta ) { switch ( $meta ) { case 'name': - $result = $user->data->display_name; - break; + $result = $user->data->display_name; + break; case 'role': - $result = $user->roles[0]; - break; + $result = $user->roles[0]; + break; case 'address': - $result = get_user_meta($user_id, 'address', true); - break; + $result = get_user_meta( $user_id, 'address', true ); + break; case 'phone': - $result = get_user_meta($user_id, 'atbdp_phone', true); - break; + $result = get_user_meta( $user_id, 'atbdp_phone', true ); + break; case 'email': - $result = $user->data->user_email; - break; + $result = $user->data->user_email; + break; case 'website': - $result = $user->data->user_url; - break; + $result = $user->data->user_url; + break; case 'description': - $result = trim( get_user_meta( $user_id, 'description', true ) ); - //var_dump($result); - break; + $result = trim( get_user_meta( $user_id, 'description', true ) ); + // var_dump($result); + break; case 'facebook': - $result = get_user_meta($user_id, 'atbdp_facebook', true); - break; + $result = get_user_meta( $user_id, 'atbdp_facebook', true ); + break; case 'twitter': - $result = get_user_meta($user_id, 'atbdp_twitter', true); - break; + $result = get_user_meta( $user_id, 'atbdp_twitter', true ); + break; case 'linkedin': - $result = get_user_meta($user_id, 'atbdp_linkedin', true); - break; + $result = get_user_meta( $user_id, 'atbdp_linkedin', true ); + break; case 'youtube': - $result = get_user_meta($user_id, 'atbdp_youtube', true); - break; + $result = get_user_meta( $user_id, 'atbdp_youtube', true ); + break; } return $result; @@ -420,20 +442,20 @@ public static function user_info( $user_id_or_obj, $meta ) { public static function parse_video( $url ) { $embeddable_url = ''; - $is_youtube = preg_match('/youtu\.be/i', $url) || preg_match('/youtube\.com\/watch/i', $url) || preg_match('/youtube\.com\/shorts/i', $url); - if ($is_youtube) { + $is_youtube = preg_match( '/youtu\.be/i', $url ) || preg_match( '/youtube\.com\/watch/i', $url ) || preg_match( '/youtube\.com\/shorts/i', $url ); + if ( $is_youtube ) { $pattern = '/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(shorts\/)|(watch\?))\??v?=?([^#\&\?]*).*/'; - preg_match($pattern, $url, $matches); - if (count($matches) && strlen($matches[8]) == 11) { + preg_match( $pattern, $url, $matches ); + if ( count( $matches ) && strlen( $matches[8] ) == 11 ) { $embeddable_url = 'https://www.youtube.com/embed/' . $matches[8]; } } - $is_vimeo = preg_match('/vimeo\.com/i', $url); - if ($is_vimeo) { + $is_vimeo = preg_match( '/vimeo\.com/i', $url ); + if ( $is_vimeo ) { $pattern = '/\/\/(www\.)?vimeo.com\/(\d+)($|\/)/'; - preg_match($pattern, $url, $matches); - if (count($matches)) { + preg_match( $pattern, $url, $matches ); + if ( count( $matches ) ) { $embeddable_url = 'https://player.vimeo.com/video/' . $matches[2]; } } @@ -463,25 +485,23 @@ public static function badge_exists( $listing_id ) { // @cache @kowsar if ( self::is_new( $listing_id ) || self::is_featured( $listing_id ) || self::is_popular( $listing_id ) ) { return true; - } - else { + } else { return false; } } public static function is_new( $listing_id ) { - $post = get_post( $listing_id ); // @cache @kowsar - $new_listing_time = get_directorist_option('new_listing_day'); - $each_hours = 60 * 60 * 24; - $s_date1 = strtotime(current_time('mysql')); - $s_date2 = strtotime($post->post_date); - $s_date_diff = abs($s_date1 - $s_date2); - $days = round($s_date_diff / $each_hours); - - if ($days <= (int)$new_listing_time) { + $post = get_post( $listing_id ); // @cache @kowsar + $new_listing_time = get_directorist_option( 'new_listing_day' ); + $each_hours = 60 * 60 * 24; + $s_date1 = strtotime( current_time( 'mysql' ) ); + $s_date2 = strtotime( $post->post_date ); + $s_date_diff = abs( $s_date1 - $s_date2 ); + $days = round( $s_date_diff / $each_hours ); + + if ( $days <= (int) $new_listing_time ) { return true; - } - else { + } else { return false; } } @@ -496,7 +516,7 @@ public static function default_preview_image_src( $directory_id ) { if ( ! empty( $settings['preview_image'] ) ) { $default_preview = $settings['preview_image']; } else { - $default_img = get_directorist_option( 'default_preview_image' ); + $default_img = get_directorist_option( 'default_preview_image' ); $default_preview = $default_img ? $default_img : DIRECTORIST_ASSETS . 'images/grid.jpg'; } @@ -512,18 +532,18 @@ public static function is_featured( $listing_id ) { } public static function new_badge_text() { - return get_directorist_option('new_badge_text', 'New'); + return get_directorist_option( 'new_badge_text', 'New' ); } public static function popular_badge_text() { - return get_directorist_option('popular_badge_text', 'Popular'); + return get_directorist_option( 'popular_badge_text', 'Popular' ); } public static function featured_badge_text() { - return get_directorist_option('feature_badge_text', 'Featured'); + return get_directorist_option( 'feature_badge_text', 'Featured' ); } - public static function single_listing_dummy_shortcode( $shortcode, $atts = [] ) { + public static function single_listing_dummy_shortcode( $shortcode, $atts = array() ) { $atts_string = ''; if ( $atts ) { @@ -557,42 +577,47 @@ public static function get_directory_types_with_custom_single_page( $page_id = n $directory_types = directorist_get_directories( $args ); if ( empty( $directory_types ) || is_wp_error( $directory_types ) ) { - return []; + return array(); } - $directory_types = array_filter( $directory_types, static function( $directory_type ) use ( $page_id ) { - $selected_page_id = (int) get_term_meta( $directory_type->term_id, 'single_listing_page', true ); + $directory_types = array_filter( + $directory_types, + static function ( $directory_type ) use ( $page_id ) { + $selected_page_id = (int) get_term_meta( $directory_type->term_id, 'single_listing_page', true ); - if ( is_null( $page_id ) ) { - return $selected_page_id; - } + if ( is_null( $page_id ) ) { + return $selected_page_id; + } - return ( $selected_page_id === (int) $page_id ); - } ); + return ( $selected_page_id === (int) $page_id ); + } + ); return $directory_types; } public static function builder_selected_single_pages() { // @cache @kowsar - $pages = []; - - $types = get_terms( array( - 'taxonomy' => 'atbdp_listing_types', - 'hide_empty' => false, - 'meta_query' => array( - array( - 'key' => 'single_listing_page', - 'compare' => 'EXISTS', + $pages = array(); + + $types = get_terms( + array( + 'taxonomy' => 'atbdp_listing_types', + 'hide_empty' => false, + 'meta_query' => array( + array( + 'key' => 'single_listing_page', + 'compare' => 'EXISTS', + ), ), - ), - ) ); + ) + ); foreach ( $types as $type ) { - $page_id = get_directorist_type_option( $type->term_id, 'single_listing_page' ); + $page_id = get_directorist_type_option( $type->term_id, 'single_listing_page' ); $single_listing_enabled = get_directorist_type_option( $type->term_id, 'enable_single_listing_page' ); if ( $single_listing_enabled && $page_id ) { - $pages[$page_id] = $type->name; + $pages[ $page_id ] = $type->name; } } @@ -615,26 +640,27 @@ public static function get_listing_payment_status( $listing_id = '' ) { // get_listing_order_id public static function get_listing_order_id( $listing_id = '' ) { - $args = [ - 'post_type' => 'atbdp_orders', + $args = array( + 'post_type' => 'atbdp_orders', 'post_status' => 'publish', - 'meta_query' => [ - [ - 'key' => '_listing_id', + 'meta_query' => array( + array( + 'key' => '_listing_id', 'value' => $listing_id, - ] - ] - ]; + ), + ), + ); - $orders = new \WP_Query( $args ); + $orders = new \WP_Query( $args ); $order_id = ( $orders->have_posts() ) ? $orders->post->ID : ''; return $order_id; } - public static function add_hidden_data_to_dom( string $data_key = '', array $data = [] ) { + public static function add_hidden_data_to_dom( string $data_key = '', array $data = array() ) { - if ( empty( $data ) ) { return; } + if ( empty( $data ) ) { + return; } $data_value = base64_encode( json_encode( $data ) ); ?> @@ -648,11 +674,11 @@ class="directorist-dom-data directorist-dom-data-<?php echo esc_attr( $data_key } public static function add_shortcode_comment( string $shortcode = '' ) { - echo "<!-- directorist-shortcode:: [ " . esc_attr( $shortcode ) . "] -->"; + echo '<!-- directorist-shortcode:: [ ' . esc_attr( $shortcode ) . '] -->'; } public static function sanitize_query_strings( $url = '' ) { - $matches = []; + $matches = array(); $qs_pattern = '/[?].+/'; $qs = preg_match( $qs_pattern, $url, $matches ); @@ -686,7 +712,7 @@ public static function is_rankmath_active() { */ public static function is_yoast_active() { $yoast_free_is_active = self::is_plugin_active( 'wordpress-seo/wp-seo.php' ); - $yoast_premium_is_active = self::is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ); + $yoast_premium_is_active = self::is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ); return ( $yoast_free_is_active || $yoast_premium_is_active ); } @@ -720,7 +746,7 @@ public static function validate_date_format( $date, $format = 'Y-m-d h:i:s' ) { $d = \DateTime::createFromFormat( $format, $date ); - return $d && $d->format($format) === $date; + return $d && $d->format( $format ) === $date; } /** @@ -730,7 +756,7 @@ public static function validate_date_format( $date, $format = 'Y-m-d h:i:s' ) { * @return string URL */ public static function escape_query_strings_from_url( $url = '' ) { - $matches = []; + $matches = array(); $qs_pattern = '/[?].+/'; $qs = preg_match( $qs_pattern, $url, $matches ); @@ -787,7 +813,7 @@ public static function get_query_strings_from_url( $url = '' ) { } $qs_pattern = self::get_query_string_pattern(); - $matches = []; + $matches = array(); preg_match( $qs_pattern, $url, $matches ); @@ -795,5 +821,4 @@ public static function get_query_strings_from_url( $url = '' ) { return $query_strings; } - } diff --git a/includes/classes/class-add-listing.php b/includes/classes/class-add-listing.php index 6d51b8673f..c3dccdba93 100644 --- a/includes/classes/class-add-listing.php +++ b/includes/classes/class-add-listing.php @@ -287,23 +287,28 @@ public function atbdp_submit_listing() { // // Terms & conditions and privacy policy have been merged in v8. // if ( directorist_should_check_privacy_policy( $directory_id ) && empty( $posted_data['privacy_policy'] ) && directorist_should_check_terms_and_condition( $directory_id ) && empty( $posted_data['t_c_check'] ) ) { - // $error->add( 'terms_and_condition_required', __( 'Terms and condition is required.', 'directorist' ) ); + // $error->add( 'terms_and_condition_required', __( 'Terms and condition is required.', 'directorist' ) ); // } // if ( directorist_should_check_privacy_policy( $directory_id ) && empty( $posted_data['privacy_policy'] ) ) { - // $error->add( 'privacy_policy_required', __( 'Privacy Policy is required.', 'directorist' ) ); + // $error->add( 'privacy_policy_required', __( 'Privacy Policy is required.', 'directorist' ) ); // } if ( $error->has_errors() ) { - return wp_send_json( apply_filters( 'atbdp_listing_form_submission_info', array( - 'error' => true, - 'error_msg' => implode( '<br>', $error->get_error_messages() ), - ) ) ); + return wp_send_json( + apply_filters( + 'atbdp_listing_form_submission_info', + array( + 'error' => true, + 'error_msg' => implode( '<br>', $error->get_error_messages() ), + ) + ) + ); } // Terms & conditions and privacy policy have been merged in v8. if ( ! empty( $posted_data['t_c_check'] ) || ! empty( $posted_data['privacy_policy'] ) ) { - $meta_data['_t_c_check'] = true; + $meta_data['_t_c_check'] = true; $meta_data['_privacy_policy'] = true; } @@ -334,9 +339,9 @@ public function atbdp_submit_listing() { $listing_data['post_status'] = directorist_get_listing_edit_status( $directory_id, $listing_id ); // if ( $preview_enable ) { - // $listing_data['post_status'] = 'private'; + // $listing_data['post_status'] = 'private'; // } else { - // $listing_data['post_status'] = directorist_get_listing_edit_status( $directory_id, $listing_id ); + // $listing_data['post_status'] = directorist_get_listing_edit_status( $directory_id, $listing_id ); // } $listing_id = wp_update_post( $listing_data ); @@ -402,7 +407,7 @@ public function atbdp_submit_listing() { do_action( 'atbdp_after_created_listing', $listing_id ); $data = array( - 'id' => $listing_id + 'id' => $listing_id, ); // handling media files @@ -427,10 +432,12 @@ public function atbdp_submit_listing() { $data['redirect_url'] = ATBDP_Permalink::get_checkout_page_link( $listing_id ); $data['need_payment'] = true; - wp_update_post( array( - 'ID' => $listing_id, - 'post_status' => 'pending', - ) ); + wp_update_post( + array( + 'ID' => $listing_id, + 'post_status' => 'pending', + ) + ); } } @@ -464,11 +471,14 @@ public function atbdp_submit_listing() { wp_send_json( apply_filters( 'atbdp_listing_form_submission_info', $data ) ); - } catch (Exception $e ) { - return wp_send_json( array( - 'error' => true, - 'error_msg' => $e->getMessage(), - ), $e->getCode() ); + } catch ( Exception $e ) { + return wp_send_json( + array( + 'error' => true, + 'error_msg' => $e->getMessage(), + ), + $e->getCode() + ); } } @@ -487,29 +497,33 @@ public static function current_user_can_create() { } public static function filter_empty_meta_data( $meta_data ) { - return array_filter( $meta_data, static function( $value, $key ) { - if ( $key === '_hide_contact_owner' && ! $value ) { - return false; - } + return array_filter( + $meta_data, + static function ( $value, $key ) { + if ( $key === '_hide_contact_owner' && ! $value ) { + return false; + } - if ( is_array( $value ) ) { - return ! empty( $value ); - } + if ( is_array( $value ) ) { + return ! empty( $value ); + } - if ( is_null( $value ) ) { - return false; - } + if ( is_null( $value ) ) { + return false; + } - if ( is_string( $value ) && $value === '' ) { - return false; - } + if ( is_string( $value ) && $value === '' ) { + return false; + } - if ( is_numeric( $value ) && $value == 0 ) { - return false; - } + if ( is_numeric( $value ) && $value == 0 ) { + return false; + } - return true; - }, ARRAY_FILTER_USE_BOTH ); + return true; + }, + ARRAY_FILTER_USE_BOTH + ); } public static function is_admin_only_field( $field ) { @@ -604,7 +618,6 @@ public static function upload_images( $listing_id, $posted_data ) { directorist_background_image_process( $background_processable_images ); } - } catch ( Exception $e ) { error_log( $e->getMessage() ); @@ -750,7 +763,7 @@ public static function process_categories( $field, $posted_data, &$data, $error return; } - $categories = $field->get_value( $posted_data ); + $categories = $field->get_value( $posted_data ); $category_ids = array(); foreach ( $categories as $category ) { @@ -861,7 +874,7 @@ public static function validate_field( $field, $posted_data ) { if ( ! $should_validate ) { return array( 'is_valid' => true, - 'message' => '' + 'message' => '', ); } @@ -873,7 +886,7 @@ public static function validate_field( $field, $posted_data ) { return array( 'is_valid' => ! $field->has_error(), - 'message' => $field->get_error() + 'message' => $field->get_error(), ); } @@ -974,7 +987,7 @@ private function renew_listing( $listing_id ) { $expiry_date = calc_listing_expiry_date(); } else { $old_expiry_date = get_post_meta( $listing_id, '_expiry_date', true ); - $expiry_date = calc_listing_expiry_date( $old_expiry_date, '', $directory_type ); + $expiry_date = calc_listing_expiry_date( $old_expiry_date, '', $directory_type ); } // update related post meta_data @@ -996,8 +1009,7 @@ private function renew_listing( $listing_id ) { wp_safe_redirect( $r_url ); exit; } - } // ends ATBDP_Add_Listing -endif; \ No newline at end of file +endif; diff --git a/includes/classes/class-ajax-handler.php b/includes/classes/class-ajax-handler.php index c85ed0e7ae..49ae159506 100644 --- a/includes/classes/class-ajax-handler.php +++ b/includes/classes/class-ajax-handler.php @@ -1,8 +1,8 @@ <?php defined( 'ABSPATH' ) || die( 'Direct access is not allowed.' ); -use \Directorist\Helper; -use \Directorist\Directorist_All_Authors; +use Directorist\Helper; +use Directorist\Directorist_All_Authors; if ( ! class_exists( 'ATBDP_Ajax_Handler' ) ) : @@ -117,18 +117,17 @@ public function __construct() { add_action( 'wp_ajax_nopriv_directorist_instant_search', array( $this, 'instant_search' ) ); // user verification - add_action('wp_ajax_directorist_send_confirmation_email', [$this, 'send_confirm_email'] ); - add_action('wp_ajax_nopriv_directorist_send_confirmation_email', [$this, 'send_confirm_email'] ); + add_action( 'wp_ajax_directorist_send_confirmation_email', array( $this, 'send_confirm_email' ) ); + add_action( 'wp_ajax_nopriv_directorist_send_confirmation_email', array( $this, 'send_confirm_email' ) ); // zipcode search add_action( 'wp_ajax_directorist_zipcode_search', array( $this, 'zipcode_search' ) ); add_action( 'wp_ajax_nopriv_directorist_zipcode_search', array( $this, 'zipcode_search' ) ); - add_action( 'wp_ajax_directorist_generate_nonce', [ $this, 'handle_generate_nonce' ] ); - - add_action( 'wp_ajax_directorist_taxonomy_pagination', [ $this, 'directorist_taxonomy_pagination' ] ); - add_action( 'wp_ajax_nopriv_directorist_taxonomy_pagination', [ $this, 'directorist_taxonomy_pagination' ] ); + add_action( 'wp_ajax_directorist_generate_nonce', array( $this, 'handle_generate_nonce' ) ); + add_action( 'wp_ajax_directorist_taxonomy_pagination', array( $this, 'directorist_taxonomy_pagination' ) ); + add_action( 'wp_ajax_nopriv_directorist_taxonomy_pagination', array( $this, 'directorist_taxonomy_pagination' ) ); } public function directorist_taxonomy_pagination() { @@ -141,50 +140,58 @@ public function directorist_taxonomy_pagination() { ); } - $page = isset($_REQUEST['page']) ? absint($_REQUEST['page']) : ''; - $atts = !empty( $_REQUEST['attrs'] ) && is_array($_REQUEST['attrs']) ? $_REQUEST['attrs'] : []; - $type = is_array($atts) && isset($atts['type']) ? $atts['type'] : ''; + $page = isset( $_REQUEST['page'] ) ? absint( $_REQUEST['page'] ) : ''; + $atts = ! empty( $_REQUEST['attrs'] ) && is_array( $_REQUEST['attrs'] ) ? $_REQUEST['attrs'] : array(); + $type = is_array( $atts ) && isset( $atts['type'] ) ? $atts['type'] : ''; - $taxonomy = new Directorist\Directorist_Listing_Taxonomy($atts, $type ); - $taxonomy->set_terms($page); + $taxonomy = new Directorist\Directorist_Listing_Taxonomy( $atts, $type ); + $taxonomy->set_terms( $page ); - wp_send_json_success(array('content' => $taxonomy->render_shortcode( $atts ))); + wp_send_json_success( array( 'content' => $taxonomy->render_shortcode( $atts ) ) ); } public function send_confirm_email() { if ( ! check_ajax_referer( 'directorist_nonce', 'directorist_nonce', false ) ) { - wp_send_json_error([ - 'code' => 'invalid_nonce', - 'message' => __( 'Invalid Nonce', 'directorist' ) - ]); + wp_send_json_error( + array( + 'code' => 'invalid_nonce', + 'message' => __( 'Invalid Nonce', 'directorist' ), + ) + ); exit; } if ( ! directorist_is_email_verification_enabled() ) { - wp_send_json_error([ - 'code' => 'invalid_request', - 'message' => __( 'Invalid Request', 'directorist' ) - ]); + wp_send_json_error( + array( + 'code' => 'invalid_request', + 'message' => __( 'Invalid Request', 'directorist' ), + ) + ); exit; } $email = isset( $_REQUEST['user'] ) ? sanitize_email( wp_unslash( $_REQUEST['user'] ) ) : ''; if ( ! is_email( $email ) ) { - wp_send_json_error([ - 'code' => 'invalid_email', - 'message' => __( 'Invalid email address', 'directorist' ) - ]); + wp_send_json_error( + array( + 'code' => 'invalid_email', + 'message' => __( 'Invalid email address', 'directorist' ), + ) + ); exit; } - $user = get_user_by( 'email', $email ); + $user = get_user_by( 'email', $email ); if ( $user instanceof \WP_User && get_user_meta( $user->ID, 'directorist_user_email_unverified', true ) ) { ATBDP()->email->send_user_confirmation_email( $user ); } - $args = ATBDP_Permalink::get_signin_signup_page_link( array( - 'send_verification_email' => true - ) ); + $args = ATBDP_Permalink::get_signin_signup_page_link( + array( + 'send_verification_email' => true, + ) + ); wp_safe_redirect( $args ); exit; @@ -199,20 +206,22 @@ public function zipcode_search() { ); } $google_api = get_directorist_option( 'map_api_key' ); - $zipcode = ! empty( $_POST['zipcode'] ) ? sanitize_text_field( $_POST['zipcode'] ) : ''; - $url = 'https://maps.googleapis.com/maps/api/place/textsearch/json?query=postcode+' . $zipcode . '&key=' . $google_api; - $data = wp_remote_get( $url ); - $response = wp_remote_retrieve_body( $data ); - $json = $response ? json_decode( $response, true ) : array(); - $lat_long = ! empty( $json['results'][0]['geometry']['location'] ) ? directorist_clean( $json['results'][0]['geometry']['location'] ) : array(); - if( ! empty( $lat_long ) ) { + $zipcode = ! empty( $_POST['zipcode'] ) ? sanitize_text_field( $_POST['zipcode'] ) : ''; + $url = 'https://maps.googleapis.com/maps/api/place/textsearch/json?query=postcode+' . $zipcode . '&key=' . $google_api; + $data = wp_remote_get( $url ); + $response = wp_remote_retrieve_body( $data ); + $json = $response ? json_decode( $response, true ) : array(); + $lat_long = ! empty( $json['results'][0]['geometry']['location'] ) ? directorist_clean( $json['results'][0]['geometry']['location'] ) : array(); + if ( ! empty( $lat_long ) ) { wp_send_json( $lat_long ); } else { wp_send_json_error( array( 'error_message' => sprintf( - __( '<div class="error_message">%s <p>%s</p></div>', 'directorist' ), - directorist_icon('fas fa-info-circle', false), __( 'Please enter a valid zip code.', 'directorist' ) ) + __( '<div class="error_message">%1$s <p>%2$s</p></div>', 'directorist' ), + directorist_icon( 'fas fa-info-circle', false ), + __( 'Please enter a valid zip code.', 'directorist' ) + ), ) ); } @@ -236,7 +245,7 @@ public function instant_search() { $args = directorist_clean( (array) wp_unslash( $_POST['data_atts'] ) ); } - if( ! empty( $args['_current_page'] ) && 'search_result' == $args['_current_page'] ) { + if ( ! empty( $args['_current_page'] ) && 'search_result' == $args['_current_page'] ) { $type = 'search_result'; } else { $type = 'instant_search'; @@ -250,7 +259,7 @@ public function instant_search() { $listings = new Directorist\Directorist_Listings( $args, $type ); ob_start(); - if( 'list' === $listings->view ) { + if ( 'list' === $listings->view ) { $listings->render_list_view( $listings->post_ids() ); } else { $listings->render_grid_view( $listings->post_ids() ); @@ -259,26 +268,26 @@ public function instant_search() { ob_start(); $listings->archive_view_template(); - $archive_view = ob_get_clean(); + $archive_view = ob_get_clean(); $display_listings_count = get_directorist_option( 'display_listings_count', true ); - $category_id = ! empty( $_POST['in_cat'] ) ? absint( $_POST['in_cat'] ) : 0; - $category = get_term_by( 'id', $category_id, ATBDP_CATEGORY ); - $location_id = ! empty( $_POST['in_loc'] ) ? absint( $_POST['in_loc'] ) : 0; - $location = get_term_by( 'id', $location_id, ATBDP_LOCATION ); + $category_id = ! empty( $_POST['in_cat'] ) ? absint( $_POST['in_cat'] ) : 0; + $category = get_term_by( 'id', $category_id, ATBDP_CATEGORY ); + $location_id = ! empty( $_POST['in_loc'] ) ? absint( $_POST['in_loc'] ) : 0; + $location = get_term_by( 'id', $location_id, ATBDP_LOCATION ); wp_send_json( array( - 'search_result' => $archive_view, - 'directory_type' => $listings->render_shortcode(), - 'view_as' => $archive_view, - 'count' => $listings->query_results->total, - 'header_title' => $display_listings_count ? $listings->listings_header_title() : '', - 'category_name' => $category ? $category->name : '', - 'location_name' => $location ? $location->name : '', + 'search_result' => $archive_view, + 'directory_type' => $listings->render_shortcode(), + 'view_as' => $archive_view, + 'count' => $listings->query_results->total, + 'header_title' => $display_listings_count ? $listings->listings_header_title() : '', + 'category_name' => $category ? $category->name : '', + 'location_name' => $location ? $location->name : '', 'render_listings' => $render_listings, - 'view' => $listings->view + 'view' => $listings->view, ) ); } @@ -315,11 +324,13 @@ public function directorist_quick_ajax_login() { $password = ! empty( $_POST['password'] ) ? $_POST['password'] : ''; // @codingStandardsIgnoreLine.WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $rememberme = ! empty( $_POST['rememberme'] ) ? boolval( $_POST['rememberme'] ) : false; - $user = wp_signon( array( - 'user_login' => $username, - 'user_password' => $password, - 'remember' => $rememberme, - ) ); + $user = wp_signon( + array( + 'user_login' => $username, + 'user_password' => $password, + 'remember' => $rememberme, + ) + ); if ( is_wp_error( $user ) ) { wp_send_json( @@ -517,36 +528,43 @@ public function category_custom_field_search() { $selector = isset( $selectors[ $listing_layout ] ) ? $selectors[ $listing_layout ] : 'no_sidebar'; $form_type = 'search_result'; } else { - $selector = $selectors['search_home']; + $selector = $selectors['search_home']; $form_type = 'search_form'; } if ( ! empty( $atts ) ) { - $atts = array_filter( $atts, static function( $key ) { - return substr( $key, 0, 7 ) == 'filter_'; - }, ARRAY_FILTER_USE_KEY ); + $atts = array_filter( + $atts, + static function ( $key ) { + return substr( $key, 0, 7 ) == 'filter_'; + }, + ARRAY_FILTER_USE_KEY + ); } $search_form = new \Directorist\Directorist_Listing_Search_Form( $form_type, $directory_id, $atts ); // search form ob_start(); - if ( $form_type === 'search_form' ) : - $search_form->advanced_search_form_fields_template(); - else: ?> + if ( $form_type === 'search_form' ) : + $search_form->advanced_search_form_fields_template(); + else : ?> <input type="hidden" name="directory_type" value="<?php echo esc_attr( $directory_slug ); ?>"> <?php foreach ( $search_form->form_data[1]['fields'] as $field ) : ?> - <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] ) ?>"> + <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] ); ?>"> <?php $search_form->field_template( $field ); ?> </div> - <?php endforeach; + <?php + endforeach; endif; - $markup = ob_get_clean(); + $markup = ob_get_clean(); - wp_send_json( array( - 'search_form' => $markup, - 'container' => $selector, - ) ); + wp_send_json( + array( + 'search_form' => $markup, + 'container' => $selector, + ) + ); } public function atbdp_listing_default_type() { @@ -563,10 +581,12 @@ public function atbdp_listing_default_type() { do_action( 'directorist_before_set_default_directory_type', $default_directory_id, $current_language ); - $directory_types = directorist_get_directories( array( - 'fields' => 'ids', - 'exclude' => $default_directory_id, - ) ); + $directory_types = directorist_get_directories( + array( + 'fields' => 'ids', + 'exclude' => $default_directory_id, + ) + ); if ( ! empty( $directory_types ) || ! is_wp_error( $directory_types ) ) { foreach ( $directory_types as $directory_type ) { @@ -588,7 +608,7 @@ public function directorist_type_slug_change() { if ( ! directorist_verify_nonce() ) { wp_send_json( array( - 'error'=> __( 'Session expired, please reload the window and try again.', 'directorist' ), + 'error' => __( 'Session expired, please reload the window and try again.', 'directorist' ), ) ); } @@ -629,7 +649,7 @@ public function directorist_type_slug_change() { public function ajax_callback_custom_fields() { if ( ! directorist_verify_nonce() ) { - wp_send_json_error( __( 'Invalid request!', 'directorist'), 400 ); + wp_send_json_error( __( 'Invalid request!', 'directorist' ), 400 ); } $directory_id = ! empty( $_POST['directory_id'] ) ? sanitize_text_field( wp_unslash( $_POST['directory_id'] ) ) : 0; @@ -671,7 +691,7 @@ public function ajax_callback_custom_fields() { \Directorist\Directorist_Listing_Form::instance()->add_listing_category_custom_field_template( $field_properties, $listing_id ); - $result[ $field_key ]= ob_get_clean(); + $result[ $field_key ] = ob_get_clean(); } } @@ -694,7 +714,7 @@ public function guest_reception() { $data = array( 'status' => false, 'status_code' => 'nonce_varification_failed', - 'message' => __('The session has expired, please reload and try again.', 'directorist' ), + 'message' => __( 'The session has expired, please reload and try again.', 'directorist' ), 'data' => array( 'error_log' => $error_log, ), @@ -825,7 +845,7 @@ public function atbdp_ajax_login() { echo json_encode( array( 'loggedin' => false, - 'message' => $user_signon->get_error_message() + 'message' => $user_signon->get_error_message(), ) ); } else { @@ -1031,7 +1051,7 @@ public function update_user_profile() { if ( ! empty( $_POST['user'] ) ) { if ( ! empty( $_POST['profile_picture_meta'] ) && count( $_POST['profile_picture_meta'] ) ) { - $meta_data = ( ! empty( $_POST['profile_picture_meta'][0] ) ) ? directorist_clean( wp_unslash( $_POST['profile_picture_meta'][0] ) ) : []; + $meta_data = ( ! empty( $_POST['profile_picture_meta'][0] ) ) ? directorist_clean( wp_unslash( $_POST['profile_picture_meta'][0] ) ) : array(); if ( 'true' !== $meta_data['oldFile'] ) { foreach ( $_FILES as $file => $array ) { @@ -1054,7 +1074,6 @@ public function update_user_profile() { } wp_send_json_error( array( 'message' => __( 'Ops! something went wrong. Try again.', 'directorist' ) ) ); - } public function update_user_preferences() { @@ -1070,9 +1089,9 @@ public function update_user_preferences() { wp_send_json_error( array( 'message' => __( 'Ops! something went wrong. Try again.', 'directorist' ) ) ); } - $hide_contact_form = isset( $_POST['directorist_hide_contact_form'] ) ? sanitize_text_field( $_POST['directorist_hide_contact_form'] ) : 'no'; - $display_author_email = isset( $_POST['directorist_display_author_email'] ) ? sanitize_text_field( $_POST['directorist_display_author_email'] ) : ''; - $contact_owner_recipient = isset( $_POST['directorist_contact_owner_recipient'] ) ? sanitize_text_field( $_POST['directorist_contact_owner_recipient'] ) : ''; + $hide_contact_form = isset( $_POST['directorist_hide_contact_form'] ) ? sanitize_text_field( $_POST['directorist_hide_contact_form'] ) : 'no'; + $display_author_email = isset( $_POST['directorist_display_author_email'] ) ? sanitize_text_field( $_POST['directorist_display_author_email'] ) : ''; + $contact_owner_recipient = isset( $_POST['directorist_contact_owner_recipient'] ) ? sanitize_text_field( $_POST['directorist_contact_owner_recipient'] ) : ''; // Save the sanitized value to user meta if ( ! empty( $hide_contact_form ) ) { @@ -1083,13 +1102,12 @@ public function update_user_preferences() { update_user_meta( $user_id, 'directorist_display_author_email', $display_author_email ); } - if( ! empty( $contact_owner_recipient ) ) { + if ( ! empty( $contact_owner_recipient ) ) { update_user_meta( $user_id, 'directorist_contact_owner_recipient', $contact_owner_recipient ); } // Return a success message wp_send_json_success( array( 'message' => __( 'Preferences updated successfully.', 'directorist' ) ) ); - } private function insert_attachment( $file_handler, $post_id, $setthumb = 'false' ) { @@ -1434,7 +1452,7 @@ function atbdp_email_listing_owner_listing_contact() { $name = ( ! empty( $_POST['atbdp-contact-name'] ) ) ? sanitize_text_field( wp_unslash( $_POST['atbdp-contact-name'] ) ) : ''; $email = ! empty( $_POST['atbdp-contact-email'] ) ? sanitize_email( wp_unslash( $_POST['atbdp-contact-email'] ) ) : ''; $listing_email = get_post_meta( $post_id, '_email', true ); - $message = ( ! empty( $_POST['atbdp-contact-message'] ) ) ? stripslashes( sanitize_textarea_field( wp_unslash( $_POST['atbdp-contact-message'] ) ) ) : ''; + $message = ( ! empty( $_POST['atbdp-contact-message'] ) ) ? stripslashes( sanitize_textarea_field( wp_unslash( $_POST['atbdp-contact-message'] ) ) ) : ''; // vars $post_author_id = get_post_field( 'post_author', $post_id ); $user = get_userdata( $post_author_id ); @@ -1448,7 +1466,7 @@ function atbdp_email_listing_owner_listing_contact() { $current_time = current_time( 'timestamp' ); $contact_email_subject = get_directorist_option( 'email_sub_listing_contact_email' ); $contact_email_body = get_directorist_option( 'email_tmpl_listing_contact_email' ); - $contact_recipient = get_user_meta( $post_author_id, 'directorist_contact_owner_recipient', true ); + $contact_recipient = get_user_meta( $post_author_id, 'directorist_contact_owner_recipient', true ); $user_email = ! empty( $contact_recipient ) ? $contact_recipient : 'author'; $placeholders = array( @@ -1471,11 +1489,16 @@ function atbdp_email_listing_owner_listing_contact() { } else { $to = $user->user_email; } - $subject = strtr( $contact_email_subject, $placeholders ); - $message = strtr( $contact_email_body, $placeholders ); - $message = nl2br( $message ); - $headers = ATBDP()->email->get_email_headers( [ 'name' => $name, 'email' => $email ] ); - $message = atbdp_email_html( $subject, $message ); + $subject = strtr( $contact_email_subject, $placeholders ); + $message = strtr( $contact_email_body, $placeholders ); + $message = nl2br( $message ); + $headers = ATBDP()->email->get_email_headers( + array( + 'name' => $name, + 'email' => $email, + ) + ); + $message = atbdp_email_html( $subject, $message ); // return true or false, based on the result $is_sent = ATBDP()->email->send_mail( $to, $subject, $message, $headers ) ? true : false; @@ -1591,10 +1614,13 @@ function atbdp_email_admin_listing_contact() { */ public function ajax_callback_send_contact_email() { if ( ! directorist_verify_nonce() ) { - wp_send_json( [ - 'error' => 1, - 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ) - ], 200 ); + wp_send_json( + array( + 'error' => 1, + 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ), + ), + 200 + ); } /** @@ -1606,14 +1632,14 @@ public function ajax_callback_send_contact_email() { $disable_all_email = get_directorist_option( 'disable_email_notification' ); - $error_response = [ - 'error' => 1, - 'message' => __( 'Sorry! Please try again.', 'directorist' ) - ]; + $error_response = array( + 'error' => 1, + 'message' => __( 'Sorry! Please try again.', 'directorist' ), + ); // is admin disabled all the notification if ( $disable_all_email ) { - echo wp_json_encode($error_response); + echo wp_json_encode( $error_response ); die(); } @@ -1622,7 +1648,7 @@ public function ajax_callback_send_contact_email() { // is admin disabled both notification if ( ! $sendOwner && ! $sendAdmin ) { - echo wp_json_encode($error_response); + echo wp_json_encode( $error_response ); die(); } @@ -1630,7 +1656,7 @@ public function ajax_callback_send_contact_email() { if ( $sendOwner ) { $send_to_owner = $this->atbdp_email_listing_owner_listing_contact(); if ( ! $send_to_owner ) { - echo wp_json_encode($error_response); + echo wp_json_encode( $error_response ); die(); } } @@ -1638,7 +1664,7 @@ public function ajax_callback_send_contact_email() { if ( $sendAdmin ) { $send_to_admin = $this->atbdp_email_admin_listing_contact(); if ( ! $send_to_admin ) { - echo wp_json_encode($error_response); + echo wp_json_encode( $error_response ); die(); } } @@ -1650,10 +1676,12 @@ public function ajax_callback_send_contact_email() { */ do_action( 'atbdp_listing_contact_owner_submitted' ); - echo wp_json_encode( [ - 'error' => 1, - 'message' => __( 'Your message sent successfully.', 'directorist' ) - ] ); + echo wp_json_encode( + array( + 'error' => 1, + 'message' => __( 'Your message sent successfully.', 'directorist' ), + ) + ); die(); } @@ -1728,7 +1756,7 @@ public function custom_field_search( $term_id = 0 ) { 'name' => 'atbdp_custom_fields', 'query_args' => $args, 'cache' => apply_filters( 'atbdp_cache_custom_fields', true ), - 'value' => function( $data ) { + 'value' => function ( $data ) { return get_posts( $data['query_args'] ); }, ) @@ -1746,12 +1774,14 @@ public function custom_field_search( $term_id = 0 ) { public function handle_generate_nonce() { // Ensure the user is logged in if ( ! is_user_logged_in() ) { - wp_send_json_error( [ 'message' => __( 'User not logged in.', 'directorist' ) ] ); + wp_send_json_error( array( 'message' => __( 'User not logged in.', 'directorist' ) ) ); } - wp_send_json_success( [ - 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ) - ] ); + wp_send_json_success( + array( + 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ), + ) + ); } } diff --git a/includes/classes/class-announcement.php b/includes/classes/class-announcement.php index 9c39e9c80b..58869006ef 100644 --- a/includes/classes/class-announcement.php +++ b/includes/classes/class-announcement.php @@ -22,7 +22,6 @@ public function __construct() { add_action( 'wp_ajax_atbdp_close_announcement', array( $this, 'close_announcement' ) ); add_action( 'wp_ajax_atbdp_get_new_announcement_count', array( $this, 'response_new_announcement_count' ) ); add_action( 'wp_ajax_atbdp_clear_seen_announcements', array( $this, 'clear_seen_announcements' ) ); - } public function non_legacy_add_dashboard_nav_link() { @@ -99,7 +98,7 @@ public function non_legacy_add_dashboard_nav_content() { $recipient = get_post_meta( get_the_ID(), '_recepents', true ); if ( ! empty( $recipient ) && is_array( $recipient ) ) { if ( ! in_array( $current_user_email, $recipient ) ) { - $skipped_post_count++; + ++$skipped_post_count; continue; } } @@ -234,7 +233,7 @@ public function get_new_announcement_count() { $recipient = get_post_meta( get_the_ID(), '_recepents', true ); if ( ! empty( $recipient ) && is_array( $recipient ) ) { if ( ! in_array( $current_user_email, $recipient ) ) { - $skipped_post_count++; + ++$skipped_post_count; continue; } } @@ -316,7 +315,7 @@ public function add_dashboard_nav_content() { $recipient = get_post_meta( get_the_ID(), '_recepents', true ); if ( ! empty( $recipient ) && is_array( $recipient ) ) { if ( ! in_array( $current_user_email, $recipient ) ) { - $skipped_post_count++; + ++$skipped_post_count; continue; } } @@ -378,11 +377,11 @@ private function get_all_user_emails() { return array_filter( $result ); } - $number_of_loops = ceil( $total/$number ); + $number_of_loops = ceil( $total / $number ); // Run subsequent queries - for ( $i = 2; $i <= $number_of_loops ; $i++ ) { - $args = array( + for ( $i = 2; $i <= $number_of_loops; $i++ ) { + $args = array( 'role__not_in' => 'Administrator', 'fields' => 'user_email', 'paged' => $i, diff --git a/includes/classes/class-cache-helper.php b/includes/classes/class-cache-helper.php index 1e7fdaa846..ff9b764678 100644 --- a/includes/classes/class-cache-helper.php +++ b/includes/classes/class-cache-helper.php @@ -19,7 +19,6 @@ class ATBDP_Cache_Helper { * @param boolean $refresh true to force a new version. * @return string transient version based on time(), 10 digits. */ - public static function get_transient_version( $group, $refresh = false ) { $transient_name = $group . '-transient-version'; $transient_value = get_transient( $transient_name ); diff --git a/includes/classes/class-cron.php b/includes/classes/class-cron.php index a783528110..d0bce27adf 100644 --- a/includes/classes/class-cron.php +++ b/includes/classes/class-cron.php @@ -46,7 +46,6 @@ function update_atbdp_schedule_tasks( $post_id, $post ) { /** * @since 5.0.1 */ - public function atbdp_cron_init( $schedules ) { $schedules['atbdp_listing_manage'] = apply_filters( 'atbdp_cron_setup_args', @@ -93,12 +92,11 @@ public function atbdp_custom_schedule_cron() { } } - /** - * Move featured listing to general - * - * @since 6.6.6 - */ - + /** + * Move featured listing to general + * + * @since 6.6.6 + */ private function featured_listing_followup() { if ( directorist_is_monetization_enabled() && directorist_is_featured_listing_enabled() ) { $featured_days = get_directorist_option( 'featured_listing_time', 30 ); @@ -181,17 +179,17 @@ private function update_renewal_status() { 'cache_results' => false, 'nopaging' => true, 'meta_query' => array( - 'relation' => 'AND', + 'relation' => 'AND', 'renewal_status' => array( - 'key' => '_listing_status', - 'value' => 'renewal', + 'key' => '_listing_status', + 'value' => 'renewal', 'compare' => '!=', ), - 'never_expire' => array( + 'never_expire' => array( 'key' => '_never_expire', 'compare' => 'NOT EXISTS', ), - 'expiry_date' => array( + 'expiry_date' => array( 'key' => '_expiry_date', 'value' => $renew_email_threshold_date, 'compare' => '<=', @@ -225,7 +223,7 @@ private function update_expired_status() { $delete_in_days = (int) get_directorist_option( 'delete_expired_listings_after' ); $del_exp_l = get_directorist_option( 'delete_expired_listing' ); // add renewal reminder days to deletion thresholds - $delete_threshold = directorist_can_user_renew_listings() ? ( $email_renewal_day + $delete_in_days ) : $delete_in_days; + $delete_threshold = directorist_can_user_renew_listings() ? ( $email_renewal_day + $delete_in_days ) : $delete_in_days; // Define the query $args = array( @@ -235,12 +233,12 @@ private function update_expired_status() { 'nopaging' => true, 'post_status' => 'publish', // get expired post with published status 'meta_query' => array( - 'relation' => 'AND', + 'relation' => 'AND', 'never_expire' => array( 'key' => '_never_expire', 'compare' => 'NOT EXISTS', ), - 'expiry_date' => array( + 'expiry_date' => array( 'key' => '_expiry_date', 'value' => current_time( 'mysql' ), 'compare' => '<=', // eg. expire date 6 <= current date 7 will return the post @@ -260,7 +258,7 @@ private function update_expired_status() { '_featured' => 0, '_renewal_reminder_sent' => 0, ); - + // if deletion threshold is set then add deletion date if ( $delete_threshold > 0 ) { $metas['_deletion_date'] = date( 'Y-m-d H:i:s', strtotime( '+' . $delete_threshold . ' days' ) ); @@ -291,48 +289,48 @@ private function update_expired_listing_status() { // TODO: Status has been migrated, remove related code. // // Define the query // $args = array( - // 'post_type' => ATBDP_POST_TYPE, - // 'posts_per_page' => -1, - // 'post_status' => 'publish', // get expired post with published status + // 'post_type' => ATBDP_POST_TYPE, + // 'posts_per_page' => -1, + // 'post_status' => 'publish', // get expired post with published status + // ); + // $meta = array(); + // $meta['renewed_by_admin'] = array( + // 'relation' => 'OR', + // array( + // 'key' => '_expiry_date', + // 'value' => current_time( 'mysql' ), + // 'compare' => '>', // eg. expire date 6 <= current date 7 will return the post + // 'type' => 'DATETIME', + // ), + // array( + // 'key' => '_never_expire', + // 'value' => 1, + // ), + // ); + // $meta['get_expired'] = array( + // 'key' => '_listing_status', + // 'value' => 'expired', + // 'compare' => '=', + // ); + + // $args['meta_query'] = array_merge( array( 'relation' => 'AND' ), $meta ); + // $listings = new WP_Query( $args ); + // if ( $listings->found_posts ) { + // foreach ( $listings->posts as $listing ) { + // prepare the post meta data + // $metas = array( + // '_listing_status' => 'post_status', + // '_renewal_reminder_sent' => 0, + // ); + // wp_update_post( + // array( + // 'ID' => $listing->ID, + // 'post_status' => 'publish', // update the status to private so that we do not run this func a second time + // 'meta_input' => $metas, // insert all meta data once to reduce update meta query + // ) // ); - // $meta = array(); - // $meta['renewed_by_admin'] = array( - // 'relation' => 'OR', - // array( - // 'key' => '_expiry_date', - // 'value' => current_time( 'mysql' ), - // 'compare' => '>', // eg. expire date 6 <= current date 7 will return the post - // 'type' => 'DATETIME', - // ), - // array( - // 'key' => '_never_expire', - // 'value' => 1, - // ), - // ); - // $meta['get_expired'] = array( - // 'key' => '_listing_status', - // 'value' => 'expired', - // 'compare' => '=', - // ); - - // $args['meta_query'] = array_merge( array( 'relation' => 'AND' ), $meta ); - // $listings = new WP_Query( $args ); - // if ( $listings->found_posts ) { - // foreach ( $listings->posts as $listing ) { - // // prepare the post meta data - // $metas = array( - // '_listing_status' => 'post_status', - // '_renewal_reminder_sent' => 0, - // ); - // wp_update_post( - // array( - // 'ID' => $listing->ID, - // 'post_status' => 'publish', // update the status to private so that we do not run this func a second time - // 'meta_input' => $metas, // insert all meta data once to reduce update meta query - // ) - // ); - // } - // } + // } + // } $args = array( 'post_type' => ATBDP_POST_TYPE, @@ -340,33 +338,35 @@ private function update_expired_listing_status() { 'post_status' => 'expired', 'cache_results' => false, 'nopaging' => true, - 'meta_query' => array( - 'relation' => 'OR', + 'meta_query' => array( + 'relation' => 'OR', 'never_expire' => array( 'key' => '_never_expire', 'compare' => 'EXISTS', ), - 'expiry_date' => array( + 'expiry_date' => array( 'key' => '_expiry_date', 'value' => current_time( 'mysql' ), 'compare' => '>', // eg. expire date 6 <= current date 7 will return the post 'type' => 'DATETIME', ), - ) + ), ); $listings = new WP_Query( $args ); if ( $listings->have_posts() ) { foreach ( $listings->posts as $listing ) { - wp_update_post( array( - 'ID' => $listing->ID, - 'post_status' => 'publish', - 'meta_input' => array( - '_listing_status' => 'post_status', - '_renewal_reminder_sent' => 0, - ), - ) ); + wp_update_post( + array( + 'ID' => $listing->ID, + 'post_status' => 'publish', + 'meta_input' => array( + '_listing_status' => 'post_status', + '_renewal_reminder_sent' => 0, + ), + ) + ); do_action( 'atbdp_after_renewal', $listing->ID ); } } @@ -390,13 +390,13 @@ private function send_renewal_reminders() { 'nopaging' => true, 'post_status' => 'expired', 'meta_query' => array( - 'relation' => 'AND', + 'relation' => 'AND', // TODO: Status has been migrated, remove related code. // array( - // 'key' => '_listing_status', - // 'value' => 'expired', + // 'key' => '_listing_status', + // 'value' => 'expired', // ), - 'never_expire' => array( + 'never_expire' => array( 'key' => '_never_expire', 'compare' => 'NOT EXISTS', ), @@ -445,13 +445,13 @@ private function delete_expired_listings() { 'nopaging' => true, 'post_status' => 'expired', 'meta_query' => array( - 'relation' => 'AND', + 'relation' => 'AND', // TODO: Status has been migrated, remove related code. // array( - // 'key' => '_listing_status', - // 'value' => 'expired', + // 'key' => '_listing_status', + // 'value' => 'expired', // ), - 'never_expire' => array( + 'never_expire' => array( 'key' => '_never_expire', 'compare' => 'NOT EXISTS', ), diff --git a/includes/classes/class-custom-post.php b/includes/classes/class-custom-post.php index 37c0cf8d31..3898c08bda 100644 --- a/includes/classes/class-custom-post.php +++ b/includes/classes/class-custom-post.php @@ -93,7 +93,7 @@ public function quick_edit_scripts() { $directory_select.val( $selected_option[0].value ); } - // Set the value of the "View Count" input field + // Set the value of the "View Count" input field if ( view_count !== '' ) { $view_count_input.val( view_count ); } @@ -163,7 +163,8 @@ public static function on_quick_or_bulk_edit_custom_box( $column_name, $post_typ return; } - if ( 'directory_type' === $column_name ) : ?> + if ( 'directory_type' === $column_name ) : + ?> <fieldset class="inline-edit-col-right" style="margin-top: 0;"> <div class="inline-edit-group wp-clearfix"> <?php wp_nonce_field( directorist_get_nonce_key(), 'directorist_nonce' ); ?> @@ -174,7 +175,8 @@ public static function on_quick_or_bulk_edit_custom_box( $column_name, $post_typ <?php $listing_types = directorist_get_directories(); - foreach ( $listing_types as $listing_type ) { ?> + foreach ( $listing_types as $listing_type ) { + ?> <option value="<?php echo esc_attr( $listing_type->term_id ); ?>"><?php echo esc_html( $listing_type->name ); ?></option> <?php } ?> </select> @@ -185,7 +187,8 @@ public static function on_quick_or_bulk_edit_custom_box( $column_name, $post_typ <?php - if ( 'directorist_listing_view_count' === $column_name ) : ?> + if ( 'directorist_listing_view_count' === $column_name ) : + ?> <fieldset class="inline-edit-col-right"> <div class="inline-edit-group wp-clearfix"> <label class="inline-edit-directorist-listing-view-count alignleft"> @@ -194,12 +197,13 @@ public static function on_quick_or_bulk_edit_custom_box( $column_name, $post_typ </label> </div> </fieldset> - <?php endif; + <?php + endif; } public function add_cpt_to_pll( $post_types, $hide ) { /* - echo '<pre>'; + echo '<pre>'; var_dump($post_types); echo '</pre>';*/ @@ -380,9 +384,9 @@ public function add_new_listing_columns( $columns ) { $columns['atbdp_featured'] = __( 'Featured', 'directorist' ); } - $columns['directorist_listing_view_count'] = '<span class="screen-reader-text">' . esc_html__( 'Listing views', 'directorist' ) .'</span><span aria-hidden="true" class="dashicons dashicons-visibility"></span>'; + $columns['directorist_listing_view_count'] = '<span class="screen-reader-text">' . esc_html__( 'Listing views', 'directorist' ) . '</span><span aria-hidden="true" class="dashicons dashicons-visibility"></span>'; - $columns['atbdp_date'] = __( 'Date', 'directorist' ); + $columns['atbdp_date'] = __( 'Date', 'directorist' ); return apply_filters( 'atbdp_add_new_listing_column', $columns ); } @@ -470,7 +474,7 @@ public function manage_listing_columns( $column_name, $post_id ) { case 'atbdp_date': $creation_time = get_the_time( 'U' ); - $created_date = date_i18n( $date_format, $creation_time ); + $created_date = date_i18n( $date_format, $creation_time ); $never_expire = get_post_meta( $post_id, '_never_expire', true ); $expiry_date = ''; diff --git a/includes/classes/class-custom-taxonomy.php b/includes/classes/class-custom-taxonomy.php index 6c0d4fc85b..2887f743a1 100644 --- a/includes/classes/class-custom-taxonomy.php +++ b/includes/classes/class-custom-taxonomy.php @@ -49,7 +49,6 @@ public function __construct() { add_action( 'template_redirect', array( $this, 'atbdp_template_redirect' ) ); add_action( 'wp_loaded', array( $this, 'directorist_bulk_term_update' ) ); - } @@ -86,14 +85,12 @@ public function directorist_bulk_term_update() { update_term_meta( $data->term_id, '_directory_type', array( $id ) ); } } - } else { - if ( ! is_numeric( $old_data ) ) { + } elseif ( ! is_numeric( $old_data ) ) { $term_with_directory_slug = get_term_by( 'slug', $old_data, 'atbdp_listing_types' ); $id = $term_with_directory_slug->term_id; update_term_meta( $data->term_id, '_directory_type', array( $id ) ); - } else { - update_term_meta( $data->term_id, '_directory_type', array( $old_data ) ); - } + } else { + update_term_meta( $data->term_id, '_directory_type', array( $old_data ) ); } } else { update_term_meta( $data->term_id, '_directory_type', array( default_directory_type() ) ); @@ -262,7 +259,7 @@ public function edit_category_form_fields( $term, $taxonomy ) { $icon_name = get_term_meta( $term->term_id, 'category_icon', true ); $selected_directory_types = (array) get_term_meta( $term->term_id, '_directory_type', true ); $directory_types = directorist_get_directories(); - $default_listing_type = $this->default_listing_type(); + $default_listing_type = $this->default_listing_type(); if ( ! $default_listing_type ) { ?> <tr class="form-field term-group-wrap"> @@ -289,9 +286,9 @@ public function edit_category_form_fields( $term, $taxonomy ) { <tr class="form-field term-group-wrap"> <th scope="row"><label for="category_icon"><?php esc_html_e( 'Category Icon', 'directorist' ); ?></label></th> <td> - <div class="directorist-category-icon-picker"></div> - <input type="hidden" class="category_icon_value" value="<?php echo esc_attr( $icon_name ); ?>" name="category_icon"> - </td> + <div class="directorist-category-icon-picker"></div> + <input type="hidden" class="category_icon_value" value="<?php echo esc_attr( $icon_name ); ?>" name="category_icon"> + </td> </tr> <?php // get current cat image @@ -328,7 +325,8 @@ public function edit_location_form_fields( $term, $taxonomy ) { $image_src = ( $image_id ) ? wp_get_attachment_url( (int) $image_id ) : ''; $directory_types = directorist_get_directories(); $default_listing_type = $this->default_listing_type(); - if ( ! $default_listing_type ) { ?> + if ( ! $default_listing_type ) { + ?> <tr class="form-field term-group-wrap"> <th scope="row"><label for="category_icon"><?php esc_html_e( 'Directory Type', 'directorist' ); ?></label></th> <td> @@ -364,7 +362,7 @@ public function edit_location_form_fields( $term, $taxonomy ) { </div> <p> <input type="button" class="button button-secondary" id="atbdp-categories-upload-image" - value="<?php esc_html_e( 'Add Image', 'directorist' ); ?>"/> + value="<?php esc_html_e( 'Add Image', 'directorist' ); ?>"/> </p> </td> </tr> @@ -436,7 +434,7 @@ public function add_category_form_fields( $taxonomy ) { <div class="form-field term-group"> <label for="category_icon"><?php esc_html_e( 'Category Icon', 'directorist' ); ?></label> <div class="directorist-category-icon-picker"></div> - <input type="hidden" class="category_icon_value" value="" name="category_icon"> + <input type="hidden" class="category_icon_value" value="" name="category_icon"> </div> <div class="form-field term-group"> <label for="atbdp-categories-image-id"><?php esc_html_e( 'Image', 'directorist' ); ?></label> @@ -444,7 +442,7 @@ public function add_category_form_fields( $taxonomy ) { <div id="atbdp-categories-image-wrapper"></div> <p> <input type="button" class="button button-secondary" id="atbdp-categories-upload-image" - value="<?php esc_attr_e( 'Add Image', 'directorist' ); ?>"/> + value="<?php esc_attr_e( 'Add Image', 'directorist' ); ?>"/> </p> </div> <?php @@ -480,7 +478,7 @@ public function add_location_form_fields( $taxonomy ) { <div id="atbdp-categories-image-wrapper"></div> <p> <input type="button" class="button button-secondary" id="atbdp-categories-upload-image" - value="<?php esc_html_e( 'Add Image', 'directorist' ); ?>"/> + value="<?php esc_html_e( 'Add Image', 'directorist' ); ?>"/> </p> </div> <?php @@ -586,7 +584,7 @@ protected function register_tag() { 'menu_name' => __( 'Tags', 'directorist' ), ); - $args = array( + $args = array( 'hierarchical' => false, 'labels' => $labels, 'show_ui' => true, @@ -614,7 +612,7 @@ public function category_columns( $original_columns ) { $new_columns = $original_columns; array_splice( $new_columns, 1 ); // in this way we could place our columns on the first place after the first checkbox. - $new_columns['ID'] = __( 'ID', 'directorist' ); + $new_columns['ID'] = __( 'ID', 'directorist' ); $new_columns['atbdp_category_icon'] = __( 'Icon', 'directorist' ); if ( directorist_is_multi_directory_enabled() ) { @@ -651,7 +649,7 @@ public function category_rows( $empty_string, $column_name, $term_id ) { $directory_type = is_array( $directory_type ) ? $directory_type : array( $directory_type ); /* - $icon_type = array(); + $icon_type = array(); if (!empty($icon)){ $icon_type = explode('-', $icon); } @@ -772,7 +770,6 @@ public function get_one_high_level_term( $post_id, $taxonomoy = 'category' ) { } } return false; - } /** @@ -808,7 +805,6 @@ public function get_one_deepest_level_term( $post_id, $taxonomy = 'category' ) { } } return false; - } public function get_listing_types() { diff --git a/includes/classes/class-database.php b/includes/classes/class-database.php index 0090a2483b..d7d37e40b7 100644 --- a/includes/classes/class-database.php +++ b/includes/classes/class-database.php @@ -95,7 +95,6 @@ public function get( $row_id ) { public function get_all( $limit = -1 ) { global $wpdb; return $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE 1=1 LIMIT %d;", $limit ) ); - } @@ -172,7 +171,7 @@ public function insert( $data, $type = '' ) { $data = array_intersect_key( $data, $column_formats ); // Reorder $column_formats to match the order of columns given in $data - $data_keys = array_keys( $data ); + $data_keys = array_keys( $data ); $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); $wpdb->insert( $this->table_name, $data, $column_formats ); @@ -215,7 +214,7 @@ public function update( $row_id, $data = array(), $where = '' ) { $data = array_intersect_key( $data, $column_formats ); // Reorder $column_formats to match the order of columns given in $data - $data_keys = array_keys( $data ); + $data_keys = array_keys( $data ); $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { diff --git a/includes/classes/class-directorist-api.php b/includes/classes/class-directorist-api.php index 87f1f14112..1763ae9a8d 100644 --- a/includes/classes/class-directorist-api.php +++ b/includes/classes/class-directorist-api.php @@ -22,7 +22,7 @@ public static function get_promotion() { return $promotion; } - $promotion = static::get( 'v1/get-promo' ); + $promotion = static::get( 'v1/get-promo' ); $promotion = json_decode( $promotion ); $end_time = static::get_promotion_end_time( $promotion ); @@ -59,7 +59,7 @@ public static function get_products() { if ( empty( $products ) ) { return array( - 'themes' => array(), + 'themes' => array(), 'extensions' => array(), ); } @@ -92,7 +92,7 @@ protected static function get_request_args() { * @return string */ public static function get( $endpoint = '' ) { - $url = static::URL . $endpoint; + $url = static::URL . $endpoint; $response = wp_remote_get( $url, static::get_request_args() ); return wp_remote_retrieve_body( $response ); diff --git a/includes/classes/class-email.php b/includes/classes/class-email.php index e9033619c8..501e0c7f7a 100644 --- a/includes/classes/class-email.php +++ b/includes/classes/class-email.php @@ -64,9 +64,9 @@ public function send_email_after_listing_updated( $listing_id ) { } } - /** - * @since 5.8 - */ + /** + * @since 5.8 + */ public function atbdp_wp_mail_from_name() { $site_name = get_option( 'blogname' ); return $site_name; @@ -99,24 +99,22 @@ public function replace_in_content( $content, $order_id = 0, $listing_id = 0, $u } if ( empty( $user ) ) { $post_author_id = get_post_field( 'post_author', $listing_id ? $listing_id : $order_id ); - $user = get_userdata( $post_author_id ); - } else { - if ( ! $user instanceof WP_User ) { + $user = get_userdata( $post_author_id ); + } elseif ( ! $user instanceof WP_User ) { $user = get_userdata( (int) $user ); - } } - $user_password = $user ? get_user_meta( $user->ID, '_atbdp_generated_password', true ) : ''; - $site_name = get_option( 'blogname' ); - $site_url = site_url(); - $l_title = get_the_title( $listing_id ); - $listing_url = get_permalink( $listing_id ); - $l_edit_url = admin_url( "post.php?post={$listing_id}&action=edit" ); + $user_password = $user ? get_user_meta( $user->ID, '_atbdp_generated_password', true ) : ''; + $site_name = get_option( 'blogname' ); + $site_url = site_url(); + $l_title = get_the_title( $listing_id ); + $listing_url = get_permalink( $listing_id ); + $l_edit_url = admin_url( "post.php?post={$listing_id}&action=edit" ); $user_dashboard = admin_url( 'users.php' ); - $date_format = get_option( 'date_format' ); - $time_format = get_option( 'time_format' ); - $current_time = current_time( 'timestamp' ); - $exp_date = get_post_meta( $listing_id, '_expiry_date', true ); - $never_exp = get_post_meta( $listing_id, '_never_expire', true ); + $date_format = get_option( 'date_format' ); + $time_format = get_option( 'time_format' ); + $current_time = current_time( 'timestamp' ); + $exp_date = get_post_meta( $listing_id, '_expiry_date', true ); + $never_exp = get_post_meta( $listing_id, '_never_expire', true ); if ( $renewal ) { $token = 'cB0XtpVzGb180dgPi3hADW-' . $listing_id; update_post_meta( $listing_id, '_renewal_token', $token ); @@ -124,41 +122,40 @@ public function replace_in_content( $content, $order_id = 0, $listing_id = 0, $u } else { $renewal_link = ATBDP_Permalink::get_renewal_page_link( $listing_id ); } - $dashboard_link = ATBDP_Permalink::get_dashboard_page_link(); + $dashboard_link = ATBDP_Permalink::get_dashboard_page_link(); $order_receipt_link = ATBDP_Permalink::get_payment_receipt_page_link( $order_id ); - $cats = wp_get_object_terms( $listing_id, ATBDP_CATEGORY, array( 'fields' => 'names' ) );/*@todo, maybe we can use get_the_terms() for utilizing some default caching???*/ - $cat_name = ! empty( $cats ) ? $cats[0] : '';/*@todo; if a listing is attached to multiple cats, we can print more than one cat later.*/ + $cats = wp_get_object_terms( $listing_id, ATBDP_CATEGORY, array( 'fields' => 'names' ) );/*@todo, maybe we can use get_the_terms() for utilizing some default caching???*/ + $cat_name = ! empty( $cats ) ? $cats[0] : '';/*@todo; if a listing is attached to multiple cats, we can print more than one cat later.*/ $find_replace = array( - '==NAME==' => ! empty( $user->display_name ) ? $user->display_name : '', - '==USERNAME==' => ! empty( $user->user_login ) ? $user->user_login : '', - '==SITE_NAME==' => $site_name, - '==SITE_LINK==' => sprintf( '<a href="%s">%s</a>', $site_url, $site_name ), - '==SITE_URL==' => sprintf( '<a href="%s">%s</a>', $site_url, $site_url ), - '==EXPIRATION_DATE==' => ! empty( $never_exp ) ? __( 'Never Expires', 'directorist' ) : date_i18n( $date_format, strtotime( $exp_date ) ), - '==CATEGORY_NAME==' => $cat_name, - '==RENEWAL_LINK==' => sprintf( '<a href="%s">%s</a>', $renewal_link, __( 'Visit Listing Renewal Page', 'directorist' ) ), - '==LISTING_ID==' => $listing_id, - '==LISTING_TITLE==' => $l_title, - '==LISTING_EDIT_URL==' => sprintf( '<a href="%s">%s</a>', $l_edit_url, $l_title ), - '==LISTING_LINK==' => sprintf( '<a href="%s">%s</a>', $listing_url, $l_title ), - '==LISTING_URL==' => sprintf( '<a href="%s">%s</a>', $listing_url, $listing_url ), - '==ORDER_ID==' => $order_id, - '==ORDER_RECEIPT_URL==' => sprintf( '<a href="%s">%s</a>', $order_receipt_link, __( 'View Order/Payment Receipt', 'directorist' ) ), - // '==ORDER_DETAILS==' => ATBDP_Order::get_order_details( $order_id ), - '==TODAY==' => date_i18n( $date_format, $current_time ), - '==NOW==' => date_i18n( $date_format . ' ' . $time_format, $current_time ), - '==DASHBOARD_LINK==' => sprintf( '<a href="%s">%s</a>', $dashboard_link, $dashboard_link ), - '==USER_PASSWORD==' => $user_password, - '==USER_DASHBOARD==' => sprintf( '<a href="%s">%s</a>', $user_dashboard, __( 'Click Here', 'directorist' ) ), - '==PIN==' => $pin, - '==CONFIRM_EMAIL_ADDRESS_URL==' => $user ? sprintf( '<p align="center"><a style="text-decoration: none;background-color: #8569fb;padding: 8px 10px;color: #fff;border-radius: 4px;" href="%s">%s</a></p>', esc_url_raw(directorist_password_reset_url($user, false, true)), __( 'Confirm Email Address', 'directorist' ) ) : '', - '==SET_PASSWORD_AND_CONFIRM_EMAIL_ADDRESS_URL==' => $user ? sprintf( '<p align="center"><a style="text-decoration: none;background-color: #8569fb;padding: 8px 10px;color: #fff;border-radius: 4px;" href="%s">%s</a></p>', esc_url_raw(directorist_password_reset_url($user, true, true)), __( 'Set Password And Confirm Email Address', 'directorist' ) ) : '' + '==NAME==' => ! empty( $user->display_name ) ? $user->display_name : '', + '==USERNAME==' => ! empty( $user->user_login ) ? $user->user_login : '', + '==SITE_NAME==' => $site_name, + '==SITE_LINK==' => sprintf( '<a href="%s">%s</a>', $site_url, $site_name ), + '==SITE_URL==' => sprintf( '<a href="%s">%s</a>', $site_url, $site_url ), + '==EXPIRATION_DATE==' => ! empty( $never_exp ) ? __( 'Never Expires', 'directorist' ) : date_i18n( $date_format, strtotime( $exp_date ) ), + '==CATEGORY_NAME==' => $cat_name, + '==RENEWAL_LINK==' => sprintf( '<a href="%s">%s</a>', $renewal_link, __( 'Visit Listing Renewal Page', 'directorist' ) ), + '==LISTING_ID==' => $listing_id, + '==LISTING_TITLE==' => $l_title, + '==LISTING_EDIT_URL==' => sprintf( '<a href="%s">%s</a>', $l_edit_url, $l_title ), + '==LISTING_LINK==' => sprintf( '<a href="%s">%s</a>', $listing_url, $l_title ), + '==LISTING_URL==' => sprintf( '<a href="%s">%s</a>', $listing_url, $listing_url ), + '==ORDER_ID==' => $order_id, + '==ORDER_RECEIPT_URL==' => sprintf( '<a href="%s">%s</a>', $order_receipt_link, __( 'View Order/Payment Receipt', 'directorist' ) ), + // '==ORDER_DETAILS==' => ATBDP_Order::get_order_details( $order_id ), + '==TODAY==' => date_i18n( $date_format, $current_time ), + '==NOW==' => date_i18n( $date_format . ' ' . $time_format, $current_time ), + '==DASHBOARD_LINK==' => sprintf( '<a href="%s">%s</a>', $dashboard_link, $dashboard_link ), + '==USER_PASSWORD==' => $user_password, + '==USER_DASHBOARD==' => sprintf( '<a href="%s">%s</a>', $user_dashboard, __( 'Click Here', 'directorist' ) ), + '==PIN==' => $pin, + '==CONFIRM_EMAIL_ADDRESS_URL==' => $user ? sprintf( '<p align="center"><a style="text-decoration: none;background-color: #8569fb;padding: 8px 10px;color: #fff;border-radius: 4px;" href="%s">%s</a></p>', esc_url_raw( directorist_password_reset_url( $user, false, true ) ), __( 'Confirm Email Address', 'directorist' ) ) : '', + '==SET_PASSWORD_AND_CONFIRM_EMAIL_ADDRESS_URL==' => $user ? sprintf( '<p align="center"><a style="text-decoration: none;background-color: #8569fb;padding: 8px 10px;color: #fff;border-radius: 4px;" href="%s">%s</a></p>', esc_url_raw( directorist_password_reset_url( $user, true, true ) ), __( 'Set Password And Confirm Email Address', 'directorist' ) ) : '', ); - $c = nl2br( strtr( $content, $find_replace ) ); + $c = nl2br( strtr( $content, $find_replace ) ); // we do not want to use br for line break in the order details markup. so we removed that from bulk replacement. return str_replace( '==ORDER_DETAILS==', ATBDP_Order::get_order_details( $order_id ), $c ); - } /** @@ -455,7 +452,7 @@ public function html_content_type() { */ public function get_email_headers( $data = array() ) { // get the data from the db - $name = ! empty( $data['name'] ) ? sanitize_text_field( $data['name'] ) : get_directorist_option( 'email_from_name', get_option( 'blogname' ) ); + $name = ! empty( $data['name'] ) ? sanitize_text_field( $data['name'] ) : get_directorist_option( 'email_from_name', get_option( 'blogname' ) ); $email = ! empty( $data['email'] ) ? sanitize_email( $data['email'] ) : get_directorist_option( 'email_from_email', get_option( 'admin_email' ) ); // build the header for email and return it @todo; is it better to trim here? test on free time. return "From: {$name} <{$email}>\r\nReply-To: {$email}\r\n"; @@ -509,10 +506,10 @@ public function notify_owner_order_created( $order_id, $listing_id, $offline = f // Send email according to the type of the payment that user used during checkout. get email template from the db. $offline = ( ! empty( $offline ) ) ? '_offline' : ''; $subject = $this->replace_in_content( get_directorist_option( "email_sub{$offline}_new_order" ), $order_id, $listing_id, $user ); - $body = $this->replace_in_content( get_directorist_option( "email_tmpl{$offline}_new_order" ), $order_id, $listing_id, $user ); + $body = $this->replace_in_content( get_directorist_option( "email_tmpl{$offline}_new_order" ), $order_id, $listing_id, $user ); $message = atbdp_email_html( $subject, $body ); - $to = $user->user_email; + $to = $user->user_email; $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -548,11 +545,11 @@ public function notify_owner_order_completed( $order_id, $listing_id ) { if ( ! in_array( 'order_completed', get_directorist_option( 'notify_user', array( 'order_completed' ), true ) ) ) { return false; } - $user = $this->get_owner( $listing_id ? $listing_id : $order_id ); + $user = $this->get_owner( $listing_id ? $listing_id : $order_id ); $subject = $this->replace_in_content( get_directorist_option( 'email_sub_completed_order' ), $order_id, $listing_id, $user ); - $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_completed_order' ), $order_id, $listing_id, $user ); + $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_completed_order' ), $order_id, $listing_id, $user ); $message = atbdp_email_html( $subject, $body ); - $to = $user->user_email; + $to = $user->user_email; $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -587,11 +584,11 @@ public function notify_owner_listing_submitted( $listing_id ) { return false; } - $user = $this->get_owner( $listing_id ); + $user = $this->get_owner( $listing_id ); $subject = $this->replace_in_content( get_directorist_option( 'email_sub_new_listing' ), null, $listing_id, $user ); - $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_new_listing' ), null, $listing_id, $user ); + $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_new_listing' ), null, $listing_id, $user ); $message = atbdp_email_html( $subject, $body ); - $to = $user->user_email; + $to = $user->user_email; $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $user->user_email, $subject, $message, $headers ); @@ -627,13 +624,13 @@ public function notify_admin_listing_published( $listing_id ) { return false; } - $s = __( '[==SITE_NAME==] The Listing #==LISTING_ID== has been published on your website', 'directorist' ); + $s = __( '[==SITE_NAME==] The Listing #==LISTING_ID== has been published on your website', 'directorist' ); $subject = $this->replace_in_content( $s, null, $listing_id ); - $body = $this->get_listing_published_admin_tmpl(); - $body = $this->replace_in_content( $body, null, $listing_id ); + $body = $this->get_listing_published_admin_tmpl(); + $body = $this->replace_in_content( $body, null, $listing_id ); $message = atbdp_email_html( $subject, $body ); - $to = $this->get_admin_email_list(); + $to = $this->get_admin_email_list(); $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -651,7 +648,6 @@ public function notify_admin_listing_published( $listing_id ) { do_action( 'directorist_email_on_notify_admin_listing_published', $action_args ); return $is_sent; - } @@ -670,11 +666,11 @@ public function notify_owner_listing_published( $listing_id ) { return false; } - $user = $this->get_owner( $listing_id ); + $user = $this->get_owner( $listing_id ); $subject = $this->replace_in_content( get_directorist_option( 'email_sub_pub_listing' ), null, $listing_id, $user ); - $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_pub_listing' ), null, $listing_id, $user ); + $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_pub_listing' ), null, $listing_id, $user ); $message = atbdp_email_html( $subject, $body ); - $to = $user->user_email; + $to = $user->user_email; $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -711,9 +707,9 @@ public function notify_owner_listing_edited( $listing_id ) { return false; } - $user = $this->get_owner( $listing_id ); - $subject = $this->replace_in_content( get_directorist_option( 'email_sub_edit_listing' ), null, $listing_id, $user ); - $to = $user->user_email; + $user = $this->get_owner( $listing_id ); + $subject = $this->replace_in_content( get_directorist_option( 'email_sub_edit_listing' ), null, $listing_id, $user ); + $to = $user->user_email; $directory_type = directorist_get_listing_directory( $listing_id ); $edited_status = directorist_get_listing_edit_status( $directory_type ); if ( 'publish' === $edited_status ) { @@ -755,11 +751,11 @@ public function notify_owner_listing_to_expire( $listing_id ) { return false; } - $user = $this->get_owner( $listing_id ); + $user = $this->get_owner( $listing_id ); $subject = $this->replace_in_content( get_directorist_option( 'email_sub_to_expire_listing' ), null, $listing_id, $user ); - $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_to_expire_listing' ), null, $listing_id, $user, true ); + $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_to_expire_listing' ), null, $listing_id, $user, true ); $message = atbdp_email_html( $subject, $body ); - $to = $user->user_email; + $to = $user->user_email; $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -790,15 +786,15 @@ public function notify_owner_listing_expired( $listing_id ) { $notify = apply_filters( 'directorist_notify_owner_listing_expired', true, $listing_id ); - if ( ! $listing_id || ! $notify || $this->disable_notification() || ! in_array( 'listing_expired', get_directorist_option( 'notify_user', array( 'listing_expired' ), true ) ) ) { + if ( ! $listing_id || ! $notify || $this->disable_notification() || ! in_array( 'listing_expired', get_directorist_option( 'notify_user', array( 'listing_expired' ), true ) ) ) { return false; } - $user = $this->get_owner( $listing_id ); + $user = $this->get_owner( $listing_id ); $subject = $this->replace_in_content( get_directorist_option( 'email_sub_expired_listing' ), null, $listing_id, $user ); - $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_expired_listing' ), null, $listing_id, $user, true ); + $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_expired_listing' ), null, $listing_id, $user, true ); $message = atbdp_email_html( $subject, $body ); - $to = $user->user_email; + $to = $user->user_email; $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -833,11 +829,11 @@ public function notify_owner_to_renew( $listing_id ) { return false; } - $user = $this->get_owner( $listing_id ); + $user = $this->get_owner( $listing_id ); $subject = $this->replace_in_content( get_directorist_option( 'email_sub_to_renewal_listing' ), null, $listing_id, $user ); - $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_to_renewal_listing' ), null, $listing_id, $user, true ); + $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_to_renewal_listing' ), null, $listing_id, $user, true ); $message = atbdp_email_html( $subject, $body ); - $to = $user->user_email; + $to = $user->user_email; $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -874,7 +870,7 @@ public function notify_owner_listing_renewed( $listing_id ) { } $user = $this->get_owner( $listing_id ); - $sub = $this->replace_in_content( get_directorist_option( 'email_sub_renewed_listing' ), null, $listing_id, $user ); + $sub = $this->replace_in_content( get_directorist_option( 'email_sub_renewed_listing' ), null, $listing_id, $user ); $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_renewed_listing' ), null, $listing_id, $user ); return $this->send_mail( $user->user_email, $sub, $body, $this->get_email_headers() ); @@ -898,12 +894,12 @@ public function notify_owner_listing_deleted( $listing_id ) { return false; } - $user = $this->get_owner( $listing_id ); + $user = $this->get_owner( $listing_id ); $subject = $this->replace_in_content( get_directorist_option( 'email_sub_deleted_listing' ), null, $listing_id, $user ); - $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_deleted_listing' ), null, $listing_id, $user ); + $body = $this->replace_in_content( get_directorist_option( 'email_tmpl_deleted_listing' ), null, $listing_id, $user ); $message = atbdp_email_html( $subject, $body ); - $to = $user->user_email; + $to = $user->user_email; $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -941,25 +937,24 @@ public function notify_admin_listing_deleted( $listing_id ) { return false; // vail if order created notification to admin off } - $s = __( '[==SITE_NAME==] A Listing has been deleted [ID#: ==LISTING_ID==] on your website', 'directorist' ); - $sub = $this->replace_in_content( $s, null, $listing_id ); + $s = __( '[==SITE_NAME==] A Listing has been deleted [ID#: ==LISTING_ID==] on your website', 'directorist' ); + $sub = $this->replace_in_content( $s, null, $listing_id ); $body = $this->replace_in_content( $this->get_listing_deleted_admin_tmpl(), null, $listing_id ); $body = atbdp_email_html( $sub, $body ); return $this->send_mail( $this->get_admin_email_list(), $sub, $body, $this->get_email_headers() ); - } public function notify_admin_become_author( $user_id ) { if ( get_directorist_option( 'disable_email_notification' ) ) { return false; } - $s = __( '[==SITE_NAME==] New Author Request', 'directorist' ); + $s = __( '[==SITE_NAME==] New Author Request', 'directorist' ); $subject = str_replace( '==SITE_NAME==', get_option( 'blogname' ), $s ); - $body = $this->author_approval_admin_tmpl(); - $body = $this->replace_in_content( $body, null, null, $user_id ); + $body = $this->author_approval_admin_tmpl(); + $body = $this->replace_in_content( $body, null, null, $user_id ); $message = atbdp_email_html( $subject, $body ); - $to = $this->get_admin_email_list(); + $to = $this->get_admin_email_list(); $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -1005,14 +1000,14 @@ public function notify_admin_order_created( $order_id, $listing_id ) { return false; // vail if order created notification to admin off } - $s = __( '[==SITE_NAME==] You have a new order #==ORDER_ID== on your website', 'directorist' ); + $s = __( '[==SITE_NAME==] You have a new order #==ORDER_ID== on your website', 'directorist' ); $subject = $this->replace_in_content( $s, $order_id ); - $t = $this->get_order_created_admin_tmpl(); // get the email template & replace order_receipt placeholder in it - $body = str_replace( '==ORDER_RECEIPT_URL==', admin_url( 'edit.php?post_type=atbdp_orders' ), $t ); /*@todo; MAYBE ?? it would be good if there is a dedicated page for viewing the payment receipt by the admin regardless the order_receipt shortcode is used or not.*/ - $body = $this->replace_in_content( $body, $order_id, $listing_id ); + $t = $this->get_order_created_admin_tmpl(); // get the email template & replace order_receipt placeholder in it + $body = str_replace( '==ORDER_RECEIPT_URL==', admin_url( 'edit.php?post_type=atbdp_orders' ), $t ); /*@todo; MAYBE ?? it would be good if there is a dedicated page for viewing the payment receipt by the admin regardless the order_receipt shortcode is used or not.*/ + $body = $this->replace_in_content( $body, $order_id, $listing_id ); $message = atbdp_email_html( $subject, $body ); - $to = $this->get_admin_email_list(); + $to = $this->get_admin_email_list(); $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -1050,14 +1045,14 @@ public function notify_admin_order_completed( $order_id, $listing_id ) { return false; } - $s = __( '[==SITE_NAME==] Payment Notification : Order #==ORDER_ID== Completed', 'directorist' ); + $s = __( '[==SITE_NAME==] Payment Notification : Order #==ORDER_ID== Completed', 'directorist' ); $subject = $this->replace_in_content( $s, $order_id ); - $t = $this->get_order_completed_admin_tmpl(); // get the email template & replace order_receipt placeholder in it - $body = str_replace( '==ORDER_RECEIPT_URL==', admin_url( 'edit.php?post_type=atbdp_orders' ), $t ); - $body = $this->replace_in_content( $body, $order_id, $listing_id ); + $t = $this->get_order_completed_admin_tmpl(); // get the email template & replace order_receipt placeholder in it + $body = str_replace( '==ORDER_RECEIPT_URL==', admin_url( 'edit.php?post_type=atbdp_orders' ), $t ); + $body = $this->replace_in_content( $body, $order_id, $listing_id ); $message = atbdp_email_html( $subject, $body ); - $to = $this->get_admin_email_list(); + $to = $this->get_admin_email_list(); $headers = $this->get_email_headers(); $is_sent = $this->send_mail( $to, $subject, $message, $headers ); @@ -1092,14 +1087,14 @@ public function notify_admin_listing_submitted( $listing_id ) { return false; } - $s = __( '[==SITE_NAME==] A new listing has been submitted on your website', 'directorist' ); + $s = __( '[==SITE_NAME==] A new listing has been submitted on your website', 'directorist' ); $subject = str_replace( '==SITE_NAME==', get_option( 'blogname' ), $s ); - $to = $this->get_admin_email_list(); + $to = $this->get_admin_email_list(); $headers = $this->get_email_headers(); - $body = $this->get_listing_submitted_admin_tmpl(); + $body = $this->get_listing_submitted_admin_tmpl(); $message = $this->replace_in_content( $body, null, $listing_id ); - $body = atbdp_email_html( $subject, $message ); + $body = atbdp_email_html( $subject, $message ); $is_sent = $this->send_mail( $to, $subject, $body, $headers ); @@ -1116,7 +1111,6 @@ public function notify_admin_listing_submitted( $listing_id ) { do_action( 'directorist_email_on_notify_admin_listing_submitted', $action_args ); return $is_sent; - } /** @@ -1158,11 +1152,11 @@ public function notify_admin_listing_edited( $listing_id ) { return false; } - $s = __( '[==SITE_NAME==] The Listing #==LISTING_ID== has been edited on your website', 'directorist' ); + $s = __( '[==SITE_NAME==] The Listing #==LISTING_ID== has been edited on your website', 'directorist' ); $subject = $this->replace_in_content( $s, null, $listing_id ); - $to = $this->get_admin_email_list(); - $body = $this->get_listing_edited_admin_tmpl(); - $body = $this->replace_in_content( $body, null, $listing_id ); + $to = $this->get_admin_email_list(); + $body = $this->get_listing_edited_admin_tmpl(); + $body = $this->replace_in_content( $body, null, $listing_id ); $message = atbdp_email_html( $subject, $body ); $headers = $this->get_email_headers(); @@ -1205,7 +1199,6 @@ public function custom_wp_new_user_notification_email( $user_id ) { We look forward to seeing you soon' ); - $body = $this->replace_in_content( $body, null, null, $user ); $body = atbdp_email_html( $sub, $body ); $mail = $this->send_mail( $user->user_email, $sub, $body, $this->get_email_headers() ); @@ -1214,7 +1207,7 @@ public function custom_wp_new_user_notification_email( $user_id ) { } } - public function send_user_confirmation_email(Wp_User $user) { + public function send_user_confirmation_email( Wp_User $user ) { if ( get_directorist_option( 'disable_email_notification' ) ) { return; @@ -1245,6 +1238,5 @@ public function send_user_confirmation_email(Wp_User $user) { return $this->send_mail( $user->user_email, $subject, $body, $this->get_email_headers() ); } - } // ends class -endif; \ No newline at end of file +endif; diff --git a/includes/classes/class-extension.php b/includes/classes/class-extension.php index c4786b5084..2f40a00c3d 100644 --- a/includes/classes/class-extension.php +++ b/includes/classes/class-extension.php @@ -154,7 +154,7 @@ public function prepare_the_final_requred_extension_list( array $args = array() $is_purchased = ( in_array( $extension, $purchased_extensions ) ) ? true : false; $is_purchased_alias = ( in_array( $extension_alias, $purchased_extensions ) ) ? true : false; - $is_installed = file_exists( $plugin_dir_path . $extension ); + $is_installed = file_exists( $plugin_dir_path . $extension ); $is_installed_alias = ( ! empty( $extension_alias ) && file_exists( $plugin_dir_path . $extension_alias ) ) ? true : false; $base = "{$extension}/{$extension}.php"; @@ -217,12 +217,12 @@ public function setup_products_list() { $products = API::get_products(); // Apply filters for extensions and themes - $this->extensions = apply_filters('atbdp_extension_list', $products['extensions']); - $this->themes = apply_filters('atbdp_theme_list', $products['themes']); + $this->extensions = apply_filters( 'atbdp_extension_list', $products['extensions'] ); + $this->themes = apply_filters( 'atbdp_theme_list', $products['themes'] ); // Set default values if extensions or themes are empty - $this->extensions = empty($this->extensions) ? static::get_default_extensions() : $this->extensions; - $this->themes = empty($this->themes) ? static::get_default_themes() : $this->themes; + $this->extensions = empty( $this->extensions ) ? static::get_default_extensions() : $this->extensions; + $this->themes = empty( $this->themes ) ? static::get_default_themes() : $this->themes; } // get_the_products_list @@ -247,332 +247,335 @@ public function setup_extension_updater() { // Get the base file path of the extension $base = $extension['base'] ?? $key . '/' . $key . '.php'; $base_file = WP_PLUGIN_DIR . '/' . $base; - $plugin_data = $plugins_data[ $base ] ?? []; + $plugin_data = $plugins_data[ $base ] ?? array(); if ( empty( $plugin_data ) ) { continue; } - $extension_license_map = $licenses[ $key ] ?? []; + $extension_license_map = $licenses[ $key ] ?? array(); if ( empty( $extension_license_map ) || empty( $extension_license_map['license'] ) ) { continue; } // Initialize the plugin updater for the extension - new EDD_SL_Plugin_Updater( 'https://directorist.com', $base_file, [ - 'version' => $plugin_data['Version'], // Current version number - 'license' => $extension_license_map['license'], // License key from user meta - 'item_id' => $item_id, // Plugin ID - 'author' => 'AazzTech', // Plugin author - 'url' => home_url(), // Site URL - 'beta' => false, // Beta release flag - ] ); + new EDD_SL_Plugin_Updater( + 'https://directorist.com', + $base_file, + array( + 'version' => $plugin_data['Version'], // Current version number + 'license' => $extension_license_map['license'], // License key from user meta + 'item_id' => $item_id, // Plugin ID + 'author' => 'AazzTech', // Plugin author + 'url' => home_url(), // Site URL + 'beta' => false, // Beta release flag + ) + ); } } public static function get_default_extensions() { - return [ - 'directorist-coupon' => [ - 'name' => 'Coupon', - 'description' => __( 'It lets you offer discounts to users when purchasing listing plans or paying for featured listings.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-coupon/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/11/19_Coupon.png', - 'active' => true, - 'item_id' => 32345, - ], - 'directorist-compare-listing' => [ - 'name' => 'Compare Listings', - 'description' => __( 'Compare Listings extension allows users to add a set of listings in a list and compare its features by viewing in a comparison table.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-compare-listing/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/2020/07/Compare-Listings.png', - 'active' => true, - 'item_id' => 26378, - ], - 'directorist-listings-with-map' => [ - 'name' => 'Listings With Map', - 'description' => __( 'Show your listings with the interactive maps and make your business visible comprehensively. This awesome extension will make your website the brand recognition it deserves.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-listings-with-map/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/06_Listings-With-Map-1.png', - 'base' => 'directorist-listings-with-map/directorist-listings-map.php', - 'active' => true, - 'item_id' => 13794, - ], - 'directorist-pricing-plans' => [ - 'name' => 'Pricing Plans', - 'description' => __( 'Do you have a growing directory site? Do you want to make money with your site very easily? Start generating a handsome amount of revenue from your directory site with Directorist Pricing Plans today.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-pricing-plans/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/15_Pricing-Plans-1.png', - 'active' => true, - 'item_id' => 13776, - ], - 'directorist-woocommerce-pricing-plans' => [ - 'name' => 'WooCommerce Pricing Plans', - 'description' => __( 'Do you have a growing directory site? Do you want to make money with your site by integrating your favorite WooCommerce payment gateway? Start generating a handsome amount of revenue from your directory site with Directorist WooCommerce Pricing Plans today.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-woocommerce-pricing-plans/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/16_WooCommerce-Pricing-Plans-1.png', - 'active' => true, - 'item_id' => 13784, - ], - 'directorist-paypal' => [ - 'name' => 'PayPal Payment Gateway', - 'description' => __( 'Do you want to boost your income on your business directory site? Are you looking for a robust payment gateway with worldwide acceptance? If you are, then Directorist PayPal Payment Gateway is the perfect fit for you.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-paypal/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/14_PayPal-Payment-Gateway-2.png', - 'active' => true, - 'item_id' => 13702, - ], - 'directorist-stripe' => [ - 'name' => 'Stripe Payment Gateway', - 'description' => __( 'Are you looking for a versatile Directorist payment gateway for your business directory that accepts a great number of currencies? If yes, then Directorist Stripe Payment Gateway is the smartest way to go', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-stripe/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/13_Stripe-Payment-Gateway-3.png', - 'active' => true, - 'item_id' => 13700, - ], - 'directorist-claim-listing' => [ - 'name' => 'Claim Listing', - 'description' => __( 'Let business owners maintain tons of listings by claiming them and monetize your directory listing website with instant revenue.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-claim-listing/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/12_Claim-Listing-2.png', - 'active' => true, - 'item_id' => 13786, - ], - 'directorist-mark-as-sold' => [ - 'name' => 'Mark as Sold', - 'description' => __( 'Mark as sold is a dynamic extension that provides listing authors the opportunity to show visitors if a particular item is sold or not.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-mark-as-sold/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/03_Mark-As-Sold-1.png', - 'active' => true, - 'item_id' => 20204, - ], - 'directorist-social-login' => [ - 'name' => 'Social Login', - 'description' => __( 'Use Directorist Social Login to accelerate the registration process by offering a single-click login option using Facebook or Google profile.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-social-login/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/04_Social-Login-1.png', - 'active' => true, - 'item_id' => 13795, - ], - 'directorist-google-recaptcha' => [ - 'name' => 'Google reCAPTCHA', - 'description' => __( 'Use reCAPTCHA service from Google to help your directory site protect from spam and further abuse. This Google reCAPTCHA extension allows you to make it happen by taking care of your site.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-google-recaptcha/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/10_Google-ReCAPTCHA-2.png', - 'active' => true, - 'item_id' => 13768, - ], - 'directorist-faqs' => [ - 'name' => 'Listing FAQs', - 'description' => __( 'Use an organized FAQ page on your directory website and provide quick information to help customers make a potential decision. Here, the idea is to keep the answers short and direct so that people find info quickly.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-faqs/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/08_Listing-FAQs-1.png', - 'active' => true, - 'item_id' => 13780, - ], - 'directorist-business-hours' => [ - 'name' => 'Business Hours', - 'description' => __( 'Inform your customers about your business hours in the best way possible especially when your businesses are opened and when they are closed', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-business-hours/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/11_Business-Hours.png', - 'base' => 'directorist-business-hours/bd-business-hour.php', - 'active' => true, + return array( + 'directorist-coupon' => array( + 'name' => 'Coupon', + 'description' => __( 'It lets you offer discounts to users when purchasing listing plans or paying for featured listings.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-coupon/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/11/19_Coupon.png', + 'active' => true, + 'item_id' => 32345, + ), + 'directorist-compare-listing' => array( + 'name' => 'Compare Listings', + 'description' => __( 'Compare Listings extension allows users to add a set of listings in a list and compare its features by viewing in a comparison table.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-compare-listing/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/2020/07/Compare-Listings.png', + 'active' => true, + 'item_id' => 26378, + ), + 'directorist-listings-with-map' => array( + 'name' => 'Listings With Map', + 'description' => __( 'Show your listings with the interactive maps and make your business visible comprehensively. This awesome extension will make your website the brand recognition it deserves.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-listings-with-map/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/06_Listings-With-Map-1.png', + 'base' => 'directorist-listings-with-map/directorist-listings-map.php', + 'active' => true, + 'item_id' => 13794, + ), + 'directorist-pricing-plans' => array( + 'name' => 'Pricing Plans', + 'description' => __( 'Do you have a growing directory site? Do you want to make money with your site very easily? Start generating a handsome amount of revenue from your directory site with Directorist Pricing Plans today.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-pricing-plans/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/15_Pricing-Plans-1.png', + 'active' => true, + 'item_id' => 13776, + ), + 'directorist-woocommerce-pricing-plans' => array( + 'name' => 'WooCommerce Pricing Plans', + 'description' => __( 'Do you have a growing directory site? Do you want to make money with your site by integrating your favorite WooCommerce payment gateway? Start generating a handsome amount of revenue from your directory site with Directorist WooCommerce Pricing Plans today.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-woocommerce-pricing-plans/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/16_WooCommerce-Pricing-Plans-1.png', + 'active' => true, + 'item_id' => 13784, + ), + 'directorist-paypal' => array( + 'name' => 'PayPal Payment Gateway', + 'description' => __( 'Do you want to boost your income on your business directory site? Are you looking for a robust payment gateway with worldwide acceptance? If you are, then Directorist PayPal Payment Gateway is the perfect fit for you.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-paypal/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/14_PayPal-Payment-Gateway-2.png', + 'active' => true, + 'item_id' => 13702, + ), + 'directorist-stripe' => array( + 'name' => 'Stripe Payment Gateway', + 'description' => __( 'Are you looking for a versatile Directorist payment gateway for your business directory that accepts a great number of currencies? If yes, then Directorist Stripe Payment Gateway is the smartest way to go', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-stripe/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/13_Stripe-Payment-Gateway-3.png', + 'active' => true, + 'item_id' => 13700, + ), + 'directorist-claim-listing' => array( + 'name' => 'Claim Listing', + 'description' => __( 'Let business owners maintain tons of listings by claiming them and monetize your directory listing website with instant revenue.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-claim-listing/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/12_Claim-Listing-2.png', + 'active' => true, + 'item_id' => 13786, + ), + 'directorist-mark-as-sold' => array( + 'name' => 'Mark as Sold', + 'description' => __( 'Mark as sold is a dynamic extension that provides listing authors the opportunity to show visitors if a particular item is sold or not.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-mark-as-sold/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/03_Mark-As-Sold-1.png', + 'active' => true, + 'item_id' => 20204, + ), + 'directorist-social-login' => array( + 'name' => 'Social Login', + 'description' => __( 'Use Directorist Social Login to accelerate the registration process by offering a single-click login option using Facebook or Google profile.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-social-login/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/04_Social-Login-1.png', + 'active' => true, + 'item_id' => 13795, + ), + 'directorist-google-recaptcha' => array( + 'name' => 'Google reCAPTCHA', + 'description' => __( 'Use reCAPTCHA service from Google to help your directory site protect from spam and further abuse. This Google reCAPTCHA extension allows you to make it happen by taking care of your site.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-google-recaptcha/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/10_Google-ReCAPTCHA-2.png', + 'active' => true, + 'item_id' => 13768, + ), + 'directorist-faqs' => array( + 'name' => 'Listing FAQs', + 'description' => __( 'Use an organized FAQ page on your directory website and provide quick information to help customers make a potential decision. Here, the idea is to keep the answers short and direct so that people find info quickly.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-faqs/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/08_Listing-FAQs-1.png', + 'active' => true, + 'item_id' => 13780, + ), + 'directorist-business-hours' => array( + 'name' => 'Business Hours', + 'description' => __( 'Inform your customers about your business hours in the best way possible especially when your businesses are opened and when they are closed', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-business-hours/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/11_Business-Hours.png', + 'base' => 'directorist-business-hours/bd-business-hour.php', + 'active' => true, 'item_id' => 13714, - ], - 'directorist-slider-carousel' => [ - 'name' => 'Listings Slider & Carousel', - 'description' => __( 'Increase the beauty of your directory website by displaying numerous listings through attractive sliders or carousels with this highly customizable extension.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-slider-carousel/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/09_Listings-Slider-Carousel-1.png', - 'base' => 'directorist-slider-carousel/bd-directorist-slider.php', - 'active' => true, - 'item_id' => 13774 - ], - 'directorist-live-chat' => [ - 'name' => 'Live Chat', - 'description' => __( 'Live Chat is an extension that allows the visitors to contact business owners immediately and easily. It makes the business more credible as customer satisfaction increases notably.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-live-chat/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/02_Live-Chats-1.png', - 'active' => true, - 'item_id' => 21274 - ], - 'directorist-booking' => [ - 'name' => 'Booking (Reservation & Appointment)', - 'description' => __( 'This extension comes with all the solutions you need to set up a dynamic booking and reservation system on your directory website.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-booking/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/01_Booking-1.png', - 'active' => true, - 'item_id' => 21718, - ], - 'directorist-gallery' => [ - 'name' => 'Image Gallery', - 'description' => __( 'Use a quality image gallery and increase conversation by reducing your return rate on your directory listing website.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-gallery/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/07_Image-Gallery-1.png', - 'base' => 'directorist-gallery/bd-directorist-gallery.php', - 'active' => true, - 'item_id' => 13778, - ], - 'directorist-adverts-manager' => [ - 'name' => 'Directorist Ads Manager', - 'description' => __( 'Are you wondering about placing advertisements in your directory? Directorist Ads Manager allows you to insert advertisements on specific Directorist pages such as All listings, Single Listings, All Location, All Category, etc.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-adverts-manager/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/12/single-ad-manager.png', - 'active' => true, - 'item_id' => 32342, - ], - 'directorist-buddyboss-integration' => [ - 'name' => 'BuddyBoss Integration', - 'description' => __( 'Directorist - BuddyBoss Integration extension is used to integrate the giant Directorist with the popular BuddyBoss plugin. It combines all the functionalities needed to create a complete community based WordPress directory website using Directorist plugin and BuddyBoss platform', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-buddyboss-integration/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/2021/07/BuddyBoss-Integration.png', - 'active' => true, - 'item_id' => 60945, - ], - 'directorist-oxygen-integration' => [ - 'name' => 'Directorist Oxygen', - 'description' => __( 'Directorist Oxygen is used to integrate the giant Directorist with the popular Oxygen Page Builder plugin. It combines all the functionalities needed to create a complete WordPress directory website using Oxygen Builder.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-oxygen-integration/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/06/Oxygen-Builder.png', - 'active' => true, - 'item_id' => 56997, - ], - 'directorist-authorize-net' => [ - 'name' => 'Authorize.net Payment Gateway', - 'description' => __( 'Directorist Authorize Payment Gateway is a secured payment solution that accepts a great number of payment options for Directorist Pricing Plan like Visa, MasterCard, Discover, AmEx, JCB, PayPal, and more.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-authorize-net/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/04/21_Authorize.net2_.png', - 'active' => true, - 'item_id' => 52499, - ], - 'directorist-buddypress-integration' => [ - 'name' => 'BuddyPress Integration', - 'description' => __( 'Directorist - BuddyPress Integration is a premium extension which makes Direcorist and BuddyPress work as a single integrated app, allowing you to build a hybrid listings directory and social network together.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-buddypress-integration/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/2021/08/BuddyPress.svg', - 'active' => true, - 'item_id' => 62897, - ], - 'directorist-directory-linking' => [ - 'name' => 'Multi Directory Linking', - 'description' => __( 'If you are running multi-directories on your directory website, Multi-directory Linking will be an awesome extension that will allow your users to connect to other types of directories. This opens up a new window to earn money from your directory website.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-directory-linking/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/2021/10/25_Type-Linking.svg', - 'active' => true, - 'item_id' => 70261, - ], - 'directorist-job-manager' => [ - 'name' => 'Job Manager', - 'description' => __( 'If you\'re wondering how to place job listings with detailed specifications, then Directorist-Job Manager gets you rid out of this problem', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-job-manager/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2024/05/30_Jobs_Manager.svg', - 'active' => true, - 'item_id' => 134332, - ], - 'directorist-mailchimp-integration' => [ - 'name' => 'Mailchimp Integration', - 'description' => __( 'Directorist Mailchimp Integration Connects Directorist with Mailchimp. It helps you to make your directory business grow faster and smarter with more leads.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-mailchimp-integration/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/11/27_Mailchimp.svg', - 'active' => true, - 'item_id' => 76269, - ], - 'directorist-helpgent-integration' => [ - 'name' => 'HelpGent Integration', - 'description' => __( 'Directorist HelpGent Integration puts Directorist and HelpGent on the same avenue. The integration helps you to make your directory website more accessible to your audience which eventually creates more leads and conversions', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-helpgent-integration/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2024/05/31_Directorist_-_HelpGent_Integration.svg', - 'active' => true, - 'item_id' => 188735, - ], - 'directorist-digital-marketplace' => [ - 'name' => 'Digital Marketplace', - 'description' => __( 'If you want to create a marketplace of fixed-price services or digital downloads, then the Digital Marketplace Extension will be a worth-investment to kickstart.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-digital-marketplace/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2022/10/30_Marketplace.svg', - 'active' => true, - 'item_id' => 148417, - ], - 'directorist-gamipress-integration' => [ - 'name' => 'Gamipress Integration', - 'description' => __( 'Directorist GamiPress Integration Connects Directorist with GamiPress in one place. It helps you to aggrandize the engagement of your directory business with the utmost possible ease.', 'directorist' ), - 'link' => 'https://directorist.com/product/directorist-gamipress-integration/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2022/04/28_Gamipress.svg', - 'active' => true, - 'item_id' => 102370, - ], - - ]; + ), + 'directorist-slider-carousel' => array( + 'name' => 'Listings Slider & Carousel', + 'description' => __( 'Increase the beauty of your directory website by displaying numerous listings through attractive sliders or carousels with this highly customizable extension.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-slider-carousel/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/09_Listings-Slider-Carousel-1.png', + 'base' => 'directorist-slider-carousel/bd-directorist-slider.php', + 'active' => true, + 'item_id' => 13774, + ), + 'directorist-live-chat' => array( + 'name' => 'Live Chat', + 'description' => __( 'Live Chat is an extension that allows the visitors to contact business owners immediately and easily. It makes the business more credible as customer satisfaction increases notably.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-live-chat/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/02_Live-Chats-1.png', + 'active' => true, + 'item_id' => 21274, + ), + 'directorist-booking' => array( + 'name' => 'Booking (Reservation & Appointment)', + 'description' => __( 'This extension comes with all the solutions you need to set up a dynamic booking and reservation system on your directory website.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-booking/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/01_Booking-1.png', + 'active' => true, + 'item_id' => 21718, + ), + 'directorist-gallery' => array( + 'name' => 'Image Gallery', + 'description' => __( 'Use a quality image gallery and increase conversation by reducing your return rate on your directory listing website.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-gallery/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/07_Image-Gallery-1.png', + 'base' => 'directorist-gallery/bd-directorist-gallery.php', + 'active' => true, + 'item_id' => 13778, + ), + 'directorist-adverts-manager' => array( + 'name' => 'Directorist Ads Manager', + 'description' => __( 'Are you wondering about placing advertisements in your directory? Directorist Ads Manager allows you to insert advertisements on specific Directorist pages such as All listings, Single Listings, All Location, All Category, etc.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-adverts-manager/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/12/single-ad-manager.png', + 'active' => true, + 'item_id' => 32342, + ), + 'directorist-buddyboss-integration' => array( + 'name' => 'BuddyBoss Integration', + 'description' => __( 'Directorist - BuddyBoss Integration extension is used to integrate the giant Directorist with the popular BuddyBoss plugin. It combines all the functionalities needed to create a complete community based WordPress directory website using Directorist plugin and BuddyBoss platform', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-buddyboss-integration/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/2021/07/BuddyBoss-Integration.png', + 'active' => true, + 'item_id' => 60945, + ), + 'directorist-oxygen-integration' => array( + 'name' => 'Directorist Oxygen', + 'description' => __( 'Directorist Oxygen is used to integrate the giant Directorist with the popular Oxygen Page Builder plugin. It combines all the functionalities needed to create a complete WordPress directory website using Oxygen Builder.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-oxygen-integration/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/06/Oxygen-Builder.png', + 'active' => true, + 'item_id' => 56997, + ), + 'directorist-authorize-net' => array( + 'name' => 'Authorize.net Payment Gateway', + 'description' => __( 'Directorist Authorize Payment Gateway is a secured payment solution that accepts a great number of payment options for Directorist Pricing Plan like Visa, MasterCard, Discover, AmEx, JCB, PayPal, and more.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-authorize-net/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/04/21_Authorize.net2_.png', + 'active' => true, + 'item_id' => 52499, + ), + 'directorist-buddypress-integration' => array( + 'name' => 'BuddyPress Integration', + 'description' => __( 'Directorist - BuddyPress Integration is a premium extension which makes Direcorist and BuddyPress work as a single integrated app, allowing you to build a hybrid listings directory and social network together.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-buddypress-integration/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/2021/08/BuddyPress.svg', + 'active' => true, + 'item_id' => 62897, + ), + 'directorist-directory-linking' => array( + 'name' => 'Multi Directory Linking', + 'description' => __( 'If you are running multi-directories on your directory website, Multi-directory Linking will be an awesome extension that will allow your users to connect to other types of directories. This opens up a new window to earn money from your directory website.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-directory-linking/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/2021/10/25_Type-Linking.svg', + 'active' => true, + 'item_id' => 70261, + ), + 'directorist-job-manager' => array( + 'name' => 'Job Manager', + 'description' => __( 'If you\'re wondering how to place job listings with detailed specifications, then Directorist-Job Manager gets you rid out of this problem', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-job-manager/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2024/05/30_Jobs_Manager.svg', + 'active' => true, + 'item_id' => 134332, + ), + 'directorist-mailchimp-integration' => array( + 'name' => 'Mailchimp Integration', + 'description' => __( 'Directorist Mailchimp Integration Connects Directorist with Mailchimp. It helps you to make your directory business grow faster and smarter with more leads.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-mailchimp-integration/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/11/27_Mailchimp.svg', + 'active' => true, + 'item_id' => 76269, + ), + 'directorist-helpgent-integration' => array( + 'name' => 'HelpGent Integration', + 'description' => __( 'Directorist HelpGent Integration puts Directorist and HelpGent on the same avenue. The integration helps you to make your directory website more accessible to your audience which eventually creates more leads and conversions', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-helpgent-integration/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2024/05/31_Directorist_-_HelpGent_Integration.svg', + 'active' => true, + 'item_id' => 188735, + ), + 'directorist-digital-marketplace' => array( + 'name' => 'Digital Marketplace', + 'description' => __( 'If you want to create a marketplace of fixed-price services or digital downloads, then the Digital Marketplace Extension will be a worth-investment to kickstart.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-digital-marketplace/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2022/10/30_Marketplace.svg', + 'active' => true, + 'item_id' => 148417, + ), + 'directorist-gamipress-integration' => array( + 'name' => 'Gamipress Integration', + 'description' => __( 'Directorist GamiPress Integration Connects Directorist with GamiPress in one place. It helps you to aggrandize the engagement of your directory business with the utmost possible ease.', 'directorist' ), + 'link' => 'https://directorist.com/product/directorist-gamipress-integration/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2022/04/28_Gamipress.svg', + 'active' => true, + 'item_id' => 102370, + ), + + ); } public static function get_default_themes() { - return [ - 'dlist' => [ - 'name' => 'DList', - 'description' => __( 'DList is a listing directory WordPress theme that provides immense opportunities to build any kind of directory or listing site. You may design pages on the front-end and watch them instantly come to life.', 'directorist' ), - 'link' => 'https://directorist.com/product/dlist/', - 'demo_link' => 'https://demo.directorist.com/theme/dlist/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/dlist-featured.png', - 'active' => true, - ], - 'dservice' => [ - 'name' => 'DService', - 'description' => __( 'DService is a kind of listing Directory WordPress theme that brings business owners and customers on the same platform. This multifunctional WordPress theme provides them the opportunity to interact with one another for business purposes.', 'directorist' ), - 'link' => 'https://directorist.com/product/dservice/', - 'demo_link' => 'https://demo.directorist.com/theme/dservice/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/dservice-featured.png', - 'active' => true, - ], - 'directoria' => [ - 'name' => 'Directoria', - 'description' => __( 'Directoria is an astonishing directory and listing WordPress theme that is designed and developed to provide fastest page loading speed without knowing a single line of code.', 'directorist' ), - 'link' => 'https://directorist.com/product/directoria/', - 'demo_link' => 'https://demo.directorist.com/plugin/demo-one/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/Directoria-1.png', - 'active' => true, - ], - 'dlawyers' => [ - 'name' => 'dLawyers', - 'description' => __( 'dLawyers is a beautiful WordPress directory theme for legal, legal adviser companies, legal offices, court consultants, lawyers, counsel bureau, attorney agencies, and other law-related businesses.', 'directorist' ), - 'link' => 'https://directorist.com/product/dlawyers/', - 'demo_link' => 'https://demo.directorist.com/theme/dlawyers/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/09/dlawyers_theme.png', - 'active' => true, - ], - 'ddoctors' => [ - 'name' => 'dDoctors', - 'description' => __( 'dDoctors is a beautiful WordPress directory theme for doctor, nurse, medical techonologist, hospital, clinic, and other medical-related businesses.', 'directorist' ), - 'link' => 'https://directorist.com/product/ddoctors/', - 'demo_link' => 'https://demo.directorist.com/theme/ddoctors/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/09/ddoctors_theme.png', - 'active' => true, - ], - 'onelisting-pro' => [ - 'name' => 'Onelisting Pro', - 'description' => __( 'Onelisting Pro is a beautiful WordPress directory theme for doctor, nurse, medical techonologist, hospital, clinic, and other medical-related businesses.', 'directorist' ), - 'link' => 'https://directorist.com/product/onelisting-pro/', - 'demo_link' => 'https://demo.directorist.com/theme/onelisting-pro/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/11/onelisting.png', - 'active' => true, - ], - 'dplace' => [ - 'name' => 'dPlace', - 'description' => __( 'dPlace theme is tailored to meet all the nitty gritties to build attractive mobile responsive travel agency directory websites. As a full-fledged theme, it will allow you to create travel & tour directories with booking and reservation features.', 'directorist' ), - 'link' => 'https://directorist.com/product/dplace/', - 'demo_link' => 'https://demo.directorist.com/theme/dplace/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/11/dPlace.jpg', - 'active' => true, - ], - 'drestaurant' => [ - 'name' => 'dRestaurant', - 'description' => __( 'Are you looking for the best restaurant directory theme that brings you more business? Then, nothing can beat dRestaurant, as it is the most powerful theme that checks all your visual needs with the concept of scalability in mind.', 'directorist' ), - 'link' => 'https://directorist.com/product/drestaurant/', - 'demo_link' => 'https://demo.directorist.com/theme/drestaurant/', - 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/11/1.png', - 'active' => true, - ], - - - ]; + return array( + 'dlist' => array( + 'name' => 'DList', + 'description' => __( 'DList is a listing directory WordPress theme that provides immense opportunities to build any kind of directory or listing site. You may design pages on the front-end and watch them instantly come to life.', 'directorist' ), + 'link' => 'https://directorist.com/product/dlist/', + 'demo_link' => 'https://demo.directorist.com/theme/dlist/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/dlist-featured.png', + 'active' => true, + ), + 'dservice' => array( + 'name' => 'DService', + 'description' => __( 'DService is a kind of listing Directory WordPress theme that brings business owners and customers on the same platform. This multifunctional WordPress theme provides them the opportunity to interact with one another for business purposes.', 'directorist' ), + 'link' => 'https://directorist.com/product/dservice/', + 'demo_link' => 'https://demo.directorist.com/theme/dservice/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/dservice-featured.png', + 'active' => true, + ), + 'directoria' => array( + 'name' => 'Directoria', + 'description' => __( 'Directoria is an astonishing directory and listing WordPress theme that is designed and developed to provide fastest page loading speed without knowing a single line of code.', 'directorist' ), + 'link' => 'https://directorist.com/product/directoria/', + 'demo_link' => 'https://demo.directorist.com/plugin/demo-one/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2020/08/Directoria-1.png', + 'active' => true, + ), + 'dlawyers' => array( + 'name' => 'dLawyers', + 'description' => __( 'dLawyers is a beautiful WordPress directory theme for legal, legal adviser companies, legal offices, court consultants, lawyers, counsel bureau, attorney agencies, and other law-related businesses.', 'directorist' ), + 'link' => 'https://directorist.com/product/dlawyers/', + 'demo_link' => 'https://demo.directorist.com/theme/dlawyers/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/09/dlawyers_theme.png', + 'active' => true, + ), + 'ddoctors' => array( + 'name' => 'dDoctors', + 'description' => __( 'dDoctors is a beautiful WordPress directory theme for doctor, nurse, medical techonologist, hospital, clinic, and other medical-related businesses.', 'directorist' ), + 'link' => 'https://directorist.com/product/ddoctors/', + 'demo_link' => 'https://demo.directorist.com/theme/ddoctors/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/09/ddoctors_theme.png', + 'active' => true, + ), + 'onelisting-pro' => array( + 'name' => 'Onelisting Pro', + 'description' => __( 'Onelisting Pro is a beautiful WordPress directory theme for doctor, nurse, medical techonologist, hospital, clinic, and other medical-related businesses.', 'directorist' ), + 'link' => 'https://directorist.com/product/onelisting-pro/', + 'demo_link' => 'https://demo.directorist.com/theme/onelisting-pro/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/11/onelisting.png', + 'active' => true, + ), + 'dplace' => array( + 'name' => 'dPlace', + 'description' => __( 'dPlace theme is tailored to meet all the nitty gritties to build attractive mobile responsive travel agency directory websites. As a full-fledged theme, it will allow you to create travel & tour directories with booking and reservation features.', 'directorist' ), + 'link' => 'https://directorist.com/product/dplace/', + 'demo_link' => 'https://demo.directorist.com/theme/dplace/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/11/dPlace.jpg', + 'active' => true, + ), + 'drestaurant' => array( + 'name' => 'dRestaurant', + 'description' => __( 'Are you looking for the best restaurant directory theme that brings you more business? Then, nothing can beat dRestaurant, as it is the most powerful theme that checks all your visual needs with the concept of scalability in mind.', 'directorist' ), + 'link' => 'https://directorist.com/product/drestaurant/', + 'demo_link' => 'https://demo.directorist.com/theme/drestaurant/', + 'thumbnail' => 'https://directorist.com/wp-content/uploads/edd/2021/11/1.png', + 'active' => true, + ), + + ); } // exclude_purchased_extensions @@ -854,7 +857,7 @@ public function plugins_bulk_action() { if ( 'activate' === $task ) { foreach ( $plugin_items as $plugin ) { $activated = activate_plugin( $plugin ); - if( is_wp_error( $activated ) ) { + if ( is_wp_error( $activated ) ) { $status['success'] = false; $status['message'] = 'Error in plugin activation'; wp_send_json( array( 'status' => $status ) ); @@ -992,7 +995,7 @@ public function update_the_themes( array $args = array() ) { $status['message'] = __( 'The theme has been updated successfully', 'directorist' ); $status['log'] = $download_status['message']; wp_clean_themes_cache(); - }; + } return array( 'status' => $status ); } @@ -1050,11 +1053,11 @@ public function authenticate_the_customer() { $status = array( 'success' => true, - 'log' => array(), + 'log' => array(), ); if ( ! directorist_verify_nonce( 'nonce', 'atbdp_nonce_action_js' ) ) { - $status['success'] = false; + $status['success'] = false; $status['log']['invalid_request'] = array( 'type' => 'error', 'message' => 'Invalid request', @@ -1099,7 +1102,7 @@ public function authenticate_the_customer() { // Get licencing data $response = self::remote_authenticate_user( array( - 'user' => $username, + 'user' => $username, 'password' => $password, ) ); @@ -1125,7 +1128,7 @@ public function authenticate_the_customer() { wp_send_json( array( - 'status' => $status, + 'status' => $status, 'response_body' => $response, ) ); @@ -1148,7 +1151,7 @@ public function authenticate_the_customer() { wp_send_json( array( - 'status' => $status, + 'status' => $status, 'has_previous_subscriptions' => true, ) ); @@ -1178,7 +1181,7 @@ public function authenticate_the_customer() { wp_send_json( array( - 'status' => $status, + 'status' => $status, 'license_data' => $license_data, ) ); @@ -1186,7 +1189,7 @@ public function authenticate_the_customer() { // handle_refresh_purchase_status_request public function handle_refresh_purchase_status_request() { - $status = array( 'success' => true ); + $status = array( 'success' => true ); if ( ! directorist_verify_nonce( 'nonce', 'atbdp_nonce_action_js' ) ) { $status['success'] = false; @@ -1231,7 +1234,7 @@ public function refresh_purchase_status( array $args = array() ) { // Get licencing data $authentication = self::remote_authenticate_user( array( - 'user' => $username, + 'user' => $username, 'password' => $password, ) ); @@ -1242,7 +1245,7 @@ public function refresh_purchase_status( array $args = array() ) { $status['message'] = $authentication['message']; return array( - 'status' => $status, + 'status' => $status, 'response_body' => $authentication, ); } @@ -1309,7 +1312,7 @@ public function prepare_available_in_subscriptions( array $products = array() ) } foreach ( $products as $product ) { - $product_key = $this->get_product_key_from_permalink( $product['permalink'] ); + $product_key = $this->get_product_key_from_permalink( $product['permalink'] ); $available_in_subscriptions[ $product_key ] = $product; } @@ -1358,7 +1361,7 @@ public function handle_license_activation_request() { wp_send_json( array( - 'status' => $status, + 'status' => $status, 'activation_status' => $activation_status, ) ); @@ -1390,7 +1393,7 @@ public function activate_license( $license_item, $product_type = '' ) { $purchased_items = $user_purchased[ $product_type ]; // Append new product - $product_key = $this->get_product_key_from_permalink( $license_item['permalink'] ); + $product_key = $this->get_product_key_from_permalink( $license_item['permalink'] ); $purchased_items[ $product_key ] = $license_item; $user_purchased[ $product_type ] = $purchased_items; @@ -1418,7 +1421,7 @@ public function handle_file_install_request_from_subscriptions() { $installation_status = $this->install_file_from_subscriptions( array( 'item_key' => $item_key, - 'type' => $type, + 'type' => $type, ) ); @@ -1429,7 +1432,7 @@ public function handle_file_install_request_from_subscriptions() { public function install_file_from_subscriptions( array $args = array() ) { $default = array( 'item_key' => '', - 'type' => '', + 'type' => '', ); $args = array_merge( $default, $args ); @@ -1518,7 +1521,7 @@ public function install_file_from_subscriptions( array $args = array() ) { // handle_plugin_download_request public function handle_file_download_request() { - $status = array( 'success' => true ); + $status = array( 'success' => true ); if ( ! directorist_verify_nonce( 'nonce', 'atbdp_nonce_action_js' ) ) { $status['success'] = false; @@ -1601,7 +1604,7 @@ public function download_plugin( array $args = array() ) { $status = array( 'success' => false ); $default = array( - 'url' => '', + 'url' => '', 'init_wp_filesystem' => true, ); $args = array_merge( $default, $args ); @@ -1660,7 +1663,7 @@ public function download_plugin( array $args = array() ) { function ( $errno, $errstr, $errfile, $errline ) { // error was suppressed with the @-operator if ( 0 === error_reporting() ) { - return false; + return false; } throw new ErrorException( $errstr, 0, $errno, $errfile, $errline ); @@ -1710,7 +1713,7 @@ public function download_theme( array $args = array() ) { $status = array( 'success' => false ); $default = array( - 'url' => '', + 'url' => '', 'init_wp_filesystem' => true, ); $args = array_merge( $default, $args ); @@ -1769,7 +1772,7 @@ public function download_theme( array $args = array() ) { function ( $errno, $errstr, $errfile, $errline ) { // error was suppressed with the @-operator if ( 0 === error_reporting() ) { - return false; + return false; } throw new ErrorException( $errstr, 0, $errno, $errfile, $errline ); @@ -1859,7 +1862,6 @@ public function install_themes_from_zip_files( $zip_files, $temp_dest, $wp_files unzip_file( $zip, $temp_dest ); // @unlink( $zip ); } - } // get_customers_purchased @@ -1883,7 +1885,7 @@ public function get_customers_purchased( $license_data ) { if ( empty( $activation_status['success'] ) ) { $invalid_purchased_extensions[] = array( 'extension' => $extension, - 'response' => $activation_status['response'], + 'response' => $activation_status['response'], ); continue; } @@ -1922,7 +1924,7 @@ public function get_customers_purchased( $license_data ) { $invalid_purchased_themes[] = $theme; $invalid_purchased_themes[] = array( 'extension' => $theme, - 'response' => $activation_status['response'], + 'response' => $activation_status['response'], ); continue; } @@ -1965,7 +1967,7 @@ public function get_customers_purchased( $license_data ) { public function download_purchased_items() { $status = array( 'success' => true, - 'log' => array(), + 'log' => array(), ); if ( ! directorist_verify_nonce( 'nonce', 'atbdp_nonce_action_js' ) ) { @@ -2003,7 +2005,7 @@ public function download_purchased_items() { $this->download_plugin( array( - 'url' => $download_link, + 'url' => $download_link, 'init_wp_filesystem' => false, ) ); @@ -2020,7 +2022,7 @@ public function download_purchased_items() { $this->download_theme( array( - 'url' => $download_link, + 'url' => $download_link, 'init_wp_filesystem' => false, ) ); @@ -2067,11 +2069,11 @@ public function get_extensions_overview() { $installed_extensions[ $plugin_base ] = $plugin_data; if ( is_plugin_active( $plugin_base ) ) { - $total_active_extensions++; + ++$total_active_extensions; } if ( in_array( $plugin_base, $outdated_plugins_key ) ) { - $total_outdated_extensions++; + ++$total_outdated_extensions; } } } @@ -2087,13 +2089,13 @@ public function get_extensions_overview() { $extensions_promo_list = $this->get_extensions_promo_list( array( 'extensions_available_in_subscriptions' => $extensions_available_in_subscriptions, - 'installed_extensions' => $installed_extensions, + 'installed_extensions' => $installed_extensions, ) ); $required_extensions_list = $this->prepare_the_final_requred_extension_list( array( - 'installed_extension_list' => $installed_extensions, + 'installed_extension_list' => $installed_extensions, 'extensions_available_in_subscriptions' => $extensions_available_in_subscriptions, ) ); @@ -2103,7 +2105,7 @@ public function get_extensions_overview() { $total_available_extensions = $total_installed_ext_list + $total_ext_available_in_subscriptions; $overview = array( - 'outdated_plugin_list' => is_array( $outdated_plugins ) ? $outdated_plugins : [], + 'outdated_plugin_list' => is_array( $outdated_plugins ) ? $outdated_plugins : array(), 'outdated_plugins_key' => $outdated_plugins_key, 'all_installed_plugins_list' => $all_installed_plugins_list, 'installed_extension_list' => $installed_extensions, @@ -2234,11 +2236,11 @@ public function get_themes_overview() { ); if ( $active_theme_slug === $theme_base ) { - $total_active_themes++; + ++$total_active_themes; } if ( in_array( $theme_base, $outdated_themes_keys ) ) { - $total_outdated_themes++; + ++$total_outdated_themes; } } } @@ -2504,7 +2506,7 @@ public static function get_file_download_link( $file_item = array(), $product_ty 'get_info' => 'download_link', ); - if( ATBDP()->beta ) { + if ( ATBDP()->beta ) { $query_args['beta'] = true; } @@ -2592,7 +2594,7 @@ public function show_extension_view() { 'ATBDP_Extensions' => $this, 'is_logged_in' => $is_logged_in, 'hard_logout' => $hard_logout, - 'is_beta' => ATBDP()->beta, + 'is_beta' => ATBDP()->beta, 'total_active_extensions' => $extensions_overview['total_active_extensions'], 'total_outdated_extensions' => $extensions_overview['total_outdated_extensions'], @@ -2637,7 +2639,6 @@ protected function is_varified_host( $extension_url ) { return in_array( parse_url( $extension_url, PHP_URL_HOST ), $signed_hostnames, true ); } - } -} \ No newline at end of file +} diff --git a/includes/classes/class-geo-query.php b/includes/classes/class-geo-query.php index 4a81c868e7..ebb47ae891 100644 --- a/includes/classes/class-geo-query.php +++ b/includes/classes/class-geo-query.php @@ -48,27 +48,27 @@ public function posts_join( $sql, $query ) { public function posts_where( $sql, $query ) { global $wpdb; $atbdp_geo_query = $query->get( 'atbdp_geo_query' ); - + if ( $atbdp_geo_query ) { $lat_field = ! empty( $atbdp_geo_query['lat_field'] ) ? $atbdp_geo_query['lat_field'] : 'latitude'; $lng_field = ! empty( $atbdp_geo_query['lng_field'] ) ? $atbdp_geo_query['lng_field'] : 'longitude'; - + // Use the distance range from the query arguments $min_distance = isset( $atbdp_geo_query['min_distance'] ) ? $atbdp_geo_query['min_distance'] : 0; $max_distance = isset( $atbdp_geo_query['max_distance'] ) ? $atbdp_geo_query['max_distance'] : 100; - + if ( $sql ) { $sql .= ' AND '; } - + // Generate the Haversine formula for distance $haversine = $this->haversine_term( $atbdp_geo_query ); - + // Prepare SQL with BETWEEN for min and max distance $new_sql = '( atbdp_geo_query_lat.meta_key = %s AND atbdp_geo_query_lng.meta_key = %s AND ' . $haversine . ' BETWEEN %f AND %f )'; - $sql .= $wpdb->prepare( $new_sql, $lat_field, $lng_field, $min_distance, $max_distance ); + $sql .= $wpdb->prepare( $new_sql, $lat_field, $lng_field, $min_distance, $max_distance ); } - + return $sql; } @@ -119,8 +119,8 @@ private function haversine_term( $atbdp_geo_query ) { } $lat_field = 'atbdp_geo_query_lat.meta_value'; $lng_field = 'atbdp_geo_query_lng.meta_value'; - $lat = 0; - $lng = 0; + $lat = 0; + $lng = 0; if ( isset( $atbdp_geo_query['latitude'] ) ) { $lat = $atbdp_geo_query['latitude']; } diff --git a/includes/classes/class-helper.php b/includes/classes/class-helper.php index d49e7bc216..5ac4f04c83 100644 --- a/includes/classes/class-helper.php +++ b/includes/classes/class-helper.php @@ -19,7 +19,7 @@ public function __construct() { public static function get_default_slider( $args ) { $gallery_image = ''; /* - $args = array( + $args = array( 'image_links' => '', 'plan_slider' => '', 'listing_prv_img' => '', @@ -51,7 +51,7 @@ public static function get_default_slider( $args ) { $gallery_image .= '<div class="atbd_big_gallery">'; $gallery_image .= '<div class="atbd_directory_gallery">'; foreach ( $args['image_links'] as $image_link ) { - $image_link = ! empty( $image_link ) ? $image_link : ''; + $image_link = ! empty( $image_link ) ? $image_link : ''; $gallery_image .= '<div class="single_image">'; $gallery_image .= '<img src="' . esc_url( $image_link ) . '" alt=" ' . esc_html( $args['p_title'] ) . '">'; $gallery_image .= '</div>'; @@ -61,11 +61,11 @@ public static function get_default_slider( $args ) { $gallery_image .= '<span class="prev fa fa-angle-left"></span>'; $gallery_image .= '<span class="next fa fa-angle-right"></span>'; } - $gallery_image .= '</div>'; + $gallery_image .= '</div>'; $image_links_thumbnails = ! empty( $args['image_links_thumbnails'] ) ? $args['image_links_thumbnails'] : array(); $listing_prv_img = ! empty( $args['listing_prv_img'] ) ? $args['listing_prv_img'] : ''; if ( ! empty( $args['display_thumbnail_img'] ) && ( 1 != count( $image_links_thumbnails ) || ( ! empty( $listing_prv_img ) && ! empty( $display_prv_image ) ) ) ) { - $gallery_image .= '<div class="atbd_directory_image_thumbnail">'; + $gallery_image .= '<div class="atbd_directory_image_thumbnail">'; $listing_prv_imgurl_thumb = ! empty( $listing_prv_img ) ? atbdp_get_image_source( $listing_prv_img, 'thumbnail' ) : ''; if ( ! empty( $listing_prv_imgurl_thumb && ! empty( $args['display_prv_image'] ) ) ) { array_unshift( $image_links_thumbnails, $listing_prv_imgurl_thumb ); @@ -84,10 +84,10 @@ public static function get_default_slider( $args ) { } elseif ( ! empty( $args['display_prv_image'] ) ) { $default_image = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); $listing_prv_image = ! empty( $listing_prv_img ) ? esc_url( $listing_prv_imgurl ) : $default_image; - $gallery_image .= '<div class="single_image">'; - $gallery_image .= '<img src="' . $listing_prv_image . '" + $gallery_image .= '<div class="single_image">'; + $gallery_image .= '<img src="' . $listing_prv_image . '" alt="' . esc_html( $args['p_title'] ) . '">'; - $gallery_image .= '</div>'; + $gallery_image .= '</div>'; } return $gallery_image; @@ -177,17 +177,17 @@ public static function atbdp_thumbnail_card( $img_src = '', $_args = array() ) { if ( $by_ratio ) { $padding_top_value = (int) $ratio_height / (int) $ratio_width * 100; $padding_top_css = "padding-top: $padding_top_value%;"; - $style .= $padding_top_css; + $style .= $padding_top_css; } else { $height_value = (int) $ratio_height; $height_css = "height: {$height_value}px;"; - $style .= $height_css; + $style .= $height_css; } $background_color_css = ''; if ( 'full' !== $image_size && ! $blur_background ) { $background_color_css = "background-color: $background_color"; - $style .= $background_color_css; + $style .= $background_color_css; } // Card Front Wrap @@ -237,10 +237,10 @@ public static function atbdp_thumbnail_card( $img_src = '', $_args = array() ) { 'style' => array(), ), 'img' => array( - 'src' => array(), - 'alt' => array(), + 'src' => array(), + 'alt' => array(), 'class' => array(), - ) + ), ) ); } @@ -276,7 +276,7 @@ public function verify_nonce( $nonce = '', $action = '', $method = '_REQUEST' ) // else check provided nonce and action if ( empty( $nonce ) || empty( $action ) ) { $nonce_name = $this->nonce_name(); - $nonce = ! empty( ${$method[ $nonce_name ]} ) ? ${$method[ $nonce_name ]} : null; + $nonce = ! empty( ${$method[ $nonce_name ]} ) ? ${$method[ $nonce_name ]} : null; $nonce_action = $this->nonce_action(); } else { $nonce = ( ! empty( $_REQUEST[ $nonce ] ) ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $nonce ] ) ) : null; @@ -363,8 +363,8 @@ public function adjust_brightness( $hex, $percent, $darken = true ) { $return = '#'; foreach ( $color_parts as $color ) { - $color = hexdec( $color ); // Convert to decimal - $color = max( 0, min( 255, $color + $steps ) ); // Adjust color + $color = hexdec( $color ); // Convert to decimal + $color = max( 0, min( 255, $color + $steps ) ); // Adjust color $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code } @@ -636,7 +636,7 @@ public function output_listings_all_taxonomy_info( $cats = array(), $locs = arra <p class="info_title"><?php esc_html_e( 'Location:', 'directorist' ); ?></p> <?php foreach ( $locs as $loc ) { - $location_count--; // reduce count to display comma for the right item + --$location_count; // reduce count to display comma for the right item ?> <li> <span><?php if ( is_object( $loc ) ) { ?> diff --git a/includes/classes/class-image-resizer.php b/includes/classes/class-image-resizer.php index 9178aaefcb..b7c0c9030f 100644 --- a/includes/classes/class-image-resizer.php +++ b/includes/classes/class-image-resizer.php @@ -2,163 +2,166 @@ /** * Exit if accessed directly */ -if ( ! defined('ABSPATH')) { - exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; } -class Atbdp_Image_resizer -{ - /** - * The attachment image ID - * - * @var int - */ - protected $attachmentId; - - /** - * Constructor - * - * @param int $attachmentId - * @return void - */ - public function __construct($attachmentId) - { - $this->attachmentId = ( is_string( $attachmentId ) || is_int( $attachmentId ) ) ? $attachmentId : '' ; - } - - /** - * Resizes an attachment image - * - * @param int $width - * @param int $height - * @param boolean $crop - * @param int $quality - * @return array - */ - public function resize($width, $height, $crop = true, $quality = 100) - { - global $wpdb; - - // Get the attachment - $attachmentUrl = wp_get_attachment_url($this->attachmentId, 'full'); - - // Bail if we don't have an attachment URL - if ( ! $attachmentUrl ) { - return array('url' => $this->attachmentId, 'width' => $width, 'height' => $height); - } - - // Get the image file path - $filePath = parse_url($attachmentUrl); - $filePath = ! empty( $_SERVER['DOCUMENT_ROOT'] ) ? directorist_clean( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ) . $filePath['path'] : ''; - - // Additional handling for multisite - if (is_multisite()) { - global $blog_id; - $blogDetails = get_blog_details($blog_id); - $filePath = str_replace($blogDetails->path . 'files/', '/wp-content/blogs.dir/'. $blog_id .'/files/', $filePath); - } - - // Destination width and height variables - $destWidth = apply_filters('easingslider_resize_image_width', $width, $attachmentUrl); - $destHeight = apply_filters('easingslider_resize_image_height', $height, $attachmentUrl); - - // File name suffix (appended to original file name) - $suffix = "{$destWidth}x{$destHeight}"; - - // Some additional info about the image - $info = pathinfo($filePath); - $dir = $info['dirname']; - $ext = $info['extension']; - $name = wp_basename($filePath, ".$ext"); - - // Suffix applied to filename - $suffix = "{$destWidth}x{$destHeight}"; - - // Get the destination file name - $destFileName = "{$dir}/{$name}-{$suffix}.{$ext}"; - - // Execute the resizing if resized image doesn't already exist. - if ( ! file_exists($destFileName)) { - - // Load Wordpress Image Editor - $editor = wp_get_image_editor($filePath); - - // Bail if we encounter a WP_Error - if (is_wp_error($editor)) { - return array('url' => $attachmentUrl, 'width' => $width, 'height' => $height); - } - - // Set the quality - $editor->set_quality($quality); - - // Get the original image size - $size = $editor->get_size(); - $origWidth = $size['width']; - $origHeight = $size['height']; - - $srcX = $srcY = 0; - $srcW = $origWidth; - $srcH = $origHeight; - - // Handle cropping - if ($crop) { - - $cmpX = $origWidth / $destWidth; - $cmpY = $origHeight / $destHeight; - - // Calculate x or y coordinate, and width or height of source - if ($cmpX > $cmpY) { - $srcW = round($origWidth / $cmpX * $cmpY); - $srcX = round(($origWidth - ($origWidth / $cmpX * $cmpY)) / 2); - } - else if ($cmpY > $cmpX) { - $srcH = round($origHeight / $cmpY * $cmpX); - $srcY = round(($origHeight - ($origHeight / $cmpY * $cmpX)) / 2); - } - - } - - // Time to crop the image - $editor->crop($srcX, $srcY, $srcW, $srcH, $destWidth, $destHeight); - - // Now let's save the image - $saved = $editor->save($destFileName); - - // Get resized image information - $resizedUrl = str_replace(basename($attachmentUrl), basename($saved['path']), $attachmentUrl); - $resizedWidth = $saved['width']; - $resizedHeight = $saved['height']; - $resizedType = $saved['mime-type']; - - /** - * Add the resized dimensions to original image metadata - * - * This ensures our resized images are deleted when the original image is deleted from the Media Library - */ - $metadata = wp_get_attachment_metadata($this->attachmentId); - if (isset($metadata['image_meta'])) { - $metadata['image_meta']['resized_images'][] = $resizedWidth .'x'. $resizedHeight; - wp_update_attachment_metadata($this->attachmentId, $metadata); - } - - // Create the image array - $resizedImage = array( - 'url' => $resizedUrl, - 'width' => $resizedWidth, - 'height' => $resizedHeight, - 'type' => $resizedType - ); - - } - else { - $resizedImage = array( - 'url' => str_replace(basename($attachmentUrl), basename($destFileName), $attachmentUrl), - 'width' => $destWidth, - 'height' => $destHeight, - 'type' => $ext - ); - } - - // And we're done! - return $resizedImage; - } +class Atbdp_Image_resizer { + + /** + * The attachment image ID + * + * @var int + */ + protected $attachmentId; + + /** + * Constructor + * + * @param int $attachmentId + * @return void + */ + public function __construct( $attachmentId ) { + $this->attachmentId = ( is_string( $attachmentId ) || is_int( $attachmentId ) ) ? $attachmentId : ''; + } + + /** + * Resizes an attachment image + * + * @param int $width + * @param int $height + * @param boolean $crop + * @param int $quality + * @return array + */ + public function resize( $width, $height, $crop = true, $quality = 100 ) { + global $wpdb; + + // Get the attachment + $attachmentUrl = wp_get_attachment_url( $this->attachmentId, 'full' ); + + // Bail if we don't have an attachment URL + if ( ! $attachmentUrl ) { + return array( + 'url' => $this->attachmentId, + 'width' => $width, + 'height' => $height, + ); + } + + // Get the image file path + $filePath = parse_url( $attachmentUrl ); + $filePath = ! empty( $_SERVER['DOCUMENT_ROOT'] ) ? directorist_clean( wp_unslash( $_SERVER['DOCUMENT_ROOT'] ) ) . $filePath['path'] : ''; + + // Additional handling for multisite + if ( is_multisite() ) { + global $blog_id; + $blogDetails = get_blog_details( $blog_id ); + $filePath = str_replace( $blogDetails->path . 'files/', '/wp-content/blogs.dir/' . $blog_id . '/files/', $filePath ); + } + + // Destination width and height variables + $destWidth = apply_filters( 'easingslider_resize_image_width', $width, $attachmentUrl ); + $destHeight = apply_filters( 'easingslider_resize_image_height', $height, $attachmentUrl ); + + // File name suffix (appended to original file name) + $suffix = "{$destWidth}x{$destHeight}"; + + // Some additional info about the image + $info = pathinfo( $filePath ); + $dir = $info['dirname']; + $ext = $info['extension']; + $name = wp_basename( $filePath, ".$ext" ); + + // Suffix applied to filename + $suffix = "{$destWidth}x{$destHeight}"; + + // Get the destination file name + $destFileName = "{$dir}/{$name}-{$suffix}.{$ext}"; + + // Execute the resizing if resized image doesn't already exist. + if ( ! file_exists( $destFileName ) ) { + + // Load WordPress Image Editor + $editor = wp_get_image_editor( $filePath ); + + // Bail if we encounter a WP_Error + if ( is_wp_error( $editor ) ) { + return array( + 'url' => $attachmentUrl, + 'width' => $width, + 'height' => $height, + ); + } + + // Set the quality + $editor->set_quality( $quality ); + + // Get the original image size + $size = $editor->get_size(); + $origWidth = $size['width']; + $origHeight = $size['height']; + + $srcX = $srcY = 0; + $srcW = $origWidth; + $srcH = $origHeight; + + // Handle cropping + if ( $crop ) { + + $cmpX = $origWidth / $destWidth; + $cmpY = $origHeight / $destHeight; + + // Calculate x or y coordinate, and width or height of source + if ( $cmpX > $cmpY ) { + $srcW = round( $origWidth / $cmpX * $cmpY ); + $srcX = round( ( $origWidth - ( $origWidth / $cmpX * $cmpY ) ) / 2 ); + } elseif ( $cmpY > $cmpX ) { + $srcH = round( $origHeight / $cmpY * $cmpX ); + $srcY = round( ( $origHeight - ( $origHeight / $cmpY * $cmpX ) ) / 2 ); + } + } + + // Time to crop the image + $editor->crop( $srcX, $srcY, $srcW, $srcH, $destWidth, $destHeight ); + + // Now let's save the image + $saved = $editor->save( $destFileName ); + + // Get resized image information + $resizedUrl = str_replace( basename( $attachmentUrl ), basename( $saved['path'] ), $attachmentUrl ); + $resizedWidth = $saved['width']; + $resizedHeight = $saved['height']; + $resizedType = $saved['mime-type']; + + /** + * Add the resized dimensions to original image metadata + * + * This ensures our resized images are deleted when the original image is deleted from the Media Library + */ + $metadata = wp_get_attachment_metadata( $this->attachmentId ); + if ( isset( $metadata['image_meta'] ) ) { + $metadata['image_meta']['resized_images'][] = $resizedWidth . 'x' . $resizedHeight; + wp_update_attachment_metadata( $this->attachmentId, $metadata ); + } + + // Create the image array + $resizedImage = array( + 'url' => $resizedUrl, + 'width' => $resizedWidth, + 'height' => $resizedHeight, + 'type' => $resizedType, + ); + + } else { + $resizedImage = array( + 'url' => str_replace( basename( $attachmentUrl ), basename( $destFileName ), $attachmentUrl ), + 'width' => $destWidth, + 'height' => $destHeight, + 'type' => $ext, + ); + } + + // And we're done! + return $resizedImage; + } } diff --git a/includes/classes/class-installation.php b/includes/classes/class-installation.php index 35ff28c7c1..92ff148a0b 100644 --- a/includes/classes/class-installation.php +++ b/includes/classes/class-installation.php @@ -13,206 +13,206 @@ if ( ! class_exists( 'ATBDP_Installation' ) ) : -/** - * Directorist installation class. - */ -class ATBDP_Installation { - /** - * DB updates and callbacks that need to be run per version. - * - * @since 7.1.0 - * @var array + * Directorist installation class. */ - private static $db_updates = array( - '7.1.0' => [ - 'directorist_710_migrate_reviews_table_to_comments_table', - 'directorist_710_migrate_posts_table_to_comments_table', - 'directorist_710_review_rating_clear_transients', - 'directorist_710_update_db_version', - ], - '7.10.0' => [ - 'directorist_7100_clean_falsy_never_expire_meta', - 'directorist_7100_migrate_expired_meta_to_expired_status', - // 'directorist_7100_clean_listing_status_expired_meta', // Use this in future version to cleanup old data. - 'directorist_7100_update_db_version', - ], - '7.11.0' => [ - 'directorist_7110_merge_dashboard_login_registration_page', - 'directorist_7110_update_db_version', - ], - '7.12.3' => [ - 'directorist_7123_remove_upload_files_cap', - 'directorist_7123_update_db_version', - ], - '8.0.0' => [ - 'directorist_800_update_db_version', - ] - ); + class ATBDP_Installation { + + /** + * DB updates and callbacks that need to be run per version. + * + * @since 7.1.0 + * @var array + */ + private static $db_updates = array( + '7.1.0' => array( + 'directorist_710_migrate_reviews_table_to_comments_table', + 'directorist_710_migrate_posts_table_to_comments_table', + 'directorist_710_review_rating_clear_transients', + 'directorist_710_update_db_version', + ), + '7.10.0' => array( + 'directorist_7100_clean_falsy_never_expire_meta', + 'directorist_7100_migrate_expired_meta_to_expired_status', + // 'directorist_7100_clean_listing_status_expired_meta', // Use this in future version to cleanup old data. + 'directorist_7100_update_db_version', + ), + '7.11.0' => array( + 'directorist_7110_merge_dashboard_login_registration_page', + 'directorist_7110_update_db_version', + ), + '7.12.3' => array( + 'directorist_7123_remove_upload_files_cap', + 'directorist_7123_update_db_version', + ), + '8.0.0' => array( + 'directorist_800_update_db_version', + ), + ); + + /** + * Background update class. + * + * @since 7.1.0 + * @var object + */ + private static $background_updater; + + /** + * It installs the required features or options for the plugin to run properly. + * + * @link https://codex.wordpress.org/Function_Reference/register_post_type + * @return void + */ + public static function install() { + require_once ATBDP_CLASS_DIR . 'class-custom-post.php'; // include custom post class + require_once ATBDP_CLASS_DIR . 'class-roles.php'; // include custom roles and Caps + + $ATBDP_Custom_Post = new ATBDP_Custom_Post(); + $ATBDP_Custom_Post->register_new_post_types(); + + flush_rewrite_rules(); // lets flash the rewrite rules as we have registered the custom post + + // Add custom ATBDP_Roles & Capabilities + if ( ! get_option( 'atbdp_roles_mapped' ) ) { + $roles = new ATBDP_Roles(); + $roles->add_caps(); + } - /** - * Background update class. - * - * @since 7.1.0 - * @var object - */ - private static $background_updater; + // Insert atbdp_roles_mapped option to the db to prevent mapping meta cap + add_option( 'atbdp_roles_mapped', true ); - /** - *It installs the required features or options for the plugin to run properly. - * @link https://codex.wordpress.org/Function_Reference/register_post_type - * @return void - */ - public static function install() { - require_once ATBDP_CLASS_DIR . 'class-custom-post.php'; // include custom post class - require_once ATBDP_CLASS_DIR . 'class-roles.php'; // include custom roles and Caps - - $ATBDP_Custom_Post = new ATBDP_Custom_Post(); - $ATBDP_Custom_Post->register_new_post_types(); - - flush_rewrite_rules(); // lets flash the rewrite rules as we have registered the custom post - - // Add custom ATBDP_Roles & Capabilities - if ( ! get_option( 'atbdp_roles_mapped' ) ) { - $roles = new ATBDP_Roles; - $roles->add_caps(); - } - - // Insert atbdp_roles_mapped option to the db to prevent mapping meta cap - add_option( 'atbdp_roles_mapped', true ); + $atbdp_option = get_option( 'atbdp_option' ); + $atpdp_setup_wizard = apply_filters( 'atbdp_setup_wizard', true ); - $atbdp_option = get_option( 'atbdp_option' ); - $atpdp_setup_wizard = apply_filters( 'atbdp_setup_wizard', true ); + if ( ! $atbdp_option && $atpdp_setup_wizard ) { + update_option( 'directorist_merge_dashboard_login_reg_page', true ); + set_transient( '_directorist_setup_page_redirect', true, 30 ); + } - if( ! $atbdp_option && $atpdp_setup_wizard ) { - update_option( 'directorist_merge_dashboard_login_reg_page', true ); - set_transient( '_directorist_setup_page_redirect', true, 30 ); + self::maybe_update_db_version(); } - self::maybe_update_db_version(); - } - - public static function init() { - add_action( 'init', [ __CLASS__, 'init_background_updater' ], 5 ); - add_action( 'admin_init', [ __CLASS__, 'install_actions' ] ); - } - - /** - * Init background updates - * - * @since 7.1.0 - */ - public static function init_background_updater() { - include_once ATBDP_INC_DIR . 'classes/class-background-updater.php'; - self::$background_updater = new \Directorist\Background_Updater(); - } + public static function init() { + add_action( 'init', array( __CLASS__, 'init_background_updater' ), 5 ); + add_action( 'admin_init', array( __CLASS__, 'install_actions' ) ); + } - /** - * Install actions when a update button is clicked within the admin area. - * - * This function is hooked into admin_init to affect admin only. - * - * @since 7.1.0 - */ - public static function install_actions() { - if ( ! empty( $_GET['do_update_directorist'] ) ) { // WPCS: input var ok. - check_admin_referer( 'directorist_db_update', 'directorist_db_update_nonce' ); - self::update(); + /** + * Init background updates + * + * @since 7.1.0 + */ + public static function init_background_updater() { + include_once ATBDP_INC_DIR . 'classes/class-background-updater.php'; + self::$background_updater = new \Directorist\Background_Updater(); } - if ( ! empty( $_GET['force_update_directorist'] ) ) { // WPCS: input var ok. - check_admin_referer( 'directorist_force_db_update', 'directorist_force_db_update_nonce' ); - $blog_id = get_current_blog_id(); + /** + * Install actions when a update button is clicked within the admin area. + * + * This function is hooked into admin_init to affect admin only. + * + * @since 7.1.0 + */ + public static function install_actions() { + if ( ! empty( $_GET['do_update_directorist'] ) ) { // WPCS: input var ok. + check_admin_referer( 'directorist_db_update', 'directorist_db_update_nonce' ); + self::update(); + } + + if ( ! empty( $_GET['force_update_directorist'] ) ) { // WPCS: input var ok. + check_admin_referer( 'directorist_force_db_update', 'directorist_force_db_update_nonce' ); + $blog_id = get_current_blog_id(); - // Used to fire an action added in WP_Background_Process::_construct() that calls WP_Background_Process::handle_cron_healthcheck(). - // This method will make sure the database updates are executed even if cron is disabled. Nothing will happen if the updates are already running. - do_action( 'wp_' . $blog_id . '_directorist_updater_cron' ); + // Used to fire an action added in WP_Background_Process::_construct() that calls WP_Background_Process::handle_cron_healthcheck(). + // This method will make sure the database updates are executed even if cron is disabled. Nothing will happen if the updates are already running. + do_action( 'wp_' . $blog_id . '_directorist_updater_cron' ); - wp_safe_redirect( admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-settings' ) ); - exit; + wp_safe_redirect( admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-settings' ) ); + exit; + } } - } - /** - * Get list of DB update callbacks. - * - * @since 7.1.0 - * @return array - */ - public static function get_db_update_callbacks() { - return self::$db_updates; - } + /** + * Get list of DB update callbacks. + * + * @since 7.1.0 + * @return array + */ + public static function get_db_update_callbacks() { + return self::$db_updates; + } - /** - * Push all needed DB updates to the queue for processing. - * - * @since 7.1.0 - */ - private static function update() { - $current_db_version = get_option( 'directorist_db_version' ); - $update_queued = false; - - foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) { - if ( version_compare( $current_db_version, $version, '<' ) ) { - foreach ( $update_callbacks as $update_callback ) { - self::$background_updater->push_to_queue( $update_callback ); - $update_queued = true; + /** + * Push all needed DB updates to the queue for processing. + * + * @since 7.1.0 + */ + private static function update() { + $current_db_version = get_option( 'directorist_db_version' ); + $update_queued = false; + + foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) { + if ( version_compare( $current_db_version, $version, '<' ) ) { + foreach ( $update_callbacks as $update_callback ) { + self::$background_updater->push_to_queue( $update_callback ); + $update_queued = true; + } } } - } - if ( $update_queued ) { - self::$background_updater->save()->dispatch(); + if ( $update_queued ) { + self::$background_updater->save()->dispatch(); + } } - } - - /** - * Update DB version to current. - * - * @since 7.1.0 - * @param string|null $version New Directorist DB version or null. - */ - public static function update_db_version( $version = null ) { - delete_option( 'directorist_db_version' ); - add_option( 'directorist_db_version', is_null( $version ) ? ATBDP_VERSION : $version ); - } - /** - * See if we need to show or run database updates during install. - * - * @since 7.1.0 - */ - private static function maybe_update_db_version() { - // Probably new installation, so add current db version. - if ( ! get_option( 'directorist_setup_wizard_completed' ) && ! get_option( 'directorist_db_version', null ) ) { - self::update_db_version(); + /** + * Update DB version to current. + * + * @since 7.1.0 + * @param string|null $version New Directorist DB version or null. + */ + public static function update_db_version( $version = null ) { + delete_option( 'directorist_db_version' ); + add_option( 'directorist_db_version', is_null( $version ) ? ATBDP_VERSION : $version ); } - if ( self::needs_db_update() ) { - if ( apply_filters( 'directorist/updater/enable_db_auto_update', false ) ) { - self::init_background_updater(); - self::update(); + /** + * See if we need to show or run database updates during install. + * + * @since 7.1.0 + */ + private static function maybe_update_db_version() { + // Probably new installation, so add current db version. + if ( ! get_option( 'directorist_setup_wizard_completed' ) && ! get_option( 'directorist_db_version', null ) ) { + self::update_db_version(); } - } else { - self::update_db_version(); - } - } - /** - * Is a DB update needed? - * - * @since 7.1.0 - * @return boolean - */ - public static function needs_db_update() { - $current_db_version = get_option( 'directorist_db_version', null ); - $updates = self::get_db_update_callbacks(); + if ( self::needs_db_update() ) { + if ( apply_filters( 'directorist/updater/enable_db_auto_update', false ) ) { + self::init_background_updater(); + self::update(); + } + } else { + self::update_db_version(); + } + } - return ( is_null( $current_db_version ) || version_compare( $current_db_version, max( array_keys( $updates ) ), '<' ) ); + /** + * Is a DB update needed? + * + * @since 7.1.0 + * @return boolean + */ + public static function needs_db_update() { + $current_db_version = get_option( 'directorist_db_version', null ); + $updates = self::get_db_update_callbacks(); + + return ( is_null( $current_db_version ) || version_compare( $current_db_version, max( array_keys( $updates ) ), '<' ) ); + } } -} - -ATBDP_Installation::init(); + ATBDP_Installation::init(); -endif; \ No newline at end of file +endif; diff --git a/includes/classes/class-listing-db.php b/includes/classes/class-listing-db.php index f3cc59939d..119cf362d1 100644 --- a/includes/classes/class-listing-db.php +++ b/includes/classes/class-listing-db.php @@ -13,110 +13,106 @@ use Directorist\database\DB; // Exit if accessed directly -if ( ! defined('ABSPATH') ) { die( 'Sorry, it is not your place to have fun..' ); } - -if (!class_exists('ATBDP_Listing_DB')): -class ATBDP_Listing_DB { - - public function __construct () - { - add_action( 'before_delete_post', array( $this, 'atbdp_delete_attachment' ) ); - } - - /** - * @param init $id Current post id - * @since 6.4.1 - * - */ - public function atbdp_delete_attachment($id){ - - if( 'at_biz_dir' === get_post_type( $id ) ){ - $listing_img = directorist_get_listing_gallery_images( $id ); - $listing_img = !empty($listing_img) ? $listing_img : array(); - $listing_prv_img = directorist_get_listing_preview_image( $id ); - - if ( is_array( $listing_img ) ) { - array_unshift($listing_img, $listing_prv_img); - } - - if ( ! empty( $listing_img ) ) { - foreach ( $listing_img as $image ) { - wp_delete_attachment( $image, true ); - } - } - } - } - - /** - * Unused method - * - * @return bool - */ - public function all_listing() { - _deprecated_function( __METHOD__, '7.4.3' ); - return false; - } - - public function get_listing_order_by_featured() - { - $args = array( - 'post_type' => ATBDP_POST_TYPE, - 'post_per_page'=>-1 - ); - } - - /** - * It returns all the listing of the given user or the current user if no user id is passed. - * @param int $user_id [optional] The id of the user. Default is current user id. - * @return WP_Query it returns an object of the WP_Query class with the items/listings on success and false on failure. - */ - public function get_listing_by_user( $user_id = 0 ) - { - $pagination = get_directorist_option('user_listings_pagination',1); - $listingS_per_page = get_directorist_option('user_listings_per_page',9); - - //for pagination - $paged = atbdp_get_paged_num(); - $args = array( - 'author' => ! empty( $user_id ) ? absint( $user_id ) : get_current_user_id(), - 'post_type' => ATBDP_POST_TYPE, - 'posts_per_page' => (int) $listingS_per_page, - 'order' => 'DESC', - 'orderby' => 'date', - 'post_status' => array( 'publish', 'pending', 'private', 'draft' ), - ); - if( ! empty( $pagination) ) { - $args['paged'] = $paged; - }else{ - $args['no_found_rows'] = false; - } - $args = apply_filters('atbdp_user_dashboard_query_arguments', $args); - return new WP_Query(apply_filters('atbdp_user_dashboard_query_arguments',$args)); - } - - /** - * It deletes a specific listing along with its meta and reviews by listing id - * @param int $id The ID of the listing that should be deleted - * @return bool It returns true on success and false on failure - */ - public function delete_listing_by_id($id) - { - - $deleted = wp_delete_post(absint($id), true); // i - if ( false !== $deleted ) { - do_action( 'directorist_listing_deleted', $id ); - return true; - } - return false; - - } - //@TODO; methods to add: delete all listing by user - - public function get_favourites( $user_id = 0 ) { - _deprecated_function( __METHOD__, '7.4.3', 'DB::favorite_listings_query' ); - return DB::favorite_listings_query(); - } - -} // ends class ATBDP_Listing_DB - -endif; \ No newline at end of file +if ( ! defined( 'ABSPATH' ) ) { + die( 'Sorry, it is not your place to have fun..' ); } + +if ( ! class_exists( 'ATBDP_Listing_DB' ) ) : + class ATBDP_Listing_DB { + + public function __construct() { + add_action( 'before_delete_post', array( $this, 'atbdp_delete_attachment' ) ); + } + + /** + * @param init $id Current post id + * @since 6.4.1 + */ + public function atbdp_delete_attachment( $id ) { + + if ( 'at_biz_dir' === get_post_type( $id ) ) { + $listing_img = directorist_get_listing_gallery_images( $id ); + $listing_img = ! empty( $listing_img ) ? $listing_img : array(); + $listing_prv_img = directorist_get_listing_preview_image( $id ); + + if ( is_array( $listing_img ) ) { + array_unshift( $listing_img, $listing_prv_img ); + } + + if ( ! empty( $listing_img ) ) { + foreach ( $listing_img as $image ) { + wp_delete_attachment( $image, true ); + } + } + } + } + + /** + * Unused method + * + * @return bool + */ + public function all_listing() { + _deprecated_function( __METHOD__, '7.4.3' ); + return false; + } + + public function get_listing_order_by_featured() { + $args = array( + 'post_type' => ATBDP_POST_TYPE, + 'post_per_page' => -1, + ); + } + + /** + * It returns all the listing of the given user or the current user if no user id is passed. + * + * @param int $user_id [optional] The id of the user. Default is current user id. + * @return WP_Query it returns an object of the WP_Query class with the items/listings on success and false on failure. + */ + public function get_listing_by_user( $user_id = 0 ) { + $pagination = get_directorist_option( 'user_listings_pagination', 1 ); + $listingS_per_page = get_directorist_option( 'user_listings_per_page', 9 ); + + // for pagination + $paged = atbdp_get_paged_num(); + $args = array( + 'author' => ! empty( $user_id ) ? absint( $user_id ) : get_current_user_id(), + 'post_type' => ATBDP_POST_TYPE, + 'posts_per_page' => (int) $listingS_per_page, + 'order' => 'DESC', + 'orderby' => 'date', + 'post_status' => array( 'publish', 'pending', 'private', 'draft' ), + ); + if ( ! empty( $pagination ) ) { + $args['paged'] = $paged; + } else { + $args['no_found_rows'] = false; + } + $args = apply_filters( 'atbdp_user_dashboard_query_arguments', $args ); + return new WP_Query( apply_filters( 'atbdp_user_dashboard_query_arguments', $args ) ); + } + + /** + * It deletes a specific listing along with its meta and reviews by listing id + * + * @param int $id The ID of the listing that should be deleted + * @return bool It returns true on success and false on failure + */ + public function delete_listing_by_id( $id ) { + + $deleted = wp_delete_post( absint( $id ), true ); // i + if ( false !== $deleted ) { + do_action( 'directorist_listing_deleted', $id ); + return true; + } + return false; + } + // @TODO; methods to add: delete all listing by user + + public function get_favourites( $user_id = 0 ) { + _deprecated_function( __METHOD__, '7.4.3', 'DB::favorite_listings_query' ); + return DB::favorite_listings_query(); + } + } // ends class ATBDP_Listing_DB + +endif; diff --git a/includes/classes/class-listing.php b/includes/classes/class-listing.php index 01403d1919..2486ce143f 100644 --- a/includes/classes/class-listing.php +++ b/includes/classes/class-listing.php @@ -11,56 +11,55 @@ */ // Exit if accessed directly -if (!defined('ABSPATH')) { - die('You should not access this file directly...'); +if ( ! defined( 'ABSPATH' ) ) { + die( 'You should not access this file directly...' ); } -if (!class_exists('ATBDP_Listing')): - - class ATBDP_Listing - { - /** - * ATBDP_Add_Listing Object. - * - * @var object|ATBDP_Add_Listing - * @since 1.0 - */ - public $add_listing; - - /** - * ATBDP_Add_Listing Object. - * - * @var object|ATBDP_Add_Listing - * @since 1.0 - */ - public $db; - - public function __construct() - { - $this->include_files(); - $this->add_listing = new ATBDP_Add_Listing; - $this->db = new ATBDP_Listing_DB; - // for search functionality - // add_action('pre_get_posts', array($this, 'modify_search_query'), 1, 10); - // remove adjacent_posts_rel_link_wp_head for accurate post views - remove_action('wp_head', array($this, 'adjacent_posts_rel_link_wp_head', 10)); - add_action('plugins_loaded', array($this, 'manage_listings_status')); - - add_filter('post_thumbnail_html', array($this, 'post_thumbnail_html'), 10, 3); - add_action('wp_head', array($this, 'og_metatags')); +if ( ! class_exists( 'ATBDP_Listing' ) ) : + + class ATBDP_Listing { + + /** + * ATBDP_Add_Listing Object. + * + * @var object|ATBDP_Add_Listing + * @since 1.0 + */ + public $add_listing; + + /** + * ATBDP_Add_Listing Object. + * + * @var object|ATBDP_Add_Listing + * @since 1.0 + */ + public $db; + + public function __construct() { + $this->include_files(); + $this->add_listing = new ATBDP_Add_Listing(); + $this->db = new ATBDP_Listing_DB(); + // for search functionality + // add_action('pre_get_posts', array($this, 'modify_search_query'), 1, 10); + // remove adjacent_posts_rel_link_wp_head for accurate post views + remove_action( 'wp_head', array( $this, 'adjacent_posts_rel_link_wp_head', 10 ) ); + add_action( 'plugins_loaded', array( $this, 'manage_listings_status' ) ); + + add_filter( 'post_thumbnail_html', array( $this, 'post_thumbnail_html' ), 10, 3 ); + add_action( 'wp_head', array( $this, 'og_metatags' ) ); // add_action('template_redirect', array($this, 'atbdp_listing_status_controller')); // This method has been renamed to update_listing_status_after_review - add_action('template_redirect', array( $this, 'update_listing_status_after_review' ) ); + add_action( 'template_redirect', array( $this, 'update_listing_status_after_review' ) ); - // listing filter - add_action('restrict_manage_posts', array($this, 'atbdp_listings_filter')); - add_filter('parse_query', array($this, 'listing_type_search_query')); + // listing filter + add_action( 'restrict_manage_posts', array( $this, 'atbdp_listings_filter' ) ); + add_filter( 'parse_query', array( $this, 'listing_type_search_query' ) ); - add_action('wp_ajax_directorist_track_listing_views', array( $this, 'directorist_track_listing_views' ) ); - add_action('wp_ajax_nopriv_directorist_track_listing_views', array( $this, 'directorist_track_listing_views' ) ); + add_action( 'wp_ajax_directorist_track_listing_views', array( $this, 'directorist_track_listing_views' ) ); + add_action( 'wp_ajax_nopriv_directorist_track_listing_views', array( $this, 'directorist_track_listing_views' ) ); add_filter( 'the_title', array( $this, 'add_preview_prefix_in_title' ), 10, 2 ); - } + } public function add_preview_prefix_in_title( $title, $listing_id ) { if ( is_admin() || ! directorist_is_listing_post_type( $listing_id ) || ! isset( $_GET['preview'] ) ) { @@ -73,54 +72,56 @@ public function add_preview_prefix_in_title( $title, $listing_id ) { ); } - public function listing_type_search_query( $query ) - { - global $pagenow; - $type = 'post'; - if (isset($_GET['post_type'])) { - $type = ! empty( $_GET['post_type'] ) ? directorist_clean( wp_unslash( $_GET['post_type'] ) ) : ''; - } - if ('at_biz_dir' == $type && is_admin() && $pagenow == 'edit.php' && isset($_GET['directory_type']) && ! empty( $_GET['directory_type'] ) ) { - $value = ! empty( $_GET['directory_type'] ) ? directorist_clean( wp_unslash( $_GET['directory_type'] ) ) : ''; - $tax_query = array( - 'relation' => 'AND', - array( - 'taxonomy' => ATBDP_TYPE, - 'terms' => $value, - ), - ); - $query->set( 'tax_query', $tax_query ); - } - } - - public function atbdp_listings_filter( ) { - $type = 'post'; - if (isset($_GET['post_type'])) { - $type = ! empty( $_GET['post_type'] ) ? directorist_clean( wp_unslash( $_GET['post_type'] ) ) : ''; - } - - //only add filter to post type you want - if ( ( 'at_biz_dir' == $type ) && directorist_is_multi_directory_enabled() ) { ?> - <select name="directory_type"> - <option value=""><?php esc_html_e( 'Filter by directory ', 'directorist' ); ?></option> - <?php - $current_v = ! empty( $_GET['directory_type'] ) ? directorist_clean( wp_unslash( $_GET['directory_type'] ) ) : ''; - - $listing_types = get_terms([ - 'taxonomy' => 'atbdp_listing_types', - 'hide_empty' => false, - ]); - foreach ($listing_types as $listing_type) { ?> - <option value="<?php echo esc_attr( $listing_type->term_id ); ?>" <?php echo $listing_type->term_id == $current_v ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $listing_type->name ); ?></option> - <?php } ?> - </select> - <?php - } - } - - /** - * @since 6.3.5 - */ + public function listing_type_search_query( $query ) { + global $pagenow; + $type = 'post'; + if ( isset( $_GET['post_type'] ) ) { + $type = ! empty( $_GET['post_type'] ) ? directorist_clean( wp_unslash( $_GET['post_type'] ) ) : ''; + } + if ( 'at_biz_dir' == $type && is_admin() && $pagenow == 'edit.php' && isset( $_GET['directory_type'] ) && ! empty( $_GET['directory_type'] ) ) { + $value = ! empty( $_GET['directory_type'] ) ? directorist_clean( wp_unslash( $_GET['directory_type'] ) ) : ''; + $tax_query = array( + 'relation' => 'AND', + array( + 'taxonomy' => ATBDP_TYPE, + 'terms' => $value, + ), + ); + $query->set( 'tax_query', $tax_query ); + } + } + + public function atbdp_listings_filter() { + $type = 'post'; + if ( isset( $_GET['post_type'] ) ) { + $type = ! empty( $_GET['post_type'] ) ? directorist_clean( wp_unslash( $_GET['post_type'] ) ) : ''; + } + + // only add filter to post type you want + if ( ( 'at_biz_dir' == $type ) && directorist_is_multi_directory_enabled() ) { ?> + <select name="directory_type"> + <option value=""><?php esc_html_e( 'Filter by directory ', 'directorist' ); ?></option> + <?php + $current_v = ! empty( $_GET['directory_type'] ) ? directorist_clean( wp_unslash( $_GET['directory_type'] ) ) : ''; + + $listing_types = get_terms( + array( + 'taxonomy' => 'atbdp_listing_types', + 'hide_empty' => false, + ) + ); + foreach ( $listing_types as $listing_type ) { + ?> + <option value="<?php echo esc_attr( $listing_type->term_id ); ?>" <?php echo $listing_type->term_id == $current_v ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $listing_type->name ); ?></option> + <?php } ?> + </select> + <?php + } + } + + /** + * @since 6.3.5 + */ public function update_listing_status_after_review() { // Exit early if listing status or review status isn't set, or if preview mode is enabled if ( ( empty( $_GET['listing_status'] ) && empty( $_GET['reviewed'] ) ) || isset( $_GET['preview'] ) ) { @@ -152,7 +153,7 @@ public function update_listing_status_after_review() { // Trigger custom action after updating listing status do_action( 'directorist_listing_status_updated', $listing_id, $args ); - wp_safe_redirect( remove_query_arg( [ '_token', 'edited', 'post_id', 'reviewed' ] ) ); + wp_safe_redirect( remove_query_arg( array( '_token', 'edited', 'post_id', 'reviewed' ) ) ); } protected function validate_nonce( $listing_id ) { @@ -208,189 +209,189 @@ protected function prepare_post_update_args( $listing_id, $directory_id ) { $edit_status = directorist_get_listing_edit_status( $directory_id, $listing_id ); $edited = isset( $_GET['edited'] ) ? sanitize_text_field( $_GET['edited'] ) : 'no'; - $args = [ + $args = array( 'id' => $listing_id, 'edited' => filter_var( $edited, FILTER_VALIDATE_BOOLEAN ), 'new_l_status' => $create_status, 'edit_l_status' => $edit_status, 'create_status' => $create_status, 'edit_status' => $edit_status, - ]; + ); // Filter for custom argument modifications - return apply_filters( 'atbdp_reviewed_listing_status_controller_argument', [ - 'ID' => $listing_id, - 'post_status' => atbdp_get_listing_status_after_submission( $args ), - 'edited' => $args['edited'], - ] ); + return apply_filters( + 'atbdp_reviewed_listing_status_controller_argument', + array( + 'ID' => $listing_id, + 'post_status' => atbdp_get_listing_status_after_submission( $args ), + 'edited' => $args['edited'], + ) + ); + } + + // manage_listings_status + public function manage_listings_status() { + add_action( 'atbdp_order_created', array( $this, 'update_listing_status' ), 10, 2 ); } - // manage_listings_status - public function manage_listings_status() { - add_action('atbdp_order_created', [ $this, 'update_listing_status'], 10, 2); - } + // update_listing_status + public function update_listing_status( $order_id, $listing_id ) { + $pricing_plan_enabled = is_fee_manager_active(); - // update_listing_status - public function update_listing_status( $order_id, $listing_id ) { - $pricing_plan_enabled = is_fee_manager_active(); + if ( $pricing_plan_enabled ) { + return; + } - if ( $pricing_plan_enabled ) { + if ( ! directorist_is_featured_listing_enabled() ) { return; - }; + } + + $directory_type = directorist_get_listing_directory( $listing_id ); + $post_status = get_term_meta( $directory_type, 'new_listing_status', true ); + + $order_meta = get_post_meta( $order_id ); + $payment_status = $order_meta['_payment_status'][0]; + + if ( 'completed' !== $payment_status ) { + $post_status = 'pending'; + } + + $args = array( + 'ID' => $listing_id, + 'post_status' => $post_status, + ); + + $is_directory_post = ( 'at_biz_dir' === get_post_type( $listing_id ) ) ? true : false; + + if ( $is_directory_post ) { + wp_update_post( apply_filters( 'atbdp_reviewed_listing_status_controller_argument', $args ) ); + } + } + + /** + * Adds the Facebook OG tags and Twitter Cards. + * + * @since 1.0.0 + * @access public + */ + public function og_metatags() { + + global $post; - if ( ! directorist_is_featured_listing_enabled() ) { + if ( ! isset( $post ) ) { return; - }; - - $directory_type = directorist_get_listing_directory( $listing_id ); - $post_status = get_term_meta( $directory_type, 'new_listing_status', true ); - - $order_meta = get_post_meta( $order_id ); - $payment_status = $order_meta['_payment_status'][0]; - - if ( 'completed' !== $payment_status ) { - $post_status = 'pending'; - } - - $args = array( - 'ID' => $listing_id, - 'post_status' => $post_status, - ); - - $is_directory_post = ( 'at_biz_dir' === get_post_type( $listing_id ) ) ? true : false; - - if ( $is_directory_post ) { - wp_update_post( apply_filters('atbdp_reviewed_listing_status_controller_argument', $args) ); - } - } - - /** - * Adds the Facebook OG tags and Twitter Cards. - * - * @since 1.0.0 - * @access public - */ - public function og_metatags() - { - - global $post; - - if (!isset($post)) return; - - if (is_singular('at_biz_dir')) { - - - $title = get_the_title(); - - // Get Location page title - - ?> - <meta property="og:url" content="<?php echo esc_url( atbdp_get_current_url() ); ?>" /> - <meta property="og:type" content="article" /> - <meta property="og:title" content="<?php echo esc_attr( $title ); ?>" /> - <meta property="og:site_name" content="<?php echo esc_attr( get_bloginfo('name') ); ?>" /> - <meta name="twitter:card" content="summary" /> - - <?php - if (!empty($post->post_content)) { ?> - <meta property="og:description" content="<?php echo esc_attr( wp_trim_words($post->post_content, 150) ); ?>" /> - <?php } - - $images = directorist_get_listing_preview_image( $post->ID ); - if (!empty($images)) { - $thumbnail = atbdp_get_image_source($images, 'full'); - - if ( ! empty( $thumbnail ) ) { ?> - <meta property="og:image" content="<?php echo esc_attr( $thumbnail ); ?>" /> - <meta name="twitter:image" content="<?php echo esc_attr( $thumbnail ); ?>" /> - <?php } - - } - - } - - } - - /** - * Filter the post content. - * - * @param string $html The post thumbnail HTML. - * @return string $html Filtered thumbnail HTML. - * @since 5.4.0 - * @access public - * - */ - public function post_thumbnail_html($html, $post_id) - { - $double_thumb = get_directorist_option( 'fix_listing_double_thumb', 1 ); - if (!empty($double_thumb)) { - if (is_singular('at_biz_dir')) { - if (!isset($post_id)) return ''; - if ( ATBDP_POST_TYPE === get_post_type( $post_id ) ) { - $html = ''; - } - } - } - return $html; - } - - public function modify_search_query(WP_Query $query) - { - if (!is_admin() && $query->is_main_query() && $query->is_archive()) { - global $wp_query; - $post_type = get_query_var('post_type'); - $s = get_query_var('s'); - $post_type = (!empty($post_type)) ? $post_type : (!empty($query->post_type) ? $query->post_type : 'any'); - - if ($query->is_search() && $post_type == ATBDP_POST_TYPE) { - /*@TODO; make the number of items to show dynamic using setting panel*/ - $srch_p_num = get_directorist_option('search_posts_num', 6); - $query->set('posts_per_page', absint($srch_p_num)); - - } - return $query; - } else { - return $query; - } - - } - - public function include_files() - { - load_some_file(array('class-template'), ATBDP_CLASS_DIR); - load_some_file(array('class-add-listing'), ATBDP_CLASS_DIR); - load_some_file(array('class-listing-db'), ATBDP_CLASS_DIR); - } - - public function set_post_views($postID) - { - /*@todo; add option to verify the user using his/her IP address so that reloading the page multiple times by the same user does not increase his post view of the same post on the same day.*/ - directorist_set_listing_views_count( $postID ); - } - - public function directorist_track_listing_views() { - if ( ! directorist_verify_nonce() ) { + } + + if ( is_singular( 'at_biz_dir' ) ) { + + $title = get_the_title(); + + // Get Location page title + + ?> + <meta property="og:url" content="<?php echo esc_url( atbdp_get_current_url() ); ?>" /> + <meta property="og:type" content="article" /> + <meta property="og:title" content="<?php echo esc_attr( $title ); ?>" /> + <meta property="og:site_name" content="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" /> + <meta name="twitter:card" content="summary" /> + + <?php + if ( ! empty( $post->post_content ) ) { + ?> + <meta property="og:description" content="<?php echo esc_attr( wp_trim_words( $post->post_content, 150 ) ); ?>" /> + <?php + } + + $images = directorist_get_listing_preview_image( $post->ID ); + if ( ! empty( $images ) ) { + $thumbnail = atbdp_get_image_source( $images, 'full' ); + + if ( ! empty( $thumbnail ) ) { + ?> + <meta property="og:image" content="<?php echo esc_attr( $thumbnail ); ?>" /> + <meta name="twitter:image" content="<?php echo esc_attr( $thumbnail ); ?>" /> + <?php + } + } + } + } + + /** + * Filter the post content. + * + * @param string $html The post thumbnail HTML. + * @return string $html Filtered thumbnail HTML. + * @since 5.4.0 + * @access public + */ + public function post_thumbnail_html( $html, $post_id ) { + $double_thumb = get_directorist_option( 'fix_listing_double_thumb', 1 ); + if ( ! empty( $double_thumb ) ) { + if ( is_singular( 'at_biz_dir' ) ) { + if ( ! isset( $post_id ) ) { + return ''; + } + if ( ATBDP_POST_TYPE === get_post_type( $post_id ) ) { + $html = ''; + } + } + } + return $html; + } + + public function modify_search_query( WP_Query $query ) { + if ( ! is_admin() && $query->is_main_query() && $query->is_archive() ) { + global $wp_query; + $post_type = get_query_var( 'post_type' ); + $s = get_query_var( 's' ); + $post_type = ( ! empty( $post_type ) ) ? $post_type : ( ! empty( $query->post_type ) ? $query->post_type : 'any' ); + + if ( $query->is_search() && $post_type == ATBDP_POST_TYPE ) { + /*@TODO; make the number of items to show dynamic using setting panel*/ + $srch_p_num = get_directorist_option( 'search_posts_num', 6 ); + $query->set( 'posts_per_page', absint( $srch_p_num ) ); + + } + return $query; + } else { + return $query; + } + } + + public function include_files() { + load_some_file( array( 'class-template' ), ATBDP_CLASS_DIR ); + load_some_file( array( 'class-add-listing' ), ATBDP_CLASS_DIR ); + load_some_file( array( 'class-listing-db' ), ATBDP_CLASS_DIR ); + } + + public function set_post_views( $postID ) { + /*@todo; add option to verify the user using his/her IP address so that reloading the page multiple times by the same user does not increase his post view of the same post on the same day.*/ + directorist_set_listing_views_count( $postID ); + } + + public function directorist_track_listing_views() { + if ( ! directorist_verify_nonce() ) { wp_send_json_error( array( - 'error'=> __( 'Session expired, please reload the window and try again.', 'directorist' ), + 'error' => __( 'Session expired, please reload the window and try again.', 'directorist' ), ), ); } - $count_loggedin = get_directorist_option( 'count_loggedin_user' ); - if ( is_user_logged_in() && empty( $count_loggedin ) ) { - return; - } - - if ( isset( $_POST['listing_id'] ) ) { - $listing_id = absint( $_POST['listing_id'] ); - $this->set_post_views( $listing_id ); - // Return 'success' to the AJAX request to indicate that the view has been counted. - wp_send_json_success(); - } - - die(); - } - } + $count_loggedin = get_directorist_option( 'count_loggedin_user' ); + if ( is_user_logged_in() && empty( $count_loggedin ) ) { + return; + } + + if ( isset( $_POST['listing_id'] ) ) { + $listing_id = absint( $_POST['listing_id'] ); + $this->set_post_views( $listing_id ); + // Return 'success' to the AJAX request to indicate that the view has been counted. + wp_send_json_success(); + } + + die(); + } + } endif; \ No newline at end of file diff --git a/includes/classes/class-listings-export.php b/includes/classes/class-listings-export.php index 614565ddbe..ef54645e4c 100644 --- a/includes/classes/class-listings-export.php +++ b/includes/classes/class-listings-export.php @@ -1,370 +1,410 @@ <?php namespace Directorist; + class Listings_Exporter { - // get_prepared_listings_export_file - public static function get_prepared_listings_export_file() { - $filename = "listings-export-data"; - $file_name = "{$filename}.csv"; - $file_contents = self::get_listings_data_as_csv_content(); + // get_prepared_listings_export_file + public static function get_prepared_listings_export_file() { + $filename = 'listings-export-data'; + $file_name = "{$filename}.csv"; + $file_contents = self::get_listings_data_as_csv_content(); - $old_file_id = get_directorist_option( 'directorist_export_attachent_id', '', true ); - if ( ! empty( $old_file_id ) ) { - wp_delete_attachment( $old_file_id, true ); - } + $old_file_id = get_directorist_option( 'directorist_export_attachent_id', '', true ); + if ( ! empty( $old_file_id ) ) { + wp_delete_attachment( $old_file_id, true ); + } - $upload_dir = wp_upload_dir(); + $upload_dir = wp_upload_dir(); - if ( wp_mkdir_p( $upload_dir['path'] ) ) { - $file = $upload_dir['path'] . '/' . $file_name; - } else { - $file = $upload_dir['basedir'] . '/' . $file_name; - } + if ( wp_mkdir_p( $upload_dir['path'] ) ) { + $file = $upload_dir['path'] . '/' . $file_name; + } else { + $file = $upload_dir['basedir'] . '/' . $file_name; + } - file_put_contents( $file, $file_contents ); + file_put_contents( $file, $file_contents ); - $wp_filetype = wp_check_filetype( $file_name, null ); - $attachment = array( - 'post_mime_type' => $wp_filetype['type'], - 'post_title' => sanitize_file_name( $filename ), - 'post_content' => '', - 'post_status' => 'inherit' - ); + $wp_filetype = wp_check_filetype( $file_name, null ); + $attachment = array( + 'post_mime_type' => $wp_filetype['type'], + 'post_title' => sanitize_file_name( $filename ), + 'post_content' => '', + 'post_status' => 'inherit', + ); - $attach_id = wp_insert_attachment( $attachment, $file ); - $attach_url = wp_get_attachment_url( $attach_id ); + $attach_id = wp_insert_attachment( $attachment, $file ); + $attach_url = wp_get_attachment_url( $attach_id ); - update_directorist_option( 'directorist_export_attachent_id', $attach_id ); + update_directorist_option( 'directorist_export_attachent_id', $attach_id ); - return [ 'success' => true, 'file_url' => $attach_url]; - } + return array( + 'success' => true, + 'file_url' => $attach_url, + ); + } - // get_listings_data_as_csv_content - public static function get_listings_data_as_csv_content() { - $contents = ''; + // get_listings_data_as_csv_content + public static function get_listings_data_as_csv_content() { + $contents = ''; - $listings_data = self::get_listings_data(); + $listings_data = self::get_listings_data(); - if ( empty( $listings_data ) ) { - return $contents; - } + if ( empty( $listings_data ) ) { + return $contents; + } - foreach ( $listings_data as $index => $row ) { - if ( $index === 0 ) { - $contents .= join( ',', array_keys( $row ) ) . "\n"; - } + foreach ( $listings_data as $index => $row ) { + if ( $index === 0 ) { + $contents .= join( ',', array_keys( $row ) ) . "\n"; + } - $row_content = ''; + $row_content = ''; - foreach ( $row as $row_key => $row_value ) { + foreach ( $row as $row_key => $row_value ) { - $row_content__ = ''; + $row_content__ = ''; // $accepted_types = [ 'string', 'integer', 'double', 'boolean' ]; - if ( is_bool( $row_value ) || is_int( $row_value ) || is_double( $row_value ) || is_string( $row_value ) ) { - $row_content__ = $row_value; - } - - if ( is_array( $row_value ) ) { - $row_content__ = maybe_serialize( $row_value ); - } - - $row_content__ = str_replace( '"', "'", $row_content__ ); - $row_content__ = '"' . $row_content__ . '",'; - $row_content .= $row_content__; - } - $contents .= rtrim( $row_content, ',' ) . "\n"; - } - - - return $contents; - } - - // get_listings_data - public static function get_listings_data() { - $listings_data = []; - - $listings = new \WP_Query( apply_filters( 'directorist_listings_export_query' , [ - 'post_type' => ATBDP_POST_TYPE, - 'posts_per_page' => -1, - 'post_status' => 'publish', - ])); - - $field_map = [ - 'native_field' => [ - 'verify' => 'verifyNativeField', - 'update_data' => 'updateNativeFieldData', - ], - 'taxonomy_field' => [ - 'verify' => 'verifyTaxonomyField', - 'update_data' => 'updateTaxonomyFieldData', - ], - 'listing_image_module_field' => [ - 'verify' => 'verifyListingImageModuleField', - 'update_data' => 'updateListingImageModuleFieldsData', - ], - 'price_module_field' => [ - 'verify' => 'verifyPriceModuleField', - 'update_data' => 'updatePriceModuleFieldData', - ], - 'map_module_field' => [ - 'verify' => 'verifyMapModuleField', - 'update_data' => 'updateMapModuleFieldData', - ], - 'meta_key_field' => [ - 'verify' => 'verifyMetaKeyField', - 'update_data' => 'updateMetaKeyFieldData', - ], - ]; - - $tr_lengths = []; - - if ( $listings->have_posts() ) { - while ( $listings->have_posts() ) { - $listings->the_post(); - - $row = []; - $row['id'] = get_the_ID(); - $row['directory'] = self::get_directory_slug_by_id( get_the_id() ); - - $directory_type_id = get_post_meta( get_the_ID(), '_directory_type', true ); - $submission_form = get_term_meta( $directory_type_id, 'submission_form_fields', true ); - - if ( is_array( $submission_form ) && ! empty( $submission_form['fields'] ) ) { - foreach ( $submission_form['fields'] as $field_key => $field_args ) { - foreach ( $field_map as $field_map_key => $field_map_args ) { - $verify = $field_map_args[ 'verify' ]; - $update_data = $field_map_args[ 'update_data' ]; - - if ( self::$verify( $field_args ) ) { - $row = self::$update_data( $row, $field_key, $field_args ); - $row = apply_filters( 'directorist_listings_export_submission_form_fields_row', $row, $field_key, $field_args, $field_map_key ); - break; - } - } - } - } - - $row = apply_filters( 'directorist_listings_export_row', $row ); - $max_row_length = count( array_keys( $row ) ); - $tr_lengths [] = $max_row_length; - $listings_data[] = $row; - } - wp_reset_postdata(); - } - - $listings_data = self::justifyDataTableRow( $listings_data, $tr_lengths ); - - return $listings_data; - } - - // justifyDataRow - public static function justifyDataTableRow( $data_table = [], $tr_lengths = [] ) { - if ( empty( $data_table ) ) { return $data_table; } - if ( ! is_array( $data_table ) ) { return $data_table; } - - $max_tr_val = max($tr_lengths); - $max_tr_index = array_search($max_tr_val, $tr_lengths); - $modal_tr = $data_table[ $max_tr_index ]; - - $justify_table = []; - foreach ( $data_table as $row ) { - $tr = []; - - foreach ( $modal_tr as $row_key => $row_value ) { - $tr[ $row_key ] = ( isset( $row[ $row_key ] ) ) ? $row[ $row_key ] : ''; - } - - $justify_table[] = $tr; - } - - return $justify_table; - } - - - // ================[ Submission Form Fields Helper ]================ - // verifyNativeField - public static function verifyNativeField( $args = [] ) { - if ( ! is_array( $args ) ) { return false; } - if ( empty( $args['widget_group'] ) ) { return false; } - if ( empty( $args['widget_name'] ) ) { return false; } - if ( empty( $args['field_key'] ) ) { return false; } - if ( 'preset' !== $args['widget_group'] ) { return false; } - - $native_fields = [ 'listing_title', 'listing_content' ]; - - if ( ! in_array( $args['field_key'], $native_fields ) ) { return false; } - - return true; - } - - // updateNativeFieldData - public static function updateNativeFieldData( array $row = [], string $field_key = '', array $field_args = [] ) { - $field_data_map = [ - 'listing_title' => 'get_the_title', - 'listing_content' => 'get_the_content', - ]; - - $field_key = $field_args['field_key']; - $content = call_user_func( $field_data_map[ $field_key ] ) ; - // $content = str_replace( '"', '""', $content ); - - $row[ $field_key ] = self::escape_data( $content ); - - return $row; - } - - // verifyTaxonomyField - public static function verifyTaxonomyField( $args = [] ) { - if ( ! is_array( $args ) ) { return false; } - if ( empty( $args['widget_group'] ) ) { return false; } - if ( empty( $args['widget_name'] ) ) { return false; } - if ( empty( $args['field_key'] ) ) { return false; } - if ( 'preset' !== $args['widget_group'] ) { return false; } - - $taxonomy = [ 'category', 'location', 'tag' ]; - - if ( ! in_array( $args['widget_name'], $taxonomy ) ) { return false; } - - return true; - } - - // updateTaxonomyFieldData - public static function updateTaxonomyFieldData( array $row = [], string $field_key = '', array $field_args = [] ) { - $term_map = [ - 'category' => ATBDP_CATEGORY, - 'location' => ATBDP_LOCATION, - 'tag' => ATBDP_TAGS, - ]; - - $row[ $field_key ] = self::get_term_names( get_the_ID(), $term_map[ $field_args['widget_name'] ] ); - - return $row; - } + if ( is_bool( $row_value ) || is_int( $row_value ) || is_double( $row_value ) || is_string( $row_value ) ) { + $row_content__ = $row_value; + } + + if ( is_array( $row_value ) ) { + $row_content__ = maybe_serialize( $row_value ); + } + + $row_content__ = str_replace( '"', "'", $row_content__ ); + $row_content__ = '"' . $row_content__ . '",'; + $row_content .= $row_content__; + } + $contents .= rtrim( $row_content, ',' ) . "\n"; + } + + return $contents; + } + + // get_listings_data + public static function get_listings_data() { + $listings_data = array(); + + $listings = new \WP_Query( + apply_filters( + 'directorist_listings_export_query', + array( + 'post_type' => ATBDP_POST_TYPE, + 'posts_per_page' => -1, + 'post_status' => 'publish', + ) + ) + ); + + $field_map = array( + 'native_field' => array( + 'verify' => 'verifyNativeField', + 'update_data' => 'updateNativeFieldData', + ), + 'taxonomy_field' => array( + 'verify' => 'verifyTaxonomyField', + 'update_data' => 'updateTaxonomyFieldData', + ), + 'listing_image_module_field' => array( + 'verify' => 'verifyListingImageModuleField', + 'update_data' => 'updateListingImageModuleFieldsData', + ), + 'price_module_field' => array( + 'verify' => 'verifyPriceModuleField', + 'update_data' => 'updatePriceModuleFieldData', + ), + 'map_module_field' => array( + 'verify' => 'verifyMapModuleField', + 'update_data' => 'updateMapModuleFieldData', + ), + 'meta_key_field' => array( + 'verify' => 'verifyMetaKeyField', + 'update_data' => 'updateMetaKeyFieldData', + ), + ); + + $tr_lengths = array(); + + if ( $listings->have_posts() ) { + while ( $listings->have_posts() ) { + $listings->the_post(); + + $row = array(); + $row['id'] = get_the_ID(); + $row['directory'] = self::get_directory_slug_by_id( get_the_id() ); + + $directory_type_id = get_post_meta( get_the_ID(), '_directory_type', true ); + $submission_form = get_term_meta( $directory_type_id, 'submission_form_fields', true ); + + if ( is_array( $submission_form ) && ! empty( $submission_form['fields'] ) ) { + foreach ( $submission_form['fields'] as $field_key => $field_args ) { + foreach ( $field_map as $field_map_key => $field_map_args ) { + $verify = $field_map_args['verify']; + $update_data = $field_map_args['update_data']; + + if ( self::$verify( $field_args ) ) { + $row = self::$update_data( $row, $field_key, $field_args ); + $row = apply_filters( 'directorist_listings_export_submission_form_fields_row', $row, $field_key, $field_args, $field_map_key ); + break; + } + } + } + } + + $row = apply_filters( 'directorist_listings_export_row', $row ); + $max_row_length = count( array_keys( $row ) ); + $tr_lengths [] = $max_row_length; + $listings_data[] = $row; + } + wp_reset_postdata(); + } - // verifyListingImageModuleField - public static function verifyListingImageModuleField( $args = [] ) { - if ( ! is_array( $args ) ) { return false; } - if ( empty( $args['widget_group'] ) ) { return false; } - if ( empty( $args['widget_name'] ) ) { return false; } - if ( empty( $args['field_key'] ) ) { return false; } - if ( 'preset' !== $args['widget_group'] ) { return false; } - if ( 'listing_img' !== $args['field_key'] ) { return false; } + $listings_data = self::justifyDataTableRow( $listings_data, $tr_lengths ); - return true; - } + return $listings_data; + } + + // justifyDataRow + public static function justifyDataTableRow( $data_table = array(), $tr_lengths = array() ) { + if ( empty( $data_table ) ) { + return $data_table; } + if ( ! is_array( $data_table ) ) { + return $data_table; } + + $max_tr_val = max( $tr_lengths ); + $max_tr_index = array_search( $max_tr_val, $tr_lengths ); + $modal_tr = $data_table[ $max_tr_index ]; + + $justify_table = array(); + foreach ( $data_table as $row ) { + $tr = array(); + + foreach ( $modal_tr as $row_key => $row_value ) { + $tr[ $row_key ] = ( isset( $row[ $row_key ] ) ) ? $row[ $row_key ] : ''; + } + + $justify_table[] = $tr; + } - // updateListingImageModuleFieldsData - public static function updateListingImageModuleFieldsData( array $row = [], string $field_key = '', array $field_args = [] ) { - $preview_image = directorist_get_listing_preview_image( get_the_ID() ); - $gallery_images = directorist_get_listing_gallery_images( get_the_ID() ); + return $justify_table; + } + + + // ================[ Submission Form Fields Helper ]================ + // verifyNativeField + public static function verifyNativeField( $args = array() ) { + if ( ! is_array( $args ) ) { + return false; } + if ( empty( $args['widget_group'] ) ) { + return false; } + if ( empty( $args['widget_name'] ) ) { + return false; } + if ( empty( $args['field_key'] ) ) { + return false; } + if ( 'preset' !== $args['widget_group'] ) { + return false; } + + $native_fields = array( 'listing_title', 'listing_content' ); + + if ( ! in_array( $args['field_key'], $native_fields ) ) { + return false; } + + return true; + } - if ( empty( $preview_image ) && empty( $gallery_images ) ) { - return $row; - } + // updateNativeFieldData + public static function updateNativeFieldData( array $row = array(), string $field_key = '', array $field_args = array() ) { + $field_data_map = array( + 'listing_title' => 'get_the_title', + 'listing_content' => 'get_the_content', + ); - $image_urls = []; + $field_key = $field_args['field_key']; + $content = call_user_func( $field_data_map[ $field_key ] ); + // $content = str_replace( '"', '""', $content ); + + $row[ $field_key ] = self::escape_data( $content ); + + return $row; + } + + // verifyTaxonomyField + public static function verifyTaxonomyField( $args = array() ) { + if ( ! is_array( $args ) ) { + return false; } + if ( empty( $args['widget_group'] ) ) { + return false; } + if ( empty( $args['widget_name'] ) ) { + return false; } + if ( empty( $args['field_key'] ) ) { + return false; } + if ( 'preset' !== $args['widget_group'] ) { + return false; } + + $taxonomy = array( 'category', 'location', 'tag' ); + + if ( ! in_array( $args['widget_name'], $taxonomy ) ) { + return false; } + + return true; + } + + // updateTaxonomyFieldData + public static function updateTaxonomyFieldData( array $row = array(), string $field_key = '', array $field_args = array() ) { + $term_map = array( + 'category' => ATBDP_CATEGORY, + 'location' => ATBDP_LOCATION, + 'tag' => ATBDP_TAGS, + ); + + $row[ $field_key ] = self::get_term_names( get_the_ID(), $term_map[ $field_args['widget_name'] ] ); + + return $row; + } + + // verifyListingImageModuleField + public static function verifyListingImageModuleField( $args = array() ) { + if ( ! is_array( $args ) ) { + return false; } + if ( empty( $args['widget_group'] ) ) { + return false; } + if ( empty( $args['widget_name'] ) ) { + return false; } + if ( empty( $args['field_key'] ) ) { + return false; } + if ( 'preset' !== $args['widget_group'] ) { + return false; } + if ( 'listing_img' !== $args['field_key'] ) { + return false; } + + return true; + } + + // updateListingImageModuleFieldsData + public static function updateListingImageModuleFieldsData( array $row = array(), string $field_key = '', array $field_args = array() ) { + $preview_image = directorist_get_listing_preview_image( get_the_ID() ); + $gallery_images = directorist_get_listing_gallery_images( get_the_ID() ); + + if ( empty( $preview_image ) && empty( $gallery_images ) ) { + return $row; + } + + $image_urls = array(); $image_url = wp_get_attachment_image_url( $preview_image, 'full' ); if ( $image_url ) { $image_urls[] = $image_url; } - foreach ( $gallery_images as $image ) { + foreach ( $gallery_images as $image ) { if ( $image === $preview_image ) { continue; } - + $image_url = wp_get_attachment_image_url( $image, 'full' ); if ( $image_url ) { $image_urls[] = $image_url; } } - $row[ $field_args['field_key'] ] = implode( ',', $image_urls ); - - return $row; - } + $row[ $field_args['field_key'] ] = implode( ',', $image_urls ); - // verifyMetaKeyField - public static function verifyMetaKeyField( $args = [] ) { - if ( ! is_array( $args ) ) { return false; } - if ( empty( $args['widget_group'] ) ) { return false; } - if ( empty( $args['widget_name'] ) ) { return false; } - if ( empty( $args['field_key'] ) ) { return false; } - - return true; - } + return $row; + } - // updateMetaKeyFieldData - public static function updateMetaKeyFieldData( array $row = [], string $field_key = '', array $field_args = [] ) { - $value = get_post_meta( get_the_id(), '_' . $field_args['field_key'], true ); - $row[ 'publish_date' ] = get_the_date( 'Y-m-d H:i:s', get_the_ID() ); - $row[ $field_args['field_key'] ] = self::escape_data( $value ); + // verifyMetaKeyField + public static function verifyMetaKeyField( $args = array() ) { + if ( ! is_array( $args ) ) { + return false; } + if ( empty( $args['widget_group'] ) ) { + return false; } + if ( empty( $args['widget_name'] ) ) { + return false; } + if ( empty( $args['field_key'] ) ) { + return false; } + + return true; + } - return $row; - } + // updateMetaKeyFieldData + public static function updateMetaKeyFieldData( array $row = array(), string $field_key = '', array $field_args = array() ) { + $value = get_post_meta( get_the_id(), '_' . $field_args['field_key'], true ); + $row['publish_date'] = get_the_date( 'Y-m-d H:i:s', get_the_ID() ); + $row[ $field_args['field_key'] ] = self::escape_data( $value ); - // verifyPriceModuleField - public static function verifyPriceModuleField( $args = [] ) { - if ( ! is_array( $args ) ) { return false; } - if ( empty( $args['widget_group'] ) ) { return false; } - if ( empty( $args['widget_name'] ) ) { return false; } - if ( 'pricing' !== $args['widget_name'] ) { return false; } + return $row; + } - return true; - } + // verifyPriceModuleField + public static function verifyPriceModuleField( $args = array() ) { + if ( ! is_array( $args ) ) { + return false; } + if ( empty( $args['widget_group'] ) ) { + return false; } + if ( empty( $args['widget_name'] ) ) { + return false; } + if ( 'pricing' !== $args['widget_name'] ) { + return false; } + + return true; + } - // updatePriceModuleFieldData - public static function updatePriceModuleFieldData( array $row = [], string $field_key = '', array $field_args = [] ) { - $row[ 'price' ] = self::escape_data( get_post_meta( get_the_id(), '_price', true ) ); - $row[ 'price_range' ] = self::escape_data( get_post_meta( get_the_id(), '_price_range', true ) ); - $row[ 'atbd_listing_pricing' ] = self::escape_data( get_post_meta( get_the_id(), '_atbd_listing_pricing', true ) ); + // updatePriceModuleFieldData + public static function updatePriceModuleFieldData( array $row = array(), string $field_key = '', array $field_args = array() ) { + $row['price'] = self::escape_data( get_post_meta( get_the_id(), '_price', true ) ); + $row['price_range'] = self::escape_data( get_post_meta( get_the_id(), '_price_range', true ) ); + $row['atbd_listing_pricing'] = self::escape_data( get_post_meta( get_the_id(), '_atbd_listing_pricing', true ) ); - return $row; - } + return $row; + } - // verifyMapModuleField - public static function verifyMapModuleField( $args = [] ) { - if ( ! is_array( $args ) ) { return false; } - if ( empty( $args['widget_group'] ) ) { return false; } - if ( empty( $args['widget_name'] ) ) { return false; } - if ( 'map' !== $args['widget_name'] ) { return false; } + // verifyMapModuleField + public static function verifyMapModuleField( $args = array() ) { + if ( ! is_array( $args ) ) { + return false; } + if ( empty( $args['widget_group'] ) ) { + return false; } + if ( empty( $args['widget_name'] ) ) { + return false; } + if ( 'map' !== $args['widget_name'] ) { + return false; } - return true; - } + return true; + } - // updateMapModuleFieldData - public static function updateMapModuleFieldData( array $row = [], string $field_key = '', array $field_args = [] ) { - $row[ 'hide_map' ] = get_post_meta( get_the_id(), '_hide_map', true ); - $row[ 'manual_lat' ] = self::escape_data( get_post_meta( get_the_id(), '_manual_lat', true ) ); - $row[ 'manual_lng' ] = self::escape_data( get_post_meta( get_the_id(), '_manual_lng', true ) ); + // updateMapModuleFieldData + public static function updateMapModuleFieldData( array $row = array(), string $field_key = '', array $field_args = array() ) { + $row['hide_map'] = get_post_meta( get_the_id(), '_hide_map', true ); + $row['manual_lat'] = self::escape_data( get_post_meta( get_the_id(), '_manual_lat', true ) ); + $row['manual_lng'] = self::escape_data( get_post_meta( get_the_id(), '_manual_lng', true ) ); - return $row; - } + return $row; + } - // ================[ Submission Form Fields Helper : End ]================ + // ================[ Submission Form Fields Helper : End ]================ - // get_directory_slug_by_id - public static function get_directory_slug_by_id( $id = 0 ) { - $directory_type_id = get_post_meta( $id, '_directory_type', true ); - $directory_type = ( ! empty( $directory_type_id ) ) ? get_term_by( 'id', $directory_type_id, ATBDP_DIRECTORY_TYPE ) : ''; - $directory_type_slug = ( ! empty( $directory_type ) && is_object( $directory_type ) ) ? $directory_type->slug : ''; + // get_directory_slug_by_id + public static function get_directory_slug_by_id( $id = 0 ) { + $directory_type_id = get_post_meta( $id, '_directory_type', true ); + $directory_type = ( ! empty( $directory_type_id ) ) ? get_term_by( 'id', $directory_type_id, ATBDP_DIRECTORY_TYPE ) : ''; + $directory_type_slug = ( ! empty( $directory_type ) && is_object( $directory_type ) ) ? $directory_type->slug : ''; - return $directory_type_slug; - } + return $directory_type_slug; + } - // get_term_names - public static function get_term_names( $post_id = 0, $taxonomy = '' ) { - $terms = get_the_terms( $post_id, $taxonomy ); + // get_term_names + public static function get_term_names( $post_id = 0, $taxonomy = '' ) { + $terms = get_the_terms( $post_id, $taxonomy ); - if ( is_wp_error( $terms ) || empty( $terms ) ) { - return ''; - } + if ( is_wp_error( $terms ) || empty( $terms ) ) { + return ''; + } - return join( ',', wp_list_pluck( $terms, 'name' ) ); - } + return join( ',', wp_list_pluck( $terms, 'name' ) ); + } /** * Escape a string to be used in a CSV context @@ -384,9 +424,9 @@ public static function get_term_names( $post_id = 0, $taxonomy = '' ) { */ public static function escape_data( $data ) { - if( ! is_string( $data ) ) { - return $data; - } + if ( ! is_string( $data ) ) { + return $data; + } $active_content_triggers = array( '=', '+', '-', '@' ); diff --git a/includes/classes/class-metabox.php b/includes/classes/class-metabox.php index 3e687c8fdb..2d9e4f8824 100644 --- a/includes/classes/class-metabox.php +++ b/includes/classes/class-metabox.php @@ -16,10 +16,10 @@ class ATBDP_Metabox { */ public function __construct() { if ( is_admin() ) { - add_action('add_meta_boxes_'.ATBDP_POST_TYPE, array($this, 'listing_metabox')); - add_action('transition_post_status', array($this, 'publish_atbdp_listings'), 10, 3); - add_action( 'edit_post', array($this, 'save_post_meta'), 10, 2); - add_action('post_submitbox_misc_actions', array($this, 'post_submitbox_meta')); + add_action( 'add_meta_boxes_' . ATBDP_POST_TYPE, array( $this, 'listing_metabox' ) ); + add_action( 'transition_post_status', array( $this, 'publish_atbdp_listings' ), 10, 3 ); + add_action( 'edit_post', array( $this, 'save_post_meta' ), 10, 2 ); + add_action( 'post_submitbox_misc_actions', array( $this, 'post_submitbox_meta' ) ); // load dynamic fields add_action( 'wp_ajax_atbdp_dynamic_admin_listing_form', array( $this, 'atbdp_dynamic_admin_listing_form' ) ); } @@ -28,80 +28,82 @@ public function __construct() { public function atbdp_dynamic_admin_listing_form() { if ( ! directorist_verify_nonce() ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), - ) ); + wp_send_json( + array( + 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), + ) + ); } - $term_id = ! empty( $_POST['directory_type'] ) ? (int) directorist_clean( wp_unslash( $_POST['directory_type'] ) ) : ''; - $listing_id = ! empty( $_POST['listing_id'] ) ? directorist_clean( wp_unslash( $_POST['listing_id'] ) ) : ''; + $term_id = ! empty( $_POST['directory_type'] ) ? (int) directorist_clean( wp_unslash( $_POST['directory_type'] ) ) : ''; + $listing_id = ! empty( $_POST['listing_id'] ) ? directorist_clean( wp_unslash( $_POST['listing_id'] ) ) : ''; // listing meta fields ob_start(); $this->render_listing_meta_fields( $term_id, $listing_id ); - $listing_meta_fields = ob_get_clean(); + $listing_meta_fields = ob_get_clean(); ob_start(); $this->render_listing_taxonomies( $listing_id, $term_id, ATBDP_CATEGORY ); - $listing_categories = ob_get_clean(); + $listing_categories = ob_get_clean(); ob_start(); $this->render_listing_taxonomies( $listing_id, $term_id, ATBDP_LOCATION ); - $listing_locations = ob_get_clean(); + $listing_locations = ob_get_clean(); ob_start(); $this->render_listing_pop_taxonomies( $listing_id, $term_id, ATBDP_CATEGORY ); - $listing_pop_categories = ob_get_clean(); + $listing_pop_categories = ob_get_clean(); ob_start(); $this->render_listing_pop_taxonomies( $listing_id, $term_id, ATBDP_LOCATION ); - $listing_pop_locations = ob_get_clean(); + $listing_pop_locations = ob_get_clean(); ob_start(); $this->render_expire_date( $listing_id, $term_id ); $listing_expiration = ob_get_clean(); + $required_script_src = array(); - $required_script_src = []; - - $map_type = get_directorist_option('select_listing_map', 'openstreet'); + $map_type = get_directorist_option( 'select_listing_map', 'openstreet' ); $script_name = ( 'openstreet' === $map_type ) ? 'openstreet-map' : 'google-map'; - $is_enabled_script_debugging = get_directorist_option( 'script_debugging', false, true ); - $ext = $is_enabled_script_debugging ? '.js' : '.min.js'; - $required_script_src[ 'map-custom-script' ] = DIRECTORIST_JS . $script_name . $ext; - - wp_send_json_success( array( - 'listing_meta_fields' => $listing_meta_fields, - 'listing_categories' => $listing_categories, - 'listing_pop_categories' => $listing_pop_categories, - 'listing_locations' => $listing_locations, - 'listing_pop_locations' => $listing_pop_locations, - 'required_js_scripts' => $required_script_src, - 'listing_expiration' => $listing_expiration - ) ); - + $is_enabled_script_debugging = get_directorist_option( 'script_debugging', false, true ); + $ext = $is_enabled_script_debugging ? '.js' : '.min.js'; + $required_script_src['map-custom-script'] = DIRECTORIST_JS . $script_name . $ext; + + wp_send_json_success( + array( + 'listing_meta_fields' => $listing_meta_fields, + 'listing_categories' => $listing_categories, + 'listing_pop_categories' => $listing_pop_categories, + 'listing_locations' => $listing_locations, + 'listing_pop_locations' => $listing_pop_locations, + 'required_js_scripts' => $required_script_src, + 'listing_expiration' => $listing_expiration, + ) + ); } public function render_listing_taxonomies( $listing_id, $term_id, $taxonomy_id, $parent_id = 0 ) { - $args = array( + $args = array( 'hide_empty' => 0, 'hierarchical' => true, - 'parent' => $parent_id + 'parent' => $parent_id, ); $saving_terms = get_the_terms( $listing_id, $taxonomy_id ); $saving_values = array(); - if( $saving_terms ) { - foreach( $saving_terms as $saving_term ) { + if ( $saving_terms ) { + foreach ( $saving_terms as $saving_term ) { $saving_values[] = $saving_term->term_id; } } - $terms = get_terms( $taxonomy_id, $args); + $terms = get_terms( $taxonomy_id, $args ); - if( $terms ) { - foreach( $terms as $term ) { + if ( $terms ) { + foreach ( $terms as $term ) { $directory_type = get_term_meta( $term->term_id, '_directory_type', true ); - $directory_type = ! empty ( $directory_type ) ? $directory_type : array(); + $directory_type = ! empty( $directory_type ) ? $directory_type : array(); $directory_type_int = array_map( 'intval', $directory_type ); $checked = in_array( $term->term_id, $saving_values, true ) ? 'checked' : ''; if ( in_array( $term_id, $directory_type_int, true ) ) { ?> @@ -119,85 +121,86 @@ public function render_listing_taxonomies( $listing_id, $term_id, $taxonomy_id, } ?> </li> - <?php + <?php } } } } public function render_listing_pop_taxonomies( $listing_id, $term_id, $taxonomy_id ) { - $args = array( - 'hide_empty' => 0, - 'hierarchical' => false + $args = array( + 'hide_empty' => 0, + 'hierarchical' => false, ); - $saving_terms = get_the_terms( $listing_id, $taxonomy_id ); - $saving_values = array(); - if( $saving_terms ) { - foreach( $saving_terms as $saving_term ) { + $saving_terms = get_the_terms( $listing_id, $taxonomy_id ); + $saving_values = array(); + if ( $saving_terms ) { + foreach ( $saving_terms as $saving_term ) { $saving_values[] = $saving_term->term_id; } } - $terms = get_terms( $taxonomy_id, $args); + $terms = get_terms( $taxonomy_id, $args ); - if( $terms ) { - foreach( $terms as $term ) { + if ( $terms ) { + foreach ( $terms as $term ) { $directory_type = get_term_meta( $term->term_id, '_directory_type', true ); - $directory_type = ! empty ( $directory_type ) ? $directory_type : array(); - $checked = in_array( $term->term_id, $saving_values ) ? 'checked' : ''; - if( in_array( $term_id, $directory_type) ) { ?> + $directory_type = ! empty( $directory_type ) ? $directory_type : array(); + $checked = in_array( $term->term_id, $saving_values ) ? 'checked' : ''; + if ( in_array( $term_id, $directory_type ) ) { + ?> <li id="popular-<?php echo esc_attr( $taxonomy_id ); ?>-<?php echo esc_attr( $term->term_id ); ?>" class="popular-category"><label class="selectit"><input value="<?php echo esc_attr( $term->term_id ); ?>" type="checkbox" id="in-popular-<?php echo esc_attr( $taxonomy_id ); ?>-<?php echo esc_attr( $term->term_id ); ?>" <?php echo ! empty( $checked ) ? esc_attr( $checked ) : ''; ?>> <?php echo esc_html( $term->name ); ?></label></li> - <?php + <?php } } } } public function listing_metabox( $post ) { - add_meta_box('listing_form_info', __('Listing Information', 'directorist'), array($this, 'listing_form_info_meta'), ATBDP_POST_TYPE, 'normal', 'high'); + add_meta_box( 'listing_form_info', __( 'Listing Information', 'directorist' ), array( $this, 'listing_form_info_meta' ), ATBDP_POST_TYPE, 'normal', 'high' ); } public function render_listing_meta_fields( $type, $id ) { $form_data = $this->build_form_data( $type ); foreach ( $form_data as $section ) { - \Directorist\Directorist_Listing_Form::instance($id)->section_template( $section ); + \Directorist\Directorist_Listing_Form::instance( $id )->section_template( $section ); } } - public function render_expire_date( $listing_id, $term_id ) - { + public function render_expire_date( $listing_id, $term_id ) { // show expiration date and featured listing. - $directory_type = isset( $term_id ) ? $term_id : default_directory_type(); - $expiration = get_term_meta( $directory_type, 'default_expiration', true ); - $expire_in_days = ! empty( $expiration ) ? $expiration : '90'; - $f_active = directorist_is_featured_listing_enabled(); - $never_expire = get_post_meta( $listing_id, '_never_expire', true ); - $never_expire = !empty( $never_expire ) ? (int) $never_expire : ''; - - $e_d = get_post_meta( $listing_id, '_expiry_date', true ); - $e_d = !empty( $e_d ) ? $e_d : calc_listing_expiry_date( '', $expire_in_days, $directory_type ); - $expiry_date = atbdp_parse_mysql_date( $e_d ); - - $featured = get_post_meta( $listing_id, '_featured', true); - $listing_type = get_post_meta( $listing_id, '_listing_type', true); + $directory_type = isset( $term_id ) ? $term_id : default_directory_type(); + $expiration = get_term_meta( $directory_type, 'default_expiration', true ); + $expire_in_days = ! empty( $expiration ) ? $expiration : '90'; + $f_active = directorist_is_featured_listing_enabled(); + $never_expire = get_post_meta( $listing_id, '_never_expire', true ); + $never_expire = ! empty( $never_expire ) ? (int) $never_expire : ''; + + $e_d = get_post_meta( $listing_id, '_expiry_date', true ); + $e_d = ! empty( $e_d ) ? $e_d : calc_listing_expiry_date( '', $expire_in_days, $directory_type ); + $expiry_date = atbdp_parse_mysql_date( $e_d ); + + $featured = get_post_meta( $listing_id, '_featured', true ); + $listing_type = get_post_meta( $listing_id, '_listing_type', true ); // TODO: Status has been migrated, remove related code. // $listing_status = get_post_meta( $listing_id, '_listing_status', true); $listing_status = get_post_status( $listing_id ); - $default_expire_in_days = !empty( $default_expire_in_days ) ? $default_expire_in_days : ''; + $default_expire_in_days = ! empty( $default_expire_in_days ) ? $default_expire_in_days : ''; // load the meta fields - $data = compact('f_active', 'never_expire', 'expiry_date', 'featured', 'listing_type', 'listing_status', 'default_expire_in_days'); + $data = compact( 'f_active', 'never_expire', 'expiry_date', 'featured', 'listing_type', 'listing_status', 'default_expire_in_days' ); - if( empty($never_expire) && isset( $expiry_date ) ) : ?> + if ( empty( $never_expire ) && isset( $expiry_date ) ) : + ?> <span id="atbdp-timestamp"> - <strong><?php esc_html_e( "Expiration", 'directorist' ); ?></strong> - <?php esc_html_e( "Date & Time", 'directorist' ); ?> + <strong><?php esc_html_e( 'Expiration', 'directorist' ); ?></strong> + <?php esc_html_e( 'Date & Time', 'directorist' ); ?> </span> <div id="atbdp-timestamp-wrap" class="atbdp-timestamp-wrap"> <label> <select id="atbdp-mm" name="exp_date[mm]"> <?php $months = atbdp_get_months();// get an array of translatable month names - foreach( $months as $key => $month_name ) { + foreach ( $months as $key => $month_name ) { $key += 1; printf( '<option value="%1$d" %2$s>%1$d-%3$s</option>', esc_attr( $key ), esc_attr( selected( $key, (int) $expiry_date['month'] ) ), esc_html( $month_name ) ); } @@ -217,38 +220,45 @@ public function render_expire_date( $listing_id, $term_id ) <input type="text" id="atbdp-mn" placeholder="min" name="exp_date[mn]" value="<?php echo esc_attr( $expiry_date['min'] ); ?>" size="2" maxlength="2" /> </label> </div> - <?php endif; - + <?php + endif; } public function listing_form_info_meta( $post ) { wp_enqueue_script( 'atbdp-google-map-front' ); - wp_enqueue_script( 'atbdp-markerclusterer' ); - $all_types = directory_types(); - $default = default_directory_type(); - $current_type = directorist_get_listing_directory( $post->ID ); - $value = $current_type ? $current_type : $default; + wp_enqueue_script( 'atbdp-markerclusterer' ); + $all_types = directory_types(); + $default = default_directory_type(); + $current_type = directorist_get_listing_directory( $post->ID ); + $value = $current_type ? $current_type : $default; wp_nonce_field( 'listing_info_action', 'listing_info_nonce' ); $show_directory_type_nav = directorist_is_multi_directory_enabled() && ( count( $all_types ) > 1 ); $show_directory_type_nav = apply_filters( 'directorist_show_admin_edit_listing_directory_type_nav', $show_directory_type_nav, $post->ID ); - if ( $show_directory_type_nav ) { ?> + if ( $show_directory_type_nav ) { + ?> <label><?php esc_html_e( 'Directory', 'directorist' ); ?></label> <select name="directory_type"> <option value=""><?php esc_attr_e( 'Select a directory...', 'directorist' ); ?></option> - <?php foreach ( $all_types as $type ): + <?php + foreach ( $all_types as $type ) : ?> - <option value="<?php echo esc_attr( $type->term_id ); ?>" <?php echo selected( $type->term_id, $value ); ; ?> ><?php echo esc_attr( $type->name ); ?></option> - <?php endforeach; + <option value="<?php echo esc_attr( $type->term_id ); ?>" + <?php + echo selected( $type->term_id, $value ); + ?> + ><?php echo esc_attr( $type->name ); ?></option> + <?php + endforeach; ?> </select> - <?php } else {?> + <?php } else { ?> <input type="hidden" name="directory_type" value="<?php echo esc_attr( $default ); ?>"> <?php } ?> - <div id="directiost-listing-fields_wrapper" data-id="<?php echo esc_attr( $post->ID )?>"> + <div id="directiost-listing-fields_wrapper" data-id="<?php echo esc_attr( $post->ID ); ?>"> <div style="display: none" class="directorist-content-module atbd_content_module- atbdp_category_custom_fields-wrapper"> <div class="directorist-content-module__contents atbdb_content_module_contents-"> <div class="atbdp_category_custom_fields"></div> @@ -265,9 +275,9 @@ public function listing_form_info_meta( $post ) { public function build_form_data( $type ) { $form_data = array(); $submission_form_fields = get_term_meta( $type, 'submission_form_fields', true ); - $excluded_fields = array( 'title', 'description', 'location', 'category', 'tag', 'privacy_policy', 'terms_conditions' ); + $excluded_fields = array( 'title', 'description', 'location', 'category', 'tag', 'privacy_policy', 'terms_conditions' ); - if ( !empty( $submission_form_fields['groups'] ) ) { + if ( ! empty( $submission_form_fields['groups'] ) ) { foreach ( $submission_form_fields['groups'] as $group ) { $section = $group; @@ -292,51 +302,54 @@ public function build_form_data( $type ) { /** * @since 5.4.0 */ - public function publish_atbdp_listings( $new_status, $old_status, $post ){ + public function publish_atbdp_listings( $new_status, $old_status, $post ) { $nonce = isset( $_REQUEST['_wpnonce'] ) ? directorist_clean( wp_unslash( $_REQUEST['_wpnonce'] ) ) : null; - if ( ($post->post_type == 'at_biz_dir') && ( $old_status == 'pending' && $new_status == 'publish' ) && !wp_verify_nonce( $nonce, 'quick-publish-action' ) ){ - do_action('atbdp_listing_published', $post->ID);//for sending email notification + if ( ( $post->post_type == 'at_biz_dir' ) && ( $old_status == 'pending' && $new_status == 'publish' ) && ! wp_verify_nonce( $nonce, 'quick-publish-action' ) ) { + do_action( 'atbdp_listing_published', $post->ID );// for sending email notification } } /** * It outputs expiration date and featured checkbox custom field on the submit box metabox. + * * @param WP_Post $post */ - public function post_submitbox_meta($post) - { + public function post_submitbox_meta( $post ) { - if(ATBDP_POST_TYPE !=$post->post_type) return; // vail if it is not our post type + if ( ATBDP_POST_TYPE != $post->post_type ) { + return; // vail if it is not our post type + } // show expiration date and featured listing. - $directory_type = default_directory_type(); - $expiration = get_term_meta( $directory_type, 'default_expiration', true ); - $expire_in_days = ! empty( $expiration ) ? $expiration : '90'; - $f_active = directorist_is_featured_listing_enabled(); - $never_expire = get_post_meta($post->ID, '_never_expire', true); - $never_expire = !empty($never_expire) ? (int) $never_expire : ''; - - $e_d = get_post_meta($post->ID, '_expiry_date', true); - $e_d = !empty($e_d) ? $e_d : calc_listing_expiry_date( '', $expire_in_days ); - $expiry_date = atbdp_parse_mysql_date($e_d); - - $featured = get_post_meta($post->ID, '_featured', true); - $listing_type = get_post_meta($post->ID, '_listing_type', true); + $directory_type = default_directory_type(); + $expiration = get_term_meta( $directory_type, 'default_expiration', true ); + $expire_in_days = ! empty( $expiration ) ? $expiration : '90'; + $f_active = directorist_is_featured_listing_enabled(); + $never_expire = get_post_meta( $post->ID, '_never_expire', true ); + $never_expire = ! empty( $never_expire ) ? (int) $never_expire : ''; + + $e_d = get_post_meta( $post->ID, '_expiry_date', true ); + $e_d = ! empty( $e_d ) ? $e_d : calc_listing_expiry_date( '', $expire_in_days ); + $expiry_date = atbdp_parse_mysql_date( $e_d ); + + $featured = get_post_meta( $post->ID, '_featured', true ); + $listing_type = get_post_meta( $post->ID, '_listing_type', true ); // TODO: Status has been migrated, remove related code. // $listing_status = get_post_meta($post->ID, '_listing_status', true); $listing_status = get_post_status( $post->ID ); - $default_expire_in_days = !empty($default_expire_in_days) ? $default_expire_in_days : ''; + $default_expire_in_days = ! empty( $default_expire_in_days ) ? $default_expire_in_days : ''; // load the meta fields - $data = compact('f_active', 'never_expire', 'expiry_date', 'featured', 'listing_type', 'listing_status', 'default_expire_in_days'); + $data = compact( 'f_active', 'never_expire', 'expiry_date', 'featured', 'listing_type', 'listing_status', 'default_expire_in_days' ); - if( apply_filters( 'directorist_before_featured_expire_metabox', true, $post ) ){ - ATBDP()->load_template('admin-templates/listing-form/expiration-featured-fields', array('data'=> $data)); + if ( apply_filters( 'directorist_before_featured_expire_metabox', true, $post ) ) { + ATBDP()->load_template( 'admin-templates/listing-form/expiration-featured-fields', array( 'data' => $data ) ); } } /** * Save Meta Data of ATBDP_POST_TYPE - * @param int $post_id Post ID of the current post being saved - * @param object $post Current post object being saved + * + * @param int $post_id Post ID of the current post being saved + * @param object $post Current post object being saved */ public function save_post_meta( $post_id, $post ) { $nonce = ! empty( $_POST['listing_info_nonce'] ) ? directorist_clean( wp_unslash( $_POST['listing_info_nonce'] ) ) : ''; @@ -349,14 +362,14 @@ public function save_post_meta( $post_id, $post ) { return; } - if ( ( ATBDP_POST_TYPE !== $post->post_type ) || wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) || ! current_user_can( 'edit_'.ATBDP_POST_TYPE, $post_id ) ) { + if ( ( ATBDP_POST_TYPE !== $post->post_type ) || wp_is_post_autosave( $post ) || wp_is_post_revision( $post ) || ! current_user_can( 'edit_' . ATBDP_POST_TYPE, $post_id ) ) { return; } - $directory_id = ! empty( $_POST['directory_type'] ) ? directorist_clean( wp_unslash( $_POST['directory_type'] ) ) : directorist_get_default_directory(); - $listing_categories = ! empty( $_POST['tax_input'][ ATBDP_CATEGORY ] ) ? directorist_clean( wp_unslash( $_POST['tax_input'][ ATBDP_CATEGORY ] ) ) : array(); - $listing_locations = ! empty( $_POST['tax_input'][ ATBDP_LOCATION ] ) ? directorist_clean( wp_unslash( $_POST['tax_input'][ ATBDP_LOCATION ] ) ) : array(); - $meta_data = array(); + $directory_id = ! empty( $_POST['directory_type'] ) ? directorist_clean( wp_unslash( $_POST['directory_type'] ) ) : directorist_get_default_directory(); + $listing_categories = ! empty( $_POST['tax_input'][ ATBDP_CATEGORY ] ) ? directorist_clean( wp_unslash( $_POST['tax_input'][ ATBDP_CATEGORY ] ) ) : array(); + $listing_locations = ! empty( $_POST['tax_input'][ ATBDP_LOCATION ] ) ? directorist_clean( wp_unslash( $_POST['tax_input'][ ATBDP_LOCATION ] ) ) : array(); + $meta_data = array(); if ( $directory_id ) { $directory_term = get_term_by( is_numeric( $directory_id ) ? 'id' : 'slug', $directory_id, ATBDP_TYPE ); @@ -387,7 +400,7 @@ public function save_post_meta( $post_id, $post ) { if ( 'pricing' === $key ) { $meta_data['_atbd_listing_pricing'] = isset( $_POST['atbd_listing_pricing'] ) ? directorist_clean( wp_unslash( $_POST['atbd_listing_pricing'] ) ) : ''; - $meta_data['_price' ] = isset( $_POST['price'] ) ? directorist_clean( wp_unslash( $_POST['price'] ) ) : ''; + $meta_data['_price'] = isset( $_POST['price'] ) ? directorist_clean( wp_unslash( $_POST['price'] ) ) : ''; $meta_data['_price_range'] = isset( $_POST['price_range'] ) ? directorist_clean( wp_unslash( $_POST['price_range'] ) ) : ''; } @@ -400,19 +413,19 @@ public function save_post_meta( $post_id, $post ) { $field_key = ! empty( $value['field_key'] ) ? $value['field_key'] : ''; if ( ! in_array( $field_key, array( 'listing_title', 'listing_content', 'tax_input' ), true ) ) { - $meta_field_key = '_' . $field_key; + $meta_field_key = '_' . $field_key; $meta_data[ $meta_field_key ] = isset( $_POST[ $field_key ] ) ? wp_unslash( $_POST[ $field_key ] ) : ''; } } $meta_data['_directory_type'] = $directory_id; - $should_update_directory = apply_filters( 'directorist_should_update_directory_type', (bool) $meta_data['_directory_type'] ); + $should_update_directory = apply_filters( 'directorist_should_update_directory_type', (bool) $meta_data['_directory_type'] ); if ( $should_update_directory ) { wp_set_object_terms( $post_id, $directory_id, ATBDP_TYPE ); } - $admin_plan = isset( $_POST['admin_plan'] ) ? directorist_clean( wp_unslash( $_POST['admin_plan'] ) ) : ''; + $admin_plan = isset( $_POST['admin_plan'] ) ? directorist_clean( wp_unslash( $_POST['admin_plan'] ) ) : ''; if ( ! is_fee_manager_active() || ( 'null' === $admin_plan ) ) { $meta_data['_featured'] = ! empty( $_POST['featured'] ) ? true : false; } else { @@ -427,16 +440,18 @@ public function save_post_meta( $post_id, $post ) { $meta_data['_never_expire'] = null; } - //prepare expiry date, if we receive complete expire date from the submitted post, then use it, else use the default data + // prepare expiry date, if we receive complete expire date from the submitted post, then use it, else use the default data $expire_date = ! empty( $_POST['exp_date'] ) ? directorist_clean( wp_unslash( $_POST['exp_date'] ) ) : array(); if ( ! is_empty_v( $expire_date ) && ! empty( $expire_date['aa'] ) ) { - $expire_date = get_date_in_mysql_format( array( - 'year' => (int) $expire_date['aa'], - 'month' => (int) $expire_date['mm'], - 'day' => (int) $expire_date['jj'], - 'hour' => (int) $expire_date['hh'], - 'min' => (int) $expire_date['mn'] - ) ); + $expire_date = get_date_in_mysql_format( + array( + 'year' => (int) $expire_date['aa'], + 'month' => (int) $expire_date['mm'], + 'day' => (int) $expire_date['jj'], + 'hour' => (int) $expire_date['hh'], + 'min' => (int) $expire_date['mn'], + ) + ); } else { $expire_date = calc_listing_expiry_date( '', $default_expiration, $directory_id ); // get the expiry date in mysql date format using the default expiration date. } @@ -445,7 +460,7 @@ public function save_post_meta( $post_id, $post ) { $meta_data = apply_filters( 'atbdp_listing_meta_admin_submission', $meta_data, $_POST ); $valid_metadata = directorist_filter_listing_empty_metadata( $meta_data ); - foreach ( $valid_metadata as $meta_key => $meta_value) { + foreach ( $valid_metadata as $meta_key => $meta_value ) { update_post_meta( $post_id, $meta_key, $meta_value ); } @@ -464,14 +479,16 @@ public function save_post_meta( $post_id, $post ) { // let's check is listing need to update if ( empty( $listing_status ) || ( 'expired' === $listing_status ) && ( 'private' === $listing_status ) ) { if ( ( $expire_date > $current_date ) || $should_never_expire ) { - wp_update_post( array( - 'ID' => $post_id, - 'post_status' => $listing_status, // update the status to private so that we do not run this func a second time - 'meta_input' => array( - // Used it for backward compatibility. - '_listing_status' => 'post_status', - ), - ) ); + wp_update_post( + array( + 'ID' => $post_id, + 'post_status' => $listing_status, // update the status to private so that we do not run this func a second time + 'meta_input' => array( + // Used it for backward compatibility. + '_listing_status' => 'post_status', + ), + ) + ); } } } diff --git a/includes/classes/class-permalink.php b/includes/classes/class-permalink.php index 86f475af93..73d6694331 100644 --- a/includes/classes/class-permalink.php +++ b/includes/classes/class-permalink.php @@ -13,773 +13,783 @@ use Directorist\Helper; // Exit if accessed directly -if ( ! defined('ABSPATH') ) { die( 'You are not allowed to access this file directly' ); } +if ( ! defined( 'ABSPATH' ) ) { + die( 'You are not allowed to access this file directly' ); } -if (!class_exists('ATBDP_Permalink')): -class ATBDP_Permalink { +if ( ! class_exists( 'ATBDP_Permalink' ) ) : + class ATBDP_Permalink { + + // atbdp_get_listing_permalink + public static function get_listing_permalink( $post_id = 0, $permalink = '' ) { + if ( ATBDP_POST_TYPE !== get_post_type( $post_id ) ) { + return $permalink; + } + + if ( empty( get_directorist_option( 'single_listing_slug_with_directory_type', false ) ) ) { + return $permalink; + } + + if ( empty( $permalink ) ) { + $permalink = get_the_permalink( $post_id ); + } + + $directory_slug = ''; + $directory_id = directorist_get_listing_directory( $post_id ); + + if ( $directory_id ) { + $directory_term = get_term( $directory_id, ATBDP_DIRECTORY_TYPE ); + $directory_slug = $directory_term ? $directory_term->slug : ''; + } + + if ( empty( $directory_slug ) ) { + $directory_terms = get_the_terms( $post_id, ATBDP_DIRECTORY_TYPE ); + + if ( ! is_wp_error( $directory_terms ) && ! empty( $directory_terms ) ) { + $directory_slug = $directory_terms[0]->slug; + } + } + + $permalink = str_replace( '%' . ATBDP_DIRECTORY_TYPE . '%', $directory_slug, $permalink ); - // atbdp_get_listing_permalink - public static function get_listing_permalink( $post_id = 0, $permalink = '' ) { - if ( ATBDP_POST_TYPE !== get_post_type( $post_id ) ) { return $permalink; } - if ( empty( get_directorist_option( 'single_listing_slug_with_directory_type', false ) ) ) { - return $permalink; - } + public static function get_listing_slug() { + $listing_slug = 'directory/%' . ATBDP_DIRECTORY_TYPE . '%'; + $custom_listing_slug = get_directorist_option( 'atbdp_listing_slug', 'directory' ); + + if ( ! empty( $custom_listing_slug ) ) { + $listing_slug = $custom_listing_slug . '/%' . ATBDP_DIRECTORY_TYPE . '%'; + } - if ( empty( $permalink ) ) { - $permalink = get_the_permalink( $post_id ); + return strtolower( $listing_slug ); } - $directory_slug = ''; - $directory_id = directorist_get_listing_directory( $post_id ); + /** + * It returns the link to the custom search archive page of ATBDP + * + * @return string + */ + public static function get_search_result_page_link() { + $link = home_url(); + $id = get_directorist_option( 'search_result_page' ); // get the page id of the search page. + + if ( atbdp_required_polylang_url() && $id && pll_get_post( $id ) ) { + $link = get_permalink( pll_get_post( $id ) ); + return apply_filters( 'atbdp_search_result_page_url', $link ); + } - if ( $directory_id ) { - $directory_term = get_term( $directory_id, ATBDP_DIRECTORY_TYPE ); - $directory_slug = $directory_term ? $directory_term->slug : ''; - } + if ( $id ) { + $link = get_permalink( $id ); + } - if ( empty( $directory_slug ) ) { - $directory_terms = get_the_terms( $post_id, ATBDP_DIRECTORY_TYPE ); + return apply_filters( 'atbdp_search_result_page_url', $link ); + } - if ( ! is_wp_error( $directory_terms ) && ! empty( $directory_terms ) ) { - $directory_slug = $directory_terms[0]->slug; + /** + * It returns the link to the custom search archive page of ATBDP + * + * @return string + */ + public static function get_user_profile_page_link( $author_id, $directory_type = '' ) { + $link = home_url(); + $page_id = get_directorist_option( 'author_profile_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + if ( '' != get_option( 'permalink_structure' ) ) { + $author = get_user_by( 'id', $author_id ); + $author_id = ( $author ) ? $author->user_login : $author_id; + + if ( ! empty( $directory_type ) && directorist_is_multi_directory_enabled() ) { + $slug = $author_id . '/directory/' . $directory_type; + $link = Helper::join_slug_to_url( $link, $slug ); + } else { + $link = Helper::join_slug_to_url( $link, $author_id ); + } + } } + + return apply_filters( 'atbdp_author_profile_page_url', $link, $page_id, $author_id, $directory_type ); } - $permalink = str_replace( '%' . ATBDP_DIRECTORY_TYPE . '%', $directory_slug, $permalink ); - - return $permalink; - } + /** + * It returns the link to the custom search archive page of ATBDP + * + * @return string + */ + public static function get_login_redirection_page_link() { + // Check if has temp redirect url + $temp_login_redirect = get_transient( 'atbdp_redirect_after_login' ); + + if ( ! empty( $temp_login_redirect ) ) { + delete_transient( 'atbdp_redirect_after_login' ); + return $temp_login_redirect; + } - public static function get_listing_slug() { - $listing_slug = 'directory/%'. ATBDP_DIRECTORY_TYPE .'%'; - $custom_listing_slug = get_directorist_option('atbdp_listing_slug', 'directory'); + $page_id = get_directorist_option( 'redirection_after_login', 'previous_page' ); + + if ( 'previous_page' == $page_id ) { + $link = wp_get_referer(); + } else { + $link = $page_id ? get_permalink( $page_id ) : ''; + } + + return apply_filters( 'atbdp_login_redirection_page_url', $link, $page_id ); + } + + public static function get_reg_redirection_page_link( $previous_page, $query_vars = array(), $page_link = '' ) { + $page_id = get_directorist_option( 'redirection_after_reg', 'previous_page' ); + + if ( ! empty( $page_link ) ) { + return $page_link; + } + + if ( 'previous_page' == $page_id ) { + $link = $previous_page; + } else { + $link = $page_id ? get_permalink( $page_id ) : ''; + } + + if ( ! empty( $query_vars ) && is_array( $query_vars ) ) { + $link = add_query_arg( $query_vars, $link ); + } + + return apply_filters( 'atbdp_reg_redirection_page_url', $link, $page_id ); + } + + /** + * It returns the link to the custom search archive page of ATBDP + * + * @param array $query_vars [optional] Array of query vars to be added to the registration page url + * @return string + */ + public static function get_dashboard_page_link( $query_vars = array() ) { + $link = home_url(); + $page_id = get_directorist_option( 'user_dashboard' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } + + if ( ! empty( $query_vars ) && is_array( $query_vars ) ) { + $link = add_query_arg( $query_vars, $link ); + } + + return apply_filters( 'atbdp_dashboard_page_url', $link, $page_id ); + } + + /** + * It returns the link to the custom search archive page of ATBDP + * + * @param array $query_vars [optional] Array of query vars to be added to the registration page url + * @return string + */ + public static function get_signin_signup_page_link( $query_vars = array() ) { + $link = home_url(); + $page_id = get_directorist_option( 'signin_signup_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } + + if ( ! empty( $query_vars ) && is_array( $query_vars ) ) { + $link = add_query_arg( $query_vars, $link ); + } + + return apply_filters( 'directorist_account_page_url', $link, $page_id ); + } + + /** + * It returns the link to the custom search archive page of ATBDP + * + * @return string + */ + public static function get_transaction_failure_page_link() { + $link = home_url(); + $page_id = get_directorist_option( 'transaction_failure_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } + + return apply_filters( 'atbdp_transaction_failure_page_url', $link, $page_id ); + } + + + /** + * It returns the link to the custom search archive page of ATBDP + * + * @param array $query_vars [optional] Array of query vars to be added to the registration page url + * @return string + */ + public static function get_registration_page_link( $query_vars = array() ) { + $link = home_url(); + $page_id = get_directorist_option( 'signin_signup_page' ); // get the page id of the custom registration page. + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } + + if ( ! empty( $query_vars ) && is_array( $query_vars ) ) { + $link = add_query_arg( $query_vars, $link ); + } + + return apply_filters( 'atbdp_registration_page_url', $link, $page_id ); + } + + /** + * It returns the link to the custom search archive page of ATBDP + * + * @param array $query_vars [optional] Array of query vars to be added to the registration page url + * @return string + */ + public static function get_registration_page_url( $query_vars = array() ) { + $link = home_url() . '/registration'; + /* + $id = get_directorist_option('custom_registration'); // get the page id of the custom registration page. + if( $id ) $link = get_permalink( $id ); + if (!empty($query_vars) && is_array($query_vars)){ + $link = add_query_arg( $query_vars, $link ); + }*/ + return apply_filters( 'atbdp_registration_page_url', $link ); + } + + + /** + * It returns the link to the all listing page of ATBDP + * + * @param array $query_vars [optional] Array of query vars to be added to the all listing page url + * @return string + * @since 5.0 + */ + public static function get_directorist_listings_page_link( $query_vars = array() ) { + $link = home_url(); + $page_id = get_directorist_option( 'all_listing_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } + + if ( ! empty( $query_vars ) && is_array( $query_vars ) ) { + $link = add_query_arg( $query_vars, $link ); + } + + return apply_filters( 'atbdp_listings_page_url', $link, $page_id ); + } + + /** + * It returns the link to the custom search archive page of ATBDP + * + * @param array $query_vars [optional] Array of query vars to be added to the registration page url + * @return string + */ + public static function get_login_page_link( $query_vars = array() ) { + $login_url = self::get_login_page_url( $query_vars ); + return apply_filters( 'atbdp_user_login_page_url', $login_url ); + } + + /** + * It returns the link to the custom search archive page of ATBDP + * + * @param array $query_vars [optional] Array of query vars to be added to the registration page url + * @return string + */ + public static function get_login_page_url( $query_vars = array() ) { + $link = home_url() . '/login'; + $page_id = get_directorist_option( 'signin_signup_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } + + if ( ! empty( $query_vars ) && is_array( $query_vars ) ) { + $link = add_query_arg( $query_vars, $link ); + } + + return apply_filters( 'atbdp_user_login_page_url', $link, $page_id ); + } + + + /** + * It returns the link to the add listing page + * + * @return string + */ + public static function get_add_listing_page_link() { + $link = home_url(); + $id = get_directorist_option( 'add_listing_page' ); + if ( $id ) { + $link = get_permalink( $id ); + } + return apply_filters( 'atbdp_add_listing_page_url', $link ); + } + + /** + * It returns the link to the add listing page + * + * @return string + */ + public static function get_add_listing_page_link_with_plan( $plan_id ) { + $link = home_url(); + $page_id = get_directorist_option( 'add_listing_page' ); + + if ( $page_id ) { + $args = array( + 'listing_type' => isset( $_GET['directory_type'] ) ? sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ) : '', + 'plan' => $plan_id, + ); + $link = get_permalink( $page_id ); + $link = add_query_arg( $args, $link ); + } + + return apply_filters( 'atbdp_add_listing_page_url', $link, $page_id, $plan_id ); + } + + /** + * It returns the link to the dashbord manage fees + * + * @return string + */ + public static function get_fee_plan_page_link() { + $link = home_url(); + $page_id = get_directorist_option( 'pricing_plans' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } - if ( ! empty( $custom_listing_slug ) ) { - $listing_slug = $custom_listing_slug. '/%' .ATBDP_DIRECTORY_TYPE. '%'; - } + return apply_filters( 'atbdp_fee_plan_page_url', $link, $page_id ); + } + + /** + * It returns the link to the dashbord manage fees + * + * @since 6.3 + * @return string + */ + public static function get_privacy_policy_page_url() { + $link = home_url(); + $page_id = get_directorist_option( 'privacy_policy' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } + + return apply_filters( 'atbdp_privacy_policy_page_url', $link, $page_id ); + } + + /** + * It returns the link to the dashbord manage fees + * + * @since 6.3 + * @return string + */ + public static function get_terms_and_conditions_page_url() { + $link = home_url(); + $page_id = get_directorist_option( 'terms_conditions' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + } + + return apply_filters( 'atbdp_terms_and_conditions_page_url', $link, $page_id ); + } + + + /** + * It returns the link to the custom edit listing page + * + * @param int $listing_id Listing ID + * @since 3.1.0 + * @return string + */ + public static function get_edit_listing_page_link( $listing_id ) { + $link = home_url(); + $page_id = get_directorist_option( 'add_listing_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . 'edit/' . $listing_id ); + } else { + $link = add_query_arg( + array( + 'atbdp_action' => 'edit', + 'atbdp_listing_id' => $listing_id, + ), + $link + ); + } + } + + return apply_filters( 'atbdp_edit_listing_page_url', $link, $page_id, $listing_id ); + } + + + /** + * It returns the current page url of the WordPress and you can add any query string to the url + * + * @param array $query_args The array of query arguments passed to the current url + * @return mixed it returns the current url of WordPress + */ + public static function get_current_page_url( $query_args = array() ) { + + global $wp; + $link = home_url( $wp->request ); + if ( ! is_empty_v( $query_args ) ) { + $link = home_url( add_query_arg( $query_args, $wp->request ) ); + } + + return apply_filters( 'atbdp_current_page_url', $link ); + } + + + /** + * It returns the link to the custom category archive page of ATBDP + * + * @param $cat + * @param string $field + * @return string + */ + public static function get_category_archive( $cat, $field = 'slug' ) { + $link = add_query_arg( + array( + 'q' => '', + 'in_cat' => $cat->{$field}, + ), + self::get_search_result_page_link() + ); + return apply_filters( 'atbdp_category_archive_url', $link, $cat, $field ); + } + + /** + * Generate a permalink for single category page. + * + * @since 4.5.3 + * + * @param object $term The term object. + * @return string Term link. + */ + public static function atbdp_get_category_page( $term, $directory_type = '' ) { + + $page_id = get_directorist_option( 'single_category_page' ); + $link = '/'; + + if ( $page_id ) { + if ( atbdp_required_polylang_url() ) { + $translation_page = pll_get_post( $page_id ); + + if ( $translation_page ) { + + $args = array( + 'category' => $term->slug, + 'directory_type' => $directory_type, + ); + + $translatted_page_link = get_permalink( $translation_page ); + + $link = add_query_arg( $args, $translatted_page_link ); + + return apply_filters( 'atbdp_single_category', $link, $page_id, $term, $directory_type ); + + } + } else { + $link = get_permalink( $page_id ); + + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . $term->slug ); + + } else { + $link = add_query_arg( 'atbdp_category', $term->slug, $link ); + } + } + } + + if ( ! empty( $directory_type ) && 'all' != $directory_type ) { + $link = $link . '?directory_type=' . $directory_type; + } + + return apply_filters( 'atbdp_single_category', $link, $page_id, $term, $directory_type ); + } + + /** + * Generate a permalink for single location page. + * + * @since 4.5.3 + * + * @param object $term The term object. + * @return string Term link. + */ + public static function atbdp_get_location_page( $term, $directory_type = '' ) { + + $page_id = get_directorist_option( 'single_location_page' ); + $link = '/'; + + if ( $page_id ) { + if ( atbdp_required_polylang_url() ) { + $translation_page = pll_get_post( $page_id ); + + if ( $translation_page ) { + + $args = array( + 'location' => $term->slug, + 'directory_type' => $directory_type, + ); + + $translatted_page_link = get_permalink( $translation_page ); + $link = add_query_arg( $args, $translatted_page_link ); + + return apply_filters( 'atbdp_single_location', $link, $page_id, $term, $directory_type ); + + } + } else { + $link = get_permalink( $page_id ); + + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . $term->slug ); + + } else { + $link = add_query_arg( 'atbdp_location', $term->slug, $link ); + } + } + } + + if ( ! empty( $directory_type ) && 'all' != $directory_type ) { + $link = $link . '?directory_type=' . $directory_type; + } + + return apply_filters( 'atbdp_single_location', $link, $page_id, $term, $directory_type ); + } + + /** + * Generate a permalink for single location page. + * + * @since 4.5.3 + * + * @param object $term The term object. + * @return string Term link. + */ + public static function atbdp_get_tag_page( $term, $directory_type = '' ) { + + $page_id = get_directorist_option( 'single_tag_page' ); + $link = '/'; + + if ( $page_id ) { + if ( atbdp_required_polylang_url() ) { + $translation_page = pll_get_post( $page_id ); + + if ( $translation_page ) { + $args = array( + 'location' => $term->slug, + 'directory_type' => $directory_type, + ); + + $translatted_page_link = get_permalink( $translation_page ); + $link = add_query_arg( $args, $translatted_page_link ); + + return apply_filters( 'atbdp_single_tag', $link, $page_id, $term, $directory_type ); + } + } else { + $link = get_permalink( $page_id ); + + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . $term->slug ); + + } else { + $link = add_query_arg( 'atbdp_single_tag', $term->slug, $link ); + } + } + } + + if ( ! empty( $directory_type ) && 'all' != $directory_type ) { + $link = $link . '?directory_type=' . $directory_type; + } + + return apply_filters( 'atbdp_single_tag', $link, $page_id, $term, $directory_type ); + } + + /** + * It returns the link to the custom category archive page of ATBDP + * + * @param $loc + * @param string $field + * @return string + */ + public static function get_location_archive( $loc, $field = 'slug' ) { + $link = add_query_arg( + array( + 'q' => '', + 'in_loc' => $loc->{$field}, + ), + self::get_search_result_page_link() + ); + return apply_filters( 'atbdp_location_archive_url', $link, $loc, $field ); + } + + /** + * It returns the link to the custom tag archive page of ATBDP + * + * @param WP_Term $tag + * @param string $field + * @return string + */ + public static function get_tag_archive( $tag, $field = 'slug' ) { + $link = add_query_arg( + array( + 'q' => '', + 'in_tag' => $tag->{$field}, + ), + self::get_search_result_page_link() + ); + return apply_filters( 'atbdp_tag_archive_url', $link, $tag, $field ); + } + + /** + * Generate a permalink for Payment receipt page. + * + * @since 3.1.0 + * + * @param int $order_id Order ID. + * @return string Payment receipt page URL. + */ + public static function get_payment_receipt_page_link( $order_id ) { + $link = home_url(); // default url + $page_id = get_directorist_option( 'payment_receipt_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . 'order/' . $order_id ); + } else { + $link = add_query_arg( + array( + 'atbdp_action' => 'order', + 'atbdp_order' => $order_id, + ), + $link + ); + } + } + + return apply_filters( 'atbdp_payment_receipt_page_url', $link, $page_id, $order_id ); + } + + /** + * Generate a permalink for Checkout page + * + * @since 3.1.0 + * + * @param int $listing_id Listing ID. + * @return string It returns Checkout page URL. + */ + public static function get_checkout_page_link( $listing_id ) { + $link = home_url(); // default url + $page_id = get_directorist_option( 'checkout_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . 'submit/' . $listing_id ); + } else { + $link = add_query_arg( + array( + 'atbdp_action' => 'submission', + 'atbdp_listing_id' => $listing_id, + ), + $link + ); + } + } + + return apply_filters( 'atbdp_checkout_page_url', $link, $page_id, $listing_id ); + } + + /** + * Generate a permalink for Checkout page + * + * @since 3.1.0 + * + * @param int $listing_id Listing ID. + * @return string It returns Checkout page URL. + */ + public static function get_fee_renewal_checkout_page_link( $listing_id ) { + $link = home_url(); // default url + $page_id = get_directorist_option( 'checkout_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . 'submit/' . $listing_id ); + } else { + $link = add_query_arg( + array( + 'atbdp_action' => 'submission', + 'atbdp_listing_id' => $listing_id, + ), + $link + ); + } + } + + return apply_filters( 'atbdp_renewal_checkout_page_url', $link, $page_id, $listing_id ); + } + + public static function get_renewal_page_link( $listing_id ) { + $link = home_url(); + $id = get_directorist_option( 'add_listing_page' ); + + if ( $id ) { + $link = get_permalink( $id ); + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . 'renew/' . $listing_id ); + } else { + $link = add_query_arg( + array( + 'atbdp_action' => 'renew', + 'atbdp_listing_id ' => $listing_id, + ), + $link + ); + } + } + + return $link; + } + + /** + * Generate a permalink for IPN Notify URL + * + * @since 3.1.2 + * + * @param int $order_id Order ID. + * @return string It returns IPN Notify URL + */ + public static function get_ipn_notify_page_link( $order_id ) { + $link = home_url(); // default url + $page_id = get_directorist_option( 'checkout_page' ); + + if ( $page_id ) { + $link = get_permalink( $page_id ); + + if ( '' != get_option( 'permalink_structure' ) ) { + $link = user_trailingslashit( trailingslashit( $link ) . 'paypal-ipn/' . $order_id ); + } else { + $link = add_query_arg( + array( + 'atbdp_action' => 'paypal-ipn', + 'atbdp_order_id' => $order_id, + ), + $link + ); + } + } + + return apply_filters( 'atbdp_paypal_ipn_page_url', $link, $page_id, $order_id ); + } + } // end ATBDP_Permalink - return strtolower( $listing_slug ); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @return string - */ - public static function get_search_result_page_link() - { - $link = home_url(); - $id = get_directorist_option('search_result_page'); // get the page id of the search page. - - if ( atbdp_required_polylang_url() && $id && pll_get_post( $id ) ) { - $link = get_permalink( pll_get_post( $id ) ); - return apply_filters('atbdp_search_result_page_url', $link ); - } - - if ( $id ) { - $link = get_permalink( $id ); - } - - return apply_filters('atbdp_search_result_page_url', $link ); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @return string - */ - public static function get_user_profile_page_link( $author_id , $directory_type = '' ) - { - $link = home_url(); - $page_id = get_directorist_option('author_profile_page'); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - if( '' != get_option( 'permalink_structure' ) ) { - $author = get_user_by( 'id', $author_id ); - $author_id = ( $author ) ? $author->user_login : $author_id; - - if( ! empty( $directory_type ) && directorist_is_multi_directory_enabled() ) { - $slug = $author_id . '/directory/' . $directory_type; - $link = Helper::join_slug_to_url( $link, $slug ); - } else { - $link = Helper::join_slug_to_url( $link, $author_id ); - } - } - } - - return apply_filters( 'atbdp_author_profile_page_url', $link, $page_id, $author_id, $directory_type ); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @return string - */ - public static function get_login_redirection_page_link() - { - // Check if has temp redirect url - $temp_login_redirect = get_transient( 'atbdp_redirect_after_login' ); - - if ( ! empty( $temp_login_redirect ) ) { - delete_transient( 'atbdp_redirect_after_login' ); - return $temp_login_redirect; - } - - $page_id = get_directorist_option( 'redirection_after_login', 'previous_page' ); - - if ( 'previous_page' == $page_id ) { - $link = wp_get_referer(); - } else { - $link = $page_id ? get_permalink( $page_id ) : ''; - } - - return apply_filters( 'atbdp_login_redirection_page_url', $link, $page_id ); - } - - public static function get_reg_redirection_page_link( $previous_page, $query_vars=array(), $page_link = "" ) - { - $page_id = get_directorist_option( 'redirection_after_reg', 'previous_page' ); - - if( ! empty( $page_link ) ) { - return $page_link; - } - - if ( 'previous_page' == $page_id ) { - $link = $previous_page; - } else { - $link = $page_id ? get_permalink( $page_id ) : ''; - } - - if ( ! empty( $query_vars ) && is_array( $query_vars ) ) { - $link = add_query_arg( $query_vars, $link ); - } - - return apply_filters( 'atbdp_reg_redirection_page_url', $link, $page_id ); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @param array $query_vars [optional] Array of query vars to be added to the registration page url - * @return string - */ - public static function get_dashboard_page_link( $query_vars = array() ) - { - $link = home_url(); - $page_id = get_directorist_option( 'user_dashboard' ); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - } - - if ( ! empty( $query_vars ) && is_array( $query_vars ) ){ - $link = add_query_arg( $query_vars, $link ); - } - - return apply_filters( 'atbdp_dashboard_page_url', $link, $page_id ); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @param array $query_vars [optional] Array of query vars to be added to the registration page url - * @return string - */ - public static function get_signin_signup_page_link( $query_vars = array() ) - { - $link = home_url(); - $page_id = get_directorist_option( 'signin_signup_page' ); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - } - - if ( ! empty( $query_vars ) && is_array( $query_vars ) ){ - $link = add_query_arg( $query_vars, $link ); - } - - return apply_filters( 'directorist_account_page_url', $link, $page_id ); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @return string - */ - public static function get_transaction_failure_page_link() - { - $link = home_url(); - $page_id = get_directorist_option('transaction_failure_page'); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - } - - return apply_filters( 'atbdp_transaction_failure_page_url', $link, $page_id ); - } - - - /** - * It returns the link to the custom search archive page of ATBDP - * @param array $query_vars [optional] Array of query vars to be added to the registration page url - * @return string - */ - public static function get_registration_page_link($query_vars=array()) - { - $link = home_url(); - $page_id = get_directorist_option('signin_signup_page'); // get the page id of the custom registration page. - - if ( $page_id ) { - $link = get_permalink( $page_id ); - } - - if ( ! empty( $query_vars ) && is_array( $query_vars ) ) { - $link = add_query_arg( $query_vars, $link ); - } - - return apply_filters( 'atbdp_registration_page_url', $link, $page_id ); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @param array $query_vars [optional] Array of query vars to be added to the registration page url - * @return string - */ - public static function get_registration_page_url($query_vars=array()) - { - $link = home_url().'/registration'; - /*$id = get_directorist_option('custom_registration'); // get the page id of the custom registration page. - if( $id ) $link = get_permalink( $id ); - if (!empty($query_vars) && is_array($query_vars)){ - $link = add_query_arg( $query_vars, $link ); - }*/ - return apply_filters('atbdp_registration_page_url', $link); - } - - - /** - * It returns the link to the all listing page of ATBDP - * @param array $query_vars [optional] Array of query vars to be added to the all listing page url - * @return string - * @since 5.0 - */ - public static function get_directorist_listings_page_link($query_vars=array()) - { - $link = home_url(); - $page_id = get_directorist_option( 'all_listing_page' ); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - } - - if (!empty($query_vars) && is_array($query_vars)){ - $link = add_query_arg( $query_vars, $link ); - } - - return apply_filters( 'atbdp_listings_page_url', $link, $page_id ); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @param array $query_vars [optional] Array of query vars to be added to the registration page url - * @return string - */ - public static function get_login_page_link($query_vars=array()) - { - $login_url = ATBDP_Permalink::get_login_page_url( $query_vars ); - return apply_filters('atbdp_user_login_page_url', $login_url); - } - - /** - * It returns the link to the custom search archive page of ATBDP - * @param array $query_vars [optional] Array of query vars to be added to the registration page url - * @return string - */ - public static function get_login_page_url($query_vars=array()) - { - $link = home_url() .'/login'; - $page_id = get_directorist_option( 'signin_signup_page' ); - - if( $page_id ) { - $link = get_permalink( $page_id ); - } - - if (!empty($query_vars) && is_array($query_vars)){ - $link = add_query_arg( $query_vars, $link ); - } - - return apply_filters( 'atbdp_user_login_page_url', $link, $page_id ); - } - - - /** - * It returns the link to the add listing page - * @return string - */ - public static function get_add_listing_page_link() - { - $link = home_url(); - $id = get_directorist_option('add_listing_page'); - if( $id ) $link = get_permalink( $id ); - return apply_filters('atbdp_add_listing_page_url', $link ); - } - - /** - * It returns the link to the add listing page - * @return string - */ - public static function get_add_listing_page_link_with_plan($plan_id) - { - $link = home_url(); - $page_id = get_directorist_option( 'add_listing_page' ); - - if ( $page_id ) { - $args = [ - 'listing_type' => isset( $_GET['directory_type'] ) ? sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ) : '', - 'plan' => $plan_id, - ]; - $link = get_permalink( $page_id ); - $link = add_query_arg( $args, $link); - } - - return apply_filters( 'atbdp_add_listing_page_url', $link, $page_id, $plan_id ); - } - - /** - * It returns the link to the dashbord manage fees - * @return string - */ - public static function get_fee_plan_page_link() - { - $link = home_url(); - $page_id = get_directorist_option( 'pricing_plans' ); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - } - - return apply_filters( 'atbdp_fee_plan_page_url', $link, $page_id ); - } - - /** - * It returns the link to the dashbord manage fees - * @since 6.3 - * @return string - */ - public static function get_privacy_policy_page_url() - { - $link = home_url(); - $page_id = get_directorist_option( 'privacy_policy' ); - - if( $page_id ) { - $link = get_permalink( $page_id ); - } - - return apply_filters( 'atbdp_privacy_policy_page_url', $link, $page_id ); - } - - /** - * It returns the link to the dashbord manage fees - * @since 6.3 - * @return string - */ - public static function get_terms_and_conditions_page_url() - { - $link = home_url(); - $page_id = get_directorist_option( 'terms_conditions' ); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - } - - return apply_filters( 'atbdp_terms_and_conditions_page_url', $link, $page_id ); - } - - - /** - * It returns the link to the custom edit listing page - * @param int $listing_id Listing ID - * @since 3.1.0 - * @return string - */ - public static function get_edit_listing_page_link($listing_id) - { - $link = home_url(); - $page_id = get_directorist_option('add_listing_page'); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - if ( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . 'edit/' . $listing_id ); - } else { - $link = add_query_arg( array( 'atbdp_action' => 'edit', 'atbdp_listing_id' => $listing_id ), $link ); - } - } - - return apply_filters( 'atbdp_edit_listing_page_url', $link, $page_id, $listing_id ); - } - - - /** - * It returns the current page url of the wordpress and you can add any query string to the url - * @param array $query_args The array of query arguments passed to the current url - * @return mixed it returns the current url of WordPress - */ - public static function get_current_page_url($query_args=array()){ - - global $wp; - $link = home_url($wp->request); - if (!is_empty_v($query_args)){ - $link = home_url(add_query_arg($query_args, $wp->request)); - } - - return apply_filters('atbdp_current_page_url', $link ); - } - - - /** - * It returns the link to the custom category archive page of ATBDP - * @param $cat - * @param string $field - * @return string - */ - public static function get_category_archive($cat, $field='slug') - { - $link = add_query_arg( - array( - 'q'=>'', - 'in_cat'=>$cat->{$field} - ), - self::get_search_result_page_link() - ); - return apply_filters( 'atbdp_category_archive_url', $link, $cat, $field ); - } - - /** - * Generate a permalink for single category page. - * - * @since 4.5.3 - * - * @param object $term The term object. - * @return string Term link. - */ - public static function atbdp_get_category_page( $term, $directory_type = '' ) { - - $page_id = get_directorist_option('single_category_page'); - $link = '/'; - - if ( $page_id ) { - if ( atbdp_required_polylang_url() ) { - $translation_page = pll_get_post( $page_id ); - - if ( $translation_page ) { - - $args = [ - 'category' => $term->slug, - 'directory_type' => $directory_type, - ]; - - $translatted_page_link = get_permalink( $translation_page ); - - $link = add_query_arg( $args, $translatted_page_link ); - - return apply_filters( 'atbdp_single_category', $link, $page_id, $term, $directory_type ); - - } - } else { - $link = get_permalink( $page_id ); - - if( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . $term->slug ); - - } else { - $link = add_query_arg( 'atbdp_category', $term->slug, $link ); - } - } - } - - if ( ! empty( $directory_type ) && 'all' != $directory_type ) { - $link = $link . '?directory_type=' . $directory_type; - } - - return apply_filters( 'atbdp_single_category', $link, $page_id, $term, $directory_type ); - - } - - /** - * Generate a permalink for single location page. - * - * @since 4.5.3 - * - * @param object $term The term object. - * @return string Term link. - */ - public static function atbdp_get_location_page( $term, $directory_type = '' ) { - - $page_id = get_directorist_option('single_location_page'); - $link = '/'; - - if ( $page_id ) { - if ( atbdp_required_polylang_url() ) { - $translation_page = pll_get_post( $page_id ); - - if ( $translation_page ) { - - $args = [ - 'location' => $term->slug, - 'directory_type' => $directory_type, - ]; - - $translatted_page_link = get_permalink( $translation_page ); - $link = add_query_arg( $args, $translatted_page_link ); - - return apply_filters( 'atbdp_single_location', $link, $page_id, $term, $directory_type ); - - } - } else { - $link = get_permalink( $page_id ); - - if ( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . $term->slug ); - - } else { - $link = add_query_arg( 'atbdp_location', $term->slug, $link ); - } - } - } - - if ( ! empty( $directory_type ) && 'all' != $directory_type ) { - $link = $link . '?directory_type=' . $directory_type; - } - - return apply_filters( 'atbdp_single_location', $link, $page_id, $term, $directory_type ); - - } - - /** - * Generate a permalink for single location page. - * - * @since 4.5.3 - * - * @param object $term The term object. - * @return string Term link. - */ - public static function atbdp_get_tag_page( $term, $directory_type = '' ) { - - $page_id = get_directorist_option('single_tag_page'); - $link = '/'; - - if ( $page_id ) { - if ( atbdp_required_polylang_url() ) { - $translation_page = pll_get_post( $page_id ); - - if ( $translation_page ) { - $args = [ - 'location' => $term->slug, - 'directory_type' => $directory_type, - ]; - - $translatted_page_link = get_permalink( $translation_page ); - $link = add_query_arg( $args, $translatted_page_link ); - - return apply_filters( 'atbdp_single_tag', $link, $page_id, $term, $directory_type ); - } - } else { - $link = get_permalink( $page_id ); - - if ( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . $term->slug ); - - } else { - $link = add_query_arg( 'atbdp_single_tag', $term->slug, $link ); - } - } - } - - if ( ! empty( $directory_type ) && 'all' != $directory_type ) { - $link = $link . '?directory_type=' . $directory_type; - } - - return apply_filters( 'atbdp_single_tag', $link, $page_id, $term, $directory_type ); - - } - - /** - * It returns the link to the custom category archive page of ATBDP - * @param $loc - * @param string $field - * @return string - */ - public static function get_location_archive($loc, $field='slug') - { - $link = add_query_arg( - array( - 'q'=>'', - 'in_loc'=>$loc->{$field} - ), - self::get_search_result_page_link() - ); - return apply_filters( 'atbdp_location_archive_url', $link, $loc, $field ); - - } - - /** - * It returns the link to the custom tag archive page of ATBDP - * @param WP_Term $tag - * @param string $field - * @return string - */ - public static function get_tag_archive($tag, $field='slug') - { - $link = add_query_arg( - array( - 'q'=>'', - 'in_tag'=>$tag->{$field} - ), - self::get_search_result_page_link() - ); - return apply_filters( 'atbdp_tag_archive_url', $link, $tag, $field ); - } - - /** - * Generate a permalink for Payment receipt page. - * - * @since 3.1.0 - * - * @param int $order_id Order ID. - * @return string Payment receipt page URL. - */ - public static function get_payment_receipt_page_link($order_id) { - $link = home_url(); // default url - $page_id = get_directorist_option( 'payment_receipt_page' ); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - - if ( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . 'order/' . $order_id ); - } else { - $link = add_query_arg( - array( - 'atbdp_action' => 'order', - 'atbdp_order' => $order_id - ), - $link - ); - } - } - - return apply_filters( 'atbdp_payment_receipt_page_url', $link, $page_id, $order_id ); - } - - /** - * Generate a permalink for Checkout page - * - * @since 3.1.0 - * - * @param int $listing_id Listing ID. - * @return string It returns Checkout page URL. - */ - public static function get_checkout_page_link($listing_id) { - $link = home_url(); // default url - $page_id = get_directorist_option('checkout_page'); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - - if ( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . 'submit/' . $listing_id ); - } else { - $link = add_query_arg( - array( - 'atbdp_action' => 'submission', - 'atbdp_listing_id' => $listing_id - ), - $link - ); - } - } - - return apply_filters( 'atbdp_checkout_page_url', $link, $page_id, $listing_id ); - } - - /** - * Generate a permalink for Checkout page - * - * @since 3.1.0 - * - * @param int $listing_id Listing ID. - * @return string It returns Checkout page URL. - */ - public static function get_fee_renewal_checkout_page_link($listing_id) { - $link = home_url(); // default url - $page_id = get_directorist_option('checkout_page'); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - - if ( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . 'submit/' . $listing_id ); - } else { - $link = add_query_arg( - array( - 'atbdp_action' => 'submission', - 'atbdp_listing_id' => $listing_id - ), - $link - ); - } - } - - return apply_filters( 'atbdp_renewal_checkout_page_url', $link, $page_id, $listing_id ); - } - - public static function get_renewal_page_link($listing_id) - { - $link = home_url(); - $id = get_directorist_option('add_listing_page'); - - if( $id ) { - $link = get_permalink( $id ); - if( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . 'renew/' . $listing_id ); - } else { - $link = add_query_arg( array( 'atbdp_action' => 'renew', 'atbdp_listing_id ' => $listing_id ), $link ); - } - } - - return $link; - } - - /** - * Generate a permalink for IPN Notify URL - * - * @since 3.1.2 - * - * @param int $order_id Order ID. - * @return string It returns IPN Notify URL - */ - public static function get_ipn_notify_page_link($order_id) { - $link = home_url(); // default url - $page_id = get_directorist_option( 'checkout_page' ); - - if ( $page_id ) { - $link = get_permalink( $page_id ); - - if ( '' != get_option( 'permalink_structure' ) ) { - $link = user_trailingslashit( trailingslashit( $link ) . 'paypal-ipn/' . $order_id ); - } else { - $link = add_query_arg( - array( - 'atbdp_action' => 'paypal-ipn', - 'atbdp_order_id' => $order_id - ), - $link - ); - } - } - - return apply_filters( 'atbdp_paypal_ipn_page_url', $link, $page_id, $order_id ); - } - -} // end ATBDP_Permalink - -endif; \ No newline at end of file +endif; diff --git a/includes/classes/class-rewrite.php b/includes/classes/class-rewrite.php index 64ddfbae5d..6f6adc2228 100644 --- a/includes/classes/class-rewrite.php +++ b/includes/classes/class-rewrite.php @@ -1,212 +1,211 @@ <?php -if ( !class_exists('ATBDP_Rewrite') ): +if ( ! class_exists( 'ATBDP_Rewrite' ) ) : -/** - * Class ATBDP_Rewrite - * It handle custom rewrite rules and actions etc. - */ -class ATBDP_Rewrite { + /** + * Class ATBDP_Rewrite + * It handle custom rewrite rules and actions etc. + */ + class ATBDP_Rewrite { - protected $pages = array(); + protected $pages = array(); - public function __construct() { - // add the rewrite rules to the init hook - add_action( 'init', array( $this, 'add_write_rules' ) ); + public function __construct() { + // add the rewrite rules to the init hook + add_action( 'init', array( $this, 'add_write_rules' ) ); - $flush_rewrite_rules_on_demand = apply_filters( 'directorist_flush_rewrite_rules_on_demand', false ); + $flush_rewrite_rules_on_demand = apply_filters( 'directorist_flush_rewrite_rules_on_demand', false ); - if ( $flush_rewrite_rules_on_demand ) { - add_action( 'wp_loaded', array( $this, 'flush_rewrite_rules_on_demand' ) ); + if ( $flush_rewrite_rules_on_demand ) { + add_action( 'wp_loaded', array( $this, 'flush_rewrite_rules_on_demand' ) ); + } + add_action( 'directorist_setup_wizard_page_created', array( $this, 'flush_rewrite_rules_on_demand' ) ); + add_action( 'directorist_setup_wizard_payment_page_created', array( $this, 'flush_rewrite_rules_on_demand' ) ); + add_action( 'directorist_setup_wizard_completed', array( $this, 'flush_rewrite_rules_on_demand' ) ); + add_action( 'directorist_options_updated', array( $this, 'flush_rewrite_rules_on_demand' ) ); } - add_action( 'directorist_setup_wizard_page_created', array( $this, 'flush_rewrite_rules_on_demand' ) ); - add_action( 'directorist_setup_wizard_payment_page_created', array( $this, 'flush_rewrite_rules_on_demand' ) ); - add_action( 'directorist_setup_wizard_completed', array( $this, 'flush_rewrite_rules_on_demand' ) ); - add_action( 'directorist_options_updated', array( $this, 'flush_rewrite_rules_on_demand' ) ); - } - - protected function get_pages() { - if ( ! empty( $this->pages ) ) { + + protected function get_pages() { + if ( ! empty( $this->pages ) ) { + return $this->pages; + } + + $pages = array( + 'all_listing_page', + 'author_profile_page', + 'checkout_page', + 'payment_receipt_page', + 'add_listing_page', + 'single_category_page', + 'single_location_page', + 'single_tag_page', + ); + + foreach ( $pages as $page_option_key ) { + $this->pages[ $page_option_key ] = (int) get_directorist_option( $page_option_key ); + } + return $this->pages; } - $pages = array( - 'all_listing_page', - 'author_profile_page', - 'checkout_page', - 'payment_receipt_page', - 'add_listing_page', - 'single_category_page', - 'single_location_page', - 'single_tag_page', - ); - - foreach ( $pages as $page_option_key ) { - $this->pages[ $page_option_key ] = (int) get_directorist_option( $page_option_key ); + protected function get_page_ids() { + return array_unique( array_values( $this->get_pages() ) ); } - return $this->pages; - } - - protected function get_page_ids() { - return array_unique( array_values( $this->get_pages() ) ); - } - - protected function get_page_id( $option_key ) { - $pages = $this->get_pages(); - return array_key_exists( $option_key, $pages ) ? $pages[ $option_key ] : 0; - } + protected function get_page_id( $option_key ) { + $pages = $this->get_pages(); + return array_key_exists( $option_key, $pages ) ? $pages[ $option_key ] : 0; + } - protected function get_page_slug( $page_id, $default_slug ) { - $home_url = home_url( '/' ); - $slug = str_replace( $home_url, '', get_permalink( $page_id ) ); - $slug = rtrim( $slug, '/' ); - $slug = preg_match( '/([?])/', $slug ) ? $default_slug : $slug; + protected function get_page_slug( $page_id, $default_slug ) { + $home_url = home_url( '/' ); + $slug = str_replace( $home_url, '', get_permalink( $page_id ) ); + $slug = rtrim( $slug, '/' ); + $slug = preg_match( '/([?])/', $slug ) ? $default_slug : $slug; - return apply_filters( 'directorist_rewrite_get_page_slug', $slug, $page_id, $default_slug ); - } + return apply_filters( 'directorist_rewrite_get_page_slug', $slug, $page_id, $default_slug ); + } - public function add_write_rules() { - $cached_pages = get_pages( array( - 'include' => $this->get_page_ids() - ) ); + public function add_write_rules() { + $cached_pages = get_pages( + array( + 'include' => $this->get_page_ids(), + ) + ); - $page_id = $this->get_page_id( 'all_listing_page' ); - if ( $page_id ) { - $link = $this->get_page_slug( $page_id, 'directory-all-listing' ); + $page_id = $this->get_page_id( 'all_listing_page' ); + if ( $page_id ) { + $link = $this->get_page_slug( $page_id, 'directory-all-listing' ); - add_rewrite_rule( "$link/page/?([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&paged=$matches[1]', 'top' ); - } + add_rewrite_rule( "$link/page/?([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&paged=$matches[1]', 'top' ); + } - // Author profile page URL Rewrite - $page_id = $this->get_page_id( 'author_profile_page' ); - if ( $page_id ) { - $link = $this->get_page_slug( $page_id, 'directory-profile' ); + // Author profile page URL Rewrite + $page_id = $this->get_page_id( 'author_profile_page' ); + if ( $page_id ) { + $link = $this->get_page_slug( $page_id, 'directory-profile' ); - // Link > Page - add_rewrite_rule( "$link/page/(\d+)/?$", 'index.php?page_id='.$page_id.'&paged=$matches[1]', 'top' ); + // Link > Page + add_rewrite_rule( "$link/page/(\d+)/?$", 'index.php?page_id=' . $page_id . '&paged=$matches[1]', 'top' ); - // Link > Author > Page - add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id='.$page_id.'&author_id=$matches[1]', 'top' ); - add_rewrite_rule( "$link/([^/]+)/page/(\d)/?$", 'index.php?page_id='.$page_id.'&author_id=$matches[1]&paged=$matches[2]', 'top' ); + // Link > Author > Page + add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id=' . $page_id . '&author_id=$matches[1]', 'top' ); + add_rewrite_rule( "$link/([^/]+)/page/(\d)/?$", 'index.php?page_id=' . $page_id . '&author_id=$matches[1]&paged=$matches[2]', 'top' ); - // Link > Author > Directory > Page - add_rewrite_rule( "$link/([^/]+)/directory/([^/]+)/?$", 'index.php?page_id='.$page_id.'&author_id=$matches[1]&directory-type=$matches[2]', 'top' ); - add_rewrite_rule( "$link/([^/]+)/directory/([^/]+)/page/(\d)/?$", 'index.php?page_id='.$page_id.'&author_id=$matches[1]&directory-type=$matches[2]&paged=$matches[3]', 'top' ); + // Link > Author > Directory > Page + add_rewrite_rule( "$link/([^/]+)/directory/([^/]+)/?$", 'index.php?page_id=' . $page_id . '&author_id=$matches[1]&directory-type=$matches[2]', 'top' ); + add_rewrite_rule( "$link/([^/]+)/directory/([^/]+)/page/(\d)/?$", 'index.php?page_id=' . $page_id . '&author_id=$matches[1]&directory-type=$matches[2]&paged=$matches[3]', 'top' ); - // Link > Directory > Page - add_rewrite_rule( "$link/directory/([^/]+)/?$", 'index.php?page_id='.$page_id.'&directory-type=$matches[1]', 'top' ); - add_rewrite_rule( "$link/directory/([^/]+)/page/(\d)/?$", 'index.php?page_id='.$page_id.'&directory-type=$matches[1]&paged=$matches[2]', 'top' ); - } + // Link > Directory > Page + add_rewrite_rule( "$link/directory/([^/]+)/?$", 'index.php?page_id=' . $page_id . '&directory-type=$matches[1]', 'top' ); + add_rewrite_rule( "$link/directory/([^/]+)/page/(\d)/?$", 'index.php?page_id=' . $page_id . '&directory-type=$matches[1]&paged=$matches[2]', 'top' ); + } - // Checkout page URL Rewrite - $page_id = $this->get_page_id( 'checkout_page' ); - if ( $page_id ) { - $link = $this->get_page_slug( $page_id, 'directory-checkout' ); + // Checkout page URL Rewrite + $page_id = $this->get_page_id( 'checkout_page' ); + if ( $page_id ) { + $link = $this->get_page_slug( $page_id, 'directory-checkout' ); - add_rewrite_rule( "$link/submit/([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_action=submission&atbdp_listing_id=$matches[1]', 'top' ); - add_rewrite_rule( "$link/promote/([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_action=promotion&atbdp_listing_id=$matches[1]', 'top' ); - add_rewrite_rule( "$link/paypal-ipn/([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_action=paypal-ipn&atbdp_order_id=$matches[1]', 'top' ); - add_rewrite_rule( "$link/([^/]+)/([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_action=$matches[1]&atbdp_order_id=$matches[2]', 'top' ); // we can add listing_id instead of order_id if we want. - } + add_rewrite_rule( "$link/submit/([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_action=submission&atbdp_listing_id=$matches[1]', 'top' ); + add_rewrite_rule( "$link/promote/([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_action=promotion&atbdp_listing_id=$matches[1]', 'top' ); + add_rewrite_rule( "$link/paypal-ipn/([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_action=paypal-ipn&atbdp_order_id=$matches[1]', 'top' ); + add_rewrite_rule( "$link/([^/]+)/([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_action=$matches[1]&atbdp_order_id=$matches[2]', 'top' ); // we can add listing_id instead of order_id if we want. + } - // Payment receipt page - $page_id = $this->get_page_id( 'payment_receipt_page' ); - if( $page_id ) { - $link = $this->get_page_slug( $page_id, 'directory-payment-receipt' ); + // Payment receipt page + $page_id = $this->get_page_id( 'payment_receipt_page' ); + if ( $page_id ) { + $link = $this->get_page_slug( $page_id, 'directory-payment-receipt' ); - add_rewrite_rule( "$link/order/([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_action=order&atbdp_order_id=$matches[1]', 'top' ); - } + add_rewrite_rule( "$link/order/([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_action=order&atbdp_order_id=$matches[1]', 'top' ); + } + // Edit Listing/Renew Listing/Delete listings etc + $page_id = $this->get_page_id( 'add_listing_page' ); + if ( $page_id ) { + $link = $this->get_page_slug( $page_id, 'directory-add-listing' ); - // Edit Listing/Renew Listing/Delete listings etc - $page_id = $this->get_page_id( 'add_listing_page' ); - if ( $page_id ) { - $link = $this->get_page_slug( $page_id, 'directory-add-listing' ); + add_rewrite_rule( "$link/([^/]+)/([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_action=$matches[1]&atbdp_listing_id=$matches[2]', 'top' ); + } - add_rewrite_rule( "$link/([^/]+)/([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_action=$matches[1]&atbdp_listing_id=$matches[2]', 'top' ); - } + // Single Category page + $page_id = $this->get_page_id( 'single_category_page' ); + if ( $page_id ) { + $link = $this->get_page_slug( $page_id, 'directory-single-category' ); + add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_category=$matches[1]&paged=$matches[2]', 'top' ); + add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id=' . $page_id . '&atbdp_category=$matches[1]', 'top' ); + } - // Single Category page - $page_id = $this->get_page_id( 'single_category_page' ); - if ( $page_id ) { - $link = $this->get_page_slug( $page_id, 'directory-single-category' ); - add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_category=$matches[1]&paged=$matches[2]', 'top' ); - add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id='.$page_id.'&atbdp_category=$matches[1]', 'top' ); - } + // Single Location page + $page_id = $this->get_page_id( 'single_location_page' ); + if ( $page_id ) { + $link = $this->get_page_slug( $page_id, 'directory-single-location' ); - // Single Location page - $page_id = $this->get_page_id( 'single_location_page' ); - if ( $page_id ) { - $link = $this->get_page_slug( $page_id, 'directory-single-location' ); + add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_location=$matches[1]&paged=$matches[2]', 'top' ); + add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id=' . $page_id . '&atbdp_location=$matches[1]', 'top' ); + } - add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_location=$matches[1]&paged=$matches[2]', 'top' ); - add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id='.$page_id.'&atbdp_location=$matches[1]', 'top' ); - } + // Single Tag page + $page_id = $this->get_page_id( 'single_tag_page' ); + if ( $page_id ) { + $link = $this->get_page_slug( $page_id, 'directory-single-tag' ); - // Single Tag page - $page_id = $this->get_page_id( 'single_tag_page' ); - if ( $page_id ) { - $link = $this->get_page_slug( $page_id, 'directory-single-tag' ); + add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id=' . $page_id . '&atbdp_tag=$matches[1]&paged=$matches[2]', 'top' ); + add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id=' . $page_id . '&atbdp_tag=$matches[1]', 'top' ); + } - add_rewrite_rule( "$link/([^/]+)/page/?([0-9]{1,})/?$", 'index.php?page_id='.$page_id.'&atbdp_tag=$matches[1]&paged=$matches[2]', 'top' ); - add_rewrite_rule( "$link/([^/]+)/?$", 'index.php?page_id='.$page_id.'&atbdp_tag=$matches[1]', 'top' ); + unset( $cached_pages ); + + // Rewrite tags (Making custom query var available throughout the application + // WordPress by default does not understand the unknown query vars. It needs to be registered with WP for using it. + // by using add_rewrite_tag() or add_query_arg() on init hook or other earlier hook, we can register custom query var eg. atbdp_action and we can access it later on any other page + // by using get_query_var( 'atbdp_action' ); anywhere in the page. + // otherwise, get_query_var() would return and empty string even if the 'atbdp_action' var is available in the query string. + // + add_rewrite_tag( '%atbdp_action%', '([^/]+)' ); + add_rewrite_tag( '%atbdp_order_id%', '([0-9]{1,})' ); + add_rewrite_tag( '%atbdp_listing_id%', '([0-9]{1,})' ); + add_rewrite_tag( '%author_id%', '([^/]+)' ); + add_rewrite_tag( '%directory-type%', '([^/]+)' ); + add_rewrite_tag( '%atbdp_category%', '([^/]+)' ); + add_rewrite_tag( '%atbdp_location%', '([^/]+)' ); + add_rewrite_tag( '%atbdp_tag%', '([^/]+)' ); } - unset( $cached_pages ); - - // Rewrite tags (Making custom query var available throughout the application - // WordPress by default does not understand the unknown query vars. It needs to be registered with WP for using it. - // by using add_rewrite_tag() or add_query_arg() on init hook or other earlier hook, we can register custom query var eg. atbdp_action and we can access it later on any other page - // by using get_query_var( 'atbdp_action' ); anywhere in the page. - // otherwise, get_query_var() would return and empty string even if the 'atbdp_action' var is available in the query string. - // - add_rewrite_tag( '%atbdp_action%', '([^/]+)' ); - add_rewrite_tag( '%atbdp_order_id%', '([0-9]{1,})' ); - add_rewrite_tag( '%atbdp_listing_id%', '([0-9]{1,})' ); - add_rewrite_tag( '%author_id%', '([^/]+)' ); - add_rewrite_tag( '%directory-type%', '([^/]+)' ); - add_rewrite_tag( '%atbdp_category%', '([^/]+)' ); - add_rewrite_tag( '%atbdp_location%', '([^/]+)' ); - add_rewrite_tag( '%atbdp_tag%', '([^/]+)' ); - } + /** + * Flush the rewrite rules if needed as we have added new rewrite rules + * + * @since 3.1.2 + * @access public + */ + public function flush_rewrite_rules_on_demand() { - /** - * Flush the rewrite rules if needed as we have added new rewrite rules - * - * @since 3.1.2 - * @access public - */ - public function flush_rewrite_rules_on_demand() { - - $rewrite_rules = get_option( 'rewrite_rules' ); + $rewrite_rules = get_option( 'rewrite_rules' ); - if( $rewrite_rules ) { + if ( $rewrite_rules ) { - global $wp_rewrite; - $rewrite_rules_array = array(); - foreach( $rewrite_rules as $rule => $rewrite ) { - $rewrite_rules_array[$rule]['rewrite'] = $rewrite; - } - $rewrite_rules_array = array_reverse( $rewrite_rules_array, true ); + global $wp_rewrite; + $rewrite_rules_array = array(); + foreach ( $rewrite_rules as $rule => $rewrite ) { + $rewrite_rules_array[ $rule ]['rewrite'] = $rewrite; + } + $rewrite_rules_array = array_reverse( $rewrite_rules_array, true ); - $maybe_missing = $wp_rewrite->rewrite_rules(); - $missing_rules = false; + $maybe_missing = $wp_rewrite->rewrite_rules(); + $missing_rules = false; - foreach( $maybe_missing as $rule => $rewrite ) { - if( ! array_key_exists( $rule, $rewrite_rules_array ) ) { - $missing_rules = true; - break; + foreach ( $maybe_missing as $rule => $rewrite ) { + if ( ! array_key_exists( $rule, $rewrite_rules_array ) ) { + $missing_rules = true; + break; + } } - } - if( true === $missing_rules ) { - flush_rewrite_rules(); + if ( true === $missing_rules ) { + flush_rewrite_rules(); + } } - } + } // ends ATBDP_Rewrite - } -} // ends ATBDP_Rewrite - -endif; \ No newline at end of file +endif; diff --git a/includes/classes/class-roles.php b/includes/classes/class-roles.php index 61af5ef9ac..9e0d0c777c 100644 --- a/includes/classes/class-roles.php +++ b/includes/classes/class-roles.php @@ -1,345 +1,334 @@ <?php if ( ! defined( 'ABSPATH' ) ) { - die( '-1' ); + die( '-1' ); } /** * It creates roles for ATBDP and assign capability to those roles. + * * @since 3.0.0 * * Class ATBDP_Roles */ class ATBDP_Roles { - var $version = 5; - - public function __construct() - { - // Add custom ATBDP_Roles & Capabilities once only - if (get_option('atbdp_roles_version') < $this->version){ - add_action('admin_init', array($this, 'directorist_add_caps') ); - } - + var $version = 5; - add_action('init', array($this, 'disable_admin_bar_for_subscribers'), 9); - add_filter('wp_dropdown_users_args', array($this, 'add_subscribers_to_dropdown'), 10, 2 ); + public function __construct() { + // Add custom ATBDP_Roles & Capabilities once only + if ( get_option( 'atbdp_roles_version' ) < $this->version ) { + add_action( 'admin_init', array( $this, 'directorist_add_caps' ) ); + } + add_action( 'init', array( $this, 'disable_admin_bar_for_subscribers' ), 9 ); + add_filter( 'wp_dropdown_users_args', array( $this, 'add_subscribers_to_dropdown' ), 10, 2 ); + } - } - public function directorist_add_caps() { $this->add_caps(); // Insert atbdp_roles_mapped option to the db to prevent mapping meta cap update_option( 'atbdp_roles_version', $this->version ); } - /** - * @since 5.03 - */ - - - public function add_subscribers_to_dropdown( $query_args, $r ) { - - $query_args['who'] = ''; - return $query_args; - - } - - /** - * @since 5.0.0 - * It restrict subscriber not to enter in wp admin bar - */ - public function disable_admin_bar_for_subscribers(){ - if ( is_user_logged_in() ): - global $current_user; - if( !empty( $current_user->caps['subscriber'] ) ): - add_filter('show_admin_bar', '__return_false'); - endif; - /*if (is_directoria_active() && !empty( $current_user->caps['administrator'] )): - add_filter('show_admin_bar', '__return_false'); - endif;*/ - endif; - } - - /** - * It gets the WP Roles object. - * - * @since 3.0.0 - * @access public - * @return WP_Roles It returns an object of WP_Roles Class. - */ - public function getWpRoles() { - global $wp_roles; - - if ( !empty($wp_roles) && is_object($wp_roles) ) { - return $wp_roles; - } else { - if ( ! isset( $wp_roles ) ) { - $wp_roles = new WP_Roles(); - } - } - - return $wp_roles; - } - - /** - * Add new capabilities. - * - * @since 3.0.0 - * @access public - */ - public function add_caps() { - - $wp_roles = $this->getWpRoles(); - - if( is_object( $wp_roles ) ) { - // Add all the core caps to the administrator so that he can do anything with our custom post types - $custom_posts_caps = $this->get_core_caps(); // get caps array for our custom post(s) - // Iterate over the array of post types and caps array and assign the cap to the administrator role. - foreach( $custom_posts_caps as $single_post_caps ) { - foreach( $single_post_caps as $cap ) { - $wp_roles->add_cap( 'administrator', $cap ); - } - } - - /*lets add another capability to the admin to check him if he has cap to edit our settings, Though we can use default manage_options caps. However, if a shop manager has manage_options cap, we do not want to let him access to our plugin admin panel, we just want the admin to access the plugin's settings.*/ - $wp_roles->add_cap( 'administrator', 'manage_atbdp_options' ); - - $custom_posts = array( 'at_biz_dir', 'atbdp_order' ); // we can add more custom post type here as we will work on the plugin eg. payment. - // as author, contributor, and subscriber has the same caps, so lets loop over them and add the cap. - $users_roles = apply_filters( 'atbdp_user_roles', array( - 'author', - 'contributor', - 'subscriber', - 'shop_manager', - 'customer', - 'wcfm_vendor', - 'seller', - 'vendor', - 'shop_vendor', - 'dc_vendor', - 'yith_vendor', - ) ); - - // Add the "editor" capabilities of all of our custom posts - foreach ($custom_posts as $cp) { - if(post_type_exists($cp)){ - $wp_roles->add_cap( 'editor', "edit_{$cp}s"); - $wp_roles->add_cap( 'editor', "edit_others_{$cp}s" ); - $wp_roles->add_cap( 'editor', "publish_{$cp}s"); - $wp_roles->add_cap( 'editor', "read_private_{$cp}s" ); - $wp_roles->add_cap( 'editor', "delete_{$cp}s"); - $wp_roles->add_cap( 'editor', "delete_private_{$cp}s" ); - $wp_roles->add_cap( 'editor', "delete_published_{$cp}s"); - $wp_roles->add_cap( 'editor', "delete_others_{$cp}s" ); - $wp_roles->add_cap( 'editor', "edit_private_{$cp}s"); - $wp_roles->add_cap( 'editor', "edit_published_{$cp}s" ); - } - } - - // Add required capabilities of our post type to the author, contributor, and subscriber - foreach ($users_roles as $users_role) { - foreach ($custom_posts as $cp) { - if(post_type_exists($cp)){ - $wp_roles->add_cap( $users_role, "edit_{$cp}s" ); - $wp_roles->add_cap( $users_role, "publish_{$cp}s" ); - $wp_roles->add_cap( $users_role, "delete_{$cp}s" ); - $wp_roles->add_cap( $users_role, "delete_published_{$cp}s" ); - $wp_roles->add_cap( $users_role, "edit_published_{$cp}s" ); - } - } - } - - } - } - - /** - * Gets the core post type capabilities. - * - * @since 3.0.0 - * @access public - * - * @return array $capabilities Core post type capabilities. - */ - public function get_core_caps() { - - $caps = array(); - - $custom_posts = array( 'at_biz_dir', 'atbdp_order' ); // we can add more custom post type here as we will work on the plugin eg. payment. - - foreach( $custom_posts as $cp ) { - if(post_type_exists($cp)){ - $caps[ $cp ] = array( - - "edit_{$cp}", - "read_{$cp}", - "delete_{$cp}", - "edit_{$cp}s", - "edit_others_{$cp}s", - "publish_{$cp}s", - "read_private_{$cp}s", - "delete_{$cp}s", - "delete_private_{$cp}s", - "delete_published_{$cp}s", - "delete_others_{$cp}s", - "edit_private_{$cp}s", - "edit_published_{$cp}s", - - ); - } - } - - return $caps; - - } - - /** - * Filter a user's capabilities depending on specific context and/or privilege. - * - * @since 3.0.0 - * @access public - * - * @param array $caps Returns the user's actual capabilities. - * @param string $cap Capability name. - * @param int $user_id The user ID. - * @param array $args Adds the context to the cap. Typically the object ID. - * @return array Actual capabilities for meta capability. - */ - public function meta_caps( $caps, $cap, $user_id, $args ) { - - $custom_posts = array( 'at_biz_dir', 'atbdp_order' ); - - foreach ($custom_posts as $cp) { - if(post_type_exists($cp)){ - if ( ! isset( $args[0] ) || $args[0] === $user_id ) { - break; - }else{ - // If editing, deleting, or reading a custom post from the above list, get the post and post type object. - if( "edit_{$cp}" == $cap || "delete_{$cp}" == $cap || "read_{$cp}" == $cap ) { - $post = get_post( $args[0] ); - $post_type = get_post_type_object( $post->post_type ); - // Set an empty array for the caps. - $caps = array(); - } - - // If editing a listing, assign the required capability. - if( "edit_{$cp}" == $cap ) { - if( $user_id == $post->post_author ) - $caps[] = $post_type->cap->{'edit_'.$cp.'s'}; - else - $caps[] = $post_type->cap->{'edit_others_'.$cp.'s'}; - } - - // If deleting a listing, assign the required capability. - else if( "delete_{$cp}" == $cap ) { - if( $user_id == $post->post_author ) - $caps[] = $post_type->cap->{'delete_'.$cp.'s'}; - else - $caps[] = $post_type->cap->{'delete_others_'.$cp.'s'}; - } - - // If reading a private listing, assign the required capability. - else if( "read_{$cp}" == $cap ) { - if( 'private' != $post->post_status ) - $caps[] = 'read'; - elseif ( $user_id == $post->post_author ) - $caps[] = 'read'; - else - $caps[] = $post_type->cap->{'read_private_'.$cp.'s'}; - } - } - - } - - } - - - - // Return the capabilities required by the user. - return $caps; - - } - - /** - * Remove core post type capabilities (called on uninstall). - * - * @since 3.0.0 - * @access public - */ - public function remove_caps() { - - global $wp_roles; - - if( class_exists( 'WP_Roles' ) ) { - if( ! isset( $wp_roles ) ) { - $wp_roles = new WP_Roles(); - } - } - - if( is_object( $wp_roles ) ) { - - // Remove the "administrator" Capabilities - $capabilities = $this->get_core_caps(); - - foreach( $capabilities as $cap_group ) { - foreach( $cap_group as $cap ) { - $wp_roles->remove_cap( 'administrator', $cap ); - } - } - - $wp_roles->remove_cap( 'administrator', 'manage_atbdp_options' ); - - $custom_posts = array( 'at_biz_dir', 'atbdp_order' ); // we can add more custom post type here as we will work on the plugin eg. payment. - // as author, contributor, and subscriber has the same caps, so lets loop over them and add the cap. - $users_roles = array('author', 'contributor', 'subscriber'); - - - // Remove the "editor" capabilities - foreach ($custom_posts as $cp) { - if(post_type_exists($cp)){ - $wp_roles->remove_cap( 'editor', "edit_{$cp}s"); - $wp_roles->remove_cap( 'editor', "edit_others_{$cp}s" ); - $wp_roles->remove_cap( 'editor', "publish_{$cp}s"); - $wp_roles->remove_cap( 'editor', "read_private_{$cp}s" ); - $wp_roles->remove_cap( 'editor', "delete_{$cp}s"); - $wp_roles->remove_cap( 'editor', "delete_private_{$cp}s" ); - $wp_roles->remove_cap( 'editor', "delete_published_{$cp}s"); - $wp_roles->remove_cap( 'editor', "delete_others_{$cp}s" ); - $wp_roles->remove_cap( 'editor', "edit_private_{$cp}s"); - $wp_roles->remove_cap( 'editor', "edit_published_{$cp}s" ); - } - } - - // Remove the "editor" capabilities of all of our custom posts - foreach ($custom_posts as $cp) { - if(post_type_exists($cp)){ - $wp_roles->remove_cap( 'editor', "edit_{$cp}s"); - $wp_roles->remove_cap( 'editor', "edit_others_{$cp}s" ); - $wp_roles->remove_cap( 'editor', "publish_{$cp}s"); - $wp_roles->remove_cap( 'editor', "read_private_{$cp}s" ); - $wp_roles->remove_cap( 'editor', "delete_{$cp}s"); - $wp_roles->remove_cap( 'editor', "delete_private_{$cp}s" ); - $wp_roles->remove_cap( 'editor', "delete_published_{$cp}s"); - $wp_roles->remove_cap( 'editor', "delete_others_{$cp}s" ); - $wp_roles->remove_cap( 'editor', "edit_private_{$cp}s"); - $wp_roles->remove_cap( 'editor', "edit_published_{$cp}s" ); - } - } - - - // Remove required capabilities of our post type to the author, contributor, and subscriber - foreach ($users_roles as $users_role) { - foreach ($custom_posts as $cp) { - if(post_type_exists($cp)){ - $wp_roles->remove_cap( $users_role, "edit_{$cp}s" ); - $wp_roles->remove_cap( $users_role, "publish_{$cp}s" ); - $wp_roles->remove_cap( $users_role, "delete_{$cp}s" ); - $wp_roles->remove_cap( $users_role, "delete_published_{$cp}s" ); - $wp_roles->remove_cap( $users_role, "edit_published_{$cp}s" ); - } - } - } - - } - } + /** + * @since 5.03 + */ + public function add_subscribers_to_dropdown( $query_args, $r ) { + + $query_args['who'] = ''; + return $query_args; + } + + /** + * @since 5.0.0 + * It restrict subscriber not to enter in wp admin bar + */ + public function disable_admin_bar_for_subscribers() { + if ( is_user_logged_in() ) : + global $current_user; + if ( ! empty( $current_user->caps['subscriber'] ) ) : + add_filter( 'show_admin_bar', '__return_false' ); + endif; + /* + if (is_directoria_active() && !empty( $current_user->caps['administrator'] )): + add_filter('show_admin_bar', '__return_false'); + endif;*/ + endif; + } + + /** + * It gets the WP Roles object. + * + * @since 3.0.0 + * @access public + * @return WP_Roles It returns an object of WP_Roles Class. + */ + public function getWpRoles() { + global $wp_roles; + + if ( ! empty( $wp_roles ) && is_object( $wp_roles ) ) { + return $wp_roles; + } elseif ( ! isset( $wp_roles ) ) { + $wp_roles = new WP_Roles(); + } + + return $wp_roles; + } + + /** + * Add new capabilities. + * + * @since 3.0.0 + * @access public + */ + public function add_caps() { + + $wp_roles = $this->getWpRoles(); + + if ( is_object( $wp_roles ) ) { + // Add all the core caps to the administrator so that he can do anything with our custom post types + $custom_posts_caps = $this->get_core_caps(); // get caps array for our custom post(s) + // Iterate over the array of post types and caps array and assign the cap to the administrator role. + foreach ( $custom_posts_caps as $single_post_caps ) { + foreach ( $single_post_caps as $cap ) { + $wp_roles->add_cap( 'administrator', $cap ); + } + } + + /*lets add another capability to the admin to check him if he has cap to edit our settings, Though we can use default manage_options caps. However, if a shop manager has manage_options cap, we do not want to let him access to our plugin admin panel, we just want the admin to access the plugin's settings.*/ + $wp_roles->add_cap( 'administrator', 'manage_atbdp_options' ); + + $custom_posts = array( 'at_biz_dir', 'atbdp_order' ); // we can add more custom post type here as we will work on the plugin eg. payment. + // as author, contributor, and subscriber has the same caps, so lets loop over them and add the cap. + $users_roles = apply_filters( + 'atbdp_user_roles', + array( + 'author', + 'contributor', + 'subscriber', + 'shop_manager', + 'customer', + 'wcfm_vendor', + 'seller', + 'vendor', + 'shop_vendor', + 'dc_vendor', + 'yith_vendor', + ) + ); + + // Add the "editor" capabilities of all of our custom posts + foreach ( $custom_posts as $cp ) { + if ( post_type_exists( $cp ) ) { + $wp_roles->add_cap( 'editor', "edit_{$cp}s" ); + $wp_roles->add_cap( 'editor', "edit_others_{$cp}s" ); + $wp_roles->add_cap( 'editor', "publish_{$cp}s" ); + $wp_roles->add_cap( 'editor', "read_private_{$cp}s" ); + $wp_roles->add_cap( 'editor', "delete_{$cp}s" ); + $wp_roles->add_cap( 'editor', "delete_private_{$cp}s" ); + $wp_roles->add_cap( 'editor', "delete_published_{$cp}s" ); + $wp_roles->add_cap( 'editor', "delete_others_{$cp}s" ); + $wp_roles->add_cap( 'editor', "edit_private_{$cp}s" ); + $wp_roles->add_cap( 'editor', "edit_published_{$cp}s" ); + } + } + + // Add required capabilities of our post type to the author, contributor, and subscriber + foreach ( $users_roles as $users_role ) { + foreach ( $custom_posts as $cp ) { + if ( post_type_exists( $cp ) ) { + $wp_roles->add_cap( $users_role, "edit_{$cp}s" ); + $wp_roles->add_cap( $users_role, "publish_{$cp}s" ); + $wp_roles->add_cap( $users_role, "delete_{$cp}s" ); + $wp_roles->add_cap( $users_role, "delete_published_{$cp}s" ); + $wp_roles->add_cap( $users_role, "edit_published_{$cp}s" ); + } + } + } + } + } + + /** + * Gets the core post type capabilities. + * + * @since 3.0.0 + * @access public + * + * @return array $capabilities Core post type capabilities. + */ + public function get_core_caps() { + + $caps = array(); + + $custom_posts = array( 'at_biz_dir', 'atbdp_order' ); // we can add more custom post type here as we will work on the plugin eg. payment. + + foreach ( $custom_posts as $cp ) { + if ( post_type_exists( $cp ) ) { + $caps[ $cp ] = array( + + "edit_{$cp}", + "read_{$cp}", + "delete_{$cp}", + "edit_{$cp}s", + "edit_others_{$cp}s", + "publish_{$cp}s", + "read_private_{$cp}s", + "delete_{$cp}s", + "delete_private_{$cp}s", + "delete_published_{$cp}s", + "delete_others_{$cp}s", + "edit_private_{$cp}s", + "edit_published_{$cp}s", + + ); + } + } + + return $caps; + } + + /** + * Filter a user's capabilities depending on specific context and/or privilege. + * + * @since 3.0.0 + * @access public + * + * @param array $caps Returns the user's actual capabilities. + * @param string $cap Capability name. + * @param int $user_id The user ID. + * @param array $args Adds the context to the cap. Typically the object ID. + * @return array Actual capabilities for meta capability. + */ + public function meta_caps( $caps, $cap, $user_id, $args ) { + + $custom_posts = array( 'at_biz_dir', 'atbdp_order' ); + + foreach ( $custom_posts as $cp ) { + if ( post_type_exists( $cp ) ) { + if ( ! isset( $args[0] ) || $args[0] === $user_id ) { + break; + } else { + // If editing, deleting, or reading a custom post from the above list, get the post and post type object. + if ( "edit_{$cp}" == $cap || "delete_{$cp}" == $cap || "read_{$cp}" == $cap ) { + $post = get_post( $args[0] ); + $post_type = get_post_type_object( $post->post_type ); + // Set an empty array for the caps. + $caps = array(); + } + + // If editing a listing, assign the required capability. + if ( "edit_{$cp}" == $cap ) { + if ( $user_id == $post->post_author ) { + $caps[] = $post_type->cap->{'edit_' . $cp . 's'}; + } else { + $caps[] = $post_type->cap->{'edit_others_' . $cp . 's'}; + } + } + + // If deleting a listing, assign the required capability. + elseif ( "delete_{$cp}" == $cap ) { + if ( $user_id == $post->post_author ) { + $caps[] = $post_type->cap->{'delete_' . $cp . 's'}; + } else { + $caps[] = $post_type->cap->{'delete_others_' . $cp . 's'}; + } + } + + // If reading a private listing, assign the required capability. + elseif ( "read_{$cp}" == $cap ) { + if ( 'private' != $post->post_status ) { + $caps[] = 'read'; + } elseif ( $user_id == $post->post_author ) { + $caps[] = 'read'; + } else { + $caps[] = $post_type->cap->{'read_private_' . $cp . 's'}; + } + } + } + } + } + + // Return the capabilities required by the user. + return $caps; + } + + /** + * Remove core post type capabilities (called on uninstall). + * + * @since 3.0.0 + * @access public + */ + public function remove_caps() { + + global $wp_roles; + + if ( class_exists( 'WP_Roles' ) ) { + if ( ! isset( $wp_roles ) ) { + $wp_roles = new WP_Roles(); + } + } + + if ( is_object( $wp_roles ) ) { + + // Remove the "administrator" Capabilities + $capabilities = $this->get_core_caps(); + + foreach ( $capabilities as $cap_group ) { + foreach ( $cap_group as $cap ) { + $wp_roles->remove_cap( 'administrator', $cap ); + } + } + + $wp_roles->remove_cap( 'administrator', 'manage_atbdp_options' ); + + $custom_posts = array( 'at_biz_dir', 'atbdp_order' ); // we can add more custom post type here as we will work on the plugin eg. payment. + // as author, contributor, and subscriber has the same caps, so lets loop over them and add the cap. + $users_roles = array( 'author', 'contributor', 'subscriber' ); + + // Remove the "editor" capabilities + foreach ( $custom_posts as $cp ) { + if ( post_type_exists( $cp ) ) { + $wp_roles->remove_cap( 'editor', "edit_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "edit_others_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "publish_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "read_private_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "delete_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "delete_private_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "delete_published_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "delete_others_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "edit_private_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "edit_published_{$cp}s" ); + } + } + + // Remove the "editor" capabilities of all of our custom posts + foreach ( $custom_posts as $cp ) { + if ( post_type_exists( $cp ) ) { + $wp_roles->remove_cap( 'editor', "edit_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "edit_others_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "publish_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "read_private_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "delete_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "delete_private_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "delete_published_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "delete_others_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "edit_private_{$cp}s" ); + $wp_roles->remove_cap( 'editor', "edit_published_{$cp}s" ); + } + } + + // Remove required capabilities of our post type to the author, contributor, and subscriber + foreach ( $users_roles as $users_role ) { + foreach ( $custom_posts as $cp ) { + if ( post_type_exists( $cp ) ) { + $wp_roles->remove_cap( $users_role, "edit_{$cp}s" ); + $wp_roles->remove_cap( $users_role, "publish_{$cp}s" ); + $wp_roles->remove_cap( $users_role, "delete_{$cp}s" ); + $wp_roles->remove_cap( $users_role, "delete_published_{$cp}s" ); + $wp_roles->remove_cap( $users_role, "edit_published_{$cp}s" ); + } + } + } + } + } } diff --git a/includes/classes/class-seo.php b/includes/classes/class-seo.php index ff4556ae43..aa6c10d39f 100644 --- a/includes/classes/class-seo.php +++ b/includes/classes/class-seo.php @@ -1,22 +1,22 @@ <?php -defined('ABSPATH') || die('Direct access is not allowed.'); +defined( 'ABSPATH' ) || die( 'Direct access is not allowed.' ); if ( ! class_exists( 'ATBDP_SEO' ) ) : - /** - * Class ATBDP_SEO - */ - class ATBDP_SEO { + /** + * Class ATBDP_SEO + */ + class ATBDP_SEO { - public function __construct() { + public function __construct() { $is_enabled_seo = ! empty( get_directorist_option( 'atbdp_enable_seo' ) ); - if ( ! $is_enabled_seo ) { + if ( ! $is_enabled_seo ) { return; } - add_action( 'init', [ $this, 'setup_seo' ] ); - } + add_action( 'init', array( $this, 'setup_seo' ) ); + } /** * Setup SEO @@ -32,55 +32,55 @@ public function setup_seo() { } // Add Yoast SEO Compatibility - if ( Directorist\Helper::is_yoast_active() ) { + if ( Directorist\Helper::is_yoast_active() ) { $this->add_yoast_compatibility(); return; - } + } add_filter( 'the_title', array( $this, 'update_taxonomy_page_title' ), 10, 2 ); add_filter( 'single_post_title', array( $this, 'update_taxonomy_single_page_title' ), 10, 2 ); - add_filter( 'pre_get_document_title', array($this, 'atbdp_custom_page_title'), 10 ); + add_filter( 'pre_get_document_title', array( $this, 'atbdp_custom_page_title' ), 10 ); - add_action('wp_head', array($this, 'atbdp_add_meta_keywords'), 10, 2); - add_filter('wp_title', array($this, 'atbdp_custom_page_title'), 10, 2); - add_action('wp_head', array($this, 'add_opengraph_meta'), 10, 2); - add_action('wp_head', array($this, 'add_texonomy_canonical')); - add_action( 'wp', [ $this, 'remove_duplicate_canonical' ] ); + add_action( 'wp_head', array( $this, 'atbdp_add_meta_keywords' ), 10, 2 ); + add_filter( 'wp_title', array( $this, 'atbdp_custom_page_title' ), 10, 2 ); + add_action( 'wp_head', array( $this, 'add_opengraph_meta' ), 10, 2 ); + add_action( 'wp_head', array( $this, 'add_texonomy_canonical' ) ); + add_action( 'wp', array( $this, 'remove_duplicate_canonical' ) ); } // Add Yoast Compatibility - public function add_yoast_compatibility() { - add_filter( 'the_title', array( $this, 'update_taxonomy_page_title' ), 10, 2 ); + public function add_yoast_compatibility() { + add_filter( 'the_title', array( $this, 'update_taxonomy_page_title' ), 10, 2 ); add_filter( 'single_post_title', array( $this, 'update_taxonomy_single_page_title' ), 10, 2 ); - add_filter( 'pre_get_document_title', array($this, 'atbdp_custom_page_title'), 10 ); + add_filter( 'pre_get_document_title', array( $this, 'atbdp_custom_page_title' ), 10 ); - add_filter('wp_title', array($this, 'atbdp_custom_page_title'), 10, 2); + add_filter( 'wp_title', array( $this, 'atbdp_custom_page_title' ), 10, 2 ); - add_filter('wpseo_title', array($this, 'wpseo_title')); - add_filter('wpseo_metadesc', array($this, 'wpseo_metadesc')); - add_filter('wpseo_canonical', array($this, 'directorist_canonical')); - add_filter('wpseo_opengraph_url', array($this, 'directorist_canonical')); - add_filter('wpseo_opengraph_title', array($this, 'wpseo_opengraph_title')); - //add_filter('wpseo_opengraph_image', array($this, 'wpseo_opengraph_image')); + add_filter( 'wpseo_title', array( $this, 'wpseo_title' ) ); + add_filter( 'wpseo_metadesc', array( $this, 'wpseo_metadesc' ) ); + add_filter( 'wpseo_canonical', array( $this, 'directorist_canonical' ) ); + add_filter( 'wpseo_opengraph_url', array( $this, 'directorist_canonical' ) ); + add_filter( 'wpseo_opengraph_title', array( $this, 'wpseo_opengraph_title' ) ); + // add_filter('wpseo_opengraph_image', array($this, 'wpseo_opengraph_image')); - remove_action('wp_head', 'rel_canonical'); + remove_action( 'wp_head', 'rel_canonical' ); /* Exclude Multiple Taxonomies From Yoast SEO Sitemap */ - add_filter( 'wpseo_sitemap_exclude_taxonomy', [ $this, 'yoast_sitemap_exclude_taxonomy'], 10, 2 ); - } + add_filter( 'wpseo_sitemap_exclude_taxonomy', array( $this, 'yoast_sitemap_exclude_taxonomy' ), 10, 2 ); + } - // Add Rank Math Compatibility - public function add_rankmath_compatibility() { - add_filter( 'the_title', array( $this, 'update_taxonomy_page_title' ), 10, 2 ); + // Add Rank Math Compatibility + public function add_rankmath_compatibility() { + add_filter( 'the_title', array( $this, 'update_taxonomy_page_title' ), 10, 2 ); add_filter( 'single_post_title', array( $this, 'update_taxonomy_single_page_title' ), 10, 2 ); - add_filter( 'pre_get_document_title', array($this, 'atbdp_custom_page_title'), 10 ); + add_filter( 'pre_get_document_title', array( $this, 'atbdp_custom_page_title' ), 10 ); - add_filter( 'rank_math/frontend/title', [ $this, 'optimize_rankmath_frontend_meta_title' ], 20, 1 ); - add_filter( 'rank_math/frontend/description', [ $this, 'optimize_rankmath_frontend_meta_description' ], 20, 1); - add_filter( 'rank_math/frontend/canonical', [ $this, 'directorist_canonical' ], 20, 1); - } + add_filter( 'rank_math/frontend/title', array( $this, 'optimize_rankmath_frontend_meta_title' ), 20, 1 ); + add_filter( 'rank_math/frontend/description', array( $this, 'optimize_rankmath_frontend_meta_description' ), 20, 1 ); + add_filter( 'rank_math/frontend/canonical', array( $this, 'directorist_canonical' ), 20, 1 ); + } // Optimize rankmath frontend meta title - public function optimize_rankmath_frontend_meta_title( $content ) { + public function optimize_rankmath_frontend_meta_title( $content ) { // Optimize meta title for single taxonomy pages $term = $this->get_taxonomy_page_term_data( get_the_ID() ); @@ -89,15 +89,15 @@ public function optimize_rankmath_frontend_meta_title( $content ) { return $content; } - $current_page = get_post(); + $current_page = get_post(); $current_page_title = $current_page->post_title; $taxonomy_page_title = str_replace( $current_page_title, $term['name'], $content ); return $taxonomy_page_title; - } + } // Optimize rankmath frontend meta description - public function optimize_rankmath_frontend_meta_description( $content ) { + public function optimize_rankmath_frontend_meta_description( $content ) { // Optimize meta description for single taxonomy pages $term = $this->get_taxonomy_page_term_data( get_the_ID() ); @@ -107,564 +107,566 @@ public function optimize_rankmath_frontend_meta_description( $content ) { } return $term['description']; - } - - // yoast_sitemap_exclude_taxonomy - public function yoast_sitemap_exclude_taxonomy( $value, $taxonomy ) { - $taxonomy_to_exclude = [ ATBDP_CATEGORY, ATBDP_LOCATION, ATBDP_TAGS, ATBDP_DIRECTORY_TYPE ]; - if ( in_array( $taxonomy, $taxonomy_to_exclude ) ) return true; - } - - // get_taxonomy_term - public function get_taxonomy_term($id = null) - { - $id = ($id) ? $id : get_the_ID(); - $post = get_post($id); - $taxonomy = null; - - if ($post instanceof WP_Post && ($post->post_type == 'post' || $post->post_type == 'page')) { - $CAT_page_ID = directorist_get_page_id( 'category' ); - $LOC_page_ID = directorist_get_page_id( 'location' ); - $Tag_page_ID = directorist_get_page_id( 'tag' ); - // Change Location page title - if ($post->ID == $LOC_page_ID) { - if ($slug = get_query_var('atbdp_location')) { - $term = get_term_by('slug', $slug, ATBDP_LOCATION); - $taxonomy = $term; - } - } - // Change Category page title - if ($post->ID == $CAT_page_ID) { - if ($slug = get_query_var('atbdp_category')) { - $term = get_term_by('slug', $slug, ATBDP_CATEGORY); - $taxonomy = $term; - } - } - // Change Tag page title - if ($post->ID == $Tag_page_ID) { - if ($slug = get_query_var('atbdp_tag')) { - $term = get_term_by('slug', $slug, ATBDP_TAGS); - $taxonomy = $term; - } - } - } - - return $taxonomy; - } - - - // wpseo_opengraph_title - public function wpseo_opengraph_title($title) - { + } + + // yoast_sitemap_exclude_taxonomy + public function yoast_sitemap_exclude_taxonomy( $value, $taxonomy ) { + $taxonomy_to_exclude = array( ATBDP_CATEGORY, ATBDP_LOCATION, ATBDP_TAGS, ATBDP_DIRECTORY_TYPE ); + if ( in_array( $taxonomy, $taxonomy_to_exclude ) ) { + return true; + } + } + + // get_taxonomy_term + public function get_taxonomy_term( $id = null ) { + $id = ( $id ) ? $id : get_the_ID(); + $post = get_post( $id ); + $taxonomy = null; + + if ( $post instanceof WP_Post && ( $post->post_type == 'post' || $post->post_type == 'page' ) ) { + $CAT_page_ID = directorist_get_page_id( 'category' ); + $LOC_page_ID = directorist_get_page_id( 'location' ); + $Tag_page_ID = directorist_get_page_id( 'tag' ); + // Change Location page title + if ( $post->ID == $LOC_page_ID ) { + if ( $slug = get_query_var( 'atbdp_location' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_LOCATION ); + $taxonomy = $term; + } + } + // Change Category page title + if ( $post->ID == $CAT_page_ID ) { + if ( $slug = get_query_var( 'atbdp_category' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_CATEGORY ); + $taxonomy = $term; + } + } + // Change Tag page title + if ( $post->ID == $Tag_page_ID ) { + if ( $slug = get_query_var( 'atbdp_tag' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_TAGS ); + $taxonomy = $term; + } + } + } + + return $taxonomy; + } + + + // wpseo_opengraph_title + public function wpseo_opengraph_title( $title ) { $wpseo_title = $this->wpseo_title( $title ); - return $wpseo_title; - } + return $wpseo_title; + } - public function update_taxonomy_page_title($title, $id = null) - { - if ( is_null( $id ) ) return $title; + public function update_taxonomy_page_title( $title, $id = null ) { + if ( is_null( $id ) ) { + return $title; + } - return $this->get_taxonomy_page_title( $title, $id ); - } + return $this->get_taxonomy_page_title( $title, $id ); + } - public function update_taxonomy_single_page_title( $title, $post ) - { - if ( is_null( $post ) ) return $title; + public function update_taxonomy_single_page_title( $title, $post ) { + if ( is_null( $post ) ) { + return $title; + } - return $this->get_taxonomy_page_title( $title, $post->ID ); - } + return $this->get_taxonomy_page_title( $title, $post->ID ); + } - public function get_taxonomy_page_title( $default_title, $page_id ) - { - if ( is_admin() ) { return $default_title; } - if ( ! is_int( $page_id ) ) { return $default_title; } + public function get_taxonomy_page_title( $default_title, $page_id ) { + if ( is_admin() ) { + return $default_title; } + if ( ! is_int( $page_id ) ) { + return $default_title; } - $category_page_id = directorist_get_page_id( 'category' ); - $location_page_id = directorist_get_page_id( 'location' ); - $tag_page_id = directorist_get_page_id( 'tag' ); + $category_page_id = directorist_get_page_id( 'category' ); + $location_page_id = directorist_get_page_id( 'location' ); + $tag_page_id = directorist_get_page_id( 'tag' ); - if ( ! in_array( $page_id, [ $category_page_id, $location_page_id, $tag_page_id ] ) ) { - return $default_title; - } + if ( ! in_array( $page_id, array( $category_page_id, $location_page_id, $tag_page_id ) ) ) { + return $default_title; + } - $term = $this->get_taxonomy_term(); - $page_title = ( ! empty( $term ) ) ? $term->name : $default_title; + $term = $this->get_taxonomy_term(); + $page_title = ( ! empty( $term ) ) ? $term->name : $default_title; - return $page_title; - } + return $page_title; + } - public function get_taxonomy_page_term_data( $page_id ) { - $category_page_id = directorist_get_page_id( 'category' ); - $location_page_id = directorist_get_page_id( 'location' ); - $tag_page_id = directorist_get_page_id( 'tag' ); + public function get_taxonomy_page_term_data( $page_id ) { + $category_page_id = directorist_get_page_id( 'category' ); + $location_page_id = directorist_get_page_id( 'location' ); + $tag_page_id = directorist_get_page_id( 'tag' ); - $term_pages = [ $category_page_id, $location_page_id, $tag_page_id ]; + $term_pages = array( $category_page_id, $location_page_id, $tag_page_id ); - if ( ! in_array( $page_id, $term_pages ) ) { - return null; - } + if ( ! in_array( $page_id, $term_pages ) ) { + return null; + } $term_data = $this->get_taxonomy_term(); - $term_data = ( $term_data ) ? json_decode( json_encode( $term_data ), true ) : []; + $term_data = ( $term_data ) ? json_decode( json_encode( $term_data ), true ) : array(); - return $term_data; - } + return $term_data; + } - public function wpseo_metadesc($desc) - { - global $post; + public function wpseo_metadesc( $desc ) { + global $post; - if ( empty( $post ) ) { - return $desc; - } - - $overwrite_yoast = get_directorist_option('overwrite_by_yoast'); - if (!isset($post)) return $desc; - - - $CAT_page_ID = directorist_get_page_id( 'category' ); - $LOC_page_ID = directorist_get_page_id( 'location' ); - $Tag_page_ID = directorist_get_page_id( 'tag' ); - - if (($post->ID != $CAT_page_ID) && ($post->ID != $LOC_page_ID) && ($post->ID != $Tag_page_ID) && (!is_singular('at_biz_dir'))) { - return $desc; - } - - $wpseo_titles = get_option('wpseo_titles'); + if ( empty( $post ) ) { + return $desc; + } - $sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options(); + $overwrite_yoast = get_directorist_option( 'overwrite_by_yoast' ); + if ( ! isset( $post ) ) { + return $desc; + } - if (isset($wpseo_titles['separator']) && isset($sep_options[$wpseo_titles['separator']])) { - $sep = $sep_options[$wpseo_titles['separator']]; - } else { - $sep = '-'; // Setting default separator if Admin didn't set it from backed - } + $CAT_page_ID = directorist_get_page_id( 'category' ); + $LOC_page_ID = directorist_get_page_id( 'location' ); + $Tag_page_ID = directorist_get_page_id( 'tag' ); - $replacements = array( - '%%sep%%' => $sep, - '%%page%%' => '', - '%%primary_category%%' => '', - '%%sitename%%' => get_bloginfo('name') - ); + if ( ( $post->ID != $CAT_page_ID ) && ( $post->ID != $LOC_page_ID ) && ( $post->ID != $Tag_page_ID ) && ( ! is_singular( 'at_biz_dir' ) ) ) { + return $desc; + } - $desc_template = ''; - if (is_singular('at_biz_dir')) { - if (!empty($overwrite_yoast)) { - return ''; - } - } + $wpseo_titles = get_option( 'wpseo_titles' ); - // Category page - if ($post->ID == $CAT_page_ID) { - if (!empty($overwrite_yoast)) { - return ''; - } - if ($slug = get_query_var('atbdp_category')) { + $sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options(); - $term = get_term_by('slug', $slug, 'at_biz_dir-category'); - $replacements['%%term_title%%'] = $term->name; + if ( isset( $wpseo_titles['separator'] ) && isset( $sep_options[ $wpseo_titles['separator'] ] ) ) { + $sep = $sep_options[ $wpseo_titles['separator'] ]; + } else { + $sep = '-'; // Setting default separator if Admin didn't set it from backed + } - // Get Archive SEO desc - if (array_key_exists('metadesc-tax-at_biz_dir-category', $wpseo_titles)) { - $desc_template = $wpseo_titles['metadesc-tax-at_biz_dir-category']; - } + $replacements = array( + '%%sep%%' => $sep, + '%%page%%' => '', + '%%primary_category%%' => '', + '%%sitename%%' => get_bloginfo( 'name' ), + ); + + $desc_template = ''; + if ( is_singular( 'at_biz_dir' ) ) { + if ( ! empty( $overwrite_yoast ) ) { + return ''; + } + } + + // Category page + if ( $post->ID == $CAT_page_ID ) { + if ( ! empty( $overwrite_yoast ) ) { + return ''; + } + if ( $slug = get_query_var( 'atbdp_category' ) ) { + + $term = get_term_by( 'slug', $slug, 'at_biz_dir-category' ); + $replacements['%%term_title%%'] = $term->name; + + // Get Archive SEO desc + if ( array_key_exists( 'metadesc-tax-at_biz_dir-category', $wpseo_titles ) ) { + $desc_template = $wpseo_titles['metadesc-tax-at_biz_dir-category']; + } + + // Get Term SEO desc + $meta = get_option( 'wpseo_taxonomy_meta' ); + + if ( array_key_exists( 'at_biz_dir-category', $meta ) ) { + + if ( array_key_exists( $term->term_id, $meta['at_biz_dir-category'] ) ) { + + if ( array_key_exists( 'wpseo_desc', $meta['at_biz_dir-category'][ $term->term_id ] ) ) { + $desc_template = $meta['at_biz_dir-category'][ $term->term_id ]['wpseo_desc']; + } + } + } + } + } + + // Location page + if ( $post->ID == $LOC_page_ID ) { + if ( ! empty( $overwrite_yoast ) ) { + return ''; + } + if ( $slug = get_query_var( 'atbdp_location' ) ) { + + $term = get_term_by( 'slug', $slug, 'at_biz_dir-location' ); + $replacements['%%term_title%%'] = $term->name; + + // Get Archive SEO desc + if ( array_key_exists( 'metadesc-tax-at_biz_dir-location', $wpseo_titles ) ) { + $desc_template = $wpseo_titles['metadesc-tax-at_biz_dir-location']; + } - // Get Term SEO desc - $meta = get_option('wpseo_taxonomy_meta'); + // Get Term SEO desc + $meta = get_option( 'wpseo_taxonomy_meta' ); - if (array_key_exists('at_biz_dir-category', $meta)) { + if ( array_key_exists( 'at_biz_dir-location', $meta ) ) { - if (array_key_exists($term->term_id, $meta['at_biz_dir-category'])) { + if ( array_key_exists( $term->term_id, $meta['at_biz_dir-location'] ) ) { - if (array_key_exists('wpseo_desc', $meta['at_biz_dir-category'][$term->term_id])) { - $desc_template = $meta['at_biz_dir-category'][$term->term_id]['wpseo_desc']; - } - } - } - } - } + if ( array_key_exists( 'wpseo_desc', $meta['at_biz_dir-location'][ $term->term_id ] ) ) { + $desc_template = $meta['at_biz_dir-location'][ $term->term_id ]['wpseo_desc']; + } + } + } + } + } - // Location page - if ($post->ID == $LOC_page_ID) { - if (!empty($overwrite_yoast)) { - return ''; - } - if ($slug = get_query_var('atbdp_location')) { + // Tag page + if ( $post->ID == $Tag_page_ID ) { + if ( ! empty( $overwrite_yoast ) ) { + return ''; + } + if ( $slug = get_query_var( 'atbdp_tag' ) ) { - $term = get_term_by('slug', $slug, 'at_biz_dir-location'); - $replacements['%%term_title%%'] = $term->name; + $term = get_term_by( 'slug', $slug, 'at_biz_dir-tags' ); + $replacements['%%term_title%%'] = $term->name; - // Get Archive SEO desc - if (array_key_exists('metadesc-tax-at_biz_dir-location', $wpseo_titles)) { - $desc_template = $wpseo_titles['metadesc-tax-at_biz_dir-location']; - } + // Get Archive SEO desc + if ( array_key_exists( 'metadesc-tax-at_biz_dir-tags', $wpseo_titles ) ) { + $desc_template = $wpseo_titles['metadesc-tax-at_biz_dir-tags']; + } - // Get Term SEO desc - $meta = get_option('wpseo_taxonomy_meta'); + // Get Term SEO desc + $meta = get_option( 'wpseo_taxonomy_meta' ); - if (array_key_exists('at_biz_dir-location', $meta)) { + if ( array_key_exists( 'at_biz_dir-tags', $meta ) ) { - if (array_key_exists($term->term_id, $meta['at_biz_dir-location'])) { + if ( array_key_exists( $term->term_id, $meta['at_biz_dir-tags'] ) ) { - if (array_key_exists('wpseo_desc', $meta['at_biz_dir-location'][$term->term_id])) { - $desc_template = $meta['at_biz_dir-location'][$term->term_id]['wpseo_desc']; - } - } - } - } - } + if ( array_key_exists( 'wpseo_desc', $meta['at_biz_dir-tags'][ $term->term_id ] ) ) { + $desc_template = $meta['at_biz_dir-tags'][ $term->term_id ]['wpseo_desc']; + } + } + } + } + } - // Tag page - if ($post->ID == $Tag_page_ID) { - if (!empty($overwrite_yoast)) { - return ''; - } - if ($slug = get_query_var('atbdp_tag')) { + // Return + if ( ! empty( $desc_template ) ) { + $desc = strtr( $desc_template, $replacements ); + } - $term = get_term_by('slug', $slug, 'at_biz_dir-tags'); - $replacements['%%term_title%%'] = $term->name; - - // Get Archive SEO desc - if (array_key_exists('metadesc-tax-at_biz_dir-tags', $wpseo_titles)) { - $desc_template = $wpseo_titles['metadesc-tax-at_biz_dir-tags']; - } - - // Get Term SEO desc - $meta = get_option('wpseo_taxonomy_meta'); - - if (array_key_exists('at_biz_dir-tags', $meta)) { - - if (array_key_exists($term->term_id, $meta['at_biz_dir-tags'])) { - - if (array_key_exists('wpseo_desc', $meta['at_biz_dir-tags'][$term->term_id])) { - $desc_template = $meta['at_biz_dir-tags'][$term->term_id]['wpseo_desc']; - } - } - } - } - } - - - // Return - if (!empty($desc_template)) { - $desc = strtr($desc_template, $replacements); - } - - return $desc; - } + return $desc; + } - public function wpseo_title($title, $id = null) - { - global $post; + public function wpseo_title( $title, $id = null ) { + global $post; - if ( empty( $post ) ) { - return $title; - } + if ( empty( $post ) ) { + return $title; + } - $CAT_page_ID = directorist_get_page_id( 'category' ); - $LOC_page_ID = directorist_get_page_id( 'location' ); - $Tag_page_ID = directorist_get_page_id( 'tag' ); + $CAT_page_ID = directorist_get_page_id( 'category' ); + $LOC_page_ID = directorist_get_page_id( 'location' ); + $Tag_page_ID = directorist_get_page_id( 'tag' ); - if (($post->ID != $CAT_page_ID) && ($post->ID != $LOC_page_ID) && ($post->ID != $Tag_page_ID) && (!is_singular('at_biz_dir'))) { - return $title; - } + if ( ( $post->ID != $CAT_page_ID ) && ( $post->ID != $LOC_page_ID ) && ( $post->ID != $Tag_page_ID ) && ( ! is_singular( 'at_biz_dir' ) ) ) { + return $title; + } - $wpseo_titles = get_option('wpseo_titles'); + $wpseo_titles = get_option( 'wpseo_titles' ); - $sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options(); + $sep_options = WPSEO_Option_Titles::get_instance()->get_separator_options(); - if (isset($wpseo_titles['separator']) && isset($sep_options[$wpseo_titles['separator']])) { - $sep = $sep_options[$wpseo_titles['separator']]; - } else { - $sep = '-'; // Setting default separator if Admin didn't set it from backed - } + if ( isset( $wpseo_titles['separator'] ) && isset( $sep_options[ $wpseo_titles['separator'] ] ) ) { + $sep = $sep_options[ $wpseo_titles['separator'] ]; + } else { + $sep = '-'; // Setting default separator if Admin didn't set it from backed + } - $replacements = array( - '%%sep%%' => $sep, - '%%page%%' => '', - '%%primary_category%%' => '', - '%%sitename%%' => get_bloginfo('name') - ); + $replacements = array( + '%%sep%%' => $sep, + '%%page%%' => '', + '%%primary_category%%' => '', + '%%sitename%%' => get_bloginfo( 'name' ), + ); - $title_template = ''; + $title_template = ''; - // Category page - if ($post->ID == $CAT_page_ID) { - if ($slug = get_query_var('atbdp_category')) { - $term = get_term_by('slug', $slug, 'at_biz_dir-category'); - $replacements['%%term_title%%'] = $term->name; + // Category page + if ( $post->ID == $CAT_page_ID ) { + if ( $slug = get_query_var( 'atbdp_category' ) ) { + $term = get_term_by( 'slug', $slug, 'at_biz_dir-category' ); + $replacements['%%term_title%%'] = $term->name; - // Get Archive SEO title - if (array_key_exists('title-tax-at_biz_dir-category', $wpseo_titles)) { + // Get Archive SEO title + if ( array_key_exists( 'title-tax-at_biz_dir-category', $wpseo_titles ) ) { $title_template = $wpseo_titles['title-tax-at_biz_dir-category']; } - // Get Term SEO title - $meta = get_option('wpseo_taxonomy_meta'); + // Get Term SEO title + $meta = get_option( 'wpseo_taxonomy_meta' ); + + if ( array_key_exists( 'at_biz_dir-category', $meta ) ) { + if ( array_key_exists( $term->term_id, $meta['at_biz_dir-category'] ) ) { + + if ( array_key_exists( 'wpseo_focuskw', $meta['at_biz_dir-category'][ $term->term_id ] ) ) { + $replacements['%%term_title%%'] = $meta['at_biz_dir-category'][ $term->term_id ]['wpseo_focuskw']; + } + + if ( array_key_exists( 'wpseo_title', $meta['at_biz_dir-category'][ $term->term_id ] ) && ! empty( $meta['at_biz_dir-category'][ $term->term_id ]['wpseo_title'] ) ) { + $title_template = $meta['at_biz_dir-category'][ $term->term_id ]['wpseo_title']; + } + } + } + } + } + + // Location page + if ( $post->ID == $LOC_page_ID ) { + $slug = get_query_var( 'atbdp_location' ); + if ( ! empty( $slug ) ) { + $term = get_term_by( 'slug', $slug, 'at_biz_dir-location' ); + $replacements['%%term_title%%'] = $term->name; + + // Get Archive SEO title + if ( array_key_exists( 'title-tax-at_biz_dir-location', $wpseo_titles ) ) { + $title_template = $wpseo_titles['title-tax-at_biz_dir-location']; + } + + // Get Term SEO title + $meta = get_option( 'wpseo_taxonomy_meta' ); + + if ( array_key_exists( 'at_biz_dir-location', $meta ) ) { + + if ( array_key_exists( $term->term_id, $meta['at_biz_dir-location'] ) ) { + + if ( array_key_exists( 'wpseo_focuskw', $meta['at_biz_dir-location'][ $term->term_id ] ) ) { + $replacements['%%term_title%%'] = $meta['at_biz_dir-location'][ $term->term_id ]['wpseo_focuskw']; + } + + if ( array_key_exists( 'wpseo_title', $meta['at_biz_dir-location'][ $term->term_id ] ) && ! empty( $meta['at_biz_dir-location'][ $term->term_id ]['wpseo_title'] ) ) { + $title_template = $meta['at_biz_dir-location'][ $term->term_id ]['wpseo_title']; + } + } + } + } + } + + // Tag page + if ( $post->ID == $Tag_page_ID ) { + if ( $slug = get_query_var( 'atbdp_tag' ) ) { + + $term = get_term_by( 'slug', $slug, 'at_biz_dir-tags' ); + $replacements['%%term_title%%'] = $term->name; + + // Get Archive SEO title + if ( array_key_exists( 'title-tax-at_biz_dir-tags', $wpseo_titles ) ) { + $title_template = $wpseo_titles['title-tax-at_biz_dir-tags']; + } + + // Get Term SEO title + $meta = get_option( 'wpseo_taxonomy_meta' ); + + if ( array_key_exists( 'at_biz_dir-tags', $meta ) ) { + + if ( array_key_exists( $term->term_id, $meta['at_biz_dir-tags'] ) ) { + + if ( array_key_exists( 'wpseo_focuskw', $meta['at_biz_dir-tags'][ $term->term_id ] ) ) { + $replacements['%%term_title%%'] = $meta['at_biz_dir-tags'][ $term->term_id ]['wpseo_focuskw']; + } + + if ( array_key_exists( 'wpseo_title', $meta['at_biz_dir-tags'][ $term->term_id ] ) && ! empty( $meta['at_biz_dir-tags'][ $term->term_id ]['wpseo_title'] ) ) { + $title_template = $meta['at_biz_dir-tags'][ $term->term_id ]['wpseo_title']; + } + } + } + } + } + + // Return + if ( ! empty( $title_template ) ) { + $title = strtr( $title_template, $replacements ); + } + + return $title; + } + + // remove_duplicate_canonical + public function remove_duplicate_canonical() { + global $post; + + if ( empty( $post ) ) { + return; + } + + $CAT_page_ID = directorist_get_page_id( 'category' ); + $LOC_page_ID = directorist_get_page_id( 'location' ); + $Tag_page_ID = directorist_get_page_id( 'tag' ); + + $targeted_pages = array( $CAT_page_ID, $LOC_page_ID, $Tag_page_ID ); + if ( ! in_array( $post->ID, $targeted_pages ) ) { + return; + } + + remove_action( 'wp_head', 'rel_canonical' ); + } + + public function add_texonomy_canonical() { + global $post; + + if ( empty( $post ) ) { + return; + } + + $CAT_page_ID = directorist_get_page_id( 'category' ); + $LOC_page_ID = directorist_get_page_id( 'location' ); + $Tag_page_ID = directorist_get_page_id( 'tag' ); + + $targeted_pages = array( $CAT_page_ID, $LOC_page_ID, $Tag_page_ID ); + if ( ! in_array( $post->ID, $targeted_pages ) ) { + return; + } + + $url = get_permalink( $post->ID ); + + // Location page + if ( $post->ID == $LOC_page_ID ) { + if ( $slug = get_query_var( 'atbdp_location' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_LOCATION ); + $url = ATBDP_Permalink::atbdp_get_location_page( $term ); + } + } + + // Category page + if ( $post->ID == $CAT_page_ID ) { + if ( $slug = get_query_var( 'atbdp_category' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_CATEGORY ); + $url = ATBDP_Permalink::atbdp_get_category_page( $term ); + } + } + + // User listings page + if ( $post->ID == $Tag_page_ID ) { + + if ( $slug = get_query_var( 'atbdp_tag' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_TAGS ); + $url = ATBDP_Permalink::atbdp_get_tag_page( $term ); + } + } + ?> + <link rel='canonical' href='<?php echo esc_url( $url ); ?>' /> + <?php + } + + + /** + * Override the Yoast SEO canonical URL on our category, location & user_listings pages. + * + * @since 1.6.1 + * @param array $url The Yoast canonical URL. + * @return Modified canonical URL. + */ + public function directorist_canonical( $url ) { + global $post; + + if ( empty( $post ) ) { + return $url; + } + + $CAT_page_ID = directorist_get_page_id( 'category' ); + $LOC_page_ID = directorist_get_page_id( 'location' ); + $Tag_page_ID = directorist_get_page_id( 'tag' ); + + // Location page + if ( $post->ID == $LOC_page_ID ) { + + if ( $slug = get_query_var( 'atbdp_location' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_LOCATION ); + $url = ATBDP_Permalink::atbdp_get_location_page( $term ); + } + } + + // Category page + if ( $post->ID == $CAT_page_ID ) { + + if ( $slug = get_query_var( 'atbdp_category' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_CATEGORY ); + $url = ATBDP_Permalink::atbdp_get_category_page( $term ); + } + } - if (array_key_exists('at_biz_dir-category', $meta)) { - if (array_key_exists($term->term_id, $meta['at_biz_dir-category'])) { + // User listings page + if ( $post->ID == $Tag_page_ID ) { - if (array_key_exists('wpseo_focuskw', $meta['at_biz_dir-category'][$term->term_id])) { - $replacements['%%term_title%%'] = $meta['at_biz_dir-category'][$term->term_id]['wpseo_focuskw']; - } + if ( $slug = get_query_var( 'atbdp_tag' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_TAGS ); + $url = ATBDP_Permalink::atbdp_get_tag_page( $term ); + } + } - if (array_key_exists('wpseo_title', $meta['at_biz_dir-category'][$term->term_id]) && !empty($meta['at_biz_dir-category'][$term->term_id]['wpseo_title'])) { - $title_template = $meta['at_biz_dir-category'][$term->term_id]['wpseo_title']; - } - } - } - } - } + return $url; + } - // Location page - if ($post->ID == $LOC_page_ID) { - $slug = get_query_var('atbdp_location'); - if ( ! empty( $slug ) ) { - $term = get_term_by('slug', $slug, 'at_biz_dir-location'); - $replacements['%%term_title%%'] = $term->name; + public function atbdp_add_meta_keywords() { + $seo_meta = $this->get_seo_meta_data(); + /** + * Filter SEO meta description. + * + * @since 1.0.0 + * + * @param string $meta_desc Meta description content. + */ + $meta_desc = apply_filters( 'atbdp_seo_meta_description', $seo_meta['description'] ); + if ( ! empty( $meta_desc ) ) { + ?> + <meta name="description" content="<?php echo esc_attr( $meta_desc ); ?>" /> + <?php + } + } - // Get Archive SEO title - if (array_key_exists('title-tax-at_biz_dir-location', $wpseo_titles)) { - $title_template = $wpseo_titles['title-tax-at_biz_dir-location']; - } - // Get Term SEO title - $meta = get_option('wpseo_taxonomy_meta'); + /** + * Set custom page title. + * + * @since 1.0.0 + * @since 1.6.18 Option added to disable overwrite by Yoast SEO titles & metas on GD pages. + * @package atbdpectory + * @global object $wp WordPress object. + * @param string $title Old title. + * @param string $sep Title separator. + * @return string Modified title. + */ + public function atbdp_custom_page_title( $title = '', $sep = '' ) { + // global $wp; + if ( $sep == '' ) { + /** + * Filter the page title separator. + * + * @since 4.6.0 + * @package Directorist + * @param string $sep The separator, default: `|`. + */ + $sep = apply_filters( 'atbdp_page_title_separator', '|' ); + } + + $seo_meta = $this->get_seo_meta_data(); + $page = $seo_meta['page']; + if ( ! empty( $seo_meta['title'] ) && ! empty( $page ) ) { + $title = $seo_meta['title']; + } + + /** + * Filter page meta title to replace variables. + * + * @since 1.5.4 + * @param string $title The page title including variables. + * @param string $atbdp_page The atbdpectory page type if any. + * @param string $sep The title separator symbol. + */ + return apply_filters( 'atbdp_seo_meta_title', $title, $page, $sep ); + } - if (array_key_exists('at_biz_dir-location', $meta)) { - - if (array_key_exists($term->term_id, $meta['at_biz_dir-location'])) { - - if (array_key_exists('wpseo_focuskw', $meta['at_biz_dir-location'][$term->term_id])) { - $replacements['%%term_title%%'] = $meta['at_biz_dir-location'][$term->term_id]['wpseo_focuskw']; - } - - if (array_key_exists('wpseo_title', $meta['at_biz_dir-location'][$term->term_id]) && !empty($meta['at_biz_dir-location'][$term->term_id]['wpseo_title'])) { - $title_template = $meta['at_biz_dir-location'][$term->term_id]['wpseo_title']; - } - } - } - } - } - - // Tag page - if ($post->ID == $Tag_page_ID) { - if ($slug = get_query_var('atbdp_tag')) { - - $term = get_term_by('slug', $slug, 'at_biz_dir-tags'); - $replacements['%%term_title%%'] = $term->name; - - // Get Archive SEO title - if (array_key_exists('title-tax-at_biz_dir-tags', $wpseo_titles)) { - $title_template = $wpseo_titles['title-tax-at_biz_dir-tags']; - } - - // Get Term SEO title - $meta = get_option('wpseo_taxonomy_meta'); - - if (array_key_exists('at_biz_dir-tags', $meta)) { - - if (array_key_exists($term->term_id, $meta['at_biz_dir-tags'])) { - - if (array_key_exists('wpseo_focuskw', $meta['at_biz_dir-tags'][$term->term_id])) { - $replacements['%%term_title%%'] = $meta['at_biz_dir-tags'][$term->term_id]['wpseo_focuskw']; - } - - if (array_key_exists('wpseo_title', $meta['at_biz_dir-tags'][$term->term_id]) && !empty($meta['at_biz_dir-tags'][$term->term_id]['wpseo_title'])) { - $title_template = $meta['at_biz_dir-tags'][$term->term_id]['wpseo_title']; - } - } - } - } - } - - // Return - if (!empty($title_template)) { - $title = strtr($title_template, $replacements); - } - - return $title; - } - - // remove_duplicate_canonical - public function remove_duplicate_canonical() { - global $post; - - if ( empty( $post ) ) { - return; - } - - $CAT_page_ID = directorist_get_page_id( 'category' ); - $LOC_page_ID = directorist_get_page_id( 'location' ); - $Tag_page_ID = directorist_get_page_id( 'tag' ); - - $targeted_pages = [ $CAT_page_ID, $LOC_page_ID, $Tag_page_ID ]; - if ( ! in_array( $post->ID, $targeted_pages ) ) return; - - remove_action('wp_head', 'rel_canonical'); - } - - public function add_texonomy_canonical() - { - global $post; - - if ( empty( $post ) ) { - return; - } - - $CAT_page_ID = directorist_get_page_id( 'category' ); - $LOC_page_ID = directorist_get_page_id( 'location' ); - $Tag_page_ID = directorist_get_page_id( 'tag' ); - - $targeted_pages = [ $CAT_page_ID, $LOC_page_ID, $Tag_page_ID ]; - if ( ! in_array( $post->ID, $targeted_pages ) ) return; - - $url = get_permalink($post->ID); - - // Location page - if ($post->ID == $LOC_page_ID) { - if ($slug = get_query_var('atbdp_location')) { - $term = get_term_by('slug', $slug, ATBDP_LOCATION); - $url = ATBDP_Permalink::atbdp_get_location_page($term); - } - } - - // Category page - if ($post->ID == $CAT_page_ID) { - if ($slug = get_query_var('atbdp_category')) { - $term = get_term_by('slug', $slug, ATBDP_CATEGORY); - $url = ATBDP_Permalink::atbdp_get_category_page($term); - } - } - - // User listings page - if ($post->ID == $Tag_page_ID) { - - if ($slug = get_query_var('atbdp_tag')) { - $term = get_term_by('slug', $slug, ATBDP_TAGS); - $url = ATBDP_Permalink::atbdp_get_tag_page($term); - } - } - ?> - <link rel='canonical' href='<?php echo esc_url( $url ); ?>' /> - <?php - } - - - /** - * Override the Yoast SEO canonical URL on our category, location & user_listings pages. - * - * @since 1.6.1 - * @param array $url The Yoast canonical URL. - * @return Modified canonical URL. - */ - public function directorist_canonical($url) - { - global $post; - - if ( empty( $post ) ) { - return $url; - } - - $CAT_page_ID = directorist_get_page_id( 'category' ); - $LOC_page_ID = directorist_get_page_id( 'location' ); - $Tag_page_ID = directorist_get_page_id( 'tag' ); - - // Location page - if ($post->ID == $LOC_page_ID) { - - if ($slug = get_query_var('atbdp_location')) { - $term = get_term_by('slug', $slug, ATBDP_LOCATION); - $url = ATBDP_Permalink::atbdp_get_location_page($term); - } - } - - // Category page - if ($post->ID == $CAT_page_ID) { - - if ($slug = get_query_var('atbdp_category')) { - $term = get_term_by('slug', $slug, ATBDP_CATEGORY); - $url = ATBDP_Permalink::atbdp_get_category_page($term); - } - } - - // User listings page - if ($post->ID == $Tag_page_ID) { - - if ($slug = get_query_var('atbdp_tag')) { - $term = get_term_by('slug', $slug, ATBDP_TAGS); - $url = ATBDP_Permalink::atbdp_get_tag_page($term); - } - } - - return $url; - } - - public function atbdp_add_meta_keywords() - { - $seo_meta = $this->get_seo_meta_data(); - /** - * Filter SEO meta description. - * - * @since 1.0.0 - * - * @param string $meta_desc Meta description content. - */ - $meta_desc = apply_filters( 'atbdp_seo_meta_description', $seo_meta['description'] ); - if ( ! empty( $meta_desc ) ) { ?> - <meta name="description" content="<?php echo esc_attr( $meta_desc ); ?>" /> - <?php - } - } - - - /** - * Set custom page title. - * - * @since 1.0.0 - * @since 1.6.18 Option added to disable overwrite by Yoast SEO titles & metas on GD pages. - * @package atbdpectory - * @global object $wp WordPress object. - * @param string $title Old title. - * @param string $sep Title separator. - * @return string Modified title. - */ - public function atbdp_custom_page_title($title = '', $sep = '') - { - // global $wp; - if ($sep == '') { - /** - * Filter the page title separator. - * - * @since 4.6.0 - * @package Directorist - * @param string $sep The separator, default: `|`. - */ - $sep = apply_filters('atbdp_page_title_separator', '|'); - } - - $seo_meta = $this->get_seo_meta_data(); - $page = $seo_meta['page']; - if ( ! empty( $seo_meta['title'] ) && ! empty( $page ) ) { - $title = $seo_meta['title']; - } - - /** - * Filter page meta title to replace variables. - * - * @since 1.5.4 - * @param string $title The page title including variables. - * @param string $atbdp_page The atbdpectory page type if any. - * @param string $sep The title separator symbol. - */ - return apply_filters( 'atbdp_seo_meta_title', $title, $page, $sep ); - } - - // add_opengraph_meta - public function add_opengraph_meta() { + // add_opengraph_meta + public function add_opengraph_meta() { // Get current directorist page key $current_directorist_page = self::get_directorist_current_page(); @@ -673,578 +675,644 @@ public function add_opengraph_meta() { return; } - $seo_meta_data = $this->get_seo_meta_data(); - - $og_metas = [ - 'site_name' => [ - 'property' => 'og:site_name', - 'content' => '', - ], - 'title' => [ - 'property' => 'og:title', - 'content' => '', - ], - 'description' => [ - 'property' => 'og:description', - 'content' => '', - ], - 'url' => [ - 'property' => 'og:url', - 'content' => '', - ], - 'image' => [ - 'property' => 'og:image', - 'content' => '', - ], - 'twitter_card' => [ - 'name' => 'twitter:card', - 'content' => 'summary_large_image', - ], - 'twitter_title' => [ - 'property' => 'twitter:title', - 'content' => '', - ], - 'twitter_description' => [ - 'property' => 'twitter:description', - 'content' => '', - ], - 'twitter_image' => [ - 'property' => 'twitter:image', - 'content' => '', - ] - ]; - - // Sync the data - foreach ( $seo_meta_data as $meta_key => $meta_value ) { - if ( ! empty( $og_metas[ $meta_key ] ) ) { - $og_metas[ $meta_key ]['content'] = $seo_meta_data[ $meta_key ]; - } - } - - // Adjust the title - if ( ! empty( $seo_meta_data['site_name'] ) && ! empty( $og_metas['title'] ) ) { - $site_name = $seo_meta_data['site_name']; - $title = $og_metas['title']['content']; - - $title_has_site_name = preg_match( '/'. $site_name .'/', $title ) ; - $og_metas['title']['content'] = ( $title_has_site_name ) ? $title : $title . ' | ' . $site_name; - } - - $og_metas = apply_filters( 'atbdp_og_metas', $og_metas ); - - if ( empty( $og_metas ) || ! is_array( $og_metas ) ) { - return; - } - - // Adjust Twitter Meta - if ( empty( $og_metas['twitter_title']['content'] ) ) { - $og_metas['twitter_title']['content'] = $og_metas['title']['content']; - } - - if ( empty( $og_metas['twitter_description']['content'] ) ) { - $og_metas['twitter_description']['content'] = $og_metas['description']['content']; - } - - if ( empty( $og_metas['twitter_image']['content'] ) ) { - $og_metas['twitter_image']['content'] = $og_metas['image']['content']; - } - - foreach ( $og_metas as $meta_key => $meta_attributes ) { - $props = ''; - foreach ( $meta_attributes as $attr => $value ) { - if ( ! empty( $meta_attributes['content'] ) ) { - $value = esc_attr( $value ); + $seo_meta_data = $this->get_seo_meta_data(); + + $og_metas = array( + 'site_name' => array( + 'property' => 'og:site_name', + 'content' => '', + ), + 'title' => array( + 'property' => 'og:title', + 'content' => '', + ), + 'description' => array( + 'property' => 'og:description', + 'content' => '', + ), + 'url' => array( + 'property' => 'og:url', + 'content' => '', + ), + 'image' => array( + 'property' => 'og:image', + 'content' => '', + ), + 'twitter_card' => array( + 'name' => 'twitter:card', + 'content' => 'summary_large_image', + ), + 'twitter_title' => array( + 'property' => 'twitter:title', + 'content' => '', + ), + 'twitter_description' => array( + 'property' => 'twitter:description', + 'content' => '', + ), + 'twitter_image' => array( + 'property' => 'twitter:image', + 'content' => '', + ), + ); + + // Sync the data + foreach ( $seo_meta_data as $meta_key => $meta_value ) { + if ( ! empty( $og_metas[ $meta_key ] ) ) { + $og_metas[ $meta_key ]['content'] = $seo_meta_data[ $meta_key ]; + } + } + + // Adjust the title + if ( ! empty( $seo_meta_data['site_name'] ) && ! empty( $og_metas['title'] ) ) { + $site_name = $seo_meta_data['site_name']; + $title = $og_metas['title']['content']; + + $title_has_site_name = preg_match( '/' . $site_name . '/', $title ); + $og_metas['title']['content'] = ( $title_has_site_name ) ? $title : $title . ' | ' . $site_name; + } + + $og_metas = apply_filters( 'atbdp_og_metas', $og_metas ); + + if ( empty( $og_metas ) || ! is_array( $og_metas ) ) { + return; + } + + // Adjust Twitter Meta + if ( empty( $og_metas['twitter_title']['content'] ) ) { + $og_metas['twitter_title']['content'] = $og_metas['title']['content']; + } + + if ( empty( $og_metas['twitter_description']['content'] ) ) { + $og_metas['twitter_description']['content'] = $og_metas['description']['content']; + } + + if ( empty( $og_metas['twitter_image']['content'] ) ) { + $og_metas['twitter_image']['content'] = $og_metas['image']['content']; + } + + foreach ( $og_metas as $meta_key => $meta_attributes ) { + $props = ''; + foreach ( $meta_attributes as $attr => $value ) { + if ( ! empty( $meta_attributes['content'] ) ) { + $value = esc_attr( $value ); $props .= "{$attr}=\"{$value}\" "; - } - } - - $props = rtrim( $props ); - if ( ! empty( $props ) ) { ?> - <meta <?php echo esc_attr( $props ); ?> /> - <?php } - } - } - - // get_seo_meta_data - public function get_seo_meta_data() { - global $wp; - - $desc = ! is_search() ? esc_html( get_the_excerpt() ) : ''; - $meta_desc = ( strlen( $desc ) > 200 ) ? substr( $desc, 0, 200 ) . "..." : $desc; - - $default_seo_meta = [ - 'site_name' => get_bloginfo('name'), - 'title' => get_the_title(), - 'description' => $meta_desc, - 'page' => '', - 'current_page' => home_url( add_query_arg( array(), $wp->request ) ) . '/', - 'image' => '', - ]; - - $current_page = self::get_directorist_current_page(); - $callback = "get_{$current_page}_page_seo_meta"; - $seo_meta = $default_seo_meta; - - if ( method_exists( $this, $callback ) ) { - $seo_meta = call_user_func_array( [ $this, $callback ], [ $seo_meta ] ); - } - - $title = $seo_meta['title'] . ' | ' . get_bloginfo( 'name' ); - $seo_meta['title'] = apply_filters( 'directorist_seo_meta_title', $title, $seo_meta['title'] ); - - if ( ! empty( $seo_meta['description'] ) ) { - $seo_meta['description'] = stripslashes_deep( $seo_meta['description'] ); - /** - * Filter page description to replace variables. - * - * @since 1.5.4 - * - * @param string $meta_desc The page description including variables. - * @param string $gd_page The atbdpectory page type if any. - */ - $seo_meta['description'] = apply_filters( 'atbdp_seo_meta_description_pre', $seo_meta['description'], $seo_meta['page'] ); - } - - return $seo_meta; - } - - // get_home_page_seo_meta - public function get_home_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'home'; - - // Title - $settings_title = get_directorist_option('homepage_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; + } + } - // Description - $settings_description = get_directorist_option('homepage_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; - - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - - return $seo_meta; - } + $props = rtrim( $props ); + if ( ! empty( $props ) ) { + ?> + <meta <?php echo esc_attr( $props ); ?> /> + <?php + } + } + } - // get_search_result_page_seo_meta - public function get_search_result_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'search-result'; - - // Title - $settings_title = get_directorist_option('search_result_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; + // get_seo_meta_data + public function get_seo_meta_data() { + global $wp; - $query = ( isset( $_GET['q'] ) && ( '' !== $_GET['q'] ) ) ? ucfirst( directorist_clean( wp_unslash( $_GET['q'] ) ) ) : ''; - $category = ( isset( $_GET['in_cat'] ) && ( '' !== $_GET['in_cat'] ) ) ? ucfirst( directorist_clean( wp_unslash( $_GET['in_cat'] ) ) ) : ''; - $location = ( isset( $_GET['in_loc'] ) && ( '' !== $_GET['in_loc'] ) ) ? ucfirst( directorist_clean( wp_unslash( $_GET['in_loc'] ) ) ) : ''; - - $category = get_term_by( 'id', $category, ATBDP_CATEGORY ); - $location = get_term_by( 'id', $location, ATBDP_LOCATION ); + $desc = ! is_search() ? esc_html( get_the_excerpt() ) : ''; + $meta_desc = ( strlen( $desc ) > 200 ) ? substr( $desc, 0, 200 ) . '...' : $desc; - $in_s_string_text = ! empty( $query ) ? $query : ''; - $in_cat_text = ! empty( $category ) ? ( ! empty( $query ) ? __( 'from', 'directorist ') : '' ) . $category->name : ''; - $in_loc_text = ! empty( $location ) ? ( ! empty( $query ) ? __( 'from', 'directorist ') : '' ) . $location->name : ''; + $default_seo_meta = array( + 'site_name' => get_bloginfo( 'name' ), + 'title' => get_the_title(), + 'description' => $meta_desc, + 'page' => '', + 'current_page' => home_url( add_query_arg( array(), $wp->request ) ) . '/', + 'image' => '', + ); - $how_to = get_directorist_option('meta_title_for_search_result', 'searched_value'); + $current_page = self::get_directorist_current_page(); + $callback = "get_{$current_page}_page_seo_meta"; + $seo_meta = $default_seo_meta; - if ( 'searched_value' === $how_to ) { - if ( ! empty( $query ) || ! empty( $category ) || ! empty( $location ) ) { - $seo_meta['title'] = $in_s_string_text . $in_cat_text . $in_loc_text; - } - } + if ( method_exists( $this, $callback ) ) { + $seo_meta = call_user_func_array( array( $this, $callback ), array( $seo_meta ) ); + } - // Description - $settings_description = get_directorist_option('search_result_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + $title = $seo_meta['title'] . ' | ' . get_bloginfo( 'name' ); + $seo_meta['title'] = apply_filters( 'directorist_seo_meta_title', $title, $seo_meta['title'] ); + + if ( ! empty( $seo_meta['description'] ) ) { + $seo_meta['description'] = stripslashes_deep( $seo_meta['description'] ); + /** + * Filter page description to replace variables. + * + * @since 1.5.4 + * + * @param string $meta_desc The page description including variables. + * @param string $gd_page The atbdpectory page type if any. + */ + $seo_meta['description'] = apply_filters( 'atbdp_seo_meta_description_pre', $seo_meta['description'], $seo_meta['page'] ); + } - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + return $seo_meta; + } - return $seo_meta; - } + // get_home_page_seo_meta + public function get_home_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'home'; - // get_add_listing_page_seo_meta - public function get_add_listing_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'add-listing'; + // Title + $settings_title = get_directorist_option( 'homepage_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } - // Title - $settings_title = get_directorist_option('add_listing_page_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; + // Description + $settings_description = get_directorist_option( 'homepage_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - // Description - $settings_description = get_directorist_option('all_listing_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + return $seo_meta; + } - return $seo_meta; - } + // get_search_result_page_seo_meta + public function get_search_result_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'search-result'; - // get_all_listing_page_seo_meta - public function get_all_listing_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'all-listing'; + // Title + $settings_title = get_directorist_option( 'search_result_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } - // Title - $settings_title = get_directorist_option('all_listing_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; + $query = ( isset( $_GET['q'] ) && ( '' !== $_GET['q'] ) ) ? ucfirst( directorist_clean( wp_unslash( $_GET['q'] ) ) ) : ''; + $category = ( isset( $_GET['in_cat'] ) && ( '' !== $_GET['in_cat'] ) ) ? ucfirst( directorist_clean( wp_unslash( $_GET['in_cat'] ) ) ) : ''; + $location = ( isset( $_GET['in_loc'] ) && ( '' !== $_GET['in_loc'] ) ) ? ucfirst( directorist_clean( wp_unslash( $_GET['in_loc'] ) ) ) : ''; - // Description - $settings_description = get_directorist_option('all_listing_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + $category = get_term_by( 'id', $category, ATBDP_CATEGORY ); + $location = get_term_by( 'id', $location, ATBDP_LOCATION ); - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + $in_s_string_text = ! empty( $query ) ? $query : ''; + $in_cat_text = ! empty( $category ) ? ( ! empty( $query ) ? __( 'from', 'directorist ' ) : '' ) . $category->name : ''; + $in_loc_text = ! empty( $location ) ? ( ! empty( $query ) ? __( 'from', 'directorist ' ) : '' ) . $location->name : ''; - return $seo_meta; - } + $how_to = get_directorist_option( 'meta_title_for_search_result', 'searched_value' ); - // get_dashboard_page_seo_meta - public function get_dashboard_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'dashboard'; + if ( 'searched_value' === $how_to ) { + if ( ! empty( $query ) || ! empty( $category ) || ! empty( $location ) ) { + $seo_meta['title'] = $in_s_string_text . $in_cat_text . $in_loc_text; + } + } - // Title - $settings_title = get_directorist_option('dashboard_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; + // Description + $settings_description = get_directorist_option( 'search_result_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - // Description - $settings_description = get_directorist_option('dashboard_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + return $seo_meta; + } - return $seo_meta; - } + // get_add_listing_page_seo_meta + public function get_add_listing_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'add-listing'; - // get_author_page_seo_meta - public function get_author_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'author'; + // Title + $settings_title = get_directorist_option( 'add_listing_page_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } - // Title - $settings_title = get_directorist_option('author_profile_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; + // Description + $settings_description = get_directorist_option( 'all_listing_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - // Description - $settings_description = get_directorist_option('author_page_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + return $seo_meta; + } - return $seo_meta; - } + // get_all_listing_page_seo_meta + public function get_all_listing_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'all-listing'; - // get_category_page_seo_meta - public function get_category_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'category'; + // Title + $settings_title = get_directorist_option( 'all_listing_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } - // Title - $settings_title = get_directorist_option('category_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; + // Description + $settings_description = get_directorist_option( 'all_listing_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - // Description - $settings_description = get_directorist_option('category_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + return $seo_meta; + } - return $seo_meta; - } + // get_dashboard_page_seo_meta + public function get_dashboard_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'dashboard'; - // get_all_locations_page_seo_meta - public function get_all_locations_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'all_locations'; + // Title + $settings_title = get_directorist_option( 'dashboard_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } - // Title - $settings_title = get_directorist_option('all_locations_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; + // Description + $settings_description = get_directorist_option( 'dashboard_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - // Description - $settings_description = get_directorist_option('all_locations_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + return $seo_meta; + } - return $seo_meta; - } + // get_author_page_seo_meta + public function get_author_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'author'; - // get_single_listing_page_seo_meta - public function get_single_listing_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'all_locations'; + // Title + $settings_title = get_directorist_option( 'author_profile_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } - $desc = esc_html( get_the_excerpt() ); - $meta_desc = ( strlen( $desc ) > 200 ) ? substr( $desc, 0, 200 ) . "..." : $desc; + // Description + $settings_description = get_directorist_option( 'author_page_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - $seo_meta['title'] = get_the_title(); - $seo_meta['description'] = $meta_desc; - $seo_meta['image'] = get_the_post_thumbnail_url(); + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - if ( empty( $seo_meta['image'] ) ) { - $listing_img_id = directorist_get_listing_preview_image( get_the_ID() ); + return $seo_meta; + } - if ( ! $listing_img_id ) { - $listing_img_id = directorist_get_listing_gallery_images( get_the_ID() ); - $listing_img_id = $listing_img_id[0] ?? null; - } + // get_category_page_seo_meta + public function get_category_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'category'; - $seo_meta['image'] = $listing_img_id ? wp_get_attachment_image_url( $listing_img_id, 'post-thumbnail' ) : ''; - } + // Title + $settings_title = get_directorist_option( 'category_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + // Description + $settings_description = get_directorist_option( 'category_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - return $seo_meta; - } + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - // get_single_category_page_seo_meta - public function get_single_category_page_seo_meta( $default_seo_meta = [] ) { - global $post; + return $seo_meta; + } - if ( empty( $post ) ) { - return $default_seo_meta; - } + // get_all_locations_page_seo_meta + public function get_all_locations_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'all_locations'; - $seo_meta = []; - $seo_meta['page'] = 'single_category'; + // Title + $settings_title = get_directorist_option( 'all_locations_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } - $slug = get_query_var('atbdp_category'); - $term = get_term_by('slug', $slug, ATBDP_CATEGORY); + // Description + $settings_description = get_directorist_option( 'all_locations_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - // Title - $settings_title = get_directorist_option('single_category_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; - if ( ! empty( $term ) ) $seo_meta['title'] = $term->name; + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - // Description - $settings_description = get_directorist_option('single_category_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + return $seo_meta; + } - // URL - $url = get_term_link( $slug, ATBDP_CATEGORY ); - $url = ( is_string( $url ) ) ? $url : ''; + // get_single_listing_page_seo_meta + public function get_single_listing_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'all_locations'; - if ( ! empty( $url ) ) { - $seo_meta['url'] = $url; - } + $desc = esc_html( get_the_excerpt() ); + $meta_desc = ( strlen( $desc ) > 200 ) ? substr( $desc, 0, 200 ) . '...' : $desc; - $CAT_page_ID = directorist_get_page_id( 'category' ); + $seo_meta['title'] = get_the_title(); + $seo_meta['description'] = $meta_desc; + $seo_meta['image'] = get_the_post_thumbnail_url(); - // show term description as meta description first - if ( $post->ID == $CAT_page_ID && $slug && ! empty( $term ) ) { - if ( ! empty( $term->description ) ) $seo_meta['description'] = $term->description; - $thumb_id = get_term_meta( $term->term_id, 'image', true ); - $seo_meta['image'] = wp_get_attachment_url( $thumb_id ); - } + if ( empty( $seo_meta['image'] ) ) { + $listing_img_id = directorist_get_listing_preview_image( get_the_ID() ); - // If Yoast is active - if ( atbdp_yoast_is_active() ) { - $seo_meta = $this->sync_with_yoast_seo_meta([ - 'url' => $url, - 'seo_meta' => $seo_meta, - ]); - } + if ( ! $listing_img_id ) { + $listing_img_id = directorist_get_listing_gallery_images( get_the_ID() ); + $listing_img_id = $listing_img_id[0] ?? null; + } - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + $seo_meta['image'] = $listing_img_id ? wp_get_attachment_image_url( $listing_img_id, 'post-thumbnail' ) : ''; + } - return $seo_meta; - } + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - // get_single_location_page_seo_meta - public function get_single_location_page_seo_meta( $default_seo_meta = [] ) { - global $post; + return $seo_meta; + } - if ( empty( $post ) ) { - return $default_seo_meta; - } + // get_single_category_page_seo_meta + public function get_single_category_page_seo_meta( $default_seo_meta = array() ) { + global $post; - $seo_meta = []; - $seo_meta['page'] = 'single_location'; + if ( empty( $post ) ) { + return $default_seo_meta; + } - $slug = get_query_var('atbdp_location'); - $term = get_term_by('slug', $slug, ATBDP_LOCATION); + $seo_meta = array(); + $seo_meta['page'] = 'single_category'; - // Title - $settings_title = get_directorist_option('single_locations_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; - if ( ! empty( $term ) ) $seo_meta['title'] = $term->name; + $slug = get_query_var( 'atbdp_category' ); + $term = get_term_by( 'slug', $slug, ATBDP_CATEGORY ); - // Description - $settings_description = get_directorist_option('single_locations_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; + // Title + $settings_title = get_directorist_option( 'single_category_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } + if ( ! empty( $term ) ) { + $seo_meta['title'] = $term->name; + } - $LOC_page_ID = directorist_get_page_id( 'location' ); + // Description + $settings_description = get_directorist_option( 'single_category_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } - // show term description as meta description first - if ( $post->ID == $LOC_page_ID && $slug && ! empty( $term ) ) { - if ( ! empty( $term->description ) ) $seo_meta['description'] = $term->description; - $thumb_id = get_term_meta( $term->term_id, 'image', true ); - $seo_meta['image'] = wp_get_attachment_url( $thumb_id ); - } + // URL + $url = get_term_link( $slug, ATBDP_CATEGORY ); + $url = ( is_string( $url ) ) ? $url : ''; - // If Yoast math is active - if ( atbdp_yoast_is_active() ) { - $url = get_term_link( $slug, ATBDP_LOCATION ); - $url = ( is_string( $url ) ) ? $url : ''; - - $seo_meta = $this->sync_with_yoast_seo_meta([ - 'url' => $url, - 'seo_meta' => $seo_meta, - ]); - } - - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - - return $seo_meta; - } - - // get_single_tag_page_seo_meta - public function get_single_tag_page_seo_meta( $default_seo_meta = [] ) { - global $post; - - if ( empty( $post ) ) { - return $default_seo_meta; - } - - $seo_meta = []; - $seo_meta['page'] = 'single_tag'; - - $slug = get_query_var('atbdp_tag'); - $term = get_term_by('slug', $slug, ATBDP_TAGS); - $seo_meta['title'] = !empty($term) ? $term->name : ''; - - $TAG_page_ID = directorist_get_page_id( 'tag' ); - - // show term description as meta description first - if ( $post->ID == $TAG_page_ID && $slug && ! empty( $term ) ) { - if ( ! empty( $term->description ) ) $seo_meta['description'] = $term->description; - $thumb_id = get_term_meta( $term->term_id, 'image', true ); - $seo_meta['image'] = wp_get_attachment_url( $thumb_id ); - } - - if ( atbdp_yoast_is_active() ) { - $url = get_term_link( $slug, ATBDP_TAGS ); - $url = ( is_string( $url ) ) ? $url : ''; - - $seo_meta = $this->sync_with_yoast_seo_meta([ - 'url' => $url, - 'seo_meta' => $seo_meta, - ]); - } - - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - - return $seo_meta; - } - - // get_registration_page_seo_meta - public function get_registration_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'all_locations'; - - // Title - $settings_title = get_directorist_option('registration_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; - - // Description - $settings_description = get_directorist_option('registration_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; - - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - - return $seo_meta; - } - - // get_login_page_seo_meta - public function get_login_page_seo_meta( $default_seo_meta = [] ) { - $seo_meta = []; - $seo_meta['page'] = 'login'; - - // Title - $settings_title = get_directorist_option('login_meta_title'); - if ( ! empty( $settings_title ) ) $seo_meta['title'] = $settings_title; - - // Description - $settings_description = get_directorist_option('login_meta_desc'); - if ( ! empty( $settings_description ) ) $seo_meta['description'] = $settings_description; - - $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; - - return $seo_meta; - } - - public static function get_directorist_current_page() { - $all_directorist_pages = [ - 'home', - 'search_result', - 'add_listing', - 'all_listing', - 'dashboard', - 'author', - 'category', - 'single_category', - 'all_locations', - 'single_listing', - 'single_location', - 'single_tag', - 'login', - 'registration', - ]; - - foreach( $all_directorist_pages as $page_name ) { + if ( ! empty( $url ) ) { + $seo_meta['url'] = $url; + } + + $CAT_page_ID = directorist_get_page_id( 'category' ); + + // show term description as meta description first + if ( $post->ID == $CAT_page_ID && $slug && ! empty( $term ) ) { + if ( ! empty( $term->description ) ) { + $seo_meta['description'] = $term->description; + } + $thumb_id = get_term_meta( $term->term_id, 'image', true ); + $seo_meta['image'] = wp_get_attachment_url( $thumb_id ); + } + + // If Yoast is active + if ( atbdp_yoast_is_active() ) { + $seo_meta = $this->sync_with_yoast_seo_meta( + array( + 'url' => $url, + 'seo_meta' => $seo_meta, + ) + ); + } + + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + + return $seo_meta; + } + + // get_single_location_page_seo_meta + public function get_single_location_page_seo_meta( $default_seo_meta = array() ) { + global $post; + + if ( empty( $post ) ) { + return $default_seo_meta; + } + + $seo_meta = array(); + $seo_meta['page'] = 'single_location'; + + $slug = get_query_var( 'atbdp_location' ); + $term = get_term_by( 'slug', $slug, ATBDP_LOCATION ); + + // Title + $settings_title = get_directorist_option( 'single_locations_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } + if ( ! empty( $term ) ) { + $seo_meta['title'] = $term->name; + } + + // Description + $settings_description = get_directorist_option( 'single_locations_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } + + $LOC_page_ID = directorist_get_page_id( 'location' ); + + // show term description as meta description first + if ( $post->ID == $LOC_page_ID && $slug && ! empty( $term ) ) { + if ( ! empty( $term->description ) ) { + $seo_meta['description'] = $term->description; + } + $thumb_id = get_term_meta( $term->term_id, 'image', true ); + $seo_meta['image'] = wp_get_attachment_url( $thumb_id ); + } + + // If Yoast math is active + if ( atbdp_yoast_is_active() ) { + $url = get_term_link( $slug, ATBDP_LOCATION ); + $url = ( is_string( $url ) ) ? $url : ''; + + $seo_meta = $this->sync_with_yoast_seo_meta( + array( + 'url' => $url, + 'seo_meta' => $seo_meta, + ) + ); + } + + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + + return $seo_meta; + } + + // get_single_tag_page_seo_meta + public function get_single_tag_page_seo_meta( $default_seo_meta = array() ) { + global $post; + + if ( empty( $post ) ) { + return $default_seo_meta; + } + + $seo_meta = array(); + $seo_meta['page'] = 'single_tag'; + + $slug = get_query_var( 'atbdp_tag' ); + $term = get_term_by( 'slug', $slug, ATBDP_TAGS ); + $seo_meta['title'] = ! empty( $term ) ? $term->name : ''; + + $TAG_page_ID = directorist_get_page_id( 'tag' ); + + // show term description as meta description first + if ( $post->ID == $TAG_page_ID && $slug && ! empty( $term ) ) { + if ( ! empty( $term->description ) ) { + $seo_meta['description'] = $term->description; + } + $thumb_id = get_term_meta( $term->term_id, 'image', true ); + $seo_meta['image'] = wp_get_attachment_url( $thumb_id ); + } + + if ( atbdp_yoast_is_active() ) { + $url = get_term_link( $slug, ATBDP_TAGS ); + $url = ( is_string( $url ) ) ? $url : ''; + + $seo_meta = $this->sync_with_yoast_seo_meta( + array( + 'url' => $url, + 'seo_meta' => $seo_meta, + ) + ); + } + + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + + return $seo_meta; + } + + // get_registration_page_seo_meta + public function get_registration_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'all_locations'; + + // Title + $settings_title = get_directorist_option( 'registration_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } + + // Description + $settings_description = get_directorist_option( 'registration_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } + + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + + return $seo_meta; + } + + // get_login_page_seo_meta + public function get_login_page_seo_meta( $default_seo_meta = array() ) { + $seo_meta = array(); + $seo_meta['page'] = 'login'; + + // Title + $settings_title = get_directorist_option( 'login_meta_title' ); + if ( ! empty( $settings_title ) ) { + $seo_meta['title'] = $settings_title; + } + + // Description + $settings_description = get_directorist_option( 'login_meta_desc' ); + if ( ! empty( $settings_description ) ) { + $seo_meta['description'] = $settings_description; + } + + $seo_meta = ( is_array( $default_seo_meta ) ) ? array_merge( $default_seo_meta, $seo_meta ) : $seo_meta; + + return $seo_meta; + } + + public static function get_directorist_current_page() { + $all_directorist_pages = array( + 'home', + 'search_result', + 'add_listing', + 'all_listing', + 'dashboard', + 'author', + 'category', + 'single_category', + 'all_locations', + 'single_listing', + 'single_location', + 'single_tag', + 'login', + 'registration', + ); + + foreach ( $all_directorist_pages as $page_name ) { if ( atbdp_is_page( $page_name ) ) { return $page_name; } - } + } return ''; - } - - // sync_with_yoast_seo_meta - public function sync_with_yoast_seo_meta( array $args = [] ) { - $default = [ - 'url' => '', 'seo_meta' => [], - ]; - - $args = array_merge( $default, $args ); - $url = $args['url']; - $seo_meta = $args['seo_meta']; - - if ( function_exists( 'YoastSEO' ) && is_string( $url ) ) { - try { - $yoast_meta = YoastSEO()->meta->for_url( $url ); - } catch ( Exception $e ) { - $yoast_meta = null; - } - } - - if ( empty( $yoast_meta ) ) { - return $seo_meta; - } - - // Image - $og_images = $yoast_meta->open_graph_images; - $og_image = ( ! empty( $og_images ) && is_array( $og_images ) ) ? reset( $og_images )['url'] : ''; - - $yoast_seo_meta = [ - 'title' => $yoast_meta->open_graph_title, - 'description' => $yoast_meta->open_graph_description, - 'image' => $og_image, - 'twitter_title' => $yoast_meta->twitter_title, - 'twitter_description' => $yoast_meta->twitter_description, - 'twitter_image' => $yoast_meta->twitter_image, - ]; - - foreach ( $yoast_seo_meta as $yoast_meta_key => $yoast_meta_value ) { - if ( ! empty( $yoast_meta_value ) ) { - $seo_meta[ $yoast_meta_key ] = $yoast_meta_value; - } - } - - return $seo_meta; - } - - } // ends class + } + + // sync_with_yoast_seo_meta + public function sync_with_yoast_seo_meta( array $args = array() ) { + $default = array( + 'url' => '', + 'seo_meta' => array(), + ); + + $args = array_merge( $default, $args ); + $url = $args['url']; + $seo_meta = $args['seo_meta']; + + if ( function_exists( 'YoastSEO' ) && is_string( $url ) ) { + try { + $yoast_meta = YoastSEO()->meta->for_url( $url ); + } catch ( Exception $e ) { + $yoast_meta = null; + } + } + + if ( empty( $yoast_meta ) ) { + return $seo_meta; + } + + // Image + $og_images = $yoast_meta->open_graph_images; + $og_image = ( ! empty( $og_images ) && is_array( $og_images ) ) ? reset( $og_images )['url'] : ''; + + $yoast_seo_meta = array( + 'title' => $yoast_meta->open_graph_title, + 'description' => $yoast_meta->open_graph_description, + 'image' => $og_image, + 'twitter_title' => $yoast_meta->twitter_title, + 'twitter_description' => $yoast_meta->twitter_description, + 'twitter_image' => $yoast_meta->twitter_image, + ); + + foreach ( $yoast_seo_meta as $yoast_meta_key => $yoast_meta_value ) { + if ( ! empty( $yoast_meta_value ) ) { + $seo_meta[ $yoast_meta_key ] = $yoast_meta_value; + } + } + + return $seo_meta; + } + } // ends class endif; \ No newline at end of file diff --git a/includes/classes/class-settings-panel.php b/includes/classes/class-settings-panel.php index c0cd3f82a0..69ee878f16 100644 --- a/includes/classes/class-settings-panel.php +++ b/includes/classes/class-settings-panel.php @@ -2,33 +2,32 @@ use Directorist\Asset_Loader\Enqueue; -if ( ! class_exists('ATBDP_Settings_Panel') ) { - class ATBDP_Settings_Panel - { +if ( ! class_exists( 'ATBDP_Settings_Panel' ) ) { + class ATBDP_Settings_Panel { + private $extension_url = ''; - public $fields = []; - public $layouts = []; - public $config = []; - public $default_form = []; - public $old_custom_fields = []; - public $cetagory_options = []; + public $fields = array(); + public $layouts = array(); + public $config = array(); + public $default_form = array(); + public $old_custom_fields = array(); + public $cetagory_options = array(); // run - public function run() - { - add_action('directorist_installed', [ $this, 'update_init_options' ] ); - add_action('directorist_updated', [ $this, 'update_init_options' ] ); + public function run() { + add_action( 'directorist_installed', array( $this, 'update_init_options' ) ); + add_action( 'directorist_updated', array( $this, 'update_init_options' ) ); - if ( ! is_admin() ) { - return; - } + if ( ! is_admin() ) { + return; + } - add_action( 'admin_menu', [$this, 'add_menu_pages'] ); - add_action( 'wp_ajax_save_settings_data', [ $this, 'handle_save_settings_data_request' ] ); - add_action( 'wp_ajax_save_settings_data', [ $this, 'handle_save_settings_data_request' ] ); - add_filter( 'atbdp_listing_type_settings_field_list', [ $this, 'register_setting_fields' ] ); + add_action( 'admin_menu', array( $this, 'add_menu_pages' ) ); + add_action( 'wp_ajax_save_settings_data', array( $this, 'handle_save_settings_data_request' ) ); + add_action( 'wp_ajax_save_settings_data', array( $this, 'handle_save_settings_data_request' ) ); + add_filter( 'atbdp_listing_type_settings_field_list', array( $this, 'register_setting_fields' ) ); - $this->extension_url = sprintf("<a target='_blank' href='%s'>%s</a>", esc_url(admin_url('edit.php?post_type=at_biz_dir&page=atbdp-extension')), __('Checkout Awesome Extensions', 'directorist')); + $this->extension_url = sprintf( "<a target='_blank' href='%s'>%s</a>", esc_url( admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-extension' ) ), __( 'Checkout Awesome Extensions', 'directorist' ) ); } public function update_init_options() { @@ -37,134 +36,138 @@ public function update_init_options() { update_directorist_option( 'lazy_load_taxonomy_fields', $enable_lazy_loading ); } - public static function in_settings_page() { - if ( ! is_admin() ) { - return false; - } - - if ( ! isset( $_REQUEST['post_type'] ) && ! isset( $_REQUEST['page'] ) ) { - return false; - } - - if ( 'at_biz_dir' !== $_REQUEST['post_type'] && 'atbdp-settings' !== $_REQUEST['page'] ) { - return false; - } - - return true; - } - - // register_setting_fields - public function register_setting_fields( $fields = [] ) { - $fields['script_debugging'] = [ - 'type' => 'toggle', - 'label' => 'Script debugging', - 'description' => __( 'Loads unminified .css, .js files', 'directorist' ), - ]; - - $fields['import_settings'] = [ - 'type' => 'import', - 'label' => 'Import', - 'button-label' => 'Upload Settings File', - ]; - - $fields['export_settings'] = [ - 'type' => 'export', - 'label' => 'Export', - 'button-label' => 'Download Settings File', - 'export-file-name' => 'directory-settings', - ]; - - $fields['single_listing_slug_with_directory_type'] = [ - 'type' => 'toggle', - 'label' => __('Add Directory Type to Permalink', 'directorist'), - 'value' => directorist_is_multi_directory_enabled(), - 'show-if' => [ - 'where' => "enable_multi_directory", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]; - - $fields['restore_default_settings'] = [ - 'type' => 'restore', - 'label' => 'Restore Default Settings', - 'button-label' => 'Restore', - 'restor-data' => $this->get_simple_data_content( [ 'path' => 'directory/directory-settings.json' ] ), - ]; - - $fields['enable_multi_directory'] = [ - 'type' => 'toggle', - 'label' => 'Enable Multi Directory', - 'value' => false, - 'confirm-before-change' => true, - 'confirmation-modal' => [ - 'show-model-header' => false - ], - 'data-on-change' => [ - 'action' => 'updateData', - 'args' => [ 'reload_after_save' => true ] - ], - 'componets' => [ - 'link' => [ - 'label' => __( 'Start Building Directory', 'directorist' ), - 'type' => 'success', - 'url' => admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types' ), - 'show' => directorist_is_multi_directory_enabled(), - ] - ] - ]; - - $fields['regenerate_pages'] = [ - 'type' => 'ajax-action', - 'action' => 'atbdp_upgrade_old_pages', - 'label' => 'Upgrade/Regenerate Pages', - 'button-label' => 'Regenerate Pages', - 'button-label-on-processing' => '<i class="fas fa-circle-notch fa-spin"></i> Processing', - 'data' => [], - ]; - - $users = get_users( + public static function in_settings_page() { + if ( ! is_admin() ) { + return false; + } + + if ( ! isset( $_REQUEST['post_type'] ) && ! isset( $_REQUEST['page'] ) ) { + return false; + } + + if ( 'at_biz_dir' !== $_REQUEST['post_type'] && 'atbdp-settings' !== $_REQUEST['page'] ) { + return false; + } + + return true; + } + + // register_setting_fields + public function register_setting_fields( $fields = array() ) { + $fields['script_debugging'] = array( + 'type' => 'toggle', + 'label' => 'Script debugging', + 'description' => __( 'Loads unminified .css, .js files', 'directorist' ), + ); + + $fields['import_settings'] = array( + 'type' => 'import', + 'label' => 'Import', + 'button-label' => 'Upload Settings File', + ); + + $fields['export_settings'] = array( + 'type' => 'export', + 'label' => 'Export', + 'button-label' => 'Download Settings File', + 'export-file-name' => 'directory-settings', + ); + + $fields['single_listing_slug_with_directory_type'] = array( + 'type' => 'toggle', + 'label' => __( 'Add Directory Type to Permalink', 'directorist' ), + 'value' => directorist_is_multi_directory_enabled(), + 'show-if' => array( + 'where' => 'enable_multi_directory', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ); + + $fields['restore_default_settings'] = array( + 'type' => 'restore', + 'label' => 'Restore Default Settings', + 'button-label' => 'Restore', + 'restor-data' => $this->get_simple_data_content( array( 'path' => 'directory/directory-settings.json' ) ), + ); + + $fields['enable_multi_directory'] = array( + 'type' => 'toggle', + 'label' => 'Enable Multi Directory', + 'value' => false, + 'confirm-before-change' => true, + 'confirmation-modal' => array( + 'show-model-header' => false, + ), + 'data-on-change' => array( + 'action' => 'updateData', + 'args' => array( 'reload_after_save' => true ), + ), + 'componets' => array( + 'link' => array( + 'label' => __( 'Start Building Directory', 'directorist' ), + 'type' => 'success', + 'url' => admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types' ), + 'show' => directorist_is_multi_directory_enabled(), + ), + ), + ); + + $fields['regenerate_pages'] = array( + 'type' => 'ajax-action', + 'action' => 'atbdp_upgrade_old_pages', + 'label' => 'Upgrade/Regenerate Pages', + 'button-label' => 'Regenerate Pages', + 'button-label-on-processing' => '<i class="fas fa-circle-notch fa-spin"></i> Processing', + 'data' => array(), + ); + + $users = get_users( array( 'role__not_in' => 'Administrator', // Administrator | Subscriber 'number' => apply_filters( 'directorist_announcement_user_query_num', 1000 ), ) ); - $recipient = []; - - if ( ! empty( $users ) ) { - foreach ( $users as $user ) { - $recipient[] = [ - 'value' => $user->user_email, - 'label' => ( ! empty( $user->display_name ) ) ? $user->display_name : $user->user_nicename, - ]; - } - } - - $fields['listing_import_button'] = [ - 'type' => 'button', - 'url' => admin_url( 'edit.php?post_type=at_biz_dir&page=tools' ), - 'open-in-new-tab' => true, - 'label' => __( 'Import', 'directorist' ), - 'button-label' => __( 'Run Importer', 'directorist' ), - ]; - - $fields['listing_export_button'] = [ - 'type' => 'export-data', - 'label' => __( 'Export', 'directorist' ), - 'button-label' => __( 'Download Export File', 'directorist' ), - 'export-file-name' => __( 'listings-export-data', 'directorist' ), - 'prepare-export-file-from' => 'directorist_prepare_listings_export_file', - 'nonce' => [ - 'key' => 'directorist_nonce', - 'value' => wp_create_nonce( directorist_get_nonce_key() ), - ], - ]; - - $c = '<b><span style="color:#c71585;">'; //color start - $e = '</span></b>'; // end color - - $description = <<<SWBD + $recipient = array(); + + if ( ! empty( $users ) ) { + foreach ( $users as $user ) { + $recipient[] = array( + 'value' => $user->user_email, + 'label' => ( ! empty( $user->display_name ) ) ? $user->display_name : $user->user_nicename, + ); + } + } + + $fields['listing_import_button'] = array( + 'type' => 'button', + 'url' => admin_url( 'edit.php?post_type=at_biz_dir&page=tools' ), + 'open-in-new-tab' => true, + 'label' => __( 'Import', 'directorist' ), + 'button-label' => __( 'Run Importer', 'directorist' ), + ); + + $fields['listing_export_button'] = array( + 'type' => 'export-data', + 'label' => __( 'Export', 'directorist' ), + 'button-label' => __( 'Download Export File', 'directorist' ), + 'export-file-name' => __( 'listings-export-data', 'directorist' ), + 'prepare-export-file-from' => 'directorist_prepare_listings_export_file', + 'nonce' => array( + 'key' => 'directorist_nonce', + 'value' => wp_create_nonce( directorist_get_nonce_key() ), + ), + ); + + $c = '<b><span style="color:#c71585;">'; // color start + $e = '</span></b>'; // end color + + $description = <<<SWBD You can use the following keywords/placeholder in any of your email bodies/templates or subjects to output dynamic value. **Usage: place the placeholder name between $c == $e and $c == $e . For Example: use {$c}==SITE_NAME=={$e} to output The Your Website Name etc. <br/><br/> {$c}==NAME=={$e} : It outputs The listing owner's display name on the site<br/> {$c}==USERNAME=={$e} : It outputs The listing owner's user name on the site<br/> @@ -190,116 +193,141 @@ public function register_setting_fields( $fields = [] ) { Additionally, you can also use HTML tags in your template. SWBD; - $fields['email_note'] = [ - 'type' => 'note', - 'title' => 'You can use Placeholders to output dynamic value', - 'description' => $description, - ]; - - // Marker Clustering - $fields['marker_clustering'] = [ - 'type' => 'toggle', - 'label' => __('Marker Clustering', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "select_listing_map", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'google'], - ], - ], - ]; - - - // Map Country Restriction Field - $fields['country_restriction'] = [ - 'type' => 'toggle', - 'label' => __('Country Restriction', 'directorist'), - 'value' => false, - 'show-if' => [ - 'where' => "select_listing_map", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'google'], - ], - ], - ]; - - // Use Default Latitude/Longitude in All Listing Map View - $fields['use_def_lat_long'] = [ - 'type' => 'toggle', - 'label' => __('Force Default Location', 'directorist'), - 'value' => false, - 'description' => __('Enable this option to force the default latitude and longitude to create a default location on all listings map view. - Otherwise default location works only on the add listing form map.', 'directorist'), - ]; - - $countries = atbdp_country_code_to_name(); - $items = array(); - - foreach ($countries as $country => $code) { - $items[] = array( - 'value' => $country, - 'label' => $code, - ); - } - - $fields['restricted_countries'] = [ - 'type' => 'checkbox', - 'label' => __('Select Countries', 'directorist'), - 'options' => $items, - 'value' => '', - 'show-if' => [ - 'where' => "country_restriction", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]; - - - // Single Listings - $fields['submission_confirmation'] = [ - 'type' => 'toggle', - 'label' => __('Show Submission Confirmation', 'directorist'), - 'value' => true, - ]; - - $fields['pending_confirmation_msg'] = [ - 'type' => 'textarea', - 'label' => __('Pending Confirmation Message', 'directorist'), - 'value' => __('Thank you for your submission. Your listing is being reviewed and it may take up to 24 hours to complete the review.', 'directorist'), - 'show-if' => [ - 'where' => "submission_confirmation", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]; - - $fields['publish_confirmation_msg'] = [ - 'type' => 'textarea', - 'label' => __('Publish Confirmation Message', 'directorist'), - 'value' => __('Congratulations! Your listing has been approved/published. Now it is publicly available.', 'directorist'), - 'show-if' => [ - 'where' => "submission_confirmation", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]; - - return $fields; - } + $fields['email_note'] = array( + 'type' => 'note', + 'title' => 'You can use Placeholders to output dynamic value', + 'description' => $description, + ); + + // Marker Clustering + $fields['marker_clustering'] = array( + 'type' => 'toggle', + 'label' => __( 'Marker Clustering', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'select_listing_map', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'google', + ), + ), + ), + ); + + // Map Country Restriction Field + $fields['country_restriction'] = array( + 'type' => 'toggle', + 'label' => __( 'Country Restriction', 'directorist' ), + 'value' => false, + 'show-if' => array( + 'where' => 'select_listing_map', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'google', + ), + ), + ), + ); + + // Use Default Latitude/Longitude in All Listing Map View + $fields['use_def_lat_long'] = array( + 'type' => 'toggle', + 'label' => __( 'Force Default Location', 'directorist' ), + 'value' => false, + 'description' => __( + 'Enable this option to force the default latitude and longitude to create a default location on all listings map view. + Otherwise default location works only on the add listing form map.', + 'directorist' + ), + ); + + $countries = atbdp_country_code_to_name(); + $items = array(); + + foreach ( $countries as $country => $code ) { + $items[] = array( + 'value' => $country, + 'label' => $code, + ); + } + + $fields['restricted_countries'] = array( + 'type' => 'checkbox', + 'label' => __( 'Select Countries', 'directorist' ), + 'options' => $items, + 'value' => '', + 'show-if' => array( + 'where' => 'country_restriction', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ); + + // Single Listings + $fields['submission_confirmation'] = array( + 'type' => 'toggle', + 'label' => __( 'Show Submission Confirmation', 'directorist' ), + 'value' => true, + ); + + $fields['pending_confirmation_msg'] = array( + 'type' => 'textarea', + 'label' => __( 'Pending Confirmation Message', 'directorist' ), + 'value' => __( 'Thank you for your submission. Your listing is being reviewed and it may take up to 24 hours to complete the review.', 'directorist' ), + 'show-if' => array( + 'where' => 'submission_confirmation', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ); + + $fields['publish_confirmation_msg'] = array( + 'type' => 'textarea', + 'label' => __( 'Publish Confirmation Message', 'directorist' ), + 'value' => __( 'Congratulations! Your listing has been approved/published. Now it is publicly available.', 'directorist' ), + 'show-if' => array( + 'where' => 'submission_confirmation', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ); + + return $fields; + } // get_simple_data_content - public function get_simple_data_content( array $args = [] ) { - $default = [ 'path' => '', 'json_decode' => true ]; - $args = array_merge( $default, $args ); + public function get_simple_data_content( array $args = array() ) { + $default = array( + 'path' => '', + 'json_decode' => true, + ); + $args = array_merge( $default, $args ); $path = ( ! empty( $args['path'] ) ) ? $args['path'] : ''; // $path = 'directory/directory.json' $file = DIRECTORIST_ASSETS_DIR . "sample-data/{$path}"; - if ( ! file_exists( $file ) ) { return ''; } + if ( ! file_exists( $file ) ) { + return ''; } $data = file_get_contents( $file ); @@ -311,50 +339,57 @@ public function get_simple_data_content( array $args = [] ) { } // handle_save_settings_data_request - public function handle_save_settings_data_request() - { - $status = [ 'success' => false, 'status_log' => [] ]; + public function handle_save_settings_data_request() { + $status = array( + 'success' => false, + 'status_log' => array(), + ); - if ( ! directorist_verify_nonce() ) { - $status['status_log'] = [ - 'type' => 'error', + if ( ! directorist_verify_nonce() ) { + $status['status_log'] = array( + 'type' => 'error', 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ), - ]; + ); - wp_send_json( [ 'status' => $status ] ); - } + wp_send_json( array( 'status' => $status ) ); + } - if ( ! current_user_can( 'manage_options' ) ) { - $status['status_log'] = [ - 'type' => 'error', + if ( ! current_user_can( 'manage_options' ) ) { + $status['status_log'] = array( + 'type' => 'error', 'message' => __( 'You are not allowed to access this resource', 'directorist' ), - ]; - - wp_send_json( [ 'status' => $status ] ); - } + ); + wp_send_json( array( 'status' => $status ) ); + } - $field_list = ( ! empty( $_POST['field_list'] ) ) ? Directorist\Helper::maybe_json( sanitize_text_field( wp_unslash( $_POST['field_list'] ) ) ) : []; + $field_list = ( ! empty( $_POST['field_list'] ) ) ? Directorist\Helper::maybe_json( sanitize_text_field( wp_unslash( $_POST['field_list'] ) ) ) : array(); // If field list is empty if ( empty( $field_list ) || ! is_array( $field_list ) ) { - $status['status_log'] = [ - 'type' => 'success', + $status['status_log'] = array( + 'type' => 'success', 'message' => __( 'No changes made', 'directorist' ), - ]; - - wp_send_json( [ 'status' => $status, 'field_list' => $field_list ] ); + ); + + wp_send_json( + array( + 'status' => $status, + 'field_list' => $field_list, + ) + ); } - $options = []; + $options = array(); foreach ( $field_list as $field_key ) { - if ( ! isset( $_POST[ $field_key ] ) ) { continue; } + if ( ! isset( $_POST[ $field_key ] ) ) { + continue; } $options[ $field_key ] = sanitize_text_field( wp_unslash( $_POST[ $field_key ] ) ); } - // Prepare Settings - $this->prepare_settings(); + // Prepare Settings + $this->prepare_settings(); $update_settings_options = $this->update_settings_options( $options ); @@ -362,57 +397,59 @@ public function handle_save_settings_data_request() } // update_settings_options - public function update_settings_options( array $options = [] ) { - $status = [ 'success' => false, 'status_log' => [] ]; + public function update_settings_options( array $options = array() ) { + $status = array( + 'success' => false, + 'status_log' => array(), + ); // If field list is empty if ( empty( $options ) || ! is_array( $options ) ) { - $status['status_log'] = [ - 'type' => 'success', + $status['status_log'] = array( + 'type' => 'success', 'message' => __( 'Nothing to save', 'directorist' ), - ]; + ); - return [ 'status' => $status ]; + return array( 'status' => $status ); } // Update the options - $atbdp_options = get_option('atbdp_option'); + $atbdp_options = get_option( 'atbdp_option' ); foreach ( $options as $option_key => $option_value ) { - if ( ! isset( $this->fields[ $option_key ] ) ) { continue; } + if ( ! isset( $this->fields[ $option_key ] ) ) { + continue; } $atbdp_options[ $option_key ] = Directorist\Helper::maybe_json( $option_value, true ); } update_option( 'atbdp_option', $atbdp_options ); - /** - * @since 7.3.0 - */ - do_action( 'directorist_options_updated' ); + /** + * @since 7.3.0 + */ + do_action( 'directorist_options_updated' ); // Send Status - $status['options'] = $options; - $status['success'] = true; - $status['status_log'] = [ - 'type' => 'success', + $status['options'] = $options; + $status['success'] = true; + $status['status_log'] = array( + 'type' => 'success', 'message' => __( 'Saving Successful', 'directorist' ), - ]; + ); - return [ 'status' => $status ]; + return array( 'status' => $status ); } // maybe_serialize - public function maybe_serialize($value = '') - { - return maybe_serialize(Directorist\Helper::maybe_json($value)); + public function maybe_serialize( $value = '' ) { + return maybe_serialize( Directorist\Helper::maybe_json( $value ) ); } // prepare_settings - public function prepare_settings() - { - $business_hours_label = sprintf(__('Open Now %s', 'directorist'), !class_exists('BD_Business_Hour') ? '(Requires Business Hours extension)' : ''); + public function prepare_settings() { + $business_hours_label = sprintf( __( 'Open Now %s', 'directorist' ), ! class_exists( 'BD_Business_Hour' ) ? '(Requires Business Hours extension)' : '' ); - $bank_transfer_instruction = " + $bank_transfer_instruction = ' Please make your payment directly to our bank account and use your ORDER ID (#==ORDER_ID==) as a Reference. Our bank account information is given below. Account details : @@ -421,2814 +458,3219 @@ public function prepare_settings() Account Number : [Enter your Account Number] Bank Name : [Enter your Bank Name] -Please remember that your order may be canceled if you do not make your payment within next 72 hours."; - - $bank_payment_desc = __('You can make your payment directly to our bank account using this gateway. Please use your ORDER ID as a reference when making the payment. We will complete your order as soon as your deposit is cleared in our bank.', 'directorist'); - - $default_size = directorist_default_preview_size(); - $default_preview_size_text = $default_size['width'].'x'.$default_size['height'].' px'; +Please remember that your order may be canceled if you do not make your payment within next 72 hours.'; + $bank_payment_desc = __( 'You can make your payment directly to our bank account using this gateway. Please use your ORDER ID as a reference when making the payment. We will complete your order as soon as your deposit is cleared in our bank.', 'directorist' ); - $this->fields = apply_filters('atbdp_listing_type_settings_field_list', [ + $default_size = directorist_default_preview_size(); + $default_preview_size_text = $default_size['width'] . 'x' . $default_size['height'] . ' px'; - 'enable_monetization' => [ - 'label' => __( 'Enable Monetization', 'directorist' ), - 'type' => 'toggle', - 'value' => false, - 'description' => __( 'Enable monetization to accept payments from users and earn through listing submissions. - ', 'directorist' ), - - ], + $this->fields = apply_filters( + 'atbdp_listing_type_settings_field_list', + array( - 'enable_featured_listing' => [ - 'label' => __( 'Monetize with Featured Listings', 'directorist' ), - 'type' => 'toggle', - 'value' => false, - 'description' => sprintf( - __( 'Enable this option to charge users for featuring their listing. + 'enable_monetization' => array( + 'label' => __( 'Enable Monetization', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + 'description' => __( + 'Enable monetization to accept payments from users and earn through listing submissions. + ', + 'directorist' + ), + + ), + + 'enable_featured_listing' => array( + 'label' => __( 'Monetize with Featured Listings', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + 'description' => sprintf( + __( + 'Enable this option to charge users for featuring their listing. Note: You need to add the "Listing Type" field to the add listing form for this feature to work properly. - <a href="%s" target="_blank">Watch how</a>', 'directorist' ), - esc_url( '' ) // Replace with your URL - ), - 'show-if' => [ - 'where' => "enable_monetization", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - - 'featured_listing_desc' => [ - 'type' => 'textarea', - 'label' => __('Listing Description at Checkout', 'directorist'), - 'show-if' => [ - 'where' => "enable_featured_listing", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - 'value' => __('You are about to feature your listing, promoting it to the top of search results and listings pages for enhanced visibility.', 'directorist'), - ], - - 'featured_listing_price' => [ - 'label' => __('Featured Listing Fee', 'directorist'), - 'type' => 'number', - 'min' => 0, - 'step' => '0.01', - 'value' => 19.99, - 'description' => __('Set the amount you want to charge users for featuring their listing.', 'directorist'), - 'show-if' => [ - 'where' => "enable_featured_listing", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - - 'featured_listing_time' => [ - 'label' => __( 'Featured Listing Duration (in Days)', 'directorist' ), - 'description' => __( 'Set how many days a listing stays featured', 'directorist' ), - 'type' => 'number', - 'value' => 30, - 'show-if' => [ - 'where' => "enable_featured_listing", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - - 'active_gateways' => [ - 'label' => __('Payment Methods', 'directorist'), - 'type' => 'checkbox', - 'value' => ['bank_transfer'], - 'options' => apply_filters( 'directorist_active_gateways', [ - [ - 'value' => 'bank_transfer', - 'label' => __('Bank Transfer (Offline Gateway)', 'directorist'), - ], - ] ), - 'description' => __('Check the gateway(s) you would like to use to collect payment from your users. A user will be use any of the active gateways during the checkout process ', 'directorist'), - ], - - 'default_gateway' => [ - 'label' => __('Default Gateway', 'directorist'), - 'type' => 'select', - 'value' => 'bank_transfer', - 'options' => apply_filters('atbdp_default_gateways', [ - [ - 'value' => 'bank_transfer', - 'label' => __('Bank Transfer (Offline Gateway)', 'directorist'), - ] - ] ), - 'description' => __('Select the default gateway you would like to show as a selected gateway on the checkout page', 'directorist'), - ], - - 'payment_currency_note' => [ - 'type' => 'note', - 'title' => __('Note About This Currency Settings:', 'directorist'), - 'description' => __('This currency settings lets you customize how you would like to accept payment from your user/customer and how to display pricing on the order form/history.', 'directorist'), - ], - - 'payment_currency' => [ - 'type' => 'text', - 'label' => __('Currency Code', 'directorist'), - 'value' => __('USD', 'directorist'), - 'description' => sprintf( - __( 'Enter the 3-letter currency code (e.g., USD for US Dollar). For a full list of currency codes, refer to %s.', 'directorist' ), - "<a href='" . esc_url( 'https://www.iban.com/currency-codes' ) . "'>" . __( 'ISO 4217 Currency Codes', 'directorist' ) . "</a>" - ), - ], - - 'payment_thousand_separator' => [ - 'type' => 'text', - 'label' => __('Thousand Separator', 'directorist'), - 'value' => __(',', 'directorist'), - 'description' => __( 'Enter the currency thousand separator. Eg. , or . etc.', 'directorist' ), - ], - - 'payment_decimal_separator' => [ - 'type' => 'text', - 'label' => __('Decimal Separator', 'directorist'), - 'value' => __('.', 'directorist'), - 'description' => __('Enter the currency decimal separator. Eg. "." or ",". Default is "."', 'directorist'), - ], - - 'payment_currency_position' => [ - 'label' => __('Currency Position', 'directorist'), - 'type' => 'select', - 'value' => 'before', - 'options' => [ - [ - 'value' => 'before', - 'label' => __('$5 - Before', 'directorist'), - ], - [ - 'value' => 'after', - 'label' => __('After - 5$', 'directorist'), - ] - ], - 'description' => __('Select where you would like to show the currency symbol. Default is before. Eg. $5', 'directorist'), - ], - - // gateway settings - 'offline_payment_note' => [ - 'type' => 'note', - 'title' => __('Note About Bank Transfer Gateway:', 'directorist'), - 'description' => __('You should remember that this payment gateway needs some manual action to complete an order. After getting notification of order using this offline payment gateway, you should check your bank if the money is deposited to your account. Then you should change the order status manually from the "Order History" submenu.', 'directorist'), - ], - - 'bank_transfer_title' => [ - 'type' => 'text', - 'label' => __('Gateway Title', 'directorist'), - 'value' => __('Bank Transfer', 'directorist'), - 'description' => __('Enter the title of this gateway that should be displayed to the user on the front end.', 'directorist'), - ], - - 'bank_transfer_description' => [ - 'type' => 'textarea', - 'label' => __('Gateway Description', 'directorist'), - 'value' => $bank_payment_desc, - 'description' => __('Enter some description for your user to transfer funds to your account.', 'directorist'), - ], - - 'bank_transfer_instruction' => [ - 'type' => 'textarea', - 'label' => __('Bank Information', 'directorist'), - 'value' => $bank_transfer_instruction, - 'description' => __('Enter your bank information below so that use can make payment directly to your bank account.', 'directorist'), - ], - - //extension setting - 'extension_promotion' => [ - 'type' => 'note', - 'title' => __('Need more Features?', 'directorist'), - 'description' => sprintf(__('You can add new features and expand the functionality of the plugin even more by using extensions. %s', 'directorist'), $this->extension_url), - ], - - 'announcement_to' => [ - 'label' => __('To', 'directorist'), - 'type' => 'select', - 'value' => 'all_user', - 'options' => [ - [ - 'value' => 'all_user', - 'label' => __( 'All User', 'directorist' ) - ], - [ - 'value' => 'selected_user', - 'label' => __( 'Selected User', 'directorist' ) - ] - ] - ], - - 'announcement_subject' => [ - 'label' => __('Subject', 'directorist'), - 'type' => 'text', - 'value' => false - ], - - 'announcement_send_to_email' => [ - 'label' => __('Send a copy to email', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - - // Button Type - 'button_type' => [ - 'label' => __('Button Type', 'directorist'), - 'type' => 'select', - 'value' => 'select_option', - 'show-default-option' => true, - 'options' => [ - [ - 'value' => 'button_type_primary', - 'label' => __('Primary', 'directorist'), - ], - [ - 'value' => 'button_type_secondary', - 'label' => __('Secondary', 'directorist'), - ], - ] - ], - - // Primary Button - 'button_primary_example' => [ - 'label' => __('Button Example', 'directorist'), - 'description' => __('Modify the color of primary buttons like Save & Preview, Search, etc to match your design preferences', 'directorist'), - 'type' => 'button-example', - 'button-class' => 'directorist-btn-primary', - 'button-label' => __( 'Primary', 'directorist' ), - 'show-if' => [ - 'where' => "button_type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'button_type_primary'], - ], - ], - ], - 'button_primary_color' => [ - 'label' => __('Text Color', 'directorist'), - 'type' => 'color', - 'value' => '#ffffff', - 'show-if' => [ - 'where' => "button_type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'button_type_primary'], - ], - ], - ], - 'button_primary_bg_color' => [ - 'label' => __('Background Color', 'directorist'), - 'type' => 'color', - 'value' => '#444752', - 'show-if' => [ - 'where' => "button_type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'button_type_primary'], - ], - ], - ], - - // Secondary Button - 'button_secondary_example' => [ - 'label' => __('Button Example', 'directorist'), - 'description' => __('Modify the color of secondary buttons like Logout, etc to match your design preferences', 'directorist'), - 'type' => 'button-example', - 'button-class' => 'directorist-btn-secondary', - 'button-label' => __( 'Secondary', 'directorist' ), - 'show-if' => [ - 'where' => "button_type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'button_type_secondary'], - ], - ], - ], - 'button_secondary_color' => [ - 'label' => __('Text Color', 'directorist'), - 'type' => 'color', - 'value' => '#404040', - 'show-if' => [ - 'where' => "button_type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'button_type_secondary'], - ], - ], - ], - 'button_secondary_bg_color' => [ - 'label' => __('Background Color', 'directorist'), - 'type' => 'color', - 'value' => '#f2f3f5', - 'show-if' => [ - 'where' => "button_type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'button_type_secondary'], - ], - ], - ], - // Badge Color - 'featured_back_color' => [ - 'type' => 'color', - 'label' => __('Background Color', 'directorist'), - 'value' => '#fa8b0c', - 'change-if' => [ - 'where' => 'feature_badge_type', - 'conditions' => [ - [ - 'key' => 'value', - 'compare' => '=', - 'value' => 'icon_badge' - ], - ], - 'effects' => [ - [ - 'key' => 'label', - 'value' => __('Hover Background Color', 'directorist'), - 'default_value' => __('Background Color', 'directorist') - ], - ], - ], - ], - - 'popular_back_color' => [ - 'type' => 'color', - 'label' => __('Background Color', 'directorist'), - 'value' => '#f51957', - ], - - 'new_back_color' => [ - 'type' => 'color', - 'label' => __('Background Color', 'directorist'), - 'value' => '#2C99FF', - ], - - // Map Marker Color - 'marker_shape_color' => [ - 'type' => 'color', - 'label' => __('Marker Shape Color', 'directorist'), - 'value' => '#444752', - ], - - 'marker_icon_color' => [ - 'type' => 'color', - 'label' => __('Marker Icon Color', 'directorist'), - 'value' => '#ffffff', - ], - - // Primary Color - 'brand_color' => [ - 'type' => 'color', - 'label' => __('Brand Color', 'directorist'), - 'value' => '#444752', - ], - - // Email - 'email_to_expire_day' => [ - 'label' => __('When to send expire notice', 'directorist'), - 'type' => 'number', - 'description' => __('Select the days before a listing expires to send an expiration reminder email', 'directorist'), - 'value' => 7, - 'placeholder' => '10', - 'rules' => [ - 'required' => true, - ], - ], - 'email_renewal_day' => [ - 'label' => __('When to send renewal reminder', 'directorist'), - 'type' => 'number', - 'description' => __('Select the days after a listing expires to send a renewal reminder email', 'directorist'), - 'value' => 7, - 'placeholder' => '10', - 'rules' => [ - 'required' => true, - ], - ], - 'delete_expired_listing_permanently' => [ - 'label' => __('Permanently Delete Expired Listings', 'directorist'), - 'type' => 'toggle', - 'description' => __( 'Automatically delete trashed listings permanently after the defined duration', 'directorist' ), - 'value' => true, - ], - 'delete_expired_listings_after' => [ - 'label' => __( 'Permanently Delete After (days) of Expiration', 'directorist' ), - 'type' => 'number', - 'value' => 15, - 'placeholder' => '15', - 'rules' => [ - 'required' => true, - ], - ], - 'paginate_author_listings' => [ - 'label' => __('Paginate Author Listings', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'atbdp_enable_cache' => [ - 'label' => __('Enable Cache', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'atbdp_reset_cache' => [ - 'label' => __('Reset Cache', 'directorist'), - 'type' => 'toggle', - 'show-if' => [ - 'where' => "atbdp_enable_cache", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - 'value' => false, - ], - 'guest_listings' => [ - 'label' => __('Guest Listing Submission', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - 'guest_email_label' => [ - 'type' => 'text', - 'label' => __( 'Guest Email Label', 'directorist' ), - 'value' => __( 'Your Email', 'directorist' ), - 'show-if' => [ - 'where' => "guest_listings", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'guest_email_placeholder' => [ - 'type' => 'text', - 'label' => __( 'Guest Email Placeholder', 'directorist' ), - 'value' => __( 'example@email.com', 'directorist' ), - 'show-if' => [ - 'where' => "guest_listings", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - - // listings page - 'all_listing_layout' => [ - 'label' => __( 'All Listings Layout', 'directorist' ), - 'type' => 'select', - 'value' => 'left_sidebar', - 'options' => [ - [ - 'value' => 'left_sidebar', - 'label' => __('Left Sidebar Filter', 'directorist'), - ], - [ - 'value' => 'right_sidebar', - 'label' => __('Right Sidebar Filter', 'directorist'), - ], - [ - 'value' => 'no_sidebar', - 'label' => __('Popup Filter', 'directorist'), - ], - ], - ], - - 'listing_hide_top_search_bar' => [ - 'type' => 'toggle', - 'label' => __('Hide Top Search Bar', 'directorist'), - 'value' => false, - 'show-if' => [ - 'where' => "all_listing_layout", - 'conditions' => [ - ['key' => 'value', 'compare' => '!=', 'value' => 'no_sidebar'], - ], - ], - ], - 'listings_sidebar_filter_text' => [ - 'type' => 'text', - 'label' => __('Filters Text', 'directorist'), - 'value' => __('Filters', 'directorist'), - 'show-if' => [ - 'where' => "all_listing_layout", - 'conditions' => [ - ['key' => 'value', 'compare' => '!=', 'value' => 'no_sidebar'], - ], - ], - ], - 'listings_filter_button_text' => [ - 'type' => 'text', - 'label' => __('Filters Button Text', 'directorist'), - 'value' => __('Filters', 'directorist'), - 'show-if' => [ - 'where' => "all_listing_layout", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'no_sidebar'], - ], - ], - ], - 'display_listings_count' => [ - 'type' => 'toggle', - 'label' => __('Display Listings Count', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_listings_header", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'all_listing_title' => [ - 'type' => 'text', - 'label' => __('Listings Count Text', 'directorist'), - 'value' => __('Items Found', 'directorist'), - 'show-if' => [ - 'where' => "display_listings_header", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'listings_reset_text' => [ - 'type' => 'text', - 'label' => __('Reset Button text', 'directorist'), - 'value' => __('Reset Filters', 'directorist'), - 'show-if' => [ - 'where' => "all_listing_layout", - 'conditions' => [ - [ 'key' => 'value', 'compare' => '=', 'value' => 'no_sidebar' ], - ], - ], - ], - 'listings_sidebar_reset_text' => [ - 'type' => 'text', - 'label' => __('Reset text', 'directorist'), - 'value' => __('Clear All', 'directorist'), - 'show-if' => [ - 'where' => "all_listing_layout", - 'conditions' => [ - [ 'key' => 'value', 'compare' => '!=', 'value' => 'no_sidebar' ], - ], - ], - ], - 'listings_apply_text' => [ - 'type' => 'text', - 'label' => __('Apply Button text', 'directorist'), - 'value' => __('Apply Filters', 'directorist'), - 'show-if' => [ - 'where' => "all_listing_layout", - 'conditions' => [ - [ 'key' => 'value', 'compare' => '=', 'value' => 'no_sidebar' ], - ], - ], - ], - - - 'display_sort_by' => [ - 'type' => 'toggle', - 'label' => __('Enable Sorting Options', 'directorist'), - 'value' => true, - ], - 'sort_by_text' => [ - 'type' => 'text', - 'label' => __('"Sort By" Label', 'directorist'), - 'value' => __('Sort By', 'directorist'), - 'show-if' => [ - 'where' => "display_sort_by", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'listings_sort_by_items' => [ - 'label' => __('Sort Options', 'directorist'), - 'type' => 'checkbox', - 'value' => [ - 'a_z', - 'z_a', - 'latest', - 'oldest', - 'popular', - 'price_low_high', - 'price_high_low', - 'random' - ], - 'options' => [ - [ - 'value' => 'a_z', - 'label' => __('A to Z (title)', 'directorist'), - ], - [ - 'value' => 'z_a', - 'label' => __('Z to A (title)', 'directorist'), - ], - [ - 'value' => 'latest', - 'label' => __('Latest listings', 'directorist'), - ], - [ - 'value' => 'oldest', - 'label' => __('Oldest listings', 'directorist'), - ], - [ - 'value' => 'popular', - 'label' => __('Popular listings', 'directorist'), - ], - [ - 'value' => 'price_low_high', - 'label' => __('Price (low to high)', 'directorist'), - ], - [ - 'value' => 'price_high_low', - 'label' => __('Price (high to low)', 'directorist'), - ], - [ - 'value' => 'random', - 'label' => __('Random listings', 'directorist'), - ], - ], - ], - 'listings_view_as_items' => [ - 'label' => __('View Type', 'directorist'), - 'type' => 'checkbox', - 'value' => [ - 'listings_grid', - 'listings_list', - 'listings_map' - ], - 'options' => [ - [ - 'value' => 'listings_grid', - 'label' => __('Grid', 'directorist'), - ], - [ - 'value' => 'listings_list', - 'label' => __('List', 'directorist'), - ], - [ - 'value' => 'listings_map', - 'label' => __('Map', 'directorist'), - ], - ], - ], - 'default_listing_view' => [ - 'label' => __('Default View', 'directorist'), - 'type' => 'select', - 'value' => 'grid', - 'options' => [ - [ - 'value' => 'grid', - 'label' => __('Grid', 'directorist'), - ], - [ - 'value' => 'list', - 'label' => __('List', 'directorist'), - ], - [ - 'value' => 'map', - 'label' => __('Map', 'directorist'), - ], - ], - ], - 'all_listing_columns' => [ - 'label' => __('Listings Columns', 'directorist'), - 'type' => 'number', - 'value' => 2, - 'placeholder' => '3', - ], - 'preview_image_quality' => [ - 'label' => __('Image Quality', 'directorist'), - 'type' => 'select', - 'value' => 'directorist_preview', - 'options' => [ - [ - 'value' => 'directorist_preview', - 'label' => __( 'Default', 'directorist' ), - ], - [ - 'value' => 'medium', - 'label' => __('Medium', 'directorist'), - ], - [ - 'value' => 'large', - 'label' => __('Large', 'directorist'), - ], - [ - 'value' => 'full', - 'label' => __('Full', 'directorist'), - ], - ], - 'description' => sprintf( __( 'Default: %s.<br/>If changed, regenerate thumbnails via <a href="%s" target="_blank">this</a> plugin for proper functionality.', 'directorist' ), $default_preview_size_text, 'https://wordpress.org/plugins/regenerate-thumbnails/' ), - ], - 'way_to_show_preview' => [ - 'label' => __('Image Size', 'directorist'), - 'type' => 'select', - 'value' => 'cover', - - 'options' => [ - [ - 'value' => 'full', - 'label' => __('Original', 'directorist'), - ], - [ - 'value' => 'cover', - 'label' => __('Fill with Container', 'directorist'), - ], - [ - 'value' => 'contain', - 'label' => __('Fit with Container', 'directorist'), - ], - ], - ], - 'crop_width' => [ - 'label' => __('Width', 'directorist'), - 'type' => 'number', - 'value' => '350', - 'min' => '1', - 'max' => '1200', - 'step' => '1', - 'group' => 'container', - 'group_label' => 'Container', - ], - 'crop_height' => [ - 'label' => __('Height', 'directorist'), - 'type' => 'number', - 'value' => '260', - 'min' => '1', - 'max' => '1200', - 'step' => '1', - 'group' => 'container', - 'group_label' => 'Container', - ], - 'prv_container_size_by' => [ - 'label' => __('Size By', 'directorist'), - 'type' => 'select', - 'value' => 'px', - 'options' => [ - [ - 'value' => 'px', - 'label' => __('Pixel', 'directorist'), - ], - [ - 'value' => 'ratio', - 'label' => __('Ratio', 'directorist'), - ], - ], - 'group' => 'container', - 'group_label' => 'Container', - ], - 'prv_background_type' => [ - 'label' => __('Background', 'directorist'), - 'type' => 'select', - 'value' => 'blur', - - 'options' => [ - [ - 'value' => 'blur', - 'label' => __('Blur', 'directorist'), - ], - [ - 'value' => 'color', - 'label' => __('Custom Color', 'directorist'), - ], - ], - ], - 'prv_background_color' => [ - 'type' => 'text', - 'label' => __('Select Color', 'directorist'), - 'show-if' => [ - 'where' => "prv_background_type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'color'], - ], - ], - 'value' => 'gainsboro', - ], - 'all_listing_page_items' => [ - 'label' => __('Listings Per Page', 'directorist'), - 'type' => 'number', - 'value' => '6', - 'min' => '1', - 'max' => '100', - 'step' => '1', - ], - 'pagination_type' => [ - 'label' => __( 'Pagination Type', 'directorist' ), - 'type' => 'select', - 'value' => 'numbered', - 'options' => [ - [ - 'value' => 'numbered', - 'label' => __( 'Numbered', 'directorist' ), - ], - [ - 'value' => 'infinite_scroll', - 'label' => __( 'Infinite Scroll', 'directorist' ), - ], - ], - ], - 'display_listings_header' => [ - 'label' => __('Enable Header', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'listing_filters_button' => [ - 'type' => 'toggle', - 'label' => __('Display Filters Button', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "all_listing_layout", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'no_sidebar'], - ], - ], - ], - // single listing settings - 'disable_single_listing' => [ - 'type' => 'toggle', - 'label' => __('Disable Single Listing View'), - 'value' => false, - ], - 'restrict_single_listing_for_logged_in_user' => [ - 'type' => 'toggle', - 'label' => __('Show Single Listings to Logged-In Users Only', 'directorist'), - 'value' => false, - ], - 'single_listing_template' => [ - 'label' => __('Template', 'directorist'), - 'type' => 'select', - 'value' => 'directorist_template', - 'show-if' => [ - 'where' => "disable_single_listing", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - 'options' => [ - [ - 'value' => 'theme_template_page', - 'label' => __('Theme Template (Page)', 'directorist'), - ], - [ - 'value' => 'current_theme_template', - 'label' => __('Theme Template (Post)', 'directorist'), - ], - [ - 'value' => 'directorist_template', - 'label' => __('Directorist Template', 'directorist'), - ], - ], - ], - 'atbdp_listing_slug' => [ - 'type' => 'text', - 'label' => __('Listing Slug', 'directorist'), - 'show-if' => [ - 'where' => "disable_single_listing", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - 'value' => 'directory', - ], - 'dsiplay_slider_single_page' => [ - 'type' => 'toggle', - 'label' => __('Show Slider Image', 'directorist'), - 'value' => true, - 'description' => __('Hide/show slider image from single listing page.', 'directorist'), - 'show-if' => [ - 'where' => "disable_single_listing", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - ], - 'single_slider_image_size' => [ - 'label' => __('Image Size', 'directorist'), - 'type' => 'select', - 'value' => 'cover', - 'show-if' => [ - 'where' => "dsiplay_slider_single_page", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - 'options' => [ - [ - 'value' => 'cover', - 'label' => __('Fill with Container', 'directorist'), - ], - [ - 'value' => 'contain', - 'label' => __('Fit with Container', 'directorist'), - ], - ], - ], - 'single_slider_background_type' => [ - 'label' => __('Slider Background Type', 'directorist'), - 'type' => 'select', - 'value' => 'custom-color', - 'show-if' => [ - 'where' => "single_slider_image_size", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'contain'], - ], - ], - 'options' => [ - [ - 'value' => 'blur', - 'label' => __('Blur', 'directorist'), - ], - [ - 'value' => 'custom-color', - 'label' => __('Custom Color', 'directorist'), - ], - ], - ], - 'single_slider_background_color' => [ - 'type' => 'color', - 'label' => __('Background Color', 'directorist'), - 'show-if' => [ - 'where' => "single_slider_background_type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'custom-color'], - ], - ], - 'value' => '#ffffff', - ], - - 'gallery_crop_width' => [ - 'label' => __('Image Width', 'directorist'), - 'type' => 'number', - 'value' => '740', - 'min' => '1', - 'max' => '1200', - 'step' => '1', - 'show-if' => [ - 'where' => "dsiplay_slider_single_page", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'gallery_crop_height' => [ - 'label' => __('Image Height', 'directorist'), - 'type' => 'number', - 'value' => '580', - 'min' => '1', - 'max' => '1200', - 'step' => '1', - 'show-if' => [ - 'where' => "dsiplay_slider_single_page", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - // badge settings - 'new_badge_text' => [ - 'type' => 'text', - 'label' => __('Badge Text', 'directorist'), - 'description' => __('Text displayed on the badge when a listing is newly created.', 'directorist'), - 'value' => __('New', 'directorist'), - ], - 'new_listing_day' => [ - 'label' => __('New Badge Display Duration', 'directorist'), - 'description' => __('Enter the number of days the "New" badge will appear on a new listing.', 'directorist'), - 'type' => 'number', - 'value' => '3', - 'min' => '1', - 'max' => '100', - 'step' => '1', - ], - 'feature_badge_type' => [ - 'label' => __('Badge Type', 'directorist'), - 'type' => 'select', - 'value' => 'text_badge', - 'options' => [ - [ - 'value' => 'text_badge', - 'label' => __('Text Badge', 'directorist'), - ], - [ - 'value' => 'icon_badge', - 'label' => __('Icon with Hover Text', 'directorist'), - ], - ], - ], - 'feature_badge_text' => [ - 'type' => 'text', - 'label' => __('Badge Text', 'directorist'), - 'description' => __('Text displayed on the badge when a listing is marked as featured.', 'directorist'), - 'value' => __('Featured', 'directorist'), - 'change-if' => [ - 'where' => 'feature_badge_type', - 'conditions' => [ - [ - 'key' => 'value', - 'compare' => '=', - 'value' => 'icon_badge' - ], - ], - 'effects' => [ - [ - 'key' => 'label', - 'value' => __('Badge Hover Text', 'directorist'), - 'default_value' => __('Badge Text', 'directorist') - ], - ], - ], - ], - 'popular_badge_text' => [ - 'type' => 'text', - 'label' => __('Badge Text', 'directorist'), - 'description' => __('Text displayed on the badge when an item is marked as popular.', 'directorist'), - 'value' => __('Popular', 'directorist'), - ], - 'listing_popular_by' => [ - 'label' => __('Determine Popularity By', 'directorist'), - 'description' => __('Select the criteria used to determine popularity.', 'directorist'), - 'type' => 'select', - 'value' => 'view_count', - 'options' => [ - [ - 'value' => 'view_count', - 'label' => __('View Count', 'directorist'), - ], - [ - 'value' => 'average_rating', - 'label' => __('Average Rating', 'directorist'), - ], - ], - ], - 'views_for_popular' => [ - 'type' => 'text', - 'label' => __('View Count Threshold', 'directorist'), - 'description' => __('Minimum number of views to mark an item as popular.', 'directorist'), - 'value' => 5, - ], - 'count_loggedin_user' => [ - 'type' => 'toggle', - 'label' => __('Include Logged-In User Views', 'directorist'), - 'description' => __('Count views from logged-in users toward popularity.', 'directorist'), - 'value' => false, - ], - 'average_review_for_popular' => [ - 'label' => __('Minimum Average Rating', 'directorist'), - 'description' => __('Minimum average rating (equal or greater than) to mark an item as popular.', 'directorist'), - 'type' => 'number', - 'value' => '4', - 'min' => '.5', - 'max' => '4.5', - 'step' => '.5', - ], - - // select map settings - 'select_listing_map' => [ - 'label' => __('Select Map', 'directorist'), - 'type' => 'select', - 'value' => 'openstreet', - 'options' => [ - [ - 'value' => 'google', - 'label' => __('Google Map', 'directorist'), - ], - [ - 'value' => 'openstreet', - 'label' => __('OpenStreetMap', 'directorist'), - ], - ], - ], - 'map_api_key' => [ - 'type' => 'text', - 'label' => __('Google Map API key', 'directorist'), - 'description' => sprintf(__('Please replace it by your own API. It\'s required to use Google Map. You can find detailed information %s.', 'directorist'), '<a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank"> <div class="atbdp_shortcodes" style="color: red;">here</div> </a>'), - 'value' => '', - 'show-if' => [ - 'where' => "select_listing_map", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'google'], - ], - ], - ], - 'default_latitude' => [ - 'type' => 'text', - 'label' => __('Default Latitude', 'directorist'), - 'description' => sprintf(__('You can find it %s', 'directorist'), '<a href="https://www.maps.ie/coordinates.html" target="_blank" class="directorist-find-latlan">here</a>'), - 'value' => '40.7127753', - ], - 'default_longitude' => [ - 'type' => 'text', - 'label' => __('Default Longitude', 'directorist'), - 'description' => sprintf(__('You can find it %s', 'directorist'), '<a href="https://www.maps.ie/coordinates.html" target="_blank" class="directorist-find-latlan">here</a>'), - 'value' => '-74.0059728', - ], - 'map_zoom_level' => [ - 'label' => __('Zoom Level for Single Listing', 'directorist'), - 'description' => __('Here 0 means 100% zoom-out. 22 means 100% zoom-in. Minimum Zoom Allowed = 1. Max Zoom Allowed = 22.', 'directorist'), - 'type' => 'number', - 'value' => '16', - 'min' => '1', - 'max' => '22', - 'step' => '1', - ], - 'map_view_zoom_level' => [ - 'label' => __('Zoom Level for Map View', 'directorist'), - 'description' => __('Here 0 means 100% zoom-out. 18 means 100% zoom-in. Minimum Zoom Allowed = 1. Max Zoom Allowed = 22.', 'directorist'), - 'type' => 'number', - 'value' => '1', - 'min' => '1', - 'max' => '18', - 'step' => '1', - ], - 'listings_map_height' => [ - 'label' => __('Map Height', 'directorist'), - 'description' => __('In pixel.', 'directorist'), - 'type' => 'number', - 'value' => '350', - 'min' => '5', - 'max' => '1200', - 'step' => '5', - ], - 'display_map_info' => [ - 'type' => 'toggle', - 'label' => __('Display Map Info Window', 'directorist'), - 'value' => true, - ], - 'display_image_map' => [ - 'type' => 'toggle', - 'label' => __('Display Preview Image', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_favorite_badge_map' => [ - 'type' => 'toggle', - 'label' => __('Display Favorite Badge', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_user_avatar_map' => [ - 'type' => 'toggle', - 'label' => __('Display User Avatar', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_title_map' => [ - 'type' => 'toggle', - 'label' => __('Display Title', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_review_map' => [ - 'type' => 'toggle', - 'label' => __('Display Review', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_price_map' => [ - 'type' => 'toggle', - 'label' => __('Display Price', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_address_map' => [ - 'type' => 'toggle', - 'label' => __('Display Address', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_direction_map' => [ - 'type' => 'toggle', - 'label' => __('Display Get Direction', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_phone_map' => [ - 'type' => 'toggle', - 'label' => __('Display Phone', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "display_map_info", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - // user dashboard settings - 'my_listing_tab' => [ - 'type' => 'toggle', - 'label' => __('Display My Listing Tab', 'directorist'), - 'value' => true, - ], - 'my_listing_tab_text' => [ - 'type' => 'text', - 'label' => __('"My Listing" Tab Label', 'directorist'), - 'value' => __('My Listing', 'directorist'), - 'show-if' => [ - 'where' => "my_listing_tab", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'user_listings_pagination' => [ - 'type' => 'toggle', - 'label' => __('Listings Pagination', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "my_listing_tab", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'user_listings_per_page' => [ - 'label' => __('Listings Per Page', 'directorist'), - 'type' => 'number', - 'value' => '9', - 'min' => '1', - 'max' => '30', - 'step' => '1', - 'show-if' => [ - 'where' => "my_listing_tab", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'my_profile_tab' => [ - 'type' => 'toggle', - 'label' => __('Display My Profile Tab', 'directorist'), - 'value' => true, - ], - 'my_profile_tab_text' => [ - 'type' => 'text', - 'label' => __('"My Profile" Tab Label', 'directorist'), - 'value' => __('My Profile', 'directorist'), - 'show-if' => [ - 'where' => "my_profile_tab", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'fav_listings_tab' => [ - 'type' => 'toggle', - 'label' => __('Display Favourite Listings Tab', 'directorist'), - 'value' => true, - ], - 'fav_listings_tab_text' => [ - 'type' => 'text', - 'label' => __('"Favourite Listings" Tab Label', 'directorist'), - 'value' => __('Favorite Listings', 'directorist'), - 'show-if' => [ - 'where' => "fav_listings_tab", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'submit_listing_button' => [ - 'type' => 'toggle', - 'label' => __('Display Submit Listing Button', 'directorist'), - 'value' => true, - ], - 'become_author_button' => [ - 'type' => 'toggle', - 'label' => __('Display "Become An Author" button', 'directorist'), - 'value' => true, - ], - 'become_author_button_text' => [ - 'type' => 'text', - 'label' => __('"Become An Author" button Label', 'directorist'), - 'value' => __('Become An Author', 'directorist'), - 'show-if' => [ - 'where' => "become_author_button", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - // all authors settings - 'all_authors_columns' => [ - 'label' => __('Number of Columns', 'directorist'), - 'type' => 'number', - 'value' => '3', - 'min' => '1', - 'max' => '6', - 'step' => '1', - ], - 'all_authors_sorting' => [ - 'type' => 'toggle', - 'label' => __('Display Alphabet Sorting', 'directorist'), - 'value' => true, - ], - 'all_authors_image' => [ - 'type' => 'toggle', - 'label' => __('Display Image', 'directorist'), - 'value' => true, - ], - 'all_authors_name' => [ - 'type' => 'toggle', - 'label' => __('Display Name', 'directorist'), - 'value' => true, - ], - 'all_authors_select_role' => [ - 'label' => __('Select Role', 'directorist'), - 'type' => 'select', - 'value' => 'all', - 'options' => $this->get_user_roles(), - ], - 'all_authors_contact' => [ - 'label' => esc_html__( 'Contact Info', 'directorist' ), - 'type' => 'checkbox', - 'value' => [ - 'phone', - 'address', - 'website', - ], - 'description' => esc_html__( 'Email will show only for logged in user.', 'directorist' ), - 'options' => [ - [ - 'value' => 'phone', - 'label' => esc_html__( 'Phone', 'directorist' ), - ], - [ - 'value' => 'email', - 'label' => esc_html__( 'Email', 'directorist' ), - ], - [ - 'value' => 'address', - 'label' => esc_html__( 'Address', 'directorist' ), - ], - [ - 'value' => 'website', - 'label' => esc_html__( 'Website', 'directorist' ), - ], - ], - ], - 'all_authors_description' => [ - 'type' => 'toggle', - 'label' => __('Display Description', 'directorist'), - 'value' => true, - ], - 'all_authors_description_limit' => [ - 'label' => __('Description Word Limit', 'directorist'), - 'type' => 'number', - 'value' => '13', - 'min' => '1', - 'max' => '50', - 'step' => '1', - 'show-if' => [ - 'where' => "all_authors_description", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'all_authors_social_info' => [ - 'type' => 'toggle', - 'label' => __('Display Social Info', 'directorist'), - 'value' => true, - ], - 'all_authors_button' => [ - 'type' => 'toggle', - 'label' => __('Display All Listings Button', 'directorist'), - 'value' => true, - ], - 'all_authors_button_text' => [ - 'type' => 'text', - 'label' => __('All Listings Button text', 'directorist'), - 'value' => __('View All Listings', 'directorist'), - 'show-if' => [ - 'where' => "all_authors_button", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'all_authors_pagination' => [ - 'type' => 'toggle', - 'label' => __('Paginate All Authors ', 'directorist'), - 'value' => true, - ], - 'all_authors_per_page' => [ - 'label' => __('Authors Per Page', 'directorist'), - 'type' => 'number', - 'value' => '9', - 'min' => '1', - 'max' => '50', - 'step' => '1', - ], - // search form settings - 'search_title' => [ - 'type' => 'text', - 'label' => __('Search Bar Title', 'directorist'), - 'value' => __('Search here', 'directorist'), - ], - 'search_subtitle' => [ - 'type' => 'text', - 'label' => __('Search Bar Sub-title', 'directorist'), - 'value' => __( 'Find the best match of your interest', 'directorist' ), - ], - - 'search_more_filter' => [ - 'type' => 'toggle', - 'label' => __('Display More Filters', 'directorist'), - 'value' => true, - ], - 'search_filters' => [ - 'type' => 'checkbox', - 'label' => __('Filter Actions', 'directorist'), - 'show-if' => [ - 'where' => "search_more_filter", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - 'value' => [ - 'search_reset_filters', - 'search_apply_filters', - ], - 'options' => [ - [ - 'value' => 'search_reset_filters', - 'label' => __('Reset', 'directorist'), - ], - [ - 'value' => 'search_apply_filters', - 'label' => __('Apply', 'directorist'), - ], - ], - ], - 'search_listing_text' => [ - 'type' => 'text', - 'label' => __('Search Button Text', 'directorist'), - 'value' => __('Search Listing', 'directorist'), - ], - 'search_more_filters' => [ - 'type' => 'text', - 'label' => __('More Filters Button Text', 'directorist'), - 'value' => __('More Filters', 'directorist'), - 'show-if' => [ - 'where' => "search_more_filter", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'search_reset_text' => [ - 'type' => 'text', - 'label' => __('Reset Button Text', 'directorist'), - 'value' => __('Reset Filters', 'directorist'), - 'show-if' => [ - 'where' => "search_more_filter", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'search_apply_filter' => [ - 'type' => 'text', - 'label' => __('Apply Button Text', 'directorist'), - 'value' => __('Apply Filters', 'directorist'), - 'show-if' => [ - 'where' => "search_more_filter", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'show_popular_category' => [ - 'type' => 'toggle', - 'label' => __('Display Popular Categories', 'directorist'), - 'value' => false, - ], - - 'popular_cat_title' => [ - 'type' => 'text', - 'label' => __('Section Title', 'directorist'), - 'value' => __('Browse by popular categories', 'directorist'), - 'show-if' => [ - 'where' => "show_popular_category", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'popular_cat_num' => [ - 'label' => __('Number of Categories to Display', 'directorist'), - 'type' => 'number', - 'value' => '10', - 'min' => '1', - 'max' => '30', - 'step' => '1', - 'show-if' => [ - 'where' => "show_popular_category", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'search_home_bg' => [ - 'label' => __('Search Section Background', 'directorist'), - 'type' => 'wp-media-picker', - 'default-img' => '', - 'value' => '', - ], - // search result settings - 'search_result_layout' => [ - 'label' => __( 'All Listings Layout', 'directorist' ), - 'type' => 'select', - 'value' => 'left_sidebar', - 'options' => [ - [ - 'value' => 'left_sidebar', - 'label' => __('Left Sidebar Filter', 'directorist'), - ], - [ - 'value' => 'right_sidebar', - 'label' => __('Right Sidebar Filter', 'directorist'), - ], - [ - 'value' => 'no_sidebar', - 'label' => __('Popup Filter', 'directorist'), - ], - ], - ], - 'search_result_hide_top_search_bar' => [ - 'type' => 'toggle', - 'label' => __('Hide Top Search Bar', 'directorist'), - 'value' => false, - 'show-if' => [ - 'where' => "search_result_layout", - 'conditions' => [ - ['key' => 'value', 'compare' => '!=', 'value' => 'no_sidebar'], - ], - ], - ], - 'search_result_sidebar_filter_text' => [ - 'type' => 'text', - 'label' => __('Filters Text', 'directorist'), - 'value' => __('Filters', 'directorist'), - 'show-if' => [ - 'where' => "search_result_layout", - 'conditions' => [ - ['key' => 'value', 'compare' => '!=', 'value' => 'no_sidebar'], - ], - ], - ], - 'search_result_filter_button_text' => [ - 'type' => 'text', - 'label' => __('Filters Button Text', 'directorist'), - 'value' => __('Filters', 'directorist'), - 'show-if' => [ - 'where' => "search_result_layout", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'no_sidebar'], - ], - ], - ], - 'display_search_result_listings_count' => [ - 'type' => 'toggle', - 'label' => __('Display Listings Count', 'directorist'), - 'value' => true, - 'show-if' => [ - 'where' => "search_header", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'search_result_listing_title' => [ - 'type' => 'text', - 'label' => __('Listings Count Text', 'directorist'), - 'value' => __('Items Found', 'directorist'), - 'show-if' => [ - 'where' => "search_header", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'sresult_reset_text' => [ - 'type' => 'text', - 'label' => __('Reset Button Text', 'directorist'), - 'value' => __('Reset Filters', 'directorist'), - 'show-if' => [ - 'where' => "search_result_layout", - 'conditions' => [ - [ 'key' => 'value', 'compare' => '=', 'value' => 'no_sidebar' ], - ], - ], - ], - 'sresult_sidebar_reset_text' => [ - 'type' => 'text', - 'label' => __('Reset text', 'directorist'), - 'value' => __('Clear All', 'directorist'), - 'show-if' => [ - 'where' => "search_result_layout", - 'conditions' => [ - [ 'key' => 'value', 'compare' => '!=', 'value' => 'no_sidebar' ], - ], - ], - ], - 'sresult_apply_text' => [ - 'type' => 'text', - 'label' => __('Apply Filters Button Text', 'directorist'), - 'value' => __('Apply Filters', 'directorist'), - 'show-if' => [ - 'where' => "search_result_layout", - 'conditions' => [ - [ 'key' => 'value', 'compare' => '=', 'value' => 'no_sidebar' ], - ], - ], - ], - 'search_view_as_items' => [ - 'type' => 'checkbox', - 'label' => __('View Type', 'directorist'), - 'description' => '', - 'value' => [ - 'listings_grid', - 'listings_list', - 'listings_map' - ], - 'options' => [ - [ - 'value' => 'listings_grid', - 'label' => __('Grid', 'directorist'), - ], - [ - 'value' => 'listings_list', - 'label' => __('List', 'directorist'), - ], - [ - 'value' => 'listings_map', - 'label' => __('Map', 'directorist'), - ], - ], - ], - 'search_sort_by' => [ - 'type' => 'toggle', - 'label' => __('Enable Sorting Options', 'directorist'), - 'value' => true, - ], - 'search_sortby_text' => [ - 'type' => 'text', - 'label' => __('"Sort By" Label', 'directorist'), - 'value' => __('Sort By', 'directorist'), - ], - 'search_sort_by_items' => [ - 'type' => 'checkbox', - 'label' => __('Sort Options', 'directorist'), - 'description' => '', - 'value' => [ - 'a_z', - 'z_a', - 'latest', - 'oldest', - 'popular', - 'price_low_high', - 'price_high_low', - 'random' - ], - 'options' => [ - [ - 'value' => 'a_z', - 'label' => __('A to Z (title)', 'directorist'), - ], - [ - 'value' => 'z_a', - 'label' => __('Z to A (title)', 'directorist'), - ], - [ - 'value' => 'latest', - 'label' => __('Latest listings', 'directorist'), - ], - [ - 'value' => 'oldest', - 'label' => __('Oldest listings', 'directorist'), - ], - [ - 'value' => 'popular', - 'label' => __('Popular listings', 'directorist'), - ], - [ - 'value' => 'price_low_high', - 'label' => __('Price (low to high)', 'directorist'), - ], - [ - 'value' => 'price_high_low', - 'label' => __('Price (high to low)', 'directorist'), - ], - [ - 'value' => 'random', - 'label' => __('Random listings', 'directorist'), - ], - ], - ], - 'search_listing_columns' => [ - 'label' => __('Number of Columns', 'directorist'), - 'type' => 'number', - 'value' => '3', - 'min' => '1', - 'max' => '5', - 'step' => '1', - ], - 'search_posts_num' => [ - 'label' => __('Search Results Per Page', 'directorist'), - 'type' => 'number', - 'value' => '6', - 'min' => '1', - 'max' => '100', - 'step' => '1', - ], - 'search_header' => [ - 'type' => 'toggle', - 'label' => __('Display Header', 'directorist'), - 'value' => true, - ], - 'search_result_filters_button_display' => [ - 'type' => 'toggle', - 'label' => __('Display Filters Button', 'directorist'), - 'show-if' => [ - 'where' => "search_result_layout", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'no_sidebar'], - ], - ], - 'value' => true, - ], - // upgrade/ regenerate pages - 'shortcode-updated' => [ - 'type' => 'toggle', - 'label' => __('Upgrade/Regenerate Pages', 'directorist'), - 'value' => true, - ], - // pages, links, views settings - 'add_listing_page' => [ - 'label' => __('Add Listing Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_add_listing]</div>'), - 'value' => atbdp_get_option('add_listing_page', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'all_listing_page' => [ - 'label' => __('All Listings Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_all_listing]</div>'), - 'value' => atbdp_get_option('all_listing_page', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'user_dashboard' => [ - 'label' => __('Dashboard Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_user_dashboard]</div>'), - 'value' => atbdp_get_option('user_dashboard', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'signin_signup_page' => [ - 'label' => __( 'Sign In & Signup Page', 'directorist' ), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_signin_signup]</div>'), - 'value' => atbdp_get_option( 'signin_signup_page', 'atbdp_general' ), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'author_profile_page' => [ - 'label' => __('User Profile Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_author_profile]</div>'), - 'value' => atbdp_get_option('author_profile', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'all_categories_page' => [ - 'label' => __('All Categories Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_all_categories]</div>'), - 'value' => atbdp_get_option('all_categories', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'single_category_page' => [ - 'label' => __('Single Category Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_category]</div>'), - 'value' => atbdp_get_option('single_category_page', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'all_locations_page' => [ - 'label' => __('All Locations Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_all_locations]</div>'), - 'value' => atbdp_get_option('all_locations', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'single_location_page' => [ - 'label' => __('Single Location Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_location]</div>'), - 'value' => atbdp_get_option('single_location_page', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'single_tag_page' => [ - 'label' => __('Single Tag Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_tag]</div>'), - 'value' => atbdp_get_option('single_tag_page', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'custom_registration' => [ - 'label' => __('Registration Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_custom_registration]</div>'), - 'value' => atbdp_get_option('custom_registration', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'user_login' => [ - 'label' => __('Login Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_user_login]</div>'), - 'value' => atbdp_get_option('user_login', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'search_listing' => [ - 'label' => __('Listing Search Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_search_listing]</div>'), - 'value' => atbdp_get_option('search_listing', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'search_result_page' => [ - 'label' => __('Listing Search Result Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_search_result]</div>'), - 'value' => atbdp_get_option('search_result_page', 'atbdp_general'), - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'checkout_page' => [ - 'label' => __('Checkout Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_checkout]</div>'), - 'value' => '', - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'payment_receipt_page' => [ - 'label' => __('Payment/Order Receipt Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_payment_receipt]</div>'), - 'value' => '', - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - 'transaction_failure_page' => [ - 'label' => __('Transaction Failure Page', 'directorist'), - 'type' => 'select', - 'description' => sprintf(__('Following shortcode must be in the selected page %s', 'directorist'), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_transaction_failure]</div>'), - 'value' => '', - 'showDefaultOption' => true, - 'options' => $this->get_pages_vl_arrays(), - ], - // seo settings - 'atbdp_enable_seo' => [ - 'type' => 'toggle', - 'label' => __('Enable SEO', 'directorist'), - 'value' => true, - ], - 'add_listing_page_meta_title' => [ - 'type' => 'text', - 'label' => __('Add Listing Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'add_listing_page_meta_desc' => [ - 'type' => 'text', - 'label' => __('Add Listing Page Meta Description', 'directorist'), - 'value' => '', - ], - 'all_listing_meta_title' => [ - 'type' => 'text', - 'label' => __('All Listing Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'all_listing_meta_desc' => [ - 'type' => 'text', - 'label' => __('All Listing Page Meta Description', 'directorist'), - 'value' => '', - ], - 'dashboard_meta_title' => [ - 'type' => 'text', - 'label' => __('User Dashboard Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'dashboard_meta_desc' => [ - 'type' => 'text', - 'label' => __('Dashboard Page Meta Description', 'directorist'), - 'value' => '', - ], - 'author_profile_meta_title' => [ - 'type' => 'text', - 'label' => __('Author Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'author_page_meta_desc' => [ - 'type' => 'text', - 'label' => __('Author Page Meta Description', 'directorist'), - 'value' => '', - ], - 'category_meta_title' => [ - 'type' => 'text', - 'label' => __('Category Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'category_meta_desc' => [ - 'type' => 'text', - 'label' => __('Category Page Meta Description', 'directorist'), - 'value' => '', - ], - 'single_category_meta_title' => [ - 'type' => 'text', - 'label' => __('Single Category Page Meta Title', 'directorist'), - 'description' => __('Default the title of the category.', 'directorist'), - 'value' => '', - ], - 'single_category_meta_desc' => [ - 'type' => 'text', - 'label' => __('Single Category Page Meta Description', 'directorist'), - 'description' => __('Leave it blank to set category\'s description as meta description of this page', 'directorist'), - 'value' => '', - ], - 'all_locations_meta_title' => [ - 'type' => 'text', - 'label' => __('All Locations Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'all_locations_meta_desc' => [ - 'type' => 'text', - 'label' => __('All Locations Page Meta Description', 'directorist'), - 'value' => '', - ], - 'single_locations_meta_title' => [ - 'type' => 'text', - 'label' => __('Single Location Page Meta Title', 'directorist'), - 'description' => __('Default the title of the location.', 'directorist'), - 'value' => '', - ], - 'single_locations_meta_desc' => [ - 'type' => 'text', - 'label' => __('Single Locations Page Meta Description', 'directorist'), - 'description' => __('Leave it blank to set location\'s description as meta description of this page', 'directorist'), - 'value' => '', - ], - 'registration_meta_title' => [ - 'type' => 'text', - 'label' => __('Registration Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'registration_meta_desc' => [ - 'type' => 'text', - 'label' => __('Registration Page Meta Description', 'directorist'), - 'value' => '', - ], - 'login_meta_title' => [ - 'type' => 'text', - 'label' => __('Login Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'login_meta_desc' => [ - 'type' => 'text', - 'label' => __('Login Page Meta Description', 'directorist'), - 'value' => '', - ], - 'homepage_meta_title' => [ - 'type' => 'text', - 'label' => __('Search Home Page Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - ], - 'homepage_meta_desc' => [ - 'type' => 'text', - 'label' => __('Search Home Page Meta Description', 'directorist'), - 'value' => '', - ], - 'meta_title_for_search_result' => [ - 'label' => __('Search Result Page Meta Title', 'directorist'), - 'type' => 'select', - 'value' => 'searched_value', - 'options' => [ - [ - 'value' => 'searched_value', - 'label' => __('From User Search', 'directorist'), - ], - [ - 'value' => 'custom', - 'label' => __('Custom', 'directorist'), - ], - ], - ], - 'search_result_meta_title' => [ - 'type' => 'text', - 'label' => __('Custom Meta Title', 'directorist'), - 'description' => __('Default the title of the page set as frontpage.', 'directorist'), - 'value' => '', - 'show-if' => [ - 'where' => "meta_title_for_search_result", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'custom'], - ], - ], - ], - 'search_result_meta_desc' => [ - 'type' => 'text', - 'label' => __('Search Result Page Meta Description', 'directorist'), - 'value' => '', - ], - //currency settings - 'g_currency_note' => [ - 'type' => 'note', - 'title' => __('Note:', 'directorist'), - 'description' => __('Customize how prices are displayed on your site. To accept payments in a different currency, visit Monetization → General Settings', 'directorist'), - ], - 'g_currency' => [ - 'type' => 'text', - 'label' => __('Currency Code', 'directorist'), - 'description' => sprintf( - __( 'Enter the 3-letter currency code (e.g., USD for US Dollar). For a full list of currency codes, refer to %s.', 'directorist' ), - "<a href='" . esc_url( 'https://www.iban.com/currency-codes' ) . "'>" . __( 'ISO 4217 Currency Codes', 'directorist' ) . "</a>" - ), - 'value' => 'USD', - ], - 'g_currency_position' => [ - 'label' => __('Currency Position', 'directorist'), - 'type' => 'select', - 'value' => 'before', - 'description' => __( "Select where you'd like the currency symbol to appear. The default is before the amount (e.g., $5)", 'directorist' ), - 'options' => [ - [ - 'value' => 'before', - 'label' => __('$5 - Before', 'directorist'), - ], - [ - 'value' => 'after', - 'label' => __('After - 5$', 'directorist'), - ], - ], - ], - // categories settings - 'display_categories_as' => [ - 'label' => __('Default View', 'directorist'), - 'type' => 'select', - 'value' => 'grid', - 'options' => [ - [ - 'value' => 'grid', - 'label' => __('Grid', 'directorist'), - ], - [ - 'value' => 'list', - 'label' => __('List', 'directorist'), - ], - ], - ], - 'categories_column_number' => [ - 'label' => __('Number of Columns', 'directorist'), - 'description' => __('Set how many columns to display on categories page.', 'directorist'), - 'type' => 'select', - 'value' => '4', - 'options' => [ - [ - 'value' => 1, - 'label' => 1, - ], - [ - 'value' => 2, - 'label' => 2, - ], - [ - 'value' => 3, - 'label' => 3, - ], - [ - 'value' => 4, - 'label' => 4, - ], - [ - 'value' => 5, - 'label' => 5, - ], - [ - 'value' => 6, - 'label' => 6, - ], - ], - ], - 'categories_depth_number' => [ - 'label' => __('Sub-category Depth', 'directorist'), - 'description' => __('Set how many sub-categories to display.', 'directorist'), - 'type' => 'number', - 'value' => '4', - 'min' => '1', - 'max' => '15', - 'step' => '2', - 'show-if' => [ - 'where' => "display_categories_as", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'list'], - ], - ], - ], - 'order_category_by' => [ - 'label' => __('Order By', 'directorist'), - 'type' => 'select', - 'value' => 'id', - 'options' => [ - [ - 'value' => 'id', - 'label' => __('ID', 'directorist'), - ], - [ - 'value' => 'count', - 'label' => __('Count', 'directorist'), - ], - [ - 'value' => 'name', - 'label' => __('Name', 'directorist'), - ], - [ - 'value' => 'slug', - 'label' => __('Slug', 'directorist'), - ], - ], - ], - 'sort_category_by' => [ - 'label' => __('Sort By', 'directorist'), - 'type' => 'select', - 'value' => 'asc', - 'options' => [ - [ - 'value' => 'asc', - 'label' => __('Ascending', 'directorist'), - ], - [ - 'value' => 'desc', - 'label' => __('Descending', 'directorist'), - ], - ], - ], - 'display_listing_count' => [ - 'label' => __('Display Listing Count', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'hide_empty_categories' => [ - 'label' => __('Hide Empty Categories', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - // locations settings - 'display_locations_as' => [ - 'label' => __('Default View', 'directorist'), - 'type' => 'select', - 'value' => 'grid', - 'options' => [ - [ - 'value' => 'grid', - 'label' => __('Grid', 'directorist'), - ], - [ - 'value' => 'list', - 'label' => __('List', 'directorist'), - ], - ], - ], - 'locations_column_number' => [ - 'label' => __('Number of Columns', 'directorist'), - 'description' => __('Set how many columns to display on locations page.', 'directorist'), - 'type' => 'select', - 'value' => '4', - 'options' => [ - [ - 'value' => 1, - 'label' => 1, - ], - [ - 'value' => 2, - 'label' => 2, - ], - [ - 'value' => 3, - 'label' => 3, - ], - [ - 'value' => 4, - 'label' => 4, - ], - [ - 'value' => 5, - 'label' => 5, - ], - [ - 'value' => 6, - 'label' => 6, - ], - ], - ], - 'locations_depth_number' => [ - 'label' => __('Sub-location Depth', 'directorist'), - 'description' => __('Set how many sub-locations to display.', 'directorist'), - 'type' => 'number', - 'value' => '4', - 'min' => '1', - 'max' => '15', - 'step' => '2', - 'show-if' => [ - 'where' => "display_locations_as", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'list'], - ], - ], - ], - 'order_location_by' => [ - 'label' => __('Order By', 'directorist'), - 'type' => 'select', - 'value' => 'id', - 'options' => [ - [ - 'value' => 'id', - 'label' => __('ID', 'directorist'), - ], - [ - 'value' => 'count', - 'label' => __('Count', 'directorist'), - ], - [ - 'value' => 'name', - 'label' => __('Name', 'directorist'), - ], - [ - 'value' => 'slug', - 'label' => __('Slug', 'directorist'), - ], - ], - ], - 'sort_location_by' => [ - 'label' => __('Sort By', 'directorist'), - 'type' => 'select', - 'value' => 'asc', - 'options' => [ - [ - 'value' => 'asc', - 'label' => __('Ascending', 'directorist'), - ], - [ - 'value' => 'desc', - 'label' => __('Descending', 'directorist'), - ], - ], - ], - 'display_location_listing_count' => [ - 'label' => __('Display Listing Count', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'hide_empty_locations' => [ - 'label' => __('Hide Empty Locations', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - // registration settings - 'new_user_registration' => [ - 'label' => __('Enable Registration', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'enable_email_verification' => [ - 'label' => __('Enable Email Verification', 'directorist'), - 'type' => 'toggle', - 'value' => false, - 'description' => sprintf(__('Enable email verification to verify user email during registration. To view the verification status navigate to Users → %s.', 'directorist'), "<a href='" . admin_url('users.php') . "'>" . __('All Users', 'directorist') . "</a>") - ], - 'reg_username' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('Username', 'directorist'), - ], - 'display_password_reg' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'reg_password' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('Password', 'directorist'), - 'show-if' => [ - 'where' => "display_password_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'require_password_reg' => [ - 'label' => __('Required', 'directorist'), - 'type' => 'toggle', - 'value' => true, - 'show-if' => [ - 'where' => "display_password_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'reg_email' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('Email', 'directorist'), - ], - 'display_website_reg' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - 'reg_website' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('Website', 'directorist'), - 'show-if' => [ - 'where' => "display_website_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'require_website_reg' => [ - 'label' => __('Required', 'directorist'), - 'type' => 'toggle', - 'value' => false, - 'show-if' => [ - 'where' => "display_website_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_fname_reg' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - 'reg_fname' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('First Name', 'directorist'), - 'show-if' => [ - 'where' => "display_fname_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'require_fname_reg' => [ - 'label' => __('Required', 'directorist'), - 'type' => 'toggle', - 'value' => false, - 'show-if' => [ - 'where' => "display_fname_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_lname_reg' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - 'reg_lname' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('Last Name', 'directorist'), - 'show-if' => [ - 'where' => "display_lname_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'require_lname_reg' => [ - 'label' => __('Required', 'directorist'), - 'type' => 'toggle', - 'value' => false, - 'show-if' => [ - 'where' => "display_lname_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_bio_reg' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - 'reg_bio' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('About/bio', 'directorist'), - 'show-if' => [ - 'where' => "display_bio_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'require_bio_reg' => [ - 'label' => __('Required', 'directorist'), - 'type' => 'toggle', - 'value' => false, - 'show-if' => [ - 'where' => "display_bio_reg", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'registration_privacy' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'registration_privacy_label' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('I agree to the', 'directorist'), - 'show-if' => [ - 'where' => "registration_privacy", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'registration_privacy_label_link' => [ - 'type' => 'text', - 'label' => __('Linking Text', 'directorist'), - 'value' => __('Privacy & Policy', 'directorist'), - 'show-if' => [ - 'where' => "registration_privacy", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'regi_terms_condition' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'regi_terms_label' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('I agree with all', 'directorist'), - 'show-if' => [ - 'where' => "regi_terms_condition", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'regi_terms_label_link' => [ - 'type' => 'text', - 'label' => __('Linking Text', 'directorist'), - 'value' => __('terms & conditions', 'directorist'), - 'show-if' => [ - 'where' => "regi_terms_condition", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_user_type' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - 'reg_signup' => [ - 'type' => 'text', - 'label' => __('Text', 'directorist'), - 'value' => __('Sign Up', 'directorist'), - ], - 'display_login' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'login_text' => [ - 'type' => 'text', - 'label' => __('Text', 'directorist'), - 'value' => __('Already have an account?', 'directorist'), - 'show-if' => [ - 'where' => "display_login", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'log_linkingmsg' => [ - 'type' => 'text', - 'label' => __('Linking Text', 'directorist'), - 'value' => __('Login', 'directorist'), - 'show-if' => [ - 'where' => "display_login", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'auto_login' => [ - 'label' => __('Auto Login after Registration', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - 'redirection_after_reg' => [ - 'label' => __('Redirection after Registration', 'directorist'), - 'type' => 'select', - 'value' => get_directorist_option( 'signin_signup_page' ), - 'options' => $this->get_pages_with_prev_page(), - ], - // login settings - 'log_username' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('Username or Email Address', 'directorist'), - ], - 'log_password' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('Password', 'directorist'), - ], - 'display_rememberme' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'log_rememberme' => [ - 'type' => 'text', - 'label' => __('Label', 'directorist'), - 'value' => __('Remember Me', 'directorist'), - 'show-if' => [ - 'where' => "display_rememberme", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'log_button' => [ - 'type' => 'text', - 'label' => __('Text', 'directorist'), - 'value' => __('Log In', 'directorist'), - ], - 'display_signup' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'reg_text' => [ - 'type' => 'textarea', - 'label' => __('Text', 'directorist'), - 'value' => __("Don't have an account?", 'directorist'), - 'show-if' => [ - 'where' => "display_signup", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'reg_linktxt' => [ - 'type' => 'text', - 'label' => __('Linking Text', 'directorist'), - 'value' => __('Sign Up', 'directorist'), - 'show-if' => [ - 'where' => "display_signup", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'display_recpass' => [ - 'label' => __('Enable', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'recpass_text' => [ - 'type' => 'text', - 'label' => __('Name', 'directorist'), - 'value' => __('Recover Password', 'directorist'), - 'show-if' => [ - 'where' => "display_recpass", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'recpass_desc' => [ - 'type' => 'textarea', - 'label' => __('Description', 'directorist'), - 'value' => __('Lost your password? Please enter your email address. You will receive a link to create a new password via email.', 'directorist'), - 'show-if' => [ - 'where' => "display_recpass", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'recpass_username' => [ - 'type' => 'text', - 'label' => __('Email Label', 'directorist'), - 'value' => __('E-mail', 'directorist'), - 'show-if' => [ - 'where' => "display_recpass", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'recpass_placeholder' => [ - 'type' => 'text', - 'label' => __('Username or Email Placeholder', 'directorist'), - 'value' => __('eg. mail@example.com', 'directorist'), - 'show-if' => [ - 'where' => "display_recpass", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'recpass_button' => [ - 'type' => 'text', - 'label' => __('Button Text', 'directorist'), - 'value' => __('Get New Password', 'directorist'), - 'show-if' => [ - 'where' => "display_recpass", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'redirection_after_login' => [ - 'label' => __('Redirection after Login', 'directorist'), - 'type' => 'select', - 'value' => 'previous_page', - 'options' => $this->get_pages_with_prev_page(), - ], - // email general settings - 'disable_email_notification' => [ - 'label' => __('Disable all Email Notifications', 'directorist'), - 'type' => 'toggle', - 'value' => false, - ], - 'email_from_name' => [ - 'type' => 'text', - 'label' => __('Sender Name for Emails', 'directorist'), - 'description' => __('The name that will appear as the sender in emails generated by Directorist.', 'directorist'), - 'value' => get_option('blogname'), - 'show-if' => [ - 'where' => "disable_email_notification", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - ], - 'email_from_email' => [ - 'type' => 'text', - 'label' => __('Sender Email Address', 'directorist'), - 'description' => __('The email address that will appear as the sender in emails generated by Directorist.', 'directorist'), - 'value' => get_option('admin_email'), - 'show-if' => [ - 'where' => "disable_email_notification", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - ], - 'admin_email_lists' => [ - 'type' => 'textarea', - 'label' => __('Admin Email Address(es) for Notifications', 'directorist'), - 'description' => __('Enter one or more email addresses (comma-separated) where admin notifications will be sent. Example: admin1@example.com, admin2@example.com.', 'directorist'), - 'value' => get_option('admin_email'), - 'show-if' => [ - 'where' => "disable_email_notification", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - ], - 'notify_admin' => [ - 'label' => __('Notify the Admin when Any of the Selected Event Happens', 'directorist'), - 'type' => 'checkbox', - 'value' => $this->default_events_to_notify_admin(), - 'options' => $this->events_to_notify_admin(), - 'description' => __('Select the situation when you would like to send an email to the Admin', 'directorist'), - 'show-if' => [ - 'where' => "disable_email_notification", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - ], - 'notify_user' => [ - 'label' => __('Notify the Listing Owner when Any of the Selected Event Happens', 'directorist'), - 'type' => 'checkbox', - 'value' => $this->default_events_to_notify_user(), - 'options' => $this->events_to_notify_user(), - 'description' => __('Select the situation when you would like to send an email to the Listing', 'directorist'), - 'show-if' => [ - 'where' => "disable_email_notification", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => false], - ], - ], - ], - // email templates settings - 'allow_email_header' => [ - 'label' => __('Email Header', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'email_header_color' => [ - 'type' => 'color', - 'label' => __('Email Header Color', 'directorist'), - 'value' => '#8569fb', - 'show-if' => [ - 'where' => "allow_email_header", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - 'email_sub_new_listing' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when a listing is submitted/received.', 'directorist'), - 'value' => __('[==SITE_NAME==] : Listing "==LISTING_TITLE==" Received', 'directorist'), - ], - 'email_tmpl_new_listing' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when a listing is submitted/received. HTML content is allowed too.', 'directorist'), - 'value' => __(" + <a href="%s" target="_blank">Watch how</a>', + 'directorist' + ), + esc_url( '' ) // Replace with your URL + ), + 'show-if' => array( + 'where' => 'enable_monetization', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + + 'featured_listing_desc' => array( + 'type' => 'textarea', + 'label' => __( 'Listing Description at Checkout', 'directorist' ), + 'show-if' => array( + 'where' => 'enable_featured_listing', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + 'value' => __( 'You are about to feature your listing, promoting it to the top of search results and listings pages for enhanced visibility.', 'directorist' ), + ), + + 'featured_listing_price' => array( + 'label' => __( 'Featured Listing Fee', 'directorist' ), + 'type' => 'number', + 'min' => 0, + 'step' => '0.01', + 'value' => 19.99, + 'description' => __( 'Set the amount you want to charge users for featuring their listing.', 'directorist' ), + 'show-if' => array( + 'where' => 'enable_featured_listing', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + + 'featured_listing_time' => array( + 'label' => __( 'Featured Listing Duration (in Days)', 'directorist' ), + 'description' => __( 'Set how many days a listing stays featured', 'directorist' ), + 'type' => 'number', + 'value' => 30, + 'show-if' => array( + 'where' => 'enable_featured_listing', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + + 'active_gateways' => array( + 'label' => __( 'Payment Methods', 'directorist' ), + 'type' => 'checkbox', + 'value' => array( 'bank_transfer' ), + 'options' => apply_filters( + 'directorist_active_gateways', + array( + array( + 'value' => 'bank_transfer', + 'label' => __( 'Bank Transfer (Offline Gateway)', 'directorist' ), + ), + ) + ), + 'description' => __( 'Check the gateway(s) you would like to use to collect payment from your users. A user will be use any of the active gateways during the checkout process ', 'directorist' ), + ), + + 'default_gateway' => array( + 'label' => __( 'Default Gateway', 'directorist' ), + 'type' => 'select', + 'value' => 'bank_transfer', + 'options' => apply_filters( + 'atbdp_default_gateways', + array( + array( + 'value' => 'bank_transfer', + 'label' => __( 'Bank Transfer (Offline Gateway)', 'directorist' ), + ), + ) + ), + 'description' => __( 'Select the default gateway you would like to show as a selected gateway on the checkout page', 'directorist' ), + ), + + 'payment_currency_note' => array( + 'type' => 'note', + 'title' => __( 'Note About This Currency Settings:', 'directorist' ), + 'description' => __( 'This currency settings lets you customize how you would like to accept payment from your user/customer and how to display pricing on the order form/history.', 'directorist' ), + ), + + 'payment_currency' => array( + 'type' => 'text', + 'label' => __( 'Currency Code', 'directorist' ), + 'value' => __( 'USD', 'directorist' ), + 'description' => sprintf( + __( 'Enter the 3-letter currency code (e.g., USD for US Dollar). For a full list of currency codes, refer to %s.', 'directorist' ), + "<a href='" . esc_url( 'https://www.iban.com/currency-codes' ) . "'>" . __( 'ISO 4217 Currency Codes', 'directorist' ) . '</a>' + ), + ), + + 'payment_thousand_separator' => array( + 'type' => 'text', + 'label' => __( 'Thousand Separator', 'directorist' ), + 'value' => __( ',', 'directorist' ), + 'description' => __( 'Enter the currency thousand separator. Eg. , or . etc.', 'directorist' ), + ), + + 'payment_decimal_separator' => array( + 'type' => 'text', + 'label' => __( 'Decimal Separator', 'directorist' ), + 'value' => __( '.', 'directorist' ), + 'description' => __( 'Enter the currency decimal separator. Eg. "." or ",". Default is "."', 'directorist' ), + ), + + 'payment_currency_position' => array( + 'label' => __( 'Currency Position', 'directorist' ), + 'type' => 'select', + 'value' => 'before', + 'options' => array( + array( + 'value' => 'before', + 'label' => __( '$5 - Before', 'directorist' ), + ), + array( + 'value' => 'after', + 'label' => __( 'After - 5$', 'directorist' ), + ), + ), + 'description' => __( 'Select where you would like to show the currency symbol. Default is before. Eg. $5', 'directorist' ), + ), + + // gateway settings + 'offline_payment_note' => array( + 'type' => 'note', + 'title' => __( 'Note About Bank Transfer Gateway:', 'directorist' ), + 'description' => __( 'You should remember that this payment gateway needs some manual action to complete an order. After getting notification of order using this offline payment gateway, you should check your bank if the money is deposited to your account. Then you should change the order status manually from the "Order History" submenu.', 'directorist' ), + ), + + 'bank_transfer_title' => array( + 'type' => 'text', + 'label' => __( 'Gateway Title', 'directorist' ), + 'value' => __( 'Bank Transfer', 'directorist' ), + 'description' => __( 'Enter the title of this gateway that should be displayed to the user on the front end.', 'directorist' ), + ), + + 'bank_transfer_description' => array( + 'type' => 'textarea', + 'label' => __( 'Gateway Description', 'directorist' ), + 'value' => $bank_payment_desc, + 'description' => __( 'Enter some description for your user to transfer funds to your account.', 'directorist' ), + ), + + 'bank_transfer_instruction' => array( + 'type' => 'textarea', + 'label' => __( 'Bank Information', 'directorist' ), + 'value' => $bank_transfer_instruction, + 'description' => __( 'Enter your bank information below so that use can make payment directly to your bank account.', 'directorist' ), + ), + + // extension setting + 'extension_promotion' => array( + 'type' => 'note', + 'title' => __( 'Need more Features?', 'directorist' ), + 'description' => sprintf( __( 'You can add new features and expand the functionality of the plugin even more by using extensions. %s', 'directorist' ), $this->extension_url ), + ), + + 'announcement_to' => array( + 'label' => __( 'To', 'directorist' ), + 'type' => 'select', + 'value' => 'all_user', + 'options' => array( + array( + 'value' => 'all_user', + 'label' => __( 'All User', 'directorist' ), + ), + array( + 'value' => 'selected_user', + 'label' => __( 'Selected User', 'directorist' ), + ), + ), + ), + + 'announcement_subject' => array( + 'label' => __( 'Subject', 'directorist' ), + 'type' => 'text', + 'value' => false, + ), + + 'announcement_send_to_email' => array( + 'label' => __( 'Send a copy to email', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + + // Button Type + 'button_type' => array( + 'label' => __( 'Button Type', 'directorist' ), + 'type' => 'select', + 'value' => 'select_option', + 'show-default-option' => true, + 'options' => array( + array( + 'value' => 'button_type_primary', + 'label' => __( 'Primary', 'directorist' ), + ), + array( + 'value' => 'button_type_secondary', + 'label' => __( 'Secondary', 'directorist' ), + ), + ), + ), + + // Primary Button + 'button_primary_example' => array( + 'label' => __( 'Button Example', 'directorist' ), + 'description' => __( 'Modify the color of primary buttons like Save & Preview, Search, etc to match your design preferences', 'directorist' ), + 'type' => 'button-example', + 'button-class' => 'directorist-btn-primary', + 'button-label' => __( 'Primary', 'directorist' ), + 'show-if' => array( + 'where' => 'button_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'button_type_primary', + ), + ), + ), + ), + 'button_primary_color' => array( + 'label' => __( 'Text Color', 'directorist' ), + 'type' => 'color', + 'value' => '#ffffff', + 'show-if' => array( + 'where' => 'button_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'button_type_primary', + ), + ), + ), + ), + 'button_primary_bg_color' => array( + 'label' => __( 'Background Color', 'directorist' ), + 'type' => 'color', + 'value' => '#444752', + 'show-if' => array( + 'where' => 'button_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'button_type_primary', + ), + ), + ), + ), + + // Secondary Button + 'button_secondary_example' => array( + 'label' => __( 'Button Example', 'directorist' ), + 'description' => __( 'Modify the color of secondary buttons like Logout, etc to match your design preferences', 'directorist' ), + 'type' => 'button-example', + 'button-class' => 'directorist-btn-secondary', + 'button-label' => __( 'Secondary', 'directorist' ), + 'show-if' => array( + 'where' => 'button_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'button_type_secondary', + ), + ), + ), + ), + 'button_secondary_color' => array( + 'label' => __( 'Text Color', 'directorist' ), + 'type' => 'color', + 'value' => '#404040', + 'show-if' => array( + 'where' => 'button_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'button_type_secondary', + ), + ), + ), + ), + 'button_secondary_bg_color' => array( + 'label' => __( 'Background Color', 'directorist' ), + 'type' => 'color', + 'value' => '#f2f3f5', + 'show-if' => array( + 'where' => 'button_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'button_type_secondary', + ), + ), + ), + ), + // Badge Color + 'featured_back_color' => array( + 'type' => 'color', + 'label' => __( 'Background Color', 'directorist' ), + 'value' => '#fa8b0c', + 'change-if' => array( + 'where' => 'feature_badge_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'icon_badge', + ), + ), + 'effects' => array( + array( + 'key' => 'label', + 'value' => __( 'Hover Background Color', 'directorist' ), + 'default_value' => __( 'Background Color', 'directorist' ), + ), + ), + ), + ), + + 'popular_back_color' => array( + 'type' => 'color', + 'label' => __( 'Background Color', 'directorist' ), + 'value' => '#f51957', + ), + + 'new_back_color' => array( + 'type' => 'color', + 'label' => __( 'Background Color', 'directorist' ), + 'value' => '#2C99FF', + ), + + // Map Marker Color + 'marker_shape_color' => array( + 'type' => 'color', + 'label' => __( 'Marker Shape Color', 'directorist' ), + 'value' => '#444752', + ), + + 'marker_icon_color' => array( + 'type' => 'color', + 'label' => __( 'Marker Icon Color', 'directorist' ), + 'value' => '#ffffff', + ), + + // Primary Color + 'brand_color' => array( + 'type' => 'color', + 'label' => __( 'Brand Color', 'directorist' ), + 'value' => '#444752', + ), + + // Email + 'email_to_expire_day' => array( + 'label' => __( 'When to send expire notice', 'directorist' ), + 'type' => 'number', + 'description' => __( 'Select the days before a listing expires to send an expiration reminder email', 'directorist' ), + 'value' => 7, + 'placeholder' => '10', + 'rules' => array( + 'required' => true, + ), + ), + 'email_renewal_day' => array( + 'label' => __( 'When to send renewal reminder', 'directorist' ), + 'type' => 'number', + 'description' => __( 'Select the days after a listing expires to send a renewal reminder email', 'directorist' ), + 'value' => 7, + 'placeholder' => '10', + 'rules' => array( + 'required' => true, + ), + ), + 'delete_expired_listing_permanently' => array( + 'label' => __( 'Permanently Delete Expired Listings', 'directorist' ), + 'type' => 'toggle', + 'description' => __( 'Automatically delete trashed listings permanently after the defined duration', 'directorist' ), + 'value' => true, + ), + 'delete_expired_listings_after' => array( + 'label' => __( 'Permanently Delete After (days) of Expiration', 'directorist' ), + 'type' => 'number', + 'value' => 15, + 'placeholder' => '15', + 'rules' => array( + 'required' => true, + ), + ), + 'paginate_author_listings' => array( + 'label' => __( 'Paginate Author Listings', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'atbdp_enable_cache' => array( + 'label' => __( 'Enable Cache', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'atbdp_reset_cache' => array( + 'label' => __( 'Reset Cache', 'directorist' ), + 'type' => 'toggle', + 'show-if' => array( + 'where' => 'atbdp_enable_cache', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + 'value' => false, + ), + 'guest_listings' => array( + 'label' => __( 'Guest Listing Submission', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'guest_email_label' => array( + 'type' => 'text', + 'label' => __( 'Guest Email Label', 'directorist' ), + 'value' => __( 'Your Email', 'directorist' ), + 'show-if' => array( + 'where' => 'guest_listings', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'guest_email_placeholder' => array( + 'type' => 'text', + 'label' => __( 'Guest Email Placeholder', 'directorist' ), + 'value' => __( 'example@email.com', 'directorist' ), + 'show-if' => array( + 'where' => 'guest_listings', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + + // listings page + 'all_listing_layout' => array( + 'label' => __( 'All Listings Layout', 'directorist' ), + 'type' => 'select', + 'value' => 'left_sidebar', + 'options' => array( + array( + 'value' => 'left_sidebar', + 'label' => __( 'Left Sidebar Filter', 'directorist' ), + ), + array( + 'value' => 'right_sidebar', + 'label' => __( 'Right Sidebar Filter', 'directorist' ), + ), + array( + 'value' => 'no_sidebar', + 'label' => __( 'Popup Filter', 'directorist' ), + ), + ), + ), + + 'listing_hide_top_search_bar' => array( + 'type' => 'toggle', + 'label' => __( 'Hide Top Search Bar', 'directorist' ), + 'value' => false, + 'show-if' => array( + 'where' => 'all_listing_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '!=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'listings_sidebar_filter_text' => array( + 'type' => 'text', + 'label' => __( 'Filters Text', 'directorist' ), + 'value' => __( 'Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'all_listing_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '!=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'listings_filter_button_text' => array( + 'type' => 'text', + 'label' => __( 'Filters Button Text', 'directorist' ), + 'value' => __( 'Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'all_listing_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'display_listings_count' => array( + 'type' => 'toggle', + 'label' => __( 'Display Listings Count', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_listings_header', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'all_listing_title' => array( + 'type' => 'text', + 'label' => __( 'Listings Count Text', 'directorist' ), + 'value' => __( 'Items Found', 'directorist' ), + 'show-if' => array( + 'where' => 'display_listings_header', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'listings_reset_text' => array( + 'type' => 'text', + 'label' => __( 'Reset Button text', 'directorist' ), + 'value' => __( 'Reset Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'all_listing_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'listings_sidebar_reset_text' => array( + 'type' => 'text', + 'label' => __( 'Reset text', 'directorist' ), + 'value' => __( 'Clear All', 'directorist' ), + 'show-if' => array( + 'where' => 'all_listing_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '!=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'listings_apply_text' => array( + 'type' => 'text', + 'label' => __( 'Apply Button text', 'directorist' ), + 'value' => __( 'Apply Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'all_listing_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + + 'display_sort_by' => array( + 'type' => 'toggle', + 'label' => __( 'Enable Sorting Options', 'directorist' ), + 'value' => true, + ), + 'sort_by_text' => array( + 'type' => 'text', + 'label' => __( '"Sort By" Label', 'directorist' ), + 'value' => __( 'Sort By', 'directorist' ), + 'show-if' => array( + 'where' => 'display_sort_by', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'listings_sort_by_items' => array( + 'label' => __( 'Sort Options', 'directorist' ), + 'type' => 'checkbox', + 'value' => array( + 'a_z', + 'z_a', + 'latest', + 'oldest', + 'popular', + 'price_low_high', + 'price_high_low', + 'random', + ), + 'options' => array( + array( + 'value' => 'a_z', + 'label' => __( 'A to Z (title)', 'directorist' ), + ), + array( + 'value' => 'z_a', + 'label' => __( 'Z to A (title)', 'directorist' ), + ), + array( + 'value' => 'latest', + 'label' => __( 'Latest listings', 'directorist' ), + ), + array( + 'value' => 'oldest', + 'label' => __( 'Oldest listings', 'directorist' ), + ), + array( + 'value' => 'popular', + 'label' => __( 'Popular listings', 'directorist' ), + ), + array( + 'value' => 'price_low_high', + 'label' => __( 'Price (low to high)', 'directorist' ), + ), + array( + 'value' => 'price_high_low', + 'label' => __( 'Price (high to low)', 'directorist' ), + ), + array( + 'value' => 'random', + 'label' => __( 'Random listings', 'directorist' ), + ), + ), + ), + 'listings_view_as_items' => array( + 'label' => __( 'View Type', 'directorist' ), + 'type' => 'checkbox', + 'value' => array( + 'listings_grid', + 'listings_list', + 'listings_map', + ), + 'options' => array( + array( + 'value' => 'listings_grid', + 'label' => __( 'Grid', 'directorist' ), + ), + array( + 'value' => 'listings_list', + 'label' => __( 'List', 'directorist' ), + ), + array( + 'value' => 'listings_map', + 'label' => __( 'Map', 'directorist' ), + ), + ), + ), + 'default_listing_view' => array( + 'label' => __( 'Default View', 'directorist' ), + 'type' => 'select', + 'value' => 'grid', + 'options' => array( + array( + 'value' => 'grid', + 'label' => __( 'Grid', 'directorist' ), + ), + array( + 'value' => 'list', + 'label' => __( 'List', 'directorist' ), + ), + array( + 'value' => 'map', + 'label' => __( 'Map', 'directorist' ), + ), + ), + ), + 'all_listing_columns' => array( + 'label' => __( 'Listings Columns', 'directorist' ), + 'type' => 'number', + 'value' => 2, + 'placeholder' => '3', + ), + 'preview_image_quality' => array( + 'label' => __( 'Image Quality', 'directorist' ), + 'type' => 'select', + 'value' => 'directorist_preview', + 'options' => array( + array( + 'value' => 'directorist_preview', + 'label' => __( 'Default', 'directorist' ), + ), + array( + 'value' => 'medium', + 'label' => __( 'Medium', 'directorist' ), + ), + array( + 'value' => 'large', + 'label' => __( 'Large', 'directorist' ), + ), + array( + 'value' => 'full', + 'label' => __( 'Full', 'directorist' ), + ), + ), + 'description' => sprintf( __( 'Default: %1$s.<br/>If changed, regenerate thumbnails via <a href="%2$s" target="_blank">this</a> plugin for proper functionality.', 'directorist' ), $default_preview_size_text, 'https://wordpress.org/plugins/regenerate-thumbnails/' ), + ), + 'way_to_show_preview' => array( + 'label' => __( 'Image Size', 'directorist' ), + 'type' => 'select', + 'value' => 'cover', + + 'options' => array( + array( + 'value' => 'full', + 'label' => __( 'Original', 'directorist' ), + ), + array( + 'value' => 'cover', + 'label' => __( 'Fill with Container', 'directorist' ), + ), + array( + 'value' => 'contain', + 'label' => __( 'Fit with Container', 'directorist' ), + ), + ), + ), + 'crop_width' => array( + 'label' => __( 'Width', 'directorist' ), + 'type' => 'number', + 'value' => '350', + 'min' => '1', + 'max' => '1200', + 'step' => '1', + 'group' => 'container', + 'group_label' => 'Container', + ), + 'crop_height' => array( + 'label' => __( 'Height', 'directorist' ), + 'type' => 'number', + 'value' => '260', + 'min' => '1', + 'max' => '1200', + 'step' => '1', + 'group' => 'container', + 'group_label' => 'Container', + ), + 'prv_container_size_by' => array( + 'label' => __( 'Size By', 'directorist' ), + 'type' => 'select', + 'value' => 'px', + 'options' => array( + array( + 'value' => 'px', + 'label' => __( 'Pixel', 'directorist' ), + ), + array( + 'value' => 'ratio', + 'label' => __( 'Ratio', 'directorist' ), + ), + ), + 'group' => 'container', + 'group_label' => 'Container', + ), + 'prv_background_type' => array( + 'label' => __( 'Background', 'directorist' ), + 'type' => 'select', + 'value' => 'blur', + + 'options' => array( + array( + 'value' => 'blur', + 'label' => __( 'Blur', 'directorist' ), + ), + array( + 'value' => 'color', + 'label' => __( 'Custom Color', 'directorist' ), + ), + ), + ), + 'prv_background_color' => array( + 'type' => 'text', + 'label' => __( 'Select Color', 'directorist' ), + 'show-if' => array( + 'where' => 'prv_background_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'color', + ), + ), + ), + 'value' => 'gainsboro', + ), + 'all_listing_page_items' => array( + 'label' => __( 'Listings Per Page', 'directorist' ), + 'type' => 'number', + 'value' => '6', + 'min' => '1', + 'max' => '100', + 'step' => '1', + ), + 'pagination_type' => array( + 'label' => __( 'Pagination Type', 'directorist' ), + 'type' => 'select', + 'value' => 'numbered', + 'options' => array( + array( + 'value' => 'numbered', + 'label' => __( 'Numbered', 'directorist' ), + ), + array( + 'value' => 'infinite_scroll', + 'label' => __( 'Infinite Scroll', 'directorist' ), + ), + ), + ), + 'display_listings_header' => array( + 'label' => __( 'Enable Header', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'listing_filters_button' => array( + 'type' => 'toggle', + 'label' => __( 'Display Filters Button', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'all_listing_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + // single listing settings + 'disable_single_listing' => array( + 'type' => 'toggle', + 'label' => __( 'Disable Single Listing View' ), + 'value' => false, + ), + 'restrict_single_listing_for_logged_in_user' => array( + 'type' => 'toggle', + 'label' => __( 'Show Single Listings to Logged-In Users Only', 'directorist' ), + 'value' => false, + ), + 'single_listing_template' => array( + 'label' => __( 'Template', 'directorist' ), + 'type' => 'select', + 'value' => 'directorist_template', + 'show-if' => array( + 'where' => 'disable_single_listing', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + 'options' => array( + array( + 'value' => 'theme_template_page', + 'label' => __( 'Theme Template (Page)', 'directorist' ), + ), + array( + 'value' => 'current_theme_template', + 'label' => __( 'Theme Template (Post)', 'directorist' ), + ), + array( + 'value' => 'directorist_template', + 'label' => __( 'Directorist Template', 'directorist' ), + ), + ), + ), + 'atbdp_listing_slug' => array( + 'type' => 'text', + 'label' => __( 'Listing Slug', 'directorist' ), + 'show-if' => array( + 'where' => 'disable_single_listing', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + 'value' => 'directory', + ), + 'dsiplay_slider_single_page' => array( + 'type' => 'toggle', + 'label' => __( 'Show Slider Image', 'directorist' ), + 'value' => true, + 'description' => __( 'Hide/show slider image from single listing page.', 'directorist' ), + 'show-if' => array( + 'where' => 'disable_single_listing', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + ), + 'single_slider_image_size' => array( + 'label' => __( 'Image Size', 'directorist' ), + 'type' => 'select', + 'value' => 'cover', + 'show-if' => array( + 'where' => 'dsiplay_slider_single_page', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + 'options' => array( + array( + 'value' => 'cover', + 'label' => __( 'Fill with Container', 'directorist' ), + ), + array( + 'value' => 'contain', + 'label' => __( 'Fit with Container', 'directorist' ), + ), + ), + ), + 'single_slider_background_type' => array( + 'label' => __( 'Slider Background Type', 'directorist' ), + 'type' => 'select', + 'value' => 'custom-color', + 'show-if' => array( + 'where' => 'single_slider_image_size', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'contain', + ), + ), + ), + 'options' => array( + array( + 'value' => 'blur', + 'label' => __( 'Blur', 'directorist' ), + ), + array( + 'value' => 'custom-color', + 'label' => __( 'Custom Color', 'directorist' ), + ), + ), + ), + 'single_slider_background_color' => array( + 'type' => 'color', + 'label' => __( 'Background Color', 'directorist' ), + 'show-if' => array( + 'where' => 'single_slider_background_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'custom-color', + ), + ), + ), + 'value' => '#ffffff', + ), + + 'gallery_crop_width' => array( + 'label' => __( 'Image Width', 'directorist' ), + 'type' => 'number', + 'value' => '740', + 'min' => '1', + 'max' => '1200', + 'step' => '1', + 'show-if' => array( + 'where' => 'dsiplay_slider_single_page', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'gallery_crop_height' => array( + 'label' => __( 'Image Height', 'directorist' ), + 'type' => 'number', + 'value' => '580', + 'min' => '1', + 'max' => '1200', + 'step' => '1', + 'show-if' => array( + 'where' => 'dsiplay_slider_single_page', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + // badge settings + 'new_badge_text' => array( + 'type' => 'text', + 'label' => __( 'Badge Text', 'directorist' ), + 'description' => __( 'Text displayed on the badge when a listing is newly created.', 'directorist' ), + 'value' => __( 'New', 'directorist' ), + ), + 'new_listing_day' => array( + 'label' => __( 'New Badge Display Duration', 'directorist' ), + 'description' => __( 'Enter the number of days the "New" badge will appear on a new listing.', 'directorist' ), + 'type' => 'number', + 'value' => '3', + 'min' => '1', + 'max' => '100', + 'step' => '1', + ), + 'feature_badge_type' => array( + 'label' => __( 'Badge Type', 'directorist' ), + 'type' => 'select', + 'value' => 'text_badge', + 'options' => array( + array( + 'value' => 'text_badge', + 'label' => __( 'Text Badge', 'directorist' ), + ), + array( + 'value' => 'icon_badge', + 'label' => __( 'Icon with Hover Text', 'directorist' ), + ), + ), + ), + 'feature_badge_text' => array( + 'type' => 'text', + 'label' => __( 'Badge Text', 'directorist' ), + 'description' => __( 'Text displayed on the badge when a listing is marked as featured.', 'directorist' ), + 'value' => __( 'Featured', 'directorist' ), + 'change-if' => array( + 'where' => 'feature_badge_type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'icon_badge', + ), + ), + 'effects' => array( + array( + 'key' => 'label', + 'value' => __( 'Badge Hover Text', 'directorist' ), + 'default_value' => __( 'Badge Text', 'directorist' ), + ), + ), + ), + ), + 'popular_badge_text' => array( + 'type' => 'text', + 'label' => __( 'Badge Text', 'directorist' ), + 'description' => __( 'Text displayed on the badge when an item is marked as popular.', 'directorist' ), + 'value' => __( 'Popular', 'directorist' ), + ), + 'listing_popular_by' => array( + 'label' => __( 'Determine Popularity By', 'directorist' ), + 'description' => __( 'Select the criteria used to determine popularity.', 'directorist' ), + 'type' => 'select', + 'value' => 'view_count', + 'options' => array( + array( + 'value' => 'view_count', + 'label' => __( 'View Count', 'directorist' ), + ), + array( + 'value' => 'average_rating', + 'label' => __( 'Average Rating', 'directorist' ), + ), + ), + ), + 'views_for_popular' => array( + 'type' => 'text', + 'label' => __( 'View Count Threshold', 'directorist' ), + 'description' => __( 'Minimum number of views to mark an item as popular.', 'directorist' ), + 'value' => 5, + ), + 'count_loggedin_user' => array( + 'type' => 'toggle', + 'label' => __( 'Include Logged-In User Views', 'directorist' ), + 'description' => __( 'Count views from logged-in users toward popularity.', 'directorist' ), + 'value' => false, + ), + 'average_review_for_popular' => array( + 'label' => __( 'Minimum Average Rating', 'directorist' ), + 'description' => __( 'Minimum average rating (equal or greater than) to mark an item as popular.', 'directorist' ), + 'type' => 'number', + 'value' => '4', + 'min' => '.5', + 'max' => '4.5', + 'step' => '.5', + ), + + // select map settings + 'select_listing_map' => array( + 'label' => __( 'Select Map', 'directorist' ), + 'type' => 'select', + 'value' => 'openstreet', + 'options' => array( + array( + 'value' => 'google', + 'label' => __( 'Google Map', 'directorist' ), + ), + array( + 'value' => 'openstreet', + 'label' => __( 'OpenStreetMap', 'directorist' ), + ), + ), + ), + 'map_api_key' => array( + 'type' => 'text', + 'label' => __( 'Google Map API key', 'directorist' ), + 'description' => sprintf( __( 'Please replace it by your own API. It\'s required to use Google Map. You can find detailed information %s.', 'directorist' ), '<a href="https://developers.google.com/maps/documentation/javascript/get-api-key" target="_blank"> <div class="atbdp_shortcodes" style="color: red;">here</div> </a>' ), + 'value' => '', + 'show-if' => array( + 'where' => 'select_listing_map', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'google', + ), + ), + ), + ), + 'default_latitude' => array( + 'type' => 'text', + 'label' => __( 'Default Latitude', 'directorist' ), + 'description' => sprintf( __( 'You can find it %s', 'directorist' ), '<a href="https://www.maps.ie/coordinates.html" target="_blank" class="directorist-find-latlan">here</a>' ), + 'value' => '40.7127753', + ), + 'default_longitude' => array( + 'type' => 'text', + 'label' => __( 'Default Longitude', 'directorist' ), + 'description' => sprintf( __( 'You can find it %s', 'directorist' ), '<a href="https://www.maps.ie/coordinates.html" target="_blank" class="directorist-find-latlan">here</a>' ), + 'value' => '-74.0059728', + ), + 'map_zoom_level' => array( + 'label' => __( 'Zoom Level for Single Listing', 'directorist' ), + 'description' => __( 'Here 0 means 100% zoom-out. 22 means 100% zoom-in. Minimum Zoom Allowed = 1. Max Zoom Allowed = 22.', 'directorist' ), + 'type' => 'number', + 'value' => '16', + 'min' => '1', + 'max' => '22', + 'step' => '1', + ), + 'map_view_zoom_level' => array( + 'label' => __( 'Zoom Level for Map View', 'directorist' ), + 'description' => __( 'Here 0 means 100% zoom-out. 18 means 100% zoom-in. Minimum Zoom Allowed = 1. Max Zoom Allowed = 22.', 'directorist' ), + 'type' => 'number', + 'value' => '1', + 'min' => '1', + 'max' => '18', + 'step' => '1', + ), + 'listings_map_height' => array( + 'label' => __( 'Map Height', 'directorist' ), + 'description' => __( 'In pixel.', 'directorist' ), + 'type' => 'number', + 'value' => '350', + 'min' => '5', + 'max' => '1200', + 'step' => '5', + ), + 'display_map_info' => array( + 'type' => 'toggle', + 'label' => __( 'Display Map Info Window', 'directorist' ), + 'value' => true, + ), + 'display_image_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display Preview Image', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_favorite_badge_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display Favorite Badge', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_user_avatar_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display User Avatar', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_title_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display Title', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_review_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display Review', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_price_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display Price', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_address_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display Address', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_direction_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display Get Direction', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_phone_map' => array( + 'type' => 'toggle', + 'label' => __( 'Display Phone', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'display_map_info', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + // user dashboard settings + 'my_listing_tab' => array( + 'type' => 'toggle', + 'label' => __( 'Display My Listing Tab', 'directorist' ), + 'value' => true, + ), + 'my_listing_tab_text' => array( + 'type' => 'text', + 'label' => __( '"My Listing" Tab Label', 'directorist' ), + 'value' => __( 'My Listing', 'directorist' ), + 'show-if' => array( + 'where' => 'my_listing_tab', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'user_listings_pagination' => array( + 'type' => 'toggle', + 'label' => __( 'Listings Pagination', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'my_listing_tab', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'user_listings_per_page' => array( + 'label' => __( 'Listings Per Page', 'directorist' ), + 'type' => 'number', + 'value' => '9', + 'min' => '1', + 'max' => '30', + 'step' => '1', + 'show-if' => array( + 'where' => 'my_listing_tab', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'my_profile_tab' => array( + 'type' => 'toggle', + 'label' => __( 'Display My Profile Tab', 'directorist' ), + 'value' => true, + ), + 'my_profile_tab_text' => array( + 'type' => 'text', + 'label' => __( '"My Profile" Tab Label', 'directorist' ), + 'value' => __( 'My Profile', 'directorist' ), + 'show-if' => array( + 'where' => 'my_profile_tab', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'fav_listings_tab' => array( + 'type' => 'toggle', + 'label' => __( 'Display Favourite Listings Tab', 'directorist' ), + 'value' => true, + ), + 'fav_listings_tab_text' => array( + 'type' => 'text', + 'label' => __( '"Favourite Listings" Tab Label', 'directorist' ), + 'value' => __( 'Favorite Listings', 'directorist' ), + 'show-if' => array( + 'where' => 'fav_listings_tab', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'submit_listing_button' => array( + 'type' => 'toggle', + 'label' => __( 'Display Submit Listing Button', 'directorist' ), + 'value' => true, + ), + 'become_author_button' => array( + 'type' => 'toggle', + 'label' => __( 'Display "Become An Author" button', 'directorist' ), + 'value' => true, + ), + 'become_author_button_text' => array( + 'type' => 'text', + 'label' => __( '"Become An Author" button Label', 'directorist' ), + 'value' => __( 'Become An Author', 'directorist' ), + 'show-if' => array( + 'where' => 'become_author_button', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + // all authors settings + 'all_authors_columns' => array( + 'label' => __( 'Number of Columns', 'directorist' ), + 'type' => 'number', + 'value' => '3', + 'min' => '1', + 'max' => '6', + 'step' => '1', + ), + 'all_authors_sorting' => array( + 'type' => 'toggle', + 'label' => __( 'Display Alphabet Sorting', 'directorist' ), + 'value' => true, + ), + 'all_authors_image' => array( + 'type' => 'toggle', + 'label' => __( 'Display Image', 'directorist' ), + 'value' => true, + ), + 'all_authors_name' => array( + 'type' => 'toggle', + 'label' => __( 'Display Name', 'directorist' ), + 'value' => true, + ), + 'all_authors_select_role' => array( + 'label' => __( 'Select Role', 'directorist' ), + 'type' => 'select', + 'value' => 'all', + 'options' => $this->get_user_roles(), + ), + 'all_authors_contact' => array( + 'label' => esc_html__( 'Contact Info', 'directorist' ), + 'type' => 'checkbox', + 'value' => array( + 'phone', + 'address', + 'website', + ), + 'description' => esc_html__( 'Email will show only for logged in user.', 'directorist' ), + 'options' => array( + array( + 'value' => 'phone', + 'label' => esc_html__( 'Phone', 'directorist' ), + ), + array( + 'value' => 'email', + 'label' => esc_html__( 'Email', 'directorist' ), + ), + array( + 'value' => 'address', + 'label' => esc_html__( 'Address', 'directorist' ), + ), + array( + 'value' => 'website', + 'label' => esc_html__( 'Website', 'directorist' ), + ), + ), + ), + 'all_authors_description' => array( + 'type' => 'toggle', + 'label' => __( 'Display Description', 'directorist' ), + 'value' => true, + ), + 'all_authors_description_limit' => array( + 'label' => __( 'Description Word Limit', 'directorist' ), + 'type' => 'number', + 'value' => '13', + 'min' => '1', + 'max' => '50', + 'step' => '1', + 'show-if' => array( + 'where' => 'all_authors_description', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'all_authors_social_info' => array( + 'type' => 'toggle', + 'label' => __( 'Display Social Info', 'directorist' ), + 'value' => true, + ), + 'all_authors_button' => array( + 'type' => 'toggle', + 'label' => __( 'Display All Listings Button', 'directorist' ), + 'value' => true, + ), + 'all_authors_button_text' => array( + 'type' => 'text', + 'label' => __( 'All Listings Button text', 'directorist' ), + 'value' => __( 'View All Listings', 'directorist' ), + 'show-if' => array( + 'where' => 'all_authors_button', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'all_authors_pagination' => array( + 'type' => 'toggle', + 'label' => __( 'Paginate All Authors ', 'directorist' ), + 'value' => true, + ), + 'all_authors_per_page' => array( + 'label' => __( 'Authors Per Page', 'directorist' ), + 'type' => 'number', + 'value' => '9', + 'min' => '1', + 'max' => '50', + 'step' => '1', + ), + // search form settings + 'search_title' => array( + 'type' => 'text', + 'label' => __( 'Search Bar Title', 'directorist' ), + 'value' => __( 'Search here', 'directorist' ), + ), + 'search_subtitle' => array( + 'type' => 'text', + 'label' => __( 'Search Bar Sub-title', 'directorist' ), + 'value' => __( 'Find the best match of your interest', 'directorist' ), + ), + + 'search_more_filter' => array( + 'type' => 'toggle', + 'label' => __( 'Display More Filters', 'directorist' ), + 'value' => true, + ), + 'search_filters' => array( + 'type' => 'checkbox', + 'label' => __( 'Filter Actions', 'directorist' ), + 'show-if' => array( + 'where' => 'search_more_filter', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + 'value' => array( + 'search_reset_filters', + 'search_apply_filters', + ), + 'options' => array( + array( + 'value' => 'search_reset_filters', + 'label' => __( 'Reset', 'directorist' ), + ), + array( + 'value' => 'search_apply_filters', + 'label' => __( 'Apply', 'directorist' ), + ), + ), + ), + 'search_listing_text' => array( + 'type' => 'text', + 'label' => __( 'Search Button Text', 'directorist' ), + 'value' => __( 'Search Listing', 'directorist' ), + ), + 'search_more_filters' => array( + 'type' => 'text', + 'label' => __( 'More Filters Button Text', 'directorist' ), + 'value' => __( 'More Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'search_more_filter', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'search_reset_text' => array( + 'type' => 'text', + 'label' => __( 'Reset Button Text', 'directorist' ), + 'value' => __( 'Reset Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'search_more_filter', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'search_apply_filter' => array( + 'type' => 'text', + 'label' => __( 'Apply Button Text', 'directorist' ), + 'value' => __( 'Apply Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'search_more_filter', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'show_popular_category' => array( + 'type' => 'toggle', + 'label' => __( 'Display Popular Categories', 'directorist' ), + 'value' => false, + ), + + 'popular_cat_title' => array( + 'type' => 'text', + 'label' => __( 'Section Title', 'directorist' ), + 'value' => __( 'Browse by popular categories', 'directorist' ), + 'show-if' => array( + 'where' => 'show_popular_category', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'popular_cat_num' => array( + 'label' => __( 'Number of Categories to Display', 'directorist' ), + 'type' => 'number', + 'value' => '10', + 'min' => '1', + 'max' => '30', + 'step' => '1', + 'show-if' => array( + 'where' => 'show_popular_category', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'search_home_bg' => array( + 'label' => __( 'Search Section Background', 'directorist' ), + 'type' => 'wp-media-picker', + 'default-img' => '', + 'value' => '', + ), + // search result settings + 'search_result_layout' => array( + 'label' => __( 'All Listings Layout', 'directorist' ), + 'type' => 'select', + 'value' => 'left_sidebar', + 'options' => array( + array( + 'value' => 'left_sidebar', + 'label' => __( 'Left Sidebar Filter', 'directorist' ), + ), + array( + 'value' => 'right_sidebar', + 'label' => __( 'Right Sidebar Filter', 'directorist' ), + ), + array( + 'value' => 'no_sidebar', + 'label' => __( 'Popup Filter', 'directorist' ), + ), + ), + ), + 'search_result_hide_top_search_bar' => array( + 'type' => 'toggle', + 'label' => __( 'Hide Top Search Bar', 'directorist' ), + 'value' => false, + 'show-if' => array( + 'where' => 'search_result_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '!=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'search_result_sidebar_filter_text' => array( + 'type' => 'text', + 'label' => __( 'Filters Text', 'directorist' ), + 'value' => __( 'Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'search_result_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '!=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'search_result_filter_button_text' => array( + 'type' => 'text', + 'label' => __( 'Filters Button Text', 'directorist' ), + 'value' => __( 'Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'search_result_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'display_search_result_listings_count' => array( + 'type' => 'toggle', + 'label' => __( 'Display Listings Count', 'directorist' ), + 'value' => true, + 'show-if' => array( + 'where' => 'search_header', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'search_result_listing_title' => array( + 'type' => 'text', + 'label' => __( 'Listings Count Text', 'directorist' ), + 'value' => __( 'Items Found', 'directorist' ), + 'show-if' => array( + 'where' => 'search_header', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'sresult_reset_text' => array( + 'type' => 'text', + 'label' => __( 'Reset Button Text', 'directorist' ), + 'value' => __( 'Reset Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'search_result_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'sresult_sidebar_reset_text' => array( + 'type' => 'text', + 'label' => __( 'Reset text', 'directorist' ), + 'value' => __( 'Clear All', 'directorist' ), + 'show-if' => array( + 'where' => 'search_result_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '!=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'sresult_apply_text' => array( + 'type' => 'text', + 'label' => __( 'Apply Filters Button Text', 'directorist' ), + 'value' => __( 'Apply Filters', 'directorist' ), + 'show-if' => array( + 'where' => 'search_result_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'no_sidebar', + ), + ), + ), + ), + 'search_view_as_items' => array( + 'type' => 'checkbox', + 'label' => __( 'View Type', 'directorist' ), + 'description' => '', + 'value' => array( + 'listings_grid', + 'listings_list', + 'listings_map', + ), + 'options' => array( + array( + 'value' => 'listings_grid', + 'label' => __( 'Grid', 'directorist' ), + ), + array( + 'value' => 'listings_list', + 'label' => __( 'List', 'directorist' ), + ), + array( + 'value' => 'listings_map', + 'label' => __( 'Map', 'directorist' ), + ), + ), + ), + 'search_sort_by' => array( + 'type' => 'toggle', + 'label' => __( 'Enable Sorting Options', 'directorist' ), + 'value' => true, + ), + 'search_sortby_text' => array( + 'type' => 'text', + 'label' => __( '"Sort By" Label', 'directorist' ), + 'value' => __( 'Sort By', 'directorist' ), + ), + 'search_sort_by_items' => array( + 'type' => 'checkbox', + 'label' => __( 'Sort Options', 'directorist' ), + 'description' => '', + 'value' => array( + 'a_z', + 'z_a', + 'latest', + 'oldest', + 'popular', + 'price_low_high', + 'price_high_low', + 'random', + ), + 'options' => array( + array( + 'value' => 'a_z', + 'label' => __( 'A to Z (title)', 'directorist' ), + ), + array( + 'value' => 'z_a', + 'label' => __( 'Z to A (title)', 'directorist' ), + ), + array( + 'value' => 'latest', + 'label' => __( 'Latest listings', 'directorist' ), + ), + array( + 'value' => 'oldest', + 'label' => __( 'Oldest listings', 'directorist' ), + ), + array( + 'value' => 'popular', + 'label' => __( 'Popular listings', 'directorist' ), + ), + array( + 'value' => 'price_low_high', + 'label' => __( 'Price (low to high)', 'directorist' ), + ), + array( + 'value' => 'price_high_low', + 'label' => __( 'Price (high to low)', 'directorist' ), + ), + array( + 'value' => 'random', + 'label' => __( 'Random listings', 'directorist' ), + ), + ), + ), + 'search_listing_columns' => array( + 'label' => __( 'Number of Columns', 'directorist' ), + 'type' => 'number', + 'value' => '3', + 'min' => '1', + 'max' => '5', + 'step' => '1', + ), + 'search_posts_num' => array( + 'label' => __( 'Search Results Per Page', 'directorist' ), + 'type' => 'number', + 'value' => '6', + 'min' => '1', + 'max' => '100', + 'step' => '1', + ), + 'search_header' => array( + 'type' => 'toggle', + 'label' => __( 'Display Header', 'directorist' ), + 'value' => true, + ), + 'search_result_filters_button_display' => array( + 'type' => 'toggle', + 'label' => __( 'Display Filters Button', 'directorist' ), + 'show-if' => array( + 'where' => 'search_result_layout', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'no_sidebar', + ), + ), + ), + 'value' => true, + ), + // upgrade/ regenerate pages + 'shortcode-updated' => array( + 'type' => 'toggle', + 'label' => __( 'Upgrade/Regenerate Pages', 'directorist' ), + 'value' => true, + ), + // pages, links, views settings + 'add_listing_page' => array( + 'label' => __( 'Add Listing Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_add_listing]</div>' ), + 'value' => atbdp_get_option( 'add_listing_page', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'all_listing_page' => array( + 'label' => __( 'All Listings Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_all_listing]</div>' ), + 'value' => atbdp_get_option( 'all_listing_page', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'user_dashboard' => array( + 'label' => __( 'Dashboard Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_user_dashboard]</div>' ), + 'value' => atbdp_get_option( 'user_dashboard', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'signin_signup_page' => array( + 'label' => __( 'Sign In & Signup Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_signin_signup]</div>' ), + 'value' => atbdp_get_option( 'signin_signup_page', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'author_profile_page' => array( + 'label' => __( 'User Profile Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_author_profile]</div>' ), + 'value' => atbdp_get_option( 'author_profile', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'all_categories_page' => array( + 'label' => __( 'All Categories Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_all_categories]</div>' ), + 'value' => atbdp_get_option( 'all_categories', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'single_category_page' => array( + 'label' => __( 'Single Category Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_category]</div>' ), + 'value' => atbdp_get_option( 'single_category_page', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'all_locations_page' => array( + 'label' => __( 'All Locations Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_all_locations]</div>' ), + 'value' => atbdp_get_option( 'all_locations', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'single_location_page' => array( + 'label' => __( 'Single Location Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_location]</div>' ), + 'value' => atbdp_get_option( 'single_location_page', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'single_tag_page' => array( + 'label' => __( 'Single Tag Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_tag]</div>' ), + 'value' => atbdp_get_option( 'single_tag_page', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'custom_registration' => array( + 'label' => __( 'Registration Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_custom_registration]</div>' ), + 'value' => atbdp_get_option( 'custom_registration', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'user_login' => array( + 'label' => __( 'Login Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_user_login]</div>' ), + 'value' => atbdp_get_option( 'user_login', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'search_listing' => array( + 'label' => __( 'Listing Search Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_search_listing]</div>' ), + 'value' => atbdp_get_option( 'search_listing', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'search_result_page' => array( + 'label' => __( 'Listing Search Result Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_search_result]</div>' ), + 'value' => atbdp_get_option( 'search_result_page', 'atbdp_general' ), + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'checkout_page' => array( + 'label' => __( 'Checkout Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_checkout]</div>' ), + 'value' => '', + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'payment_receipt_page' => array( + 'label' => __( 'Payment/Order Receipt Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_payment_receipt]</div>' ), + 'value' => '', + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + 'transaction_failure_page' => array( + 'label' => __( 'Transaction Failure Page', 'directorist' ), + 'type' => 'select', + 'description' => sprintf( __( 'Following shortcode must be in the selected page %s', 'directorist' ), '<div class="atbdp_shortcodes" style="color: #ff4500;">[directorist_transaction_failure]</div>' ), + 'value' => '', + 'showDefaultOption' => true, + 'options' => $this->get_pages_vl_arrays(), + ), + // seo settings + 'atbdp_enable_seo' => array( + 'type' => 'toggle', + 'label' => __( 'Enable SEO', 'directorist' ), + 'value' => true, + ), + 'add_listing_page_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Add Listing Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'add_listing_page_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Add Listing Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'all_listing_meta_title' => array( + 'type' => 'text', + 'label' => __( 'All Listing Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'all_listing_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'All Listing Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'dashboard_meta_title' => array( + 'type' => 'text', + 'label' => __( 'User Dashboard Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'dashboard_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Dashboard Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'author_profile_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Author Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'author_page_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Author Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'category_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Category Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'category_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Category Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'single_category_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Single Category Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the category.', 'directorist' ), + 'value' => '', + ), + 'single_category_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Single Category Page Meta Description', 'directorist' ), + 'description' => __( 'Leave it blank to set category\'s description as meta description of this page', 'directorist' ), + 'value' => '', + ), + 'all_locations_meta_title' => array( + 'type' => 'text', + 'label' => __( 'All Locations Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'all_locations_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'All Locations Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'single_locations_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Single Location Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the location.', 'directorist' ), + 'value' => '', + ), + 'single_locations_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Single Locations Page Meta Description', 'directorist' ), + 'description' => __( 'Leave it blank to set location\'s description as meta description of this page', 'directorist' ), + 'value' => '', + ), + 'registration_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Registration Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'registration_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Registration Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'login_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Login Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'login_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Login Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'homepage_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Search Home Page Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + ), + 'homepage_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Search Home Page Meta Description', 'directorist' ), + 'value' => '', + ), + 'meta_title_for_search_result' => array( + 'label' => __( 'Search Result Page Meta Title', 'directorist' ), + 'type' => 'select', + 'value' => 'searched_value', + 'options' => array( + array( + 'value' => 'searched_value', + 'label' => __( 'From User Search', 'directorist' ), + ), + array( + 'value' => 'custom', + 'label' => __( 'Custom', 'directorist' ), + ), + ), + ), + 'search_result_meta_title' => array( + 'type' => 'text', + 'label' => __( 'Custom Meta Title', 'directorist' ), + 'description' => __( 'Default the title of the page set as frontpage.', 'directorist' ), + 'value' => '', + 'show-if' => array( + 'where' => 'meta_title_for_search_result', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'custom', + ), + ), + ), + ), + 'search_result_meta_desc' => array( + 'type' => 'text', + 'label' => __( 'Search Result Page Meta Description', 'directorist' ), + 'value' => '', + ), + // currency settings + 'g_currency_note' => array( + 'type' => 'note', + 'title' => __( 'Note:', 'directorist' ), + 'description' => __( 'Customize how prices are displayed on your site. To accept payments in a different currency, visit Monetization → General Settings', 'directorist' ), + ), + 'g_currency' => array( + 'type' => 'text', + 'label' => __( 'Currency Code', 'directorist' ), + 'description' => sprintf( + __( 'Enter the 3-letter currency code (e.g., USD for US Dollar). For a full list of currency codes, refer to %s.', 'directorist' ), + "<a href='" . esc_url( 'https://www.iban.com/currency-codes' ) . "'>" . __( 'ISO 4217 Currency Codes', 'directorist' ) . '</a>' + ), + 'value' => 'USD', + ), + 'g_currency_position' => array( + 'label' => __( 'Currency Position', 'directorist' ), + 'type' => 'select', + 'value' => 'before', + 'description' => __( "Select where you'd like the currency symbol to appear. The default is before the amount (e.g., $5)", 'directorist' ), + 'options' => array( + array( + 'value' => 'before', + 'label' => __( '$5 - Before', 'directorist' ), + ), + array( + 'value' => 'after', + 'label' => __( 'After - 5$', 'directorist' ), + ), + ), + ), + // categories settings + 'display_categories_as' => array( + 'label' => __( 'Default View', 'directorist' ), + 'type' => 'select', + 'value' => 'grid', + 'options' => array( + array( + 'value' => 'grid', + 'label' => __( 'Grid', 'directorist' ), + ), + array( + 'value' => 'list', + 'label' => __( 'List', 'directorist' ), + ), + ), + ), + 'categories_column_number' => array( + 'label' => __( 'Number of Columns', 'directorist' ), + 'description' => __( 'Set how many columns to display on categories page.', 'directorist' ), + 'type' => 'select', + 'value' => '4', + 'options' => array( + array( + 'value' => 1, + 'label' => 1, + ), + array( + 'value' => 2, + 'label' => 2, + ), + array( + 'value' => 3, + 'label' => 3, + ), + array( + 'value' => 4, + 'label' => 4, + ), + array( + 'value' => 5, + 'label' => 5, + ), + array( + 'value' => 6, + 'label' => 6, + ), + ), + ), + 'categories_depth_number' => array( + 'label' => __( 'Sub-category Depth', 'directorist' ), + 'description' => __( 'Set how many sub-categories to display.', 'directorist' ), + 'type' => 'number', + 'value' => '4', + 'min' => '1', + 'max' => '15', + 'step' => '2', + 'show-if' => array( + 'where' => 'display_categories_as', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'list', + ), + ), + ), + ), + 'order_category_by' => array( + 'label' => __( 'Order By', 'directorist' ), + 'type' => 'select', + 'value' => 'id', + 'options' => array( + array( + 'value' => 'id', + 'label' => __( 'ID', 'directorist' ), + ), + array( + 'value' => 'count', + 'label' => __( 'Count', 'directorist' ), + ), + array( + 'value' => 'name', + 'label' => __( 'Name', 'directorist' ), + ), + array( + 'value' => 'slug', + 'label' => __( 'Slug', 'directorist' ), + ), + ), + ), + 'sort_category_by' => array( + 'label' => __( 'Sort By', 'directorist' ), + 'type' => 'select', + 'value' => 'asc', + 'options' => array( + array( + 'value' => 'asc', + 'label' => __( 'Ascending', 'directorist' ), + ), + array( + 'value' => 'desc', + 'label' => __( 'Descending', 'directorist' ), + ), + ), + ), + 'display_listing_count' => array( + 'label' => __( 'Display Listing Count', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'hide_empty_categories' => array( + 'label' => __( 'Hide Empty Categories', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + // locations settings + 'display_locations_as' => array( + 'label' => __( 'Default View', 'directorist' ), + 'type' => 'select', + 'value' => 'grid', + 'options' => array( + array( + 'value' => 'grid', + 'label' => __( 'Grid', 'directorist' ), + ), + array( + 'value' => 'list', + 'label' => __( 'List', 'directorist' ), + ), + ), + ), + 'locations_column_number' => array( + 'label' => __( 'Number of Columns', 'directorist' ), + 'description' => __( 'Set how many columns to display on locations page.', 'directorist' ), + 'type' => 'select', + 'value' => '4', + 'options' => array( + array( + 'value' => 1, + 'label' => 1, + ), + array( + 'value' => 2, + 'label' => 2, + ), + array( + 'value' => 3, + 'label' => 3, + ), + array( + 'value' => 4, + 'label' => 4, + ), + array( + 'value' => 5, + 'label' => 5, + ), + array( + 'value' => 6, + 'label' => 6, + ), + ), + ), + 'locations_depth_number' => array( + 'label' => __( 'Sub-location Depth', 'directorist' ), + 'description' => __( 'Set how many sub-locations to display.', 'directorist' ), + 'type' => 'number', + 'value' => '4', + 'min' => '1', + 'max' => '15', + 'step' => '2', + 'show-if' => array( + 'where' => 'display_locations_as', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'list', + ), + ), + ), + ), + 'order_location_by' => array( + 'label' => __( 'Order By', 'directorist' ), + 'type' => 'select', + 'value' => 'id', + 'options' => array( + array( + 'value' => 'id', + 'label' => __( 'ID', 'directorist' ), + ), + array( + 'value' => 'count', + 'label' => __( 'Count', 'directorist' ), + ), + array( + 'value' => 'name', + 'label' => __( 'Name', 'directorist' ), + ), + array( + 'value' => 'slug', + 'label' => __( 'Slug', 'directorist' ), + ), + ), + ), + 'sort_location_by' => array( + 'label' => __( 'Sort By', 'directorist' ), + 'type' => 'select', + 'value' => 'asc', + 'options' => array( + array( + 'value' => 'asc', + 'label' => __( 'Ascending', 'directorist' ), + ), + array( + 'value' => 'desc', + 'label' => __( 'Descending', 'directorist' ), + ), + ), + ), + 'display_location_listing_count' => array( + 'label' => __( 'Display Listing Count', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'hide_empty_locations' => array( + 'label' => __( 'Hide Empty Locations', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + // registration settings + 'new_user_registration' => array( + 'label' => __( 'Enable Registration', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'enable_email_verification' => array( + 'label' => __( 'Enable Email Verification', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + 'description' => sprintf( __( 'Enable email verification to verify user email during registration. To view the verification status navigate to Users → %s.', 'directorist' ), "<a href='" . admin_url( 'users.php' ) . "'>" . __( 'All Users', 'directorist' ) . '</a>' ), + ), + 'reg_username' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'Username', 'directorist' ), + ), + 'display_password_reg' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'reg_password' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'Password', 'directorist' ), + 'show-if' => array( + 'where' => 'display_password_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'require_password_reg' => array( + 'label' => __( 'Required', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + 'show-if' => array( + 'where' => 'display_password_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'reg_email' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'Email', 'directorist' ), + ), + 'display_website_reg' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'reg_website' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'Website', 'directorist' ), + 'show-if' => array( + 'where' => 'display_website_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'require_website_reg' => array( + 'label' => __( 'Required', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + 'show-if' => array( + 'where' => 'display_website_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_fname_reg' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'reg_fname' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'First Name', 'directorist' ), + 'show-if' => array( + 'where' => 'display_fname_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'require_fname_reg' => array( + 'label' => __( 'Required', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + 'show-if' => array( + 'where' => 'display_fname_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_lname_reg' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'reg_lname' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'Last Name', 'directorist' ), + 'show-if' => array( + 'where' => 'display_lname_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'require_lname_reg' => array( + 'label' => __( 'Required', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + 'show-if' => array( + 'where' => 'display_lname_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_bio_reg' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'reg_bio' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'About/bio', 'directorist' ), + 'show-if' => array( + 'where' => 'display_bio_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'require_bio_reg' => array( + 'label' => __( 'Required', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + 'show-if' => array( + 'where' => 'display_bio_reg', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'registration_privacy' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'registration_privacy_label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'I agree to the', 'directorist' ), + 'show-if' => array( + 'where' => 'registration_privacy', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'registration_privacy_label_link' => array( + 'type' => 'text', + 'label' => __( 'Linking Text', 'directorist' ), + 'value' => __( 'Privacy & Policy', 'directorist' ), + 'show-if' => array( + 'where' => 'registration_privacy', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'regi_terms_condition' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'regi_terms_label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'I agree with all', 'directorist' ), + 'show-if' => array( + 'where' => 'regi_terms_condition', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'regi_terms_label_link' => array( + 'type' => 'text', + 'label' => __( 'Linking Text', 'directorist' ), + 'value' => __( 'terms & conditions', 'directorist' ), + 'show-if' => array( + 'where' => 'regi_terms_condition', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_user_type' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'reg_signup' => array( + 'type' => 'text', + 'label' => __( 'Text', 'directorist' ), + 'value' => __( 'Sign Up', 'directorist' ), + ), + 'display_login' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'login_text' => array( + 'type' => 'text', + 'label' => __( 'Text', 'directorist' ), + 'value' => __( 'Already have an account?', 'directorist' ), + 'show-if' => array( + 'where' => 'display_login', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'log_linkingmsg' => array( + 'type' => 'text', + 'label' => __( 'Linking Text', 'directorist' ), + 'value' => __( 'Login', 'directorist' ), + 'show-if' => array( + 'where' => 'display_login', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'auto_login' => array( + 'label' => __( 'Auto Login after Registration', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'redirection_after_reg' => array( + 'label' => __( 'Redirection after Registration', 'directorist' ), + 'type' => 'select', + 'value' => get_directorist_option( 'signin_signup_page' ), + 'options' => $this->get_pages_with_prev_page(), + ), + // login settings + 'log_username' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'Username or Email Address', 'directorist' ), + ), + 'log_password' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'Password', 'directorist' ), + ), + 'display_rememberme' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'log_rememberme' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => __( 'Remember Me', 'directorist' ), + 'show-if' => array( + 'where' => 'display_rememberme', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'log_button' => array( + 'type' => 'text', + 'label' => __( 'Text', 'directorist' ), + 'value' => __( 'Log In', 'directorist' ), + ), + 'display_signup' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'reg_text' => array( + 'type' => 'textarea', + 'label' => __( 'Text', 'directorist' ), + 'value' => __( "Don't have an account?", 'directorist' ), + 'show-if' => array( + 'where' => 'display_signup', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'reg_linktxt' => array( + 'type' => 'text', + 'label' => __( 'Linking Text', 'directorist' ), + 'value' => __( 'Sign Up', 'directorist' ), + 'show-if' => array( + 'where' => 'display_signup', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'display_recpass' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'recpass_text' => array( + 'type' => 'text', + 'label' => __( 'Name', 'directorist' ), + 'value' => __( 'Recover Password', 'directorist' ), + 'show-if' => array( + 'where' => 'display_recpass', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'recpass_desc' => array( + 'type' => 'textarea', + 'label' => __( 'Description', 'directorist' ), + 'value' => __( 'Lost your password? Please enter your email address. You will receive a link to create a new password via email.', 'directorist' ), + 'show-if' => array( + 'where' => 'display_recpass', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'recpass_username' => array( + 'type' => 'text', + 'label' => __( 'Email Label', 'directorist' ), + 'value' => __( 'E-mail', 'directorist' ), + 'show-if' => array( + 'where' => 'display_recpass', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'recpass_placeholder' => array( + 'type' => 'text', + 'label' => __( 'Username or Email Placeholder', 'directorist' ), + 'value' => __( 'eg. mail@example.com', 'directorist' ), + 'show-if' => array( + 'where' => 'display_recpass', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'recpass_button' => array( + 'type' => 'text', + 'label' => __( 'Button Text', 'directorist' ), + 'value' => __( 'Get New Password', 'directorist' ), + 'show-if' => array( + 'where' => 'display_recpass', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'redirection_after_login' => array( + 'label' => __( 'Redirection after Login', 'directorist' ), + 'type' => 'select', + 'value' => 'previous_page', + 'options' => $this->get_pages_with_prev_page(), + ), + // email general settings + 'disable_email_notification' => array( + 'label' => __( 'Disable all Email Notifications', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'email_from_name' => array( + 'type' => 'text', + 'label' => __( 'Sender Name for Emails', 'directorist' ), + 'description' => __( 'The name that will appear as the sender in emails generated by Directorist.', 'directorist' ), + 'value' => get_option( 'blogname' ), + 'show-if' => array( + 'where' => 'disable_email_notification', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + ), + 'email_from_email' => array( + 'type' => 'text', + 'label' => __( 'Sender Email Address', 'directorist' ), + 'description' => __( 'The email address that will appear as the sender in emails generated by Directorist.', 'directorist' ), + 'value' => get_option( 'admin_email' ), + 'show-if' => array( + 'where' => 'disable_email_notification', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + ), + 'admin_email_lists' => array( + 'type' => 'textarea', + 'label' => __( 'Admin Email Address(es) for Notifications', 'directorist' ), + 'description' => __( 'Enter one or more email addresses (comma-separated) where admin notifications will be sent. Example: admin1@example.com, admin2@example.com.', 'directorist' ), + 'value' => get_option( 'admin_email' ), + 'show-if' => array( + 'where' => 'disable_email_notification', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + ), + 'notify_admin' => array( + 'label' => __( 'Notify the Admin when Any of the Selected Event Happens', 'directorist' ), + 'type' => 'checkbox', + 'value' => $this->default_events_to_notify_admin(), + 'options' => $this->events_to_notify_admin(), + 'description' => __( 'Select the situation when you would like to send an email to the Admin', 'directorist' ), + 'show-if' => array( + 'where' => 'disable_email_notification', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + ), + 'notify_user' => array( + 'label' => __( 'Notify the Listing Owner when Any of the Selected Event Happens', 'directorist' ), + 'type' => 'checkbox', + 'value' => $this->default_events_to_notify_user(), + 'options' => $this->events_to_notify_user(), + 'description' => __( 'Select the situation when you would like to send an email to the Listing', 'directorist' ), + 'show-if' => array( + 'where' => 'disable_email_notification', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => false, + ), + ), + ), + ), + // email templates settings + 'allow_email_header' => array( + 'label' => __( 'Email Header', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'email_header_color' => array( + 'type' => 'color', + 'label' => __( 'Email Header Color', 'directorist' ), + 'value' => '#8569fb', + 'show-if' => array( + 'where' => 'allow_email_header', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + 'email_sub_new_listing' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when a listing is submitted/received.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Listing "==LISTING_TITLE==" Received', 'directorist' ), + ), + 'email_tmpl_new_listing' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when a listing is submitted/received. HTML content is allowed too.', 'directorist' ), + 'value' => __( + " Dear ==NAME==, This email is to notify you that your listing '==LISTING_TITLE==' has been received and it is under review now. @@ -3236,110 +3678,128 @@ public function prepare_settings() Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_pub_listing' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when a listing is approved/published.', 'directorist'), - 'value' => __('[==SITE_NAME==] : Listing "==LISTING_TITLE==" published', 'directorist'), - ], - 'email_tmpl_pub_listing' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when a listing is approved/published. HTML content is allowed too.', 'directorist'), - 'value' => __(" + ", + 'directorist' + ), + ), + 'email_sub_pub_listing' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when a listing is approved/published.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Listing "==LISTING_TITLE==" published', 'directorist' ), + ), + 'email_tmpl_pub_listing' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when a listing is approved/published. HTML content is allowed too.', 'directorist' ), + 'value' => __( + " Dear ==NAME==, Congratulations! Your listing '==LISTING_TITLE==' has been approved/published. Now it is publicly available at ==LISTING_URL== Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_edit_listing' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when a listing is edited.', 'directorist'), - 'value' => __('[==SITE_NAME==] : Listing "==LISTING_TITLE==" Edited', 'directorist'), - ], - 'email_tmpl_edit_listing' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when a listing is edited. HTML content is allowed too.', 'directorist'), - 'value' => __(" + ", + 'directorist' + ), + ), + 'email_sub_edit_listing' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when a listing is edited.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Listing "==LISTING_TITLE==" Edited', 'directorist' ), + ), + 'email_tmpl_edit_listing' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when a listing is edited. HTML content is allowed too.', 'directorist' ), + 'value' => __( + " Dear ==NAME==, Congratulations! Your listing '==LISTING_TITLE==' has been edited. It is publicly available at ==LISTING_URL== Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_to_expire_listing' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when a listing is ABOUT TO EXPIRE.', 'directorist'), - 'value' => __('[==SITE_NAME==] : Your Listing "==LISTING_TITLE==" is about to expire.', 'directorist'), - ], - 'email_tmpl_to_expire_listing' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when a listing is ABOUT TO EXPIRE. HTML content is allowed too.', 'directorist'), - 'value' => __(" + ", + 'directorist' + ), + ), + 'email_sub_to_expire_listing' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when a listing is ABOUT TO EXPIRE.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Your Listing "==LISTING_TITLE==" is about to expire.', 'directorist' ), + ), + 'email_tmpl_to_expire_listing' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when a listing is ABOUT TO EXPIRE. HTML content is allowed too.', 'directorist' ), + 'value' => __( + " Dear ==NAME==, Your listing '==LISTING_TITLE==' is about to expire. It will expire on ==EXPIRATION_DATE==. You can renew it at ==RENEWAL_LINK== Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_expired_listing' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when a Listing HAS EXPIRED.', 'directorist'), - 'value' => __("[==SITE_NAME==] : Your Listing '==LISTING_TITLE==' has expired.", 'directorist'), - ], - 'email_tmpl_expired_listing' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when a Listing HAS EXPIRED. HTML content is allowed too.', 'directorist'), - 'value' => __(" + ", + 'directorist' + ), + ), + 'email_sub_expired_listing' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when a Listing HAS EXPIRED.', 'directorist' ), + 'value' => __( "[==SITE_NAME==] : Your Listing '==LISTING_TITLE==' has expired.", 'directorist' ), + ), + 'email_tmpl_expired_listing' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when a Listing HAS EXPIRED. HTML content is allowed too.', 'directorist' ), + 'value' => __( + " Dear ==NAME==, Your listing '==LISTING_TITLE==' has expired on ==EXPIRATION_DATE==. You can renew it at ==RENEWAL_LINK== Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_to_renewal_listing' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user to renew his/her listings.', 'directorist'), - 'value' => __('[==SITE_NAME==] : A Reminder to Renew your listing "==LISTING_TITLE=="', 'directorist'), - ], - 'email_tmpl_to_renewal_listing' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user to renew his/her listings. HTML content is allowed too.', 'directorist'), - 'value' => __(" + ", + 'directorist' + ), + ), + 'email_sub_to_renewal_listing' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user to renew his/her listings.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : A Reminder to Renew your listing "==LISTING_TITLE=="', 'directorist' ), + ), + 'email_tmpl_to_renewal_listing' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user to renew his/her listings. HTML content is allowed too.', 'directorist' ), + 'value' => __( + " Dear ==NAME==, We have noticed that you might have forgot to renew your listing '==LISTING_TITLE==' at ==SITE_LINK==. We would like to remind you that it expired on ==EXPIRATION_DATE==. But please don't worry. You can still renew it by clicking this link: ==RENEWAL_LINK==. Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_renewed_listing' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user his/her listings has renewed successfully.', 'directorist'), - 'value' => __('[==SITE_NAME==] : Your Listing "==LISTING_TITLE==" Has Renewed', 'directorist'), - ], - 'email_tmpl_renewed_listing' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user his/her listings has renewed successfully. HTML content is allowed too.', 'directorist'), - 'value' => __(" + ", + 'directorist' + ), + ), + 'email_sub_renewed_listing' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user his/her listings has renewed successfully.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Your Listing "==LISTING_TITLE==" Has Renewed', 'directorist' ), + ), + 'email_tmpl_renewed_listing' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user his/her listings has renewed successfully. HTML content is allowed too.', 'directorist' ), + 'value' => __( + " Dear ==NAME==, Congratulations! @@ -3348,38 +3808,44 @@ public function prepare_settings() Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_deleted_listing' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when his/her listings has deleted successfully.', 'directorist'), - 'value' => __('[==SITE_NAME==] : Your Listing "==LISTING_TITLE==" Has Been Deleted', 'directorist'), - ], - 'email_tmpl_deleted_listing' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when his/her listings has deleted successfully. HTML content is allowed too.', 'directorist'), - 'value' => __(" + ", + 'directorist' + ), + ), + 'email_sub_deleted_listing' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when his/her listings has deleted successfully.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Your Listing "==LISTING_TITLE==" Has Been Deleted', 'directorist' ), + ), + 'email_tmpl_deleted_listing' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when his/her listings has deleted successfully. HTML content is allowed too.', 'directorist' ), + 'value' => __( + " Dear ==NAME==, Your listing '==LISTING_LINK==' with the ID #==LISTING_ID== has been deleted successfully at ==SITE_LINK==. Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_new_order' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when an order is created.', 'directorist'), - 'value' => __('[==SITE_NAME==] : Your Order (#==ORDER_ID==) Received.', 'directorist'), - ], - 'email_tmpl_new_order' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when an order is created.', 'directorist'), - 'value' => __(" + ", + 'directorist' + ), + ), + 'email_sub_new_order' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when an order is created.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Your Order (#==ORDER_ID==) Received.', 'directorist' ), + ), + 'email_tmpl_new_order' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when an order is created.', 'directorist' ), + 'value' => __( + ' Dear ==NAME==, Thank you very much for your order. @@ -3395,19 +3861,23 @@ public function prepare_settings() Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_offline_new_order' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when an order is created using offline payment like bank transfer.', 'directorist'), - 'value' => __('[==SITE_NAME==] : Your Order (#==ORDER_ID==) Received.', 'directorist'), - ], - 'email_tmpl_offline_new_order' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when an order is created using offline payment like bank transfer.', 'directorist'), - 'value' => sprintf(__(" + ', + 'directorist' + ), + ), + 'email_sub_offline_new_order' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when an order is created using offline payment like bank transfer.', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Your Order (#==ORDER_ID==) Received.', 'directorist' ), + ), + 'email_tmpl_offline_new_order' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when an order is created using offline payment like bank transfer.', 'directorist' ), + 'value' => sprintf( + __( + ' Dear ==NAME==, Thank you very much for your order. @@ -3426,19 +3896,24 @@ public function prepare_settings() Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), get_directorist_option('bank_transfer_instruction')), - ], - 'email_sub_completed_order' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when an order is completed', 'directorist'), - 'value' => __('[==SITE_NAME==] : Congratulation! Your Order #==ORDER_ID== Completed.', 'directorist'), - ], - 'email_tmpl_completed_order' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when an order is completed.', 'directorist'), - 'value' => __(" + ', + 'directorist' + ), + get_directorist_option( 'bank_transfer_instruction' ) + ), + ), + 'email_sub_completed_order' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when an order is completed', 'directorist' ), + 'value' => __( '[==SITE_NAME==] : Congratulation! Your Order #==ORDER_ID== Completed.', 'directorist' ), + ), + 'email_tmpl_completed_order' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when an order is completed.', 'directorist' ), + 'value' => __( + ' Dear ==NAME==, Congratulation! This email is to notify you that your order #==ORDER_ID== has been completed. @@ -3454,19 +3929,22 @@ public function prepare_settings() Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_listing_contact_email' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when listing contact message send.', 'directorist'), - 'value' => __('==SITE_NAME== Contact via ==LISTING_TITLE==', 'directorist'), - ], - 'email_tmpl_listing_contact_email' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Edit the email template for sending to the user when when listing contact message send', 'directorist'), - 'value' => __(" + ', + 'directorist' + ), + ), + 'email_sub_listing_contact_email' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when listing contact message send.', 'directorist' ), + 'value' => __( '==SITE_NAME== Contact via ==LISTING_TITLE==', 'directorist' ), + ), + 'email_tmpl_listing_contact_email' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Edit the email template for sending to the user when when listing contact message send', 'directorist' ), + 'value' => __( + ' Dear ==NAME==, You have received a message from your listing at ==LISTING_URL==. @@ -3478,923 +3956,1213 @@ public function prepare_settings() Thanks, The Administrator of ==SITE_NAME== - ", 'directorist'), - ], - 'email_sub_registration_confirmation' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when listing contact message send.', 'directorist'), - 'value' => __('Registration Confirmation!', 'directorist'), - ], - 'email_tmpl_registration_confirmation' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Note: Use ==USER_PASSWORD== to show a temporary password when password field is disable from registration page', 'directorist'), - 'value' => __(' + ', + 'directorist' + ), + ), + 'email_sub_registration_confirmation' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when listing contact message send.', 'directorist' ), + 'value' => __( 'Registration Confirmation!', 'directorist' ), + ), + 'email_tmpl_registration_confirmation' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Note: Use ==USER_PASSWORD== to show a temporary password when password field is disable from registration page', 'directorist' ), + 'value' => __( + ' Hi ==USERNAME==, Thanks for creating an account on <b>==SITE_NAME==</b>. Your username is <b>==USERNAME==</b>. You can access your account area to view listings, change your password, and more at: ==DASHBOARD_LINK== - We look forward to seeing you soon', 'directorist'), - ], - // Email Verification - 'email_sub_email_verification' => [ - 'type' => 'text', - 'label' => __('Email Subject', 'directorist'), - 'description' => __('Edit the subject for sending to the user when listing contact message send.', 'directorist'), - 'value' => __('[==NAME==] Verify Your Email', 'directorist'), - ], - 'email_tmpl_email_verification' => [ - 'type' => 'textarea', - 'label' => __('Email Body', 'directorist'), - 'description' => __('Note: Use ==USER_PASSWORD== to show a temporary password when password field is disable from registration page', 'directorist'), - 'value' => __('Hi ==USERNAME==, + We look forward to seeing you soon', + 'directorist' + ), + ), + // Email Verification + 'email_sub_email_verification' => array( + 'type' => 'text', + 'label' => __( 'Email Subject', 'directorist' ), + 'description' => __( 'Edit the subject for sending to the user when listing contact message send.', 'directorist' ), + 'value' => __( '[==NAME==] Verify Your Email', 'directorist' ), + ), + 'email_tmpl_email_verification' => array( + 'type' => 'textarea', + 'label' => __( 'Email Body', 'directorist' ), + 'description' => __( 'Note: Use ==USER_PASSWORD== to show a temporary password when password field is disable from registration page', 'directorist' ), + 'value' => __( + 'Hi ==USERNAME==, Thank you for signing up at ==SITE_NAME==, to complete the registration, please verify your email address. To activate your account simply click on the link below and verify your email address within 24 hours. For your safety, you will not be able to access your account until verification of your email has been completed. ==CONFIRM_EMAIL_ADDRESS_URL== - <p align="center">If you did not sign up for this account you can ignore this email.</p>', 'directorist'), - ], - // single template settings - - 'enable_uninstall' => [ - 'type' => 'toggle', - 'label' => __('Remove Data on Uninstall?', 'directorist'), - 'description'=> __('Checked it if you would like Directorist to completely remove all of its data when the plugin is deleted.','directorist'), - 'value' => false, - ], - ]); - - $this->layouts = apply_filters('atbdp_listing_type_settings_layout', [ - 'listing_settings' => [ - 'label' => __( 'Listings', 'directorist' ), - 'icon' => '<i class="fa fa-list directorist_Blue"></i>', - 'submenu' => apply_filters('atbdp_listing_settings_submenu', [ - 'general' => [ - 'label' => __('General', 'directorist'), - 'icon' => '<i class="fa fa-sliders-h"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_general_sections', [ - 'general_top_settings' => [ - 'fields' => [ - // 'all_listing_layout', - 'enable_multi_directory', - 'guest_listings', - 'guest_email_label', - 'guest_email_placeholder', - ], - ], - 'registration' => [ - 'title' => __( 'Registration', 'directorist' ), - 'fields' => [ - 'new_user_registration', 'enable_email_verification' - ], - ], - 'listings_currency' => [ - 'title' => __( 'Listing Currency', 'directorist' ), - 'fields' => [ - 'g_currency_note', 'g_currency', 'g_currency_position' - ], - ], - 'listings_renewal' => [ - 'title' => __( 'Listings Renewal', 'directorist' ), - 'fields' => [ - 'email_to_expire_day', 'email_renewal_day', - ], - ], - 'expired_listings_actions' => [ - 'title' => __( 'Expired Listings Management', 'directorist' ), - 'fields' => [ - 'delete_expired_listing_permanently', 'delete_expired_listings_after', - ], - ], - ] ), - ], - 'listings_page' => [ - 'label' => __('All Listings', 'directorist'), - 'icon' => '<i class="fa fa-archive"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_listings_page_sections', [ - 'layout_search' => [ - 'title' => __(' Layout & Search', 'directorist' ), - 'fields' => [ - 'all_listing_layout', - 'all_listing_columns', - 'all_listing_page_items', - 'pagination_type', - 'listing_hide_top_search_bar', - 'listings_sidebar_filter_text', - 'listings_reset_text', - 'listings_sidebar_reset_text', - 'listings_apply_text', - ], - ], - 'header' => [ - 'title' => __( 'Header', 'directorist' ), - 'fields' => [ - 'display_listings_header', - 'listing_filters_button', - 'listings_filter_button_text', - 'display_listings_count', - 'all_listing_title', - 'listings_view_as_items', - 'default_listing_view', - 'display_sort_by', - 'sort_by_text', - 'listings_sort_by_items', - ], - ], - 'preview_image' => [ - 'title' => __( 'Preview Image', 'directorist' ), - 'fields' => [ - 'preview_image_quality', - 'way_to_show_preview', - 'crop_width', - 'crop_height', - 'prv_container_size_by', - 'prv_background_type', - 'prv_background_color' - ], - ], - ] ), - ], - 'single_listing' => [ - 'label' => __('Single Listing', 'directorist'), - 'icon' => '<i class="fa fa-info"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_listing_page_sections', [ - 'listing_template_view' => [ - 'title' => __( 'Listing Template and View', 'directorist' ), - 'fields' => [ - 'single_listing_template', 'disable_single_listing', 'restrict_single_listing_for_logged_in_user', - ], - ], - 'listing_permalink' => [ - 'title' => __( 'Listing Permalink', 'directorist' ), - 'fields' => [ - 'atbdp_listing_slug', - 'single_listing_slug_with_directory_type', - ], - ], - 'submission_confirmation' => [ - 'title' => __( 'Submission Confirmations', 'directorist' ), - 'fields' => [ - 'submission_confirmation', - 'pending_confirmation_msg', - 'publish_confirmation_msg', - ], - ], - 'slider_image' => [ - 'title' => __( 'Slider Image', 'directorist' ), - 'fields' => [ - 'dsiplay_slider_single_page', - 'single_slider_image_size', - 'single_slider_background_type', - 'single_slider_background_color', - 'gallery_crop_width', - 'gallery_crop_height' - ], - ], - ] ), - ], - 'categories_locations' => [ - 'label' => __( 'Category & Location', 'directorist' ), - 'icon' => '<i class="fa fa-list-alt"></i>', - 'sections' => apply_filters( 'atbdp_categories_settings_sections', [ - 'categories_settings' => [ - 'title' => __('Categories Page', 'directorist'), - 'fields' => [ - 'display_categories_as', 'categories_column_number', 'categories_depth_number', 'order_category_by', 'sort_category_by', 'display_listing_count', 'hide_empty_categories' - ], - ], - 'locations_settings' => [ - 'title' => __('Locations Page', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_locations_as', 'locations_column_number', 'locations_depth_number', 'order_location_by', 'sort_location_by', 'display_location_listing_count', 'hide_empty_locations' - ], - ], - ] ), - ], - - 'map' => [ - 'label' => __('Map', 'directorist'), - 'icon' => '<i class="fa fa-map"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_map_sections', [ - 'map_settings' => [ - 'title' => __('Map', 'directorist'), - 'description' => '', - 'fields' => [ - 'select_listing_map', 'map_api_key', 'marker_clustering', 'country_restriction', 'restricted_countries', 'default_latitude', 'default_longitude', 'use_def_lat_long', 'map_zoom_level', 'map_view_zoom_level', 'listings_map_height' - ], - ], - 'map_info_window' => [ - 'title' => __('Map Info Window Settings', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_map_info', 'display_image_map', 'display_favorite_badge_map', 'display_user_avatar_map', 'display_title_map', 'display_review_map', 'display_price_map', 'display_address_map', 'display_direction_map', 'display_phone_map' - ], - ], - ] ), - ], - 'badge' => [ - 'label' => __('Badges', 'directorist'), - 'icon' => '<i class="fa fa-certificate"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_badge_sections', [ - 'badge_management' => [ - 'title' => __('New Badge', 'directorist'), - 'description' => '', - 'fields' => [ - 'new_badge_text', 'new_listing_day', 'new_back_color', - ], - ], - 'popular_badge' => [ - 'title' => __('Popular Badge', 'directorist'), - 'description' => '', - 'fields' => [ - 'popular_badge_text', 'listing_popular_by', 'views_for_popular', 'average_review_for_popular', 'count_loggedin_user', 'popular_back_color', - ], - ], - 'featured_badge' => [ - 'title' => __('Featured Badge', 'directorist'), - 'description' => '', - 'fields' => [ - 'feature_badge_type', 'feature_badge_text', 'featured_back_color', - ], - ], - ] ), - ], - - ]), - ], - - 'page_settings' => [ - 'label' => __( 'Page Setup', 'directorist' ), - 'icon' => '<i class="fa fa-desktop directorist_wordpress"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_page_settings_sections', [ - 'upgrade_pages' => [ - 'title' => __('Upgrade/Regenerate Pages', 'directorist'), - 'description' => '', - 'fields' => [ - 'regenerate_pages' - ], - ], - 'pages_links_views' => [ - 'title' => __('Page, Links & View Settings', 'directorist'), - 'description' => '', - 'fields' => apply_filters( 'atbdp_pages_settings_fields', [ - 'add_listing_page', 'all_listing_page', 'user_dashboard', 'signin_signup_page', 'author_profile_page', 'all_categories_page', 'single_category_page', 'all_locations_page', 'single_location_page', 'single_tag_page', 'search_listing', 'search_result_page', 'checkout_page', 'payment_receipt_page', 'transaction_failure_page' - ] ), - ], - ]), - ], - - 'search_settings' => [ - 'label' => __( 'Search', 'directorist' ), - 'icon' => '<i class="fa fa-search directorist_warning"></i>', - 'submenu' => apply_filters('atbdp_email_settings_submenu', [ - 'search_form' => [ - 'label' => __('Search Listing', 'directorist'), - 'icon' => '<i class="fa fa-search"></i>', - 'sections' => apply_filters( 'directorist_search_setting_sections', [ - 'search_bar' => [ - 'title' => __( 'Search Bar', 'directorist' ), - 'fields' => [ - 'search_title', 'search_subtitle', 'search_home_bg', 'search_listing_text', - ], - ], - 'search_filters' => [ - 'title' => __( 'Filters', 'directorist' ), - 'fields' => [ - 'search_more_filter', 'search_more_filters', 'search_filters', 'search_reset_text', 'search_apply_filter', - ], - ], - 'poplar_categories' => [ - 'title' => __( 'Popular Categories', 'directorist' ), - 'fields' => [ - 'show_popular_category', 'popular_cat_title', 'popular_cat_num', - ], - ], - ] ), - ], - - 'search_result' => [ - 'label' => __('Search Result', 'directorist'), - 'icon' => '<i class="fa fa-check"></i>', - 'sections' => apply_filters( 'atbdp_reg_settings_sections', [ - 'search_result_layout' => [ - 'title' => __('Layout & Search', 'directorist' ), - 'fields' => [ - 'search_result_layout', - 'search_listing_columns', - 'search_posts_num', - 'search_result_hide_top_search_bar', - 'search_result_sidebar_filter_text', - 'sresult_reset_text', - 'sresult_sidebar_reset_text', - 'sresult_apply_text', - ], - ], - 'search_result_header' => [ - 'title' => __('Header', 'directorist' ), - 'fields' => [ - 'search_header', - 'search_result_filters_button_display', - 'search_result_filter_button_text', - 'display_search_result_listings_count', - 'search_result_listing_title', - 'search_view_as_items', - 'search_sort_by', - 'search_sortby_text', - 'search_sort_by_items' - ], - ], - ] ), - ], - - ]), - ], - - 'user_settings' => [ - 'label' => __( 'User', 'directorist' ), - 'icon' => '<i class="fa fa-users-cog directorist_green"></i>', - 'submenu' => apply_filters('atbdp_user_settings_submenu', [ - 'registration_form' => [ - 'label' => __('Registration Form', 'directorist'), - 'icon' => '<i class="fa fa-envelope-open"></i>', - 'sections' => apply_filters( 'atbdp_reg_settings_sections', [ - 'username' => [ - 'title' => __('Username', 'directorist'), - 'description' => '', - 'fields' => [ - 'reg_username' - ], - ], - 'password' => [ - 'title' => __('Password', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_password_reg', 'reg_password', 'require_password_reg' - ], - ], - 'email' => [ - 'title' => __('Email', 'directorist'), - 'description' => '', - 'fields' => [ - 'reg_email' - ], - ], - 'website' => [ - 'title' => __('Website', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_website_reg', 'reg_website', 'require_website_reg' - ], - ], - 'first_name' => [ - 'title' => __('First Name', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_fname_reg', 'reg_fname', 'require_fname_reg' - ], - ], - 'last_name' => [ - 'title' => __('Last Name', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_lname_reg', 'reg_lname', 'require_lname_reg' - ], - ], - 'about' => [ - 'title' => __('About/Bio', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_bio_reg', 'reg_bio', 'require_bio_reg' - ], - ], - 'user_type' => [ - 'title' => __('User Type Registration', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_user_type' - ], - ], - 'privacy_policy' => [ - 'title' => __('Privacy Policy', 'directorist'), - 'description' => '', - 'fields' => [ - 'registration_privacy', 'registration_privacy_label', 'registration_privacy_label_link' - ], - ], - 'terms_condition' => [ - 'title' => __('Terms Conditions', 'directorist'), - 'description' => '', - 'fields' => [ - 'regi_terms_condition', 'regi_terms_label', 'regi_terms_label_link' - ], - ], - - 'signup_button' => [ - 'title' => __('Sign Up Button', 'directorist'), - 'description' => '', - 'fields' => [ - 'reg_signup' - ], - ], - 'login_message' => [ - 'title' => __('Login Message', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_login', 'login_text', 'log_linkingmsg' - ], - ], - 'redirection' => [ - 'title' => __('', 'directorist'), - 'description' => '', - 'fields' => [ - 'auto_login', 'redirection_after_reg' - ], - ], - ] ), - ], - 'login_form' => [ - 'label' => __('Login Form', 'directorist'), - 'icon' => '<i class="fa fa-mail-bulk"></i>', - 'sections' => apply_filters( 'directorist_login_form_templates_settings_sections', [ - 'username' => [ - 'title' => __('Username', 'directorist'), - 'description' => '', - 'fields' => [ - 'log_username' - ], - ], - 'password' => [ - 'title' => __('Password', 'directorist'), - 'description' => '', - 'fields' => [ - 'log_password' - ], - ], - 'remember_login_info' => [ - 'title' => __('Remember Login Information', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_rememberme', 'log_rememberme' - ], - ], - 'login_button' => [ - 'title' => __('Login Button', 'directorist'), - 'description' => '', - 'fields' => [ - 'log_button' - ], - ], - 'signup_message' => [ - 'title' => __('Sign Up Message', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_signup', 'reg_text', 'reg_linktxt' - ], - ], - 'recover_password' => [ - 'title' => __('Recover Password', 'directorist'), - 'description' => '', - 'fields' => [ - 'display_recpass', 'recpass_text', 'recpass_desc', 'recpass_username', 'recpass_placeholder', 'recpass_button' - ], - ], - 'login_redirect' => [ - 'title' => '', - 'description' => '', - 'fields' => [ - 'redirection_after_login' - ], - ], - - ] ), - ], - - 'user_dashboard' => [ - 'label' => __('Dashboard', 'directorist'), - 'icon' => '<i class="fa fa-chart-bar"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_user_dashboard_sections', [ - 'general_dashboard' => [ - 'fields' => [ - 'my_profile_tab', 'my_profile_tab_text', 'fav_listings_tab', 'fav_listings_tab_text' - ], - ], - 'author_dashboard' => [ - 'title' => __('Author Dashboard', 'directorist'), - 'description' => '', - 'fields' => [ - 'my_listing_tab', 'my_listing_tab_text', 'user_listings_pagination', 'user_listings_per_page', 'submit_listing_button' - ], - ], - 'user_dashboard' => [ - 'title' => __('User Dashboard', 'directorist'), - 'description' => '', - 'fields' => [ - 'become_author_button', 'become_author_button_text' - ], - ], - ] ), - ], - 'all_authors' => [ - 'label' => __('All Authors', 'directorist'), - 'icon' => '<i class="fa fa-users"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_user_dashboard_sections', [ - 'all_authors' => [ - 'title' => __('All Authors', 'directorist'), - 'description' => '', - 'fields' => [ - 'all_authors_columns', 'all_authors_sorting', 'all_authors_image', 'all_authors_name', 'all_authors_select_role', 'all_authors_contact', 'all_authors_description', 'all_authors_description_limit', 'all_authors_social_info', 'all_authors_button', 'all_authors_button_text', 'all_authors_pagination', 'all_authors_per_page' - ], - ], - ] ), - ], - ]), - ], - - 'email_settings' => [ - 'label' => __( 'Email', 'directorist' ), - 'icon' => '<i class="fa fa-envelope directorist_Blue"></i>', - 'submenu' => apply_filters('atbdp_email_settings_submenu', [ - 'email_general' => [ - 'label' => __('General', 'directorist'), - 'icon' => '<i class="fa fa-envelope-open directorist_info"></i>', - 'sections' => apply_filters( 'atbdp_reg_settings_sections', [ - 'sender_details' => [ - 'title' => __( 'Sender Details', 'directorist' ), - 'fields' => [ - 'email_from_name', - 'email_from_email', - ], - ], - 'email_notification' => [ - 'title' => __( 'Email Notifications', 'directorist' ), - 'fields' => [ - 'disable_email_notification', 'admin_email_lists', 'notify_admin', 'notify_user' - ], - ], - ] ), - ], - 'email_templates' => [ - 'label' => __('Templates', 'directorist'), - 'icon' => '<i class="fa fa-mail-bulk directorist_info"></i>', - 'sections' => apply_filters( 'atbdp_email_templates_settings_sections', [ - 'general' => [ - 'title' => __('General', 'directorist'), - 'description' => '', - 'fields' => [ - 'allow_email_header', 'email_header_color' - ], - ], - 'new_listing' => [ - 'title' => __('For New Listing', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_note', 'email_sub_new_listing', 'email_tmpl_new_listing' - ], - ], - 'approved_listings' => [ - 'title' => __('For Approved/Published Listings', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_pub_listing', 'email_tmpl_pub_listing' - ], - ], - 'edited_listings' => [ - 'title' => __('For Edited Listings', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_edit_listing', 'email_tmpl_edit_listing' - ], - ], - 'about_expire_listings' => [ - 'title' => __('For About To Expire Listings', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_to_expire_listing', 'email_tmpl_to_expire_listing' - ], - ], - 'expired_listings' => [ - 'title' => __('For Expired Listings', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_expired_listing', 'email_tmpl_expired_listing' - ], - ], - 'remind_renewal_listings' => [ - 'title' => __('For Renewal Listings (Remind To Renew)', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_to_renewal_listing', 'email_tmpl_to_renewal_listing' - ], - ], - 'after_renewed_listings' => [ - 'title' => __('For Renewed Listings (After Renewed)', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_renewed_listing', 'email_tmpl_renewed_listing' - ], - ], - 'deleted_listings' => [ - 'title' => __('For Deleted/Trashed Listings', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_deleted_listing', 'email_tmpl_deleted_listing' - ], - ], - 'new_order_created' => [ - 'title' => __('For New Order (Created)', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_new_order', 'email_tmpl_new_order' - ], - ], - 'new_order_offline_bank' => [ - 'title' => __('For New Order (Created Using Offline Bank Transfer)', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_offline_new_order', 'email_tmpl_offline_new_order' - ], - ], - 'completed_order' => [ - 'title' => __('For Completed Order', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_completed_order', 'email_tmpl_completed_order' - ], - ], - 'listing_contact_email' => [ - 'title' => __('For Listing Contact Email', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_listing_contact_email', 'email_tmpl_listing_contact_email' - ], - ], - 'registration_confirmation' => [ - 'title' => __('Registration Confirmation', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_registration_confirmation', 'email_tmpl_registration_confirmation' - ], - ], - 'email_verification' => [ - 'title' => __('Email Verification', 'directorist'), - 'description' => '', - 'fields' => [ - 'email_sub_email_verification', 'email_tmpl_email_verification' - ], - ], - ] ), - ], - ]), - ], - - 'monetization_settings' => [ - 'label' => __( 'Monetization', 'directorist' ), - 'icon' => '<i class="fa fa-credit-card directorist_info"></i>', - 'submenu' => apply_filters('atbdp_monetization_settings_submenu', [ - 'monetization_general' => [ - 'label' => __('General Settings', 'directorist'), - 'icon' => '<i class="fa fa-home"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_monetization_general_sections', [ - 'general' => [ - 'description' => '', - 'fields' => [ - 'enable_monetization', - ], - ], - 'currency' => [ - 'title' => __( 'Currency', 'directorist' ), - 'description' => '', - 'fields' => [ - 'payment_currency_note', - 'payment_currency', - 'payment_thousand_separator', - 'payment_decimal_separator', - 'payment_currency_position'], - ], - ] ), - ], - 'featured_listings' => [ - 'label' => __('Featured Listings', 'directorist'), - 'icon' => '<i class="fa fa-arrow-up"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_featured_sections', [ - 'featured' => [ - 'fields' => [ - 'enable_featured_listing', - 'featured_listing_desc', - 'featured_listing_price', - 'featured_listing_time', - ], - ], - ] ), - ], - 'gateway' => [ - 'label' => __('Payment Gateways', 'directorist'), - 'icon' => '<i class="fa fa-bezier-curve"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_gateway_sections', [ - 'gateway_general' => [ - 'fields' => [ - 'default_gateway', - 'active_gateways', - ], - ], - ] ), - ], - 'offline_gateway' => [ - 'label' => __('Bank Transfer', 'directorist'), - 'icon' => '<i class="fa fa-university"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_offline_gateway_sections', [ - 'offline_gateway_general' => [ - 'fields' => [ - 'offline_payment_note', - 'bank_transfer_title', - 'bank_transfer_description', - 'bank_transfer_instruction' - ], - ], - ] ), - ], - ]), - ], - - 'personalization' => [ - 'label' => __( 'Personalization', 'directorist' ), - 'icon' => '<i class="fa fa-paint-brush directorist_success"></i>', - 'sections'=> apply_filters('atbdp_style_settings_controls', [ - 'brand_color_section' => [ - 'title' => __('Brand', 'directorist'), - 'fields' => apply_filters('atbdp_primary_dark_color', [ - 'brand_color', - ]) - ], - 'button_type_section' => [ - 'title' => __('Button', 'directorist'), - 'fields' => [ - 'button_type', 'button_primary_example', 'button_primary_color', 'button_primary_bg_color', 'button_secondary_example', 'button_secondary_color', 'button_secondary_bg_color' - ] - ], - 'map_marker_section' => [ - 'title' => __('All Listings Map Marker', 'directorist'), - 'fields' => apply_filters('atbdp_map_marker_color', [ - 'marker_shape_color', - 'marker_icon_color' - ]) - ], - ]) - ], - - 'extension_settings' => [ - 'label' => __( 'Extensions', 'directorist' ), - 'icon' => '<i class="fa fa-magic directorist_danger"></i>', - 'submenu' => apply_filters('atbdp_extension_settings_submenu', [ - 'extensions_general' => [ - 'label' => __('Extensions General', 'directorist'), - 'icon' => '<i class="fa fa-home"></i>', - 'sections' => apply_filters( 'atbdp_extension_settings_controls', [ - 'general_settings' => [ - 'fields' => apply_filters( 'atbdp_extension_fields', [ - 'extension_promotion' - ]) , - ], - ] ), - ], - ]), - ], - - 'import_export' => [ - 'label' => __( 'Import and Export', 'directorist' ), - 'icon' => '<i class="fa fa-tools directorist_info"></i>', - 'sections' => apply_filters('atbdp_listings_import_controls', [ - 'import_methods' => array( - 'title' => __( 'Listings', 'directorist' ), - 'fields' => apply_filters('atbdp_csv_import_settings_fields', [ - 'listing_import_button', 'listing_export_button', - ]), - ), - 'export_methods' => array( - 'title' => __( 'Settings', 'directorist' ), - 'fields' => apply_filters('atbdp_csv_export_settings_fields', [ - 'import_settings', 'export_settings', 'restore_default_settings' - ]), - ), - ]), - ], - - 'advanced' => [ - 'label' => __( 'Advanced', 'directorist' ), - 'icon' => '<i class="fa fa-filter directorist_wordpress"></i>', - 'submenu' => apply_filters('atbdp_advanced_submenu', [ - 'seo_settings' => [ - 'label' => __( 'Title & Meta (SEO)', 'directorist' ), - 'icon' => '<i class="fa fa-bolt"></i>', - 'sections' => apply_filters( 'atbdp_seo_settings_sections', [ - 'title_metas' => [ - 'fields' => [ - 'atbdp_enable_seo', 'add_listing_page_meta_title', 'add_listing_page_meta_desc', 'all_listing_meta_title', 'all_listing_meta_desc', 'dashboard_meta_title', 'dashboard_meta_desc', 'author_profile_meta_title', 'author_page_meta_desc', 'category_meta_title', 'category_meta_desc', 'single_category_meta_title', 'single_category_meta_desc', 'all_locations_meta_title', 'all_locations_meta_desc', 'single_locations_meta_title', 'single_locations_meta_desc', 'registration_meta_title', 'registration_meta_desc', 'login_meta_title', 'login_meta_desc', 'homepage_meta_title', 'homepage_meta_desc', 'meta_title_for_search_result', 'search_result_meta_title', 'search_result_meta_desc' - ], - ], - ] ), - ], - - 'miscellaneous' => [ - 'label' => __('Miscellaneous', 'directorist'), - 'icon' => '<i class="fas fa-thumbtack"></i>', - 'sections' => apply_filters('atbdp_caching_controls', [ - 'caching' => [ - 'title' => __( 'Caching', 'directorist' ), - 'fields' => [ - 'atbdp_enable_cache', 'atbdp_reset_cache', - ], - ], - 'debugging' => [ - 'title' => __( 'Debugging', 'directorist' ), - 'fields' => [ - 'script_debugging', - ], - ], - 'uninstall' => [ - 'title' => __( 'Uninstall', 'directorist' ), - 'fields' => [ 'enable_uninstall' ] - ], - ] ), - ], - ]), - ], - - ]); - - $this->config = [ - 'fields_theme' => 'butterfly', - 'submission' => [ - 'url' => admin_url('admin-ajax.php'), - 'with' => [ - 'action' => 'save_settings_data', - 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ), - ], - ], - ]; - - - } - - - // add_menu_pages - public function add_menu_pages() - { - add_submenu_page( - 'edit.php?post_type=at_biz_dir', - 'Settings', - 'Settings', - 'manage_options', - 'atbdp-settings', - [ $this, 'menu_page_callback__settings_manager' ], - 12 - ); - } - - // menu_page_callback__settings_manager - public function menu_page_callback__settings_manager() - { - // Prepare Settings - $this->prepare_settings(); - - // Get Saved Data - $atbdp_options = get_option('atbdp_option'); - - foreach( $this->fields as $field_key => $field_opt ) { - if ( ! isset( $atbdp_options[ $field_key ] ) ) { - $this->fields[ $field_key ]['forceUpdate'] = true; - continue; - } - - $this->fields[ $field_key ]['value'] = $atbdp_options[ $field_key ]; - } - - $settings_builder_data = [ - 'fields' => $this->fields, - 'layouts' => $this->layouts, - 'config' => $this->config, - ]; - - /* $status = $this->update_settings_options([ - 'new_listing_status' => 'publish', - 'edit_listing_status' => 'publish', - ]); - - $check_new = get_directorist_option( 'new_listing_status' ); - $check_edit = get_directorist_option( 'edit_listing_status' ); - - var_dump( [ '$check_new' => $check_new, '$check_edit' => $check_edit] ); */ + <p align="center">If you did not sign up for this account you can ignore this email.</p>', + 'directorist' + ), + ), + // single template settings + + 'enable_uninstall' => array( + 'type' => 'toggle', + 'label' => __( 'Remove Data on Uninstall?', 'directorist' ), + 'description' => __( 'Checked it if you would like Directorist to completely remove all of its data when the plugin is deleted.', 'directorist' ), + 'value' => false, + ), + ) + ); + + $this->layouts = apply_filters( + 'atbdp_listing_type_settings_layout', + array( + 'listing_settings' => array( + 'label' => __( 'Listings', 'directorist' ), + 'icon' => '<i class="fa fa-list directorist_Blue"></i>', + 'submenu' => apply_filters( + 'atbdp_listing_settings_submenu', + array( + 'general' => array( + 'label' => __( 'General', 'directorist' ), + 'icon' => '<i class="fa fa-sliders-h"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_general_sections', + array( + 'general_top_settings' => array( + 'fields' => array( + // 'all_listing_layout', + 'enable_multi_directory', + 'guest_listings', + 'guest_email_label', + 'guest_email_placeholder', + ), + ), + 'registration' => array( + 'title' => __( 'Registration', 'directorist' ), + 'fields' => array( + 'new_user_registration', + 'enable_email_verification', + ), + ), + 'listings_currency' => array( + 'title' => __( 'Listing Currency', 'directorist' ), + 'fields' => array( + 'g_currency_note', + 'g_currency', + 'g_currency_position', + ), + ), + 'listings_renewal' => array( + 'title' => __( 'Listings Renewal', 'directorist' ), + 'fields' => array( + 'email_to_expire_day', + 'email_renewal_day', + ), + ), + 'expired_listings_actions' => array( + 'title' => __( 'Expired Listings Management', 'directorist' ), + 'fields' => array( + 'delete_expired_listing_permanently', + 'delete_expired_listings_after', + ), + ), + ) + ), + ), + 'listings_page' => array( + 'label' => __( 'All Listings', 'directorist' ), + 'icon' => '<i class="fa fa-archive"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_listings_page_sections', + array( + 'layout_search' => array( + 'title' => __( ' Layout & Search', 'directorist' ), + 'fields' => array( + 'all_listing_layout', + 'all_listing_columns', + 'all_listing_page_items', + 'pagination_type', + 'listing_hide_top_search_bar', + 'listings_sidebar_filter_text', + 'listings_reset_text', + 'listings_sidebar_reset_text', + 'listings_apply_text', + ), + ), + 'header' => array( + 'title' => __( 'Header', 'directorist' ), + 'fields' => array( + 'display_listings_header', + 'listing_filters_button', + 'listings_filter_button_text', + 'display_listings_count', + 'all_listing_title', + 'listings_view_as_items', + 'default_listing_view', + 'display_sort_by', + 'sort_by_text', + 'listings_sort_by_items', + ), + ), + 'preview_image' => array( + 'title' => __( 'Preview Image', 'directorist' ), + 'fields' => array( + 'preview_image_quality', + 'way_to_show_preview', + 'crop_width', + 'crop_height', + 'prv_container_size_by', + 'prv_background_type', + 'prv_background_color', + ), + ), + ) + ), + ), + 'single_listing' => array( + 'label' => __( 'Single Listing', 'directorist' ), + 'icon' => '<i class="fa fa-info"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_listing_page_sections', + array( + 'listing_template_view' => array( + 'title' => __( 'Listing Template and View', 'directorist' ), + 'fields' => array( + 'single_listing_template', + 'disable_single_listing', + 'restrict_single_listing_for_logged_in_user', + ), + ), + 'listing_permalink' => array( + 'title' => __( 'Listing Permalink', 'directorist' ), + 'fields' => array( + 'atbdp_listing_slug', + 'single_listing_slug_with_directory_type', + ), + ), + 'submission_confirmation' => array( + 'title' => __( 'Submission Confirmations', 'directorist' ), + 'fields' => array( + 'submission_confirmation', + 'pending_confirmation_msg', + 'publish_confirmation_msg', + ), + ), + 'slider_image' => array( + 'title' => __( 'Slider Image', 'directorist' ), + 'fields' => array( + 'dsiplay_slider_single_page', + 'single_slider_image_size', + 'single_slider_background_type', + 'single_slider_background_color', + 'gallery_crop_width', + 'gallery_crop_height', + ), + ), + ) + ), + ), + 'categories_locations' => array( + 'label' => __( 'Category & Location', 'directorist' ), + 'icon' => '<i class="fa fa-list-alt"></i>', + 'sections' => apply_filters( + 'atbdp_categories_settings_sections', + array( + 'categories_settings' => array( + 'title' => __( 'Categories Page', 'directorist' ), + 'fields' => array( + 'display_categories_as', + 'categories_column_number', + 'categories_depth_number', + 'order_category_by', + 'sort_category_by', + 'display_listing_count', + 'hide_empty_categories', + ), + ), + 'locations_settings' => array( + 'title' => __( 'Locations Page', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_locations_as', + 'locations_column_number', + 'locations_depth_number', + 'order_location_by', + 'sort_location_by', + 'display_location_listing_count', + 'hide_empty_locations', + ), + ), + ) + ), + ), + + 'map' => array( + 'label' => __( 'Map', 'directorist' ), + 'icon' => '<i class="fa fa-map"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_map_sections', + array( + 'map_settings' => array( + 'title' => __( 'Map', 'directorist' ), + 'description' => '', + 'fields' => array( + 'select_listing_map', + 'map_api_key', + 'marker_clustering', + 'country_restriction', + 'restricted_countries', + 'default_latitude', + 'default_longitude', + 'use_def_lat_long', + 'map_zoom_level', + 'map_view_zoom_level', + 'listings_map_height', + ), + ), + 'map_info_window' => array( + 'title' => __( 'Map Info Window Settings', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_map_info', + 'display_image_map', + 'display_favorite_badge_map', + 'display_user_avatar_map', + 'display_title_map', + 'display_review_map', + 'display_price_map', + 'display_address_map', + 'display_direction_map', + 'display_phone_map', + ), + ), + ) + ), + ), + 'badge' => array( + 'label' => __( 'Badges', 'directorist' ), + 'icon' => '<i class="fa fa-certificate"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_badge_sections', + array( + 'badge_management' => array( + 'title' => __( 'New Badge', 'directorist' ), + 'description' => '', + 'fields' => array( + 'new_badge_text', + 'new_listing_day', + 'new_back_color', + ), + ), + 'popular_badge' => array( + 'title' => __( 'Popular Badge', 'directorist' ), + 'description' => '', + 'fields' => array( + 'popular_badge_text', + 'listing_popular_by', + 'views_for_popular', + 'average_review_for_popular', + 'count_loggedin_user', + 'popular_back_color', + ), + ), + 'featured_badge' => array( + 'title' => __( 'Featured Badge', 'directorist' ), + 'description' => '', + 'fields' => array( + 'feature_badge_type', + 'feature_badge_text', + 'featured_back_color', + ), + ), + ) + ), + ), + + ) + ), + ), + + 'page_settings' => array( + 'label' => __( 'Page Setup', 'directorist' ), + 'icon' => '<i class="fa fa-desktop directorist_wordpress"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_page_settings_sections', + array( + 'upgrade_pages' => array( + 'title' => __( 'Upgrade/Regenerate Pages', 'directorist' ), + 'description' => '', + 'fields' => array( + 'regenerate_pages', + ), + ), + 'pages_links_views' => array( + 'title' => __( 'Page, Links & View Settings', 'directorist' ), + 'description' => '', + 'fields' => apply_filters( + 'atbdp_pages_settings_fields', + array( + 'add_listing_page', + 'all_listing_page', + 'user_dashboard', + 'signin_signup_page', + 'author_profile_page', + 'all_categories_page', + 'single_category_page', + 'all_locations_page', + 'single_location_page', + 'single_tag_page', + 'search_listing', + 'search_result_page', + 'checkout_page', + 'payment_receipt_page', + 'transaction_failure_page', + ) + ), + ), + ) + ), + ), + + 'search_settings' => array( + 'label' => __( 'Search', 'directorist' ), + 'icon' => '<i class="fa fa-search directorist_warning"></i>', + 'submenu' => apply_filters( + 'atbdp_email_settings_submenu', + array( + 'search_form' => array( + 'label' => __( 'Search Listing', 'directorist' ), + 'icon' => '<i class="fa fa-search"></i>', + 'sections' => apply_filters( + 'directorist_search_setting_sections', + array( + 'search_bar' => array( + 'title' => __( 'Search Bar', 'directorist' ), + 'fields' => array( + 'search_title', + 'search_subtitle', + 'search_home_bg', + 'search_listing_text', + ), + ), + 'search_filters' => array( + 'title' => __( 'Filters', 'directorist' ), + 'fields' => array( + 'search_more_filter', + 'search_more_filters', + 'search_filters', + 'search_reset_text', + 'search_apply_filter', + ), + ), + 'poplar_categories' => array( + 'title' => __( 'Popular Categories', 'directorist' ), + 'fields' => array( + 'show_popular_category', + 'popular_cat_title', + 'popular_cat_num', + ), + ), + ) + ), + ), + + 'search_result' => array( + 'label' => __( 'Search Result', 'directorist' ), + 'icon' => '<i class="fa fa-check"></i>', + 'sections' => apply_filters( + 'atbdp_reg_settings_sections', + array( + 'search_result_layout' => array( + 'title' => __( 'Layout & Search', 'directorist' ), + 'fields' => array( + 'search_result_layout', + 'search_listing_columns', + 'search_posts_num', + 'search_result_hide_top_search_bar', + 'search_result_sidebar_filter_text', + 'sresult_reset_text', + 'sresult_sidebar_reset_text', + 'sresult_apply_text', + ), + ), + 'search_result_header' => array( + 'title' => __( 'Header', 'directorist' ), + 'fields' => array( + 'search_header', + 'search_result_filters_button_display', + 'search_result_filter_button_text', + 'display_search_result_listings_count', + 'search_result_listing_title', + 'search_view_as_items', + 'search_sort_by', + 'search_sortby_text', + 'search_sort_by_items', + ), + ), + ) + ), + ), + + ) + ), + ), + + 'user_settings' => array( + 'label' => __( 'User', 'directorist' ), + 'icon' => '<i class="fa fa-users-cog directorist_green"></i>', + 'submenu' => apply_filters( + 'atbdp_user_settings_submenu', + array( + 'registration_form' => array( + 'label' => __( 'Registration Form', 'directorist' ), + 'icon' => '<i class="fa fa-envelope-open"></i>', + 'sections' => apply_filters( + 'atbdp_reg_settings_sections', + array( + 'username' => array( + 'title' => __( 'Username', 'directorist' ), + 'description' => '', + 'fields' => array( + 'reg_username', + ), + ), + 'password' => array( + 'title' => __( 'Password', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_password_reg', + 'reg_password', + 'require_password_reg', + ), + ), + 'email' => array( + 'title' => __( 'Email', 'directorist' ), + 'description' => '', + 'fields' => array( + 'reg_email', + ), + ), + 'website' => array( + 'title' => __( 'Website', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_website_reg', + 'reg_website', + 'require_website_reg', + ), + ), + 'first_name' => array( + 'title' => __( 'First Name', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_fname_reg', + 'reg_fname', + 'require_fname_reg', + ), + ), + 'last_name' => array( + 'title' => __( 'Last Name', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_lname_reg', + 'reg_lname', + 'require_lname_reg', + ), + ), + 'about' => array( + 'title' => __( 'About/Bio', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_bio_reg', + 'reg_bio', + 'require_bio_reg', + ), + ), + 'user_type' => array( + 'title' => __( 'User Type Registration', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_user_type', + ), + ), + 'privacy_policy' => array( + 'title' => __( 'Privacy Policy', 'directorist' ), + 'description' => '', + 'fields' => array( + 'registration_privacy', + 'registration_privacy_label', + 'registration_privacy_label_link', + ), + ), + 'terms_condition' => array( + 'title' => __( 'Terms Conditions', 'directorist' ), + 'description' => '', + 'fields' => array( + 'regi_terms_condition', + 'regi_terms_label', + 'regi_terms_label_link', + ), + ), + + 'signup_button' => array( + 'title' => __( 'Sign Up Button', 'directorist' ), + 'description' => '', + 'fields' => array( + 'reg_signup', + ), + ), + 'login_message' => array( + 'title' => __( 'Login Message', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_login', + 'login_text', + 'log_linkingmsg', + ), + ), + 'redirection' => array( + 'title' => __( '', 'directorist' ), + 'description' => '', + 'fields' => array( + 'auto_login', + 'redirection_after_reg', + ), + ), + ) + ), + ), + 'login_form' => array( + 'label' => __( 'Login Form', 'directorist' ), + 'icon' => '<i class="fa fa-mail-bulk"></i>', + 'sections' => apply_filters( + 'directorist_login_form_templates_settings_sections', + array( + 'username' => array( + 'title' => __( 'Username', 'directorist' ), + 'description' => '', + 'fields' => array( + 'log_username', + ), + ), + 'password' => array( + 'title' => __( 'Password', 'directorist' ), + 'description' => '', + 'fields' => array( + 'log_password', + ), + ), + 'remember_login_info' => array( + 'title' => __( 'Remember Login Information', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_rememberme', + 'log_rememberme', + ), + ), + 'login_button' => array( + 'title' => __( 'Login Button', 'directorist' ), + 'description' => '', + 'fields' => array( + 'log_button', + ), + ), + 'signup_message' => array( + 'title' => __( 'Sign Up Message', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_signup', + 'reg_text', + 'reg_linktxt', + ), + ), + 'recover_password' => array( + 'title' => __( 'Recover Password', 'directorist' ), + 'description' => '', + 'fields' => array( + 'display_recpass', + 'recpass_text', + 'recpass_desc', + 'recpass_username', + 'recpass_placeholder', + 'recpass_button', + ), + ), + 'login_redirect' => array( + 'title' => '', + 'description' => '', + 'fields' => array( + 'redirection_after_login', + ), + ), + + ) + ), + ), + + 'user_dashboard' => array( + 'label' => __( 'Dashboard', 'directorist' ), + 'icon' => '<i class="fa fa-chart-bar"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_user_dashboard_sections', + array( + 'general_dashboard' => array( + 'fields' => array( + 'my_profile_tab', + 'my_profile_tab_text', + 'fav_listings_tab', + 'fav_listings_tab_text', + ), + ), + 'author_dashboard' => array( + 'title' => __( 'Author Dashboard', 'directorist' ), + 'description' => '', + 'fields' => array( + 'my_listing_tab', + 'my_listing_tab_text', + 'user_listings_pagination', + 'user_listings_per_page', + 'submit_listing_button', + ), + ), + 'user_dashboard' => array( + 'title' => __( 'User Dashboard', 'directorist' ), + 'description' => '', + 'fields' => array( + 'become_author_button', + 'become_author_button_text', + ), + ), + ) + ), + ), + 'all_authors' => array( + 'label' => __( 'All Authors', 'directorist' ), + 'icon' => '<i class="fa fa-users"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_user_dashboard_sections', + array( + 'all_authors' => array( + 'title' => __( 'All Authors', 'directorist' ), + 'description' => '', + 'fields' => array( + 'all_authors_columns', + 'all_authors_sorting', + 'all_authors_image', + 'all_authors_name', + 'all_authors_select_role', + 'all_authors_contact', + 'all_authors_description', + 'all_authors_description_limit', + 'all_authors_social_info', + 'all_authors_button', + 'all_authors_button_text', + 'all_authors_pagination', + 'all_authors_per_page', + ), + ), + ) + ), + ), + ) + ), + ), + + 'email_settings' => array( + 'label' => __( 'Email', 'directorist' ), + 'icon' => '<i class="fa fa-envelope directorist_Blue"></i>', + 'submenu' => apply_filters( + 'atbdp_email_settings_submenu', + array( + 'email_general' => array( + 'label' => __( 'General', 'directorist' ), + 'icon' => '<i class="fa fa-envelope-open directorist_info"></i>', + 'sections' => apply_filters( + 'atbdp_reg_settings_sections', + array( + 'sender_details' => array( + 'title' => __( 'Sender Details', 'directorist' ), + 'fields' => array( + 'email_from_name', + 'email_from_email', + ), + ), + 'email_notification' => array( + 'title' => __( 'Email Notifications', 'directorist' ), + 'fields' => array( + 'disable_email_notification', + 'admin_email_lists', + 'notify_admin', + 'notify_user', + ), + ), + ) + ), + ), + 'email_templates' => array( + 'label' => __( 'Templates', 'directorist' ), + 'icon' => '<i class="fa fa-mail-bulk directorist_info"></i>', + 'sections' => apply_filters( + 'atbdp_email_templates_settings_sections', + array( + 'general' => array( + 'title' => __( 'General', 'directorist' ), + 'description' => '', + 'fields' => array( + 'allow_email_header', + 'email_header_color', + ), + ), + 'new_listing' => array( + 'title' => __( 'For New Listing', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_note', + 'email_sub_new_listing', + 'email_tmpl_new_listing', + ), + ), + 'approved_listings' => array( + 'title' => __( 'For Approved/Published Listings', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_pub_listing', + 'email_tmpl_pub_listing', + ), + ), + 'edited_listings' => array( + 'title' => __( 'For Edited Listings', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_edit_listing', + 'email_tmpl_edit_listing', + ), + ), + 'about_expire_listings' => array( + 'title' => __( 'For About To Expire Listings', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_to_expire_listing', + 'email_tmpl_to_expire_listing', + ), + ), + 'expired_listings' => array( + 'title' => __( 'For Expired Listings', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_expired_listing', + 'email_tmpl_expired_listing', + ), + ), + 'remind_renewal_listings' => array( + 'title' => __( 'For Renewal Listings (Remind To Renew)', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_to_renewal_listing', + 'email_tmpl_to_renewal_listing', + ), + ), + 'after_renewed_listings' => array( + 'title' => __( 'For Renewed Listings (After Renewed)', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_renewed_listing', + 'email_tmpl_renewed_listing', + ), + ), + 'deleted_listings' => array( + 'title' => __( 'For Deleted/Trashed Listings', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_deleted_listing', + 'email_tmpl_deleted_listing', + ), + ), + 'new_order_created' => array( + 'title' => __( 'For New Order (Created)', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_new_order', + 'email_tmpl_new_order', + ), + ), + 'new_order_offline_bank' => array( + 'title' => __( 'For New Order (Created Using Offline Bank Transfer)', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_offline_new_order', + 'email_tmpl_offline_new_order', + ), + ), + 'completed_order' => array( + 'title' => __( 'For Completed Order', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_completed_order', + 'email_tmpl_completed_order', + ), + ), + 'listing_contact_email' => array( + 'title' => __( 'For Listing Contact Email', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_listing_contact_email', + 'email_tmpl_listing_contact_email', + ), + ), + 'registration_confirmation' => array( + 'title' => __( 'Registration Confirmation', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_registration_confirmation', + 'email_tmpl_registration_confirmation', + ), + ), + 'email_verification' => array( + 'title' => __( 'Email Verification', 'directorist' ), + 'description' => '', + 'fields' => array( + 'email_sub_email_verification', + 'email_tmpl_email_verification', + ), + ), + ) + ), + ), + ) + ), + ), + + 'monetization_settings' => array( + 'label' => __( 'Monetization', 'directorist' ), + 'icon' => '<i class="fa fa-credit-card directorist_info"></i>', + 'submenu' => apply_filters( + 'atbdp_monetization_settings_submenu', + array( + 'monetization_general' => array( + 'label' => __( 'General Settings', 'directorist' ), + 'icon' => '<i class="fa fa-home"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_monetization_general_sections', + array( + 'general' => array( + 'description' => '', + 'fields' => array( + 'enable_monetization', + ), + ), + 'currency' => array( + 'title' => __( 'Currency', 'directorist' ), + 'description' => '', + 'fields' => array( + 'payment_currency_note', + 'payment_currency', + 'payment_thousand_separator', + 'payment_decimal_separator', + 'payment_currency_position', + ), + ), + ) + ), + ), + 'featured_listings' => array( + 'label' => __( 'Featured Listings', 'directorist' ), + 'icon' => '<i class="fa fa-arrow-up"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_featured_sections', + array( + 'featured' => array( + 'fields' => array( + 'enable_featured_listing', + 'featured_listing_desc', + 'featured_listing_price', + 'featured_listing_time', + ), + ), + ) + ), + ), + 'gateway' => array( + 'label' => __( 'Payment Gateways', 'directorist' ), + 'icon' => '<i class="fa fa-bezier-curve"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_gateway_sections', + array( + 'gateway_general' => array( + 'fields' => array( + 'default_gateway', + 'active_gateways', + ), + ), + ) + ), + ), + 'offline_gateway' => array( + 'label' => __( 'Bank Transfer', 'directorist' ), + 'icon' => '<i class="fa fa-university"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_offline_gateway_sections', + array( + 'offline_gateway_general' => array( + 'fields' => array( + 'offline_payment_note', + 'bank_transfer_title', + 'bank_transfer_description', + 'bank_transfer_instruction', + ), + ), + ) + ), + ), + ) + ), + ), + + 'personalization' => array( + 'label' => __( 'Personalization', 'directorist' ), + 'icon' => '<i class="fa fa-paint-brush directorist_success"></i>', + 'sections' => apply_filters( + 'atbdp_style_settings_controls', + array( + 'brand_color_section' => array( + 'title' => __( 'Brand', 'directorist' ), + 'fields' => apply_filters( + 'atbdp_primary_dark_color', + array( + 'brand_color', + ) + ), + ), + 'button_type_section' => array( + 'title' => __( 'Button', 'directorist' ), + 'fields' => array( + 'button_type', + 'button_primary_example', + 'button_primary_color', + 'button_primary_bg_color', + 'button_secondary_example', + 'button_secondary_color', + 'button_secondary_bg_color', + ), + ), + 'map_marker_section' => array( + 'title' => __( 'All Listings Map Marker', 'directorist' ), + 'fields' => apply_filters( + 'atbdp_map_marker_color', + array( + 'marker_shape_color', + 'marker_icon_color', + ) + ), + ), + ) + ), + ), + + 'extension_settings' => array( + 'label' => __( 'Extensions', 'directorist' ), + 'icon' => '<i class="fa fa-magic directorist_danger"></i>', + 'submenu' => apply_filters( + 'atbdp_extension_settings_submenu', + array( + 'extensions_general' => array( + 'label' => __( 'Extensions General', 'directorist' ), + 'icon' => '<i class="fa fa-home"></i>', + 'sections' => apply_filters( + 'atbdp_extension_settings_controls', + array( + 'general_settings' => array( + 'fields' => apply_filters( + 'atbdp_extension_fields', + array( + 'extension_promotion', + ) + ), + ), + ) + ), + ), + ) + ), + ), + + 'import_export' => array( + 'label' => __( 'Import and Export', 'directorist' ), + 'icon' => '<i class="fa fa-tools directorist_info"></i>', + 'sections' => apply_filters( + 'atbdp_listings_import_controls', + array( + 'import_methods' => array( + 'title' => __( 'Listings', 'directorist' ), + 'fields' => apply_filters( + 'atbdp_csv_import_settings_fields', + array( + 'listing_import_button', + 'listing_export_button', + ) + ), + ), + 'export_methods' => array( + 'title' => __( 'Settings', 'directorist' ), + 'fields' => apply_filters( + 'atbdp_csv_export_settings_fields', + array( + 'import_settings', + 'export_settings', + 'restore_default_settings', + ) + ), + ), + ) + ), + ), + + 'advanced' => array( + 'label' => __( 'Advanced', 'directorist' ), + 'icon' => '<i class="fa fa-filter directorist_wordpress"></i>', + 'submenu' => apply_filters( + 'atbdp_advanced_submenu', + array( + 'seo_settings' => array( + 'label' => __( 'Title & Meta (SEO)', 'directorist' ), + 'icon' => '<i class="fa fa-bolt"></i>', + 'sections' => apply_filters( + 'atbdp_seo_settings_sections', + array( + 'title_metas' => array( + 'fields' => array( + 'atbdp_enable_seo', + 'add_listing_page_meta_title', + 'add_listing_page_meta_desc', + 'all_listing_meta_title', + 'all_listing_meta_desc', + 'dashboard_meta_title', + 'dashboard_meta_desc', + 'author_profile_meta_title', + 'author_page_meta_desc', + 'category_meta_title', + 'category_meta_desc', + 'single_category_meta_title', + 'single_category_meta_desc', + 'all_locations_meta_title', + 'all_locations_meta_desc', + 'single_locations_meta_title', + 'single_locations_meta_desc', + 'registration_meta_title', + 'registration_meta_desc', + 'login_meta_title', + 'login_meta_desc', + 'homepage_meta_title', + 'homepage_meta_desc', + 'meta_title_for_search_result', + 'search_result_meta_title', + 'search_result_meta_desc', + ), + ), + ) + ), + ), + + 'miscellaneous' => array( + 'label' => __( 'Miscellaneous', 'directorist' ), + 'icon' => '<i class="fas fa-thumbtack"></i>', + 'sections' => apply_filters( + 'atbdp_caching_controls', + array( + 'caching' => array( + 'title' => __( 'Caching', 'directorist' ), + 'fields' => array( + 'atbdp_enable_cache', + 'atbdp_reset_cache', + ), + ), + 'debugging' => array( + 'title' => __( 'Debugging', 'directorist' ), + 'fields' => array( + 'script_debugging', + ), + ), + 'uninstall' => array( + 'title' => __( 'Uninstall', 'directorist' ), + 'fields' => array( 'enable_uninstall' ), + ), + ) + ), + ), + ) + ), + ), + + ) + ); + + $this->config = array( + 'fields_theme' => 'butterfly', + 'submission' => array( + 'url' => admin_url( 'admin-ajax.php' ), + 'with' => array( + 'action' => 'save_settings_data', + 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ), + ), + ), + ); + } + + + // add_menu_pages + public function add_menu_pages() { + add_submenu_page( + 'edit.php?post_type=at_biz_dir', + 'Settings', + 'Settings', + 'manage_options', + 'atbdp-settings', + array( $this, 'menu_page_callback__settings_manager' ), + 12 + ); + } + + // menu_page_callback__settings_manager + public function menu_page_callback__settings_manager() { + // Prepare Settings + $this->prepare_settings(); + + // Get Saved Data + $atbdp_options = get_option( 'atbdp_option' ); + + foreach ( $this->fields as $field_key => $field_opt ) { + if ( ! isset( $atbdp_options[ $field_key ] ) ) { + $this->fields[ $field_key ]['forceUpdate'] = true; + continue; + } + + $this->fields[ $field_key ]['value'] = $atbdp_options[ $field_key ]; + } + + $settings_builder_data = array( + 'fields' => $this->fields, + 'layouts' => $this->layouts, + 'config' => $this->config, + ); + + /* + $status = $this->update_settings_options([ + 'new_listing_status' => 'publish', + 'edit_listing_status' => 'publish', + ]); + + $check_new = get_directorist_option( 'new_listing_status' ); + $check_edit = get_directorist_option( 'edit_listing_status' ); + + var_dump( [ '$check_new' => $check_new, '$check_edit' => $check_edit] ); */ $settings_builder_data['fields'] = $this->sanitize_fields_data( $settings_builder_data['fields'] ); - $data = [ - 'settings_builder_data' => base64_encode( json_encode( $settings_builder_data ) ) - ]; + $data = array( + 'settings_builder_data' => base64_encode( json_encode( $settings_builder_data ) ), + ); - atbdp_load_admin_template( 'settings-manager/settings', $data ); - } + atbdp_load_admin_template( 'settings-manager/settings', $data ); + } /** * Sanitize Fields Data @@ -4404,9 +5172,9 @@ public function menu_page_callback__settings_manager() */ public function sanitize_fields_data( $fields ) { - foreach( $fields as $key => $field_args ) { + foreach ( $fields as $key => $field_args ) { - foreach( $field_args as $field_args_key => $field_args_value ) { + foreach ( $field_args as $field_args_key => $field_args_value ) { $type = isset( $field_args['type'] ) ? $field_args['type'] : 'text'; @@ -4422,212 +5190,234 @@ public function sanitize_fields_data( $fields ) { $fields[ $key ][ $field_args_key ] = directorist_clean_post( $field_args_value ); } - } return $fields; } - /** - * Get all the pages in an array where each page is an array of key:value:id and key:label:name - * - * Example : array( - * array('value'=> 1, 'label'=> 'page_name'), - * array('value'=> 50, 'label'=> 'page_name'), - * ) - * @return array page names with key value pairs in a multi-dimensional array - * @since 3.0.0 - */ - function get_pages_vl_arrays() - { - $pages = get_pages(); - $pages_options = array(); - if ($pages) { - foreach ($pages as $page) { - $pages_options[] = array('value' => $page->ID, 'label' => $page->post_title); - } - } - - return $pages_options; - } - - function get_user_roles() - { - $get_editable_roles = get_editable_roles(); - $role = array(); - $role[] = array( 'value' => 'all', 'label' => __( 'All', 'directorist' ) ); - if( $get_editable_roles ) { - foreach( $get_editable_roles as $key => $value ) { - $role[] = array( - 'value' => $key, - 'label' => $value['name'] - ); - } - } - - return $role; - } - - /** - * Get all the pages with previous page in an array where each page is an array of key:value:id and key:label:name - * - * Example : array( - * array('value'=> 1, 'label'=> 'page_name'), - * array('value'=> 50, 'label'=> 'page_name'), - * ) - * @return array page names with key value pairs in a multi-dimensional array - * @since 3.0.0 - */ - function get_pages_with_prev_page() - { - $pages = get_pages(); - $pages_options = array(); - $pages_options[] = array( 'value' => 'previous_page', 'label' => 'Previous Page' ); - if ($pages) { - foreach ($pages as $page) { - $pages_options[] = array('value' => $page->ID, 'label' => $page->post_title); - } - } - - return $pages_options; - } - - /** - * Get an array of events to notify both the admin and the users - * @return array it returns an array of events - * @since 3.1.0 - */ - private function default_notifiable_events() - { - return apply_filters('atbdp_default_notifiable_events', array( - array( - 'value' => 'order_created', - 'label' => __('Order Created', 'directorist'), - ), - array( - 'value' => 'order_completed', - 'label' => __('Order Completed', 'directorist'), - ), - array( - 'value' => 'listing_submitted', - 'label' => __('New Listing Submitted', 'directorist'), - ), - array( - 'value' => 'listing_published', - 'label' => __('Listing Approved/Published', 'directorist'), - ), - array( - 'value' => 'listing_edited', - 'label' => __('Listing Edited', 'directorist'), - ), - array( - 'value' => 'payment_received', - 'label' => __('Payment Received', 'directorist'), - ), - array( - 'value' => 'listing_deleted', - 'label' => __('Listing Deleted', 'directorist'), - ), - array( - 'value' => 'listing_contact_form', - 'label' => __('Listing Contact Form', 'directorist'), - ), - array( - 'value' => 'listing_review', - 'label' => __('Listing Review', 'directorist'), - ), - array( - 'value' => 'listing_renewed', - 'label' => __('Listing Renewed', 'directorist'), - ), - )); - } - - /** - * Get the list of an array of notification events array to notify admin - * @return array It returns an array of events when an admin should be notified - * @since 3.1.0 - */ - public function events_to_notify_admin() - { - $events = $this->default_notifiable_events(); - return apply_filters('atbdp_events_to_notify_admin', $events); - } - - /** - * Get the list of an array of notification events array to notify user - * @return array It returns an array of events when an user should be notified - * @since 3.1.0 - */ - public function events_to_notify_user() - { - $events = array_merge($this->default_notifiable_events(), $this->only_user_notifiable_events()); - return apply_filters('atbdp_events_to_notify_user', $events); - } - - /** - * Get the default events to notify the user. - * @return array It returns an array of default events when an user should be notified. - * @since 3.1.0 - */ - public function default_events_to_notify_user() - { - return apply_filters('atbdp_default_events_to_notify_user', array( - 'order_created', - 'listing_submitted', - 'payment_received', - 'listing_published', - 'listing_to_expire', - 'listing_expired', - 'remind_to_renew', - 'listing_renewed', - 'order_completed', - 'listing_edited', - 'listing_deleted', - 'listing_contact_form', - )); - } - - /** - * Get an array of events to notify only users - * @return array it returns an array of events - * @since 3.1.0 - */ - private function only_user_notifiable_events() - { - return apply_filters('atbdp_only_user_notifiable_events', array( - array( - 'value' => 'listing_to_expire', - 'label' => __('Listing nearly Expired', 'directorist'), - ), - array( - 'value' => 'listing_expired', - 'label' => __('Listing Expired', 'directorist'), - ), - array( - 'value' => 'remind_to_renew', - 'label' => __('Remind to renew', 'directorist'), - ), - )); - } - - /** - * Get the default events to notify the admin. - * @return array It returns an array of default events when an admin should be notified. - * @since 3.1.0 - */ - public function default_events_to_notify_admin() - { - return apply_filters('atbdp_default_events_to_notify_admin', array( - 'order_created', - 'order_completed', - 'listing_submitted', - 'payment_received', - 'listing_published', - 'listing_deleted', - 'listing_contact_form', - 'listing_review' - )); - } - } -} \ No newline at end of file + /** + * Get all the pages in an array where each page is an array of key:value:id and key:label:name + * + * Example : array( + * array('value'=> 1, 'label'=> 'page_name'), + * array('value'=> 50, 'label'=> 'page_name'), + * ) + * + * @return array page names with key value pairs in a multi-dimensional array + * @since 3.0.0 + */ + function get_pages_vl_arrays() { + $pages = get_pages(); + $pages_options = array(); + if ( $pages ) { + foreach ( $pages as $page ) { + $pages_options[] = array( + 'value' => $page->ID, + 'label' => $page->post_title, + ); + } + } + + return $pages_options; + } + + function get_user_roles() { + $get_editable_roles = get_editable_roles(); + $role = array(); + $role[] = array( + 'value' => 'all', + 'label' => __( 'All', 'directorist' ), + ); + if ( $get_editable_roles ) { + foreach ( $get_editable_roles as $key => $value ) { + $role[] = array( + 'value' => $key, + 'label' => $value['name'], + ); + } + } + + return $role; + } + + /** + * Get all the pages with previous page in an array where each page is an array of key:value:id and key:label:name + * + * Example : array( + * array('value'=> 1, 'label'=> 'page_name'), + * array('value'=> 50, 'label'=> 'page_name'), + * ) + * + * @return array page names with key value pairs in a multi-dimensional array + * @since 3.0.0 + */ + function get_pages_with_prev_page() { + $pages = get_pages(); + $pages_options = array(); + $pages_options[] = array( + 'value' => 'previous_page', + 'label' => 'Previous Page', + ); + if ( $pages ) { + foreach ( $pages as $page ) { + $pages_options[] = array( + 'value' => $page->ID, + 'label' => $page->post_title, + ); + } + } + + return $pages_options; + } + + /** + * Get an array of events to notify both the admin and the users + * + * @return array it returns an array of events + * @since 3.1.0 + */ + private function default_notifiable_events() { + return apply_filters( + 'atbdp_default_notifiable_events', + array( + array( + 'value' => 'order_created', + 'label' => __( 'Order Created', 'directorist' ), + ), + array( + 'value' => 'order_completed', + 'label' => __( 'Order Completed', 'directorist' ), + ), + array( + 'value' => 'listing_submitted', + 'label' => __( 'New Listing Submitted', 'directorist' ), + ), + array( + 'value' => 'listing_published', + 'label' => __( 'Listing Approved/Published', 'directorist' ), + ), + array( + 'value' => 'listing_edited', + 'label' => __( 'Listing Edited', 'directorist' ), + ), + array( + 'value' => 'payment_received', + 'label' => __( 'Payment Received', 'directorist' ), + ), + array( + 'value' => 'listing_deleted', + 'label' => __( 'Listing Deleted', 'directorist' ), + ), + array( + 'value' => 'listing_contact_form', + 'label' => __( 'Listing Contact Form', 'directorist' ), + ), + array( + 'value' => 'listing_review', + 'label' => __( 'Listing Review', 'directorist' ), + ), + array( + 'value' => 'listing_renewed', + 'label' => __( 'Listing Renewed', 'directorist' ), + ), + ) + ); + } + + /** + * Get the list of an array of notification events array to notify admin + * + * @return array It returns an array of events when an admin should be notified + * @since 3.1.0 + */ + public function events_to_notify_admin() { + $events = $this->default_notifiable_events(); + return apply_filters( 'atbdp_events_to_notify_admin', $events ); + } + + /** + * Get the list of an array of notification events array to notify user + * + * @return array It returns an array of events when an user should be notified + * @since 3.1.0 + */ + public function events_to_notify_user() { + $events = array_merge( $this->default_notifiable_events(), $this->only_user_notifiable_events() ); + return apply_filters( 'atbdp_events_to_notify_user', $events ); + } + + /** + * Get the default events to notify the user. + * + * @return array It returns an array of default events when an user should be notified. + * @since 3.1.0 + */ + public function default_events_to_notify_user() { + return apply_filters( + 'atbdp_default_events_to_notify_user', + array( + 'order_created', + 'listing_submitted', + 'payment_received', + 'listing_published', + 'listing_to_expire', + 'listing_expired', + 'remind_to_renew', + 'listing_renewed', + 'order_completed', + 'listing_edited', + 'listing_deleted', + 'listing_contact_form', + ) + ); + } + + /** + * Get an array of events to notify only users + * + * @return array it returns an array of events + * @since 3.1.0 + */ + private function only_user_notifiable_events() { + return apply_filters( + 'atbdp_only_user_notifiable_events', + array( + array( + 'value' => 'listing_to_expire', + 'label' => __( 'Listing nearly Expired', 'directorist' ), + ), + array( + 'value' => 'listing_expired', + 'label' => __( 'Listing Expired', 'directorist' ), + ), + array( + 'value' => 'remind_to_renew', + 'label' => __( 'Remind to renew', 'directorist' ), + ), + ) + ); + } + + /** + * Get the default events to notify the admin. + * + * @return array It returns an array of default events when an admin should be notified. + * @since 3.1.0 + */ + public function default_events_to_notify_admin() { + return apply_filters( + 'atbdp_default_events_to_notify_admin', + array( + 'order_created', + 'order_completed', + 'listing_submitted', + 'payment_received', + 'listing_published', + 'listing_deleted', + 'listing_contact_form', + 'listing_review', + ) + ); + } + } +} diff --git a/includes/classes/class-setup-wizard.php b/includes/classes/class-setup-wizard.php index 5247d82456..a85c64cc18 100644 --- a/includes/classes/class-setup-wizard.php +++ b/includes/classes/class-setup-wizard.php @@ -9,382 +9,394 @@ * * Walkthrough to the basic setup upon installation */ -class SetupWizard -{ - /** @var string Currenct Step */ - public $step = ''; - - /** @var array Steps for the setup wizard */ - public $steps = array(); - - /** - * Actions to be executed after the HTTP response has completed - * - * @var array - */ - private $deferred_actions = array(); - - /** - * Hook in tabs. - */ - public function __construct() { - add_action( 'admin_menu', array( $this, 'admin_menus' ) ); - add_action( 'admin_init', array( $this, 'setup_wizard' ), 99 ); - add_action( 'admin_notices', array( $this, 'render_run_admin_setup_wizard_notice' ) ); - add_action( 'wp_ajax_directorist_setup_wizard', array( $this, 'directorist_setup_wizard' ) ); - add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); - } - - public function directorist_setup_wizard() { - if ( ! current_user_can( 'import' ) ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid request!', 'directorist' ), - ) ); - } - - if ( ! directorist_verify_nonce() ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), - ) ); - } - - $counter = $_POST['counter']; - - $request_directory_types = wp_remote_get( 'https://app.directorist.com/wp-json/directorist/v1/get-directory-types?nocache' ); - - if( is_wp_error( $request_directory_types ) ) { - return false; - } - - $multi_directory_manager = new Directorist\Multi_Directory\Multi_Directory_Manager(); - - $get_types = get_transient( 'directory_type' ); - - $post_type = ! empty( $get_types[$counter ] ) ? $get_types[$counter ] : ''; - - $response_body = wp_remote_retrieve_body( $request_directory_types ); - $pre_made_types = json_decode( $response_body, true ); - - $is_completed = ( count( $get_types ) <= $counter ) ? true : false; - $task_counter = $counter + 1; - $percentage = absint( min( round( ( ( $task_counter ) / count( $get_types ) ) * 100 ), 100 ) ); - - if( $is_completed ) { - - $has_general = get_term_by( 'slug', 'general', ATBDP_TYPE ); - - if( ! is_wp_error( $has_general ) ) { - wp_delete_term( $has_general->term_id, ATBDP_TYPE ); - } - - wp_send_json( [ - 'completed' => $is_completed, - 'percentage' => 100, - 'log' => 'Completed, redirecting...', - 'url' => admin_url('index.php?page=directorist-setup&step=step-four') - ] ); - } - - if( ! isset( $pre_made_types[$post_type] ) ) { - $log = 'Remote data not found for ' . $post_type; - wp_send_json( [ - 'completed' => false, - 'log' => $log, - 'url' => admin_url('index.php?page=directorist-setup&step=step-four') - ] ); - } - - $type = $pre_made_types[$post_type]; - - $data['log'] = 'Importing ' . $type['name'] . ' type...'; - $data['percentage'] = $percentage; - - $dummy_data = $type['listing_data']; - $builder_file_url = $type['url']; - - $builder_content = directorist_get_json_from_url( $builder_file_url ); - - if( $builder_content ) { - $multi_directory_manager->prepare_settings(); - $term = $multi_directory_manager->add_directory([ - 'directory_name' => $type['name'], - 'fields_value' => $builder_content, - 'is_json' => false - ]); - - if( ! $term['status']['success'] ) { - $term_id = $term['status']['term_id']; - }else{ - $term_id = $term['term_id']; - } - - if( $counter == 0 ) { - update_term_meta( $term_id, '_default', true ); - } - - if( ! empty( $dummy_data ) && isset( $_POST['import_listings'] ) ) { - $data['import_log'] = self::atbdp_dummy_data_import( $dummy_data, $term_id ); - } - - } - - if( isset( $_POST['share_non_sensitive_data'] ) ) { - ATBDP()->insights->optin(); - } else { - ATBDP()->insights->optout(); - } - - $data['url'] = admin_url('index.php?page=directorist-setup&step=step-four'); - $data['completed'] = $is_completed; - - wp_send_json( $data ); - } - - public function render_run_admin_setup_wizard_notice() { - - $setup_wizard = get_option( 'directorist_setup_wizard_completed' ); - $atpdp_setup_wizard = apply_filters( 'atbdp_setup_wizard', true ); - if( $setup_wizard || ! $atpdp_setup_wizard ) { - return; - } - - ?> - <div id="message" class="updated atbdp-message"> - <p><?php echo wp_kses_post( __( '<strong>Welcome to Directorist</strong> – You‘re almost ready to start your directory!', 'directorist' ) ); ?></p> - <p class="submit"> - <a href="<?php echo esc_url( admin_url( 'admin.php?page=directorist-setup' ) ); ?>" class="button-primary"><?php esc_html_e( 'Run the Setup Wizard', 'directorist' ); ?></a> - <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'directorist-hide-notice', 'install' ), 'directorist_hide_notices_nonce', '_atbdp_notice_nonce' ) ); ?>"><?php esc_html_e( 'Skip setup', 'directorist' ); ?></a> - </p> - </div> - <?php - } - - public function hide_notices() { - if ( isset( $_GET['directorist-hide-notice'] ) && isset( $_GET['_atbdp_notice_nonce'] ) ) { // WPCS: input var ok, CSRF ok. +class SetupWizard { + + /** @var string Currenct Step */ + public $step = ''; + + /** @var array Steps for the setup wizard */ + public $steps = array(); + + /** + * Actions to be executed after the HTTP response has completed + * + * @var array + */ + private $deferred_actions = array(); + + /** + * Hook in tabs. + */ + public function __construct() { + add_action( 'admin_menu', array( $this, 'admin_menus' ) ); + add_action( 'admin_init', array( $this, 'setup_wizard' ), 99 ); + add_action( 'admin_notices', array( $this, 'render_run_admin_setup_wizard_notice' ) ); + add_action( 'wp_ajax_directorist_setup_wizard', array( $this, 'directorist_setup_wizard' ) ); + add_action( 'wp_loaded', array( $this, 'hide_notices' ) ); + } + + public function directorist_setup_wizard() { + if ( ! current_user_can( 'import' ) ) { + wp_send_json( + array( + 'error' => esc_html__( 'Invalid request!', 'directorist' ), + ) + ); + } + + if ( ! directorist_verify_nonce() ) { + wp_send_json( + array( + 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), + ) + ); + } + + $counter = $_POST['counter']; + + $request_directory_types = wp_remote_get( 'https://app.directorist.com/wp-json/directorist/v1/get-directory-types?nocache' ); + + if ( is_wp_error( $request_directory_types ) ) { + return false; + } + + $multi_directory_manager = new Directorist\Multi_Directory\Multi_Directory_Manager(); + + $get_types = get_transient( 'directory_type' ); + + $post_type = ! empty( $get_types[ $counter ] ) ? $get_types[ $counter ] : ''; + + $response_body = wp_remote_retrieve_body( $request_directory_types ); + $pre_made_types = json_decode( $response_body, true ); + + $is_completed = ( count( $get_types ) <= $counter ) ? true : false; + $task_counter = $counter + 1; + $percentage = absint( min( round( ( ( $task_counter ) / count( $get_types ) ) * 100 ), 100 ) ); + + if ( $is_completed ) { + + $has_general = get_term_by( 'slug', 'general', ATBDP_TYPE ); + + if ( ! is_wp_error( $has_general ) ) { + wp_delete_term( $has_general->term_id, ATBDP_TYPE ); + } + + wp_send_json( + array( + 'completed' => $is_completed, + 'percentage' => 100, + 'log' => 'Completed, redirecting...', + 'url' => admin_url( 'index.php?page=directorist-setup&step=step-four' ), + ) + ); + } + + if ( ! isset( $pre_made_types[ $post_type ] ) ) { + $log = 'Remote data not found for ' . $post_type; + wp_send_json( + array( + 'completed' => false, + 'log' => $log, + 'url' => admin_url( 'index.php?page=directorist-setup&step=step-four' ), + ) + ); + } + + $type = $pre_made_types[ $post_type ]; + + $data['log'] = 'Importing ' . $type['name'] . ' type...'; + $data['percentage'] = $percentage; + + $dummy_data = $type['listing_data']; + $builder_file_url = $type['url']; + + $builder_content = directorist_get_json_from_url( $builder_file_url ); + + if ( $builder_content ) { + $multi_directory_manager->prepare_settings(); + $term = $multi_directory_manager->add_directory( + array( + 'directory_name' => $type['name'], + 'fields_value' => $builder_content, + 'is_json' => false, + ) + ); + + if ( ! $term['status']['success'] ) { + $term_id = $term['status']['term_id']; + } else { + $term_id = $term['term_id']; + } + + if ( $counter == 0 ) { + update_term_meta( $term_id, '_default', true ); + } + + if ( ! empty( $dummy_data ) && isset( $_POST['import_listings'] ) ) { + $data['import_log'] = self::atbdp_dummy_data_import( $dummy_data, $term_id ); + } + } + + if ( isset( $_POST['share_non_sensitive_data'] ) ) { + ATBDP()->insights->optin(); + } else { + ATBDP()->insights->optout(); + } + + $data['url'] = admin_url( 'index.php?page=directorist-setup&step=step-four' ); + $data['completed'] = $is_completed; + + wp_send_json( $data ); + } + + public function render_run_admin_setup_wizard_notice() { + + $setup_wizard = get_option( 'directorist_setup_wizard_completed' ); + $atpdp_setup_wizard = apply_filters( 'atbdp_setup_wizard', true ); + if ( $setup_wizard || ! $atpdp_setup_wizard ) { + return; + } + + ?> + <div id="message" class="updated atbdp-message"> + <p><?php echo wp_kses_post( __( '<strong>Welcome to Directorist</strong> – You‘re almost ready to start your directory!', 'directorist' ) ); ?></p> + <p class="submit"> + <a href="<?php echo esc_url( admin_url( 'admin.php?page=directorist-setup' ) ); ?>" class="button-primary"><?php esc_html_e( 'Run the Setup Wizard', 'directorist' ); ?></a> + <a class="button-secondary skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'directorist-hide-notice', 'install' ), 'directorist_hide_notices_nonce', '_atbdp_notice_nonce' ) ); ?>"><?php esc_html_e( 'Skip setup', 'directorist' ); ?></a> + </p> + </div> + <?php + } + + public function hide_notices() { + if ( isset( $_GET['directorist-hide-notice'] ) && isset( $_GET['_atbdp_notice_nonce'] ) ) { // WPCS: input var ok, CSRF ok. if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_atbdp_notice_nonce'] ) ), 'directorist_hide_notices_nonce' ) ) { // WPCS: input var ok, CSRF ok. wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'directorist' ) ); } update_option( 'directorist_setup_wizard_completed', true ); - } - - $create_pages = [ - 'checkout_page' => [ - 'post_title' => 'Checkout', - 'post_content' => '[directorist_checkout]', - ], - 'payment_receipt_page' => [ - 'post_title' => 'Payment Receipt', - 'post_content' => '[directorist_payment_receipt]', - ], - 'transaction_failure_page' => [ - 'post_title' => 'Transaction Failure', - 'post_content' => '[directorist_transaction_failure]', - ], - ]; - $atbdp_option = get_option( 'atbdp_option' ); - - if (!empty($atbdp_option['enable_monetization'])) { - foreach ($create_pages as $key => $name) { - - $args = [ - 'post_title' => $name['post_title'], - 'post_content' => $name['post_content'], - 'post_status' => 'publish', - 'post_type' => 'page', - 'comment_status' => 'closed' - ]; - if (empty($atbdp_option[$key])) { - $id = wp_insert_post($args); - - if ($id) { - $atbdp_option[$key] = $id; - } - } - } - } - - /** - * @since 7.3.0 - */ - - do_action( 'directorist_setup_wizard_completed' ); - - update_option('atbdp_option', $atbdp_option); - } - - public static function atbdp_dummy_data_import( $file = '', $type = '' ) - { - - if ( ! current_user_can( 'import' ) ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid request!', 'directorist' ), - ) ); - } - - if ( ! directorist_verify_nonce() ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), - ) ); - } - - $data = array(); - $listings_url = array(); - $imported = 0; - $failed = 0; - $count = 0; - $file = isset($_POST['file']) ? sanitize_text_field( wp_unslash( $_POST['file'] ) ) : $file; - $total_length = isset($_POST['limit']) ? sanitize_text_field( wp_unslash( $_POST['limit'])) : 5; - $position = isset($_POST['position']) ? sanitize_text_field( wp_unslash( $_POST['position'] ) ) : 0; - - $all_posts = self::read_csv($file); - - $posts = array_slice($all_posts, $position); - - $limit = 10; - - $directory_id = ! empty( $type ) ? $type : default_directory_type(); - - foreach ( $posts as $index => $post ) { - if ( $count === $limit ) { - break; + } + + $create_pages = array( + 'checkout_page' => array( + 'post_title' => 'Checkout', + 'post_content' => '[directorist_checkout]', + ), + 'payment_receipt_page' => array( + 'post_title' => 'Payment Receipt', + 'post_content' => '[directorist_payment_receipt]', + ), + 'transaction_failure_page' => array( + 'post_title' => 'Transaction Failure', + 'post_content' => '[directorist_transaction_failure]', + ), + ); + $atbdp_option = get_option( 'atbdp_option' ); + + if ( ! empty( $atbdp_option['enable_monetization'] ) ) { + foreach ( $create_pages as $key => $name ) { + + $args = array( + 'post_title' => $name['post_title'], + 'post_content' => $name['post_content'], + 'post_status' => 'publish', + 'post_type' => 'page', + 'comment_status' => 'closed', + ); + if ( empty( $atbdp_option[ $key ] ) ) { + $id = wp_insert_post( $args ); + + if ( $id ) { + $atbdp_option[ $key ] = $id; + } } + } + } + + /** + * @since 7.3.0 + */ + + do_action( 'directorist_setup_wizard_completed' ); + + update_option( 'atbdp_option', $atbdp_option ); + } + + public static function atbdp_dummy_data_import( $file = '', $type = '' ) { + + if ( ! current_user_can( 'import' ) ) { + wp_send_json( + array( + 'error' => esc_html__( 'Invalid request!', 'directorist' ), + ) + ); + } + + if ( ! directorist_verify_nonce() ) { + wp_send_json( + array( + 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), + ) + ); + } + + $data = array(); + $listings_url = array(); + $imported = 0; + $failed = 0; + $count = 0; + $file = isset( $_POST['file'] ) ? sanitize_text_field( wp_unslash( $_POST['file'] ) ) : $file; + $total_length = isset( $_POST['limit'] ) ? sanitize_text_field( wp_unslash( $_POST['limit'] ) ) : 5; + $position = isset( $_POST['position'] ) ? sanitize_text_field( wp_unslash( $_POST['position'] ) ) : 0; + + $all_posts = self::read_csv( $file ); + + $posts = array_slice( $all_posts, $position ); - // start importing listings - $image = ! empty( $post['listing_img'] ) ? $post['listing_img'] : ''; + $limit = 10; - $args = array( - 'post_title' => isset( $post['listing_title'] ) ? $post['listing_title'] : '', - 'post_content' => isset( $post['listing_content'] ) ? $post['listing_content'] : '', - 'post_type' => 'at_biz_dir', - 'post_status' => 'publish', - ); + $directory_id = ! empty( $type ) ? $type : default_directory_type(); - $post_id = wp_insert_post( $args ); + foreach ( $posts as $index => $post ) { + if ( $count === $limit ) { + break; + } + + // start importing listings + $image = ! empty( $post['listing_img'] ) ? $post['listing_img'] : ''; + + $args = array( + 'post_title' => isset( $post['listing_title'] ) ? $post['listing_title'] : '', + 'post_content' => isset( $post['listing_content'] ) ? $post['listing_content'] : '', + 'post_type' => 'at_biz_dir', + 'post_status' => 'publish', + ); - array_push( $listings_url, get_the_permalink( $post_id ) ); + $post_id = wp_insert_post( $args ); + + array_push( $listings_url, get_the_permalink( $post_id ) ); // No need to process further since it's a failed insertion. - if ( is_wp_error( $post_id ) ) { - $failed++; + if ( is_wp_error( $post_id ) ) { + ++$failed; continue; - } + } - $imported++; + ++$imported; - foreach($post as $key => $value){ - if ('category' == $key) { - $taxonomy = ATBDP_CATEGORY; - $term_exists = get_term_by( 'name', $value, $taxonomy ); + foreach ( $post as $key => $value ) { + if ( 'category' == $key ) { + $taxonomy = ATBDP_CATEGORY; + $term_exists = get_term_by( 'name', $value, $taxonomy ); if ( ! $term_exists ) { // @codingStandardsIgnoreLine. - $result = wp_insert_term( $value, $taxonomy ); - if( !is_wp_error( $result ) ){ - $term_id = $result['term_id']; - update_term_meta($term_id, '_directory_type', [ $directory_id ] ); - wp_set_object_terms($post_id, $term_id, $taxonomy); - } - }else{ - wp_set_object_terms($post_id, $term_exists->term_id, $taxonomy); - } - } elseif ('location' == $key) { - $taxonomy = ATBDP_LOCATION; - $term_exists = get_term_by( 'name', $value, $taxonomy ); + $result = wp_insert_term( $value, $taxonomy ); + if ( ! is_wp_error( $result ) ) { + $term_id = $result['term_id']; + update_term_meta( $term_id, '_directory_type', array( $directory_id ) ); + wp_set_object_terms( $post_id, $term_id, $taxonomy ); + } + } else { + wp_set_object_terms( $post_id, $term_exists->term_id, $taxonomy ); + } + } elseif ( 'location' == $key ) { + $taxonomy = ATBDP_LOCATION; + $term_exists = get_term_by( 'name', $value, $taxonomy ); if ( ! $term_exists ) { // @codingStandardsIgnoreLine. - $result = wp_insert_term( $value, $taxonomy ); - if( !is_wp_error( $result ) ){ - $term_id = $result['term_id']; - update_term_meta($term_id, '_directory_type', [ $directory_id ] ); - wp_set_object_terms($post_id, $term_id, $taxonomy); - } - }else{ - wp_set_object_terms($post_id, $term_exists->term_id, $taxonomy); - } - } elseif ('tag' == $key){ - $taxonomy = ATBDP_TAGS; - $term_exists = get_term_by( 'name', $value, $taxonomy ); + $result = wp_insert_term( $value, $taxonomy ); + if ( ! is_wp_error( $result ) ) { + $term_id = $result['term_id']; + update_term_meta( $term_id, '_directory_type', array( $directory_id ) ); + wp_set_object_terms( $post_id, $term_id, $taxonomy ); + } + } else { + wp_set_object_terms( $post_id, $term_exists->term_id, $taxonomy ); + } + } elseif ( 'tag' == $key ) { + $taxonomy = ATBDP_TAGS; + $term_exists = get_term_by( 'name', $value, $taxonomy ); if ( ! $term_exists ) { // @codingStandardsIgnoreLine. - $result = wp_insert_term( $value, $taxonomy ); - if( !is_wp_error( $result ) ){ - $term_id = $result['term_id']; - wp_set_object_terms($post_id, $term_id, $taxonomy); - } - }else{ - wp_set_object_terms($post_id, $term_exists->term_id, $taxonomy); - } - } - - if ( $value !== '' ) { - update_post_meta( $post_id, '_' . $key, $value ); - } - } - - $exp_dt = calc_listing_expiry_date(); - update_post_meta($post_id, '_expiry_date', $exp_dt); - update_post_meta($post_id, '_featured', 0); + $result = wp_insert_term( $value, $taxonomy ); + if ( ! is_wp_error( $result ) ) { + $term_id = $result['term_id']; + wp_set_object_terms( $post_id, $term_id, $taxonomy ); + } + } else { + wp_set_object_terms( $post_id, $term_exists->term_id, $taxonomy ); + } + } + + if ( $value !== '' ) { + update_post_meta( $post_id, '_' . $key, $value ); + } + } + + $exp_dt = calc_listing_expiry_date(); + update_post_meta( $post_id, '_expiry_date', $exp_dt ); + update_post_meta( $post_id, '_featured', 0 ); // TODO: Status has been migrated, remove related code. - update_post_meta($post_id, '_listing_status', 'post_status'); - - if ( ! empty( $image ) ) { - $attachment_id = ATBDP_Tools::atbdp_insert_attachment_from_url( $image, $post_id ); - if( $attachment_id ) { - update_post_meta( $post_id, '_listing_prv_img', $attachment_id ); - } - } - - - // $data['images'] = $images; - // if ( ! empty( $images ) ) { - // $images = explode( ',', $images ); - // $attachment_ids = []; - // foreach ( $images as $_url_index => $_url ) { - // $_url = trim( $_url ); - // $attachment_id = ATBDP_Tools::atbdp_insert_attachment_from_url($_url, $post_id); - // if ( $_url_index == 0 ) { - // update_post_meta($post_id, '_listing_prv_img', $attachment_id); - // } else { - // $attachment_ids[] = $attachment_id; - // } - // } - // $data['attachment_ids'] = $attachment_ids; - // update_post_meta($post_id, '_listing_img', $attachment_ids ); - // } - - //directory type - if( !empty( $directory_id ) ){ - update_post_meta($post_id, '_directory_type', $directory_id); - wp_set_object_terms($post_id, (int)$directory_id, 'atbdp_listing_types'); - } - - $count++; - } - - $data['listings'] = $listings_url; - $data['failed'] = $failed; - $data['failed'] = $failed; - - return $data; - } - - public static function read_csv($file){ - $fp = fopen($file, 'r'); - $header = fgetcsv($fp); - - // get the rest of the rows - $data = array(); - while ($row = fgetcsv($fp)) { - $arr = array(); - foreach ($header as $i => $col) - $arr[$col] = $row[$i]; - $data[] = $arr; - } - return $data; - } - - /** - * Add admin menus/screens. - */ - public function admin_menus() { + update_post_meta( $post_id, '_listing_status', 'post_status' ); + + if ( ! empty( $image ) ) { + $attachment_id = ATBDP_Tools::atbdp_insert_attachment_from_url( $image, $post_id ); + if ( $attachment_id ) { + update_post_meta( $post_id, '_listing_prv_img', $attachment_id ); + } + } + + // $data['images'] = $images; + // if ( ! empty( $images ) ) { + // $images = explode( ',', $images ); + // $attachment_ids = []; + // foreach ( $images as $_url_index => $_url ) { + // $_url = trim( $_url ); + // $attachment_id = ATBDP_Tools::atbdp_insert_attachment_from_url($_url, $post_id); + // if ( $_url_index == 0 ) { + // update_post_meta($post_id, '_listing_prv_img', $attachment_id); + // } else { + // $attachment_ids[] = $attachment_id; + // } + // } + // $data['attachment_ids'] = $attachment_ids; + // update_post_meta($post_id, '_listing_img', $attachment_ids ); + // } + + // directory type + if ( ! empty( $directory_id ) ) { + update_post_meta( $post_id, '_directory_type', $directory_id ); + wp_set_object_terms( $post_id, (int) $directory_id, 'atbdp_listing_types' ); + } + + ++$count; + } + + $data['listings'] = $listings_url; + $data['failed'] = $failed; + $data['failed'] = $failed; + + return $data; + } + + public static function read_csv( $file ) { + $fp = fopen( $file, 'r' ); + $header = fgetcsv( $fp ); + + // get the rest of the rows + $data = array(); + while ( $row = fgetcsv( $fp ) ) { + $arr = array(); + foreach ( $header as $i => $col ) { + $arr[ $col ] = $row[ $i ]; + } + $data[] = $arr; + } + return $data; + } + + /** + * Add admin menus/screens. + */ + public function admin_menus() { add_menu_page( __( 'Directorist Setup Wizard', 'directorist' ), __( 'Setup', 'directorist' ), @@ -394,115 +406,128 @@ public function admin_menus() { // Remove to remove the menu item only, page will just work fine. remove_menu_page( 'directorist-setup' ); - } + } - /** - * Show the setup wizard. - */ - public function setup_wizard() { - if ( empty( $_GET['page'] ) || 'directorist-setup' !== $_GET['page'] ) { - return; - } + /** + * Show the setup wizard. + */ + public function setup_wizard() { + if ( empty( $_GET['page'] ) || 'directorist-setup' !== $_GET['page'] ) { + return; + } if ( ! current_user_can( 'manage_options' ) ) { return; } - $this->set_steps(); - - $this->step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps)); - - $this->enqueue_scripts(); - - if (!empty($_POST['save_step']) && isset($this->steps[$this->step]['handler'])) { // WPCS: CSRF ok. - call_user_func_array($this->steps[$this->step]['handler'], array($this)); - } - - ob_start(); - $this->set_setup_wizard_template(); - exit; - } - - public function enqueue_scripts() - { - wp_enqueue_style('atbdp_setup_select2', DIRECTORIST_VENDOR_CSS . 'select2.min.css', ATBDP_VERSION, true); - wp_register_script('directorist-select2', DIRECTORIST_VENDOR_JS . 'select2.min.js', array('jquery'), ATBDP_VERSION, true); - - wp_enqueue_script('directorist-setup'); - wp_enqueue_script('directorist-select2'); - wp_enqueue_script('directorist-geolocation', DIRECTORIST_JS . 'global-geolocation.js'); - - wp_register_style('directorist-admin-style', DIRECTORIST_CSS . 'admin-main.css', ATBDP_VERSION, true); - wp_register_script('directorist-admin-setup-wizard-script', DIRECTORIST_JS . 'admin-setup-wizard.js', array('jquery'), ATBDP_VERSION, true); - - wp_enqueue_script('directorist-openstreet-layers', DIRECTORIST_VENDOR_JS . 'openstreet-map/openstreetlayers.js'); - wp_enqueue_script('directorist-openstreet-unpkg-index', DIRECTORIST_VENDOR_JS . 'openstreet-map/unpkg-index.js'); - wp_enqueue_script('directorist-openstreet-unpkg-libs', DIRECTORIST_VENDOR_JS . 'openstreet-map/unpkg-libs.js'); - wp_enqueue_script('directorist-openstreet-leaflet-versions', DIRECTORIST_VENDOR_JS . 'openstreet-map/leaflet-versions.js'); - wp_enqueue_script('directorist-openstreet-libs-setup', DIRECTORIST_VENDOR_JS . 'openstreet-map/libs-setup.js'); - - wp_enqueue_script('directorist-openstreet-leaflet-markercluster-versions', DIRECTORIST_VENDOR_JS . 'openstreet-map/leaflet.markercluster-versions.js'); - - wp_enqueue_script('directorist-test', DIRECTORIST_JS . 'openstreet-map.js', [ - 'jquery', - 'directorist-openstreet-layers', - 'directorist-openstreet-unpkg-libs', - 'directorist-openstreet-leaflet-versions', - 'directorist-openstreet-libs-setup', - 'directorist-geolocation', - ], ATBDP_VERSION, true); - - wp_enqueue_style('directorist-admin-style'); - wp_enqueue_script('directorist-admin-setup-wizard-script'); - - wp_localize_script( 'jquery', 'directorist', Localized_Data::public_data() ); - - wp_localize_script('directorist-admin-setup-wizard-script', 'import_export_data', [ 'ajaxurl' => admin_url('admin-ajax.php'), 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ) ] ); - } - - /** - * Set wizard steps - * - * @since 2.9.27 - * - * @return void - */ - protected function set_steps() - { - $this->steps = apply_filters('directorist_admin_setup_wizard_steps', array( - 'introduction' => array( - 'name' => __('Introduction', 'directorist'), - 'view' => array( $this, 'directorist_setup_introduction' ), - 'handler' => array( $this, 'directorist_step_intro_save' ), - ), - 'step-one' => array( - 'name' => __('Step One', 'directorist'), - 'view' => array( $this, 'directorist_step_one' ), - 'handler' => array( $this, 'directorist_step_one_save' ), - ), - 'step-two' => array( - 'name' => __('Step Two', 'directorist'), - 'view' => array( $this, 'directorist_step_two' ), - 'handler' => array( $this, 'directorist_step_two_save' ), - ), - 'step-three' => array( - 'name' => __('Step Three', 'directorist'), - 'view' => array( $this, 'directorist_step_three' ), - 'handler' => array( $this, 'directorist_step_three_save' ), - ), - 'step-four' => array( - 'name' => __('Step Four', 'directorist'), - 'view' => array( $this, 'directorist_step_four' ), - ), - )); - } - - public function get_map_data() { - + $this->set_steps(); + + $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); + + $this->enqueue_scripts(); + + if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { // WPCS: CSRF ok. + call_user_func_array( $this->steps[ $this->step ]['handler'], array( $this ) ); + } + + ob_start(); + $this->set_setup_wizard_template(); + exit; + } + + public function enqueue_scripts() { + wp_enqueue_style( 'atbdp_setup_select2', DIRECTORIST_VENDOR_CSS . 'select2.min.css', ATBDP_VERSION, true ); + wp_register_script( 'directorist-select2', DIRECTORIST_VENDOR_JS . 'select2.min.js', array( 'jquery' ), ATBDP_VERSION, true ); + + wp_enqueue_script( 'directorist-setup' ); + wp_enqueue_script( 'directorist-select2' ); + wp_enqueue_script( 'directorist-geolocation', DIRECTORIST_JS . 'global-geolocation.js' ); + + wp_register_style( 'directorist-admin-style', DIRECTORIST_CSS . 'admin-main.css', ATBDP_VERSION, true ); + wp_register_script( 'directorist-admin-setup-wizard-script', DIRECTORIST_JS . 'admin-setup-wizard.js', array( 'jquery' ), ATBDP_VERSION, true ); + + wp_enqueue_script( 'directorist-openstreet-layers', DIRECTORIST_VENDOR_JS . 'openstreet-map/openstreetlayers.js' ); + wp_enqueue_script( 'directorist-openstreet-unpkg-index', DIRECTORIST_VENDOR_JS . 'openstreet-map/unpkg-index.js' ); + wp_enqueue_script( 'directorist-openstreet-unpkg-libs', DIRECTORIST_VENDOR_JS . 'openstreet-map/unpkg-libs.js' ); + wp_enqueue_script( 'directorist-openstreet-leaflet-versions', DIRECTORIST_VENDOR_JS . 'openstreet-map/leaflet-versions.js' ); + wp_enqueue_script( 'directorist-openstreet-libs-setup', DIRECTORIST_VENDOR_JS . 'openstreet-map/libs-setup.js' ); + + wp_enqueue_script( 'directorist-openstreet-leaflet-markercluster-versions', DIRECTORIST_VENDOR_JS . 'openstreet-map/leaflet.markercluster-versions.js' ); + + wp_enqueue_script( + 'directorist-test', + DIRECTORIST_JS . 'openstreet-map.js', + array( + 'jquery', + 'directorist-openstreet-layers', + 'directorist-openstreet-unpkg-libs', + 'directorist-openstreet-leaflet-versions', + 'directorist-openstreet-libs-setup', + 'directorist-geolocation', + ), + ATBDP_VERSION, + true + ); + + wp_enqueue_style( 'directorist-admin-style' ); + wp_enqueue_script( 'directorist-admin-setup-wizard-script' ); + + wp_localize_script( 'jquery', 'directorist', Localized_Data::public_data() ); + + wp_localize_script( + 'directorist-admin-setup-wizard-script', + 'import_export_data', + array( + 'ajaxurl' => admin_url( 'admin-ajax.php' ), + 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ), + ) + ); + } + + /** + * Set wizard steps + * + * @since 2.9.27 + * + * @return void + */ + protected function set_steps() { + $this->steps = apply_filters( + 'directorist_admin_setup_wizard_steps', + array( + 'introduction' => array( + 'name' => __( 'Introduction', 'directorist' ), + 'view' => array( $this, 'directorist_setup_introduction' ), + 'handler' => array( $this, 'directorist_step_intro_save' ), + ), + 'step-one' => array( + 'name' => __( 'Step One', 'directorist' ), + 'view' => array( $this, 'directorist_step_one' ), + 'handler' => array( $this, 'directorist_step_one_save' ), + ), + 'step-two' => array( + 'name' => __( 'Step Two', 'directorist' ), + 'view' => array( $this, 'directorist_step_two' ), + 'handler' => array( $this, 'directorist_step_two_save' ), + ), + 'step-three' => array( + 'name' => __( 'Step Three', 'directorist' ), + 'view' => array( $this, 'directorist_step_three' ), + 'handler' => array( $this, 'directorist_step_three_save' ), + ), + 'step-four' => array( + 'name' => __( 'Step Four', 'directorist' ), + 'view' => array( $this, 'directorist_step_four' ), + ), + ) + ); + } + + public function get_map_data() { $data = array( 'p_id' => '', - //'listing_form' => $this, + // 'listing_form' => $this, 'listing_info' => '', 'select_listing_map' => get_directorist_option( 'select_listing_map', 'google' ), 'display_map_for' => get_directorist_option( 'display_map_for', 0 ), @@ -521,600 +546,588 @@ public function get_map_data() { return $data; } - public function directorist_step_one() { - $map_data = $this->get_map_data(); - Directorist\Helper::add_hidden_data_to_dom( 'map_data', $map_data ); - ?> - <div class="directorist-setup-wizard__box"> - <div class="directorist-setup-wizard__box__content"> - <h1 class="directorist-setup-wizard__box__content__title">Default Location</h1> - <p class="directorist-setup-wizard__box__content__desc">Drag the map or marker to the middle of your city</p> - <h4 class="directorist-setup-wizard__box__content__title directorist-setup-wizard__box__content__title--section">Add your location</h4> - <div class="directorist-setup-wizard__box__content__form directorist-form-address-field directorist-search-field"> - <span class="directorist-setup-wizard__box__content__location-icon directorist-filter-location-icon"> - <?php directorist_icon( 'fas fa-crosshairs' ); ?> - </span> - <input type="text" autocomplete="off" name="" class="directorist-setup-wizard__box__content__input directorist-location-js" value="" placeholder="Search your location"> - <input type="hidden" name="default_latitude" id="manual_lat" value="" /> - <input type="hidden" name="default_longitude" id="manual_lng" value="" /> - <div class="directorist-setup-wizard__box__content__input--clear"> - <?php directorist_icon( 'fas fa-times-circle' ); ?> - </div> - <div class="address_result"><ul></ul></div> - - </div> - - <div class="directorist-setup-wizard__map directorist-form-map-field__maps"> - <div id="osm"> - <div id="gmap"> - <div id="gmap_full_screen_button"> - <span class="fullscreen-enable"><?php directorist_icon( 'fas fa-expand' ); ?></span> - <span class="fullscreen-disable"><?php directorist_icon( 'fas fa-compress' ); ?></span> - </div> - </div> - </div> - </div> - - </div> - </div> - - <?php - } - - public function directorist_step_one_save() { - check_admin_referer('directorist-setup'); - - $_post_data = wp_unslash( $_POST ); - $atbdp_option = get_option('atbdp_option'); - - $atbdp_option['default_latitude'] = !empty($_post_data['default_latitude']) ? $_post_data['default_latitude'] : ''; - $atbdp_option['default_longitude'] = !empty($_post_data['default_longitude']) ? $_post_data['default_longitude'] : ''; - - update_option('atbdp_option', $atbdp_option); - - /** - * @since 7.3.0 - */ - do_action( 'directorist_setup_wizard_map' ); - - wp_redirect(esc_url_raw($this->get_next_step_link())); - exit; - } - - public function directorist_step_two() - { - - ?> - <div class="directorist-setup-wizard__content"> - <div class="directorist-setup-wizard__content__header--listings"> - <h1 class="directorist-setup-wizard__content__header__title"><?php esc_html_e('Yes! You can earn using Directorist Core for FREE', 'directorist'); ?></h1> - </div> - <div class="directorist-setup-wizard__content__items directorist-setup-wizard__content__items--listings"> - <div class="directorist-setup-wizard__content__pricing"> - <h4 class="directorist-setup-wizard__content__section-title">Monetization</h4> - <div class="directorist-setup-wizard__content__pricing__checkbox"> - <span class="feature-title">Enable Featured Listings</span> - <input type="checkbox" name="featured_listing" id="enable_featured" value=1 /> - <label for="enable_featured"></label> - - <div class="directorist-setup-wizard__content__pricing__amount"> - <span class="price-title">Featured Listing Fee</span> - <div class="price-amount"> - <span class="price-prefix">$</span> - <input type="text" name='featured_listing_price' id='featured_listing_price' value=19.99 /> - </div> - </div> - </div> - </div> - <div class="directorist-setup-wizard__content__gateway"> - <h4 class="directorist-setup-wizard__content__section-title">Payment Gateways</h4> - <div class="directorist-setup-wizard__content__gateway__checkbox"> - <span class="gateway-title">Enable payments via <strong>Bank Transfer</strong></span> - <input type="checkbox" name="active_gateways[]" id="enable_bank_transfer" value="bank_transfer" /> - <label for="enable_bank_transfer"></label> - </div> - <div class="directorist-setup-wizard__content__gateway__checkbox"> - <span class="gateway-title">Enable payments via <strong>PayPal</strong></span> - <input type="checkbox" name="active_gateways[]" id="enable_paypal" value="paypal_gateway" /> - <label for="enable_paypal"></label> - <span class="enable-warning">This will install the PayPal extension</span> - </div> - </div> - </div> - </div> - <?php - } - - /** - * Save store options. - */ - public function directorist_step_two_save() - { - check_admin_referer('directorist-setup'); - - $_post_data = wp_unslash( $_POST ); - - $atbdp_option = get_option('atbdp_option'); - $pages = !empty( $_post_data['share_essentials'] ) ? $_post_data['share_essentials'] : ''; - $atbdp_option['map_api_key'] = !empty($_post_data['map_api_key']) ? $_post_data['map_api_key'] : ''; - $atbdp_option['enable_monetization'] = !empty($_post_data['featured_listing']) ? 1 : false; - $atbdp_option['enable_featured_listing'] = !empty($_post_data['featured_listing']) ? $_post_data['featured_listing'] : ''; - $atbdp_option['featured_listing_price'] = !empty($_post_data['featured_listing_price']) ? $_post_data['featured_listing_price'] : ''; - $atbdp_option['active_gateways'] = !empty($_post_data['active_gateways']) ? $_post_data['active_gateways'] : array(); - $atbdp_option['paypal_gateway_title'] = __( 'PayPal', 'directorist-paypal' ); - $atbdp_option['paypal_gateway_description'] = __( 'You can make payment using paypal if you choose this payment gateway.', 'directorist-paypal' ); - - - if( ! empty( $_post_data['active_gateways'] ) && in_array( 'paypal_gateway',$_post_data['active_gateways'] ) ) { - directorist_download_plugin( [ 'url' => 'https://directorist.com/wp-content/uploads/2024/11/directorist-paypal.zip' ] ); - - $path = WP_PLUGIN_DIR . '/directorist-paypal/directorist-paypal.php'; - - if( ! is_plugin_active( $path ) ){ - activate_plugin( $path ); - } - } - - do_action('directorist_admin_setup_wizard_save_step_two'); - - $create_pages = [ - 'checkout_page' => [ - 'post_title' => 'Checkout', - 'post_content' => '[directorist_checkout]', - ], - 'payment_receipt_page' => [ - 'post_title' => 'Payment Receipt', - 'post_content' => '[directorist_payment_receipt]', - ], - 'transaction_failure_page' => [ - 'post_title' => 'Transaction Failure', - 'post_content' => '[directorist_transaction_failure]', - ], - ]; - - // if (!empty($atbdp_option['enable_monetization'])) { - // foreach ($create_pages as $key => $name) { - - // $args = [ - // 'post_title' => $name['post_title'], - // 'post_content' => $name['post_content'], - // 'post_status' => 'publish', - // 'post_type' => 'page', - // 'comment_status' => 'closed' - // ]; - // if (empty($atbdp_option[$key])) { - // $id = wp_insert_post($args); - - // if ($id) { - // $atbdp_option[$key] = $id; - // } - // } - // } - // } - update_option('atbdp_option', $atbdp_option); - - wp_redirect(esc_url_raw($this->get_next_step_link())); - exit; - } - - public function directorist_step_three() - { - - ?> - <div class="directorist-setup-wizard__content"> - <div class="directorist-setup-wizard__content__header text-center"> - <h1 class="directorist-setup-wizard__content__header__title"><?php esc_html_e( 'Demo Content and Data Sharing Preference', 'directorist' ); ?></h1> - </div> - <div class="directorist-setup-wizard__content__items directorist-setup-wizard__content__import"> - <div class="directorist-setup-wizard__content__import__wrapper"> - <h3 class="directorist-setup-wizard__content__import__title">Import Demo Data and Choose Data Sharing Preferences</h3> - <div class="directorist-setup-wizard__content__import__single"> - <input type="checkbox" name="import_listings" id="import-listing" value="yes" checked /> - <label for="import-listing">Import Demo Content</label> - </div> - <div class="directorist-setup-wizard__content__import__single"> - <input type="checkbox" name="share_non_sensitive_data" id="share-data" value="yes" checked /> - <label for="share-data">Share Non-Sensitive Data <a href="https://appsero.com/privacy-policy/" target="_blank">[Learn what we collect]</a></label> - </div> - </div> - <a href="#" class="directorist-setup-wizard__content__import__btn directorist-setup-wizard__btn directorist-setup-wizard__btn--full directorist-submit-importing"> - Submit & Launch My Directory - <svg xmlns="http://www.w3.org/2000/svg" width="14" height="12.007" viewBox="284 4 14 12.007"><g data-name="Group 2970"><path d="M284.841 9.02c.058-.009.116-.013.174-.012h9.876l-.215-.1c-.21-.1-.402-.236-.566-.401l-2.77-2.77a1.037 1.037 0 0 1-.145-1.327 1.002 1.002 0 0 1 1.503-.13l5.008 5.008a1.002 1.002 0 0 1 0 1.418l-5.008 5.008a1.002 1.002 0 0 1-1.503-.1c-.28-.419-.22-.98.145-1.327l2.765-2.775c.147-.147.316-.27.501-.366l.3-.135h-9.836a1.037 1.037 0 0 1-1.057-.841 1.002 1.002 0 0 1 .828-1.15Z" fill="#fff" fill-rule="evenodd" data-name="Path 1600"/></g></svg> - </a> - </div> - </div> - <div class="middle-content middle-content-import hidden"> - <h1>We are building your Directory</h1> - <div class="directorist-import-process-step-wrap"> - <div class="directorist-import-progress"> - <div class="directorist-import-progress-info"> - <div class="directorist-import-progress-info-text "> - <span class="directorist-import-text-inner">Preparing data...</span> - </div> - <div class="directorist-import-progress-info-precent">0</div> - </div> - <div class="directorist-import-progress-bar-wrap"> - <div class="directorist-import-progress-bar-bg"> - <div class="directorist-import-progress-bar"></div> - </div> - <div class="import-progress-gap"> - <span></span><span></span><span></span> - </div> - </div> - </div> - </div> - <div class="directorist-import-process-step-bottom"> - <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/social-layout.gif' ); ?>" alt="Drectorist membership notice"> - <span class="import-progress-warning">Please Don't Reload The Page</span> - </div> - </div> - <?php - } - - public function directorist_step_three_save() - { - check_admin_referer('directorist-setup'); - - $_post_data = wp_unslash($_POST); - - $pages = !empty($_post_data['map']) ? $_post_data['map'] : ''; - wp_redirect(esc_url_raw($this->get_next_step_link())); - exit; - } - - public function directorist_step_four() - { - update_option( 'directorist_setup_wizard_completed', true ); - - /** - * @since 7.3.0 - */ - - do_action( 'directorist_setup_wizard_completed' ); - ?> - <div class="directorist-setup-wizard__content"> - <div class="directorist-setup-wizard__content__items directorist-setup-wizard__content__items--completed"> - <svg class="congratulations-img" xmlns="http://www.w3.org/2000/svg" width="58.999" height="58.999" viewBox="611.001 174.001 58.999 58.999"> - <g data-name="Group 2976"><path d="m658.324 217.969-44.67 14.927a2.013 2.013 0 0 1-2.549-2.548l14.927-44.671 32.292 32.292Z" fill="#fdc70e" fill-rule="evenodd" data-name="Path 1603"/><path d="M658.324 217.97s-6.579-1.49-18.684-13.606c-11.784-11.773-13.524-18.34-13.607-18.683v-.012s6.591 1.49 18.7 13.6c12.11 12.109 13.591 18.702 13.591 18.702Z" fill="#d39518" fill-rule="evenodd" data-name="Path 1604"/><path d="m629.457 227.614-6.62 2.21a107.26 107.26 0 0 1-4.45-4.21c-1.58-1.58-2.97-3.06-4.21-4.45l2.21-6.62c1.68 2.03 3.73 4.3 6.25 6.82 2.52 2.52 4.79 4.57 6.82 6.25Z" fill="#2167d8" fill-rule="evenodd" data-name="Path 1605"/><path d="m647.477 221.594-7.11 2.37a82.592 82.592 0 0 1-10.93-9.4 82.593 82.593 0 0 1-9.4-10.93l2.37-7.11a74.4 74.4 0 0 0 11.28 13.79 74.4 74.4 0 0 0 13.79 11.28Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1606"/><path d="M635.53 194.41a1 1 0 0 1-.707-1.707 12.2 12.2 0 0 0 2.36-14.675 1 1 0 1 1 1.714-1.024 14.247 14.247 0 0 1-2.66 17.118.993.993 0 0 1-.707.288Z" fill="#2167d8" fill-rule="evenodd" data-name="Path 1607"/><path d="M633.857 184.37a1 1 0 0 1-.707-.293l-1.674-1.673a1 1 0 0 1 1.415-1.414l1.673 1.673a1 1 0 0 1-.707 1.707Z" fill="#23af6f" fill-rule="evenodd" data-name="Path 1608"/><path d="M645.57 182.697a1 1 0 0 1-1-1v-1.673a1 1 0 0 1 2 0v1.673a1 1 0 0 1-1 1Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1609"/><path d="M647.244 189.39h-1.674a1 1 0 0 1 0-2h1.674a1 1 0 0 1 0 2Z" fill="#23af6f" fill-rule="evenodd" data-name="Path 1610"/><path d="M650.59 209.47a1 1 0 0 1-.707-1.706 14.248 14.248 0 0 1 17.12-2.66 1 1 0 0 1-1.028 1.715 12.067 12.067 0 0 0-14.678 2.359 1 1 0 0 1-.707.293Z" fill="#2167d8" fill-rule="evenodd" data-name="Path 1611"/><path d="M662.304 212.817a1 1 0 0 1-.707-.292l-1.674-1.674a1 1 0 1 1 1.414-1.414l1.674 1.673a1 1 0 0 1-.707 1.707Z" fill="#23af6f" fill-rule="evenodd" data-name="Path 1612"/><path d="M663.976 199.43h-1.672a1 1 0 0 1 0-2h1.672a1 1 0 0 1 0 2Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1613"/><path d="M655.61 199.43a1 1 0 0 1-1-1v-1.673a1 1 0 0 1 2 0v1.674a1 1 0 0 1-1 1Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1614"/><path d="M647.244 196.084a1 1 0 0 1-.707-1.707 4.061 4.061 0 0 1 3.216-1.128h.022a2.1 2.1 0 0 0 1.78-.542 2.119 2.119 0 0 0 .541-1.8 3.94 3.94 0 0 1 4.346-4.348 2 2 0 0 0 2.355-2.355 4.067 4.067 0 0 1 1.131-3.218 1 1 0 1 1 1.41 1.418 2.128 2.128 0 0 0-.546 1.8 3.942 3.942 0 0 1-4.349 4.349 1.993 1.993 0 0 0-2.346 2.35 4.054 4.054 0 0 1-1.128 3.217 4.105 4.105 0 0 1-3.216 1.128h-.023a2.094 2.094 0 0 0-1.778.542 1 1 0 0 1-.708.294Z" fill="#fdc70e" fill-rule="evenodd" data-name="Path 1615"/><g data-name="Group 2975"><path d="M650.591 184.37a1 1 0 0 1-.925-1.381 9.272 9.272 0 0 0 .042-7.515 1 1 0 1 1 1.764-.944 11.275 11.275 0 0 1 .044 9.22 1 1 0 0 1-.925.62Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1616"/><path d="M660.63 194.41a1 1 0 0 1-.38-1.925 11.266 11.266 0 0 1 9.221.044 1 1 0 0 1-.944 1.764 9.267 9.267 0 0 0-7.516.042c-.12.05-.25.075-.38.075Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1617"/></g></g> - </svg> - <h1 class="directorist-setup-wizard__content__title"><?php esc_html_e('Congratulations', 'directorist'); ?></h1> - <h4 class="directorist-setup-wizard__content__desc"><?php esc_html_e('Your directory website is ready. Thank you for using Directorist', 'directorist'); ?></h4> - <h2 class="directorist-setup-wizard__content__title--section"><?php esc_html_e('What\'s next?', 'directorist'); ?></h2> - <div class="directorist-setup-wizard__content__btns"> - <a href="<?php echo esc_url(admin_url().'edit.php?post_type=at_biz_dir'); ?>" class="directorist-setup-wizard__btn"><?php esc_html_e('Create Your First Listing', 'directorist'); ?></a> - <a href="<?php echo esc_url(admin_url().'edit.php?post_type=at_biz_dir'); ?>" class="directorist-setup-wizard__btn directorist-setup-wizard__btn--return"><?php esc_html_e('Return to the Wordpress Dashboard', 'directorist'); ?></a> - </div> - </div> - </div> - <?php - } - - public function get_steps() - { - return $this->steps; - } - - /** - * Introduction step. - */ - public function directorist_setup_introduction() - { - ?> - <div class="directorist-setup-wizard__content"> - <div class="directorist-setup-wizard__content__header"> - <h1 class="directorist-setup-wizard__content__header__title"><?php esc_html_e('What type of directory are you creating?', 'directorist'); ?></h1> - <p class="directorist-setup-wizard__content__header__desc"><?php echo wp_kses(__('Select the directory type you’re building. Weather it’s a business directory, a classifieds platform, or something else, we’ve got you covered.', 'directorist'), ['strong' => []]); ?></p> - </div> - <div class="directorist-setup-wizard__content__items"> - <div class="directorist-setup-wizard__counter"> - <h3 class="directorist-setup-wizard__counter__title"> - Selected Types: <span class="selected_count">1</span>/<span class="max_count">5</span> - </h3> - <p class="directorist-setup-wizard__counter__desc">You can add more from the directory builder </p> - </div> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="business-directory" value="business" checked /> - <label for="business-directory">Business Directory</label> - </div> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="classified-listing" value="classified" /> - <label for="classified-listing">Classified Listing</label> - </div> - <!-- <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="car-directory" value="car_rent" /> - <label for="car-directory">Car Rent Directory</label> - </div> --> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="car-rent-directory" value="car_sell" /> - <label for="car-rent-directory">Car Sell Directory</label> - </div> - <!-- <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="real-estate-rent" value="real_estate_rent" /> - <label for="real-estate-rent">Real Estate (Rent)</label> - </div> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="real-estate-sell" value="real_estate_sell" /> - <label for="real-estate-sell">Real Estate (Sell)</label> - </div> --> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="place" value="place" /> - <label for="place">Place</label> - </div> - <!-- <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="travel-directory" value="travel" /> - <label for="travel-directory">Travel Directory</label> - </div> --> - <!-- <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="service-directory" value="service" /> - <label for="service-directory">Service Directory</label> - </div> --> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="job-directory" value="job" /> - <label for="job-directory">Job Directory</label> - </div> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="hotel-directory" value="hotel" /> - <label for="hotel-directory">Hotel Directory</label> - </div> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="restaurant-directory" value="restaurant" /> - <label for="restaurant-directory">Restaurant Directory</label> - </div> - <!-- <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="multipurpose-directory" value="multipurpose"/> - <label for="multipurpose-directory">Multipurpose Directory</label> - </div> --> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="lawyers-directory" value="lawyers" /> - <label for="lawyers-directory">Lawyers Directory</label> - </div> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="doctors-directory" value="doctors" /> - <label for="doctors-directory">Doctors Directory</label> - </div> - <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="need-directory" value="post_your_need" /> - <label for="need-directory">Post Your Need</label> - </div> - <!-- <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="hospitals-directory" value="hospitals" /> - <label for="hospitals-directory">Hospitals Directory</label> - </div> --> - <!-- <div class="directorist-setup-wizard__checkbox"> - <input type="checkbox" name="directory_type[]" id="others-listing" value="other" /> - <label for="others-listing">Others</label> - </div> --> - <div class="directorist-setup-wizard__checkbox directorist-setup-wizard__checkbox--custom"> - <input type="text" name="other_directory_type" id="others-listing" placeholder="Type Your Preferred Directory Name" /> - </div> - <span class="directorist-setup-wizard__notice" style="display: none"> - Minimum 1 selection is required - </span> - </div> - <a href="<?php echo esc_attr( admin_url() ); ?>" class="directorist-setup-wizard__content__notice"> - <svg xmlns="http://www.w3.org/2000/svg" width="14.932" height="16" viewBox="570 654 14.932 16"><path d="M580.32 669.25a.75.75 0 0 1-.75.75h-7.07a2.503 2.503 0 0 1-2.5-2.5v-11a2.503 2.503 0 0 1 2.5-2.5h7.07a.75.75 0 0 1 0 1.5h-7.07c-.552 0-1 .448-1 1v11c0 .552.448 1 1 1h7.07a.75.75 0 0 1 .75.75Zm4.393-7.78-3.564-3.564a.75.75 0 1 0-1.061 1.06l2.284 2.284h-5.905a.75.75 0 0 0 0 1.5h5.905l-2.284 2.284a.75.75 0 1 0 1.06 1.06l3.565-3.564a.75.75 0 0 0 0-1.06Z" fill="#484848" fill-rule="evenodd" data-name="Path 1620"/></svg> Not Right Now. Exit to Dashboard - </a> - </div> - <?php - } - - public function directorist_step_intro_save() { - check_admin_referer('directorist-setup'); - - $_post_data = wp_unslash( $_POST ); - $expiration_time = 24 * HOUR_IN_SECONDS; - $atbdp_option = get_option('atbdp_option'); - - $directory_type = ! empty( $_post_data['directory_type'] ) ? $_post_data['directory_type'] : array(); - - if( count( $directory_type ) > 1 ) { - $atbdp_option['enable_multi_directory'] = true; - update_option('atbdp_option', $atbdp_option); - } - - if( ! empty( $_post_data['other_directory_type'] ) ) { - $other_directory_type = array( - 'other_directory_type' => $_post_data['other_directory_type'], - ); - ATBDP()->insights->add_extra( $other_directory_type ); - } - - set_transient( 'directory_type', $directory_type, $expiration_time ); - - /** - * @since 7.3.0 - */ - do_action( 'directorist_setup_wizard_introduction' ); - - wp_redirect(esc_url_raw($this->get_next_step_link())); - exit; - } - - public function get_next_step_link() - { - $keys = array_keys($this->steps); - - return add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps)) + 1]); - } - - /** - * Wizard templates - * - * @since 2.9.27 - * - * @return void - */ - protected function set_setup_wizard_template() - { - $this->setup_wizard_header(); - $this->setup_wizard_steps(); - $this->setup_wizard_content(); - $this->setup_wizard_footer(); - } - - /** - * Setup Wizard Header. - */ - public function setup_wizard_header() - { - set_current_screen(); - $hide = ! isset( $_GET['step'] ) ? 'directorist-setup-wizard-vh' : 'directorist-setup-wizard-vh-none'; - - $ouput_steps = $this->steps; - array_shift($ouput_steps); - $hide = ! isset( $_GET['step'] ) ? 'atbdp-none' : ''; - $step = ! empty( $_GET['step'] ) ? $_GET['step'] : ''; - $introduction_step = empty( $step ) || 'step-one' == $step || 'step-two' == $step || 'step-three' == $step ? 'active' : ''; - $step_one = ( ! empty( $step ) && ( 'step-one' == $step || 'step-two' == $step || 'step-three' == $step ) ) ? 'active' : '' ; - $step_two = ( ! empty( $step ) && ( 'step-two' == $step || 'step-three' == $step ) ) ? 'active' : '' ; - $step_three = ( ! empty( $step ) && ( 'step-three' == $step || 'step-three' == $step ) ) ? 'active' : '' ; - - $header_title = __( 'Choose a directory type', 'directorist' ); - $active_number = 1; - - switch ( $step ) { - case 'step-one': - $active_number = 2; - $header_title = __( 'Choose Default Location', 'directorist' ); - break; - case 'step-two': - $active_number = 3; - $header_title = __( 'Earn with Directorist', 'directorist' ); - break; - case 'step-three': - $active_number = 4; - $header_title = __( 'Insert Content', 'directorist' ); - break; - default: - $active_number = 1; - } - ?> - <!DOCTYPE html> - <html <?php language_attributes(); ?>> - - <head> - <meta name="viewport" content="width=device-width" /> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> - <title><?php esc_html_e('Directorist › Setup Wizard', 'directorist'); ?></title> - <?php wp_print_scripts('directorist-admin-setup-wizard-script'); ?> - <?php wp_print_scripts('directorist-test'); ?> - <?php wp_print_scripts('directorist-select2'); ?> - <?php do_action('admin_print_styles'); ?> - <?php do_action('admin_head'); ?> - <?php do_action('directorist_setup_wizard_styles'); ?> - </head> - - <body class="atbdp-setup directorist-setup-wizard wp-core-ui<?php echo get_transient('directorist_setup_wizard_no_wc') ? esc_attr( ' directorist-setup-wizard-activated-wc' ) : ''; ?> <?php echo esc_attr( $hide ); ?>"> - <form method="post" class="directorist-setup-wizard-wrapper directorist-setup-wizard__wrapper"> - <?php if (!(isset($_GET['step']) && $_GET['step'] == 'step-four')) : ?> - <div class="directorist-setup-wizard__header"> - <div class="directorist-setup-wizard__logo"> - <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/directorist-logo.svg' );?>" alt="Directorist"> - </div> - <div class="directorist-setup-wizard__header__step"> - <ul class="atbdp-setup-steps <?php echo esc_attr( $hide ); ?>"> - <li class="<?php echo esc_attr( $introduction_step ); ?>"></li> - <li class="<?php echo esc_attr( $step_one ); ?>"></li> - <li class="<?php echo esc_attr( $step_two ); ?>"></li> - <li class="<?php echo esc_attr( $step_three ); ?>"></li> - </ul> - <span class="step-count"><?php esc_html_e( sprintf( '%s %d of 4', 'Step', $active_number ), 'directorist' ); ?></span> - </div> - <div class="directorist-setup-wizard__close"> - <a href="<?php echo esc_attr( admin_url() ); ?>" class="directorist-setup-wizard__close__btn"> - <svg xmlns="http://www.w3.org/2000/svg" width="12" height="11.998" viewBox="1237 31 12 11.998"><path d="m1244.409 36.998 4.295-4.286a1.003 1.003 0 0 0-1.418-1.418L1243 35.59l-4.286-4.296a1.003 1.003 0 0 0-1.418 1.418l4.295 4.286-4.295 4.286a.999.999 0 0 0 0 1.419.999.999 0 0 0 1.418 0l4.286-4.296 4.286 4.296a1 1 0 0 0 1.418 0 .999.999 0 0 0 0-1.419l-4.295-4.286Z" fill="#b7b7b7" fill-rule="evenodd" data-name="times"/></svg> - </a> - </div> - </div> - <?php endif; ?> - - <?php - } - - /** - * Output the steps. - */ - public function setup_wizard_steps() - { - $ouput_steps = $this->steps; - array_shift($ouput_steps); - $hide = ! isset( $_GET['step'] ) ? 'atbdp-none' : ''; - ?> - <!-- <ul class="atbdp-setup-steps <?php echo esc_attr( $hide ); ?>"> - <li class="atbdsw-logo"><img src="<?php echo esc_url(DIRECTORIST_ASSETS . 'images/directorist-logo.svg');?>" alt="Directorist"></li> - <?php foreach ($ouput_steps as $step_key => $step) : ?> - <li class="<?php - if ($step_key === $this->step && 'step-four' != $step_key ) { - echo 'active'; - } elseif ( array_search( $this->step, array_keys($this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) { - echo 'done'; - } elseif ( isset( $_GET['step'] ) && 'step-four' == $_GET['step'] ) { - echo 'done'; - } - $number = 1; - if ( 'step-one' == $step_key ) { - $number = 1; - } else if ( 'step-two' == $step_key ) { - $number = 2; - } else if ( 'step-three' == $step_key ) { - $number = 3; - } else if ( 'step-four' == $step_key ) { - $number = 4; - } - ?>"><span class="atbdp-sw-circle"><span><?php echo esc_html( $number ); ?></span> <span class="dashicons dashicons-yes"></span></span><?php echo esc_html( $step['name'] ); ?> </li> - <?php endforeach; ?> - </ul> --> - <?php - } - - /** - * Output the content for the current step. - */ - public function setup_wizard_content() - { - if ( empty( $this->steps[ $this->step ]['view'] ) ) { - wp_redirect(esc_url_raw(add_query_arg('step', 'introduction'))); - exit; - } - $introduction_class = ! isset( $_GET['step'] ) ? 'directorist-setup-wizard__introduction' : ''; - echo '<div class="directorist-setup-wizard__step '. esc_attr( $introduction_class ) .'">'; - call_user_func($this->steps[$this->step]['view']); - echo '</div>'; - } - - /** - * Setup Wizard Footer. - */ - public function setup_wizard_footer() - { - ?> - <?php if ( 'next_steps' === $this->step ) : ?> - <a class="atbdp-return-to-dashboard" href="<?php echo esc_url(admin_url()); ?>"><?php esc_html_e('Return to the WordPress Dashboard', 'directorist'); ?></a> - <?php endif; ?> - <?php if (!(isset($_GET['step']) && ($_GET['step'] == 'step-three' || $_GET['step'] == 'step-four'))) : ?> - <div class="directorist-setup-wizard__footer"> - <?php if ( ! empty( $_GET['step'] ) && 'step-four' != $_GET['step'] ) : ?> - <div class="directorist-setup-wizard__back"> - <a href="<?php echo esc_url( wp_get_referer() ) ?>" class="directorist-setup-wizard__back__btn"> - <img src="<?php echo esc_url(DIRECTORIST_ASSETS . 'images/angle-down.svg');?>" /> - Back - </a> - </div> - <?php endif; ?> - <div class="directorist-setup-wizard__next"> - <?php if ( ! empty( $_GET['step'] ) && 'step-four' != $_GET['step'] ) : ?> - <a href="/wp-admin/index.php?page=directorist-setup&step=step-three" class="w-skip-link">Skip this step</a> - <?php endif; ?> - <?php wp_nonce_field('directorist-setup'); ?> - <button type="submit" class="directorist-setup-wizard__btn directorist-setup-wizard__btn--next" name="save_step" value="submit">Next <img src="<?php echo esc_url(DIRECTORIST_ASSETS . 'images/arrow-right.svg');?>" /></button> - </div> - </div> - <?php endif; ?> - </form> - </body> - - </html> -<?php - } + public function directorist_step_one() { + $map_data = $this->get_map_data(); + Directorist\Helper::add_hidden_data_to_dom( 'map_data', $map_data ); + ?> + <div class="directorist-setup-wizard__box"> + <div class="directorist-setup-wizard__box__content"> + <h1 class="directorist-setup-wizard__box__content__title">Default Location</h1> + <p class="directorist-setup-wizard__box__content__desc">Drag the map or marker to the middle of your city</p> + <h4 class="directorist-setup-wizard__box__content__title directorist-setup-wizard__box__content__title--section">Add your location</h4> + <div class="directorist-setup-wizard__box__content__form directorist-form-address-field directorist-search-field"> + <span class="directorist-setup-wizard__box__content__location-icon directorist-filter-location-icon"> + <?php directorist_icon( 'fas fa-crosshairs' ); ?> + </span> + <input type="text" autocomplete="off" name="" class="directorist-setup-wizard__box__content__input directorist-location-js" value="" placeholder="Search your location"> + <input type="hidden" name="default_latitude" id="manual_lat" value="" /> + <input type="hidden" name="default_longitude" id="manual_lng" value="" /> + <div class="directorist-setup-wizard__box__content__input--clear"> + <?php directorist_icon( 'fas fa-times-circle' ); ?> + </div> + <div class="address_result"><ul></ul></div> + + </div> + + <div class="directorist-setup-wizard__map directorist-form-map-field__maps"> + <div id="osm"> + <div id="gmap"> + <div id="gmap_full_screen_button"> + <span class="fullscreen-enable"><?php directorist_icon( 'fas fa-expand' ); ?></span> + <span class="fullscreen-disable"><?php directorist_icon( 'fas fa-compress' ); ?></span> + </div> + </div> + </div> + </div> + + </div> + </div> + + <?php + } + + public function directorist_step_one_save() { + check_admin_referer( 'directorist-setup' ); + + $_post_data = wp_unslash( $_POST ); + $atbdp_option = get_option( 'atbdp_option' ); + + $atbdp_option['default_latitude'] = ! empty( $_post_data['default_latitude'] ) ? $_post_data['default_latitude'] : ''; + $atbdp_option['default_longitude'] = ! empty( $_post_data['default_longitude'] ) ? $_post_data['default_longitude'] : ''; + + update_option( 'atbdp_option', $atbdp_option ); + + /** + * @since 7.3.0 + */ + do_action( 'directorist_setup_wizard_map' ); + + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); + exit; + } + + public function directorist_step_two() { + + ?> + <div class="directorist-setup-wizard__content"> + <div class="directorist-setup-wizard__content__header--listings"> + <h1 class="directorist-setup-wizard__content__header__title"><?php esc_html_e( 'Yes! You can earn using Directorist Core for FREE', 'directorist' ); ?></h1> + </div> + <div class="directorist-setup-wizard__content__items directorist-setup-wizard__content__items--listings"> + <div class="directorist-setup-wizard__content__pricing"> + <h4 class="directorist-setup-wizard__content__section-title">Monetization</h4> + <div class="directorist-setup-wizard__content__pricing__checkbox"> + <span class="feature-title">Enable Featured Listings</span> + <input type="checkbox" name="featured_listing" id="enable_featured" value=1 /> + <label for="enable_featured"></label> + + <div class="directorist-setup-wizard__content__pricing__amount"> + <span class="price-title">Featured Listing Fee</span> + <div class="price-amount"> + <span class="price-prefix">$</span> + <input type="text" name='featured_listing_price' id='featured_listing_price' value=19.99 /> + </div> + </div> + </div> + </div> + <div class="directorist-setup-wizard__content__gateway"> + <h4 class="directorist-setup-wizard__content__section-title">Payment Gateways</h4> + <div class="directorist-setup-wizard__content__gateway__checkbox"> + <span class="gateway-title">Enable payments via <strong>Bank Transfer</strong></span> + <input type="checkbox" name="active_gateways[]" id="enable_bank_transfer" value="bank_transfer" /> + <label for="enable_bank_transfer"></label> + </div> + <div class="directorist-setup-wizard__content__gateway__checkbox"> + <span class="gateway-title">Enable payments via <strong>PayPal</strong></span> + <input type="checkbox" name="active_gateways[]" id="enable_paypal" value="paypal_gateway" /> + <label for="enable_paypal"></label> + <span class="enable-warning">This will install the PayPal extension</span> + </div> + </div> + </div> + </div> + <?php + } + + /** + * Save store options. + */ + public function directorist_step_two_save() { + check_admin_referer( 'directorist-setup' ); + + $_post_data = wp_unslash( $_POST ); + + $atbdp_option = get_option( 'atbdp_option' ); + $pages = ! empty( $_post_data['share_essentials'] ) ? $_post_data['share_essentials'] : ''; + $atbdp_option['map_api_key'] = ! empty( $_post_data['map_api_key'] ) ? $_post_data['map_api_key'] : ''; + $atbdp_option['enable_monetization'] = ! empty( $_post_data['featured_listing'] ) ? 1 : false; + $atbdp_option['enable_featured_listing'] = ! empty( $_post_data['featured_listing'] ) ? $_post_data['featured_listing'] : ''; + $atbdp_option['featured_listing_price'] = ! empty( $_post_data['featured_listing_price'] ) ? $_post_data['featured_listing_price'] : ''; + $atbdp_option['active_gateways'] = ! empty( $_post_data['active_gateways'] ) ? $_post_data['active_gateways'] : array(); + $atbdp_option['paypal_gateway_title'] = __( 'PayPal', 'directorist-paypal' ); + $atbdp_option['paypal_gateway_description'] = __( 'You can make payment using paypal if you choose this payment gateway.', 'directorist-paypal' ); + + if ( ! empty( $_post_data['active_gateways'] ) && in_array( 'paypal_gateway', $_post_data['active_gateways'] ) ) { + directorist_download_plugin( array( 'url' => 'https://directorist.com/wp-content/uploads/2024/11/directorist-paypal.zip' ) ); + + $path = WP_PLUGIN_DIR . '/directorist-paypal/directorist-paypal.php'; + + if ( ! is_plugin_active( $path ) ) { + activate_plugin( $path ); + } + } + + do_action( 'directorist_admin_setup_wizard_save_step_two' ); + + $create_pages = array( + 'checkout_page' => array( + 'post_title' => 'Checkout', + 'post_content' => '[directorist_checkout]', + ), + 'payment_receipt_page' => array( + 'post_title' => 'Payment Receipt', + 'post_content' => '[directorist_payment_receipt]', + ), + 'transaction_failure_page' => array( + 'post_title' => 'Transaction Failure', + 'post_content' => '[directorist_transaction_failure]', + ), + ); + + // if (!empty($atbdp_option['enable_monetization'])) { + // foreach ($create_pages as $key => $name) { + + // $args = [ + // 'post_title' => $name['post_title'], + // 'post_content' => $name['post_content'], + // 'post_status' => 'publish', + // 'post_type' => 'page', + // 'comment_status' => 'closed' + // ]; + // if (empty($atbdp_option[$key])) { + // $id = wp_insert_post($args); + + // if ($id) { + // $atbdp_option[$key] = $id; + // } + // } + // } + // } + update_option( 'atbdp_option', $atbdp_option ); + + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); + exit; + } + + public function directorist_step_three() { + + ?> + <div class="directorist-setup-wizard__content"> + <div class="directorist-setup-wizard__content__header text-center"> + <h1 class="directorist-setup-wizard__content__header__title"><?php esc_html_e( 'Demo Content and Data Sharing Preference', 'directorist' ); ?></h1> + </div> + <div class="directorist-setup-wizard__content__items directorist-setup-wizard__content__import"> + <div class="directorist-setup-wizard__content__import__wrapper"> + <h3 class="directorist-setup-wizard__content__import__title">Import Demo Data and Choose Data Sharing Preferences</h3> + <div class="directorist-setup-wizard__content__import__single"> + <input type="checkbox" name="import_listings" id="import-listing" value="yes" checked /> + <label for="import-listing">Import Demo Content</label> + </div> + <div class="directorist-setup-wizard__content__import__single"> + <input type="checkbox" name="share_non_sensitive_data" id="share-data" value="yes" checked /> + <label for="share-data">Share Non-Sensitive Data <a href="https://appsero.com/privacy-policy/" target="_blank">[Learn what we collect]</a></label> + </div> + </div> + <a href="#" class="directorist-setup-wizard__content__import__btn directorist-setup-wizard__btn directorist-setup-wizard__btn--full directorist-submit-importing"> + Submit & Launch My Directory + <svg xmlns="http://www.w3.org/2000/svg" width="14" height="12.007" viewBox="284 4 14 12.007"><g data-name="Group 2970"><path d="M284.841 9.02c.058-.009.116-.013.174-.012h9.876l-.215-.1c-.21-.1-.402-.236-.566-.401l-2.77-2.77a1.037 1.037 0 0 1-.145-1.327 1.002 1.002 0 0 1 1.503-.13l5.008 5.008a1.002 1.002 0 0 1 0 1.418l-5.008 5.008a1.002 1.002 0 0 1-1.503-.1c-.28-.419-.22-.98.145-1.327l2.765-2.775c.147-.147.316-.27.501-.366l.3-.135h-9.836a1.037 1.037 0 0 1-1.057-.841 1.002 1.002 0 0 1 .828-1.15Z" fill="#fff" fill-rule="evenodd" data-name="Path 1600"/></g></svg> + </a> + </div> + </div> + <div class="middle-content middle-content-import hidden"> + <h1>We are building your Directory</h1> + <div class="directorist-import-process-step-wrap"> + <div class="directorist-import-progress"> + <div class="directorist-import-progress-info"> + <div class="directorist-import-progress-info-text "> + <span class="directorist-import-text-inner">Preparing data...</span> + </div> + <div class="directorist-import-progress-info-precent">0</div> + </div> + <div class="directorist-import-progress-bar-wrap"> + <div class="directorist-import-progress-bar-bg"> + <div class="directorist-import-progress-bar"></div> + </div> + <div class="import-progress-gap"> + <span></span><span></span><span></span> + </div> + </div> + </div> + </div> + <div class="directorist-import-process-step-bottom"> + <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/social-layout.gif' ); ?>" alt="Drectorist membership notice"> + <span class="import-progress-warning">Please Don't Reload The Page</span> + </div> + </div> + <?php + } + + public function directorist_step_three_save() { + check_admin_referer( 'directorist-setup' ); + + $_post_data = wp_unslash( $_POST ); + + $pages = ! empty( $_post_data['map'] ) ? $_post_data['map'] : ''; + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); + exit; + } + + public function directorist_step_four() { + update_option( 'directorist_setup_wizard_completed', true ); + + /** + * @since 7.3.0 + */ + + do_action( 'directorist_setup_wizard_completed' ); + ?> + <div class="directorist-setup-wizard__content"> + <div class="directorist-setup-wizard__content__items directorist-setup-wizard__content__items--completed"> + <svg class="congratulations-img" xmlns="http://www.w3.org/2000/svg" width="58.999" height="58.999" viewBox="611.001 174.001 58.999 58.999"> + <g data-name="Group 2976"><path d="m658.324 217.969-44.67 14.927a2.013 2.013 0 0 1-2.549-2.548l14.927-44.671 32.292 32.292Z" fill="#fdc70e" fill-rule="evenodd" data-name="Path 1603"/><path d="M658.324 217.97s-6.579-1.49-18.684-13.606c-11.784-11.773-13.524-18.34-13.607-18.683v-.012s6.591 1.49 18.7 13.6c12.11 12.109 13.591 18.702 13.591 18.702Z" fill="#d39518" fill-rule="evenodd" data-name="Path 1604"/><path d="m629.457 227.614-6.62 2.21a107.26 107.26 0 0 1-4.45-4.21c-1.58-1.58-2.97-3.06-4.21-4.45l2.21-6.62c1.68 2.03 3.73 4.3 6.25 6.82 2.52 2.52 4.79 4.57 6.82 6.25Z" fill="#2167d8" fill-rule="evenodd" data-name="Path 1605"/><path d="m647.477 221.594-7.11 2.37a82.592 82.592 0 0 1-10.93-9.4 82.593 82.593 0 0 1-9.4-10.93l2.37-7.11a74.4 74.4 0 0 0 11.28 13.79 74.4 74.4 0 0 0 13.79 11.28Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1606"/><path d="M635.53 194.41a1 1 0 0 1-.707-1.707 12.2 12.2 0 0 0 2.36-14.675 1 1 0 1 1 1.714-1.024 14.247 14.247 0 0 1-2.66 17.118.993.993 0 0 1-.707.288Z" fill="#2167d8" fill-rule="evenodd" data-name="Path 1607"/><path d="M633.857 184.37a1 1 0 0 1-.707-.293l-1.674-1.673a1 1 0 0 1 1.415-1.414l1.673 1.673a1 1 0 0 1-.707 1.707Z" fill="#23af6f" fill-rule="evenodd" data-name="Path 1608"/><path d="M645.57 182.697a1 1 0 0 1-1-1v-1.673a1 1 0 0 1 2 0v1.673a1 1 0 0 1-1 1Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1609"/><path d="M647.244 189.39h-1.674a1 1 0 0 1 0-2h1.674a1 1 0 0 1 0 2Z" fill="#23af6f" fill-rule="evenodd" data-name="Path 1610"/><path d="M650.59 209.47a1 1 0 0 1-.707-1.706 14.248 14.248 0 0 1 17.12-2.66 1 1 0 0 1-1.028 1.715 12.067 12.067 0 0 0-14.678 2.359 1 1 0 0 1-.707.293Z" fill="#2167d8" fill-rule="evenodd" data-name="Path 1611"/><path d="M662.304 212.817a1 1 0 0 1-.707-.292l-1.674-1.674a1 1 0 1 1 1.414-1.414l1.674 1.673a1 1 0 0 1-.707 1.707Z" fill="#23af6f" fill-rule="evenodd" data-name="Path 1612"/><path d="M663.976 199.43h-1.672a1 1 0 0 1 0-2h1.672a1 1 0 0 1 0 2Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1613"/><path d="M655.61 199.43a1 1 0 0 1-1-1v-1.673a1 1 0 0 1 2 0v1.674a1 1 0 0 1-1 1Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1614"/><path d="M647.244 196.084a1 1 0 0 1-.707-1.707 4.061 4.061 0 0 1 3.216-1.128h.022a2.1 2.1 0 0 0 1.78-.542 2.119 2.119 0 0 0 .541-1.8 3.94 3.94 0 0 1 4.346-4.348 2 2 0 0 0 2.355-2.355 4.067 4.067 0 0 1 1.131-3.218 1 1 0 1 1 1.41 1.418 2.128 2.128 0 0 0-.546 1.8 3.942 3.942 0 0 1-4.349 4.349 1.993 1.993 0 0 0-2.346 2.35 4.054 4.054 0 0 1-1.128 3.217 4.105 4.105 0 0 1-3.216 1.128h-.023a2.094 2.094 0 0 0-1.778.542 1 1 0 0 1-.708.294Z" fill="#fdc70e" fill-rule="evenodd" data-name="Path 1615"/><g data-name="Group 2975"><path d="M650.591 184.37a1 1 0 0 1-.925-1.381 9.272 9.272 0 0 0 .042-7.515 1 1 0 1 1 1.764-.944 11.275 11.275 0 0 1 .044 9.22 1 1 0 0 1-.925.62Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1616"/><path d="M660.63 194.41a1 1 0 0 1-.38-1.925 11.266 11.266 0 0 1 9.221.044 1 1 0 0 1-.944 1.764 9.267 9.267 0 0 0-7.516.042c-.12.05-.25.075-.38.075Z" fill="#d3374e" fill-rule="evenodd" data-name="Path 1617"/></g></g> + </svg> + <h1 class="directorist-setup-wizard__content__title"><?php esc_html_e( 'Congratulations', 'directorist' ); ?></h1> + <h4 class="directorist-setup-wizard__content__desc"><?php esc_html_e( 'Your directory website is ready. Thank you for using Directorist', 'directorist' ); ?></h4> + <h2 class="directorist-setup-wizard__content__title--section"><?php esc_html_e( 'What\'s next?', 'directorist' ); ?></h2> + <div class="directorist-setup-wizard__content__btns"> + <a href="<?php echo esc_url( admin_url() . 'edit.php?post_type=at_biz_dir' ); ?>" class="directorist-setup-wizard__btn"><?php esc_html_e( 'Create Your First Listing', 'directorist' ); ?></a> + <a href="<?php echo esc_url( admin_url() . 'edit.php?post_type=at_biz_dir' ); ?>" class="directorist-setup-wizard__btn directorist-setup-wizard__btn--return"><?php esc_html_e( 'Return to the WordPress Dashboard', 'directorist' ); ?></a> + </div> + </div> + </div> + <?php + } + + public function get_steps() { + return $this->steps; + } + + /** + * Introduction step. + */ + public function directorist_setup_introduction() { + ?> + <div class="directorist-setup-wizard__content"> + <div class="directorist-setup-wizard__content__header"> + <h1 class="directorist-setup-wizard__content__header__title"><?php esc_html_e( 'What type of directory are you creating?', 'directorist' ); ?></h1> + <p class="directorist-setup-wizard__content__header__desc"><?php echo wp_kses( __( 'Select the directory type you’re building. Weather it’s a business directory, a classifieds platform, or something else, we’ve got you covered.', 'directorist' ), array( 'strong' => array() ) ); ?></p> + </div> + <div class="directorist-setup-wizard__content__items"> + <div class="directorist-setup-wizard__counter"> + <h3 class="directorist-setup-wizard__counter__title"> + Selected Types: <span class="selected_count">1</span>/<span class="max_count">5</span> + </h3> + <p class="directorist-setup-wizard__counter__desc">You can add more from the directory builder </p> + </div> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="business-directory" value="business" checked /> + <label for="business-directory">Business Directory</label> + </div> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="classified-listing" value="classified" /> + <label for="classified-listing">Classified Listing</label> + </div> + <!-- <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="car-directory" value="car_rent" /> + <label for="car-directory">Car Rent Directory</label> + </div> --> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="car-rent-directory" value="car_sell" /> + <label for="car-rent-directory">Car Sell Directory</label> + </div> + <!-- <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="real-estate-rent" value="real_estate_rent" /> + <label for="real-estate-rent">Real Estate (Rent)</label> + </div> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="real-estate-sell" value="real_estate_sell" /> + <label for="real-estate-sell">Real Estate (Sell)</label> + </div> --> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="place" value="place" /> + <label for="place">Place</label> + </div> + <!-- <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="travel-directory" value="travel" /> + <label for="travel-directory">Travel Directory</label> + </div> --> + <!-- <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="service-directory" value="service" /> + <label for="service-directory">Service Directory</label> + </div> --> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="job-directory" value="job" /> + <label for="job-directory">Job Directory</label> + </div> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="hotel-directory" value="hotel" /> + <label for="hotel-directory">Hotel Directory</label> + </div> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="restaurant-directory" value="restaurant" /> + <label for="restaurant-directory">Restaurant Directory</label> + </div> + <!-- <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="multipurpose-directory" value="multipurpose"/> + <label for="multipurpose-directory">Multipurpose Directory</label> + </div> --> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="lawyers-directory" value="lawyers" /> + <label for="lawyers-directory">Lawyers Directory</label> + </div> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="doctors-directory" value="doctors" /> + <label for="doctors-directory">Doctors Directory</label> + </div> + <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="need-directory" value="post_your_need" /> + <label for="need-directory">Post Your Need</label> + </div> + <!-- <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="hospitals-directory" value="hospitals" /> + <label for="hospitals-directory">Hospitals Directory</label> + </div> --> + <!-- <div class="directorist-setup-wizard__checkbox"> + <input type="checkbox" name="directory_type[]" id="others-listing" value="other" /> + <label for="others-listing">Others</label> + </div> --> + <div class="directorist-setup-wizard__checkbox directorist-setup-wizard__checkbox--custom"> + <input type="text" name="other_directory_type" id="others-listing" placeholder="Type Your Preferred Directory Name" /> + </div> + <span class="directorist-setup-wizard__notice" style="display: none"> + Minimum 1 selection is required + </span> + </div> + <a href="<?php echo esc_attr( admin_url() ); ?>" class="directorist-setup-wizard__content__notice"> + <svg xmlns="http://www.w3.org/2000/svg" width="14.932" height="16" viewBox="570 654 14.932 16"><path d="M580.32 669.25a.75.75 0 0 1-.75.75h-7.07a2.503 2.503 0 0 1-2.5-2.5v-11a2.503 2.503 0 0 1 2.5-2.5h7.07a.75.75 0 0 1 0 1.5h-7.07c-.552 0-1 .448-1 1v11c0 .552.448 1 1 1h7.07a.75.75 0 0 1 .75.75Zm4.393-7.78-3.564-3.564a.75.75 0 1 0-1.061 1.06l2.284 2.284h-5.905a.75.75 0 0 0 0 1.5h5.905l-2.284 2.284a.75.75 0 1 0 1.06 1.06l3.565-3.564a.75.75 0 0 0 0-1.06Z" fill="#484848" fill-rule="evenodd" data-name="Path 1620"/></svg> Not Right Now. Exit to Dashboard + </a> + </div> + <?php + } + + public function directorist_step_intro_save() { + check_admin_referer( 'directorist-setup' ); + + $_post_data = wp_unslash( $_POST ); + $expiration_time = 24 * HOUR_IN_SECONDS; + $atbdp_option = get_option( 'atbdp_option' ); + + $directory_type = ! empty( $_post_data['directory_type'] ) ? $_post_data['directory_type'] : array(); + + if ( count( $directory_type ) > 1 ) { + $atbdp_option['enable_multi_directory'] = true; + update_option( 'atbdp_option', $atbdp_option ); + } + + if ( ! empty( $_post_data['other_directory_type'] ) ) { + $other_directory_type = array( + 'other_directory_type' => $_post_data['other_directory_type'], + ); + ATBDP()->insights->add_extra( $other_directory_type ); + } + + set_transient( 'directory_type', $directory_type, $expiration_time ); + + /** + * @since 7.3.0 + */ + do_action( 'directorist_setup_wizard_introduction' ); + + wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); + exit; + } + + public function get_next_step_link() { + $keys = array_keys( $this->steps ); + + return add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) + 1 ] ); + } + + /** + * Wizard templates + * + * @since 2.9.27 + * + * @return void + */ + protected function set_setup_wizard_template() { + $this->setup_wizard_header(); + $this->setup_wizard_steps(); + $this->setup_wizard_content(); + $this->setup_wizard_footer(); + } + + /** + * Setup Wizard Header. + */ + public function setup_wizard_header() { + set_current_screen(); + $hide = ! isset( $_GET['step'] ) ? 'directorist-setup-wizard-vh' : 'directorist-setup-wizard-vh-none'; + + $ouput_steps = $this->steps; + array_shift( $ouput_steps ); + $hide = ! isset( $_GET['step'] ) ? 'atbdp-none' : ''; + $step = ! empty( $_GET['step'] ) ? $_GET['step'] : ''; + $introduction_step = empty( $step ) || 'step-one' == $step || 'step-two' == $step || 'step-three' == $step ? 'active' : ''; + $step_one = ( ! empty( $step ) && ( 'step-one' == $step || 'step-two' == $step || 'step-three' == $step ) ) ? 'active' : ''; + $step_two = ( ! empty( $step ) && ( 'step-two' == $step || 'step-three' == $step ) ) ? 'active' : ''; + $step_three = ( ! empty( $step ) && ( 'step-three' == $step || 'step-three' == $step ) ) ? 'active' : ''; + + $header_title = __( 'Choose a directory type', 'directorist' ); + $active_number = 1; + + switch ( $step ) { + case 'step-one': + $active_number = 2; + $header_title = __( 'Choose Default Location', 'directorist' ); + break; + case 'step-two': + $active_number = 3; + $header_title = __( 'Earn with Directorist', 'directorist' ); + break; + case 'step-three': + $active_number = 4; + $header_title = __( 'Insert Content', 'directorist' ); + break; + default: + $active_number = 1; + } + ?> + <!DOCTYPE html> + <html <?php language_attributes(); ?>> + + <head> + <meta name="viewport" content="width=device-width" /> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title><?php esc_html_e( 'Directorist › Setup Wizard', 'directorist' ); ?></title> + <?php wp_print_scripts( 'directorist-admin-setup-wizard-script' ); ?> + <?php wp_print_scripts( 'directorist-test' ); ?> + <?php wp_print_scripts( 'directorist-select2' ); ?> + <?php do_action( 'admin_print_styles' ); ?> + <?php do_action( 'admin_head' ); ?> + <?php do_action( 'directorist_setup_wizard_styles' ); ?> + </head> + + <body class="atbdp-setup directorist-setup-wizard wp-core-ui<?php echo get_transient( 'directorist_setup_wizard_no_wc' ) ? esc_attr( ' directorist-setup-wizard-activated-wc' ) : ''; ?> <?php echo esc_attr( $hide ); ?>"> + <form method="post" class="directorist-setup-wizard-wrapper directorist-setup-wizard__wrapper"> + <?php if ( ! ( isset( $_GET['step'] ) && $_GET['step'] == 'step-four' ) ) : ?> + <div class="directorist-setup-wizard__header"> + <div class="directorist-setup-wizard__logo"> + <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/directorist-logo.svg' ); ?>" alt="Directorist"> + </div> + <div class="directorist-setup-wizard__header__step"> + <ul class="atbdp-setup-steps <?php echo esc_attr( $hide ); ?>"> + <li class="<?php echo esc_attr( $introduction_step ); ?>"></li> + <li class="<?php echo esc_attr( $step_one ); ?>"></li> + <li class="<?php echo esc_attr( $step_two ); ?>"></li> + <li class="<?php echo esc_attr( $step_three ); ?>"></li> + </ul> + <span class="step-count"><?php esc_html_e( sprintf( '%s %d of 4', 'Step', $active_number ), 'directorist' ); ?></span> + </div> + <div class="directorist-setup-wizard__close"> + <a href="<?php echo esc_attr( admin_url() ); ?>" class="directorist-setup-wizard__close__btn"> + <svg xmlns="http://www.w3.org/2000/svg" width="12" height="11.998" viewBox="1237 31 12 11.998"><path d="m1244.409 36.998 4.295-4.286a1.003 1.003 0 0 0-1.418-1.418L1243 35.59l-4.286-4.296a1.003 1.003 0 0 0-1.418 1.418l4.295 4.286-4.295 4.286a.999.999 0 0 0 0 1.419.999.999 0 0 0 1.418 0l4.286-4.296 4.286 4.296a1 1 0 0 0 1.418 0 .999.999 0 0 0 0-1.419l-4.295-4.286Z" fill="#b7b7b7" fill-rule="evenodd" data-name="times"/></svg> + </a> + </div> + </div> + <?php endif; ?> + + <?php + } + + /** + * Output the steps. + */ + public function setup_wizard_steps() { + $ouput_steps = $this->steps; + array_shift( $ouput_steps ); + $hide = ! isset( $_GET['step'] ) ? 'atbdp-none' : ''; + ?> + <!-- <ul class="atbdp-setup-steps <?php echo esc_attr( $hide ); ?>"> + <li class="atbdsw-logo"><img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/directorist-logo.svg' ); ?>" alt="Directorist"></li> + <?php foreach ( $ouput_steps as $step_key => $step ) : ?> + <li class=" + <?php + if ( $step_key === $this->step && 'step-four' != $step_key ) { + echo 'active'; + } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) { + echo 'done'; + } elseif ( isset( $_GET['step'] ) && 'step-four' == $_GET['step'] ) { + echo 'done'; + } + $number = 1; + if ( 'step-one' == $step_key ) { + $number = 1; + } elseif ( 'step-two' == $step_key ) { + $number = 2; + } elseif ( 'step-three' == $step_key ) { + $number = 3; + } elseif ( 'step-four' == $step_key ) { + $number = 4; + } + ?> + "><span class="atbdp-sw-circle"><span><?php echo esc_html( $number ); ?></span> <span class="dashicons dashicons-yes"></span></span><?php echo esc_html( $step['name'] ); ?> </li> + <?php endforeach; ?> + </ul> --> + <?php + } + + /** + * Output the content for the current step. + */ + public function setup_wizard_content() { + if ( empty( $this->steps[ $this->step ]['view'] ) ) { + wp_redirect( esc_url_raw( add_query_arg( 'step', 'introduction' ) ) ); + exit; + } + $introduction_class = ! isset( $_GET['step'] ) ? 'directorist-setup-wizard__introduction' : ''; + echo '<div class="directorist-setup-wizard__step ' . esc_attr( $introduction_class ) . '">'; + call_user_func( $this->steps[ $this->step ]['view'] ); + echo '</div>'; + } + + /** + * Setup Wizard Footer. + */ + public function setup_wizard_footer() { + ?> + <?php if ( 'next_steps' === $this->step ) : ?> + <a class="atbdp-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Return to the WordPress Dashboard', 'directorist' ); ?></a> + <?php endif; ?> + <?php if ( ! ( isset( $_GET['step'] ) && ( $_GET['step'] == 'step-three' || $_GET['step'] == 'step-four' ) ) ) : ?> + <div class="directorist-setup-wizard__footer"> + <?php if ( ! empty( $_GET['step'] ) && 'step-four' != $_GET['step'] ) : ?> + <div class="directorist-setup-wizard__back"> + <a href="<?php echo esc_url( wp_get_referer() ); ?>" class="directorist-setup-wizard__back__btn"> + <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/angle-down.svg' ); ?>" /> + Back + </a> + </div> + <?php endif; ?> + <div class="directorist-setup-wizard__next"> + <?php if ( ! empty( $_GET['step'] ) && 'step-four' != $_GET['step'] ) : ?> + <a href="/wp-admin/index.php?page=directorist-setup&step=step-three" class="w-skip-link">Skip this step</a> + <?php endif; ?> + <?php wp_nonce_field( 'directorist-setup' ); ?> + <button type="submit" class="directorist-setup-wizard__btn directorist-setup-wizard__btn--next" name="save_step" value="submit">Next <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/arrow-right.svg' ); ?>" /></button> + </div> + </div> + <?php endif; ?> + </form> + </body> + + </html> + <?php + } } new SetupWizard(); \ No newline at end of file diff --git a/includes/classes/class-shortcode.php b/includes/classes/class-shortcode.php index d6b48d20a7..d14ec16334 100644 --- a/includes/classes/class-shortcode.php +++ b/includes/classes/class-shortcode.php @@ -5,12 +5,14 @@ namespace Directorist; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class ATBDP_Shortcode { - public static $instance = null; - public static $shortcodes = []; + public static $instance = null; + public static $shortcodes = array(); public function __construct() { @@ -18,59 +20,62 @@ public function __construct() { self::$instance = $this; - self::$shortcodes = apply_filters( 'atbdp_shortcodes', [ - // Archive - 'directorist_all_listing' => [ $this, 'listing_archive' ], - 'directorist_category' => [ $this, 'category_archive' ], - 'directorist_tag' => [ $this, 'tag_archive' ], - 'directorist_location' => [ $this, 'location_archive' ], - - // Taxonomy - 'directorist_all_categories' => [ $this, 'all_categories' ], - 'directorist_all_locations' => [ $this, 'all_locations' ], - - // Search - 'directorist_search_listing' => [ $this, 'search_listing' ], - 'directorist_search_result' => [ $this, 'search_result' ], - - // Author - 'directorist_author_profile' => [ $this, 'author_profile' ], - 'directorist_user_dashboard' => [ $this, 'user_dashboard' ], - 'directorist_all_authors' => [ $this, 'all_authors' ], - 'directorist_signin_signup' => [ $this, 'directorist_signin_signup' ], - 'directorist_custom_registration' => [ $this, 'register_registration_shortcode' ], - 'directorist_user_login' => [ $this, 'register_login_shortcode' ], - - // Forms - 'directorist_add_listing' => [ $this, 'add_listing' ], - - // Checkout - 'directorist_checkout' => [ new \ATBDP_Checkout, 'display_checkout_content' ], - 'directorist_payment_receipt' => [ new \ATBDP_Checkout, 'payment_receipt' ], - 'directorist_transaction_failure' => [ new \ATBDP_Checkout, 'transaction_failure' ], - - // Single - 'directorist_single_listings_header' => [ $this, 'single_listings_header' ], - 'directorist_single_listing_section' => [ $this, 'single_listing_section' ], - 'directorist_single_listing_field' => [ $this, 'single_listing_field' ], - - // Single -- legacy shortcode - 'directorist_listing_top_area' => '__return_empty_string', - 'directorist_listing_tags' => '__return_empty_string', - 'directorist_listing_custom_fields' => '__return_empty_string', - 'directorist_listing_video' => '__return_empty_string', - 'directorist_listing_map' => '__return_empty_string', - 'directorist_listing_contact_information' => '__return_empty_string', - 'directorist_listing_author_info' => '__return_empty_string', - 'directorist_listing_contact_owner' => '__return_empty_string', - 'directorist_listing_review' => '__return_empty_string', - 'directorist_related_listings' => '__return_empty_string', - - ]); + self::$shortcodes = apply_filters( + 'atbdp_shortcodes', + array( + // Archive + 'directorist_all_listing' => array( $this, 'listing_archive' ), + 'directorist_category' => array( $this, 'category_archive' ), + 'directorist_tag' => array( $this, 'tag_archive' ), + 'directorist_location' => array( $this, 'location_archive' ), + + // Taxonomy + 'directorist_all_categories' => array( $this, 'all_categories' ), + 'directorist_all_locations' => array( $this, 'all_locations' ), + + // Search + 'directorist_search_listing' => array( $this, 'search_listing' ), + 'directorist_search_result' => array( $this, 'search_result' ), + + // Author + 'directorist_author_profile' => array( $this, 'author_profile' ), + 'directorist_user_dashboard' => array( $this, 'user_dashboard' ), + 'directorist_all_authors' => array( $this, 'all_authors' ), + 'directorist_signin_signup' => array( $this, 'directorist_signin_signup' ), + 'directorist_custom_registration' => array( $this, 'register_registration_shortcode' ), + 'directorist_user_login' => array( $this, 'register_login_shortcode' ), + + // Forms + 'directorist_add_listing' => array( $this, 'add_listing' ), + + // Checkout + 'directorist_checkout' => array( new \ATBDP_Checkout(), 'display_checkout_content' ), + 'directorist_payment_receipt' => array( new \ATBDP_Checkout(), 'payment_receipt' ), + 'directorist_transaction_failure' => array( new \ATBDP_Checkout(), 'transaction_failure' ), + + // Single + 'directorist_single_listings_header' => array( $this, 'single_listings_header' ), + 'directorist_single_listing_section' => array( $this, 'single_listing_section' ), + 'directorist_single_listing_field' => array( $this, 'single_listing_field' ), + + // Single -- legacy shortcode + 'directorist_listing_top_area' => '__return_empty_string', + 'directorist_listing_tags' => '__return_empty_string', + 'directorist_listing_custom_fields' => '__return_empty_string', + 'directorist_listing_video' => '__return_empty_string', + 'directorist_listing_map' => '__return_empty_string', + 'directorist_listing_contact_information' => '__return_empty_string', + 'directorist_listing_author_info' => '__return_empty_string', + 'directorist_listing_contact_owner' => '__return_empty_string', + 'directorist_listing_review' => '__return_empty_string', + 'directorist_related_listings' => '__return_empty_string', + + ) + ); // Register Shorcodes foreach ( self::$shortcodes as $shortcode => $callback ) { - add_shortcode( $shortcode, $callback); + add_shortcode( $shortcode, $callback ); } } @@ -80,11 +85,11 @@ public function __construct() { public function single_listings_header( $atts ) { // Render dummy shortcode content when user isn't in single listing page - if ( !is_singular( ATBDP_POST_TYPE ) ) { + if ( ! is_singular( ATBDP_POST_TYPE ) ) { return Helper::single_listing_dummy_shortcode( 'directorist_single_listings_header', $atts ); } - $listing_id = ( isset( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) ? ( int ) esc_attr( $atts['post_id'] ) : 0; + $listing_id = ( isset( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) ? (int) esc_attr( $atts['post_id'] ) : 0; if ( ! $listing_id ) { global $post; @@ -111,11 +116,11 @@ public function single_listings_header( $atts ) { public function single_listing_section( $atts = array() ) { // Render dummy shortcode content when user isn't in single listing page - if ( !is_singular( ATBDP_POST_TYPE ) ) { + if ( ! is_singular( ATBDP_POST_TYPE ) ) { return Helper::single_listing_dummy_shortcode( 'directorist_single_listing_section', $atts ); } - $listing_id = ( isset( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) ? ( int ) esc_attr( $atts['post_id'] ) : 0; + $listing_id = ( isset( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) ? (int) esc_attr( $atts['post_id'] ) : 0; if ( ! $listing_id ) { global $post; @@ -152,14 +157,16 @@ public function single_listing_section( $atts = array() ) { public function single_listing_field( $atts = array() ) { - if( ! isset( $atts[ 'field_key' ] ) || empty( $atts[ 'field_key' ] ) ) return; + if ( ! isset( $atts['field_key'] ) || empty( $atts['field_key'] ) ) { + return; + } // Render dummy shortcode content when user isn't in single listing page - if ( !is_singular( ATBDP_POST_TYPE ) ) { + if ( ! is_singular( ATBDP_POST_TYPE ) ) { return Helper::single_listing_dummy_shortcode( 'directorist_single_listing_field', $atts ); } - $listing_id = ( isset( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) ? ( int ) esc_attr( $atts['post_id'] ) : 0; + $listing_id = ( isset( $atts['post_id'] ) && is_numeric( $atts['post_id'] ) ) ? (int) esc_attr( $atts['post_id'] ) : 0; if ( ! $listing_id ) { global $post; @@ -173,18 +180,26 @@ public function single_listing_field( $atts = array() ) { ob_start(); foreach ( $listing->content_data as $section ) { - foreach ( $section[ 'fields' ] as $field ) { - if( isset( $field[ 'field_key' ] ) && $field[ 'field_key' ] === $atts[ 'field_key' ] ) { + foreach ( $section['fields'] as $field ) { + if ( isset( $field['field_key'] ) && $field['field_key'] === $atts['field_key'] ) { /** Card & Wrapper - Open */ - if( isset( $atts[ 'card' ] ) && $atts[ 'card' ] === 'true' ) echo '<div class="directorist-card"><div class="directorist-card__body">'; - if( isset( $atts[ 'wrap' ] ) && $atts[ 'wrap' ] === 'true' ) echo '<div class="directorist-details-info-wrap">'; + if ( isset( $atts['card'] ) && $atts['card'] === 'true' ) { + echo '<div class="directorist-card"><div class="directorist-card__body">'; + } + if ( isset( $atts['wrap'] ) && $atts['wrap'] === 'true' ) { + echo '<div class="directorist-details-info-wrap">'; + } $listing->field_template( $field ); /** Card & Wrapper - Close */ - if( isset( $atts[ 'wrap' ] ) && $atts[ 'wrap' ] === 'true' ) echo '</div>'; - if( isset( $atts[ 'card' ] ) && $atts[ 'card' ] === 'true' ) echo '</div></div>'; + if ( isset( $atts['wrap'] ) && $atts['wrap'] === 'true' ) { + echo '</div>'; + } + if ( isset( $atts['card'] ) && $atts['card'] === 'true' ) { + echo '</div></div>'; + } continue 2; } @@ -200,93 +215,93 @@ public function single_listing_field( $atts = array() ) { } public function listing_archive( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); + $atts = ! empty( $atts ) ? $atts : array(); $listings = new Directorist_Listings( $atts ); - if ( empty( $atts[ 'shortcode' ] ) ) { - $atts[ 'shortcode' ] = 'directorist_all_listing'; + if ( empty( $atts['shortcode'] ) ) { + $atts['shortcode'] = 'directorist_all_listing'; } return $listings->render_shortcode( $atts ); } public function category_archive( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); - $category_slug = !empty( $_GET['category'] ) ? directorist_clean( wp_unslash( $_GET['category'] ) ) : urldecode( get_query_var('atbdp_category') ); + $atts = ! empty( $atts ) ? $atts : array(); + $category_slug = ! empty( $_GET['category'] ) ? directorist_clean( wp_unslash( $_GET['category'] ) ) : urldecode( get_query_var( 'atbdp_category' ) ); $atts['category'] = sanitize_text_field( $category_slug ); - $atts[ 'shortcode' ] = 'directorist_category'; + $atts['shortcode'] = 'directorist_category'; return $this->listing_archive( $atts ); } public function tag_archive( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); - $tag_slug = !empty( $_GET['tag'] ) ? directorist_clean( wp_unslash( $_GET['tag'] ) ) : get_query_var('atbdp_tag'); + $atts = ! empty( $atts ) ? $atts : array(); + $tag_slug = ! empty( $_GET['tag'] ) ? directorist_clean( wp_unslash( $_GET['tag'] ) ) : get_query_var( 'atbdp_tag' ); $atts['tag'] = sanitize_title_for_query( $tag_slug ); - $atts[ 'shortcode' ] = 'directorist_tag'; + $atts['shortcode'] = 'directorist_tag'; return $this->listing_archive( $atts ); } public function location_archive( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); - $location_slug = !empty( $_GET['location'] ) ? directorist_clean( wp_unslash( $_GET['location'] ) ) : urldecode( get_query_var('atbdp_location') ); + $atts = ! empty( $atts ) ? $atts : array(); + $location_slug = ! empty( $_GET['location'] ) ? directorist_clean( wp_unslash( $_GET['location'] ) ) : urldecode( get_query_var( 'atbdp_location' ) ); $atts['location'] = sanitize_text_field( $location_slug ); - $atts[ 'shortcode' ] = 'directorist_location'; + $atts['shortcode'] = 'directorist_location'; return $this->listing_archive( $atts ); } public function all_categories( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); - $taxonomy = new Directorist_Listing_Taxonomy($atts, 'category'); + $atts = ! empty( $atts ) ? $atts : array(); + $taxonomy = new Directorist_Listing_Taxonomy( $atts, 'category' ); - $atts[ 'shortcode' ] = 'directorist_all_categories'; + $atts['shortcode'] = 'directorist_all_categories'; return $taxonomy->render_shortcode( $atts ); } public function all_locations( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); - $taxonomy = new Directorist_Listing_Taxonomy($atts, 'location'); + $atts = ! empty( $atts ) ? $atts : array(); + $taxonomy = new Directorist_Listing_Taxonomy( $atts, 'location' ); - $atts[ 'shortcode' ] = 'directorist_all_locations'; + $atts['shortcode'] = 'directorist_all_locations'; return $taxonomy->render_shortcode( $atts ); } public function search_listing( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); + $atts = ! empty( $atts ) ? $atts : array(); $listing_type = ''; - if (!empty($atts['listing_type'])) { + if ( ! empty( $atts['listing_type'] ) ) { $listing_type = $atts['listing_type']; } $searchform = new Directorist_Listing_Search_Form( 'search_form', $listing_type, $atts ); - $atts[ 'shortcode' ] = 'directorist_search_listing'; + $atts['shortcode'] = 'directorist_search_listing'; return $searchform->render_search_shortcode( $atts ); } public function search_result( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); + $atts = ! empty( $atts ) ? $atts : array(); $listings = new Directorist_Listings( $atts, 'search_result' ); - $atts[ 'shortcode' ] = 'directorist_search_result'; + $atts['shortcode'] = 'directorist_search_result'; return $listings->render_shortcode( $atts ); } public function author_profile( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); + $atts = ! empty( $atts ) ? $atts : array(); $author = Directorist_Listing_Author::instance(); - $atts[ 'shortcode' ] = 'directorist_author_profile'; + $atts['shortcode'] = 'directorist_author_profile'; - return $author->render_shortcode_author_profile($atts); + return $author->render_shortcode_author_profile( $atts ); } public function all_authors() { @@ -298,30 +313,30 @@ public function user_dashboard( $atts ) { $atts = ! empty( $atts ) ? $atts : array(); $dashboard = Directorist_Listing_Dashboard::instance(); - $atts[ 'shortcode' ] = 'directorist_user_dashboard'; + $atts['shortcode'] = 'directorist_user_dashboard'; return $dashboard->render_shortcode( $atts ); } public function directorist_signin_signup( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); + $atts = ! empty( $atts ) ? $atts : array(); $account = Directorist_Account::instance(); - $atts[ 'shortcode' ] = 'directorist_signin_signup'; + $atts['shortcode'] = 'directorist_signin_signup'; return $account->render( $atts ); } public function add_listing( $atts ) { - $atts = !empty( $atts ) ? $atts : array(); - $id = get_query_var( 'atbdp_listing_id', 0 ); - $id = empty( $id ) && ! empty( $_REQUEST['edit'] ) ? directorist_clean( wp_unslash( $_REQUEST['edit'] ) ) : $id; + $atts = ! empty( $atts ) ? $atts : array(); + $id = get_query_var( 'atbdp_listing_id', 0 ); + $id = empty( $id ) && ! empty( $_REQUEST['edit'] ) ? directorist_clean( wp_unslash( $_REQUEST['edit'] ) ) : $id; - $forms = Directorist_Listing_Form::instance($id); + $forms = Directorist_Listing_Form::instance( $id ); - $atts[ 'shortcode' ] = 'directorist_add_listing'; + $atts['shortcode'] = 'directorist_add_listing'; - return $forms->render_shortcode($atts); + return $forms->render_shortcode( $atts ); } /** @@ -331,10 +346,10 @@ public function add_listing( $atts ) { * @return string */ public function register_registration_shortcode() { - $atts = [ + $atts = array( 'shortcode' => 'directorist_custom_registration', 'active_form' => 'signup', - ]; + ); return Directorist_Account::instance()->render( $atts ); } @@ -346,10 +361,10 @@ public function register_registration_shortcode() { * @return string */ public function register_login_shortcode() { - $atts = [ + $atts = array( 'shortcode' => 'directorist_user_login', 'active_form' => 'signin', - ]; + ); return Directorist_Account::instance()->render( $atts ); } diff --git a/includes/classes/class-stylesheet.php b/includes/classes/class-stylesheet.php index 4d897a4079..a62e7b371a 100644 --- a/includes/classes/class-stylesheet.php +++ b/includes/classes/class-stylesheet.php @@ -1,261 +1,263 @@ <?php -if ( ! class_exists( 'ATBDP_Stylesheet' ) ): - class ATBDP_Stylesheet { - - // add_listing_css - public static function add_listing_css() { - ob_start(); ?> - #OL_Icon_33 { - position: relative; - } - - .mapHover { - position: absolute; - background: #fff; - padding: 5px; - width: 150px; - border-radius: 3px; - border: 1px solid #ddd; - display: none; - } - - #OL_Icon_33:hover .mapHover { - display: block; - } - - /*#directorist.atbd_wrapper a { - display: block; - background: #fff; - padding: 8px 10px; - }*/ - - #directorist.atbd_wrapper a:hover { - background: #eeeeee50; - } - - #directorist.atbd_wrapper a.active { - background: #eeeeee70; - } - - .g_address_wrap ul li { - margin-bottom: 0px; - border-bottom: 1px solid #eee; - padding-bottom: 0px; - } <?php - - return ob_get_clean(); - } - - // osm_css - public static function osm_css() - { - ob_start(); ?> - .myDivIcon { - text-align: center !important; - line-height: 20px !important; - position: relative; - } - - .myDivIcon div.atbd_map_shape { - position: absolute; - top: -38px; - left: -15px; - } - .leaflet-pane .myDivIcon div.atbd_map_shape { - position: absolute; - top: -50px; - left: 50%; - margin-left: -26px; - } - <?php - - return ob_get_clean(); - } - - // business_hour_css - public static function business_hour_css() - { - ob_start(); ?> - .atbd_badge_close, - .atbd_badge_open { - position: absolute; - left: 15px; - top: 15px; - } <?php - - return ob_get_clean(); - } - - // style_settings_css - public static function style_settings_css() { - do_action( 'include_style_settings' ); - $button_primary_color = get_directorist_option('button_primary_color', '#ffffff'); - $button_primary_bg_color = get_directorist_option('button_primary_bg_color', '#444752'); - $button_secondary_color = get_directorist_option('button_secondary_color', '#ffffff'); - $button_secondary_bg_color = get_directorist_option('button_secondary_bg_color', '#222222'); - $open_back_color = get_directorist_option( 'open_back_color', '#32cc6f' ); - $closed_back_color = get_directorist_option( 'closed_back_color', '#e23636' ); - $featured_back_color = get_directorist_option( 'featured_back_color', '#fa8b0c' ); - $popular_back_color = get_directorist_option( 'popular_back_color', '#f51957' ); - $new_back_color = get_directorist_option( 'new_back_color', '#2C99FF' ); - $primary_dark_back_color = get_directorist_option( 'primary_dark_back_color', '#444752' ); - $primary_dark_border_color = get_directorist_option( 'primary_dark_border_color', '#444752' ); - $marker_shape_color = get_directorist_option( 'marker_shape_color', '#444752' ); - $marker_icon_color = get_directorist_option( 'marker_icon_color', '#444752' ); - - ob_start(); - ?> - /* Settings Panel Structure - - Button: Color Name - ----------------------- - - Color - - - Background - --- Background Hover - - - Border Color - --- Border Color Hover - - */ - /** - - @buttons - 1. Primary - - Color - - Hover Color - - BG Color - 3. Solid Secondary - - Color - - Hover Color - - BG Color - */ - - - /* ======================================= - Button: Primary - ======================================== */ - /* Color */ - .pricing .price_action .price_action--btn, #directorist.atbd_wrapper .btn-primary, .default-ad-search .submit_btn .btn-default, .atbd_content_active #directorist.atbd_wrapper.dashboard_area .user_pro_img_area .user_img .choose_btn #upload_pro_pic, #directorist.atbd_wrapper .at-modal .at-modal-close, .atbdp_login_form_shortcode #loginform p input[type="submit"], .atbd_manage_fees_wrapper .table tr .action p .btn-block, #directorist.atbd_wrapper #atbdp-checkout-form #atbdp_checkout_submit_btn, #directorist.atbd_wrapper .ezmu__btn{ - color: <?php echo ! empty( $button_primary_color ) ? esc_attr( $button_primary_color ) : esc_attr( '#fff' ); ?> !important; - } - - /* Background */ - .pricing .price_action .price_action--btn, #directorist.atbd_wrapper .btn-primary, .default-ad-search .submit_btn .btn-default, .atbd_content_active #directorist.atbd_wrapper.dashboard_area .user_pro_img_area .user_img .choose_btn #upload_pro_pic, #directorist.atbd_wrapper .at-modal .at-modal-close, .atbdp_login_form_shortcode #loginform p input[type="submit"], .atbd_manage_fees_wrapper .table tr .action p .btn-block, #directorist.atbd_wrapper #atbdp-checkout-form #atbdp_checkout_submit_btn, #directorist.atbd_wrapper .ezmu__btn{ - background: <?php echo ! empty( $button_primary_bg_color ) ? esc_attr( $button_primary_bg_color ) : esc_attr( '#444752' ); ?> !important; - } - - /* Hover Background */ - .pricing .price_action .price_action--btn:hover, #directorist.atbd_wrapper .btn-primary:hover, #directorist.atbd_wrapper .at-modal .at-modal-close:hover, .default-ad-search .submit_btn .btn-default:hover, .atbd_content_active #directorist.atbd_wrapper.dashboard_area .user_pro_img_area .user_img .choose_btn #upload_pro_pic:hover, .atbdp_login_form_shortcode #loginform p input[type="submit"]:hover, #directorist.atbd_wrapper .ezmu__btn:hover{ - background: <?php echo ! empty( $button_primary_bg_color ) ? esc_attr( $button_primary_bg_color ) : esc_attr( '#222222' ); ?> !important; - } - - /* Border Color */ - #directorist.atbd_wrapper .btn-primary, .default-ad-search .submit_btn .btn-default, .atbdp_login_form_shortcode #loginform p input[type="submit"]{ - border-color: <?php echo ! empty( $button_primary_bg_color ) ? esc_attr( $button_primary_bg_color ) : esc_attr( '#444752' ); ?> !important; - } - - /* Hover Border Color */ - #directorist.atbd_wrapper .btn-primary:hover, .default-ad-search .submit_btn .btn-default:hover, .atbdp_login_form_shortcode #loginform p input[type="submit"]:hover{ - border-color: <?php echo ! empty( $button_primary_bg_color ) ? esc_attr( $button_primary_bg_color ) : esc_attr( '#222222' ); ?> !important; - } - - /* ======================================= - Button: Secondary - ======================================== */ - /* Color */ - #directorist.atbd_wrapper .btn-secondary { - color: <?php echo ! empty( $button_secondary_color ) ? esc_attr( $button_secondary_color ) : esc_attr( '#fff' ); ?> !important; - } - - /* Background */ - #directorist.atbd_wrapper .btn-secondary { - background: <?php echo ! empty( $button_secondary_bg_color ) ? esc_attr( $button_secondary_bg_color ) : esc_attr( '#122069' ); ?> !important; - } - - /* Hover Background */ - #directorist.atbd_wrapper .btn-secondary:hover{ - background: <?php echo ! empty( $button_secondary_bg_color ) ? esc_attr( $button_secondary_bg_color ) : esc_attr( '#131469' ); ?> !important; - } - - /* Border Color */ - #directorist.atbd_wrapper .btn-secondary { - border-color: <?php echo ! empty( $button_secondary_bg_color ) ? esc_attr( $button_secondary_bg_color ) : esc_attr( '#131469' ); ?> !important; - } - - /* Hover Border Color */ - #directorist.atbd_wrapper .btn-secondary:hover{ - border-color: <?php echo ! empty( $button_secondary_bg_color ) ? esc_attr( $button_secondary_bg_color ) : esc_attr( '#131469' ); ?> !important; - } - - - /* - Badge Colors - - Badge Open - - Badge Closed - - Badge Featured - - Badge Popular - - Badge New - */ - /* Badge Open */ - .atbd_bg-success, .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_open, .atbd_content_active .widget.atbd_widget[id^='bd'] .atbd_badge.atbd_badge_open, .atbd_content_active .widget.atbd_widget[id^='dcl'] .atbd_badge.atbd_badge_open, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbd_badge.atbd_badge_open{ - background: <?php echo ! empty( $open_back_color ) ? esc_attr( $open_back_color ) : esc_attr( '#32cc6f' ); ?> !important; - } - - /* Badge Closed */ - .atbd_bg-danger, .atbd_content_active #directorist.atbd_wrapper .atbd_give_review_area #atbd_up_preview .atbd_up_prev .rmrf:hover, .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_close, .atbd_content_active .widget.atbd_widget[id^='bd'] .atbd_badge.atbd_badge_close, .atbd_content_active .widget.atbd_widget[id^='dcl'] .atbd_badge.atbd_badge_close, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbd_badge.atbd_badge_close { - background: <?php echo ! empty( $closed_back_color ) ? esc_attr( $closed_back_color ) : esc_attr( '#e23636' ); ?> !important; - } - - /* Badge Featured */ - .directorist-badge-featured, .atbd_bg-badge-feature, .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_featured, .atbd_content_active .widget.atbd_widget[id^='bd'] .atbd_badge.atbd_badge_featured, .atbd_content_active .widget.atbd_widget[id^='dcl'] .atbd_badge.atbd_badge_featured, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbd_badge.atbd_badge_featured { - background: <?php echo ! empty( $featured_back_color ) ? esc_attr( $featured_back_color ) : esc_attr( '#fa8b0c' ); ?> !important; - } - - /* Badge Popular */ - .atbd_bg-badge-popular, .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_popular, .atbd_content_active .widget.atbd_widget[id^='bd'] .atbd_badge.atbd_badge_popular, .atbd_content_active .widget.atbd_widget[id^='dcl'] .atbd_badge.atbd_badge_popular, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbd_badge.atbd_badge_popular { - background: <?php echo ! empty( $popular_back_color ) ? esc_attr( $popular_back_color ) : esc_attr( '#f51957' ); ?> !important; - } - - /* Badge New */ - .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_new { - background: <?php echo ! empty( $new_back_color ) ? esc_attr( $new_back_color ) : esc_attr( '#2C99FF' ); ?> !important; - } - - /* - Change default primary dark background - */ - .ads-advanced .price-frequency .pf-btn input:checked + span, .btn-checkbox label input:checked + span, .atbdpr-range .ui-slider-horizontal .ui-slider-range, .custom-control .custom-control-input:checked ~ .check--select, .atbd_content_active #directorist.atbd_wrapper .atbd_listing_meta .atbd_listing_rating, .atbd_content_active #directorist.atbd_wrapper .atbd_listing_meta .atbd_listing_price, #directorist.atbd_wrapper .pagination .nav-links .current, .atbd_content_active #directorist.atbd_wrapper .atbd_contact_information_module .atbd_director_social_wrap a, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbdp-widget-categories > ul.directorist-parent-category > li:hover > a span{ - background: <?php echo ! empty( $primary_dark_back_color ) ? esc_attr( $primary_dark_back_color ) : esc_attr( '#444752' ); ?> !important; - } - - /* - Change default primary dark border - */ - .ads-advanced .price-frequency .pf-btn input:checked + span, .btn-checkbox label input:checked + span, .atbdpr-range .ui-slider-horizontal .ui-slider-handle, .custom-control .custom-control-input:checked ~ .check--select, .custom-control .custom-control-input:checked ~ .radio--select, #atpp-plan-change-modal .atm-contents-inner .dcl_pricing_plan input:checked + label:before, #dwpp-plan-renew-modal .atm-contents-inner .dcl_pricing_plan input:checked + label:before{ - border-color: <?php echo ! empty( $primary_dark_border_color ) ? esc_attr( $primary_dark_border_color ) : esc_attr( '#444752' ); ?> !important; - } - - - /* - Map Marker Icon Colors - */ - /* Marker Shape color */ - .atbd_map_shape{ - background: <?php echo ! empty( $marker_shape_color ) ? esc_attr( $marker_shape_color ) : esc_attr( '#444752' ); ?> !important; - } - .atbd_map_shape:before{ - border-top-color: <?php echo ! empty( $marker_shape_color ) ? esc_attr( $marker_shape_color ) : esc_attr( '#444752' ); ?> !important; - } - - /* Marker icon color */ - .map-icon-label i, .atbd_map_shape > span { - color: <?php echo ! empty( $marker_icon_color ) ? esc_attr( $marker_icon_color ) : esc_attr( '#ffffff' ); ?> !important; - } - <?php - - return ob_get_clean(); - } - } +if ( ! class_exists( 'ATBDP_Stylesheet' ) ) : + class ATBDP_Stylesheet { + + // add_listing_css + public static function add_listing_css() { + ob_start(); ?> + #OL_Icon_33 { + position: relative; + } + + .mapHover { + position: absolute; + background: #fff; + padding: 5px; + width: 150px; + border-radius: 3px; + border: 1px solid #ddd; + display: none; + } + + #OL_Icon_33:hover .mapHover { + display: block; + } + + /*#directorist.atbd_wrapper a { + display: block; + background: #fff; + padding: 8px 10px; + }*/ + + #directorist.atbd_wrapper a:hover { + background: #eeeeee50; + } + + #directorist.atbd_wrapper a.active { + background: #eeeeee70; + } + + .g_address_wrap ul li { + margin-bottom: 0px; + border-bottom: 1px solid #eee; + padding-bottom: 0px; + } + <?php + + return ob_get_clean(); + } + + // osm_css + public static function osm_css() { + ob_start(); + ?> + .myDivIcon { + text-align: center !important; + line-height: 20px !important; + position: relative; + } + + .myDivIcon div.atbd_map_shape { + position: absolute; + top: -38px; + left: -15px; + } + .leaflet-pane .myDivIcon div.atbd_map_shape { + position: absolute; + top: -50px; + left: 50%; + margin-left: -26px; + } + <?php + + return ob_get_clean(); + } + + // business_hour_css + public static function business_hour_css() { + ob_start(); + ?> + .atbd_badge_close, + .atbd_badge_open { + position: absolute; + left: 15px; + top: 15px; + } + <?php + + return ob_get_clean(); + } + + // style_settings_css + public static function style_settings_css() { + do_action( 'include_style_settings' ); + $button_primary_color = get_directorist_option( 'button_primary_color', '#ffffff' ); + $button_primary_bg_color = get_directorist_option( 'button_primary_bg_color', '#444752' ); + $button_secondary_color = get_directorist_option( 'button_secondary_color', '#ffffff' ); + $button_secondary_bg_color = get_directorist_option( 'button_secondary_bg_color', '#222222' ); + $open_back_color = get_directorist_option( 'open_back_color', '#32cc6f' ); + $closed_back_color = get_directorist_option( 'closed_back_color', '#e23636' ); + $featured_back_color = get_directorist_option( 'featured_back_color', '#fa8b0c' ); + $popular_back_color = get_directorist_option( 'popular_back_color', '#f51957' ); + $new_back_color = get_directorist_option( 'new_back_color', '#2C99FF' ); + $primary_dark_back_color = get_directorist_option( 'primary_dark_back_color', '#444752' ); + $primary_dark_border_color = get_directorist_option( 'primary_dark_border_color', '#444752' ); + $marker_shape_color = get_directorist_option( 'marker_shape_color', '#444752' ); + $marker_icon_color = get_directorist_option( 'marker_icon_color', '#444752' ); + + ob_start(); + ?> + /* Settings Panel Structure + + Button: Color Name + ----------------------- + - Color + + - Background + --- Background Hover + + - Border Color + --- Border Color Hover + + */ + /** + + @buttons + 1. Primary + - Color + - Hover Color + - BG Color + 3. Solid Secondary + - Color + - Hover Color + - BG Color + */ + + + /* ======================================= + Button: Primary + ======================================== */ + /* Color */ + .pricing .price_action .price_action--btn, #directorist.atbd_wrapper .btn-primary, .default-ad-search .submit_btn .btn-default, .atbd_content_active #directorist.atbd_wrapper.dashboard_area .user_pro_img_area .user_img .choose_btn #upload_pro_pic, #directorist.atbd_wrapper .at-modal .at-modal-close, .atbdp_login_form_shortcode #loginform p input[type="submit"], .atbd_manage_fees_wrapper .table tr .action p .btn-block, #directorist.atbd_wrapper #atbdp-checkout-form #atbdp_checkout_submit_btn, #directorist.atbd_wrapper .ezmu__btn{ + color: <?php echo ! empty( $button_primary_color ) ? esc_attr( $button_primary_color ) : esc_attr( '#fff' ); ?> !important; + } + + /* Background */ + .pricing .price_action .price_action--btn, #directorist.atbd_wrapper .btn-primary, .default-ad-search .submit_btn .btn-default, .atbd_content_active #directorist.atbd_wrapper.dashboard_area .user_pro_img_area .user_img .choose_btn #upload_pro_pic, #directorist.atbd_wrapper .at-modal .at-modal-close, .atbdp_login_form_shortcode #loginform p input[type="submit"], .atbd_manage_fees_wrapper .table tr .action p .btn-block, #directorist.atbd_wrapper #atbdp-checkout-form #atbdp_checkout_submit_btn, #directorist.atbd_wrapper .ezmu__btn{ + background: <?php echo ! empty( $button_primary_bg_color ) ? esc_attr( $button_primary_bg_color ) : esc_attr( '#444752' ); ?> !important; + } + + /* Hover Background */ + .pricing .price_action .price_action--btn:hover, #directorist.atbd_wrapper .btn-primary:hover, #directorist.atbd_wrapper .at-modal .at-modal-close:hover, .default-ad-search .submit_btn .btn-default:hover, .atbd_content_active #directorist.atbd_wrapper.dashboard_area .user_pro_img_area .user_img .choose_btn #upload_pro_pic:hover, .atbdp_login_form_shortcode #loginform p input[type="submit"]:hover, #directorist.atbd_wrapper .ezmu__btn:hover{ + background: <?php echo ! empty( $button_primary_bg_color ) ? esc_attr( $button_primary_bg_color ) : esc_attr( '#222222' ); ?> !important; + } + + /* Border Color */ + #directorist.atbd_wrapper .btn-primary, .default-ad-search .submit_btn .btn-default, .atbdp_login_form_shortcode #loginform p input[type="submit"]{ + border-color: <?php echo ! empty( $button_primary_bg_color ) ? esc_attr( $button_primary_bg_color ) : esc_attr( '#444752' ); ?> !important; + } + + /* Hover Border Color */ + #directorist.atbd_wrapper .btn-primary:hover, .default-ad-search .submit_btn .btn-default:hover, .atbdp_login_form_shortcode #loginform p input[type="submit"]:hover{ + border-color: <?php echo ! empty( $button_primary_bg_color ) ? esc_attr( $button_primary_bg_color ) : esc_attr( '#222222' ); ?> !important; + } + + /* ======================================= + Button: Secondary + ======================================== */ + /* Color */ + #directorist.atbd_wrapper .btn-secondary { + color: <?php echo ! empty( $button_secondary_color ) ? esc_attr( $button_secondary_color ) : esc_attr( '#fff' ); ?> !important; + } + + /* Background */ + #directorist.atbd_wrapper .btn-secondary { + background: <?php echo ! empty( $button_secondary_bg_color ) ? esc_attr( $button_secondary_bg_color ) : esc_attr( '#122069' ); ?> !important; + } + + /* Hover Background */ + #directorist.atbd_wrapper .btn-secondary:hover{ + background: <?php echo ! empty( $button_secondary_bg_color ) ? esc_attr( $button_secondary_bg_color ) : esc_attr( '#131469' ); ?> !important; + } + + /* Border Color */ + #directorist.atbd_wrapper .btn-secondary { + border-color: <?php echo ! empty( $button_secondary_bg_color ) ? esc_attr( $button_secondary_bg_color ) : esc_attr( '#131469' ); ?> !important; + } + + /* Hover Border Color */ + #directorist.atbd_wrapper .btn-secondary:hover{ + border-color: <?php echo ! empty( $button_secondary_bg_color ) ? esc_attr( $button_secondary_bg_color ) : esc_attr( '#131469' ); ?> !important; + } + + + /* + Badge Colors + - Badge Open + - Badge Closed + - Badge Featured + - Badge Popular + - Badge New + */ + /* Badge Open */ + .atbd_bg-success, .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_open, .atbd_content_active .widget.atbd_widget[id^='bd'] .atbd_badge.atbd_badge_open, .atbd_content_active .widget.atbd_widget[id^='dcl'] .atbd_badge.atbd_badge_open, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbd_badge.atbd_badge_open{ + background: <?php echo ! empty( $open_back_color ) ? esc_attr( $open_back_color ) : esc_attr( '#32cc6f' ); ?> !important; + } + + /* Badge Closed */ + .atbd_bg-danger, .atbd_content_active #directorist.atbd_wrapper .atbd_give_review_area #atbd_up_preview .atbd_up_prev .rmrf:hover, .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_close, .atbd_content_active .widget.atbd_widget[id^='bd'] .atbd_badge.atbd_badge_close, .atbd_content_active .widget.atbd_widget[id^='dcl'] .atbd_badge.atbd_badge_close, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbd_badge.atbd_badge_close { + background: <?php echo ! empty( $closed_back_color ) ? esc_attr( $closed_back_color ) : esc_attr( '#e23636' ); ?> !important; + } + + /* Badge Featured */ + .directorist-badge-featured, .atbd_bg-badge-feature, .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_featured, .atbd_content_active .widget.atbd_widget[id^='bd'] .atbd_badge.atbd_badge_featured, .atbd_content_active .widget.atbd_widget[id^='dcl'] .atbd_badge.atbd_badge_featured, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbd_badge.atbd_badge_featured { + background: <?php echo ! empty( $featured_back_color ) ? esc_attr( $featured_back_color ) : esc_attr( '#fa8b0c' ); ?> !important; + } + + /* Badge Popular */ + .atbd_bg-badge-popular, .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_popular, .atbd_content_active .widget.atbd_widget[id^='bd'] .atbd_badge.atbd_badge_popular, .atbd_content_active .widget.atbd_widget[id^='dcl'] .atbd_badge.atbd_badge_popular, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbd_badge.atbd_badge_popular { + background: <?php echo ! empty( $popular_back_color ) ? esc_attr( $popular_back_color ) : esc_attr( '#f51957' ); ?> !important; + } + + /* Badge New */ + .atbd_content_active #directorist.atbd_wrapper .atbd_badge.atbd_badge_new { + background: <?php echo ! empty( $new_back_color ) ? esc_attr( $new_back_color ) : esc_attr( '#2C99FF' ); ?> !important; + } + + /* + Change default primary dark background + */ + .ads-advanced .price-frequency .pf-btn input:checked + span, .btn-checkbox label input:checked + span, .atbdpr-range .ui-slider-horizontal .ui-slider-range, .custom-control .custom-control-input:checked ~ .check--select, .atbd_content_active #directorist.atbd_wrapper .atbd_listing_meta .atbd_listing_rating, .atbd_content_active #directorist.atbd_wrapper .atbd_listing_meta .atbd_listing_price, #directorist.atbd_wrapper .pagination .nav-links .current, .atbd_content_active #directorist.atbd_wrapper .atbd_contact_information_module .atbd_director_social_wrap a, .atbd_content_active #directorist.atbd_wrapper .widget.atbd_widget .atbdp-widget-categories > ul.directorist-parent-category > li:hover > a span{ + background: <?php echo ! empty( $primary_dark_back_color ) ? esc_attr( $primary_dark_back_color ) : esc_attr( '#444752' ); ?> !important; + } + + /* + Change default primary dark border + */ + .ads-advanced .price-frequency .pf-btn input:checked + span, .btn-checkbox label input:checked + span, .atbdpr-range .ui-slider-horizontal .ui-slider-handle, .custom-control .custom-control-input:checked ~ .check--select, .custom-control .custom-control-input:checked ~ .radio--select, #atpp-plan-change-modal .atm-contents-inner .dcl_pricing_plan input:checked + label:before, #dwpp-plan-renew-modal .atm-contents-inner .dcl_pricing_plan input:checked + label:before{ + border-color: <?php echo ! empty( $primary_dark_border_color ) ? esc_attr( $primary_dark_border_color ) : esc_attr( '#444752' ); ?> !important; + } + + + /* + Map Marker Icon Colors + */ + /* Marker Shape color */ + .atbd_map_shape{ + background: <?php echo ! empty( $marker_shape_color ) ? esc_attr( $marker_shape_color ) : esc_attr( '#444752' ); ?> !important; + } + .atbd_map_shape:before{ + border-top-color: <?php echo ! empty( $marker_shape_color ) ? esc_attr( $marker_shape_color ) : esc_attr( '#444752' ); ?> !important; + } + + /* Marker icon color */ + .map-icon-label i, .atbd_map_shape > span { + color: <?php echo ! empty( $marker_icon_color ) ? esc_attr( $marker_icon_color ) : esc_attr( '#ffffff' ); ?> !important; + } + <?php + + return ob_get_clean(); + } + } endif; \ No newline at end of file diff --git a/includes/classes/class-template-hooks.php b/includes/classes/class-template-hooks.php index 82b6fe2c56..94c8d84416 100644 --- a/includes/classes/class-template-hooks.php +++ b/includes/classes/class-template-hooks.php @@ -5,7 +5,9 @@ namespace Directorist; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Template_Hooks { @@ -14,50 +16,50 @@ class Directorist_Template_Hooks { private function __construct() { // Allow '--directorist-icon' inline style var in wp_kses_post, which is used in directorist_icon() - add_filter( 'safe_style_css', array( $this, 'add_style_attr' ) ); - add_filter( 'safecss_filter_attr_allow_css', array( $this, 'allow_style_attr' ), 10, 2 ); + add_filter( 'safe_style_css', array( $this, 'add_style_attr' ) ); + add_filter( 'safecss_filter_attr_allow_css', array( $this, 'allow_style_attr' ), 10, 2 ); // Dashboard ajax $dashboard = Directorist_Listing_Dashboard::instance(); - add_action('wp_ajax_directorist_dashboard_listing_tab', array( $dashboard, 'ajax_listing_tab' ) ); + add_action( 'wp_ajax_directorist_dashboard_listing_tab', array( $dashboard, 'ajax_listing_tab' ) ); // All Categories - add_action( 'atbdp_before_all_categories_loop', array( '\Directorist\Directorist_Listing_Taxonomy', 'archive_type' ) ); + add_action( 'atbdp_before_all_categories_loop', array( '\Directorist\Directorist_Listing_Taxonomy', 'archive_type' ) ); // All Locations - add_action( 'atbdp_before_all_locations_loop', array( '\Directorist\Directorist_Listing_Taxonomy', 'archive_type' ) ); + add_action( 'atbdp_before_all_locations_loop', array( '\Directorist\Directorist_Listing_Taxonomy', 'archive_type' ) ); // Listing Archive - @todo: remove these unused hooks - add_action( 'directorist_archive_header', array( '\Directorist\Directorist_Listings', 'archive_type' ) ); - add_action( 'directorist_archive_header', array( '\Directorist\Directorist_Listings', 'archive_header' ), 15 ); + add_action( 'directorist_archive_header', array( '\Directorist\Directorist_Listings', 'archive_type' ) ); + add_action( 'directorist_archive_header', array( '\Directorist\Directorist_Listings', 'archive_header' ), 15 ); // Listings Badges - Grid View - @todo: remove these unused hooks - add_filter( 'atbdp_grid_lower_badges', array( '\Directorist\Directorist_Listings', 'featured_badge') ); - add_filter( 'atbdp_grid_lower_badges', array( '\Directorist\Directorist_Listings', 'popular_badge'), 15 ); - add_filter( 'atbdp_grid_lower_badges', array( '\Directorist\Directorist_Listings', 'new_listing_badge'), 20 ); + add_filter( 'atbdp_grid_lower_badges', array( '\Directorist\Directorist_Listings', 'featured_badge' ) ); + add_filter( 'atbdp_grid_lower_badges', array( '\Directorist\Directorist_Listings', 'popular_badge' ), 15 ); + add_filter( 'atbdp_grid_lower_badges', array( '\Directorist\Directorist_Listings', 'new_listing_badge' ), 20 ); // Listings Badges - List View - add_filter( 'atbdp_list_lower_badges', array( '\Directorist\Directorist_Listings', 'featured_badge_list_view') ); - add_filter( 'atbdp_list_lower_badges', array( '\Directorist\Directorist_Listings', 'populer_badge_list_view'), 15 ); - add_filter( 'atbdp_list_lower_badges', array( '\Directorist\Directorist_Listings', 'new_badge_list_view'), 20 ); + add_filter( 'atbdp_list_lower_badges', array( '\Directorist\Directorist_Listings', 'featured_badge_list_view' ) ); + add_filter( 'atbdp_list_lower_badges', array( '\Directorist\Directorist_Listings', 'populer_badge_list_view' ), 15 ); + add_filter( 'atbdp_list_lower_badges', array( '\Directorist\Directorist_Listings', 'new_badge_list_view' ), 20 ); // Listings Top - List View - @todo: remove these unused hooks - add_action( 'directorist_list_view_listing_meta_end', array( '\Directorist\Directorist_Listings', 'list_view_business_hours') ); - add_action( 'directorist_list_view_top_content_end', array( '\Directorist\Directorist_Listings', 'mark_as_favourite_button'), 15 ); + add_action( 'directorist_list_view_listing_meta_end', array( '\Directorist\Directorist_Listings', 'list_view_business_hours' ) ); + add_action( 'directorist_list_view_top_content_end', array( '\Directorist\Directorist_Listings', 'mark_as_favourite_button' ), 15 ); // Listing Thumbnail Area - @todo: remove these unused hooks - add_action( 'atbdp_listing_thumbnail_area', array( '\Directorist\Directorist_Listings', 'mark_as_favourite_button'), 15 ); + add_action( 'atbdp_listing_thumbnail_area', array( '\Directorist\Directorist_Listings', 'mark_as_favourite_button' ), 15 ); // Single Listing // Set high priority to override page builders. - add_filter( 'template_include', [ $this, 'single_template_path' ], 999 ); - add_filter( 'the_content', [ $this, 'single_content' ], 20 ); + add_filter( 'template_include', array( $this, 'single_template_path' ), 999 ); + add_filter( 'the_content', array( $this, 'single_content' ), 20 ); } // instance public static function instance() { if ( null == self::$instance ) { - self::$instance = new self; + self::$instance = new self(); } return self::$instance; } @@ -69,7 +71,7 @@ public function add_style_attr( $args ) { public function allow_style_attr( $allow_css, $css_test_string ) { $parts = explode( ':', $css_test_string, 2 ); - $attr = trim( $parts[0] ); + $attr = trim( $parts[0] ); if ( $attr === '--directorist-icon' ) { return true; @@ -134,8 +136,8 @@ private static function has_block_template( $template_name ) { return false; } - $has_template = false; - $template_filename = $template_name . '.html'; + $has_template = false; + $template_filename = $template_name . '.html'; // Since Gutenberg 12.1.0, the conventions for block templates directories have changed, // we should check both these possible directories for backwards-compatibility. $possible_templates_dirs = array( 'templates', 'block-templates' ); @@ -172,6 +174,9 @@ private static function has_block_template( $template_name ) { } } -add_action( 'init', function(){ - Directorist_Template_Hooks::instance(); -} ); \ No newline at end of file +add_action( + 'init', + function () { + Directorist_Template_Hooks::instance(); + } +); diff --git a/includes/classes/class-tools.php b/includes/classes/class-tools.php index a3164797c9..f111095ce6 100644 --- a/includes/classes/class-tools.php +++ b/includes/classes/class-tools.php @@ -6,194 +6,208 @@ * @author AazzTech */ - if ( ! class_exists( 'ATBDP_Tools' ) ) : - class ATBDP_Tools - { - /** - * The current delimiter for the file being read. - * - * @var string - */ - protected $postilion = 0; - public $importable_fields = []; - private $default_directory; - - public function __construct() - { +if ( ! class_exists( 'ATBDP_Tools' ) ) : + class ATBDP_Tools { + + /** + * The current delimiter for the file being read. + * + * @var string + */ + protected $postilion = 0; + public $importable_fields = array(); + private $default_directory; + + public function __construct() { // Prevent frontend executions. if ( ! is_admin() ) { return; } - add_action('admin_menu', array($this, 'add_tools_submenu'), 10); - add_action('admin_init', array($this, 'atbdp_csv_import_controller')); - add_action( 'init', [$this, 'prepare_data'] ); - add_action('wp_ajax_atbdp_import_listing', array($this, 'atbdp_import_listing')); - add_action('wp_ajax_directorist_listing_type_form_fields', array($this, 'directorist_listing_type_form_fields')); - } + add_action( 'admin_menu', array( $this, 'add_tools_submenu' ), 10 ); + add_action( 'admin_init', array( $this, 'atbdp_csv_import_controller' ) ); + add_action( 'init', array( $this, 'prepare_data' ) ); + add_action( 'wp_ajax_atbdp_import_listing', array( $this, 'atbdp_import_listing' ) ); + add_action( 'wp_ajax_directorist_listing_type_form_fields', array( $this, 'directorist_listing_type_form_fields' ) ); + } - public function directorist_listing_type_form_fields() { + public function directorist_listing_type_form_fields() { - if ( ! directorist_verify_nonce() ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), - ) ); - } + if ( ! directorist_verify_nonce() ) { + wp_send_json( + array( + 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), + ) + ); + } - $term_id = ! empty( $_POST['directory_type'] ) ? sanitize_text_field( wp_unslash( $_POST['directory_type'] ) ) : ''; - $file = ! empty( $_POST['file_id'] ) ? get_attached_file( directorist_clean( wp_unslash( $_POST['file_id'] ) ) ) : ''; + $term_id = ! empty( $_POST['directory_type'] ) ? sanitize_text_field( wp_unslash( $_POST['directory_type'] ) ) : ''; + $file = ! empty( $_POST['file_id'] ) ? get_attached_file( directorist_clean( wp_unslash( $_POST['file_id'] ) ) ) : ''; - if( ! $file ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid file!', 'directorist' ), - ) ); - } + if ( ! $file ) { + wp_send_json( + array( + 'error' => esc_html__( 'Invalid file!', 'directorist' ), + ) + ); + } - $delimiter = ! empty( $_POST['delimiter'] ) ? directorist_clean( wp_unslash( $_POST['delimiter'] ) ) : ''; - $this->importable_fields = []; - $this->setup_fields( $term_id ); + $delimiter = ! empty( $_POST['delimiter'] ) ? directorist_clean( wp_unslash( $_POST['delimiter'] ) ) : ''; + $this->importable_fields = array(); + $this->setup_fields( $term_id ); - ob_start(); + ob_start(); - ATBDP()->load_template( 'admin-templates/import-export/data-table', array( 'data' => csv_get_data( $file, false, $delimiter ), 'fields' => $this->get_importable_fields(), 'csv_file' => $file ) ); + ATBDP()->load_template( + 'admin-templates/import-export/data-table', + array( + 'data' => csv_get_data( $file, false, $delimiter ), + 'fields' => $this->get_importable_fields(), + 'csv_file' => $file, + ) + ); - $response = ob_get_clean(); + $response = ob_get_clean(); - wp_send_json( $response ); - } + wp_send_json( $response ); + } - public function atbdp_import_listing() { + public function atbdp_import_listing() { if ( ! current_user_can( 'import' ) ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid request!', 'directorist' ), - ) ); + wp_send_json( + array( + 'error' => esc_html__( 'Invalid request!', 'directorist' ), + ) + ); } - if ( ! directorist_verify_nonce() ) { - wp_send_json( array( - 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), - ) ); - } - - $data = array(); - $preview_image = isset( $_POST['listing_img'] ) ? directorist_clean( wp_unslash( $_POST['listing_img'] ) ) : ''; - $default_directory = directorist_default_directory(); - $directory_type = isset( $_POST['directory_type'] ) ? absint( $_POST['directory_type'] ) : 0; - $directory_type = ( empty( $directory_type ) ) ? $default_directory : $directory_type; - $title = isset( $_POST['listing_title'] ) ? directorist_clean( wp_unslash( $_POST['listing_title'] ) ) : ''; - $new_listing_status = get_term_meta( $directory_type, 'new_listing_status', 'pending'); - $supported_post_status = array_keys( get_post_statuses() ); - $listing_status = isset( $_POST['listing_status'] ) ? directorist_clean( wp_unslash( $_POST['listing_status'] ) ) : ''; - $delimiter = isset( $_POST['delimiter'] ) ? directorist_clean( wp_unslash( $_POST['delimiter'] ) ) : ''; - $description = isset( $_POST['listing_content'] ) ? directorist_clean( wp_unslash( $_POST['listing_content'] ) ) : ''; - $position = isset( $_POST['position'] ) ? directorist_clean( wp_unslash( $_POST['position'] ) ) : 0; - $position = ( is_numeric( $position ) ) ? ( int ) $position : 0; - $metas = isset( $_POST['meta'] ) ? directorist_clean( wp_unslash( $_POST['meta'] ) ) : array(); - $tax_inputs = isset( $_POST['tax_input'] ) ? directorist_clean( wp_unslash( $_POST['tax_input'] ) ) : array(); - $limit = apply_filters( 'atbdp_listing_import_limit_per_cycle', 10 ); - $all_posts = isset( $_POST['csv_file'] ) ? csv_get_data( directorist_clean( wp_unslash( $_POST['csv_file'] ) ), true, $delimiter ) : []; - $total_length = ( isset( $_POST['total_post'] ) && is_numeric( $_POST['total_post'] ) ) ? directorist_clean( wp_unslash( $_POST['total_post'] ) ) : count( $all_posts ); - $limit = apply_filters('atbdp_listing_import_limit_per_cycle', ( $total_length > 100 ) ? 20 : ( ( $total_length < 35 ) ? 2 : 5 ) ); - $posts = ( ! empty( $all_posts ) ) ? array_slice( $all_posts, $position ) : []; - $posts = apply_filters( 'directorist_listings_importing_posts', $posts, $position, $limit, $_POST ); + if ( ! directorist_verify_nonce() ) { + wp_send_json( + array( + 'error' => esc_html__( 'Invalid nonce!', 'directorist' ), + ) + ); + } + + $data = array(); + $preview_image = isset( $_POST['listing_img'] ) ? directorist_clean( wp_unslash( $_POST['listing_img'] ) ) : ''; + $default_directory = directorist_default_directory(); + $directory_type = isset( $_POST['directory_type'] ) ? absint( $_POST['directory_type'] ) : 0; + $directory_type = ( empty( $directory_type ) ) ? $default_directory : $directory_type; + $title = isset( $_POST['listing_title'] ) ? directorist_clean( wp_unslash( $_POST['listing_title'] ) ) : ''; + $new_listing_status = get_term_meta( $directory_type, 'new_listing_status', 'pending' ); + $supported_post_status = array_keys( get_post_statuses() ); + $listing_status = isset( $_POST['listing_status'] ) ? directorist_clean( wp_unslash( $_POST['listing_status'] ) ) : ''; + $delimiter = isset( $_POST['delimiter'] ) ? directorist_clean( wp_unslash( $_POST['delimiter'] ) ) : ''; + $description = isset( $_POST['listing_content'] ) ? directorist_clean( wp_unslash( $_POST['listing_content'] ) ) : ''; + $position = isset( $_POST['position'] ) ? directorist_clean( wp_unslash( $_POST['position'] ) ) : 0; + $position = ( is_numeric( $position ) ) ? (int) $position : 0; + $metas = isset( $_POST['meta'] ) ? directorist_clean( wp_unslash( $_POST['meta'] ) ) : array(); + $tax_inputs = isset( $_POST['tax_input'] ) ? directorist_clean( wp_unslash( $_POST['tax_input'] ) ) : array(); + $limit = apply_filters( 'atbdp_listing_import_limit_per_cycle', 10 ); + $all_posts = isset( $_POST['csv_file'] ) ? csv_get_data( directorist_clean( wp_unslash( $_POST['csv_file'] ) ), true, $delimiter ) : array(); + $total_length = ( isset( $_POST['total_post'] ) && is_numeric( $_POST['total_post'] ) ) ? directorist_clean( wp_unslash( $_POST['total_post'] ) ) : count( $all_posts ); + $limit = apply_filters( 'atbdp_listing_import_limit_per_cycle', ( $total_length > 100 ) ? 20 : ( ( $total_length < 35 ) ? 2 : 5 ) ); + $posts = ( ! empty( $all_posts ) ) ? array_slice( $all_posts, $position ) : array(); + $posts = apply_filters( 'directorist_listings_importing_posts', $posts, $position, $limit, $_POST ); $publish_date = isset( $metas['publish_date'] ) ? directorist_clean( $metas['publish_date'] ) : ''; - if ( empty( $total_length ) ) { - $data['error'] = __('No data found', 'directorist'); - $data['_POST'] = directorist_clean( $_POST ); - $data['file'] = directorist_clean( wp_unslash( $_POST['csv_file'] ) ); - $data['all_posts'] = $all_posts; - - wp_send_json( $data ); - } - - // Counters - $imported = 0; - $failed = 0; - $count = 0; - - foreach ( $posts as $index => $post ) { - - if ( $count === $limit ) { - break; - } - - /** - * Filters whether the listing import process should start. - * - * This filter allows modifying the decision to start/skip the listing import process. - * - * @since 8.0 - * - * @param bool $should_start Indicates whether the import process should start. Default is true. - * @param array $post The current post data being imported. - */ - if( ! apply_filters( 'directorist_import_listing_starts', true, $post ) ){ - $failed++; - $count++; - continue; - } - - // start importing listings - $post_status = ( isset( $post[ $listing_status ] ) ) ? $post[ $listing_status ] : ''; - $post_status = ( in_array( $post_status, $supported_post_status, true ) ) ? $post_status : $new_listing_status; - - $args = array( - 'post_title' => isset( $post[ $title ] ) ? self::unescape_data( html_entity_decode( $post[ $title ] ) ) : '', - 'post_content' => isset( $post[ $description ] ) ? self::unescape_data( html_entity_decode( $post[ $description ] ) ) : '', - 'post_type' => ATBDP_POST_TYPE, - 'post_status' => $post_status, - ); - - // Post Date - $post_date = ! empty( $post[ $publish_date ] ) ? directorist_clean( $post[ $publish_date ] ) : ''; - $post_date = apply_filters( 'directorist_importing_listings_post_date', $post_date, $post, $args, $index ); + if ( empty( $total_length ) ) { + $data['error'] = __( 'No data found', 'directorist' ); + $data['_POST'] = directorist_clean( $_POST ); + $data['file'] = directorist_clean( wp_unslash( $_POST['csv_file'] ) ); + $data['all_posts'] = $all_posts; + + wp_send_json( $data ); + } + + // Counters + $imported = 0; + $failed = 0; + $count = 0; + + foreach ( $posts as $index => $post ) { + + if ( $count === $limit ) { + break; + } + + /** + * Filters whether the listing import process should start. + * + * This filter allows modifying the decision to start/skip the listing import process. + * + * @since 8.0 + * + * @param bool $should_start Indicates whether the import process should start. Default is true. + * @param array $post The current post data being imported. + */ + if ( ! apply_filters( 'directorist_import_listing_starts', true, $post ) ) { + ++$failed; + ++$count; + continue; + } + + // start importing listings + $post_status = ( isset( $post[ $listing_status ] ) ) ? $post[ $listing_status ] : ''; + $post_status = ( in_array( $post_status, $supported_post_status, true ) ) ? $post_status : $new_listing_status; + + $args = array( + 'post_title' => isset( $post[ $title ] ) ? self::unescape_data( html_entity_decode( $post[ $title ] ) ) : '', + 'post_content' => isset( $post[ $description ] ) ? self::unescape_data( html_entity_decode( $post[ $description ] ) ) : '', + 'post_type' => ATBDP_POST_TYPE, + 'post_status' => $post_status, + ); + + // Post Date + $post_date = ! empty( $post[ $publish_date ] ) ? directorist_clean( $post[ $publish_date ] ) : ''; + $post_date = apply_filters( 'directorist_importing_listings_post_date', $post_date, $post, $args, $index ); $post_date = strtotime( $post_date ); if ( $post_date ) { $args['post_date'] = date( 'Y-m-d H:i:s', $post_date ); } - $listing_id = ! empty( $post['id'] ) ? absint( $post['id'] ) : 0; + $listing_id = ! empty( $post['id'] ) ? absint( $post['id'] ) : 0; if ( get_post( $listing_id ) && get_post_type( $listing_id ) === ATBDP_POST_TYPE ) { $args['ID'] = $listing_id; - $post_id = wp_update_post( $args ); + $post_id = wp_update_post( $args ); } else { $post_id = wp_insert_post( $args ); } - if ( is_wp_error( $post_id ) ) { - $failed++; - continue; - } + if ( is_wp_error( $post_id ) ) { + ++$failed; + continue; + } - $imported++; + ++$imported; - if ( $tax_inputs ) { - foreach ( $tax_inputs as $taxonomy => $value ) { + if ( $tax_inputs ) { + foreach ( $tax_inputs as $taxonomy => $value ) { - if( ! $value ) { - continue; - } + if ( ! $value ) { + continue; + } - $terms = isset( $post[ $value ] ) && ! empty( $post[ $value ] ) ? explode( ',', $post[ $value ] ) : array(); - if( ! $terms ) { - continue; - } + $terms = isset( $post[ $value ] ) && ! empty( $post[ $value ] ) ? explode( ',', $post[ $value ] ) : array(); + if ( ! $terms ) { + continue; + } - if ( 'category' === $taxonomy ) { - $taxonomy = ATBDP_CATEGORY; - } elseif ( 'location' === $taxonomy ) { - $taxonomy = ATBDP_LOCATION; - } else { - $taxonomy = ATBDP_TAGS; - } + if ( 'category' === $taxonomy ) { + $taxonomy = ATBDP_CATEGORY; + } elseif ( 'location' === $taxonomy ) { + $taxonomy = ATBDP_LOCATION; + } else { + $taxonomy = ATBDP_TAGS; + } - $term_ids = array(); - $multiple = $terms > 0; + $term_ids = array(); + $multiple = $terms > 0; - foreach ( $terms as $term ) { + foreach ( $terms as $term ) { $term_id = $this->get_or_create_term_id( $term, $taxonomy ); if ( empty( $term_id ) ) { @@ -204,77 +218,77 @@ public function atbdp_import_listing() { directorist_update_term_directory( $term_id, array( $directory_type ), true ); } - $term_ids[] = $term_id; - } + $term_ids[] = $term_id; + } - wp_set_object_terms( $post_id, $term_ids, $taxonomy, $multiple ); - } - } + wp_set_object_terms( $post_id, $term_ids, $taxonomy, $multiple ); + } + } - foreach ( $metas as $index => $value ) { - $meta_value = $post[ $value ] ? self::unescape_data( $post[ $value ] ) : ''; - $meta_value = $this->maybe_unserialize_csv_string( $meta_value ); + foreach ( $metas as $index => $value ) { + $meta_value = $post[ $value ] ? self::unescape_data( $post[ $value ] ) : ''; + $meta_value = $this->maybe_unserialize_csv_string( $meta_value ); - if ( $meta_value ) { - update_post_meta( $post_id, '_' . $index, $meta_value ); - } - } + if ( $meta_value ) { + update_post_meta( $post_id, '_' . $index, $meta_value ); + } + } - $exp_dt = calc_listing_expiry_date( '', '', $directory_type ); - update_post_meta( $post_id, '_expiry_date', $exp_dt ); - update_post_meta( $post_id, '_featured', 0 ); + $exp_dt = calc_listing_expiry_date( '', '', $directory_type ); + update_post_meta( $post_id, '_expiry_date', $exp_dt ); + update_post_meta( $post_id, '_featured', 0 ); // TODO: Status has been migrated, remove related code. - update_post_meta( $post_id, '_listing_status', 'post_status' ); - - if ( ! empty( $post['directory_type'] ) ) { - $directory_type_slug = $post['directory_type']; - $directory_type_term = get_term_by( 'slug', $directory_type_slug, ATBDP_DIRECTORY_TYPE ); - $directory_type = ( ! empty( $directory_type_term ) ) ? $directory_type_term->term_id : $directory_type; - } - - update_post_meta( $post_id, '_directory_type', $directory_type ); - wp_set_object_terms( $post_id, ( int ) $directory_type, ATBDP_DIRECTORY_TYPE ); - - $preview_url = isset($post[$preview_image]) ? $post[$preview_image] : ''; - $preview_url = ( ! empty( $preview_url ) ) ? explode( ',', $preview_url ) : ''; - - if ( ! empty( $preview_url ) ) { - $attachment_ids = []; - foreach ( $preview_url as $_url_index => $_url ) { - $_url = trim( $_url ); - $attachment_id = self::atbdp_insert_attachment_from_url($_url, $post_id); - if ( $_url_index == 0 ) { - update_post_meta($post_id, '_listing_prv_img', $attachment_id); - } else { - $attachment_ids[] = $attachment_id; - } - } - update_post_meta($post_id, '_listing_img', $attachment_ids ); - } - - /** - * Fire this event once a listing is successfully imported from CSV. - * - * @since 7.2.0 - * - * @param int $post_id Listing id. - * @param array $post Listing data. - */ - do_action( 'directorist_listing_imported', $post_id, $post ); - - $count++; - } - - $data['next_position'] = ( int ) $position + ( int ) $count; - $data['percentage'] = absint( min( round( ( ( $data['next_position'] ) / $total_length ) * 100 ), 100 ) ); - $data['url'] = esc_url( admin_url( 'edit.php?post_type=at_biz_dir&page=tools&step=3' ) ); - $data['total'] = $total_length; - $data['imported'] = $imported; - $data['failed'] = $failed; - - wp_send_json( $data ); - } + update_post_meta( $post_id, '_listing_status', 'post_status' ); + + if ( ! empty( $post['directory_type'] ) ) { + $directory_type_slug = $post['directory_type']; + $directory_type_term = get_term_by( 'slug', $directory_type_slug, ATBDP_DIRECTORY_TYPE ); + $directory_type = ( ! empty( $directory_type_term ) ) ? $directory_type_term->term_id : $directory_type; + } + + update_post_meta( $post_id, '_directory_type', $directory_type ); + wp_set_object_terms( $post_id, (int) $directory_type, ATBDP_DIRECTORY_TYPE ); + + $preview_url = isset( $post[ $preview_image ] ) ? $post[ $preview_image ] : ''; + $preview_url = ( ! empty( $preview_url ) ) ? explode( ',', $preview_url ) : ''; + + if ( ! empty( $preview_url ) ) { + $attachment_ids = array(); + foreach ( $preview_url as $_url_index => $_url ) { + $_url = trim( $_url ); + $attachment_id = self::atbdp_insert_attachment_from_url( $_url, $post_id ); + if ( $_url_index == 0 ) { + update_post_meta( $post_id, '_listing_prv_img', $attachment_id ); + } else { + $attachment_ids[] = $attachment_id; + } + } + update_post_meta( $post_id, '_listing_img', $attachment_ids ); + } + + /** + * Fire this event once a listing is successfully imported from CSV. + * + * @since 7.2.0 + * + * @param int $post_id Listing id. + * @param array $post Listing data. + */ + do_action( 'directorist_listing_imported', $post_id, $post ); + + ++$count; + } + + $data['next_position'] = (int) $position + (int) $count; + $data['percentage'] = absint( min( round( ( ( $data['next_position'] ) / $total_length ) * 100 ), 100 ) ); + $data['url'] = esc_url( admin_url( 'edit.php?post_type=at_biz_dir&page=tools&step=3' ) ); + $data['total'] = $total_length; + $data['imported'] = $imported; + $data['failed'] = $failed; + + wp_send_json( $data ); + } /** * @param string $term @@ -297,115 +311,119 @@ public function get_or_create_term_id( $term, $taxonomy ) { return null; } - // maybe_unserialize_csv_string - public function maybe_unserialize_csv_string( $data ) { - if ( ! is_string( $data ) ) { + // maybe_unserialize_csv_string + public function maybe_unserialize_csv_string( $data ) { + if ( ! is_string( $data ) ) { return $data; } - $_data = str_replace( "'", '"', $data ); - $_data = maybe_unserialize( maybe_unserialize( $_data ) ); + $_data = str_replace( "'", '"', $data ); + $_data = maybe_unserialize( maybe_unserialize( $_data ) ); - if ( ! empty( $_data ) ) { - return $_data; - } - - return $data; - } - - public static function atbdp_legacy_insert_attachment_from_url( $file_url, $post_id ) { + if ( ! empty( $_data ) ) { + return $_data; + } - if (!filter_var($file_url, FILTER_VALIDATE_URL)) { - return false; - } - $contents = @file_get_contents($file_url); + return $data; + } - if ($contents === false) { - return false; - } + public static function atbdp_legacy_insert_attachment_from_url( $file_url, $post_id ) { - if( ! wp_check_filetype( $file_url )['ext'] ) { + if ( ! filter_var( $file_url, FILTER_VALIDATE_URL ) ) { + return false; + } + $contents = @file_get_contents( $file_url ); - $headers = array( - 'Accept' => 'application/json', - ); + if ( $contents === false ) { + return false; + } - $config = array( - 'method' => 'GET', - 'timeout' => 30, - 'redirection' => 5, - 'httpversion' => '1.0', - 'headers' => $headers, - 'cookies' => array(), - ); + if ( ! wp_check_filetype( $file_url )['ext'] ) { - $upload = array(); + $headers = array( + 'Accept' => 'application/json', + ); - try { - $response = wp_remote_get( $file_url, $config ); + $config = array( + 'method' => 'GET', + 'timeout' => 30, + 'redirection' => 5, + 'httpversion' => '1.0', + 'headers' => $headers, + 'cookies' => array(), + ); - if ( ! is_wp_error( $response ) ) { - $type = wp_remote_retrieve_header( $response, 'content-type' ); - $extension = preg_replace("/\w+\//", '', $type ); - $upload = wp_upload_bits(basename( $file_url . '.'. $extension ), '', wp_remote_retrieve_body($response)); + $upload = array(); - } - } catch ( Exception $e ) { + try { + $response = wp_remote_get( $file_url, $config ); - } - }else{ - $upload = wp_upload_bits(basename($file_url), null, $contents); - } + if ( ! is_wp_error( $response ) ) { + $type = wp_remote_retrieve_header( $response, 'content-type' ); + $extension = preg_replace( '/\w+\//', '', $type ); + $upload = wp_upload_bits( basename( $file_url . '.' . $extension ), '', wp_remote_retrieve_body( $response ) ); - if (isset($upload['error']) && $upload['error']) { - return false; - } + } + } catch ( Exception $e ) { - $type = ''; - if (!empty($upload['type'])) { - $type = $upload['type']; - } else { - $mime = wp_check_filetype($upload['file']); - if ($mime) { - $type = $mime['type']; - } - } - $attachment = array( 'post_title' => basename($upload['file']), 'post_content' => '', 'post_type' => 'attachment', 'post_mime_type' => $type, 'guid' => $upload['url'] ); - $id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata($id, $upload['file']) ); - return $id; + } + } else { + $upload = wp_upload_bits( basename( $file_url ), null, $contents ); + } - } + if ( isset( $upload['error'] ) && $upload['error'] ) { + return false; + } + $type = ''; + if ( ! empty( $upload['type'] ) ) { + $type = $upload['type']; + } else { + $mime = wp_check_filetype( $upload['file'] ); + if ( $mime ) { + $type = $mime['type']; + } + } + $attachment = array( + 'post_title' => basename( $upload['file'] ), + 'post_content' => '', + 'post_type' => 'attachment', + 'post_mime_type' => $type, + 'guid' => $upload['url'], + ); + $id = wp_insert_attachment( $attachment, $upload['file'], $post_id ); + wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); + return $id; + } - public static function atbdp_updated_insert_attachment_from_url( $image_url, $post_id ) { - if (!filter_var($image_url, FILTER_VALIDATE_URL)) { - return false; - } + public static function atbdp_updated_insert_attachment_from_url( $image_url, $post_id ) { - $upload = directorist_rest_upload_image_from_url( esc_url_raw( $image_url ) ); + if ( ! filter_var( $image_url, FILTER_VALIDATE_URL ) ) { + return false; + } - if ( is_wp_error( $upload ) ) { - return $upload; - } + $upload = directorist_rest_upload_image_from_url( esc_url_raw( $image_url ) ); - $image_id = directorist_rest_set_uploaded_image_as_attachment( $upload, $post_id ); + if ( is_wp_error( $upload ) ) { + return $upload; + } - return $image_id; + $image_id = directorist_rest_set_uploaded_image_as_attachment( $upload, $post_id ); - } + return $image_id; + } - public static function atbdp_insert_attachment_from_url( $image_url, $post_id ) { + public static function atbdp_insert_attachment_from_url( $image_url, $post_id ) { - $legacy = apply_filters( 'directorist_legacy_attachment_importer', false, $image_url, $post_id ); + $legacy = apply_filters( 'directorist_legacy_attachment_importer', false, $image_url, $post_id ); - if( ! $legacy ) { - return self::atbdp_updated_insert_attachment_from_url( $image_url, $post_id ); - } + if ( ! $legacy ) { + return self::atbdp_updated_insert_attachment_from_url( $image_url, $post_id ); + } - return self::atbdp_legacy_insert_attachment_from_url( $image_url, $post_id ); - } + return self::atbdp_legacy_insert_attachment_from_url( $image_url, $post_id ); + } public static function on_wp_handle_upload_prefilter( $file ) { $allowed_mimes = array( @@ -415,23 +433,23 @@ public static function on_wp_handle_upload_prefilter( $file ) { if ( empty( $file['size'] ) || empty( $file['type'] ) ) { $file['error'] = __( 'Please select a valid CSV or TXT file.', 'directorist' ); - } else if ( ! in_array( $file['type'], $allowed_mimes, true ) ) { + } elseif ( ! in_array( $file['type'], $allowed_mimes, true ) ) { $file['error'] = __( 'Sorry, only CSV and TXT files are allowed.', 'directorist' ); } return $file; } - public function atbdp_csv_import_controller() { - if ( ! isset( $_POST[ 'atbdp_save_csv_step' ] ) ) { - return; - } + public function atbdp_csv_import_controller() { + if ( ! isset( $_POST['atbdp_save_csv_step'] ) ) { + return; + } - check_admin_referer( 'directorist-csv-importer' ); + check_admin_referer( 'directorist-csv-importer' ); add_filter( 'wp_handle_upload_prefilter', array( __CLASS__, 'on_wp_handle_upload_prefilter' ) ); - $file = wp_import_handle_upload(); + $file = wp_import_handle_upload(); remove_filter( 'wp_handle_upload_prefilter', array( __CLASS__, 'on_wp_handle_upload_prefilter' ) ); @@ -441,73 +459,80 @@ public function atbdp_csv_import_controller() { 'Directorist CSV Import Error!', array( 'back_link' => true, - ) ); + ) + ); + } + + $base_url = admin_url( 'edit.php' ); + $params = apply_filters( + 'directorist_listings_import_form_submit_redirect_params', + array( + 'post_type' => ATBDP_POST_TYPE, + 'page' => 'tools', + 'file_id' => $file['id'], + 'delimiter' => isset( $_REQUEST['delimiter'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delimiter'] ) ) : ',', + 'update_existing' => isset( $_REQUEST['update_existing'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['update_existing'] ) ) : false, + 'step' => 2, + ) + ); + + $url = add_query_arg( $params, $base_url ); + $url = apply_filters( 'directorist_listings_import_form_submit_redirect_url', $url, $base_url, $params ); + + // redirect to step two || data mapping + wp_safe_redirect( $url ); + } + + + public function prepare_data() { + $this->default_directory = default_directory_type(); + $this->setup_fields(); + } + + + public function setup_fields( $directory = '' ) { + $directory = $directory ? $directory : $this->default_directory; + $fields = directorist_get_form_fields_by_directory_type( 'id', $directory ); + + $this->importable_fields['publish_date'] = esc_html__( 'Publish Date', 'directorist' ); + $this->importable_fields['listing_status'] = esc_html__( 'Listing Status', 'directorist' ); + + if ( empty( $fields ) || ! is_array( $fields ) ) { + return; } - $base_url = admin_url( 'edit.php' ); - $params = apply_filters( 'directorist_listings_import_form_submit_redirect_params', [ - 'post_type' => ATBDP_POST_TYPE, - 'page' => 'tools', - 'file_id' => $file['id'], - 'delimiter' => isset( $_REQUEST['delimiter'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['delimiter'] ) ) : ',', - 'update_existing' => isset( $_REQUEST['update_existing'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['update_existing'] ) ) : false, - 'step' => 2, - ] ); - - $url = add_query_arg( $params, $base_url ); - $url = apply_filters( 'directorist_listings_import_form_submit_redirect_url', $url, $base_url, $params ); - - // redirect to step two || data mapping - wp_safe_redirect( $url ); - } - - - public function prepare_data(){ - $this->default_directory = default_directory_type(); - $this->setup_fields(); - } - - - public function setup_fields( $directory = '' ) { - $directory = $directory ? $directory : $this->default_directory; - $fields = directorist_get_form_fields_by_directory_type( 'id', $directory ); - - $this->importable_fields[ 'publish_date' ] = esc_html__( 'Publish Date', 'directorist' ); - $this->importable_fields[ 'listing_status' ] = esc_html__( 'Listing Status', 'directorist' ); - - if ( empty( $fields ) || ! is_array( $fields ) ) { - return; - } - - foreach( $fields as $field ) { - $field_key = !empty( $field['field_key'] ) ? $field['field_key'] : ''; - $label = !empty( $field['label'] ) ? $field['label'] : ''; - if( 'tax_input[at_biz_dir-location][]' == $field_key ) { $field_key = 'location'; } - if( 'admin_category_select[]' == $field_key ) { $field_key = 'category'; } - if( 'tax_input[at_biz_dir-tags][]' == $field_key ) { $field_key = 'tag'; } - - if ( isset( $field['widget_name'] ) ) { - if( 'pricing' == $field['widget_name'] ) { - $this->importable_fields[ 'price' ] = esc_html__( 'Price', 'directorist' ); - $this->importable_fields[ 'price_range' ] = esc_html__( 'Price Range', 'directorist' ); - continue; - } - if( 'map' == $field['widget_name'] ) { - $this->importable_fields[ 'manual_lat' ] = esc_html__( 'Map Latitude', 'directorist' ); - $this->importable_fields[ 'manual_lng' ] = esc_html__( 'Map Longitude', 'directorist' ); - $this->importable_fields[ 'hide_map' ] = esc_html__( 'Hide Map', 'directorist' ); - continue; - } - } - - $this->importable_fields[ $field_key ] = $label; - } - } - - /** - * It adds a submenu for showing all the Tools and details support - */ - public function add_tools_submenu() { + foreach ( $fields as $field ) { + $field_key = ! empty( $field['field_key'] ) ? $field['field_key'] : ''; + $label = ! empty( $field['label'] ) ? $field['label'] : ''; + if ( 'tax_input[at_biz_dir-location][]' == $field_key ) { + $field_key = 'location'; } + if ( 'admin_category_select[]' == $field_key ) { + $field_key = 'category'; } + if ( 'tax_input[at_biz_dir-tags][]' == $field_key ) { + $field_key = 'tag'; } + + if ( isset( $field['widget_name'] ) ) { + if ( 'pricing' == $field['widget_name'] ) { + $this->importable_fields['price'] = esc_html__( 'Price', 'directorist' ); + $this->importable_fields['price_range'] = esc_html__( 'Price Range', 'directorist' ); + continue; + } + if ( 'map' == $field['widget_name'] ) { + $this->importable_fields['manual_lat'] = esc_html__( 'Map Latitude', 'directorist' ); + $this->importable_fields['manual_lng'] = esc_html__( 'Map Longitude', 'directorist' ); + $this->importable_fields['hide_map'] = esc_html__( 'Hide Map', 'directorist' ); + continue; + } + } + + $this->importable_fields[ $field_key ] = $label; + } + } + + /** + * It adds a submenu for showing all the Tools and details support + */ + public function add_tools_submenu() { add_submenu_page( 'edit.php?post_type=at_biz_dir', __( 'Tools', 'directorist' ), @@ -519,124 +544,120 @@ public function add_tools_submenu() { // Remove to remove the menu item. remove_submenu_page( 'edit.php?post_type=at_biz_dir', 'tools' ); - } - - public function get_data_table( $file_path, $delimiter = ',' ){ - $csv_data = csv_get_data( $file_path, false, $delimiter ); - $data = [ - 'data' => $csv_data, - 'csv_file' => $file_path, - 'fields' => $this->get_importable_fields(), - ]; - - ATBDP()->load_template('admin-templates/import-export/data-table', $data ); - } - - public function render_tools_submenu_page() { - - ATBDP()->load_template( 'admin-templates/import-export/import-export', [ 'controller' => $this ] ); - - } - - /** - * Importer Header Template - * - * @param bool $return - * @return string $template - */ - public function importer_header_template( $return = false ) { - $template_data = []; - - $template_data['controller'] = $this; - $template_data['download_link'] = esc_url( ATBDP_URL .'views/admin-templates/import-export/data/dummy.csv' ); - $template_data['nav_menu'] = $this->get_header_nav_menu(); - - $template_path = 'admin-templates/import-export/header-templates/header'; - ATBDP()->load_template( $template_path, $template_data ); - - } - - /** - * Importer header nav menu item template - * - * @param bool $return - * @return string $template - */ - public function importer_header_nav_menu_item_template( $template_data = [], $return = false ) { - - $template_data['controller'] = $this; - ATBDP()->load_template( 'admin-templates/import-export/header-templates/nav-item', $template_data ); - - } - - /** - * Get Header Nav Menu - * - * @return array - */ - public function get_header_nav_menu() { - $step = isset( $_GET['step'] ) ? sanitize_key( wp_unslash( $_GET['step'] ) ) : ''; - $nav_menu = []; - - // Item - 1 - $nav_item = []; - $nav_item['nav_item_class'] = ! $step ? esc_attr('active') : ( $step > 1 ? esc_attr('done') : ''); - $nav_item['label'] = esc_html__('Upload CSV File', 'directorist'); - $nav_menu[] = $nav_item; - - // Item - 2 - $nav_item = []; - $class = ( '2' == $step ) ? esc_attr('active') : ( $step > 2 ? esc_attr('done') : '' ); - $class = 'atbdp-mapping-step ' . $class; - $nav_item['nav_item_class'] = trim( $class ); - $nav_item['label'] = esc_html__('Column Mapping', 'directorist'); - $nav_menu[] = $nav_item; - - // Item - 3 - $nav_item = []; - $class = ( $step == 3 ) ? esc_attr('done') : ''; - $class = 'atbdp-progress-step ' . $class; - $nav_item['nav_item_class'] = trim( $class ); - $nav_item['label'] = esc_html__('Import', 'directorist'); - $nav_menu[] = $nav_item; - - // Item - 4 - $nav_item = []; - $nav_item['nav_item_class'] = ( '3' == $step ) ? esc_attr('active done') : ''; - $nav_item['label'] = esc_html__('Done', 'directorist'); - $nav_menu[] = $nav_item; - - $nav_menu = apply_filters( 'directorist_listings_importer_header_nav_menu', $nav_menu, $step ); - - return $nav_menu; - } - - /** - * Importer Body Template - * - * @param bool $return - * @return string $template - */ - public function importer_body_template( $return = false ) { - $step = ( isset( $_REQUEST['step'] ) ) ? directorist_clean( wp_unslash( $_REQUEST['step'] ) ) : 1; - $step = ( ! empty( $step ) && is_numeric( $step ) ) ? ( int ) $step : 1; - $template_base_path = 'admin-templates/import-export/body-templates'; - $template_paths = [ - 1 => "{$template_base_path}/step-one", - 2 => "{$template_base_path}/step-two", - 3 => "{$template_base_path}/step-done", - ]; - - $template_path = ( isset( $template_paths[ $step ] ) ) ? $template_paths[ $step ] : $template_paths[ 1 ]; - - $template_data = [ - 'controller' => $this, - 'step' => $step, - ]; - - ATBDP()->load_template( $template_path, $template_data ); - - } + } + + public function get_data_table( $file_path, $delimiter = ',' ) { + $csv_data = csv_get_data( $file_path, false, $delimiter ); + $data = array( + 'data' => $csv_data, + 'csv_file' => $file_path, + 'fields' => $this->get_importable_fields(), + ); + + ATBDP()->load_template( 'admin-templates/import-export/data-table', $data ); + } + + public function render_tools_submenu_page() { + + ATBDP()->load_template( 'admin-templates/import-export/import-export', array( 'controller' => $this ) ); + } + + /** + * Importer Header Template + * + * @param bool $return + * @return string $template + */ + public function importer_header_template( $return = false ) { + $template_data = array(); + + $template_data['controller'] = $this; + $template_data['download_link'] = esc_url( ATBDP_URL . 'views/admin-templates/import-export/data/dummy.csv' ); + $template_data['nav_menu'] = $this->get_header_nav_menu(); + + $template_path = 'admin-templates/import-export/header-templates/header'; + ATBDP()->load_template( $template_path, $template_data ); + } + + /** + * Importer header nav menu item template + * + * @param bool $return + * @return string $template + */ + public function importer_header_nav_menu_item_template( $template_data = array(), $return = false ) { + + $template_data['controller'] = $this; + ATBDP()->load_template( 'admin-templates/import-export/header-templates/nav-item', $template_data ); + } + + /** + * Get Header Nav Menu + * + * @return array + */ + public function get_header_nav_menu() { + $step = isset( $_GET['step'] ) ? sanitize_key( wp_unslash( $_GET['step'] ) ) : ''; + $nav_menu = array(); + + // Item - 1 + $nav_item = array(); + $nav_item['nav_item_class'] = ! $step ? esc_attr( 'active' ) : ( $step > 1 ? esc_attr( 'done' ) : '' ); + $nav_item['label'] = esc_html__( 'Upload CSV File', 'directorist' ); + $nav_menu[] = $nav_item; + + // Item - 2 + $nav_item = array(); + $class = ( '2' == $step ) ? esc_attr( 'active' ) : ( $step > 2 ? esc_attr( 'done' ) : '' ); + $class = 'atbdp-mapping-step ' . $class; + $nav_item['nav_item_class'] = trim( $class ); + $nav_item['label'] = esc_html__( 'Column Mapping', 'directorist' ); + $nav_menu[] = $nav_item; + + // Item - 3 + $nav_item = array(); + $class = ( $step == 3 ) ? esc_attr( 'done' ) : ''; + $class = 'atbdp-progress-step ' . $class; + $nav_item['nav_item_class'] = trim( $class ); + $nav_item['label'] = esc_html__( 'Import', 'directorist' ); + $nav_menu[] = $nav_item; + + // Item - 4 + $nav_item = array(); + $nav_item['nav_item_class'] = ( '3' == $step ) ? esc_attr( 'active done' ) : ''; + $nav_item['label'] = esc_html__( 'Done', 'directorist' ); + $nav_menu[] = $nav_item; + + $nav_menu = apply_filters( 'directorist_listings_importer_header_nav_menu', $nav_menu, $step ); + + return $nav_menu; + } + + /** + * Importer Body Template + * + * @param bool $return + * @return string $template + */ + public function importer_body_template( $return = false ) { + $step = ( isset( $_REQUEST['step'] ) ) ? directorist_clean( wp_unslash( $_REQUEST['step'] ) ) : 1; + $step = ( ! empty( $step ) && is_numeric( $step ) ) ? (int) $step : 1; + $template_base_path = 'admin-templates/import-export/body-templates'; + $template_paths = array( + 1 => "{$template_base_path}/step-one", + 2 => "{$template_base_path}/step-two", + 3 => "{$template_base_path}/step-done", + ); + + $template_path = ( isset( $template_paths[ $step ] ) ) ? $template_paths[ $step ] : $template_paths[1]; + + $template_data = array( + 'controller' => $this, + 'step' => $step, + ); + + ATBDP()->load_template( $template_path, $template_data ); + } public function get_importable_fields() { return apply_filters( 'directorist_importable_fields', $this->importable_fields ); @@ -659,6 +680,6 @@ protected static function unescape_data( $value ) { return $value; } - } + } -endif; \ No newline at end of file +endif; diff --git a/includes/classes/class-updater-notice.php b/includes/classes/class-updater-notice.php index f03e051084..7e7ebca977 100644 --- a/includes/classes/class-updater-notice.php +++ b/includes/classes/class-updater-notice.php @@ -14,8 +14,8 @@ class Updater_Notice { public static function init() { - add_action( 'wp_loaded', [ __CLASS__, 'hide_notices' ] ); - add_action( 'admin_notices', [ __CLASS__, 'show_notices' ] ); + add_action( 'wp_loaded', array( __CLASS__, 'hide_notices' ) ); + add_action( 'admin_notices', array( __CLASS__, 'show_notices' ) ); } /** @@ -23,8 +23,8 @@ public static function init() { */ public static function hide_notices() { - if( is_admin() && isset( $_GET["page"] ) && ( ( $_GET["page"] == 'atbdp-settings' ) || ( $_GET["page"] == 'atbdp-directory-types' ) || ( 'atbdp-layout-builder' === $_GET["page"] ) ) ) { - remove_all_actions('admin_notices'); + if ( is_admin() && isset( $_GET['page'] ) && ( ( $_GET['page'] == 'atbdp-settings' ) || ( $_GET['page'] == 'atbdp-directory-types' ) || ( 'atbdp-layout-builder' === $_GET['page'] ) ) ) { + remove_all_actions( 'admin_notices' ); } if ( isset( $_GET['directorist-hide-notice'] ) && isset( $_GET['_directorist_notice_nonce'] ) ) { // WPCS: input var ok, CSRF ok. diff --git a/includes/classes/class-upgrade.php b/includes/classes/class-upgrade.php index 436397c022..4d51645f72 100644 --- a/includes/classes/class-upgrade.php +++ b/includes/classes/class-upgrade.php @@ -4,47 +4,47 @@ use Directorist\Multi_Directory\Multi_Directory_Manager; // it handles directorist upgrade -class ATBDP_Upgrade -{ - public $upgrade_notice_id = 'migrate_to_7'; +class ATBDP_Upgrade { - public $legacy_notice_id = 'directorist_legacy_template'; + public $upgrade_notice_id = 'migrate_to_7'; - public $directorist_notices = []; + public $legacy_notice_id = 'directorist_legacy_template'; - public $directorist_migration = []; + public $directorist_notices = array(); - public function __construct() - { - if ( !is_admin() ) return; + public $directorist_migration = array(); - add_action('admin_init', array($this, 'configure_notices')); + public function __construct() { + if ( ! is_admin() ) { + return; + } - add_action('directorist_search_setting_sections', array($this, 'support_themes_hook')); + add_action( 'admin_init', array( $this, 'configure_notices' ) ); - add_action('admin_notices', array($this, 'upgrade_notice'), 100); + add_action( 'directorist_search_setting_sections', array( $this, 'support_themes_hook' ) ); - add_action('directorist_before_settings_panel_header', array($this, 'promo_banner') ); + add_action( 'admin_notices', array( $this, 'upgrade_notice' ), 100 ); - add_action('directorist_before_all_directory_types', array($this, 'promo_banner') ); + add_action( 'directorist_before_settings_panel_header', array( $this, 'promo_banner' ) ); - // add_action('directorist_before_directory_type_edited', array($this, 'promo_banner') ); + add_action( 'directorist_before_all_directory_types', array( $this, 'promo_banner' ) ); - add_action( 'admin_notices', array( $this, 'bfcm_notice') ); + // add_action('directorist_before_directory_type_edited', array($this, 'promo_banner') ); - add_action( 'admin_init', [ $this, 'v8_force_migration' ] ); + add_action( 'admin_notices', array( $this, 'bfcm_notice' ) ); + add_action( 'admin_init', array( $this, 'v8_force_migration' ) ); } public function v8_force_migration() { - if( get_option( 'directorist_v8_force_migrated' ) ) { + if ( get_option( 'directorist_v8_force_migrated' ) ) { return; } - $listings = wp_count_posts('at_biz_dir')->publish; + $listings = wp_count_posts( 'at_biz_dir' )->publish; - if( empty( $listings ) ) { + if ( empty( $listings ) ) { update_option( 'directorist_v8_force_migrated', true ); return; } @@ -56,24 +56,24 @@ public function v8_force_migration() { public function run_v8_migration() { - //create account page + // create account page $options = get_option( 'atbdp_option' ); $account = wp_insert_post( array( - 'post_title' => 'Sign In', - 'post_content' => '[directorist_signin_signup]', - 'post_status' => 'publish', - 'post_type' => 'page', - 'comment_status' => 'closed' + 'post_title' => 'Sign In', + 'post_content' => '[directorist_signin_signup]', + 'post_status' => 'publish', + 'post_type' => 'page', + 'comment_status' => 'closed', ) ); if ( $account ) { - $options['signin_signup_page'] = (int) $account; - $options['marker_shape_color'] = '#444752'; - $options['marker_icon_color'] = '#ffffff'; - $options['all_listing_layout'] = 'no_sidebar'; - $options['search_result_layout'] = 'no_sidebar'; + $options['signin_signup_page'] = (int) $account; + $options['marker_shape_color'] = '#444752'; + $options['marker_icon_color'] = '#ffffff'; + $options['all_listing_layout'] = 'no_sidebar'; + $options['search_result_layout'] = 'no_sidebar'; update_option( 'atbdp_option', $options ); } @@ -82,18 +82,19 @@ public function run_v8_migration() { if ( did_action( 'elementor/loaded' ) && ! file_exists( $path ) ) { - directorist_download_plugin( [ 'url' => 'https://downloads.wordpress.org/plugin/addonskit-for-elementor.zip' ] ); + directorist_download_plugin( array( 'url' => 'https://downloads.wordpress.org/plugin/addonskit-for-elementor.zip' ) ); - if ( ! is_plugin_active( $path ) ){ + if ( ! is_plugin_active( $path ) ) { activate_plugin( $path ); } } - $directory_types = get_terms([ - 'taxonomy' => ATBDP_DIRECTORY_TYPE, - 'hide_empty' => false, - ]); - + $directory_types = get_terms( + array( + 'taxonomy' => ATBDP_DIRECTORY_TYPE, + 'hide_empty' => false, + ) + ); if ( is_wp_error( $directory_types ) || empty( $directory_types ) ) { return; @@ -105,19 +106,19 @@ public function run_v8_migration() { // backup the builder data Multi_Directory_Manager::builder_data_backup( $directory_type->term_id ); - //migrate custom field + // migrate custom field Multi_Directory_Manager::migrate_custom_field( $directory_type->term_id ); - //migrate review settings + // migrate review settings Multi_Directory_Manager::migrate_review_settings( $directory_type->term_id ); - //migrate contact form + // migrate contact form Multi_Directory_Manager::migrate_contact_owner_settings( $directory_type->term_id ); - //migrate related listing settings + // migrate related listing settings Multi_Directory_Manager::migrate_related_listing_settings( $directory_type->term_id ); - //migrate privacy policy + // migrate privacy policy Multi_Directory_Manager::migrate_privacy_policy( $directory_type->term_id ); - //migrate builder single listing header - $new_structure = []; + // migrate builder single listing header + $new_structure = array(); $header_contents = get_term_meta( $directory_type->term_id, 'single_listing_header', true ); if ( empty( $header_contents ) ) { @@ -130,30 +131,30 @@ public function run_v8_migration() { // Initialize contents if empty if ( empty( $contents ) ) { - $contents = [ - 'fields' => [], - 'groups' => [], - ]; + $contents = array( + 'fields' => array(), + 'groups' => array(), + ); } if ( $description ) { - $contents['fields']['description'] = [ - "icon" => "las la-tag", - "widget_group" => "preset_widgets", - "widget_name" => "description", - "original_widget_key" => "description", - "widget_key" => "description" - ]; - - $details = [ - "type" => "general_group", - "label" => "Description", - "fields" => [ - "description" - ], - "section_id" => "1627188303" . $directory_type->term_id - ]; + $contents['fields']['description'] = array( + 'icon' => 'las la-tag', + 'widget_group' => 'preset_widgets', + 'widget_name' => 'description', + 'original_widget_key' => 'description', + 'widget_key' => 'description', + ); + + $details = array( + 'type' => 'general_group', + 'label' => 'Description', + 'fields' => array( + 'description', + ), + 'section_id' => '1627188303' . $directory_type->term_id, + ); array_unshift( $contents['groups'], $details ); @@ -168,98 +169,96 @@ public function run_v8_migration() { foreach ( $header_contents['listings_header'] as $section_name => $widgets ) { if ( 'quick_actions' === $section_name ) { - $quick_widget = [ - "type" => "placeholder_group", - "placeholderKey" => "quick-widgets-placeholder", - "placeholders" => [ - [ - "type" => "placeholder_group", - "placeholderKey" => "quick-info-placeholder", - "selectedWidgets" => [ - [ - "type" => "button", - "label" => "Back", - "widget_name" => "back", - "widget_key" => "back" - ] - ] - ], - [ - "type" => "placeholder_group", - "placeholderKey" => "quick-action-placeholder", - "selectedWidgets" => $widgets, - ] - ] - ]; + $quick_widget = array( + 'type' => 'placeholder_group', + 'placeholderKey' => 'quick-widgets-placeholder', + 'placeholders' => array( + array( + 'type' => 'placeholder_group', + 'placeholderKey' => 'quick-info-placeholder', + 'selectedWidgets' => array( + array( + 'type' => 'button', + 'label' => 'Back', + 'widget_name' => 'back', + 'widget_key' => 'back', + ), + ), + ), + array( + 'type' => 'placeholder_group', + 'placeholderKey' => 'quick-action-placeholder', + 'selectedWidgets' => $widgets, + ), + ), + ); array_push( $new_structure, $quick_widget ); } - if ( 'thumbnail' === $section_name ) { $footer_thumbnail = ! empty( $widgets[0]['footer_thumbail'] ) ? $widgets[0]['footer_thumbail'] : true; - $slider_widget = [ - "type" => "placeholder_item", - "placeholderKey" => "slider-placeholder", - "selectedWidgets" => [ - [ - "type" => "thumbnail", - "label" => "Listing Image/Slider", - "widget_name" => "slider", - "widget_key" => "slider", - 'options' => [ + $slider_widget = array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'slider-placeholder', + 'selectedWidgets' => array( + array( + 'type' => 'thumbnail', + 'label' => 'Listing Image/Slider', + 'widget_name' => 'slider', + 'widget_key' => 'slider', + 'options' => array( 'title' => __( 'Listings Slider Settings', 'directorist' ), - 'fields' => [ - 'footer_thumbnail' => [ + 'fields' => array( + 'footer_thumbnail' => array( 'type' => 'toggle', 'label' => __( 'Enable Footer Thumbnail', 'directorist' ), 'value' => $footer_thumbnail, - ], - ], - ], - ] - ] - ]; + ), + ), + ), + ), + ), + ); array_push( $new_structure, $slider_widget ); } if ( 'quick_info' === $section_name ) { - $title_widget = [ - "type" => "placeholder_item", - "placeholderKey" => "listing-title-placeholder", - "selectedWidgets" => [ - [ - "type" => "title", - "label" => "Listing Title", - "widget_name" => "title", - "widget_key" => "title", - 'options' => [ - 'title' => __( "Listing Title Settings", "directorist" ), - 'fields' => [ - 'enable_tagline' => [ - 'type' => "toggle", - 'label' => __( "Show Tagline", "directorist" ), + $title_widget = array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'listing-title-placeholder', + 'selectedWidgets' => array( + array( + 'type' => 'title', + 'label' => 'Listing Title', + 'widget_name' => 'title', + 'widget_key' => 'title', + 'options' => array( + 'title' => __( 'Listing Title Settings', 'directorist' ), + 'fields' => array( + 'enable_tagline' => array( + 'type' => 'toggle', + 'label' => __( 'Show Tagline', 'directorist' ), 'value' => $tagline, - ], - ], - ], - ] - ] - ]; + ), + ), + ), + ), + ), + ); array_push( $new_structure, $title_widget ); - $more_widget = [ - "type" => "placeholder_item", - "placeholderKey" => "more-widgets-placeholder", - "selectedWidgets" => $widgets, - ]; + $more_widget = array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'more-widgets-placeholder', + 'selectedWidgets' => $widgets, + ); array_push( $new_structure, $more_widget ); } - } $new_structure = apply_filters( 'directorist_single_listing_header_migration_data', $new_structure, $header_contents ); @@ -271,8 +270,8 @@ public function run_v8_migration() { private function search_field_label_migration( $directory_id ) { $search_fields = get_term_meta( $directory_id, 'search_form_fields', true ); - $search_fields = is_array( $search_fields ) ? $search_fields : []; - $fields = isset( $search_fields['fields'] ) && is_array( $search_fields['fields'] ) ? $search_fields['fields'] : []; + $search_fields = is_array( $search_fields ) ? $search_fields : array(); + $fields = isset( $search_fields['fields'] ) && is_array( $search_fields['fields'] ) ? $search_fields['fields'] : array(); foreach ( $fields as $key => $field ) { $placeholder = empty( $field['placeholder'] ) ? '' : $field['placeholder']; @@ -294,15 +293,15 @@ public function support_themes_hook( $data ) { if ( $theme->display( 'Author', false ) === 'wpWax' ) { if ( ( 'Pixetiq' !== $theme['Name'] ) && ( version_compare( 2, $theme['Version'], '>' ) ) ) { - $data['search_form'] = [ - 'fields' => [], - ]; + $data['search_form'] = array( + 'fields' => array(), + ); } if ( ( ( 'Direo' === $theme['Name'] ) || ( 'dList' === $theme['Name'] ) ) && ( version_compare( 3, $theme['Version'], '>' ) ) ) { - $data['search_form'] = [ - 'fields' => [], - ]; + $data['search_form'] = array( + 'fields' => array(), + ); } } @@ -313,14 +312,14 @@ public function is_pro_user() { $plugin = get_user_meta( get_current_user_id(), '_plugins_available_in_subscriptions', true ); $theme = get_user_meta( get_current_user_id(), '_themes_available_in_subscriptions', true ); - if( $plugin || $theme ) { + if ( $plugin || $theme ) { return true; } else { return false; } } - public function promo_banner(){ + public function promo_banner() { if ( self::can_manage_plugins() && ! self::is_pro_user() ) { ATBDP()->load_template( 'admin-templates/admin-promo-banner' ); } @@ -335,15 +334,15 @@ public function bfcm_notice() { return; } - $response_body = self::promo_remote_get(); - $display = ! empty( $response_body->promo_2_display ) ? $response_body->promo_2_display : ''; - $text = ! empty( $response_body->promo_2_text ) ? $response_body->promo_2_text : ''; - $version = ! empty( $response_body->promo_2_version ) ? $response_body->promo_2_version : ''; - $link = ! empty( $response_body->get_now_button_link ) ? self::promo_link( $response_body->get_now_button_link ) : ''; + $response_body = self::promo_remote_get(); + $display = ! empty( $response_body->promo_2_display ) ? $response_body->promo_2_display : ''; + $text = ! empty( $response_body->promo_2_text ) ? $response_body->promo_2_text : ''; + $version = ! empty( $response_body->promo_2_version ) ? $response_body->promo_2_version : ''; + $link = ! empty( $response_body->get_now_button_link ) ? self::promo_link( $response_body->get_now_button_link ) : ''; $closed_version = get_user_meta( get_current_user_id(), 'directorist_promo2_closed_version', true ); - if ( !$display || $version == $closed_version || !$text ) { + if ( ! $display || $version == $closed_version || ! $text ) { return; } @@ -352,12 +351,12 @@ public function bfcm_notice() { $dismiss_url = add_query_arg( array( 'directorist_promo2_closed_version' => $version, - 'directorist_promo_nonce' => wp_create_nonce( 'directorist_promo_nonce' ), + 'directorist_promo_nonce' => wp_create_nonce( 'directorist_promo_nonce' ), ), atbdp_get_current_url() ); - $notice = '<div class="notice notice-info is-dismissible"><p style="font-size: 16px;">' . $text . '</p><a href="'.esc_url( $dismiss_url ).'" class="notice-dismiss" style="text-decoration: none;"><span class="screen-reader-text">'. __( 'Dismiss this notice.', 'directorist' ) .'</span></a></div>'; + $notice = '<div class="notice notice-info is-dismissible"><p style="font-size: 16px;">' . $text . '</p><a href="' . esc_url( $dismiss_url ) . '" class="notice-dismiss" style="text-decoration: none;"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'directorist' ) . '</span></a></div>'; echo wp_kses_post( $notice ); } @@ -374,14 +373,14 @@ public function upgrade_notice() { // v8.0 compatibility notice // theme check $theme = wp_get_theme( is_child_theme() ? get_template() : '' ); - if( ( $theme->display( 'Author', FALSE ) === 'wpWax' ) && ( version_compare( 2, $theme['Version'], '>' ) ) && ( 'Pixetiq' !== $theme['Name'] ) ) { + if ( ( $theme->display( 'Author', false ) === 'wpWax' ) && ( version_compare( 2, $theme['Version'], '>' ) ) && ( 'Pixetiq' !== $theme['Name'] ) ) { // show theme $this->v8_theme_upgrade_notice( $theme ); } // extension check $plugins_data = get_plugins(); - $outdated_extensions = []; + $outdated_extensions = array(); foreach ( ATBDP_Extensions::get_default_extensions() as $slug => $extension ) { $extension_base = $extension['base'] ?? $slug . '/' . $slug . '.php'; @@ -396,7 +395,7 @@ public function upgrade_notice() { } } - public function v8_extension_upgrade_notice( $outdated_extensions = [] ) { + public function v8_extension_upgrade_notice( $outdated_extensions = array() ) { if ( ! self::can_manage_plugins() ) { return; } @@ -404,14 +403,14 @@ public function v8_extension_upgrade_notice( $outdated_extensions = [] ) { $text = ''; $link = 'https://directorist.com/blog/directorist-version-8-0/'; $wp_rollback = admin_url( 'plugin-install.php?s=rollback&tab=search&type=term' ); - $extension_update_links = []; + $extension_update_links = array(); foreach ( $outdated_extensions as $extension_base => $extension ) { $extension_update_links[] = '- <a class="directorist-update-extension" href="' . $extension_base . '">' . $extension . '</a>'; } $text .= sprintf( - __( '<p class="directorist__notice_new"><span style="font-size: 16px;">📣 Directorist Extension Compatibility Notice!</span><br/> Congratulations and welcome to Directorist v8.0 with <a href="%s" target="_blank">some cool new features</a>. You are using <b style="color:#dba617">%s outdated extension(s)</b> which are incompatible with Directorist v8.0. Please update the following outdated extensions:<br>%s</p><br>', 'directorist' ), + __( '<p class="directorist__notice_new"><span style="font-size: 16px;">📣 Directorist Extension Compatibility Notice!</span><br/> Congratulations and welcome to Directorist v8.0 with <a href="%1$s" target="_blank">some cool new features</a>. You are using <b style="color:#dba617">%2$s outdated extension(s)</b> which are incompatible with Directorist v8.0. Please update the following outdated extensions:<br>%3$s</p><br>', 'directorist' ), $link, count( $outdated_extensions ), implode( '<br>', $extension_update_links ) @@ -422,7 +421,7 @@ public function v8_extension_upgrade_notice( $outdated_extensions = [] ) { $wp_rollback ); - $notice = '<div class="notice notice-warning is-dismissible directorist-plugin-updater-notice" style="padding-top: 5px;padding-bottom: 5px;">' . $text . '</div>'; + $notice = '<div class="notice notice-warning is-dismissible directorist-plugin-updater-notice" style="padding-top: 5px;padding-bottom: 5px;">' . $text . '</div>'; $notice_script = <<<SCRIPT <script> document.querySelectorAll('.directorist-update-extension').forEach(anchor => { @@ -445,13 +444,13 @@ public function v8_theme_upgrade_notice( $theme ) { return; } - $text = ''; - $link = 'https://directorist.com/blog/directorist-version-8-0/'; - $membership_page = admin_url('edit.php?post_type=at_biz_dir&page=atbdp-extension'); + $text = ''; + $link = 'https://directorist.com/blog/directorist-version-8-0/'; + $membership_page = admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-extension' ); $wp_rollback = admin_url( 'plugin-install.php?s=rollback&tab=search&type=term' ); - $text .= sprintf( __( '<p class="directorist__notice_new"><span style="font-size: 16px;">📣 Directorist Theme Compatibility Notice!</span><br/> Congratulations and welcome to Directorist v8.0 with some cool <a href="%s" target="_blank">new features</a>.Please update <a target="_blank" href="%s">%s theme</a> </p>', 'directorist' ), $link, $membership_page, $theme['Name'] ); + $text .= sprintf( __( '<p class="directorist__notice_new"><span style="font-size: 16px;">📣 Directorist Theme Compatibility Notice!</span><br/> Congratulations and welcome to Directorist v8.0 with some cool <a href="%1$s" target="_blank">new features</a>.Please update <a target="_blank" href="%2$s">%3$s theme</a> </p>', 'directorist' ), $link, $membership_page, $theme['Name'] ); $text .= sprintf( __( '<p class="directorist__notice_new_action">Mistakenly updated? Use <a target="_blank" href="%s">WP Rollback</a> to install your old Directorist</p>', 'directorist' ), @@ -468,7 +467,7 @@ public function configure_notices() { return; } - $this->directorist_notices = get_option( 'directorist_notices' ); + $this->directorist_notices = get_option( 'directorist_notices' ); if ( isset( $_GET['close-directorist-promo-version'], $_GET['directorist_promo_nonce'] ) && wp_verify_nonce( $_GET['directorist_promo_nonce'], 'directorist_promo_nonce' ) ) { update_user_meta( get_current_user_id(), '_directorist_promo_closed', directorist_clean( wp_unslash( $_GET['close-directorist-promo-version'] ) ) ); @@ -480,11 +479,10 @@ public function configure_notices() { } public static function promo_link( $link ) { - if( defined( 'DIRECTORIST_AFFLILIATE_ID' ) && DIRECTORIST_AFFLILIATE_ID !== null ) { - $link = $link . "ref/" . DIRECTORIST_AFFLILIATE_ID; + if ( defined( 'DIRECTORIST_AFFLILIATE_ID' ) && DIRECTORIST_AFFLILIATE_ID !== null ) { + $link = $link . 'ref/' . DIRECTORIST_AFFLILIATE_ID; } return $link; } - } diff --git a/includes/classes/class-user.php b/includes/classes/class-user.php index aa97c20a60..f6a4dd3b6f 100644 --- a/includes/classes/class-user.php +++ b/includes/classes/class-user.php @@ -22,31 +22,31 @@ class ATBDP_User { public function __construct() { add_action( 'wp_loaded', array( $this, 'handle_user_registration' ) ); - //add_action('init', array($this, 'activate_user')); - add_filter( 'pre_get_posts', array( $this,'restrict_listing_to_the_author' ) ); + // add_action('init', array($this, 'activate_user')); + add_filter( 'pre_get_posts', array( $this, 'restrict_listing_to_the_author' ) ); // allow contributor upload images for now. @todo; later it will be better to add custom rules and capability // add_action( 'plugins_loaded', array( $this, 'user_functions_ready_hook' ) );// before we add custom image uploading, lets use WordPress default image uploading by letting subscriber and contributor upload imaging capability - add_action( 'template_redirect', [ $this, 'registration_redirection' ] ); + add_action( 'template_redirect', array( $this, 'registration_redirection' ) ); - add_filter( 'authenticate', [$this, 'filter_authenticate'], 999999, 2 ); + add_filter( 'authenticate', array( $this, 'filter_authenticate' ), 999999, 2 ); if ( is_admin() ) { - add_filter( 'manage_users_columns', [$this,'manage_users_columns'], 10, 1 ); - add_filter( 'manage_users_custom_column', [$this,'manage_users_custom_column'], 10, 3 ); + add_filter( 'manage_users_columns', array( $this, 'manage_users_columns' ), 10, 1 ); + add_filter( 'manage_users_custom_column', array( $this, 'manage_users_custom_column' ), 10, 3 ); if ( directorist_is_email_verification_enabled() ) { - add_filter( 'user_row_actions', [$this, 'filter_user_row_actions'], 10, 2 ); - add_filter( 'bulk_actions-users', [$this, 'filter_users_table_bulk_actions'] ); - add_filter( 'handle_bulk_actions-users', [$this, 'filter_handle_bulk_actions_users'], 10, 3 ); - add_action( 'edit_user_profile', [$this, 'user_email_verification_input'] ); - add_action( 'user_new_form', [$this, 'user_email_verification_input'] ); - add_action( 'user_register', [$this, 'action_admin_edit_user_info'] ); - add_action( 'profile_update', [$this, 'action_admin_edit_user_info'] ); - add_action( 'admin_notices', [$this, 'action_email_verification_notice'] ); + add_filter( 'user_row_actions', array( $this, 'filter_user_row_actions' ), 10, 2 ); + add_filter( 'bulk_actions-users', array( $this, 'filter_users_table_bulk_actions' ) ); + add_filter( 'handle_bulk_actions-users', array( $this, 'filter_handle_bulk_actions_users' ), 10, 3 ); + add_action( 'edit_user_profile', array( $this, 'user_email_verification_input' ) ); + add_action( 'user_new_form', array( $this, 'user_email_verification_input' ) ); + add_action( 'user_register', array( $this, 'action_admin_edit_user_info' ) ); + add_action( 'profile_update', array( $this, 'action_admin_edit_user_info' ) ); + add_action( 'admin_notices', array( $this, 'action_email_verification_notice' ) ); } } else { - add_action( 'user_register', [$this, 'action_user_register'] ); + add_action( 'user_register', array( $this, 'action_user_register' ) ); } add_action( 'wp_ajax_directorist_register_form', array( $this, 'directorist_register_form' ) ); @@ -54,34 +54,40 @@ public function __construct() { } public function directorist_register_form() { - if ( ! directorist_verify_nonce() || ! isset( $_POST['params'] ) ) { - wp_send_json_error( array( - 'error' => 'Invalid request.' - ), 401 ); + if ( ! directorist_verify_nonce() || ! isset( $_POST['params'] ) ) { + wp_send_json_error( + array( + 'error' => 'Invalid request.', + ), + 401 + ); } - $params_json_decode = json_decode( stripslashes( $_POST['params'] ), true ); - $params = directorist_clean( $params_json_decode); + $params_json_decode = json_decode( stripslashes( $_POST['params'] ), true ); + $params = directorist_clean( $params_json_decode ); if ( ! directorist_is_user_registration_enabled() ) { - wp_send_json_error( array( - 'error' => 'You are not allowed to register.' - ), 400 ); + wp_send_json_error( + array( + 'error' => 'You are not allowed to register.', + ), + 400 + ); } // if the form is submitted then save the form - $require_website = ! empty( $params['registration_website_required'] ) && 'yes' === $params['registration_website_required'] ? 1 : 0; - $display_website = ! empty( $params['enable_registration_website'] ) && 'yes' === $params['enable_registration_website'] ? 1 : 0; - $display_fname = ! empty( $params['enable_registration_first_name'] ) && 'yes' === $params['enable_registration_first_name'] ? 1 : 0; - $require_fname = ! empty( $params['registration_first_name_required'] ) && 'yes' === $params['registration_first_name_required'] ? 1 : 0; - $display_lname = ! empty( $params['enable_registration_last_name'] ) && 'yes' === $params['enable_registration_last_name'] ? 1 : 0; - $require_lname = ! empty( $params['registration_last_name_required'] ) && 'yes' === $params['registration_last_name_required'] ? 1 : 0; - $display_password = ! empty( $params['enable_registration_password'] ) && 'yes' === $params['enable_registration_password'] ? 1 : 0; - $display_user_type = ! empty( $params['enable_user_type'] ) && 'yes' === $params['enable_user_type'] ? 1 : 0; - $display_bio = ! empty( $params['enable_registration_bio'] ) && 'yes' === $params['enable_registration_bio'] ? 1 : 0; - $require_bio = ! empty( $params['registration_bio_required'] ) && 'yes' === $params['registration_bio_required'] ? 1 : 0; - $registration_privacy = ! empty( $params['enable_registration_privacy'] ) && 'yes' === $params['enable_registration_privacy'] ? 1 : 0; - $terms_condition = ! empty( $params['enable_registration_terms'] ) && 'yes' === $params['enable_registration_terms'] ? 1 : 0; + $require_website = ! empty( $params['registration_website_required'] ) && 'yes' === $params['registration_website_required'] ? 1 : 0; + $display_website = ! empty( $params['enable_registration_website'] ) && 'yes' === $params['enable_registration_website'] ? 1 : 0; + $display_fname = ! empty( $params['enable_registration_first_name'] ) && 'yes' === $params['enable_registration_first_name'] ? 1 : 0; + $require_fname = ! empty( $params['registration_first_name_required'] ) && 'yes' === $params['registration_first_name_required'] ? 1 : 0; + $display_lname = ! empty( $params['enable_registration_last_name'] ) && 'yes' === $params['enable_registration_last_name'] ? 1 : 0; + $require_lname = ! empty( $params['registration_last_name_required'] ) && 'yes' === $params['registration_last_name_required'] ? 1 : 0; + $display_password = ! empty( $params['enable_registration_password'] ) && 'yes' === $params['enable_registration_password'] ? 1 : 0; + $display_user_type = ! empty( $params['enable_user_type'] ) && 'yes' === $params['enable_user_type'] ? 1 : 0; + $display_bio = ! empty( $params['enable_registration_bio'] ) && 'yes' === $params['enable_registration_bio'] ? 1 : 0; + $require_bio = ! empty( $params['registration_bio_required'] ) && 'yes' === $params['registration_bio_required'] ? 1 : 0; + $registration_privacy = ! empty( $params['enable_registration_privacy'] ) && 'yes' === $params['enable_registration_privacy'] ? 1 : 0; + $terms_condition = ! empty( $params['enable_registration_terms'] ) && 'yes' === $params['enable_registration_terms'] ? 1 : 0; $username = ! empty( $_POST['username'] ) ? directorist_clean( wp_unslash( $_POST['username'] ) ) : ''; $password = ! empty( $_POST['password'] ) ? $_POST['password'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash @@ -95,27 +101,27 @@ public function directorist_register_form() { $t_c_check = ! empty( $_POST['t_c_check'] ) ? directorist_clean( wp_unslash( $_POST['t_c_check'] ) ) : ''; $previous_page = ! empty( $_POST['previous_page'] ) ? directorist_clean( $_POST['previous_page'] ) : ''; - //password validation + // password validation if ( ! empty( $display_password ) && empty( $password ) ) { $password_validation = 'yes'; } - //website validation + // website validation if ( ! empty( $require_website ) && ! empty( $display_website ) && empty( $website ) ) { $website_validation = 'yes'; } - //first name validation + // first name validation if ( ! empty( $require_fname ) && ! empty( $display_fname ) && empty( $first_name ) ) { $fname_validation = 'yes'; } - //last name validation - if ( ! empty( $require_lname ) && !empty( $display_lname ) && empty( $last_name ) ) { + // last name validation + if ( ! empty( $require_lname ) && ! empty( $display_lname ) && empty( $last_name ) ) { $lname_validation = 'yes'; } - //bio validation + // bio validation if ( ! empty( $require_bio ) && ! empty( $display_bio ) && empty( $bio ) ) { $bio_validation = 'yes'; } @@ -124,12 +130,12 @@ public function directorist_register_form() { $user_type_validation = 'yes'; } - //privacy validation + // privacy validation if ( ! empty( $registration_privacy ) && empty( $privacy_policy ) ) { $privacy_validation = 'yes'; } - //terms & conditions validation + // terms & conditions validation if ( ! empty( $terms_condition ) && empty( $t_c_check ) ) { $t_c_validation = 'yes'; } @@ -139,13 +145,13 @@ public function directorist_register_form() { if ( 'passed' !== $validation ) { $error_msg = ''; - if ( empty( $username ) || ! empty( $password_validation ) || empty( $email ) || ! empty( $website_validation ) || ! empty( $fname_validation ) || ! empty( $lname_validation ) || ! empty( $bio_validation )|| ! empty( $privacy_validation ) || ! empty( $t_c_validation ) ) { + if ( empty( $username ) || ! empty( $password_validation ) || empty( $email ) || ! empty( $website_validation ) || ! empty( $fname_validation ) || ! empty( $lname_validation ) || ! empty( $bio_validation ) || ! empty( $privacy_validation ) || ! empty( $t_c_validation ) ) { $error_msg = directorist_get_registration_error_message( 1 ); } elseif ( email_exists( $email ) ) { $error_msg = directorist_get_registration_error_message( 2 ); } elseif ( ! empty( $username ) && 4 > strlen( $username ) ) { $error_msg = directorist_get_registration_error_message( 3 ); - } elseif ( ! empty( $username ) && preg_match('/\s/',$username) ) { + } elseif ( ! empty( $username ) && preg_match( '/\s/', $username ) ) { $error_msg = directorist_get_registration_error_message( 7 ); } elseif ( username_exists( $username ) ) { $error_msg = directorist_get_registration_error_message( 4 ); @@ -158,9 +164,11 @@ public function directorist_register_form() { } if ( $error_msg ) { - wp_send_json_error( array( - 'error' => $error_msg - ) ); + wp_send_json_error( + array( + 'error' => $error_msg, + ) + ); } } @@ -184,6 +192,7 @@ public function directorist_register_form() { /** * It fires before processing a submitted registration from the front end + * * @param array $_POST the array containing the submitted listing data. * @since 8.0 * */ @@ -192,9 +201,11 @@ public function directorist_register_form() { $user_id = $this->complete_registration( $username, $password, $email, $website, $first_name, $last_name, $bio ); if ( is_wp_error( $user_id ) || ! $user_id ) { - wp_send_json_success( array( - 'error' => directorist_get_registration_error_message( 0 ) - ) ); + wp_send_json_success( + array( + 'error' => directorist_get_registration_error_message( 0 ), + ) + ); } /* @@ -218,10 +229,14 @@ public function directorist_register_form() { ATBDP()->email->send_user_confirmation_email( get_user_by( 'ID', $user_id ) ); $response = array( - 'redirect_url' => esc_url_raw( ATBDP_Permalink::get_signin_signup_page_link( array( - 'user' => base64_encode( $email ), - 'verification' => 1, - ) ) ) + 'redirect_url' => esc_url_raw( + ATBDP_Permalink::get_signin_signup_page_link( + array( + 'user' => base64_encode( $email ), + 'verification' => 1, + ) + ) + ), ); wp_send_json_success( $response ); @@ -229,9 +244,9 @@ public function directorist_register_form() { ATBDP()->email->custom_wp_new_user_notification_email( $user_id ); - $auto_login = ! empty( $params['auto_login_after_registration'] ) && 'yes' === $params['auto_login_after_registration'] ? 1 : 0; - $redirect_after_reg = ATBDP_Permalink::get_reg_redirection_page_link(''); - $redirection_link = ! empty( $params['redirection_after_registration'] ) ? $params['redirection_after_registration'] : $redirect_after_reg; + $auto_login = ! empty( $params['auto_login_after_registration'] ) && 'yes' === $params['auto_login_after_registration'] ? 1 : 0; + $redirect_after_reg = ATBDP_Permalink::get_reg_redirection_page_link( '' ); + $redirection_link = ! empty( $params['redirection_after_registration'] ) ? $params['redirection_after_registration'] : $redirect_after_reg; if ( ! empty( $auto_login ) ) { wp_set_current_user( $user_id, $email ); @@ -240,15 +255,15 @@ public function directorist_register_form() { if ( ! empty( $redirection_link ) ) { $response = array( - 'redirect_url' => esc_url_raw( ATBDP_Permalink::get_reg_redirection_page_link( $previous_page, array( 'registration_status' => true ), $redirection_link ) ), - 'message' => esc_html__( 'Registration completed. Please check your email for confirmation. You will be redirected...', 'directorist' ), + 'redirect_url' => esc_url_raw( ATBDP_Permalink::get_reg_redirection_page_link( $previous_page, array( 'registration_status' => true ), $redirection_link ) ), + 'message' => esc_html__( 'Registration completed. Please check your email for confirmation. You will be redirected...', 'directorist' ), ); wp_send_json_success( $response ); } else { $response = array( 'redirect_url' => esc_url_raw( ATBDP_Permalink::get_signin_signup_page_link( array( 'registration_status' => true ) ) ), - 'message' => esc_html__( 'Registration completed. Please check your email for confirmation. You will be redirected...', 'directorist' ), + 'message' => esc_html__( 'Registration completed. Please check your email for confirmation. You will be redirected...', 'directorist' ), ); wp_send_json_success( $response ); @@ -292,7 +307,7 @@ public function user_email_verification_input( $profile_user ) { <?php $email_verify_checkbox = ob_get_clean(); ?> <script> jQuery(($) => { - $('#your-profile .user-email-wrap, #createuser .user-pass2-wrap').after(`<?php echo $email_verify_checkbox;?>`); + $('#your-profile .user-email-wrap, #createuser .user-pass2-wrap').after(`<?php echo $email_verify_checkbox; ?>`); }); </script> <?php @@ -363,11 +378,14 @@ public function filter_handle_bulk_actions_users( string $sendback, string $acti break; } - return add_query_arg( array( - 'users' => $user_ids, - 'email-verification-type' => $email_verification_type, - '_wpnonce' => wp_create_nonce( 'directorist_verify_user_email_notice' ) - ), $sendback ); + return add_query_arg( + array( + 'users' => $user_ids, + 'email-verification-type' => $email_verification_type, + '_wpnonce' => wp_create_nonce( 'directorist_verify_user_email_notice' ), + ), + $sendback + ); } public function action_email_verification_notice() { @@ -396,28 +414,37 @@ public function action_email_verification_notice() { switch ( $_GET['email-verification-type'] ) { case 'sent-request': - $message = sprintf( _n( - 'Email verification request sent to %s user.', - 'Email verification request sent to %s users.', - $total_links, - 'directorist' - ), $raw_links ); + $message = sprintf( + _n( + 'Email verification request sent to %s user.', + 'Email verification request sent to %s users.', + $total_links, + 'directorist' + ), + $raw_links + ); break; case 'verified': - $message = sprintf( _n( - '%s user marked as email verified.', - '%s users marked as email verified.', - $total_links, - 'directorist' - ), $raw_links ); + $message = sprintf( + _n( + '%s user marked as email verified.', + '%s users marked as email verified.', + $total_links, + 'directorist' + ), + $raw_links + ); break; case 'unverified': - $message = sprintf( _n( - '%s user marked as email unverified.', - '%s users marked as email unverified.', - $total_links, - 'directorist' - ), $raw_links ); + $message = sprintf( + _n( + '%s user marked as email unverified.', + '%s users marked as email unverified.', + $total_links, + 'directorist' + ), + $raw_links + ); break; } @@ -445,18 +472,21 @@ public function action_email_verification_notice() { * @param \WP_User $user_object WP_User object for the currently listed user. * @return string[] An array of action links to be displayed. Default 'Edit', 'Delete' for single site, and 'Edit', 'Remove' for Multisite. */ - public function filter_user_row_actions( array $actions, \WP_User $user_object ) : array { + public function filter_user_row_actions( array $actions, \WP_User $user_object ): array { $is_email_unverified = (bool) get_user_meta( $user_object->ID, 'directorist_user_email_unverified', true ); if ( $is_email_unverified ) { - $url = add_query_arg( array( - 'action' => 'directorist_request_email_verification', - 'users[]' => $user_object->ID, - '_wpnonce' => wp_create_nonce( 'bulk-users' ) - ), admin_url( 'users.php' ) ); + $url = add_query_arg( + array( + 'action' => 'directorist_request_email_verification', + 'users[]' => $user_object->ID, + '_wpnonce' => wp_create_nonce( 'bulk-users' ), + ), + admin_url( 'users.php' ) + ); - $actions['directorist_request_email_verification'] = "<a style='cursor:pointer;' href=" . esc_url( $url ) . ">" . esc_html__( 'Request email verification', 'directorist' ) . "</a>"; + $actions['directorist_request_email_verification'] = "<a style='cursor:pointer;' href=" . esc_url( $url ) . '>' . esc_html__( 'Request email verification', 'directorist' ) . '</a>'; } return $actions; @@ -467,8 +497,8 @@ public function filter_user_row_actions( array $actions, \WP_User $user_object ) * * @param int $user_id User ID. */ - public function action_user_register(int $user_id) : void { - add_user_meta($user_id, 'directorist_user_email_unverified', true); + public function action_user_register( int $user_id ): void { + add_user_meta( $user_id, 'directorist_user_email_unverified', true ); } /** @@ -507,21 +537,27 @@ public function filter_authenticate( $user, string $username ) { return $user; } - $mail_send_url = add_query_arg( array( - 'action' => 'directorist_send_confirmation_email', - 'user' => $user->user_email, - 'directorist_nonce' => wp_create_nonce( 'directorist_nonce' ), - ), admin_url( 'admin-ajax.php' ) ); + $mail_send_url = add_query_arg( + array( + 'action' => 'directorist_send_confirmation_email', + 'user' => $user->user_email, + 'directorist_nonce' => wp_create_nonce( 'directorist_nonce' ), + ), + admin_url( 'admin-ajax.php' ) + ); - return new WP_Error( 'email_unverified', sprintf( - __( 'Your account is not yet verified. Please check your email to verify your account. If you did not receive the verification email, please click on the %s', 'directorist'), - '<a href="' . esc_url_raw( $mail_send_url ) . '">' . __( 'Resend confirmation email', 'directorist' ) . '</a>' ) + return new WP_Error( + 'email_unverified', + sprintf( + __( 'Your account is not yet verified. Please check your email to verify your account. If you did not receive the verification email, please click on the %s', 'directorist' ), + '<a href="' . esc_url_raw( $mail_send_url ) . '">' . __( 'Resend confirmation email', 'directorist' ) . '</a>' + ) ); } public function registration_redirection() { $dashbord_page_id = (int) get_directorist_option( 'user_dashboard' ); - $signin_page_id = (int) get_directorist_option( 'signin_signup_page' ); + $signin_page_id = (int) get_directorist_option( 'signin_signup_page' ); if ( $dashbord_page_id && ! is_user_logged_in() && is_page( $dashbord_page_id ) ) { wp_safe_redirect( ATBDP_Permalink::get_signin_signup_page_link() ); @@ -545,13 +581,13 @@ public function registration_redirection() { * * @param string $column_value * @param string $column_name - * @param int $user_id + * @param int $user_id * * @return string */ public function manage_users_custom_column( $column_value, $column_name, $user_id ) { - switch ($column_name) { + switch ( $column_name ) { case 'directorist_email_verified': $is_user_unverified = (bool) get_user_meta( $user_id, 'directorist_user_email_unverified', true ); if ( $is_user_unverified ) { @@ -567,10 +603,10 @@ public function manage_users_custom_column( $column_value, $column_name, $user_i } elseif ( 'general' === $user_type ) { return esc_html__( 'User', 'directorist' ); } elseif ( 'become_author' === $user_type ) { - $author_pending = "<p>Author <span style='color:red;'>( " . esc_html__('Pending', 'directorist') . " )</span></p>"; - $approve = "<a href='' id='atbdp-user-type-approve' style='color: #388E3C' data-userId={$user_id} data-nonce=". wp_create_nonce( 'atbdp_user_type_approve' ) ."><span>" . esc_html__('Approve', 'directorist') . " </span></a> | "; - $deny = "<a href='' id='atbdp-user-type-deny' style='color: red' data-userId={$user_id} data-nonce=". wp_create_nonce( 'atbdp_user_type_deny' ) ."><span>" . esc_html__('Deny', 'directorist') . "</span></a>"; - return "<div class='atbdp-user-type' id='user-type-". $user_id ."'>" .$author_pending . $approve . $deny . "</div>"; + $author_pending = "<p>Author <span style='color:red;'>( " . esc_html__( 'Pending', 'directorist' ) . ' )</span></p>'; + $approve = "<a href='' id='atbdp-user-type-approve' style='color: #388E3C' data-userId={$user_id} data-nonce=" . wp_create_nonce( 'atbdp_user_type_approve' ) . '><span>' . esc_html__( 'Approve', 'directorist' ) . ' </span></a> | '; + $deny = "<a href='' id='atbdp-user-type-deny' style='color: red' data-userId={$user_id} data-nonce=" . wp_create_nonce( 'atbdp_user_type_deny' ) . '><span>' . esc_html__( 'Deny', 'directorist' ) . '</span></a>'; + return "<div class='atbdp-user-type' id='user-type-" . $user_id . "'>" . $author_pending . $approve . $deny . '</div>'; } } @@ -585,7 +621,7 @@ public function manage_users_custom_column( $column_value, $column_name, $user_i * @return array */ function manage_users_columns( $columns ) { - if(directorist_is_email_verification_enabled()) { + if ( directorist_is_email_verification_enabled() ) { $columns['directorist_email_verified'] = esc_html__( 'Email Verified?', 'directorist' ); } $columns['user_type'] = esc_html__( 'User Type', 'directorist' ); @@ -593,15 +629,15 @@ function manage_users_columns( $columns ) { } // public function user_functions_ready_hook() { - // //Allow Contributors/Subscriber/Customer to Add Media - // $roles = (array) wp_get_current_user()->roles; - - // if ( ( in_array( 'contributor', $roles ) || - // in_array( 'subscriber', $roles ) || - // in_array( 'customer', $roles ) ) && - // ! current_user_can( 'upload_files' ) ) { - // add_action( 'init', array( $this, 'allow_contributor_uploads' ) ); - // } + // Allow Contributors/Subscriber/Customer to Add Media + // $roles = (array) wp_get_current_user()->roles; + + // if ( ( in_array( 'contributor', $roles ) || + // in_array( 'subscriber', $roles ) || + // in_array( 'customer', $roles ) ) && + // ! current_user_can( 'upload_files' ) ) { + // add_action( 'init', array( $this, 'allow_contributor_uploads' ) ); + // } // } /** @@ -610,25 +646,25 @@ function manage_users_columns( $columns ) { * @return void */ // public function allow_contributor_uploads() { - // $roles = (array) wp_get_current_user()->roles; - - // // contributor - // if ( in_array( 'contributor', $roles ) ){ - // $contributor = get_role( 'contributor' ); - // $contributor->add_cap( 'upload_files' ); - // } - - // // subscriber - // if ( in_array( 'subscriber', $roles ) ){ - // $subscriber = get_role( 'subscriber' ); - // $subscriber->add_cap( 'upload_files' ); - // } - - // // customer - // if ( in_array( 'customer', $roles ) ){ - // $customer = get_role( 'customer' ); - // $customer->add_cap( 'upload_files' ); - // } + // $roles = (array) wp_get_current_user()->roles; + + // contributor + // if ( in_array( 'contributor', $roles ) ){ + // $contributor = get_role( 'contributor' ); + // $contributor->add_cap( 'upload_files' ); + // } + + // subscriber + // if ( in_array( 'subscriber', $roles ) ){ + // $subscriber = get_role( 'subscriber' ); + // $subscriber->add_cap( 'upload_files' ); + // } + + // customer + // if ( in_array( 'customer', $roles ) ){ + // $customer = get_role( 'customer' ); + // $customer->add_cap( 'upload_files' ); + // } // } public function activate_user() { @@ -636,20 +672,21 @@ public function activate_user() { if ( $user_id ) { // get user meta activation hash field $code = get_user_meta( $user_id, 'has_to_be_activated', true ); - $key = filter_input( INPUT_GET, 'key' ); + $key = filter_input( INPUT_GET, 'key' ); if ( $code == $key ) { delete_user_meta( $user_id, 'has_to_be_activated' ); - wp_safe_redirect(ATBDP_Permalink::get_login_page_link()); + wp_safe_redirect( ATBDP_Permalink::get_login_page_link() ); } } } - public function registration_form( ) { - ATBDP()->load_template('front-end/user-registration-form'); + public function registration_form() { + ATBDP()->load_template( 'front-end/user-registration-form' ); } /** * It registers a user. It is a private function, All the vars this function uses will be passed into it after proper validation and sanitization + * * @param $username * @param $password * @param $email @@ -659,9 +696,9 @@ public function registration_form( ) { * @param $bio * @return bool|int|WP_Error */ - private function complete_registration($username, $password, $email, $website, $first_name, $last_name, $bio) { - global $reg_errors, $username, $password, $email, $website, $first_name, $last_name, $bio; - $reg_errors = new WP_Error; + private function complete_registration( $username, $password, $email, $website, $first_name, $last_name, $bio ) { + global $reg_errors, $username, $password, $email, $website, $first_name, $last_name, $bio; + $reg_errors = new WP_Error(); if ( 1 > count( $reg_errors->get_error_messages() ) ) { $userdata = array( @@ -681,113 +718,115 @@ private function complete_registration($username, $password, $email, $website, $ return false; } - public function registration_validation( $username, $password, $email, $website, $first_name, $last_name, $bio, $user_type, $privacy_policy, $t_c_check ) { + public function registration_validation( $username, $password, $email, $website, $first_name, $last_name, $bio, $user_type, $privacy_policy, $t_c_check ) { global $reg_errors; - $require_website = get_directorist_option('require_website_reg',0); - $display_website = get_directorist_option('display_website_reg',1); - $display_fname = get_directorist_option('display_fname_reg',1); - $require_fname = get_directorist_option('require_fname_reg',0); - $display_lname = get_directorist_option('display_lname_reg',1); - $require_lname = get_directorist_option('require_lname_reg',0); - $display_user_type = get_directorist_option('display_user_type',0); - $display_bio = get_directorist_option('display_bio_reg',1); - $require_bio = get_directorist_option('require_bio_reg',0); - $display_password = get_directorist_option('display_password_reg',1); - $require_password = get_directorist_option('require_password_reg',0); - $registration_privacy = get_directorist_option('registration_privacy',1); - $terms_condition = get_directorist_option('regi_terms_condition',1); - //password validation - if(!empty($require_password) && !empty($display_password) && empty($password)){ + $require_website = get_directorist_option( 'require_website_reg', 0 ); + $display_website = get_directorist_option( 'display_website_reg', 1 ); + $display_fname = get_directorist_option( 'display_fname_reg', 1 ); + $require_fname = get_directorist_option( 'require_fname_reg', 0 ); + $display_lname = get_directorist_option( 'display_lname_reg', 1 ); + $require_lname = get_directorist_option( 'require_lname_reg', 0 ); + $display_user_type = get_directorist_option( 'display_user_type', 0 ); + $display_bio = get_directorist_option( 'display_bio_reg', 1 ); + $require_bio = get_directorist_option( 'require_bio_reg', 0 ); + $display_password = get_directorist_option( 'display_password_reg', 1 ); + $require_password = get_directorist_option( 'require_password_reg', 0 ); + $registration_privacy = get_directorist_option( 'registration_privacy', 1 ); + $terms_condition = get_directorist_option( 'regi_terms_condition', 1 ); + // password validation + if ( ! empty( $require_password ) && ! empty( $display_password ) && empty( $password ) ) { $password_validation = 'yes'; } - //website validation - if(!empty($require_website) && !empty($display_website) && empty($website)){ + // website validation + if ( ! empty( $require_website ) && ! empty( $display_website ) && empty( $website ) ) { $website_validation = 'yes'; } - //first name validation - if(!empty($require_fname) && !empty($display_fname) && empty($first_name)){ + // first name validation + if ( ! empty( $require_fname ) && ! empty( $display_fname ) && empty( $first_name ) ) { $fname_validation = 'yes'; } - //last name validation - if(!empty($require_lname) && !empty($display_lname) && empty($last_name)){ + // last name validation + if ( ! empty( $require_lname ) && ! empty( $display_lname ) && empty( $last_name ) ) { $lname_validation = 'yes'; } - //user type validation - if( ! empty( $display_user_type ) && empty( $user_type ) ) { + // user type validation + if ( ! empty( $display_user_type ) && empty( $user_type ) ) { $user_type_validation = 'yes'; } - //bio validation - if(!empty($require_bio) && !empty($display_bio) && empty($bio)){ + // bio validation + if ( ! empty( $require_bio ) && ! empty( $display_bio ) && empty( $bio ) ) { $bio_validation = 'yes'; } - //privacy validation - if(!empty($registration_privacy) && empty($privacy_policy)){ + // privacy validation + if ( ! empty( $registration_privacy ) && empty( $privacy_policy ) ) { $privacy_validation = 'yes'; } - //terms & conditions validation - if(!empty($terms_condition) && empty($t_c_check)){ + // terms & conditions validation + if ( ! empty( $terms_condition ) && empty( $t_c_check ) ) { $t_c_validation = 'yes'; } - $reg_errors = new WP_Error; - if ( empty( $username ) || !empty( $password_validation ) || empty( $email ) || !empty($website_validation) || !empty($fname_validation) || !empty($lname_validation) || !empty($bio_validation) || !empty($privacy_validation) || !empty($t_c_validation) || ! empty( $user_type_validation ) ) { - $reg_errors->add('field', esc_html__('Required form field is missing. Please fill all required fields.', 'directorist')); + $reg_errors = new WP_Error(); + if ( empty( $username ) || ! empty( $password_validation ) || empty( $email ) || ! empty( $website_validation ) || ! empty( $fname_validation ) || ! empty( $lname_validation ) || ! empty( $bio_validation ) || ! empty( $privacy_validation ) || ! empty( $t_c_validation ) || ! empty( $user_type_validation ) ) { + $reg_errors->add( 'field', esc_html__( 'Required form field is missing. Please fill all required fields.', 'directorist' ) ); } - if (!empty( $username ) && 4 > strlen( $username ) ) { - $reg_errors->add( 'username_length', esc_html__('Username too short. At least 4 characters is required', 'directorist') ); + if ( ! empty( $username ) && 4 > strlen( $username ) ) { + $reg_errors->add( 'username_length', esc_html__( 'Username too short. At least 4 characters is required', 'directorist' ) ); } - if ( username_exists( $username ) ) - $reg_errors->add('user_name', esc_html__('Sorry, that username already exists!', 'directorist')); + if ( username_exists( $username ) ) { + $reg_errors->add( 'user_name', esc_html__( 'Sorry, that username already exists!', 'directorist' ) ); + } - if ( preg_match('/\s/',$username)) - $reg_errors->add('space_in_username', esc_html__('Sorry, space is not allowed in username!', 'directorist')); + if ( preg_match( '/\s/', $username ) ) { + $reg_errors->add( 'space_in_username', esc_html__( 'Sorry, space is not allowed in username!', 'directorist' ) ); + } if ( ! validate_username( $username ) ) { - $reg_errors->add( 'username_invalid', esc_html__('Sorry, the username you entered is not valid', 'directorist') ); + $reg_errors->add( 'username_invalid', esc_html__( 'Sorry, the username you entered is not valid', 'directorist' ) ); } if ( ! empty( $password ) && 5 > strlen( $password ) ) { - $reg_errors->add( 'password', esc_html__('Password length must be greater than 5', 'directorist') ); + $reg_errors->add( 'password', esc_html__( 'Password length must be greater than 5', 'directorist' ) ); } if ( empty( $privacy_policy ) ) { - $reg_errors->add( 'empty_privacy', esc_html__('Privacy field is required', 'directorist') ); + $reg_errors->add( 'empty_privacy', esc_html__( 'Privacy field is required', 'directorist' ) ); } if ( empty( $t_c_check ) ) { - $reg_errors->add( 'empty_terms', esc_html__('Terms and Condition field is required', 'directorist') ); + $reg_errors->add( 'empty_terms', esc_html__( 'Terms and Condition field is required', 'directorist' ) ); } if ( empty( $user_type_validation ) ) { - $reg_errors->add( 'empty_terms', esc_html__('Terms and Condition field is required', 'directorist') ); + $reg_errors->add( 'empty_terms', esc_html__( 'Terms and Condition field is required', 'directorist' ) ); } - if ( !is_email( $email ) ) { - $reg_errors->add( 'email_invalid', esc_html__('Email is not valid', 'directorist') ); + if ( ! is_email( $email ) ) { + $reg_errors->add( 'email_invalid', esc_html__( 'Email is not valid', 'directorist' ) ); } if ( email_exists( $email ) ) { - $reg_errors->add( 'email', esc_html__('Email Already in use', 'directorist') ); + $reg_errors->add( 'email', esc_html__( 'Email Already in use', 'directorist' ) ); } if ( ! empty( $first_name ) ) { - if (!is_string($first_name)) { - $reg_errors->add('First Name', esc_html__('First Name must be letters or combination of letters and number', 'directorist')); + if ( ! is_string( $first_name ) ) { + $reg_errors->add( 'First Name', esc_html__( 'First Name must be letters or combination of letters and number', 'directorist' ) ); } } if ( ! empty( $last_name ) ) { - if (!is_string($last_name)) { - $reg_errors->add('Last Name', esc_html__('Last Name must be letters or combination of letters and number', 'directorist')); + if ( ! is_string( $last_name ) ) { + $reg_errors->add( 'Last Name', esc_html__( 'Last Name must be letters or combination of letters and number', 'directorist' ) ); } } if ( ! empty( $website ) ) { if ( ! filter_var( $website, FILTER_VALIDATE_URL ) ) { - $reg_errors->add( 'website', esc_html__('Website is not a valid URL', 'directorist') ); + $reg_errors->add( 'website', esc_html__( 'Website is not a valid URL', 'directorist' ) ); } } // if we have errors then returns a string of error message. $e = $reg_errors->get_error_messages(); // save the errors in a placeholder var as we can not use function inside empty() until php 5.5. - if ( is_wp_error( $reg_errors ) && !empty($e) ) { - //@todo; errors should be kept in the session using a helper function so that we can get all the errors after redirection + if ( is_wp_error( $reg_errors ) && ! empty( $e ) ) { + // @todo; errors should be kept in the session using a helper function so that we can get all the errors after redirection $err_msg = ''; foreach ( $reg_errors->get_error_messages() as $error ) { $err_msg .= '<div>'; @@ -796,11 +835,10 @@ public function registration_validation( $username, $password, $email, $website, $err_msg .= '</div>'; } - return apply_filters('atbdp_registration_error', $err_msg); + return apply_filters( 'atbdp_registration_error', $err_msg ); } return 'passed'; - } public function handle_user_registration() { @@ -825,6 +863,7 @@ public function handle_user_registration() { /** * It fires before processing a submitted registration from the front end + * * @param array $_POST the array containing the submitted listing data. * @since 4.4.0 * */ @@ -841,117 +880,123 @@ public function handle_user_registration() { $privacy_policy = ! empty( $_POST['privacy_policy'] ) ? directorist_clean( wp_unslash( $_POST['privacy_policy'] ) ) : ''; $t_c_check = ! empty( $_POST['t_c_check'] ) ? directorist_clean( wp_unslash( $_POST['t_c_check'] ) ) : ''; - //password validation + // password validation if ( ! empty( $require_password ) && ! empty( $display_password ) && empty( $password ) ) { $password_validation = 'yes'; } - //website validation + // website validation if ( ! empty( $require_website ) && ! empty( $display_website ) && empty( $website ) ) { $website_validation = 'yes'; } - //first name validation + // first name validation if ( ! empty( $require_fname ) && ! empty( $display_fname ) && empty( $first_name ) ) { $fname_validation = 'yes'; } - //last name validation - if ( ! empty( $require_lname ) && !empty( $display_lname ) && empty( $last_name ) ) { + // last name validation + if ( ! empty( $require_lname ) && ! empty( $display_lname ) && empty( $last_name ) ) { $lname_validation = 'yes'; } - //bio validation - if(!empty($require_bio) && !empty($display_bio) && empty($bio)){ + // bio validation + if ( ! empty( $require_bio ) && ! empty( $display_bio ) && empty( $bio ) ) { $bio_validation = 'yes'; } - if( ! empty( $display_user_type ) && empty( $user_type) ) { + if ( ! empty( $display_user_type ) && empty( $user_type ) ) { $user_type_validation = 'yes'; } - //privacy validation - if(!empty($registration_privacy) && empty($privacy_policy)){ + // privacy validation + if ( ! empty( $registration_privacy ) && empty( $privacy_policy ) ) { $privacy_validation = 'yes'; } - //terms & conditions validation - if(!empty($terms_condition) && empty($t_c_check)){ + // terms & conditions validation + if ( ! empty( $terms_condition ) && empty( $t_c_check ) ) { $t_c_validation = 'yes'; } // validate all the inputs $validation = $this->registration_validation( $username, $password, $email, $website, $first_name, $last_name, $bio, $user_type, $privacy_policy, $t_c_check ); - if ( 'passed' !== $validation ){ - if (empty( $username ) || !empty( $password_validation ) || empty( $email ) || !empty($website_validation) || !empty($fname_validation) || !empty($lname_validation) || !empty($bio_validation)|| !empty($privacy_validation)|| !empty($t_c_validation)){ - wp_safe_redirect(ATBDP_Permalink::get_registration_page_link(array('errors' => 1))); + if ( 'passed' !== $validation ) { + if ( empty( $username ) || ! empty( $password_validation ) || empty( $email ) || ! empty( $website_validation ) || ! empty( $fname_validation ) || ! empty( $lname_validation ) || ! empty( $bio_validation ) || ! empty( $privacy_validation ) || ! empty( $t_c_validation ) ) { + wp_safe_redirect( ATBDP_Permalink::get_registration_page_link( array( 'errors' => 1 ) ) ); exit(); - }elseif(email_exists($email)){ - wp_safe_redirect(ATBDP_Permalink::get_registration_page_link(array('errors' => 2))); + } elseif ( email_exists( $email ) ) { + wp_safe_redirect( ATBDP_Permalink::get_registration_page_link( array( 'errors' => 2 ) ) ); exit(); - }elseif(!empty( $username ) && 4 > strlen( $username ) ){ - wp_safe_redirect(ATBDP_Permalink::get_registration_page_link(array('errors' => 3))); + } elseif ( ! empty( $username ) && 4 > strlen( $username ) ) { + wp_safe_redirect( ATBDP_Permalink::get_registration_page_link( array( 'errors' => 3 ) ) ); exit(); - }elseif(!empty( $username ) && preg_match('/\s/',$username) ){ - wp_safe_redirect(ATBDP_Permalink::get_registration_page_link(array('errors' => 7))); + } elseif ( ! empty( $username ) && preg_match( '/\s/', $username ) ) { + wp_safe_redirect( ATBDP_Permalink::get_registration_page_link( array( 'errors' => 7 ) ) ); exit(); - }elseif( username_exists( $username )){ - wp_safe_redirect(ATBDP_Permalink::get_registration_page_link(array('errors' => 4))); + } elseif ( username_exists( $username ) ) { + wp_safe_redirect( ATBDP_Permalink::get_registration_page_link( array( 'errors' => 4 ) ) ); exit(); - }elseif(! empty( $password ) && 5 > strlen( $password )){ - wp_safe_redirect(ATBDP_Permalink::get_registration_page_link(array('errors' => 5))); + } elseif ( ! empty( $password ) && 5 > strlen( $password ) ) { + wp_safe_redirect( ATBDP_Permalink::get_registration_page_link( array( 'errors' => 5 ) ) ); exit(); - }elseif(!is_email( $email )){ - wp_safe_redirect(ATBDP_Permalink::get_registration_page_link(array('errors' => 6))); + } elseif ( ! is_email( $email ) ) { + wp_safe_redirect( ATBDP_Permalink::get_registration_page_link( array( 'errors' => 6 ) ) ); exit(); - } elseif( ! empty( $user_type_validation ) ) { - wp_safe_redirect(ATBDP_Permalink::get_registration_page_link(array('errors' => 8))); + } elseif ( ! empty( $user_type_validation ) ) { + wp_safe_redirect( ATBDP_Permalink::get_registration_page_link( array( 'errors' => 8 ) ) ); exit(); } } // sanitize user form input global $username, $password, $email, $website, $first_name, $last_name, $bio; - $username = directorist_clean( wp_unslash( $_POST['username'] ) ); + $username = directorist_clean( wp_unslash( $_POST['username'] ) ); - if (empty($display_password) || empty($_POST['password'])){ - $password = wp_generate_password( 12, false ); + if ( empty( $display_password ) || empty( $_POST['password'] ) ) { + $password = wp_generate_password( 12, false ); } else { - $password = $_POST['password']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash + $password = $_POST['password']; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash } - $email = !empty($_POST['email']) ? sanitize_email( wp_unslash( $_POST['email'] ) ) : ''; - $website = !empty($_POST['website']) ? directorist_clean( $_POST['website'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash - $first_name = !empty($_POST['fname']) ? directorist_clean( wp_unslash( $_POST['fname'] ) ) : ''; - $last_name = !empty($_POST['lname']) ? directorist_clean( wp_unslash( $_POST['lname'] ) ) : ''; - $user_type = !empty($_POST['user_type']) ? directorist_clean( wp_unslash( $_POST['user_type'] ) ) : ''; - $bio = !empty($_POST['bio']) ? sanitize_textarea_field( wp_unslash( $_POST['bio'] ) ) : ''; - $previous_page = !empty($_POST['previous_page']) ? directorist_clean( $_POST['previous_page'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash + $email = ! empty( $_POST['email'] ) ? sanitize_email( wp_unslash( $_POST['email'] ) ) : ''; + $website = ! empty( $_POST['website'] ) ? directorist_clean( $_POST['website'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash + $first_name = ! empty( $_POST['fname'] ) ? directorist_clean( wp_unslash( $_POST['fname'] ) ) : ''; + $last_name = ! empty( $_POST['lname'] ) ? directorist_clean( wp_unslash( $_POST['lname'] ) ) : ''; + $user_type = ! empty( $_POST['user_type'] ) ? directorist_clean( wp_unslash( $_POST['user_type'] ) ) : ''; + $bio = ! empty( $_POST['bio'] ) ? sanitize_textarea_field( wp_unslash( $_POST['bio'] ) ) : ''; + $previous_page = ! empty( $_POST['previous_page'] ) ? directorist_clean( $_POST['previous_page'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash // call @function complete_registration to create the user // only when no WP_error is found - $user_id = $this->complete_registration($username, $password, $email, $website, $first_name, $last_name, $bio); - if ($user_id && !is_wp_error( $user_id )) { + $user_id = $this->complete_registration( $username, $password, $email, $website, $first_name, $last_name, $bio ); + if ( $user_id && ! is_wp_error( $user_id ) ) { /* * @since 6.3.0 * If fires after completed user registration */ - do_action('atbdp_user_registration_completed', $user_id); - update_user_meta($user_id, '_atbdp_generated_password', $password); - update_user_meta($user_id, '_atbdp_privacy', $privacy_policy); - update_user_meta($user_id, '_user_type', $user_type); - update_user_meta($user_id, '_atbdp_terms_and_conditions', $t_c_check); + do_action( 'atbdp_user_registration_completed', $user_id ); + update_user_meta( $user_id, '_atbdp_generated_password', $password ); + update_user_meta( $user_id, '_atbdp_privacy', $privacy_policy ); + update_user_meta( $user_id, '_user_type', $user_type ); + update_user_meta( $user_id, '_atbdp_terms_and_conditions', $t_c_check ); // user has been created successfully, now work on activation process - wp_new_user_notification($user_id, null, 'admin'); // send activation to the admin + wp_new_user_notification( $user_id, null, 'admin' ); // send activation to the admin if ( directorist_is_email_verification_enabled() ) { ATBDP()->email->send_user_confirmation_email( get_user_by( 'ID', $user_id ) ); - wp_safe_redirect( esc_url_raw( ATBDP_Permalink::get_login_page_link( array( - 'user' => $email, - 'verification' => 1, - ) ) ) ); + wp_safe_redirect( + esc_url_raw( + ATBDP_Permalink::get_login_page_link( + array( + 'user' => $email, + 'verification' => 1, + ) + ) + ) + ); exit(); } - ATBDP()->email->custom_wp_new_user_notification_email($user_id); + ATBDP()->email->custom_wp_new_user_notification_email( $user_id ); - $redirection_after_reg = get_directorist_option( 'redirection_after_reg'); + $redirection_after_reg = get_directorist_option( 'redirection_after_reg' ); $auto_login = get_directorist_option( 'auto_login' ); if ( ! empty( $auto_login ) ) { @@ -960,71 +1005,69 @@ public function handle_user_registration() { } if ( ! empty( $redirection_after_reg ) ) { - wp_safe_redirect( esc_url_raw( ATBDP_Permalink::get_reg_redirection_page_link( $previous_page, array( 'registration_status' => true ) ) ) ); + wp_safe_redirect( esc_url_raw( ATBDP_Permalink::get_reg_redirection_page_link( $previous_page, array( 'registration_status' => true ) ) ) ); } else { wp_safe_redirect( esc_url_raw( ATBDP_Permalink::get_registration_page_link( array( 'registration_status' => true ) ) ) ); } exit(); } else { - wp_safe_redirect( esc_url_raw( ATBDP_Permalink::get_registration_page_link(array('errors' => true ) ) ) ); + wp_safe_redirect( esc_url_raw( ATBDP_Permalink::get_registration_page_link( array( 'errors' => true ) ) ) ); exit(); } } public function user_dashboard() { // load user dashboard on the front end - ATBDP()->load_template('front-end/user-dashboard'); + ATBDP()->load_template( 'front-end/user-dashboard' ); } /** * It returns all the listing of the current user + * * @return WP_Query it returns an object of the WP_Query class with the items/listings on success and false on failure. - - */ - public function current_user_listings() - { + */ + public function current_user_listings() { return ATBDP()->listing->db->get_listing_by_user(); // it returns all the listing of the current user. } /** * It returns all the favraites listing of the current user + * * @return WP_Query it returns an object of the WP_Query class with the items/listings on success and false on failure. - - */ - public function current_user_fav_listings() - { + */ + public function current_user_fav_listings() { _deprecated_function( __METHOD__, '7.4.3', 'DB::favorite_listings_query' ); return DB::favorite_listings_query(); } /** * It updates the user profile and meta data + * * @param array $data the user data to update. * @return bool It returns true on success and false on failure */ - public function update_profile($data) - { + public function update_profile( $data ) { $userdata = array(); // we need to sanitize the data and then save it. - $ID = get_current_user_id(); - $userdata['ID'] = $ID; - $userdata['display_name'] = !empty($data['full_name']) ? sanitize_text_field(trim($data['full_name'])) : ''; - $userdata['user_email'] = !empty($data['user_email']) ? sanitize_email($data['user_email'] ): ''; - $userdata['user_url'] = !empty($data['website']) ? sanitize_url(trim($data['website'] )): ''; - $phone = !empty($data['phone']) ? sanitize_text_field(trim($data['phone'] )): ''; - $first_name = !empty($data['first_name']) ? sanitize_text_field(trim($data['first_name'])) : ''; - $last_name = !empty($data['last_name']) ? sanitize_text_field(trim($data['last_name'] )): ''; - $address = !empty($data['address']) ? sanitize_text_field(trim($data['address'] )): ''; - $facebook = !empty($data['facebook']) ? sanitize_url(trim($data['facebook'] )): ''; - $twitter = !empty($data['twitter']) ? sanitize_url(trim($data['twitter'] )): ''; - $linkedIn = !empty($data['linkedIn']) ? sanitize_url(trim($data['linkedIn'] )): ''; - $youtube = !empty($data['youtube']) ? sanitize_url(trim($data['youtube'] )): ''; - $bio = !empty($data['bio']) ? sanitize_textarea_field(trim($data['bio'] )): ''; - $new_pass = !empty($data['new_pass']) ? $data['new_pass'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash - $confirm_pass = !empty($data['confirm_pass']) ? $data['confirm_pass']: ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash + $ID = get_current_user_id(); + $userdata['ID'] = $ID; + $userdata['display_name'] = ! empty( $data['full_name'] ) ? sanitize_text_field( trim( $data['full_name'] ) ) : ''; + $userdata['user_email'] = ! empty( $data['user_email'] ) ? sanitize_email( $data['user_email'] ) : ''; + $userdata['user_url'] = ! empty( $data['website'] ) ? sanitize_url( trim( $data['website'] ) ) : ''; + $phone = ! empty( $data['phone'] ) ? sanitize_text_field( trim( $data['phone'] ) ) : ''; + $first_name = ! empty( $data['first_name'] ) ? sanitize_text_field( trim( $data['first_name'] ) ) : ''; + $last_name = ! empty( $data['last_name'] ) ? sanitize_text_field( trim( $data['last_name'] ) ) : ''; + $address = ! empty( $data['address'] ) ? sanitize_text_field( trim( $data['address'] ) ) : ''; + $facebook = ! empty( $data['facebook'] ) ? sanitize_url( trim( $data['facebook'] ) ) : ''; + $twitter = ! empty( $data['twitter'] ) ? sanitize_url( trim( $data['twitter'] ) ) : ''; + $linkedIn = ! empty( $data['linkedIn'] ) ? sanitize_url( trim( $data['linkedIn'] ) ) : ''; + $youtube = ! empty( $data['youtube'] ) ? sanitize_url( trim( $data['youtube'] ) ) : ''; + $bio = ! empty( $data['bio'] ) ? sanitize_textarea_field( trim( $data['bio'] ) ) : ''; + $new_pass = ! empty( $data['new_pass'] ) ? $data['new_pass'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash + $confirm_pass = ! empty( $data['confirm_pass'] ) ? $data['confirm_pass'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash // now lets save the data to the db without password - $uid = wp_update_user($userdata); + $uid = wp_update_user( $userdata ); update_user_meta( $ID, 'address', $address ); update_user_meta( $ID, 'atbdp_facebook', $facebook ); update_user_meta( $ID, 'atbdp_twitter', $twitter ); @@ -1035,10 +1078,10 @@ public function update_profile($data) update_user_meta( $ID, 'last_name', $last_name ); update_user_meta( $ID, 'atbdp_phone', $phone ); - if (!empty($new_pass || $confirm_pass)){ + if ( ! empty( $new_pass || $confirm_pass ) ) { // password will be updated here - if ( ( $new_pass == $confirm_pass ) && ( strlen( $confirm_pass) > 5 ) ){ - wp_set_password($new_pass, $ID); // set the password to the database + if ( ( $new_pass == $confirm_pass ) && ( strlen( $confirm_pass ) > 5 ) ) { + wp_set_password( $new_pass, $ID ); // set the password to the database /** * Fire password changed action after successful password change * @@ -1050,43 +1093,39 @@ public function update_profile($data) * @param integer ID of the user who changed their password */ do_action( 'directorist_password_changed', $ID ); - }else{ - $pass_match = esc_html__('Password should be matched and more than five character', 'directorist'); - wp_send_json_error($pass_match, 'directorist'); + } else { + $pass_match = esc_html__( 'Password should be matched and more than five character', 'directorist' ); + wp_send_json_error( $pass_match, 'directorist' ); } } - if (!is_wp_error($uid)){ - $congz_txt = esc_html__('Congratulations! Your profile updated successfully', 'directorist'); - wp_send_json_success( $congz_txt, 'directorist'); + if ( ! is_wp_error( $uid ) ) { + $congz_txt = esc_html__( 'Congratulations! Your profile updated successfully', 'directorist' ); + wp_send_json_success( $congz_txt, 'directorist' ); return true; - }else{ - $ops_text = esc_html__('Oops! Something wrong.', 'directorist'); - wp_send_json_error($ops_text, 'directorist'); + } else { + $ops_text = esc_html__( 'Oops! Something wrong.', 'directorist' ); + wp_send_json_error( $ops_text, 'directorist' ); } - return false; // failed to save data, so return false - } /** * It prevent the user from showing other posts/listings on dashboard if he is not an admin + * * @param Object|WP_Query $query * @return Object|WP_Query */ - public function restrict_listing_to_the_author($query) - { + public function restrict_listing_to_the_author( $query ) { global $pagenow, $post_type; - - if( ATBDP_POST_TYPE == $post_type && 'edit.php' == $pagenow && $query->is_admin && !current_user_can( 'edit_others_'.ATBDP_POST_TYPE.'s' ) ){ + if ( ATBDP_POST_TYPE == $post_type && 'edit.php' == $pagenow && $query->is_admin && ! current_user_can( 'edit_others_' . ATBDP_POST_TYPE . 's' ) ) { global $user_ID; - $query->set('author', $user_ID ); + $query->set( 'author', $user_ID ); } - return $query; } - } // ends ATBDP_User + } // ends ATBDP_User endif; \ No newline at end of file diff --git a/includes/custom-actions.php b/includes/custom-actions.php index 3493abbe6b..cde17fe120 100644 --- a/includes/custom-actions.php +++ b/includes/custom-actions.php @@ -1,27 +1,27 @@ <?php /*This file will contain most common actions that will help other developer extends / modify our plugin settings or design */ -function atbdp_after_new_listing_button() -{ - do_action('atbdp_after_new_listing_button'); +function atbdp_after_new_listing_button() { + do_action( 'atbdp_after_new_listing_button' ); } -function atbdp_create_picvacyAndTerms_pages() -{ - - $create_permission = apply_filters('atbdp_create_required_pages', true); - if ($create_permission) { - $options = get_option('atbdp_option'); - $page_exists = get_option('atbdp_picvacyAndTerms_pages'); - // $op_name is the page option name in the database. - // if we do not have the page id assigned in the settings with the given page option name, then create an page - // and update the option. - $id = array(); - $Old_terms = get_directorist_option('listing_terms_condition_text'); - $pages = apply_filters('atbdp_create_picvacyAndTerms_pages', array( - 'privacy_policy' => array( - 'title' => __('Privacy Policy', 'directorist'), - 'content' => '<!-- wp:heading --> +function atbdp_create_picvacyAndTerms_pages() { + + $create_permission = apply_filters( 'atbdp_create_required_pages', true ); + if ( $create_permission ) { + $options = get_option( 'atbdp_option' ); + $page_exists = get_option( 'atbdp_picvacyAndTerms_pages' ); + // $op_name is the page option name in the database. + // if we do not have the page id assigned in the settings with the given page option name, then create an page + // and update the option. + $id = array(); + $Old_terms = get_directorist_option( 'listing_terms_condition_text' ); + $pages = apply_filters( + 'atbdp_create_picvacyAndTerms_pages', + array( + 'privacy_policy' => array( + 'title' => __( 'Privacy Policy', 'directorist' ), + 'content' => '<!-- wp:heading --> <h2>Who we are</h2> <!-- /wp:heading --> @@ -123,75 +123,91 @@ function atbdp_create_picvacyAndTerms_pages() <!-- wp:heading {"level":3} --> <h3>Industry regulatory disclosure requirements</h3> -<!-- /wp:heading -->' - ), - 'terms_conditions' => array( - 'title' => __('Terms and Conditions', 'directorist'), - 'content' => $Old_terms - ), - )); - if (!$page_exists) { - foreach ($pages as $op_name => $page_settings) { - $id = wp_insert_post( - array( - 'post_title' => $page_settings['title'], - 'post_content' => $page_settings['content'], - 'post_status' => 'publish', - 'post_type' => 'page', - 'comment_status' => 'closed' - ) - ); - $options[$op_name] = (int)$id; - } - } - // if we have new options then lets update the options with new option values. - if ($id) { - update_option('atbdp_picvacyAndTerms_pages', 1); - update_option('atbdp_option', $options); - }; - } +<!-- /wp:heading -->', + ), + 'terms_conditions' => array( + 'title' => __( 'Terms and Conditions', 'directorist' ), + 'content' => $Old_terms, + ), + ) + ); + if ( ! $page_exists ) { + foreach ( $pages as $op_name => $page_settings ) { + $id = wp_insert_post( + array( + 'post_title' => $page_settings['title'], + 'post_content' => $page_settings['content'], + 'post_status' => 'publish', + 'post_type' => 'page', + 'comment_status' => 'closed', + ) + ); + $options[ $op_name ] = (int) $id; + } + } + // if we have new options then lets update the options with new option values. + if ( $id ) { + update_option( 'atbdp_picvacyAndTerms_pages', 1 ); + update_option( 'atbdp_option', $options ); + } + } } // fire up the functionality for one time -/* if (!get_option('atbdp_picvacyAndTerms_pages')) { - add_action('wp_loaded', 'atbdp_create_picvacyAndTerms_pages'); +/* +if (!get_option('atbdp_picvacyAndTerms_pages')) { + add_action('wp_loaded', 'atbdp_create_picvacyAndTerms_pages'); } */ -function atbdp_handle_attachment($file_handler, $post_id, $set_thu = false) -{ - // check to make sure its a successful upload - if ( ! empty( $_FILES[$file_handler]['error'] ) && ( $_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK ) ) __return_false(); - - require_once(ABSPATH . "wp-admin" . '/includes/image.php'); - require_once(ABSPATH . "wp-admin" . '/includes/file.php'); - require_once(ABSPATH . "wp-admin" . '/includes/media.php'); - - $attach_id = media_handle_upload($file_handler, $post_id); - if (is_numeric($attach_id)) { - update_post_meta($post_id, '_atbdp_listing_images', $attach_id); - } - return $attach_id; +function atbdp_handle_attachment( $file_handler, $post_id, $set_thu = false ) { + // check to make sure its a successful upload + if ( ! empty( $_FILES[ $file_handler ]['error'] ) && ( $_FILES[ $file_handler ]['error'] !== UPLOAD_ERR_OK ) ) { + __return_false(); + } + + require_once ABSPATH . 'wp-admin' . '/includes/image.php'; + require_once ABSPATH . 'wp-admin' . '/includes/file.php'; + require_once ABSPATH . 'wp-admin' . '/includes/media.php'; + + $attach_id = media_handle_upload( $file_handler, $post_id ); + if ( is_numeric( $attach_id ) ) { + update_post_meta( $post_id, '_atbdp_listing_images', $attach_id ); + } + return $attach_id; } -function atbdp_get_preview_button() -{ - $preview_enable = get_directorist_option('preview_enable', 1); - if (!empty($preview_enable)){ - if (isset($_GET['redirect'])) { - $payment = isset($_GET['payment']) ? directorist_clean( wp_unslash( $_GET['payment'] ) ) : ''; - $id = isset($_GET['p']) ? directorist_clean( wp_unslash( $_GET['p'] ) ) : ''; - $post_id = isset($_GET['post_id']) ? directorist_clean( wp_unslash( $_GET['post_id'] ) ) : get_the_ID(); - $edited = isset($_GET['edited']) ? directorist_clean( wp_unslash( $_GET['edited'] ) ) : ''; - $redirect = directorist_clean( wp_unslash( $_GET['redirect'] ) ); - $id = empty($id) ? $post_id : $id; - if (empty($payment)){ - $url = add_query_arg(array('p' => $id, 'post_id' => $id, 'reviewed' => 'yes', 'edited' => $edited ? 'yes' : 'no'), $redirect ); - }else{ - $url = add_query_arg(array('atbdp_listing_id' => $id, 'reviewed' => 'yes'), $redirect ); - } - return '<a href="' . esc_url($url) . '" class="btn btn-success">' . apply_filters('atbdp_listing_preview_btn_text', esc_html__(' Continue','directorist') ) . '</a>'; - } - } +function atbdp_get_preview_button() { + $preview_enable = get_directorist_option( 'preview_enable', 1 ); + if ( ! empty( $preview_enable ) ) { + if ( isset( $_GET['redirect'] ) ) { + $payment = isset( $_GET['payment'] ) ? directorist_clean( wp_unslash( $_GET['payment'] ) ) : ''; + $id = isset( $_GET['p'] ) ? directorist_clean( wp_unslash( $_GET['p'] ) ) : ''; + $post_id = isset( $_GET['post_id'] ) ? directorist_clean( wp_unslash( $_GET['post_id'] ) ) : get_the_ID(); + $edited = isset( $_GET['edited'] ) ? directorist_clean( wp_unslash( $_GET['edited'] ) ) : ''; + $redirect = directorist_clean( wp_unslash( $_GET['redirect'] ) ); + $id = empty( $id ) ? $post_id : $id; + if ( empty( $payment ) ) { + $url = add_query_arg( + array( + 'p' => $id, + 'post_id' => $id, + 'reviewed' => 'yes', + 'edited' => $edited ? 'yes' : 'no', + ), + $redirect + ); + } else { + $url = add_query_arg( + array( + 'atbdp_listing_id' => $id, + 'reviewed' => 'yes', + ), + $redirect + ); + } + return '<a href="' . esc_url( $url ) . '" class="btn btn-success">' . apply_filters( 'atbdp_listing_preview_btn_text', esc_html__( ' Continue', 'directorist' ) ) . '</a>'; + } + } } /** @@ -199,65 +215,64 @@ function atbdp_get_preview_button() * @return array plugin data * @since 6.2.3 */ - -function atbdp_get_plugin_data($plugin) -{ - $plugins = get_plugins(); - foreach ($plugins as $key => $data) { - if ($plugin === $key) { - return $data; - } - } +function atbdp_get_plugin_data( $plugin ) { + $plugins = get_plugins(); + foreach ( $plugins as $key => $data ) { + if ( $plugin === $key ) { + return $data; + } + } } -function atbdp_is_extension_active() -{ - if (class_exists('BD_Business_Hour') || class_exists('DCL_Base') || class_exists('Listings_fAQs') || class_exists('BD_Gallery') || class_exists('BD_Google_Recaptcha') || class_exists('BD_Map_View') || class_exists('Directorist_Paypal_Gateway') || class_exists('Post_Your_Need') || class_exists('ATBDP_Pricing_Plans') || class_exists('BD_Slider_Carousel') || class_exists('Directorist_Social_Login') || class_exists('Directorist_Stripe_Gateway') || class_exists('DWPP_Pricing_Plans') || class_exists('Directorist_Mark_as_Sold') || class_exists('Directorist_Live_Chat') || class_exists('BD_Booking') || class_exists('ATDListingCompare')) { - return true; - } else { - return false; - } +function atbdp_is_extension_active() { + if ( class_exists( 'BD_Business_Hour' ) || class_exists( 'DCL_Base' ) || class_exists( 'Listings_fAQs' ) || class_exists( 'BD_Gallery' ) || class_exists( 'BD_Google_Recaptcha' ) || class_exists( 'BD_Map_View' ) || class_exists( 'Directorist_Paypal_Gateway' ) || class_exists( 'Post_Your_Need' ) || class_exists( 'ATBDP_Pricing_Plans' ) || class_exists( 'BD_Slider_Carousel' ) || class_exists( 'Directorist_Social_Login' ) || class_exists( 'Directorist_Stripe_Gateway' ) || class_exists( 'DWPP_Pricing_Plans' ) || class_exists( 'Directorist_Mark_as_Sold' ) || class_exists( 'Directorist_Live_Chat' ) || class_exists( 'BD_Booking' ) || class_exists( 'ATDListingCompare' ) ) { + return true; + } else { + return false; + } } -function atbdp_extend_extension_settings_submenus($default) -{ - if ( apply_filters( 'atbdp_extension_license_settings_init', atbdp_is_extension_active() ) ) { - $array_license = array( - 'title' => __('Activate License', 'directorist'), - 'name' => 'extensions_license', - 'icon' => 'font-awesome:fa-id-card', - 'controls' => apply_filters('atbdp_license_settings_controls', array( - array( - 'type' => 'notebox', - 'name' => 'businedfssdfss_hours_license', - 'description' => sprintf(__('Enter your extension license keys here to receive updates for purchased extensions. Click %s to know more about licensing.', 'directorist'), '<a target="_blank" href="https://directorist.com/documentation/extensions/license">here</a>'), - 'status' => 'info', - ), - - )), - ); - array_push($default, $array_license); - } - return $default; +function atbdp_extend_extension_settings_submenus( $default ) { + if ( apply_filters( 'atbdp_extension_license_settings_init', atbdp_is_extension_active() ) ) { + $array_license = array( + 'title' => __( 'Activate License', 'directorist' ), + 'name' => 'extensions_license', + 'icon' => 'font-awesome:fa-id-card', + 'controls' => apply_filters( + 'atbdp_license_settings_controls', + array( + array( + 'type' => 'notebox', + 'name' => 'businedfssdfss_hours_license', + 'description' => sprintf( __( 'Enter your extension license keys here to receive updates for purchased extensions. Click %s to know more about licensing.', 'directorist' ), '<a target="_blank" href="https://directorist.com/documentation/extensions/license">here</a>' ), + 'status' => 'info', + ), + + ) + ), + ); + array_push( $default, $array_license ); + } + return $default; } -add_filter('atbdp_extension_settings_submenus', 'atbdp_extend_extension_settings_submenus'); +add_filter( 'atbdp_extension_settings_submenus', 'atbdp_extend_extension_settings_submenus' ); /** * @since 6.3.5 * @return URL if current theme has the file return the actual file path otherwise return false */ - if ( !function_exists('atbdp_get_file_path') ){ - function atbdp_get_theme_file( $path = null ) { - $file_path = get_theme_file_path( $path ); - if( file_exists( $file_path ) ){ - return $file_path; - }else{ - return false; - } - } - } +if ( ! function_exists( 'atbdp_get_file_path' ) ) { + function atbdp_get_theme_file( $path = null ) { + $file_path = get_theme_file_path( $path ); + if ( file_exists( $file_path ) ) { + return $file_path; + } else { + return false; + } + } +} /** @@ -265,255 +280,256 @@ function atbdp_get_theme_file( $path = null ) { * @return URL if current theme has the file return the actual file path otherwise return false */ -if(!function_exists('atbdp_country_code_to_name')){ - function atbdp_country_code_to_name(){ - $country_code_to_name = array( - 'AF' => 'Afghanistan', - 'AL' => 'Albania', - 'DZ' => 'Algeria', - 'AS' => 'American Samoa', - 'AD' => 'Andorra', - 'AO' => 'Angola', - 'AI' => 'Anguilla', - 'AQ' => 'Antarctica', - 'AG' => 'Antigua And Barbuda', - 'AR' => 'Argentina', - 'AM' => 'Armenia', - 'AW' => 'Aruba', - 'AU' => 'Australia', - 'AT' => 'Austria', - 'AZ' => 'Azerbaijan', - 'BS' => 'Bahamas, The', - 'BH' => 'Bahrain', - 'BD' => 'Bangladesh', - 'BB' => 'Barbados', - 'BY' => 'Belarus', - 'BE' => 'Belgium', - 'BZ' => 'Belize', - 'BJ' => 'Benin', - 'BM' => 'Bermuda', - 'BT' => 'Bhutan', - 'BO' => 'Bolivia', - 'BA' => 'Bosnia And Herzegovina', - 'BW' => 'Botswana', - 'BV' => 'Bouvet Island', - 'BR' => 'Brazil', - 'IO' => 'British Indian Ocean Territory', - 'BN' => 'Brunei', - 'BG' => 'Bulgaria', - 'BF' => 'Burkina Faso', - 'MM' => 'Burma', - 'BI' => 'Burundi', - 'KH' => 'Cambodia', - 'CM' => 'Cameroon', - 'CA' => 'Canada', - 'CV' => 'Cape Verde', - 'KY' => 'Cayman Islands', - 'CF' => 'Central African Republic', - 'TD' => 'Chad', - 'CL' => 'Chile', - 'CN' => 'China', - 'CX' => 'Christmas Island', - 'CC' => 'Cocos (keeling) Islands', - 'CO' => 'Colombia', - 'KM' => 'Comoros', - 'CG' => 'Congo (brazzaville) ', - 'CD' => 'Congo (kinshasa)', - 'CK' => 'Cook Islands', - 'CR' => 'Costa Rica', - 'CI' => 'CÔte D’ivoire', - 'HR' => 'Croatia', - 'CU' => 'Cuba', - 'CW' => 'CuraÇao', - 'CY' => 'Cyprus', - 'CZ' => 'Czech Republic', - 'DK' => 'Denmark', - 'DJ' => 'Djibouti', - 'DM' => 'Dominica', - 'DO' => 'Dominican Republic', - 'EC' => 'Ecuador', - 'EG' => 'Egypt', - 'SV' => 'El Salvador', - 'GQ' => 'Equatorial Guinea', - 'ER' => 'Eritrea', - 'EE' => 'Estonia', - 'ET' => 'Ethiopia', - 'FK' => 'Falkland Islands (islas Malvinas)', - 'FO' => 'Faroe Islands', - 'FJ' => 'Fiji', - 'FI' => 'Finland', - 'FR' => 'France', - 'GF' => 'French Guiana', - 'PF' => 'French Polynesia', - 'TF' => 'French Southern And Antarctic Lands', - 'GA' => 'Gabon', - 'GM' => 'Gambia, The', - 'GE' => 'Georgia', - 'DE' => 'Germany', - 'GH' => 'Ghana', - 'GI' => 'Gibraltar', - 'GR' => 'Greece', - 'GL' => 'Greenland', - 'GD' => 'Grenada', - 'GP' => 'Guadeloupe', - 'GU' => 'Guam', - 'GT' => 'Guatemala', - 'GG' => 'Guernsey', - 'GN' => 'Guinea', - 'GW' => 'Guinea-bissau', - 'GY' => 'Guyana', - 'HT' => 'Haiti', - 'HM' => 'Heard Island And Mcdonald Islands', - 'HN' => 'Honduras', - 'HK' => 'Hong Kong', - 'HU' => 'Hungary', - 'IS' => 'Iceland', - 'IN' => 'India', - 'ID' => 'Indonesia', - 'IR' => 'Iran', - 'IQ' => 'Iraq', - 'IE' => 'Ireland', - 'IM' => 'Isle Of Man', - 'IL' => 'Israel', - 'IT' => 'Italy', - 'JM' => 'Jamaica', - 'JP' => 'Japan', - 'JE' => 'Jersey', - 'JO' => 'Jordan', - 'KZ' => 'Kazakhstan', - 'KE' => 'Kenya', - 'KI' => 'Kiribati', - 'KP' => 'Korea, North', - 'KR' => 'Korea, South', - 'KW' => 'Kuwait', - 'KG' => 'Kyrgyzstan', - 'LA' => 'Laos', - 'LV' => 'Latvia', - 'LB' => 'Lebanon', - 'LS' => 'Lesotho', - 'LR' => 'Liberia', - 'LY' => 'Libya', - 'LI' => 'Liechtenstein', - 'LT' => 'Lithuania', - 'LU' => 'Luxembourg', - 'MO' => 'Macau', - 'MK' => 'Macedonia', - 'MG' => 'Madagascar', - 'MW' => 'Malawi', - 'MY' => 'Malaysia', - 'MV' => 'Maldives', - 'ML' => 'Mali', - 'MT' => 'Malta', - 'MH' => 'Marshall Islands', - 'MQ' => 'Martinique', - 'MR' => 'Mauritania', - 'MU' => 'Mauritius', - 'YT' => 'Mayotte', - 'MX' => 'Mexico', - 'FM' => 'Micronesia, Federated States Of', - 'MD' => 'Moldova', - 'MC' => 'Monaco', - 'MN' => 'Mongolia', - 'ME' => 'Montenegro', - 'MS' => 'Montserrat', - 'MA' => 'Morocco', - 'MZ' => 'Mozambique', - 'NA' => 'Namibia', - 'NR' => 'Nauru', - 'NP' => 'Nepal', - 'NL' => 'Netherlands', - 'NC' => 'New Caledonia', - 'NZ' => 'New Zealand', - 'NI' => 'Nicaragua', - 'NE' => 'Niger', - 'NG' => 'Nigeria', - 'NU' => 'Niue', - 'NF' => 'Norfolk Island', - 'MP' => 'Northern Mariana Islands', - 'NO' => 'Norway', - 'OM' => 'Oman', - 'PK' => 'Pakistan', - 'PW' => 'Palau', - 'PA' => 'Panama', - 'PG' => 'Papua New Guinea', - 'PY' => 'Paraguay', - 'PE' => 'Peru', - 'PH' => 'Philippines', - 'PN' => 'Pitcairn Islands', - 'PL' => 'Poland', - 'PT' => 'Portugal', - 'PR' => 'Puerto Rico', - 'QA' => 'Qatar', - 'RE' => 'Reunion', - 'RO' => 'Romania', - 'RU' => 'Russia', - 'RW' => 'Rwanda', - 'BL' => 'Saint Barthelemy', - 'SH' => 'Saint Helena, Ascension, And Tristan Da Cunha', - 'KN' => 'Saint Kitts And Nevis', - 'LC' => 'Saint Lucia', - 'MF' => 'Saint Martin', - 'PM' => 'Saint Pierre And Miquelon', - 'VC' => 'Saint Vincent And The Grenadines', - 'WS' => 'Samoa', - 'SM' => 'San Marino', - 'ST' => 'Sao Tome And Principe', - 'SA' => 'Saudi Arabia', - 'SN' => 'Senegal', - 'RS' => 'Serbia', - 'SC' => 'Seychelles', - 'SL' => 'Sierra Leone', - 'SG' => 'Singapore', - 'SX' => 'Sint Maarten', - 'SK' => 'Slovakia', - 'SI' => 'Slovenia', - 'SB' => 'Solomon Islands', - 'SO' => 'Somalia', - 'ZA' => 'South Africa', - 'GS' => 'South Georgia And South Sandwich Islands', - 'SS' => 'South Sudan', - 'ES' => 'Spain', - 'LK' => 'Sri Lanka', - 'SD' => 'Sudan', - 'SR' => 'Suriname', - 'SZ' => 'Swaziland', - 'SE' => 'Sweden', - 'CH' => 'Switzerland', - 'SY' => 'Syria', - 'TW' => 'Taiwan', - 'TJ' => 'Tajikistan', - 'TZ' => 'Tanzania', - 'TH' => 'Thailand', - 'TL' => 'Timor-leste', - 'TG' => 'Togo', - 'TK' => 'Tokelau', - 'TO' => 'Tonga', - 'TT' => 'Trinidad And Tobago', - 'TN' => 'Tunisia', - 'TR' => 'Turkey', - 'TM' => 'Turkmenistan', - 'TC' => 'Turks And Caicos Islands', - 'TV' => 'Tuvalu', - 'UG' => 'Uganda', - 'UA' => 'Ukraine', - 'AE' => 'United Arab Emirates', - 'GB' => 'United Kingdom', - 'US' => 'United States', - 'UY' => 'Uruguay', - 'UZ' => 'Uzbekistan', - 'VU' => 'Vanuatu', - 'VA' => 'Vatican City', - 'VE' => 'Venezuela', - 'VN' => 'Vietnam', - 'VG' => 'Virgin Islands, British', - 'VI' => 'Virgin Islands, United States ', - 'WF' => 'Wallis And Futuna', - 'EH' => 'Western Sahara', - 'YE' => 'Yemen', - 'ZM' => 'Zambia', - 'ZW' => 'Zimbabwe'); - return $country_code_to_name; - } +if ( ! function_exists( 'atbdp_country_code_to_name' ) ) { + function atbdp_country_code_to_name() { + $country_code_to_name = array( + 'AF' => 'Afghanistan', + 'AL' => 'Albania', + 'DZ' => 'Algeria', + 'AS' => 'American Samoa', + 'AD' => 'Andorra', + 'AO' => 'Angola', + 'AI' => 'Anguilla', + 'AQ' => 'Antarctica', + 'AG' => 'Antigua And Barbuda', + 'AR' => 'Argentina', + 'AM' => 'Armenia', + 'AW' => 'Aruba', + 'AU' => 'Australia', + 'AT' => 'Austria', + 'AZ' => 'Azerbaijan', + 'BS' => 'Bahamas, The', + 'BH' => 'Bahrain', + 'BD' => 'Bangladesh', + 'BB' => 'Barbados', + 'BY' => 'Belarus', + 'BE' => 'Belgium', + 'BZ' => 'Belize', + 'BJ' => 'Benin', + 'BM' => 'Bermuda', + 'BT' => 'Bhutan', + 'BO' => 'Bolivia', + 'BA' => 'Bosnia And Herzegovina', + 'BW' => 'Botswana', + 'BV' => 'Bouvet Island', + 'BR' => 'Brazil', + 'IO' => 'British Indian Ocean Territory', + 'BN' => 'Brunei', + 'BG' => 'Bulgaria', + 'BF' => 'Burkina Faso', + 'MM' => 'Burma', + 'BI' => 'Burundi', + 'KH' => 'Cambodia', + 'CM' => 'Cameroon', + 'CA' => 'Canada', + 'CV' => 'Cape Verde', + 'KY' => 'Cayman Islands', + 'CF' => 'Central African Republic', + 'TD' => 'Chad', + 'CL' => 'Chile', + 'CN' => 'China', + 'CX' => 'Christmas Island', + 'CC' => 'Cocos (keeling) Islands', + 'CO' => 'Colombia', + 'KM' => 'Comoros', + 'CG' => 'Congo (brazzaville) ', + 'CD' => 'Congo (kinshasa)', + 'CK' => 'Cook Islands', + 'CR' => 'Costa Rica', + 'CI' => 'CÔte D’ivoire', + 'HR' => 'Croatia', + 'CU' => 'Cuba', + 'CW' => 'CuraÇao', + 'CY' => 'Cyprus', + 'CZ' => 'Czech Republic', + 'DK' => 'Denmark', + 'DJ' => 'Djibouti', + 'DM' => 'Dominica', + 'DO' => 'Dominican Republic', + 'EC' => 'Ecuador', + 'EG' => 'Egypt', + 'SV' => 'El Salvador', + 'GQ' => 'Equatorial Guinea', + 'ER' => 'Eritrea', + 'EE' => 'Estonia', + 'ET' => 'Ethiopia', + 'FK' => 'Falkland Islands (islas Malvinas)', + 'FO' => 'Faroe Islands', + 'FJ' => 'Fiji', + 'FI' => 'Finland', + 'FR' => 'France', + 'GF' => 'French Guiana', + 'PF' => 'French Polynesia', + 'TF' => 'French Southern And Antarctic Lands', + 'GA' => 'Gabon', + 'GM' => 'Gambia, The', + 'GE' => 'Georgia', + 'DE' => 'Germany', + 'GH' => 'Ghana', + 'GI' => 'Gibraltar', + 'GR' => 'Greece', + 'GL' => 'Greenland', + 'GD' => 'Grenada', + 'GP' => 'Guadeloupe', + 'GU' => 'Guam', + 'GT' => 'Guatemala', + 'GG' => 'Guernsey', + 'GN' => 'Guinea', + 'GW' => 'Guinea-bissau', + 'GY' => 'Guyana', + 'HT' => 'Haiti', + 'HM' => 'Heard Island And Mcdonald Islands', + 'HN' => 'Honduras', + 'HK' => 'Hong Kong', + 'HU' => 'Hungary', + 'IS' => 'Iceland', + 'IN' => 'India', + 'ID' => 'Indonesia', + 'IR' => 'Iran', + 'IQ' => 'Iraq', + 'IE' => 'Ireland', + 'IM' => 'Isle Of Man', + 'IL' => 'Israel', + 'IT' => 'Italy', + 'JM' => 'Jamaica', + 'JP' => 'Japan', + 'JE' => 'Jersey', + 'JO' => 'Jordan', + 'KZ' => 'Kazakhstan', + 'KE' => 'Kenya', + 'KI' => 'Kiribati', + 'KP' => 'Korea, North', + 'KR' => 'Korea, South', + 'KW' => 'Kuwait', + 'KG' => 'Kyrgyzstan', + 'LA' => 'Laos', + 'LV' => 'Latvia', + 'LB' => 'Lebanon', + 'LS' => 'Lesotho', + 'LR' => 'Liberia', + 'LY' => 'Libya', + 'LI' => 'Liechtenstein', + 'LT' => 'Lithuania', + 'LU' => 'Luxembourg', + 'MO' => 'Macau', + 'MK' => 'Macedonia', + 'MG' => 'Madagascar', + 'MW' => 'Malawi', + 'MY' => 'Malaysia', + 'MV' => 'Maldives', + 'ML' => 'Mali', + 'MT' => 'Malta', + 'MH' => 'Marshall Islands', + 'MQ' => 'Martinique', + 'MR' => 'Mauritania', + 'MU' => 'Mauritius', + 'YT' => 'Mayotte', + 'MX' => 'Mexico', + 'FM' => 'Micronesia, Federated States Of', + 'MD' => 'Moldova', + 'MC' => 'Monaco', + 'MN' => 'Mongolia', + 'ME' => 'Montenegro', + 'MS' => 'Montserrat', + 'MA' => 'Morocco', + 'MZ' => 'Mozambique', + 'NA' => 'Namibia', + 'NR' => 'Nauru', + 'NP' => 'Nepal', + 'NL' => 'Netherlands', + 'NC' => 'New Caledonia', + 'NZ' => 'New Zealand', + 'NI' => 'Nicaragua', + 'NE' => 'Niger', + 'NG' => 'Nigeria', + 'NU' => 'Niue', + 'NF' => 'Norfolk Island', + 'MP' => 'Northern Mariana Islands', + 'NO' => 'Norway', + 'OM' => 'Oman', + 'PK' => 'Pakistan', + 'PW' => 'Palau', + 'PA' => 'Panama', + 'PG' => 'Papua New Guinea', + 'PY' => 'Paraguay', + 'PE' => 'Peru', + 'PH' => 'Philippines', + 'PN' => 'Pitcairn Islands', + 'PL' => 'Poland', + 'PT' => 'Portugal', + 'PR' => 'Puerto Rico', + 'QA' => 'Qatar', + 'RE' => 'Reunion', + 'RO' => 'Romania', + 'RU' => 'Russia', + 'RW' => 'Rwanda', + 'BL' => 'Saint Barthelemy', + 'SH' => 'Saint Helena, Ascension, And Tristan Da Cunha', + 'KN' => 'Saint Kitts And Nevis', + 'LC' => 'Saint Lucia', + 'MF' => 'Saint Martin', + 'PM' => 'Saint Pierre And Miquelon', + 'VC' => 'Saint Vincent And The Grenadines', + 'WS' => 'Samoa', + 'SM' => 'San Marino', + 'ST' => 'Sao Tome And Principe', + 'SA' => 'Saudi Arabia', + 'SN' => 'Senegal', + 'RS' => 'Serbia', + 'SC' => 'Seychelles', + 'SL' => 'Sierra Leone', + 'SG' => 'Singapore', + 'SX' => 'Sint Maarten', + 'SK' => 'Slovakia', + 'SI' => 'Slovenia', + 'SB' => 'Solomon Islands', + 'SO' => 'Somalia', + 'ZA' => 'South Africa', + 'GS' => 'South Georgia And South Sandwich Islands', + 'SS' => 'South Sudan', + 'ES' => 'Spain', + 'LK' => 'Sri Lanka', + 'SD' => 'Sudan', + 'SR' => 'Suriname', + 'SZ' => 'Swaziland', + 'SE' => 'Sweden', + 'CH' => 'Switzerland', + 'SY' => 'Syria', + 'TW' => 'Taiwan', + 'TJ' => 'Tajikistan', + 'TZ' => 'Tanzania', + 'TH' => 'Thailand', + 'TL' => 'Timor-leste', + 'TG' => 'Togo', + 'TK' => 'Tokelau', + 'TO' => 'Tonga', + 'TT' => 'Trinidad And Tobago', + 'TN' => 'Tunisia', + 'TR' => 'Turkey', + 'TM' => 'Turkmenistan', + 'TC' => 'Turks And Caicos Islands', + 'TV' => 'Tuvalu', + 'UG' => 'Uganda', + 'UA' => 'Ukraine', + 'AE' => 'United Arab Emirates', + 'GB' => 'United Kingdom', + 'US' => 'United States', + 'UY' => 'Uruguay', + 'UZ' => 'Uzbekistan', + 'VU' => 'Vanuatu', + 'VA' => 'Vatican City', + 'VE' => 'Venezuela', + 'VN' => 'Vietnam', + 'VG' => 'Virgin Islands, British', + 'VI' => 'Virgin Islands, United States ', + 'WF' => 'Wallis And Futuna', + 'EH' => 'Western Sahara', + 'YE' => 'Yemen', + 'ZM' => 'Zambia', + 'ZW' => 'Zimbabwe', + ); + return $country_code_to_name; + } } /** @@ -521,32 +537,35 @@ function atbdp_country_code_to_name(){ * * @since 7.10.0 * - * @param int $meta_id - * @param int $object_id + * @param int $meta_id + * @param int $object_id * @param string $meta_key - * @param mixed $meta_value + * @param mixed $meta_value * * @return void */ function directorist_updated_post_meta_action( $meta_id, $object_id, $meta_key, $meta_value ) { - if ( $meta_key !== '_listing_status' || ! directorist_is_listing_post_type( $object_id ) ) { - return; - } - - if ( $meta_value === 'post_status' ) { - return; - } - - if ( $meta_value === 'expired' || $meta_value === 'renewal' ) { - if ( $meta_value === 'renewal' ) { - $meta_value = 'publish'; - } - - wp_update_post( array( - 'ID' => $object_id, - 'post_status' => $meta_value - ), false ); - } + if ( $meta_key !== '_listing_status' || ! directorist_is_listing_post_type( $object_id ) ) { + return; + } + + if ( $meta_value === 'post_status' ) { + return; + } + + if ( $meta_value === 'expired' || $meta_value === 'renewal' ) { + if ( $meta_value === 'renewal' ) { + $meta_value = 'publish'; + } + + wp_update_post( + array( + 'ID' => $object_id, + 'post_status' => $meta_value, + ), + false + ); + } } add_action( 'added_post_meta', 'directorist_updated_post_meta_action', 99999, 4 ); add_action( 'updated_post_meta', 'directorist_updated_post_meta_action', 99999, 4 ); @@ -556,25 +575,25 @@ function directorist_updated_post_meta_action( $meta_id, $object_id, $meta_key, * * @since 7.10.0 * - * @param mixed $check - * @param int $object_id Listing id + * @param mixed $check + * @param int $object_id Listing id * @param string $meta_key - * @param mixed $meta_value + * @param mixed $meta_value * * @return mixed Modified value of $check */ function directorist_delete_never_expire_meta_on_update( $check, $object_id, $meta_key, $meta_value ) { - if ( ! directorist_is_listing_post_type( $object_id ) || $meta_key !== '_never_expire' ) { - return $check; - } + if ( ! directorist_is_listing_post_type( $object_id ) || $meta_key !== '_never_expire' ) { + return $check; + } - if ( ! in_array( $meta_value, array( false, '', 0, '0' ), true ) ) { - return $check; - } + if ( ! in_array( $meta_value, array( false, '', 0, '0' ), true ) ) { + return $check; + } - delete_post_meta( $object_id, $meta_key ); + delete_post_meta( $object_id, $meta_key ); - return true; + return true; } add_filter( 'add_post_metadata', 'directorist_delete_never_expire_meta_on_update', 10, 4 ); add_filter( 'update_post_metadata', 'directorist_delete_never_expire_meta_on_update', 10, 4 ); diff --git a/includes/custom-filters.php b/includes/custom-filters.php index ee62d81d53..cfdb6474fc 100644 --- a/includes/custom-filters.php +++ b/includes/custom-filters.php @@ -4,18 +4,18 @@ /** * It lets you modify button classes used by the directorist plugin. You can add your custom class or modify existing ones. + * * @param string $type the type of the button being printed. eg. default or primary etc. * @return string it returns the names of the classed that should be added to a button. */ - -function atbdp_directorist_button_classes($type='primary'){ - /** - * It lets you modify button classes used by the directorist plugin. You can add your custom class or modify existing ones. - * @param $type string the type of the button eg. default, primary etc. Default value is default. - * - */ - return apply_filters('atbdp_button_class', "directorist-btn directorist-btn-{$type} directorist-btn-lg", $type); - } +function atbdp_directorist_button_classes( $type = 'primary' ) { + /** + * It lets you modify button classes used by the directorist plugin. You can add your custom class or modify existing ones. + * + * @param $type string the type of the button eg. default, primary etc. Default value is default. + */ + return apply_filters( 'atbdp_button_class', "directorist-btn directorist-btn-{$type} directorist-btn-lg", $type ); +} /** * @since 6.3.4 * @return string image scource diff --git a/includes/data-store/class-atbdp-terms-store.php b/includes/data-store/class-atbdp-terms-store.php index 4390cf90e4..015d6d9e91 100644 --- a/includes/data-store/class-atbdp-terms-store.php +++ b/includes/data-store/class-atbdp-terms-store.php @@ -1,64 +1,68 @@ <?php if ( ! class_exists( 'ATBDP_Terms_Data_Store' ) ) : - class ATBDP_Terms_Data_Store { - // get_categories_term - public static function get_categories_term( array $args = [] ) { - return get_terms( ATBDP_CATEGORY, $args ); + class ATBDP_Terms_Data_Store { + // get_categories_term + public static function get_categories_term( array $args = array() ) { + return get_terms( ATBDP_CATEGORY, $args ); - /* return ATBDP_Cache_Helper::get_the_transient([ - 'group' => 'atbdp_category_terms', - 'name' => 'atbdp_term_categories', - 'args' => $args, - 'cache' => apply_filters( 'atbdp_cache_term_categories', true ), - 'value' => function( $data ) { - return get_terms( ATBDP_CATEGORY, $data['args'] ); - } - ]); */ - } + /* + return ATBDP_Cache_Helper::get_the_transient([ + 'group' => 'atbdp_category_terms', + 'name' => 'atbdp_term_categories', + 'args' => $args, + 'cache' => apply_filters( 'atbdp_cache_term_categories', true ), + 'value' => function( $data ) { + return get_terms( ATBDP_CATEGORY, $data['args'] ); + } + ]); */ + } - // get_categories_taxanomy - public static function get_categories_taxanomy( array $args = [] ) { - return get_categories( $args ); + // get_categories_taxanomy + public static function get_categories_taxanomy( array $args = array() ) { + return get_categories( $args ); - /* return ATBDP_Cache_Helper::get_the_transient([ - 'group' => 'atbdp_category_terms', - 'name' => 'atbdp_taxonomy_categories', - 'args' => $args, - 'cache' => apply_filters( 'atbdp_cache_taxonomy_categories', true ), - 'value' => function( $data ) { - return get_categories( $data['args'] ); - } - ]); */ - } + /* + return ATBDP_Cache_Helper::get_the_transient([ + 'group' => 'atbdp_category_terms', + 'name' => 'atbdp_taxonomy_categories', + 'args' => $args, + 'cache' => apply_filters( 'atbdp_cache_taxonomy_categories', true ), + 'value' => function( $data ) { + return get_categories( $data['args'] ); + } + ]); */ + } - // get_locations_term - public static function get_locations_term( array $args = [] ) { - return get_terms( ATBDP_LOCATION, $args ); + // get_locations_term + public static function get_locations_term( array $args = array() ) { + return get_terms( ATBDP_LOCATION, $args ); - /* return ATBDP_Cache_Helper::get_the_transient([ - 'group' => 'atbdp_location_terms', - 'name' => 'atbdp_locations', - 'args' => $args, - 'cache' => apply_filters( 'atbdp_cache_locations', true ), - 'value' => function( $data ) { - return get_terms( ATBDP_LOCATION, $data['args'] ); - } - ]); */ - } - - // get_tags_term - public static function get_tags_term( array $args = [] ) { - return get_terms( ATBDP_TAGS, $args ); + /* + return ATBDP_Cache_Helper::get_the_transient([ + 'group' => 'atbdp_location_terms', + 'name' => 'atbdp_locations', + 'args' => $args, + 'cache' => apply_filters( 'atbdp_cache_locations', true ), + 'value' => function( $data ) { + return get_terms( ATBDP_LOCATION, $data['args'] ); + } + ]); */ + } - /* return ATBDP_Cache_Helper::get_the_transient([ - 'group' => 'atbdp_tag_terms', - 'name' => 'atbdp_listings_tags', - 'args' => $args, - 'cache' => apply_filters( 'atbdp_cache_listings_tags', true ), - 'value' => function( $data ) { - return get_terms( ATBDP_TAGS, $data['args'] ); - } - ]); */ - } - } -endif; \ No newline at end of file + // get_tags_term + public static function get_tags_term( array $args = array() ) { + return get_terms( ATBDP_TAGS, $args ); + + /* + return ATBDP_Cache_Helper::get_the_transient([ + 'group' => 'atbdp_tag_terms', + 'name' => 'atbdp_listings_tags', + 'args' => $args, + 'cache' => apply_filters( 'atbdp_cache_listings_tags', true ), + 'value' => function( $data ) { + return get_terms( ATBDP_TAGS, $data['args'] ); + } + ]); */ + } + } +endif; diff --git a/includes/database/db.php b/includes/database/db.php index 55bdbd06bd..287167f796 100644 --- a/includes/database/db.php +++ b/includes/database/db.php @@ -25,16 +25,16 @@ class DB { */ public static function get_listings_data( $args ) { $args['fields'] = 'ids'; - $query = new WP_Query( $args ); - $paginated = ! $query->get( 'no_found_rows' ); + $query = new WP_Query( $args ); + $paginated = ! $query->get( 'no_found_rows' ); - $results = (object) [ + $results = (object) array( 'ids' => wp_parse_id_list( $query->posts ), 'total' => $paginated ? (int) $query->found_posts : count( $query->posts ), 'total_pages' => $paginated ? (int) $query->max_num_pages : 1, 'per_page' => (int) $query->get( 'posts_per_page' ), 'current_page' => $paginated ? (int) max( 1, $query->get( 'paged', 1 ) ) : 1, - ]; + ); return apply_filters( 'directorist_listings_query_results', $results ); } @@ -50,7 +50,7 @@ public static function favorite_listings_query( $user_id = 0 ) { $user_id = $user_id ? $user_id : get_current_user_id(); $favorites = directorist_get_user_favorites( $user_id ); - if ( !$favorites ) { + if ( ! $favorites ) { return new WP_Query(); } @@ -59,10 +59,9 @@ public static function favorite_listings_query( $user_id = 0 ) { 'posts_per_page' => -1, 'order' => 'DESC', 'post__in' => $favorites, - 'orderby' => 'date' - ); + 'orderby' => 'date', + ); return new WP_Query( $args ); } - } diff --git a/includes/deprecated/class-atbdp-listing-store.php b/includes/deprecated/class-atbdp-listing-store.php index 2a8f573140..4433dafd6e 100644 --- a/includes/deprecated/class-atbdp-listing-store.php +++ b/includes/deprecated/class-atbdp-listing-store.php @@ -12,7 +12,7 @@ class ATBDP_Listings_Data_Store { * * @return object WP_Query */ - public static function get_archive_listings_query( array $query_args = [], array $custom_option = [] ) { + public static function get_archive_listings_query( array $query_args = array(), array $custom_option = array() ) { _deprecated_function( __METHOD__, '7.4.3', 'DB::get_listings' ); return DB::get_listings_data( $query_args ); } @@ -22,7 +22,7 @@ public static function get_archive_listings_query( array $query_args = [], array * * @return object WP_Query */ - public static function get_listings( array $args = [] ) { + public static function get_listings( array $args = array() ) { _deprecated_function( __METHOD__, '7.4.3' ); return get_posts( $args ); } @@ -32,20 +32,20 @@ public static function get_listings( array $args = [] ) { * * @return object WP_Query */ - public static function get_listings_query( array $args = [] ) { + public static function get_listings_query( array $args = array() ) { _deprecated_function( __METHOD__, '7.4.3' ); return new WP_Query(); } // get_listings_ids - public static function get_listings_ids( array $query_args = [] ) { + public static function get_listings_ids( array $query_args = array() ) { _deprecated_function( __METHOD__, '7.4.3' ); - $default = [ + $default = array( 'post_type' => ATBDP_POST_TYPE, 'posts_per_page' => -1, 'post_status' => 'publish', - 'fields' => 'ids' - ]; + 'fields' => 'ids', + ); $query_args = array_merge( $default, $query_args ); $query = new WP_Query( $query_args ); diff --git a/includes/deprecated/functions.php b/includes/deprecated/functions.php index 931f1b969d..a303809a79 100644 --- a/includes/deprecated/functions.php +++ b/includes/deprecated/functions.php @@ -9,108 +9,113 @@ use Directorist\Helper; function atbdp_get_shortcode_template_paths( $template_file ) { - _deprecated_function( __FUNCTION__, '7.0', 'Helper::get_template()' ); - $theme_template_file = '/directorist/shortcodes/' . $template_file . '.php'; - $theme_template_path = get_stylesheet_directory() . $theme_template_file; - $plugin_template_path = Helper::template_directory() . 'public-templates/shortcodes/' . $template_file . '.php'; - - return [ - 'theme' => $theme_template_path, - 'plugin' => $plugin_template_path, - ]; + _deprecated_function( __FUNCTION__, '7.0', 'Helper::get_template()' ); + $theme_template_file = '/directorist/shortcodes/' . $template_file . '.php'; + $theme_template_path = get_stylesheet_directory() . $theme_template_file; + $plugin_template_path = Helper::template_directory() . 'public-templates/shortcodes/' . $template_file . '.php'; + + return array( + 'theme' => $theme_template_path, + 'plugin' => $plugin_template_path, + ); } -function atbdp_get_shortcode_template( $template, $args = [] ) { - _deprecated_function( __FUNCTION__, '7.0', 'Helper::get_template()' ); +function atbdp_get_shortcode_template( $template, $args = array() ) { + _deprecated_function( __FUNCTION__, '7.0', 'Helper::get_template()' ); - return Helper::get_template( $template, $args ); + return Helper::get_template( $template, $args ); } -function atbdp_return_shortcode_template( $template, $args = [] ) { - _deprecated_function( __FUNCTION__, '7.0', 'Helper::get_template_contents()' ); +function atbdp_return_shortcode_template( $template, $args = array() ) { + _deprecated_function( __FUNCTION__, '7.0', 'Helper::get_template_contents()' ); - return Helper::get_template_contents( $template, $args ); + return Helper::get_template_contents( $template, $args ); } -function atbdp_return_widget_template( $template, $args = [] ) { - _deprecated_function( __FUNCTION__, '7.0' ); - ob_start(); - atbdp_get_widget_template( $template, $args ); +function atbdp_return_widget_template( $template, $args = array() ) { + _deprecated_function( __FUNCTION__, '7.0' ); + ob_start(); + atbdp_get_widget_template( $template, $args ); - return ob_get_clean(); + return ob_get_clean(); } function atbdp_get_shortcode_template_path( $template ) { - _deprecated_function( __FUNCTION__, '7.0' ); - $template = 'shortcodes/' . $template; + _deprecated_function( __FUNCTION__, '7.0' ); + $template = 'shortcodes/' . $template; - return atbdp_get_template_path( $template ); + return atbdp_get_template_path( $template ); } -function bdas_dropdown_terms($args = array(), $echo = true) { +function bdas_dropdown_terms( $args = array(), $echo = true ) { _deprecated_function( __METHOD__, '7.3.1' ); return ''; } -function the_thumbnail_card($img_src = '', $_args = array()) { - _deprecated_function( __FUNCTION__, '7.0', 'atbdp_thumbnail_card()' ); - return atbdp_thumbnail_card($img_src,$_args); +function the_thumbnail_card( $img_src = '', $_args = array() ) { + _deprecated_function( __FUNCTION__, '7.0', 'atbdp_thumbnail_card()' ); + return atbdp_thumbnail_card( $img_src, $_args ); } -if ( ! function_exists('get_fa_icons') ) { - function get_fa_icons() { +if ( ! function_exists( 'get_fa_icons' ) ) { + function get_fa_icons() { _deprecated_function( __FUNCTION__, '7.4.0' ); return array(); - } + } } -if (!function_exists('get_fa_icons_full')) { - function get_fa_icons_full() { +if ( ! function_exists( 'get_fa_icons_full' ) ) { + function get_fa_icons_full() { _deprecated_function( __FUNCTION__, '7.4.0' ); return array(); - } + } } -if (!function_exists('atbdp_icon_type')) { - function atbdp_icon_type($echo = false) { +if ( ! function_exists( 'atbdp_icon_type' ) ) { + function atbdp_icon_type( $echo = false ) { _deprecated_function( __FUNCTION__, '7.4.0', 'directorist_icon' ); $font_type = 'la la'; - if ($echo) { - echo esc_html( $font_type ); - } else { - return $font_type; - } - } + if ( $echo ) { + echo esc_html( $font_type ); + } else { + return $font_type; + } + } } if ( ! function_exists( 'atbdp_get_term_icon' ) ) { - function atbdp_get_term_icon( array $args = [] ) { + function atbdp_get_term_icon( array $args = array() ) { _deprecated_function( __FUNCTION__, '7.4.0' ); - $default = [ 'icon' => '', 'default' => 'lar la-folder-open', 'echo' => false ]; - $args = array_merge( $default, $args ); + $default = array( + 'icon' => '', + 'default' => 'lar la-folder-open', + 'echo' => false, + ); + $args = array_merge( $default, $args ); - $icon = ( ! empty($args['icon'] ) ) ? $args['icon'] : $args['default']; - $icon = ( ! empty( $icon ) ) ? '<span class="'. $icon .'"></span>' : $icon; + $icon = ( ! empty( $args['icon'] ) ) ? $args['icon'] : $args['default']; + $icon = ( ! empty( $icon ) ) ? '<span class="' . $icon . '"></span>' : $icon; - if ( ! $args['echo'] ) { return $icon; } + if ( ! $args['echo'] ) { + return $icon; } - echo wp_kses_post( $icon ); - } + echo wp_kses_post( $icon ); + } } -if (!function_exists('get_atbdp_listings_ids')) { - function get_atbdp_listings_ids() { +if ( ! function_exists( 'get_atbdp_listings_ids' ) ) { + function get_atbdp_listings_ids() { _deprecated_function( __FUNCTION__, '7.4.3' ); - $arg = array( - 'post_type' => 'at_biz_dir', - 'posts_per_page' => -1, - 'post_status' => 'publish', - 'fields' => 'ids' - ); - - $query = new \WP_Query( $arg ); - return $query; - } -} \ No newline at end of file + $arg = array( + 'post_type' => 'at_biz_dir', + 'posts_per_page' => -1, + 'post_status' => 'publish', + 'fields' => 'ids', + ); + + $query = new \WP_Query( $arg ); + return $query; + } +} diff --git a/includes/directorist-directory-functions.php b/includes/directorist-directory-functions.php index 9e66d75ce2..5774f98510 100644 --- a/includes/directorist-directory-functions.php +++ b/includes/directorist-directory-functions.php @@ -13,7 +13,7 @@ } function directorist_get_directory_meta( $directory_id, string $meta_key ) { - return get_term_meta( $directory_id, $meta_key, true ); + return get_term_meta( $directory_id, $meta_key, true ); } function directorist_get_listing_form_fields( $directory_id ) { @@ -32,10 +32,10 @@ function directorist_get_listing_form_fields( $directory_id ) { $fields[ $field_key ] = $_fields[ $field_key ]; } - if( isset( $fields['view_count'] ) ) { + if ( isset( $fields['view_count'] ) ) { unset( $fields['view_count'] ); } - + return $fields; } @@ -44,9 +44,9 @@ function directorist_get_listing_form_groups( $directory_id ) { $_groups = directorist_get_var( $form_data['groups'], array() ); $groups = array(); - foreach ( $_groups as $group ) { + foreach ( $_groups as $group ) { $groups[] = array( - 'label' => $group['label'], + 'label' => $group['label'], 'fields' => $group['fields'], ); } @@ -100,7 +100,7 @@ function directorist_should_check_privacy_policy( $directory_id ) { /** * Get listing default create status from directory settings. * - * @param int $directory_id + * @param int $directory_id * * @return string Default create status. */ @@ -114,8 +114,8 @@ function directorist_get_listing_create_status( $directory_id ) { * Get listing default edit status from directory settings. * And if $listing_id is given then follow the conditions. * - * @param int $directory_id - * @param int $listing_id Added in version 8. + * @param int $directory_id + * @param int $listing_id Added in version 8. * * @return string Default edit status. */ @@ -143,7 +143,7 @@ function directorist_get_listing_edit_status( $directory_id, $listing_id = 0 ) { if ( $listing_id && ( $listing_status = get_post_status( $listing_id ) ) !== false ) { if ( $builder_status === 'publish' && $listing_status === 'publish' ) { $status = 'publish'; - } else if ( $builder_status === 'pending' || $listing_status === 'pending' ) { + } elseif ( $builder_status === 'pending' || $listing_status === 'pending' ) { $status = 'pending'; } } @@ -195,11 +195,11 @@ function directorist_update_term_directory( $term_id, array $directory_ids = arr update_term_meta( $term_id, '_directory_type', $directory_ids ); } -function directorist_update_location_directory( $location_id, array $directory_ids = array(), $append = false) { +function directorist_update_location_directory( $location_id, array $directory_ids = array(), $append = false ) { directorist_update_term_directory( $location_id, $directory_ids, $append ); } -function directorist_update_category_directory( $location_id, array $directory_ids = array(), $append = false) { +function directorist_update_category_directory( $location_id, array $directory_ids = array(), $append = false ) { directorist_update_term_directory( $location_id, $directory_ids, $append ); } @@ -241,7 +241,7 @@ function directorist_get_directory_general_settings( $directory_id ) { function directorist_get_directories( array $args = array() ) { $defaults = array( - 'hide_empty' => false, + 'hide_empty' => false, 'default_only' => false, ); @@ -267,15 +267,19 @@ function directorist_get_directories_for_template( array $args = array() ) { return array(); } - return array_reduce( $directories, static function( $carry, $directory ) { - $carry[ $directory->term_id ] = array( - 'term' => $directory, - 'name' => $directory->name, - 'data' => directorist_get_directory_general_settings( $directory->term_id ), - ); - - return $carry; - }, array() ); + return array_reduce( + $directories, + static function ( $carry, $directory ) { + $carry[ $directory->term_id ] = array( + 'term' => $directory, + 'name' => $directory->name, + 'data' => directorist_get_directory_general_settings( $directory->term_id ), + ); + + return $carry; + }, + array() + ); } /** @@ -295,7 +299,7 @@ function directorist_get_category_custom_field_relations( $directory_id ) { $relations = array(); - foreach( $submission_form_fields['fields'] as $field ) { + foreach ( $submission_form_fields['fields'] as $field ) { if ( empty( $field['assign_to'] ) || empty( $field['category'] ) ) { continue; } diff --git a/includes/elementor/add-listing.php b/includes/elementor/add-listing.php index f512bcfc59..da8d9b1a1d 100644 --- a/includes/elementor/add-listing.php +++ b/includes/elementor/add-listing.php @@ -8,11 +8,13 @@ use Elementor\Controls_Manager; use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Add_Listing extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Add Listing Form', 'directorist' ); $this->az_base = 'directorist_add_listing'; parent::__construct( $data, $args ); @@ -28,26 +30,26 @@ private function az_listing_types() { return wp_list_pluck( $directories, 'name', 'slug' ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( 'type' => Controls_Manager::HEADING, 'id' => 'sec_heading', 'label' => __( 'This widget works only in Add Listing page. It has no additional elementor settings.', 'directorist' ), - 'condition' => ! directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'condition' => ! directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'type', - 'label' => __( 'Directory Types', 'directorist' ), - 'multiple' => true, - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'type', + 'label' => __( 'Directory Types', 'directorist' ), + 'multiple' => true, + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( 'mode' => 'section_end', @@ -59,7 +61,7 @@ public function az_fields(){ protected function render() { $settings = $this->get_settings_for_display(); - $atts = []; + $atts = array(); if ( directorist_is_multi_directory_enabled() ) { if ( $settings['type'] ) { @@ -69,4 +71,4 @@ protected function render() { $this->az_run_shortcode( 'directorist_add_listing', $atts ); } -} \ No newline at end of file +} diff --git a/includes/elementor/all-categories.php b/includes/elementor/all-categories.php index 3682523288..c612136818 100644 --- a/includes/elementor/all-categories.php +++ b/includes/elementor/all-categories.php @@ -8,21 +8,23 @@ use Elementor\Controls_Manager; use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_All_Categories extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Listing Categories', 'directorist' ); $this->az_base = 'directorist_all_categories'; parent::__construct( $data, $args ); } private function az_listing_categories() { - $result = array(); + $result = array(); $categories = get_terms( ATBDP_CATEGORY ); foreach ( $categories as $category ) { - $result[$category->slug] = $category->name; + $result[ $category->slug ] = $category->name; } return $result; } @@ -37,27 +39,27 @@ private function az_listing_types() { return wp_list_pluck( $directories, 'name', 'slug' ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'type', - 'label' => __( 'Directory Types', 'directorist' ), - 'multiple' => true, - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'type', + 'label' => __( 'Directory Types', 'directorist' ), + 'multiple' => true, + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'default_type', - 'label' => __( 'Default Directory Types', 'directorist' ), - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'default_type', + 'label' => __( 'Default Directory Types', 'directorist' ), + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( 'type' => Controls_Manager::SELECT, @@ -70,17 +72,17 @@ public function az_fields(){ 'default' => 'grid', ), array( - 'type' => Controls_Manager::SELECT, - 'id' => 'columns', - 'label' => __( 'Categories Per Row', 'directorist' ), - 'options' => array( - '1' => __( '1 Item / Row', 'directorist' ), - '2' => __( '2 Items / Row', 'directorist' ), - '3' => __( '3 Items / Row', 'directorist' ), - '4' => __( '4 Items / Row', 'directorist' ), - '6' => __( '6 Items / Row', 'directorist' ), + 'type' => Controls_Manager::SELECT, + 'id' => 'columns', + 'label' => __( 'Categories Per Row', 'directorist' ), + 'options' => array( + '1' => __( '1 Item / Row', 'directorist' ), + '2' => __( '2 Items / Row', 'directorist' ), + '3' => __( '3 Items / Row', 'directorist' ), + '4' => __( '4 Items / Row', 'directorist' ), + '6' => __( '6 Items / Row', 'directorist' ), ), - 'default' => '3', + 'default' => '3', 'condition' => array( 'view' => array( 'grid' ) ), ), array( @@ -96,11 +98,11 @@ public function az_fields(){ 'default' => 'id', ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'slug', - 'label' => __( 'Specify Categories', 'directorist' ), - 'multiple' => true, - 'options' => $this->az_listing_categories(), + 'type' => Controls_Manager::SELECT2, + 'id' => 'slug', + 'label' => __( 'Specify Categories', 'directorist' ), + 'multiple' => true, + 'options' => $this->az_listing_categories(), 'condition' => array( 'order_by' => array( 'slug' ) ), ), array( @@ -114,19 +116,19 @@ public function az_fields(){ 'default' => 'desc', ), array( - 'type' => Controls_Manager::NUMBER, - 'id' => 'number_cat', - 'label' => __( 'Number of Categories to Show', 'directorist' ), - 'min' => 1, - 'max' => 100, - 'step' => 1, - 'default' => 6, + 'type' => Controls_Manager::NUMBER, + 'id' => 'number_cat', + 'label' => __( 'Number of Categories to Show', 'directorist' ), + 'min' => 1, + 'max' => 100, + 'step' => 1, + 'default' => 6, ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Only For Logged In User?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Only For Logged In User?', 'directorist' ), + 'default' => 'no', ), array( 'mode' => 'section_end', @@ -159,4 +161,4 @@ protected function render() { $this->az_run_shortcode( 'directorist_all_categories', $atts ); } -} \ No newline at end of file +} diff --git a/includes/elementor/all-listing.php b/includes/elementor/all-listing.php index be57768e09..fbf751e6fa 100644 --- a/includes/elementor/all-listing.php +++ b/includes/elementor/all-listing.php @@ -8,39 +8,41 @@ use Elementor\Controls_Manager; use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_All_Listing extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'All Listings', 'directorist' ); $this->az_base = 'directorist_all_listing'; parent::__construct( $data, $args ); } private function az_listing_categories() { - $result = array(); + $result = array(); $categories = get_terms( ATBDP_CATEGORY ); foreach ( $categories as $category ) { - $result[$category->slug] = $category->name; + $result[ $category->slug ] = $category->name; } return $result; } private function az_listing_tags() { $result = array(); - $tags = get_terms( ATBDP_TAGS ); + $tags = get_terms( ATBDP_TAGS ); foreach ( $tags as $tag ) { - $result[$tag->slug] = $tag->name; + $result[ $tag->slug ] = $tag->name; } return $result; } private function az_listing_locations() { - $result = array(); + $result = array(); $locations = get_terms( ATBDP_LOCATION ); foreach ( $locations as $location ) { - $result[$location->slug] = $location->name; + $result[ $location->slug ] = $location->name; } return $result; } @@ -55,24 +57,24 @@ private function az_listing_types() { return wp_list_pluck( $directories, 'name', 'slug' ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'header', - 'label' => __( 'Show Header?', 'directorist' ), - 'default' => 'yes', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'header', + 'label' => __( 'Show Header?', 'directorist' ), + 'default' => 'yes', ), array( - 'type' => Controls_Manager::TEXT, - 'id' => 'header_title', - 'label' => __( 'Total Listings Found Title', 'directorist' ), - 'default' => __( 'Listings Found', 'directorist' ), + 'type' => Controls_Manager::TEXT, + 'id' => 'header_title', + 'label' => __( 'Total Listings Found Title', 'directorist' ), + 'default' => __( 'Listings Found', 'directorist' ), ), array( 'type' => Controls_Manager::SWITCHER, @@ -102,47 +104,47 @@ public function az_fields(){ 'condition' => array( 'view' => array( 'map' ) ), ), array( - 'type' => Controls_Manager::SELECT, - 'id' => 'columns', - 'label' => __( 'Listings Per Row', 'directorist' ), - 'options' => array( - '6' => __( '6 Items / Row', 'directorist' ), - '4' => __( '4 Items / Row', 'directorist' ), - '3' => __( '3 Items / Row', 'directorist' ), - '2' => __( '2 Items / Row', 'directorist' ), + 'type' => Controls_Manager::SELECT, + 'id' => 'columns', + 'label' => __( 'Listings Per Row', 'directorist' ), + 'options' => array( + '6' => __( '6 Items / Row', 'directorist' ), + '4' => __( '4 Items / Row', 'directorist' ), + '3' => __( '3 Items / Row', 'directorist' ), + '2' => __( '2 Items / Row', 'directorist' ), ), - 'default' => '3', + 'default' => '3', 'condition' => array( 'view' => 'grid' ), ), array( - 'type' => Controls_Manager::NUMBER, - 'id' => 'listing_number', - 'label' => __( 'Number of Listings to Show', 'directorist' ), - 'min' => 1, - 'max' => 100, - 'step' => 1, - 'default' => 6, + 'type' => Controls_Manager::NUMBER, + 'id' => 'listing_number', + 'label' => __( 'Number of Listings to Show', 'directorist' ), + 'min' => 1, + 'max' => 100, + 'step' => 1, + 'default' => 6, ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'preview', - 'label' => __( 'Show Preview Image?', 'directorist' ), - 'default' => 'yes', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'preview', + 'label' => __( 'Show Preview Image?', 'directorist' ), + 'default' => 'yes', ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'type', - 'label' => __( 'Directory Types', 'directorist' ), - 'multiple' => true, - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'type', + 'label' => __( 'Directory Types', 'directorist' ), + 'multiple' => true, + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'default_type', - 'label' => __( 'Default Directory Types', 'directorist' ), - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'default_type', + 'label' => __( 'Default Directory Types', 'directorist' ), + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( 'type' => Controls_Manager::SELECT2, @@ -166,22 +168,22 @@ public function az_fields(){ 'options' => $this->az_listing_locations(), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'featured', - 'label' => __( 'Show Featured Only?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'featured', + 'label' => __( 'Show Featured Only?', 'directorist' ), + 'default' => 'no', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'popular', - 'label' => __( 'Show Popular Only?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'popular', + 'label' => __( 'Show Popular Only?', 'directorist' ), + 'default' => 'no', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Only For Logged In User?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Only For Logged In User?', 'directorist' ), + 'default' => 'no', ), array( 'type' => Controls_Manager::SELECT, @@ -205,10 +207,10 @@ public function az_fields(){ 'default' => 'desc', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'show_pagination', - 'label' => __( 'Show Pagination?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'show_pagination', + 'label' => __( 'Show Pagination?', 'directorist' ), + 'default' => 'no', ), array( 'mode' => 'section_end', @@ -254,8 +256,8 @@ protected function render() { * * @since 7.4.2 * - * @param array $atts Available atts in the widgers - * @param array $settings All the settings of the widget + * @param array $atts Available atts in the widgers + * @param array $settings All the settings of the widget */ $atts = apply_filters( 'directorist_all_listings_elementor_widget_atts', $atts, $settings ); diff --git a/includes/elementor/all-locations.php b/includes/elementor/all-locations.php index b315fc83db..eb46d81264 100644 --- a/includes/elementor/all-locations.php +++ b/includes/elementor/all-locations.php @@ -8,21 +8,23 @@ use Elementor\Controls_Manager; use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_All_Locations extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Listing Locations', 'directorist' ); $this->az_base = 'directorist_all_locations'; parent::__construct( $data, $args ); } private function az_listing_locations() { - $result = array(); + $result = array(); $locations = get_terms( ATBDP_LOCATION ); foreach ( $locations as $location ) { - $result[$location->slug] = $location->name; + $result[ $location->slug ] = $location->name; } return $result; } @@ -37,27 +39,27 @@ private function az_listing_types() { return wp_list_pluck( $directories, 'name', 'slug' ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'type', - 'label' => __( 'Directory Types', 'directorist' ), - 'multiple' => true, - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'type', + 'label' => __( 'Directory Types', 'directorist' ), + 'multiple' => true, + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'default_type', - 'label' => __( 'Default Directory Types', 'directorist' ), - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'default_type', + 'label' => __( 'Default Directory Types', 'directorist' ), + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( 'type' => Controls_Manager::SELECT, @@ -70,17 +72,17 @@ public function az_fields(){ 'default' => 'grid', ), array( - 'type' => Controls_Manager::SELECT, - 'id' => 'columns', - 'label' => __( 'Locations Per Row', 'directorist' ), - 'options' => array( - '1' => __( '1 Item / Row', 'directorist' ), - '2' => __( '2 Items / Row', 'directorist' ), - '3' => __( '3 Items / Row', 'directorist' ), - '4' => __( '4 Items / Row', 'directorist' ), - '6' => __( '6 Items / Row', 'directorist' ), + 'type' => Controls_Manager::SELECT, + 'id' => 'columns', + 'label' => __( 'Locations Per Row', 'directorist' ), + 'options' => array( + '1' => __( '1 Item / Row', 'directorist' ), + '2' => __( '2 Items / Row', 'directorist' ), + '3' => __( '3 Items / Row', 'directorist' ), + '4' => __( '4 Items / Row', 'directorist' ), + '6' => __( '6 Items / Row', 'directorist' ), ), - 'default' => '3', + 'default' => '3', 'condition' => array( 'view' => array( 'grid' ) ), ), array( @@ -96,11 +98,11 @@ public function az_fields(){ 'default' => 'id', ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'slug', - 'label' => __( 'Specify Locations', 'directorist' ), - 'multiple' => true, - 'options' => $this->az_listing_locations(), + 'type' => Controls_Manager::SELECT2, + 'id' => 'slug', + 'label' => __( 'Specify Locations', 'directorist' ), + 'multiple' => true, + 'options' => $this->az_listing_locations(), 'condition' => array( 'order_by' => array( 'slug' ) ), ), array( @@ -114,19 +116,19 @@ public function az_fields(){ 'default' => 'desc', ), array( - 'type' => Controls_Manager::NUMBER, - 'id' => 'number_loc', - 'label' => __( 'Number of Locations to Show', 'directorist' ), - 'min' => 1, - 'max' => 100, - 'step' => 1, - 'default' => 6, + 'type' => Controls_Manager::NUMBER, + 'id' => 'number_loc', + 'label' => __( 'Number of Locations to Show', 'directorist' ), + 'min' => 1, + 'max' => 100, + 'step' => 1, + 'default' => 6, ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Only For Logged In User?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Only For Logged In User?', 'directorist' ), + 'default' => 'no', ), array( 'mode' => 'section_end', @@ -159,4 +161,4 @@ protected function render() { $this->az_run_shortcode( 'directorist_all_locations', $atts ); } -} \ No newline at end of file +} diff --git a/includes/elementor/author-profile.php b/includes/elementor/author-profile.php index 6b9d1ba7a5..d55949c555 100644 --- a/includes/elementor/author-profile.php +++ b/includes/elementor/author-profile.php @@ -7,28 +7,30 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Author_Profile extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'User Profile', 'directorist' ); $this->az_base = 'directorist_author_profile'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Only For Logged In User?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Only For Logged In User?', 'directorist' ), + 'default' => 'no', ), array( 'mode' => 'section_end', @@ -46,4 +48,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/base.php b/includes/elementor/base.php index ec35db2e7d..97a491000e 100644 --- a/includes/elementor/base.php +++ b/includes/elementor/base.php @@ -7,11 +7,13 @@ use Elementor\Widget_Base; -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} class Custom_Widget_Base extends Widget_Base { - public $az_prefix = 'directorist'; // change category prefix here /@dev + public $az_prefix = 'directorist'; // change category prefix here /@dev public $az_name; public $az_base; @@ -20,7 +22,7 @@ class Custom_Widget_Base extends Widget_Base { public $az_texts; public $az_dir; - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_category = $this->az_prefix . '-widgets'; $this->az_icon = 'directorist-el-custom'; $this->az_texts = array( @@ -30,7 +32,7 @@ public function __construct( $data = [], $args = null ) { 'transaction' => __( 'This widget works only in Transaction Failure page. It has no additional elementor settings.', 'directorist' ), ); - $this->az_dir = dirname( ( new \ReflectionClass( $this ) )->getFileName() ); + $this->az_dir = dirname( ( new \ReflectionClass( $this ) )->getFileName() ); parent::__construct( $data, $args ); } @@ -55,7 +57,7 @@ protected function az_fields() { return array(); } - public function az_run_shortcode( $shortcode, $atts = [] ) { + public function az_run_shortcode( $shortcode, $atts = array() ) { $html = ''; foreach ( $atts as $key => $value ) { @@ -75,47 +77,39 @@ protected function register_controls() { unset( $field['id'] ); unset( $field['mode'] ); $this->start_controls_section( $id, $field ); - } - elseif ( isset( $field['mode'] ) && $field['mode'] == 'section_end' ) { + } elseif ( isset( $field['mode'] ) && $field['mode'] == 'section_end' ) { $this->end_controls_section(); - } - elseif ( isset( $field['mode'] ) && $field['mode'] == 'tabs_start' ) { + } elseif ( isset( $field['mode'] ) && $field['mode'] == 'tabs_start' ) { $id = $field['id']; unset( $field['id'] ); unset( $field['mode'] ); $this->start_controls_tabs( $id ); - } - elseif ( isset( $field['mode'] ) && $field['mode'] == 'tabs_end' ) { + } elseif ( isset( $field['mode'] ) && $field['mode'] == 'tabs_end' ) { $this->end_controls_tabs(); - } - elseif ( isset( $field['mode'] ) && $field['mode'] == 'tab_start' ) { + } elseif ( isset( $field['mode'] ) && $field['mode'] == 'tab_start' ) { $id = $field['id']; unset( $field['id'] ); unset( $field['mode'] ); $this->start_controls_tab( $id, $field ); - } - elseif ( isset( $field['mode'] ) && $field['mode'] == 'tab_end' ) { + } elseif ( isset( $field['mode'] ) && $field['mode'] == 'tab_end' ) { $this->end_controls_tab(); - } - elseif ( isset( $field['mode'] ) && $field['mode'] == 'group' ) { - $type = $field['type']; + } elseif ( isset( $field['mode'] ) && $field['mode'] == 'group' ) { + $type = $field['type']; $field['name'] = $field['id']; unset( $field['mode'] ); unset( $field['type'] ); unset( $field['id'] ); $this->add_group_control( $type, $field ); - } - elseif ( isset( $field['mode'] ) && $field['mode'] == 'responsive' ) { + } elseif ( isset( $field['mode'] ) && $field['mode'] == 'responsive' ) { $id = $field['id']; unset( $field['id'] ); unset( $field['mode'] ); $this->add_responsive_control( $id, $field ); - } - else { + } else { $id = $field['id']; unset( $field['id'] ); $this->add_control( $id, $field ); } } } -} \ No newline at end of file +} diff --git a/includes/elementor/category.php b/includes/elementor/category.php index e28407661f..acce30dc86 100644 --- a/includes/elementor/category.php +++ b/includes/elementor/category.php @@ -7,28 +7,30 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Category extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Single Category', 'directorist' ); $this->az_base = 'directorist_category'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'header', - 'label' => __( 'Show Header?', 'directorist' ), - 'default' => 'yes', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'header', + 'label' => __( 'Show Header?', 'directorist' ), + 'default' => 'yes', ), array( 'type' => Controls_Manager::TEXT, @@ -58,31 +60,31 @@ public function az_fields(){ 'condition' => array( 'view' => array( 'map' ) ), ), array( - 'type' => Controls_Manager::SELECT, - 'id' => 'columns', - 'label' => __( 'Category Per Row', 'directorist' ), - 'options' => array( - '3' => __( '3 Items / Row', 'directorist' ), - '4' => __( '4 Items / Row', 'directorist' ), - '5' => __( '5 Items / Row', 'directorist' ), + 'type' => Controls_Manager::SELECT, + 'id' => 'columns', + 'label' => __( 'Category Per Row', 'directorist' ), + 'options' => array( + '3' => __( '3 Items / Row', 'directorist' ), + '4' => __( '4 Items / Row', 'directorist' ), + '5' => __( '5 Items / Row', 'directorist' ), ), - 'default' => '3', + 'default' => '3', 'condition' => array( 'view' => array( 'grid' ) ), ), array( - 'type' => Controls_Manager::NUMBER, - 'id' => 'number_cat', - 'label' => __( 'Number of Categories to Show', 'directorist' ), - 'min' => 1, - 'max' => 100, - 'step' => 1, - 'default' => 6, + 'type' => Controls_Manager::NUMBER, + 'id' => 'number_cat', + 'label' => __( 'Number of Categories to Show', 'directorist' ), + 'min' => 1, + 'max' => 100, + 'step' => 1, + 'default' => 6, ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'show_pagination', - 'label' => __( 'Show Pagination?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'show_pagination', + 'label' => __( 'Show Pagination?', 'directorist' ), + 'default' => 'no', ), array( 'type' => Controls_Manager::SELECT, @@ -106,24 +108,25 @@ public function az_fields(){ 'default' => 'desc', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Only For Logged In User?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Only For Logged In User?', 'directorist' ), + 'default' => 'no', ), array( 'mode' => 'section_end', ), ); return $fields; - } + } protected function render() { $settings = $this->get_settings_for_display(); $user = $settings['user'] ? $settings['user'] : 'no'; - $shortcode = sprintf( '[directorist_category header="%1$s" header_title="%2$s" view="%3$s" map_height="%4$s" columns="%5$s" listings_per_page="%6$s" show_pagination="%7$s" orderby="%8$s" order="%9$s" logged_in_user_only="%10$s"]', + $shortcode = sprintf( + '[directorist_category header="%1$s" header_title="%2$s" view="%3$s" map_height="%4$s" columns="%5$s" listings_per_page="%6$s" show_pagination="%7$s" orderby="%8$s" order="%9$s" logged_in_user_only="%10$s"]', esc_attr( $settings['header'] ), esc_attr( $settings['header_title'] ), esc_attr( $settings['view'] ), @@ -138,4 +141,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/checkout.php b/includes/elementor/checkout.php index 458a140833..9f6e0edd83 100644 --- a/includes/elementor/checkout.php +++ b/includes/elementor/checkout.php @@ -7,27 +7,29 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Checkout extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Cart/Checkout', 'directorist' ); $this->az_base = 'directorist_checkout'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::HEADING, - 'id' => 'sec_heading', - 'label' => $this->az_texts['checkout'], + 'type' => Controls_Manager::HEADING, + 'id' => 'sec_heading', + 'label' => $this->az_texts['checkout'], ), array( 'mode' => 'section_end', @@ -42,4 +44,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/custom-registration.php b/includes/elementor/custom-registration.php index 26ca3992c8..180ea89aeb 100644 --- a/includes/elementor/custom-registration.php +++ b/includes/elementor/custom-registration.php @@ -7,27 +7,29 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Custom_Registration extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Registration', 'directorist' ); $this->az_base = 'directorist_custom_registration'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::HEADING, - 'id' => 'sec_heading', - 'label' => __( 'This widget works only in Registration page. It has no additional elementor settings.', 'directorist' ), + 'type' => Controls_Manager::HEADING, + 'id' => 'sec_heading', + 'label' => __( 'This widget works only in Registration page. It has no additional elementor settings.', 'directorist' ), ), array( 'mode' => 'section_end', @@ -42,4 +44,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/deprecated-notice.php b/includes/elementor/deprecated-notice.php index c863d47fc3..9089408c48 100644 --- a/includes/elementor/deprecated-notice.php +++ b/includes/elementor/deprecated-notice.php @@ -35,7 +35,7 @@ public function __construct() { } $parent_plugin_data = get_plugin_data( $parent_path ); - $parent_plugin_version = explode( "-", $parent_plugin_data["Version"] )[0]; + $parent_plugin_version = explode( '-', $parent_plugin_data['Version'] )[0]; $this->is_valid = version_compare( $parent_plugin_version, $this->min_addon_version ) > -1; } } @@ -66,56 +66,81 @@ public function maybe_show_notice_for_required_plugins() { public function parent_plugin_invalid_notice() { ?> - <div class="notice notice-error" style="display: flex; flex-wrap:wrap; justify-content:space-between"> - <p style="display: flex; align-items: center;"> - The current version of your <strong><?php echo $this->parent_label; ?> is not compatible with <?php echo $this->core_plugin; ?></strong>. To ensure compatibility and access new features, <strong>update <?php echo $this->parent_label; ?> to version <?php echo $this->min_addon_version ?> or later</strong>. - </p> - </div> - <?php } + <div class="notice notice-error" style="display: flex; flex-wrap:wrap; justify-content:space-between"> + <p style="display: flex; align-items: center;"> + The current version of your <strong><?php echo $this->parent_label; ?> is not compatible with <?php echo $this->core_plugin; ?></strong>. To ensure compatibility and access new features, <strong>update <?php echo $this->parent_label; ?> to version <?php echo $this->min_addon_version; ?> or later</strong>. + </p> + </div> + <?php + } public function admin_notice_callback_to_activate_plugin(): void { $can_activate_plugin = $this->is_plugin_compatible( 'activate_plugin', $this->addon_requires_php, $this->addon_requires_wp ); ?> - <div class="notice notice-warning" style="display: flex; flex-wrap:wrap; justify-content:space-between"> - <p style="display: flex; align-items: center;"> - <span> - <?php echo wp_kses( sprintf( __( '<b>Deprecation</b>: We are not going to provide Elementor support in Directorist plugin, We have introduced huge features packed in <a href="%1$s" target="_blank">%2$s</a>', 'directorist' ), - esc_url( $this->addon_url ), - esc_html( $this->parent_label ), - esc_html( $this->core_plugin ) ), - ['a' => ['href' => true, 'target' => true], 'b' => []] ); ?> + <div class="notice notice-warning" style="display: flex; flex-wrap:wrap; justify-content:space-between"> + <p style="display: flex; align-items: center;"> + <span> + <?php + echo wp_kses( + sprintf( + __( '<b>Deprecation</b>: We are not going to provide Elementor support in Directorist plugin, We have introduced huge features packed in <a href="%1$s" target="_blank">%2$s</a>', 'directorist' ), + esc_url( $this->addon_url ), + esc_html( $this->parent_label ), + esc_html( $this->core_plugin ) + ), + array( + 'a' => array( + 'href' => true, + 'target' => true, + ), + 'b' => array(), + ) + ); + ?> </span> </p> - <?php if ( $can_activate_plugin ): ?> + <?php if ( $can_activate_plugin ) : ?> <p> <a class="button button-primary" href="<?php echo esc_url( $this->get_plugin_activation_url( $this->addon_slug ) ); ?>">Activate <?php echo $this->parent_label; ?></a> </p> - <?php endif;?> - </div> - <?php } + <?php endif; ?> + </div> + <?php + } public function admin_notice_callback_to_install_plugin(): void { $can_install_plugin = $this->is_plugin_compatible( 'install_plugins', $this->addon_requires_php, $this->addon_requires_wp ); ?> - <div class="notice notice-warning" style="display: flex; flex-wrap:wrap; justify-content:space-between"> - <p style="display: flex; align-items: center;"> - <span> - <?php echo wp_kses( sprintf( - __( '<b>Deprecation</b>: We are not going to provide Elementor support in Directorist plugin, We have introduced huge features packed in <a href="%1$s" target="_blank">%2$s</a>', 'directorist' ), - esc_url( $this->addon_url ), - esc_html( $this->parent_label ), - esc_html( $this->core_plugin ) ), - ['a' => ['href' => true, 'target' => true], 'b' => []] ); + <div class="notice notice-warning" style="display: flex; flex-wrap:wrap; justify-content:space-between"> + <p style="display: flex; align-items: center;"> + <span> + <?php + echo wp_kses( + sprintf( + __( '<b>Deprecation</b>: We are not going to provide Elementor support in Directorist plugin, We have introduced huge features packed in <a href="%1$s" target="_blank">%2$s</a>', 'directorist' ), + esc_url( $this->addon_url ), + esc_html( $this->parent_label ), + esc_html( $this->core_plugin ) + ), + array( + 'a' => array( + 'href' => true, + 'target' => true, + ), + 'b' => array(), + ) + ); ?> - </span> - </p> - <?php if ( $can_install_plugin ): ?> + </span> + </p> + <?php if ( $can_install_plugin ) : ?> <p> <a class="button button-primary" href="<?php echo esc_url( $this->get_plugin_installation_url( $this->addon_slug ) ); ?>">Install <?php echo $this->parent_label; ?></a> </p> - <?php endif;?> - </div> - <?php } + <?php endif; ?> + </div> + <?php + } public function is_plugin_compatible( string $context, ?string $requires_php = null, ?string $requires_wp = null ) { $can_use_plugin = current_user_can( $context ); diff --git a/includes/elementor/init.php b/includes/elementor/init.php index b5cba49738..4466387a22 100644 --- a/includes/elementor/init.php +++ b/includes/elementor/init.php @@ -7,9 +7,11 @@ use Elementor\Plugin; -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly +if ( ! defined( 'ABSPATH' ) ) { + exit; // Exit if accessed directly +} -if( class_exists( 'AddonskitForELementor' ) ) { +if ( class_exists( 'AddonskitForELementor' ) ) { return; } @@ -23,14 +25,14 @@ class Widget_Init { private function __construct() { $this->init(); - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_style' ) ); + add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_style' ) ); add_action( 'elementor/elements/categories_registered', array( $this, 'widget_categoty' ) ); // add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) ); } public static function instance() { if ( null == self::$instance ) { - self::$instance = new self; + self::$instance = new self(); } return self::$instance; } @@ -41,22 +43,22 @@ private function init() { // Widgets -- filename=>classname $widgets = array( - 'all-listing' => 'Directorist_All_Listing', - 'all-categories' => 'Directorist_All_Categories', - 'all-locations' => 'Directorist_All_Locations', - 'category' => 'Directorist_Category', - 'location' => 'Directorist_Location', - 'tag' => 'Directorist_Tag', - 'search-listing' => 'Directorist_Search_Listing', - 'search-result' => 'Directorist_Search_Result', - 'add-listing' => 'Directorist_Add_Listing', - 'user-login' => 'Directorist_User_Login', - 'custom-registration' => 'Directorist_Custom_Registration', - 'user-dashboard' => 'Directorist_User_Dashboard', - 'author-profile' => 'Directorist_Author_Profile', - 'transaction-failure' => 'Directorist_Transaction_Failure', - 'payment-receipt' => 'Directorist_Payment_Receipt', - 'checkout' => 'Directorist_Checkout', + 'all-listing' => 'Directorist_All_Listing', + 'all-categories' => 'Directorist_All_Categories', + 'all-locations' => 'Directorist_All_Locations', + 'category' => 'Directorist_Category', + 'location' => 'Directorist_Location', + 'tag' => 'Directorist_Tag', + 'search-listing' => 'Directorist_Search_Listing', + 'search-result' => 'Directorist_Search_Result', + 'add-listing' => 'Directorist_Add_Listing', + 'user-login' => 'Directorist_User_Login', + 'custom-registration' => 'Directorist_Custom_Registration', + 'user-dashboard' => 'Directorist_User_Dashboard', + 'author-profile' => 'Directorist_Author_Profile', + 'transaction-failure' => 'Directorist_Transaction_Failure', + 'payment-receipt' => 'Directorist_Payment_Receipt', + 'checkout' => 'Directorist_Checkout', ); $this->widgets = apply_filters( 'atbdp_elementor_widgets', $widgets ); @@ -64,7 +66,7 @@ private function init() { public function editor_style() { $img = DIRECTORIST_ASSETS . 'images/elementor-icon.png'; - wp_add_inline_style( 'elementor-editor', '.elementor-control-type-select2 .elementor-control-input-wrapper {min-width: 130px;}.elementor-element .icon .directorist-el-custom{content: url('.$img.');width: 22px;}' ); + wp_add_inline_style( 'elementor-editor', '.elementor-control-type-select2 .elementor-control-input-wrapper {min-width: 130px;}.elementor-element .icon .directorist-el-custom{content: url(' . $img . ');width: 22px;}' ); } public function widget_categoty( $class ) { @@ -83,11 +85,9 @@ public function register_widgets() { $template_name = '/directorist-elementor/' . $filename . '.php'; if ( file_exists( STYLESHEETPATH . $template_name ) ) { $file = STYLESHEETPATH . $template_name; - } - elseif ( file_exists( TEMPLATEPATH . $template_name ) ) { + } elseif ( file_exists( TEMPLATEPATH . $template_name ) ) { $file = TEMPLATEPATH . $template_name; - } - else { + } else { $file = __DIR__ . '/' . $filename . '.php'; } @@ -98,32 +98,35 @@ public function register_widgets() { $elementor_widgets_manager = Plugin::instance()->widgets_manager; if ( method_exists( $elementor_widgets_manager, 'register' ) ) { - $elementor_widgets_manager->register( new $classname ); + $elementor_widgets_manager->register( new $classname() ); } else { // Remove this deprececated check safely after 30 June, 2024 - $elementor_widgets_manager->register_widget_type( new $classname ); + $elementor_widgets_manager->register_widget_type( new $classname() ); } } } } -add_action( 'after_setup_theme', function() { - if ( did_action( 'elementor/loaded' ) ) { - $activated = apply_filters( 'atbdp_elementor_widgets_activated', true ); - if ( $activated ) { - Widget_Init::instance(); - } +add_action( + 'after_setup_theme', + function () { + if ( did_action( 'elementor/loaded' ) ) { + $activated = apply_filters( 'atbdp_elementor_widgets_activated', true ); + if ( $activated ) { + Widget_Init::instance(); + } - include_once 'deprecated-notice.php'; - $dn = new DeprecatedNotice(); - add_action( 'admin_notices', [$dn, 'maybe_show_notice_for_required_plugins'] ); + include_once 'deprecated-notice.php'; + $dn = new DeprecatedNotice(); + add_action( 'admin_notices', array( $dn, 'maybe_show_notice_for_required_plugins' ) ); + } } -} ); +); /** * Elementor compatibility with custom single listing page. * - * @param string $content + * @param string $content * @param WP_Post $page * * @return string diff --git a/includes/elementor/location.php b/includes/elementor/location.php index a2b832782c..8bffe85cae 100644 --- a/includes/elementor/location.php +++ b/includes/elementor/location.php @@ -7,28 +7,30 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Location extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Single Location', 'directorist' ); $this->az_base = 'directorist_location'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'header', - 'label' => __( 'Show Header?', 'directorist' ), - 'default' => 'yes', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'header', + 'label' => __( 'Show Header?', 'directorist' ), + 'default' => 'yes', ), array( 'type' => Controls_Manager::TEXT, @@ -62,26 +64,26 @@ public function az_fields(){ 'id' => 'columns', 'label' => __( 'Locations Per Row', 'directorist' ), 'options' => array( - '3' => __( '3 Items / Row', 'directorist' ), - '4' => __( '4 Items / Row', 'directorist' ), - '5' => __( '5 Items / Row', 'directorist' ), + '3' => __( '3 Items / Row', 'directorist' ), + '4' => __( '4 Items / Row', 'directorist' ), + '5' => __( '5 Items / Row', 'directorist' ), ), 'default' => '3', ), array( - 'type' => Controls_Manager::NUMBER, - 'id' => 'number_loc', - 'label' => __( 'Number of locations to Show', 'directorist' ), - 'min' => 1, - 'max' => 100, - 'step' => 1, - 'default' => 6, + 'type' => Controls_Manager::NUMBER, + 'id' => 'number_loc', + 'label' => __( 'Number of locations to Show', 'directorist' ), + 'min' => 1, + 'max' => 100, + 'step' => 1, + 'default' => 6, ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'show_pagination', - 'label' => __( 'Show Pagination?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'show_pagination', + 'label' => __( 'Show Pagination?', 'directorist' ), + 'default' => 'no', ), array( 'type' => Controls_Manager::SELECT, @@ -105,24 +107,25 @@ public function az_fields(){ 'default' => 'desc', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Only For Logged In User?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Only For Logged In User?', 'directorist' ), + 'default' => 'no', ), array( 'mode' => 'section_end', ), ); return $fields; - } + } protected function render() { $settings = $this->get_settings_for_display(); $user = $settings['user'] ? $settings['user'] : 'no'; - $shortcode = sprintf( '[directorist_location header="%1$s" header_title="%2$s" view="%3$s" map_height="%4$s" columns="%5$s" listings_per_page="%6$s" show_pagination="%7$s" orderby="%8$s" order="%9$s" logged_in_user_only="%10$s" ]', + $shortcode = sprintf( + '[directorist_location header="%1$s" header_title="%2$s" view="%3$s" map_height="%4$s" columns="%5$s" listings_per_page="%6$s" show_pagination="%7$s" orderby="%8$s" order="%9$s" logged_in_user_only="%10$s" ]', esc_attr( $settings['header'] ), esc_attr( $settings['header_title'] ), esc_attr( $settings['view'] ), @@ -137,4 +140,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/payment-receipt.php b/includes/elementor/payment-receipt.php index 0a1ca8508a..2d19eef639 100644 --- a/includes/elementor/payment-receipt.php +++ b/includes/elementor/payment-receipt.php @@ -7,28 +7,30 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Payment_Receipt extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Payment Receipt', 'directorist' ); $this->az_base = 'directorist_payment_receipt'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::HEADING, - 'id' => 'sec_heading', - 'label' => $this->az_texts['payment'], + 'type' => Controls_Manager::HEADING, + 'id' => 'sec_heading', + 'label' => $this->az_texts['payment'], ), array( 'mode' => 'section_end', @@ -43,4 +45,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/search-listing.php b/includes/elementor/search-listing.php index 00b5387aa6..1a39b2a277 100644 --- a/includes/elementor/search-listing.php +++ b/includes/elementor/search-listing.php @@ -8,11 +8,13 @@ use Elementor\Controls_Manager; use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Search_Listing extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Search Form', 'directorist' ); $this->az_base = 'directorist_search_listing'; parent::__construct( $data, $args ); @@ -28,18 +30,18 @@ private function az_listing_types() { return wp_list_pluck( $directories, 'name', 'slug' ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'show_subtitle', - 'label' => __( 'Add Element Title & Subtitle?', 'directorist' ), - 'default' => 'yes', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'show_subtitle', + 'label' => __( 'Add Element Title & Subtitle?', 'directorist' ), + 'default' => 'yes', ), array( 'type' => Controls_Manager::CHOOSE, @@ -81,31 +83,31 @@ public function az_fields(){ 'condition' => array( 'show_subtitle' => array( 'yes' ) ), ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'type', - 'label' => __( 'Directory Types', 'directorist' ), - 'multiple' => true, - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'type', + 'label' => __( 'Directory Types', 'directorist' ), + 'multiple' => true, + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( - 'type' => Controls_Manager::SELECT2, - 'id' => 'default_type', - 'label' => __( 'Default Directory Types', 'directorist' ), - 'options' => $this->az_listing_types(), - 'condition' => directorist_is_multi_directory_enabled() ? '' : ['nocondition' => true], + 'type' => Controls_Manager::SELECT2, + 'id' => 'default_type', + 'label' => __( 'Default Directory Types', 'directorist' ), + 'options' => $this->az_listing_types(), + 'condition' => directorist_is_multi_directory_enabled() ? '' : array( 'nocondition' => true ), ), array( - 'type' => Controls_Manager::TEXT, - 'id' => 'search_btn_text', - 'label' => __( 'Search Button Label', 'directorist' ), - 'default' => __( 'Search Listing', 'directorist' ), + 'type' => Controls_Manager::TEXT, + 'id' => 'search_btn_text', + 'label' => __( 'Search Button Label', 'directorist' ), + 'default' => __( 'Search Listing', 'directorist' ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'show_more_filter_btn', - 'label' => __( 'Show More Search Field?', 'directorist' ), - 'default' => 'yes', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'show_more_filter_btn', + 'label' => __( 'Show More Search Field?', 'directorist' ), + 'default' => 'yes', ), array( 'type' => Controls_Manager::TEXT, @@ -126,7 +128,10 @@ public function az_fields(){ 'id' => 'more_filter_reset_btn_text', 'label' => __( 'More Field Reset Button Label', 'directorist' ), 'default' => __( 'Reset Filters', 'directorist' ), - 'condition' => array( 'more_filter_reset_btn' => 'yes', 'show_more_filter_btn' => 'yes' ), + 'condition' => array( + 'more_filter_reset_btn' => 'yes', + 'show_more_filter_btn' => 'yes', + ), ), array( 'type' => Controls_Manager::SWITCHER, @@ -140,22 +145,25 @@ public function az_fields(){ 'id' => 'more_filter_search_btn_text', 'label' => __( 'More Field Search Button Label', 'directorist' ), 'default' => __( 'Apply Filters', 'directorist' ), - 'condition' => array( 'more_filter_search_btn' => 'yes', 'show_more_filter_btn' => 'yes' ), + 'condition' => array( + 'more_filter_search_btn' => 'yes', + 'show_more_filter_btn' => 'yes', + ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Show only for logged in user?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Show only for logged in user?', 'directorist' ), + 'default' => 'no', ), array( 'mode' => 'section_end', ), array( - 'mode' => 'section_start', - 'id' => 'sec_style', - 'tab' => Controls_Manager::TAB_STYLE, - 'label' => __( 'Color', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_style', + 'tab' => Controls_Manager::TAB_STYLE, + 'label' => __( 'Color', 'directorist' ), 'condition' => array( 'show_subtitle' => array( 'yes' ) ), ), array( @@ -178,10 +186,10 @@ public function az_fields(){ 'mode' => 'section_end', ), array( - 'mode' => 'section_start', - 'id' => 'sec_style_type', - 'tab' => Controls_Manager::TAB_STYLE, - 'label' => __( 'Typography', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_style_type', + 'tab' => Controls_Manager::TAB_STYLE, + 'label' => __( 'Typography', 'directorist' ), 'condition' => array( 'show_subtitle' => array( 'yes' ) ), ), array( @@ -209,17 +217,17 @@ protected function render() { $settings = $this->get_settings_for_display(); $atts = array( - 'show_title_subtitle' => $settings['show_subtitle'], - 'search_bar_title' => $settings['title'], - 'search_bar_sub_title' => $settings['subtitle'], - 'search_button_text' => $settings['search_btn_text'], - 'more_filters_button' => $settings['show_more_filter_btn'], - 'more_filters_text' => $settings['more_filter_btn_text'], - 'reset_filters_button' => $settings['more_filter_reset_btn'], - 'apply_filters_button' => $settings['more_filter_search_btn'], - 'reset_filters_text' => $settings['more_filter_reset_btn_text'], - 'apply_filters_text' => $settings['more_filter_search_btn_text'], - 'logged_in_user_only' => $settings['user'] ? $settings['user'] : 'no', + 'show_title_subtitle' => $settings['show_subtitle'], + 'search_bar_title' => $settings['title'], + 'search_bar_sub_title' => $settings['subtitle'], + 'search_button_text' => $settings['search_btn_text'], + 'more_filters_button' => $settings['show_more_filter_btn'], + 'more_filters_text' => $settings['more_filter_btn_text'], + 'reset_filters_button' => $settings['more_filter_reset_btn'], + 'apply_filters_button' => $settings['more_filter_search_btn'], + 'reset_filters_text' => $settings['more_filter_reset_btn_text'], + 'apply_filters_text' => $settings['more_filter_search_btn_text'], + 'logged_in_user_only' => $settings['user'] ? $settings['user'] : 'no', ); if ( directorist_is_multi_directory_enabled() ) { @@ -233,4 +241,4 @@ protected function render() { $this->az_run_shortcode( 'directorist_search_listing', $atts ); } -} \ No newline at end of file +} diff --git a/includes/elementor/search-result.php b/includes/elementor/search-result.php index 78b1a5689b..959990fd27 100644 --- a/includes/elementor/search-result.php +++ b/includes/elementor/search-result.php @@ -7,28 +7,30 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Search_Result extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Search Result', 'directorist' ); $this->az_base = 'directorist_search_result'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'header', - 'label' => __( 'Show Header?', 'directorist' ), - 'default' => 'yes', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'header', + 'label' => __( 'Show Header?', 'directorist' ), + 'default' => 'yes', ), array( 'type' => Controls_Manager::TEXT, @@ -65,37 +67,37 @@ public function az_fields(){ 'condition' => array( 'view' => array( 'map' ) ), ), array( - 'type' => Controls_Manager::SELECT, - 'id' => 'columns', - 'label' => __( 'Locations Per Row', 'directorist' ), - 'options' => array( - '3' => __( '3 Items / Row', 'directorist' ), - '4' => __( '4 Items / Row', 'directorist' ), - '5' => __( '5 Items / Row', 'directorist' ), + 'type' => Controls_Manager::SELECT, + 'id' => 'columns', + 'label' => __( 'Locations Per Row', 'directorist' ), + 'options' => array( + '3' => __( '3 Items / Row', 'directorist' ), + '4' => __( '4 Items / Row', 'directorist' ), + '5' => __( '5 Items / Row', 'directorist' ), ), - 'default' => '3', + 'default' => '3', 'condition' => array( 'view' => array( 'grid' ) ), ), array( - 'type' => Controls_Manager::NUMBER, - 'id' => 'number', - 'label' => __( 'Number of Listing to Show:', 'directorist' ), - 'min' => 1, - 'max' => 100, - 'step' => 1, - 'default' => 6, + 'type' => Controls_Manager::NUMBER, + 'id' => 'number', + 'label' => __( 'Number of Listing to Show:', 'directorist' ), + 'min' => 1, + 'max' => 100, + 'step' => 1, + 'default' => 6, ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'featured_only', - 'label' => __( 'Only Featured', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'featured_only', + 'label' => __( 'Only Featured', 'directorist' ), + 'default' => 'no', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'popular_only', - 'label' => __( 'Only Popular', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'popular_only', + 'label' => __( 'Only Popular', 'directorist' ), + 'default' => 'no', ), array( 'type' => Controls_Manager::SELECT, @@ -119,32 +121,33 @@ public function az_fields(){ 'default' => 'desc', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Only For Logged In User?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Only For Logged In User?', 'directorist' ), + 'default' => 'no', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'show_pagination', - 'label' => __( 'Show Pagination?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'show_pagination', + 'label' => __( 'Show Pagination?', 'directorist' ), + 'default' => 'no', ), array( 'mode' => 'section_end', ), ); return $fields; - } + } protected function render() { $settings = $this->get_settings_for_display(); - $user = $settings['user'] ? $settings['user'] : 'no'; - $featured_only = $settings['featured_only'] ? $settings['featured_only'] : 'no'; - $popular_only = $settings['popular_only'] ? $settings['popular_only'] : 'no'; + $user = $settings['user'] ? $settings['user'] : 'no'; + $featured_only = $settings['featured_only'] ? $settings['featured_only'] : 'no'; + $popular_only = $settings['popular_only'] ? $settings['popular_only'] : 'no'; - $shortcode = sprintf( '[directorist_search_result header="%1$s" header_title="%2$s" header_sub_title="%3$s" view="%4$s" map_height="%5$s" columns="%6$s" listings_per_page="%7$s" show_pagination="%8$s" orderby="%9$s" order="%10$s" featured_only="%11$s" popular_only="%12$s" logged_in_user_only="%13$s" ]', + $shortcode = sprintf( + '[directorist_search_result header="%1$s" header_title="%2$s" header_sub_title="%3$s" view="%4$s" map_height="%5$s" columns="%6$s" listings_per_page="%7$s" show_pagination="%8$s" orderby="%9$s" order="%10$s" featured_only="%11$s" popular_only="%12$s" logged_in_user_only="%13$s" ]', esc_attr( $settings['header'] ), esc_attr( $settings['header_title'] ), esc_attr( $settings['header_sub_title'] ), @@ -162,4 +165,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/tag.php b/includes/elementor/tag.php index 6c028b3ad1..1f74511170 100644 --- a/includes/elementor/tag.php +++ b/includes/elementor/tag.php @@ -7,28 +7,30 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Tag extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Single Tag', 'directorist' ); $this->az_base = 'directorist_tag'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'header', - 'label' => __( 'Show Header?', 'directorist' ), - 'default' => 'yes', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'header', + 'label' => __( 'Show Header?', 'directorist' ), + 'default' => 'yes', ), array( 'type' => Controls_Manager::TEXT, @@ -62,26 +64,26 @@ public function az_fields(){ 'id' => 'columns', 'label' => __( 'Locations Per Row', 'directorist' ), 'options' => array( - '3' => __( '3 Items / Row', 'directorist' ), - '4' => __( '4 Items / Row', 'directorist' ), - '5' => __( '5 Items / Row', 'directorist' ), + '3' => __( '3 Items / Row', 'directorist' ), + '4' => __( '4 Items / Row', 'directorist' ), + '5' => __( '5 Items / Row', 'directorist' ), ), 'default' => '3', ), array( - 'type' => Controls_Manager::NUMBER, - 'id' => 'number_loc', - 'label' => __( 'Number of locations to Show', 'directorist' ), - 'min' => 1, - 'max' => 100, - 'step' => 1, - 'default' => 6, + 'type' => Controls_Manager::NUMBER, + 'id' => 'number_loc', + 'label' => __( 'Number of locations to Show', 'directorist' ), + 'min' => 1, + 'max' => 100, + 'step' => 1, + 'default' => 6, ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'show_pagination', - 'label' => __( 'Show Pagination?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'show_pagination', + 'label' => __( 'Show Pagination?', 'directorist' ), + 'default' => 'no', ), array( 'type' => Controls_Manager::SELECT, @@ -105,30 +107,31 @@ public function az_fields(){ 'default' => 'desc', ), array( - 'type' => Controls_Manager::SWITCHER, - 'id' => 'user', - 'label' => __( 'Only For Logged In User?', 'directorist' ), - 'default' => 'no', + 'type' => Controls_Manager::SWITCHER, + 'id' => 'user', + 'label' => __( 'Only For Logged In User?', 'directorist' ), + 'default' => 'no', ), array( - 'type' => Controls_Manager::TEXT, - 'id' => 'redirect_page_url', - 'label' => __( 'Redirect Page Link', 'directorist' ), - 'default' => '', + 'type' => Controls_Manager::TEXT, + 'id' => 'redirect_page_url', + 'label' => __( 'Redirect Page Link', 'directorist' ), + 'default' => '', ), array( 'mode' => 'section_end', ), ); return $fields; - } + } protected function render() { $settings = $this->get_settings_for_display(); $user = $settings['user'] ? $settings['user'] : 'no'; - $shortcode = sprintf( '[directorist_tag header="%1$s" header_title="%2$s" view="%3$s" map_height="%4$s" columns="%5$s" listings_per_page="%6$s" show_pagination="%7$s" orderby="%8$s" order="%9$s" redirect_page_url="%10$s" logged_in_user_only="%11$s" ]', + $shortcode = sprintf( + '[directorist_tag header="%1$s" header_title="%2$s" view="%3$s" map_height="%4$s" columns="%5$s" listings_per_page="%6$s" show_pagination="%7$s" orderby="%8$s" order="%9$s" redirect_page_url="%10$s" logged_in_user_only="%11$s" ]', esc_attr( $settings['header'] ), esc_attr( $settings['header_title'] ), esc_attr( $settings['view'] ), @@ -144,4 +147,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/transaction-failure.php b/includes/elementor/transaction-failure.php index da9ee9d783..a18095c88c 100644 --- a/includes/elementor/transaction-failure.php +++ b/includes/elementor/transaction-failure.php @@ -7,28 +7,30 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Transaction_Failure extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Transaction Failure', 'directorist' ); $this->az_base = 'directorist_transaction_failure'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::HEADING, - 'id' => 'sec_heading', - 'label' => $this->az_texts['transaction'], + 'type' => Controls_Manager::HEADING, + 'id' => 'sec_heading', + 'label' => $this->az_texts['transaction'], ), array( 'mode' => 'section_end', @@ -43,4 +45,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/user-dashboard.php b/includes/elementor/user-dashboard.php index 107d436495..88a6d73c65 100644 --- a/includes/elementor/user-dashboard.php +++ b/includes/elementor/user-dashboard.php @@ -7,27 +7,29 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_User_Dashboard extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Dashboard', 'directorist' ); $this->az_base = 'directorist_user_dashboard'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::HEADING, - 'id' => 'sec_heading', - 'label' => __( 'This widget works only in Dashboard page. It has no additional elementor settings.', 'directorist' ), + 'type' => Controls_Manager::HEADING, + 'id' => 'sec_heading', + 'label' => __( 'This widget works only in Dashboard page. It has no additional elementor settings.', 'directorist' ), ), array( 'mode' => 'section_end', @@ -42,4 +44,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/elementor/user-login.php b/includes/elementor/user-login.php index 692ff45e5b..a53c74f429 100644 --- a/includes/elementor/user-login.php +++ b/includes/elementor/user-login.php @@ -7,27 +7,29 @@ use Elementor\Controls_Manager; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_User_Login extends Custom_Widget_Base { - public function __construct( $data = [], $args = null ) { + public function __construct( $data = array(), $args = null ) { $this->az_name = __( 'Login', 'directorist' ); $this->az_base = 'directorist_user_login'; parent::__construct( $data, $args ); } - public function az_fields(){ + public function az_fields() { $fields = array( array( - 'mode' => 'section_start', - 'id' => 'sec_general', - 'label' => __( 'General', 'directorist' ), + 'mode' => 'section_start', + 'id' => 'sec_general', + 'label' => __( 'General', 'directorist' ), ), array( - 'type' => Controls_Manager::HEADING, - 'id' => 'sec_heading', - 'label' => __( 'This widget works only in Login page. It has no additional elementor settings.', 'directorist' ), + 'type' => Controls_Manager::HEADING, + 'id' => 'sec_heading', + 'label' => __( 'This widget works only in Login page. It has no additional elementor settings.', 'directorist' ), ), array( 'mode' => 'section_end', @@ -42,4 +44,4 @@ protected function render() { echo do_shortcode( $shortcode ); } -} \ No newline at end of file +} diff --git a/includes/fields/class-directorist-base-field.php b/includes/fields/class-directorist-base-field.php index 9aea78251a..df2c4555cf 100644 --- a/includes/fields/class-directorist-base-field.php +++ b/includes/fields/class-directorist-base-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Builder Field Abstract class. - * */ namespace Directorist\Fields; @@ -39,24 +38,24 @@ public function get_props() { return $this->props; } - public function get_key() : string { - return ( string ) $this->field_key; + public function get_key(): string { + return (string) $this->field_key; } - public function get_internal_key() : string { - return ( string ) $this->widget_key; + public function get_internal_key(): string { + return (string) $this->widget_key; } - public function is_admin_only() : bool { - return ( bool ) $this->only_for_admin; + public function is_admin_only(): bool { + return (bool) $this->only_for_admin; } - public function is_required() : bool { - return ( bool ) $this->required; + public function is_required(): bool { + return (bool) $this->required; } - public function is_preset() : bool { - return ( bool ) ( $this->widget_group === 'preset' ); + public function is_preset(): bool { + return (bool) ( $this->widget_group === 'preset' ); } public function is_category_only() { diff --git a/includes/fields/class-directorist-categories-field.php b/includes/fields/class-directorist-categories-field.php index 1d473006fe..fe119f1a0b 100644 --- a/includes/fields/class-directorist-categories-field.php +++ b/includes/fields/class-directorist-categories-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Categories Field class. - * */ namespace Directorist\Fields; @@ -13,11 +12,11 @@ class Categories_Field extends Taxonomy_Field { public $type = 'categories'; - function get_taxonomy() : string { + function get_taxonomy(): string { return ATBDP_CATEGORY; } - public function user_can_create() : bool { + public function user_can_create(): bool { return (bool) $this->create_new_cat; } } diff --git a/includes/fields/class-directorist-checkbox-field.php b/includes/fields/class-directorist-checkbox-field.php index b54f8082e9..f1339e5a50 100644 --- a/includes/fields/class-directorist-checkbox-field.php +++ b/includes/fields/class-directorist-checkbox-field.php @@ -19,9 +19,12 @@ public function get_options() { return array(); } - return array_map( static function( $option ) { - return str_replace( '<', '<', $option['option_value'] ); - }, $options ); + return array_map( + static function ( $option ) { + return str_replace( '<', '<', $option['option_value'] ); + }, + $options + ); } public function validate( $posted_data ) { @@ -35,7 +38,7 @@ public function validate( $posted_data ) { return true; } - + public function sanitize( $posted_data ) { return directorist_clean( $this->get_value( $posted_data ) ); } diff --git a/includes/fields/class-directorist-colorpicker-field.php b/includes/fields/class-directorist-colorpicker-field.php index 6a0ab18e4d..cebccaffa0 100644 --- a/includes/fields/class-directorist-colorpicker-field.php +++ b/includes/fields/class-directorist-colorpicker-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Color Picker Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-date-field.php b/includes/fields/class-directorist-date-field.php index 32584db35a..1212d5c275 100644 --- a/includes/fields/class-directorist-date-field.php +++ b/includes/fields/class-directorist-date-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Date Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-description-field.php b/includes/fields/class-directorist-description-field.php index bae6a865e3..ed57abe77e 100644 --- a/includes/fields/class-directorist-description-field.php +++ b/includes/fields/class-directorist-description-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Description Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-email-field.php b/includes/fields/class-directorist-email-field.php index c762f04a3f..e0c1fa1271 100644 --- a/includes/fields/class-directorist-email-field.php +++ b/includes/fields/class-directorist-email-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Email Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-fields.php b/includes/fields/class-directorist-fields.php index 9310d6f5bc..e0eca1a7d3 100644 --- a/includes/fields/class-directorist-fields.php +++ b/includes/fields/class-directorist-fields.php @@ -1,7 +1,6 @@ <?php /** * Directorist Fields manager class. - * */ namespace Directorist\Fields; @@ -86,20 +85,20 @@ public static function create( $properties ) { public static function translate_key_to_field( $type ) { $map = array( - 'address' => 'text', - 'category' => 'categories', - 'color' => 'color_picker', - 'excerpt' => 'textarea', - 'fax' => 'text', - 'hide_contact_owner' => 'switch', - 'title' => 'text', - 'location' => 'locations', - 'phone' => 'text', - 'phone2' => 'text', - 'tag' => 'tags', - 'tagline' => 'text', - 'website' => 'url', - 'zip' => 'text', + 'address' => 'text', + 'category' => 'categories', + 'color' => 'color_picker', + 'excerpt' => 'textarea', + 'fax' => 'text', + 'hide_contact_owner' => 'switch', + 'title' => 'text', + 'location' => 'locations', + 'phone' => 'text', + 'phone2' => 'text', + 'tag' => 'tags', + 'tagline' => 'text', + 'website' => 'url', + 'zip' => 'text', // Custom fields in themes 'ddoctors-accept-new-patient' => 'text', 'ddoctors-gender' => 'text', @@ -114,7 +113,7 @@ public static function translate_key_to_field( $type ) { 'dlawyers_gender' => 'number', 'drealestate-number' => 'number', 'drealestate-area' => 'number', - 'dclassified-bullet-list' => 'textarea', + 'dclassified-bullet-list' => 'textarea', 'ddoctors-bullet-list' => 'textarea', 'djobs_bullet_list' => 'textarea', 'dlawyers_bullet_list' => 'textarea', diff --git a/includes/fields/class-directorist-file-field.php b/includes/fields/class-directorist-file-field.php index 4a129561cd..e6add51460 100644 --- a/includes/fields/class-directorist-file-field.php +++ b/includes/fields/class-directorist-file-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist File Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-image-upload-field.php b/includes/fields/class-directorist-image-upload-field.php index 8dd57046c3..798d82c630 100644 --- a/includes/fields/class-directorist-image-upload-field.php +++ b/includes/fields/class-directorist-image-upload-field.php @@ -38,10 +38,12 @@ public function validate( $posted_data ) { } if ( $this->get_total_upload_limit() !== 0 && ( ( count( $old_images ) + count( $new_images ) ) > $this->get_total_upload_limit() ) ) { - $this->add_error( sprintf( - _n( '%s image allowed only.', '%s images allowed only.', $this->get_total_upload_limit(), 'directorist' ), - $this->get_total_upload_limit() - ) ); + $this->add_error( + sprintf( + _n( '%s image allowed only.', '%s images allowed only.', $this->get_total_upload_limit(), 'directorist' ), + $this->get_total_upload_limit() + ) + ); return false; } @@ -53,7 +55,7 @@ public function validate( $posted_data ) { $total_size = 0; foreach ( $new_images as $file ) { - $filepath = realpath( $temp_dir . $file ); + $filepath = realpath( $temp_dir . $file ); if ( empty( $file ) || ! $filepath ) { continue; @@ -64,29 +66,35 @@ public function validate( $posted_data ) { if ( ! $real_mime || strpos( $real_mime, 'image' ) === false ) { - $this->add_error( sprintf( - __( '[%1$s] invalid file type, only image allowed.', 'directorist' ), - $file - ) ); + $this->add_error( + sprintf( + __( '[%1$s] invalid file type, only image allowed.', 'directorist' ), + $file + ) + ); continue; } if ( $filesize > $this->get_per_image_upload_size() ) { - $this->add_error( sprintf( - __( '[%1$s] size exceeded, %2$s is allowed only.', 'directorist' ), - $file, - size_format( $this->get_per_image_upload_size() ) - ) ); + $this->add_error( + sprintf( + __( '[%1$s] size exceeded, %2$s is allowed only.', 'directorist' ), + $file, + size_format( $this->get_per_image_upload_size() ) + ) + ); } $total_size += $filesize; if ( $total_size > $this->get_total_upload_size() ) { - $this->add_error( sprintf( - __( 'Total upload size (%s) exceeded.', 'directorist' ), - size_format( $this->get_total_upload_size() ) - ) ); + $this->add_error( + sprintf( + __( 'Total upload size (%s) exceeded.', 'directorist' ), + size_format( $this->get_total_upload_size() ) + ) + ); break; } @@ -108,7 +116,7 @@ public function get_total_upload_size() { $unit = 'MB'; if ( $size_in_mb < 1 ) { - $unit = 'KB'; + $unit = 'KB'; $size_in_mb = KB_IN_BYTES * $size_in_mb; } @@ -120,7 +128,7 @@ public function get_per_image_upload_size() { $unit = 'MB'; if ( $size_in_mb < 1 ) { - $unit = 'KB'; + $unit = 'KB'; $size_in_mb = KB_IN_BYTES * $size_in_mb; } diff --git a/includes/fields/class-directorist-locations-field.php b/includes/fields/class-directorist-locations-field.php index 437d6c90aa..b592fcab83 100644 --- a/includes/fields/class-directorist-locations-field.php +++ b/includes/fields/class-directorist-locations-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Locations Field class. - * */ namespace Directorist\Fields; @@ -13,11 +12,11 @@ class Locations_Field extends Taxonomy_Field { public $type = 'locations'; - function get_taxonomy() : string { + function get_taxonomy(): string { return ATBDP_LOCATION; } - public function user_can_create() : bool { + public function user_can_create(): bool { return (bool) $this->create_new_loc; } } diff --git a/includes/fields/class-directorist-map-field.php b/includes/fields/class-directorist-map-field.php index d492887651..081bae0026 100644 --- a/includes/fields/class-directorist-map-field.php +++ b/includes/fields/class-directorist-map-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Map Field class. - * */ namespace Directorist\Fields; @@ -21,7 +20,7 @@ public function get_value( $posted_data ) { return array( 'hide_map' => (bool) sanitize_text_field( directorist_get_var( $posted_data['hide_map'] ) ), 'manual_lat' => sanitize_text_field( directorist_get_var( $posted_data['manual_lat'] ) ), - 'manual_lng' => sanitize_text_field( directorist_get_var( $posted_data['manual_lng'] ) ) + 'manual_lng' => sanitize_text_field( directorist_get_var( $posted_data['manual_lng'] ) ), ); } } diff --git a/includes/fields/class-directorist-number-field.php b/includes/fields/class-directorist-number-field.php index 4df2edfddd..9f49bbdf87 100644 --- a/includes/fields/class-directorist-number-field.php +++ b/includes/fields/class-directorist-number-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Number Field class. - * */ namespace Directorist\Fields; @@ -15,9 +14,9 @@ class Number_Field extends Base_Field { public function validate( $posted_data ) { $value = $this->get_value( $posted_data ); - $min_value = $this->__get('min_value'); - $max_value = $this->__get('max_value'); - + $min_value = $this->__get( 'min_value' ); + $max_value = $this->__get( 'max_value' ); + if ( ! is_numeric( $value ) ) { $this->add_error( __( 'Invalid number.', 'directorist' ) ); @@ -25,7 +24,7 @@ public function validate( $posted_data ) { } if ( isset( $min_value, $max_value ) && ( $min_value > $value || ( $max_value > 0 && $max_value < $value ) ) ) { - $error_message = sprintf( __( 'Value should be between %d and %d', 'directorist' ), $min_value, $max_value ); + $error_message = sprintf( __( 'Value should be between %1$d and %2$d', 'directorist' ), $min_value, $max_value ); $this->add_error( $error_message ); return false; diff --git a/includes/fields/class-directorist-pricing-field.php b/includes/fields/class-directorist-pricing-field.php index 762d7c0afc..2565cc4b32 100644 --- a/includes/fields/class-directorist-pricing-field.php +++ b/includes/fields/class-directorist-pricing-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Pricing Field class. - * */ namespace Directorist\Fields; @@ -25,7 +24,7 @@ public function get_value( $posted_data ) { return array( 'price_type' => sanitize_text_field( directorist_get_var( $posted_data['atbd_listing_pricing'] ) ), 'price' => round( (float) directorist_get_var( $posted_data['price'], 0 ), 2 ), - 'price_range' => sanitize_text_field( directorist_get_var( $posted_data['price_range'] ) ) + 'price_range' => sanitize_text_field( directorist_get_var( $posted_data['price_range'] ) ), ); } diff --git a/includes/fields/class-directorist-radio-field.php b/includes/fields/class-directorist-radio-field.php index b14405acd5..56d77894a5 100644 --- a/includes/fields/class-directorist-radio-field.php +++ b/includes/fields/class-directorist-radio-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Radio Field class. - * */ namespace Directorist\Fields; @@ -20,9 +19,12 @@ public function get_options() { return array(); } - return array_map( static function( $option ) { - return str_replace( '<', '<', $option['option_value'] ); - }, $options ); + return array_map( + static function ( $option ) { + return str_replace( '<', '<', $option['option_value'] ); + }, + $options + ); } public function validate( $posted_data ) { diff --git a/includes/fields/class-directorist-select-field.php b/includes/fields/class-directorist-select-field.php index 2e40003596..57aa5caff4 100644 --- a/includes/fields/class-directorist-select-field.php +++ b/includes/fields/class-directorist-select-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Select Field class. - * */ namespace Directorist\Fields; @@ -20,9 +19,12 @@ public function get_options() { return array(); } - return array_map( static function( $option ) { - return str_replace( '<', '<', $option['option_value'] ); - }, $options ); + return array_map( + static function ( $option ) { + return str_replace( '<', '<', $option['option_value'] ); + }, + $options + ); } public function validate( $posted_data ) { diff --git a/includes/fields/class-directorist-social-info-field.php b/includes/fields/class-directorist-social-info-field.php index 5b85b21835..6f4af1bda4 100644 --- a/includes/fields/class-directorist-social-info-field.php +++ b/includes/fields/class-directorist-social-info-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Social Info Field class. - * */ namespace Directorist\Fields; @@ -24,9 +23,12 @@ public function get_value( $posted_data ) { public function validate( $posted_data ) { $items = $this->get_value( $posted_data ); - $items = array_filter( $items, static function( $item ) { - return ! ( empty( $item['id'] ) || empty( $item['url'] ) ); - } ); + $items = array_filter( + $items, + static function ( $item ) { + return ! ( empty( $item['id'] ) || empty( $item['url'] ) ); + } + ); if ( ! count( $items ) ) { $this->add_error( __( 'Invalid social info.', 'directorist' ) ); @@ -48,7 +50,7 @@ public function sanitize( $posted_data ) { $items[] = array( 'id' => $item['id'], - 'url' => sanitize_url( $item['url'] ) + 'url' => sanitize_url( $item['url'] ), ); } diff --git a/includes/fields/class-directorist-switch-field.php b/includes/fields/class-directorist-switch-field.php index fe2f3a6a1a..0b0deedc5d 100644 --- a/includes/fields/class-directorist-switch-field.php +++ b/includes/fields/class-directorist-switch-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Switch Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-tags-field.php b/includes/fields/class-directorist-tags-field.php index 11a9f4de39..6fb6d52910 100644 --- a/includes/fields/class-directorist-tags-field.php +++ b/includes/fields/class-directorist-tags-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Tags Field class. - * */ namespace Directorist\Fields; @@ -13,11 +12,11 @@ class Tags_Field extends Taxonomy_Field { public $type = 'tags'; - function get_taxonomy() : string { + function get_taxonomy(): string { return ATBDP_TAGS; } - public function user_can_create() : bool { + public function user_can_create(): bool { return (bool) $this->allow_new; } } diff --git a/includes/fields/class-directorist-taxonomy-field.php b/includes/fields/class-directorist-taxonomy-field.php index e40130d286..80f20bfe16 100644 --- a/includes/fields/class-directorist-taxonomy-field.php +++ b/includes/fields/class-directorist-taxonomy-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Taxonomy Field class. - * */ namespace Directorist\Fields; @@ -13,11 +12,11 @@ abstract class Taxonomy_Field extends Base_Field { public $type = 'taxonomy'; - abstract protected function get_taxonomy() : string; + abstract protected function get_taxonomy(): string; - abstract public function user_can_create() : bool; + abstract public function user_can_create(): bool; - public function user_can_select_multiple() : bool { + public function user_can_select_multiple(): bool { return (bool) ( $this->__get( 'type' ) === 'multiple' ); } @@ -29,7 +28,7 @@ public function get_value( $posted_data ) { if ( ! in_array( $this->get_taxonomy(), array( ATBDP_TAGS, ATBDP_LOCATION, ATBDP_CATEGORY ), true ) ) { return null; } - + if ( ! isset( $posted_data['tax_input'][ $this->get_taxonomy() ] ) ) { return null; } diff --git a/includes/fields/class-directorist-text-field.php b/includes/fields/class-directorist-text-field.php index 2fec9f1d4d..66db78d11a 100644 --- a/includes/fields/class-directorist-text-field.php +++ b/includes/fields/class-directorist-text-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Text Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-textarea-field.php b/includes/fields/class-directorist-textarea-field.php index 4e9c2db405..25f0ab34a7 100644 --- a/includes/fields/class-directorist-textarea-field.php +++ b/includes/fields/class-directorist-textarea-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Textarea Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-time-field.php b/includes/fields/class-directorist-time-field.php index 2a1b4c5a22..a00877b6c7 100644 --- a/includes/fields/class-directorist-time-field.php +++ b/includes/fields/class-directorist-time-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Time Field class. - * */ namespace Directorist\Fields; @@ -15,7 +14,7 @@ class Time_Field extends Base_Field { public function validate( $posted_data ) { $value = $this->get_value( $posted_data ); - + if ( date( 'H:i', strtotime( 'today ' . $value ) ) !== $value ) { $this->add_error( __( 'Invalid time.', 'directorist' ) ); diff --git a/includes/fields/class-directorist-url-field.php b/includes/fields/class-directorist-url-field.php index 7191a540db..26f7e7089d 100644 --- a/includes/fields/class-directorist-url-field.php +++ b/includes/fields/class-directorist-url-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Url Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-video-field.php b/includes/fields/class-directorist-video-field.php index 62bf71eae3..94bd23eb3a 100644 --- a/includes/fields/class-directorist-video-field.php +++ b/includes/fields/class-directorist-video-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist Video Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/class-directorist-viewcount-field.php b/includes/fields/class-directorist-viewcount-field.php index 96dbf67345..c016c42c1d 100644 --- a/includes/fields/class-directorist-viewcount-field.php +++ b/includes/fields/class-directorist-viewcount-field.php @@ -1,7 +1,6 @@ <?php /** * Directorist View Count Field class. - * */ namespace Directorist\Fields; diff --git a/includes/fields/init.php b/includes/fields/init.php index 65cf85298e..9e79d466db 100644 --- a/includes/fields/init.php +++ b/includes/fields/init.php @@ -1,7 +1,6 @@ <?php /** * Directorist fields file. - * */ if ( ! defined( 'ABSPATH' ) ) { exit; diff --git a/includes/gateways/class-gateway.php b/includes/gateways/class-gateway.php index b9c069fa9f..e1a4a76e09 100644 --- a/includes/gateways/class-gateway.php +++ b/includes/gateways/class-gateway.php @@ -10,7 +10,9 @@ */ // Exit if accessed directly -if ( !defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** * ATBDP_Gateway Class @@ -19,335 +21,358 @@ * @access public */ -class ATBDP_Gateway{ - private $extension_url = ''; - public function __construct() - { - // add monetization menu - - add_filter('atbdp_settings_menus', array($this, 'add_monetization_menu')); - - // add gateway submenu - add_filter('atbdp_monetization_settings_submenus', array($this, 'gateway_settings_submenu'), 10, 1); - //fields widgets - add_filter('atbdp_form_preset_widgets', array($this, 'atbdp_form_builder_widgets')); - - $this->extension_url = sprintf("<a target='_blank' href='%s'>%s</a>", esc_url(admin_url('edit.php?post_type=at_biz_dir&page=atbdp-extension')), __('Checkout Other Payment Gateways & Extensions', 'directorist')); - - } - - public function atbdp_form_builder_widgets($widgets) { - if ( ! is_fee_manager_active() && directorist_is_featured_listing_enabled() ) { - $widgets['listing-type'] = [ - 'label' => 'Listing Type', - 'icon' => 'las la-toggle-on', - 'show' => true, - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'radio', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'listing_type', - ], - 'label' => [ - 'type' => 'text', - 'label' => 'Label', - 'value' => 'Select Listing Type', - ], - 'general_label' => [ - 'type' => 'text', - 'label' => 'General label', - 'value' => 'General', - ], - 'featured_label' => [ - 'type' => 'text', - 'label' => 'Featured label', - 'value' => 'Featured', - ], - 'featured_description' => [ - 'type' => 'text', - 'label' => 'Featured description', - 'value' => 'Promote your listing to the top of search results and listings pages for a specific duration, with an additional payment', - ], - ], - ]; - } - - return $widgets; - } - - /** - * Add Monetization menu - * @param array $menus The array of menus - * @return array It returns the new array of menus. - */ - public function add_monetization_menu($menus) - { - $menus['monetization_menu'] = array( - 'title' => __('Monetization', 'directorist'), - 'name' => 'monetization_menu', - 'icon' => 'font-awesome:fa-money-bill-alt', - 'menus' => $this->get_monetization_settings_submenus(), - ); - return $menus; - } - - - /** - * It registers the monetization submenu - * @return array it returns an array of submenus - */ - public function get_monetization_settings_submenus() - { - return apply_filters('atbdp_monetization_settings_submenus', array( - 'monetization_submenu1' => array( - 'title' => __( 'Monetization Settings', 'directorist'), - 'name' => 'monetization_submenu1', - 'icon' => 'font-awesome:fa-home', - 'controls' => apply_filters('atbdp_monetization_settings_controls', array( - 'monetization_section' => array( - 'type' => 'section', - 'title' => __('Monetization General Settings', 'directorist'), - 'description' => __('You can Customize Monetization settings here. After switching any option, Do not forget to save the changes.', 'directorist'), - 'fields' => $this->get_monetization_settings_fields(), - ), // ends monetization settings section - //class_exists('ATBDP_Pricing_Plans') ? '' : - 'featured_listing_section' => array( - 'type' => 'section', - 'title' => __('Monetize by Featured Listing', 'directorist'), - 'description' => __('You can Customize featured listing related settings here', 'directorist'), - 'fields' => $this->get_featured_listing_settings_fields(), - ), // ends monetization settings section - 'monetize_by_subscription' => array( - 'type' => 'section', - 'title' => __('Monetize by Listing Plans', 'directorist'), - 'fields' => $this->get_monetize_by_subscription_fields(), - ), // ends monetization settings section - - )), - ), - - ) ); - } - - - /** - * It register the settings fields for monetization submenu - * @return array It returns an array of settings fields arrays - */ - public function get_monetization_settings_fields() - { - return apply_filters('atbdp_monetization_settings_fields', array( - array( - 'type' => 'toggle', - 'name' => 'enable_monetization', - 'label' => __('Enable Monetization Feature', 'directorist'), - 'description' => __('Choose whether you want to monetize your site or not. Monetization features will let you accept payment from your users if they submit listing based on different criteria. Default is NO.', 'directorist'), - 'default' => '', - ), - - - ) - ); - } - - - /** - * It registers the settings fields of featured listings - * @return array It returns an array of featured settings fields arrays - */ - public function get_featured_listing_settings_fields() - { - return apply_filters('atbdp_monetization_settings_fields', array( - array( - 'type' => 'toggle', - 'name' => 'enable_featured_listing', - 'label' => __('Monetize by Featured Listing', 'directorist'), - 'description' => __('You can enabled this option to collect payment from your user for making their listing featured.', 'directorist'), - 'default' => '', - ), - array( - 'type' => 'textarea', - 'name' => 'featured_listing_desc', - 'label' => __('Description', 'directorist'), - 'description' => __('You can set some description for your user for upgrading to featured listing.', 'directorist'), - 'default' => __('(Top of the search result and listings pages for a number days and it requires an additional payment.)', 'directorist'), - ), - array( - 'type' => 'textbox', - 'name' => 'featured_listing_price', - 'label' => __('Price in ', 'directorist') . atbdp_get_payment_currency(), - 'description' => __('Set the price you want to charge a user if he/she wants to upgrade his/her listing to featured listing. Note: you can change the currency settings under the gateway settings', 'directorist'), - 'default' => 19.99, - ), - ) - ); - } - - - /** - * It registers the settings fields of promoting subscription - * @return array It returns an array of promoting subscription settings fields arrays - */ - public function get_monetize_by_subscription_fields() - { - $pricing_plan = '<a style="color: red" href="https://directorist.com/product/directorist-pricing-plans" target="_blank">Pricing Plans</a>'; - return apply_filters('atbdp_monetization_by_subscription_settings_fields', array( - array( - 'type' => 'notebox', - 'name' => 'monetization_promotion', - 'description' => sprintf(__('Monetize your website by selling listing plans using %s extension.', 'directorist'), $pricing_plan), - ), - ) - ); - } - - - /** - * It register the gateway settings submenu - * @param array $submenus Array of Submenus - * @return array It returns gateway submenu - */ - public function gateway_settings_submenu($submenus){ - $submenus['gateway_submenu'] = array( - 'title' => __('Gateways Settings', 'directorist'), - 'name' => 'gateway_general', - 'icon' => 'font-awesome:fa-bezier-curve', - 'controls' => apply_filters('atbdp_gateway_settings_controls', array( - 'gateways' => array( - 'type' => 'section', - 'title' => __('Gateway General Settings', 'directorist'), - 'description' => __('You can Customize Gateway-related settings here. You can enable or disable any gateways here. Here, YES means Enabled, and NO means disabled. After switching any option, Do not forget to save the changes.', 'directorist'), - 'fields' => $this->get_gateway_settings_fields(), - ), - )), - ); - return $submenus; - } - - /** - * It register gateway settings fields - * @return array It returns an array of gateway settings fields - */ - public function get_gateway_settings_fields(){ - - return apply_filters('atbdp_gateway_settings_fields', array( - 'gateway_promotion' => array( - 'type' => 'notebox', - 'name' => 'paypal_gateway_promotion', - 'label' => __('Need more gateways?', 'directorist'), - 'description' => sprintf(__('You can use different payment gateways to process payment including PayPal. %s', 'directorist'), $this->extension_url), - 'status' => 'warning', - ), - array( - 'type' => 'toggle', - 'name' => 'gateway_test_mode', - 'label' => __('Enable Test Mode', 'directorist'), - 'description' => __('If you enable Test Mode, then no real transaction will occur. If you want to test the payment system of your website then you can set this option enabled. NOTE: Your payment gateway must support test mode eg. they should provide you a sandbox account to test. Otherwise, use only offline gateway to test.', 'directorist'), - 'default' => 1, - ), - array( - 'type' => 'checkbox', - 'name' => 'active_gateways', - 'label' => __('Active Gateways', 'directorist'), - 'description' => __('Check the gateway(s) you would like to use to collect payment from your users. A user will be use any of the active gateways during the checkout process ', 'directorist'), - 'items' => apply_filters('atbdp_active_gateways', array( - array( - 'value' => 'bank_transfer', - 'label' => __('Bank Transfer (Offline Gateway)', 'directorist'), - ), - )), - - 'default' => array( - 'bank_transfer', - ), - ), - - array( - 'type' => 'select', - 'name' => 'default_gateway', - 'label' => __('Default Gateway', 'directorist'), - 'description' => __('Select the default gateway you would like to show as a selected gateway on the checkout page', 'directorist'), - 'items' => apply_filters('atbdp_default_gateways', array( - array( - 'value' => 'bank_transfer', - 'label' => __('Bank Transfer (Offline Gateway)', 'directorist'), - ), - )), - - 'default' => array( - 'bank_transfer', - ), - ), - /*@todo; think whether it is good to list online payments here or in separate tab when a new payment gateway is added*/ - - - array( - 'type' => 'notebox', - 'name' => 'payment_currency_note', - 'label' => __('Note About This Currency Settings:', 'directorist'), - 'description' => __('This currency settings lets you customize how you would like to accept payment from your user/customer and how to display pricing on the order form/history.', 'directorist'), - 'status' => 'info', - ), - array( - 'type' => 'textbox', - 'name' => 'payment_currency', - 'label' => __( 'Currency Name', 'directorist' ), - 'description' => __( 'Enter the Name of the currency eg. USD or GBP etc.', 'directorist' ), - 'default' => 'USD', - ), - /*@todo; lets user use space as thousand separator in future. @see: https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/index.html - */ - array( - 'type' => 'textbox', - 'name' => 'payment_thousand_separator', - 'label' => __( 'Thousand Separator', 'directorist' ), - 'description' => __( 'Enter the currency thousand separator. Eg. , or . etc.', 'directorist' ), - 'default' => ',', - ), - - array( - 'type' => 'textbox', - 'name' => 'payment_decimal_separator', - 'label' => __('Decimal Separator', 'directorist'), - 'description' => __('Enter the currency decimal separator. Eg. "." or ",". Default is "."', 'directorist'), - 'default' => '.', - ), - array( - 'type' => 'select', - 'name' => 'payment_currency_position', - 'label' => __('Currency Position', 'directorist'), - 'description' => __('Select where you would like to show the currency symbol. Default is before. Eg. $5', 'directorist'), - 'default' => array( - 'before', - ), - 'items' => array( - array( - 'value' => 'before', - 'label' => __('$5 - Before', 'directorist'), - ), - array( - 'value' => 'after', - 'label' => __('After - 5$', 'directorist'), - ), - ), - ), - - ) - ); - } - - - - public static function gateways_markup() - { - $active_gateways = get_directorist_option('active_gateways', [ 'bank_transfer' ]); - $default_gw = get_directorist_option('default_gateway', 'bank_transfer'); - if ( empty( $active_gateways ) ) return ''; // if the gateways are empty, vail out. - - $format = ' +class ATBDP_Gateway { + private $extension_url = ''; + public function __construct() { + // add monetization menu + + add_filter( 'atbdp_settings_menus', array( $this, 'add_monetization_menu' ) ); + + // add gateway submenu + add_filter( 'atbdp_monetization_settings_submenus', array( $this, 'gateway_settings_submenu' ), 10, 1 ); + // fields widgets + add_filter( 'atbdp_form_preset_widgets', array( $this, 'atbdp_form_builder_widgets' ) ); + + $this->extension_url = sprintf( "<a target='_blank' href='%s'>%s</a>", esc_url( admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-extension' ) ), __( 'Checkout Other Payment Gateways & Extensions', 'directorist' ) ); + } + + public function atbdp_form_builder_widgets( $widgets ) { + if ( ! is_fee_manager_active() && directorist_is_featured_listing_enabled() ) { + $widgets['listing-type'] = array( + 'label' => 'Listing Type', + 'icon' => 'las la-toggle-on', + 'show' => true, + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'radio', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'listing_type', + ), + 'label' => array( + 'type' => 'text', + 'label' => 'Label', + 'value' => 'Select Listing Type', + ), + 'general_label' => array( + 'type' => 'text', + 'label' => 'General label', + 'value' => 'General', + ), + 'featured_label' => array( + 'type' => 'text', + 'label' => 'Featured label', + 'value' => 'Featured', + ), + 'featured_description' => array( + 'type' => 'text', + 'label' => 'Featured description', + 'value' => 'Promote your listing to the top of search results and listings pages for a specific duration, with an additional payment', + ), + ), + ); + } + + return $widgets; + } + + /** + * Add Monetization menu + * + * @param array $menus The array of menus + * @return array It returns the new array of menus. + */ + public function add_monetization_menu( $menus ) { + $menus['monetization_menu'] = array( + 'title' => __( 'Monetization', 'directorist' ), + 'name' => 'monetization_menu', + 'icon' => 'font-awesome:fa-money-bill-alt', + 'menus' => $this->get_monetization_settings_submenus(), + ); + return $menus; + } + + + /** + * It registers the monetization submenu + * + * @return array it returns an array of submenus + */ + public function get_monetization_settings_submenus() { + return apply_filters( + 'atbdp_monetization_settings_submenus', + array( + 'monetization_submenu1' => array( + 'title' => __( 'Monetization Settings', 'directorist' ), + 'name' => 'monetization_submenu1', + 'icon' => 'font-awesome:fa-home', + 'controls' => apply_filters( + 'atbdp_monetization_settings_controls', + array( + 'monetization_section' => array( + 'type' => 'section', + 'title' => __( 'Monetization General Settings', 'directorist' ), + 'description' => __( 'You can Customize Monetization settings here. After switching any option, Do not forget to save the changes.', 'directorist' ), + 'fields' => $this->get_monetization_settings_fields(), + ), // ends monetization settings section + // class_exists('ATBDP_Pricing_Plans') ? '' : + 'featured_listing_section' => array( + 'type' => 'section', + 'title' => __( 'Monetize by Featured Listing', 'directorist' ), + 'description' => __( 'You can Customize featured listing related settings here', 'directorist' ), + 'fields' => $this->get_featured_listing_settings_fields(), + ), // ends monetization settings section + 'monetize_by_subscription' => array( + 'type' => 'section', + 'title' => __( 'Monetize by Listing Plans', 'directorist' ), + 'fields' => $this->get_monetize_by_subscription_fields(), + ), // ends monetization settings section + + ) + ), + ), + + ) + ); + } + + + /** + * It register the settings fields for monetization submenu + * + * @return array It returns an array of settings fields arrays + */ + public function get_monetization_settings_fields() { + return apply_filters( + 'atbdp_monetization_settings_fields', + array( + array( + 'type' => 'toggle', + 'name' => 'enable_monetization', + 'label' => __( 'Enable Monetization Feature', 'directorist' ), + 'description' => __( 'Choose whether you want to monetize your site or not. Monetization features will let you accept payment from your users if they submit listing based on different criteria. Default is NO.', 'directorist' ), + 'default' => '', + ), + + ) + ); + } + + + /** + * It registers the settings fields of featured listings + * + * @return array It returns an array of featured settings fields arrays + */ + public function get_featured_listing_settings_fields() { + return apply_filters( + 'atbdp_monetization_settings_fields', + array( + array( + 'type' => 'toggle', + 'name' => 'enable_featured_listing', + 'label' => __( 'Monetize by Featured Listing', 'directorist' ), + 'description' => __( 'You can enabled this option to collect payment from your user for making their listing featured.', 'directorist' ), + 'default' => '', + ), + array( + 'type' => 'textarea', + 'name' => 'featured_listing_desc', + 'label' => __( 'Description', 'directorist' ), + 'description' => __( 'You can set some description for your user for upgrading to featured listing.', 'directorist' ), + 'default' => __( '(Top of the search result and listings pages for a number days and it requires an additional payment.)', 'directorist' ), + ), + array( + 'type' => 'textbox', + 'name' => 'featured_listing_price', + 'label' => __( 'Price in ', 'directorist' ) . atbdp_get_payment_currency(), + 'description' => __( 'Set the price you want to charge a user if he/she wants to upgrade his/her listing to featured listing. Note: you can change the currency settings under the gateway settings', 'directorist' ), + 'default' => 19.99, + ), + ) + ); + } + + + /** + * It registers the settings fields of promoting subscription + * + * @return array It returns an array of promoting subscription settings fields arrays + */ + public function get_monetize_by_subscription_fields() { + $pricing_plan = '<a style="color: red" href="https://directorist.com/product/directorist-pricing-plans" target="_blank">Pricing Plans</a>'; + return apply_filters( + 'atbdp_monetization_by_subscription_settings_fields', + array( + array( + 'type' => 'notebox', + 'name' => 'monetization_promotion', + 'description' => sprintf( __( 'Monetize your website by selling listing plans using %s extension.', 'directorist' ), $pricing_plan ), + ), + ) + ); + } + + + /** + * It register the gateway settings submenu + * + * @param array $submenus Array of Submenus + * @return array It returns gateway submenu + */ + public function gateway_settings_submenu( $submenus ) { + $submenus['gateway_submenu'] = array( + 'title' => __( 'Gateways Settings', 'directorist' ), + 'name' => 'gateway_general', + 'icon' => 'font-awesome:fa-bezier-curve', + 'controls' => apply_filters( + 'atbdp_gateway_settings_controls', + array( + 'gateways' => array( + 'type' => 'section', + 'title' => __( 'Gateway General Settings', 'directorist' ), + 'description' => __( 'You can Customize Gateway-related settings here. You can enable or disable any gateways here. Here, YES means Enabled, and NO means disabled. After switching any option, Do not forget to save the changes.', 'directorist' ), + 'fields' => $this->get_gateway_settings_fields(), + ), + ) + ), + ); + return $submenus; + } + + /** + * It register gateway settings fields + * + * @return array It returns an array of gateway settings fields + */ + public function get_gateway_settings_fields() { + + return apply_filters( + 'atbdp_gateway_settings_fields', + array( + 'gateway_promotion' => array( + 'type' => 'notebox', + 'name' => 'paypal_gateway_promotion', + 'label' => __( 'Need more gateways?', 'directorist' ), + 'description' => sprintf( __( 'You can use different payment gateways to process payment including PayPal. %s', 'directorist' ), $this->extension_url ), + 'status' => 'warning', + ), + array( + 'type' => 'toggle', + 'name' => 'gateway_test_mode', + 'label' => __( 'Enable Test Mode', 'directorist' ), + 'description' => __( 'If you enable Test Mode, then no real transaction will occur. If you want to test the payment system of your website then you can set this option enabled. NOTE: Your payment gateway must support test mode eg. they should provide you a sandbox account to test. Otherwise, use only offline gateway to test.', 'directorist' ), + 'default' => 1, + ), + array( + 'type' => 'checkbox', + 'name' => 'active_gateways', + 'label' => __( 'Active Gateways', 'directorist' ), + 'description' => __( 'Check the gateway(s) you would like to use to collect payment from your users. A user will be use any of the active gateways during the checkout process ', 'directorist' ), + 'items' => apply_filters( + 'atbdp_active_gateways', + array( + array( + 'value' => 'bank_transfer', + 'label' => __( 'Bank Transfer (Offline Gateway)', 'directorist' ), + ), + ) + ), + + 'default' => array( + 'bank_transfer', + ), + ), + + array( + 'type' => 'select', + 'name' => 'default_gateway', + 'label' => __( 'Default Gateway', 'directorist' ), + 'description' => __( 'Select the default gateway you would like to show as a selected gateway on the checkout page', 'directorist' ), + 'items' => apply_filters( + 'atbdp_default_gateways', + array( + array( + 'value' => 'bank_transfer', + 'label' => __( 'Bank Transfer (Offline Gateway)', 'directorist' ), + ), + ) + ), + + 'default' => array( + 'bank_transfer', + ), + ), + /*@todo; think whether it is good to list online payments here or in separate tab when a new payment gateway is added*/ + + array( + 'type' => 'notebox', + 'name' => 'payment_currency_note', + 'label' => __( 'Note About This Currency Settings:', 'directorist' ), + 'description' => __( 'This currency settings lets you customize how you would like to accept payment from your user/customer and how to display pricing on the order form/history.', 'directorist' ), + 'status' => 'info', + ), + array( + 'type' => 'textbox', + 'name' => 'payment_currency', + 'label' => __( 'Currency Name', 'directorist' ), + 'description' => __( 'Enter the Name of the currency eg. USD or GBP etc.', 'directorist' ), + 'default' => 'USD', + ), + /* + @todo; lets user use space as thousand separator in future. @see: https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/index.html + */ + array( + 'type' => 'textbox', + 'name' => 'payment_thousand_separator', + 'label' => __( 'Thousand Separator', 'directorist' ), + 'description' => __( 'Enter the currency thousand separator. Eg. , or . etc.', 'directorist' ), + 'default' => ',', + ), + + array( + 'type' => 'textbox', + 'name' => 'payment_decimal_separator', + 'label' => __( 'Decimal Separator', 'directorist' ), + 'description' => __( 'Enter the currency decimal separator. Eg. "." or ",". Default is "."', 'directorist' ), + 'default' => '.', + ), + array( + 'type' => 'select', + 'name' => 'payment_currency_position', + 'label' => __( 'Currency Position', 'directorist' ), + 'description' => __( 'Select where you would like to show the currency symbol. Default is before. Eg. $5', 'directorist' ), + 'default' => array( + 'before', + ), + 'items' => array( + array( + 'value' => 'before', + 'label' => __( '$5 - Before', 'directorist' ), + ), + array( + 'value' => 'after', + 'label' => __( 'After - 5$', 'directorist' ), + ), + ), + ), + + ) + ); + } + + + + public static function gateways_markup() { + $active_gateways = get_directorist_option( 'active_gateways', array( 'bank_transfer' ) ); + $default_gw = get_directorist_option( 'default_gateway', 'bank_transfer' ); + if ( empty( $active_gateways ) ) { + return ''; // if the gateways are empty, vail out. + } + + $format = ' <li class="list-group-item"> <div class="gateway_list directorist-radio directorist-radio-circle"> <input type="radio" id="##GATEWAY##" name="payment_gateway" value="##GATEWAY##" ##CHECKED##> @@ -358,23 +383,22 @@ public static function gateways_markup() ##DESC## </li>'; - $markup = '<ul>'; - if( !empty( $active_gateways ) ) { - foreach ($active_gateways as $gw_name){ - $title = get_directorist_option($gw_name.'_title', 'Bank Transfer'); - $desc = get_directorist_option($gw_name.'_description', 'You can make your payment directly to our bank account using this gateway. Please use your ORDER ID as a reference when making the payment. We will complete your order as soon as your deposit is cleared in our bank.'); - $desc = ! empty( $desc ) ? "<p class='directorist-payment-text'>{$desc}</p>" : ''; - $checked = ( $gw_name == $default_gw ) ? ' checked': ''; - $search = array("##GATEWAY##", "##LABEL##", "##DESC##", "##CHECKED##"); - $replace = array($gw_name, $title, $desc, $checked); - $markup .= str_replace($search, $replace , $format); - /*@todo; Add a settings to select a default payment method.*/ - } - } - - $markup .= '</ul>'; - - return $markup; - } - -} \ No newline at end of file + $markup = '<ul>'; + if ( ! empty( $active_gateways ) ) { + foreach ( $active_gateways as $gw_name ) { + $title = get_directorist_option( $gw_name . '_title', 'Bank Transfer' ); + $desc = get_directorist_option( $gw_name . '_description', 'You can make your payment directly to our bank account using this gateway. Please use your ORDER ID as a reference when making the payment. We will complete your order as soon as your deposit is cleared in our bank.' ); + $desc = ! empty( $desc ) ? "<p class='directorist-payment-text'>{$desc}</p>" : ''; + $checked = ( $gw_name == $default_gw ) ? ' checked' : ''; + $search = array( '##GATEWAY##', '##LABEL##', '##DESC##', '##CHECKED##' ); + $replace = array( $gw_name, $title, $desc, $checked ); + $markup .= str_replace( $search, $replace, $format ); + /*@todo; Add a settings to select a default payment method.*/ + } + } + + $markup .= '</ul>'; + + return $markup; + } +} diff --git a/includes/gateways/class-offline-gateway.php b/includes/gateways/class-offline-gateway.php index 990f6e0ab5..d71ad06a93 100644 --- a/includes/gateways/class-offline-gateway.php +++ b/includes/gateways/class-offline-gateway.php @@ -10,7 +10,9 @@ */ // Exit if accessed directly -if ( !defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** * ATBDP_Offline_Gateway Class @@ -21,45 +23,47 @@ class ATBDP_Offline_Gateway { - public function __construct() - { - // add new settings - add_filter('atbdp_monetization_settings_submenus', array($this, 'offline_gateway_settings_submenu'), 10, 1); - - // hook to process payment - } - - - /** - * It adds a submenu of offline gateway settings - * @param array $submenus - * @return array - */ - public function offline_gateway_settings_submenu($submenus) - { - $submenus['offline_gateway_submenu'] = array( - 'title' => __('Offline Gateway', 'directorist'), - 'name' => 'offline_gateway_menu', - 'icon' => 'font-awesome:fa-university', - 'controls' => apply_filters('atbdp_offline_gateway_settings_controls', array( - 'gateways' => array( - 'type' => 'section', - 'title' => __('Offline Gateway Settings', 'directorist'), - 'description' => __('You can customize all the settings related to your offline gateway. After switching any option, Do not forget to save the changes.', 'directorist'), - 'fields' => $this->get_offline_gateway_settings_fields(), - ), - )), - ); - return $submenus; - } - - /** - * It register the settings fields of offline gateway - * @return array It returns an array of offline settings fields array - */ - public function get_offline_gateway_settings_fields() - { - $bank_account = <<<PDO + public function __construct() { + // add new settings + add_filter( 'atbdp_monetization_settings_submenus', array( $this, 'offline_gateway_settings_submenu' ), 10, 1 ); + + // hook to process payment + } + + + /** + * It adds a submenu of offline gateway settings + * + * @param array $submenus + * @return array + */ + public function offline_gateway_settings_submenu( $submenus ) { + $submenus['offline_gateway_submenu'] = array( + 'title' => __( 'Offline Gateway', 'directorist' ), + 'name' => 'offline_gateway_menu', + 'icon' => 'font-awesome:fa-university', + 'controls' => apply_filters( + 'atbdp_offline_gateway_settings_controls', + array( + 'gateways' => array( + 'type' => 'section', + 'title' => __( 'Offline Gateway Settings', 'directorist' ), + 'description' => __( 'You can customize all the settings related to your offline gateway. After switching any option, Do not forget to save the changes.', 'directorist' ), + 'fields' => $this->get_offline_gateway_settings_fields(), + ), + ) + ), + ); + return $submenus; + } + + /** + * It register the settings fields of offline gateway + * + * @return array It returns an array of offline settings fields array + */ + public function get_offline_gateway_settings_fields() { + $bank_account = <<<PDO Please make your payment directly to our bank account and use your ORDER ID (#==ORDER_ID==) as a Reference. Our bank account information is given below. Account details : @@ -71,42 +75,43 @@ public function get_offline_gateway_settings_fields() Please remember that your order may be canceled if you do not make your payment within next 72 hours. PDO; - $bank_payment_desc = __('You can make your payment directly to our bank account using this gateway. Please use your ORDER ID as a reference when making the payment. We will complete your order as soon as your deposit is cleared in our bank.', 'directorist'); - - - return apply_filters('atbdp_offline_gateway_settings_fields', array( - array( - 'type' => 'notebox', - 'name' => 'offline_payment_note', - 'label' => __('Note About Bank Transfer Gateway:', 'directorist'), - 'description' => __('You should remember that this payment gateway needs some manual action to complete an order. After getting notification of order using this offline payment gateway, you should check your bank if the money is deposited to your account. Then you should change the order status manually from the "Order History" submenu.', 'directorist'), - 'status' => 'info', - ), - - array( - 'type' => 'textbox', - 'name' => 'bank_transfer_title', - 'label' => __('Gateway Title', 'directorist'), - 'description' => __('Enter the title of this gateway that should be displayed to the user on the front end.', 'directorist'), - 'default' => 'Bank Transfer', - ), - - array( - 'type' => 'textarea', - 'name' => 'bank_transfer_description', - 'label' => __('Gateway Description', 'directorist'), - 'description' => __('Enter some description for your user to transfer funds to your account.', 'directorist'), - 'default' => $bank_payment_desc, - ), - array( - 'type' => 'textarea', - 'name' => 'bank_transfer_instruction', - 'label' => __('Bank Information', 'directorist'), - 'description' => __('Enter your bank information below so that use can make payment directly to your bank account.', 'directorist'), - 'default' => $bank_account, - ), - - ) - ); - } + $bank_payment_desc = __( 'You can make your payment directly to our bank account using this gateway. Please use your ORDER ID as a reference when making the payment. We will complete your order as soon as your deposit is cleared in our bank.', 'directorist' ); + + return apply_filters( + 'atbdp_offline_gateway_settings_fields', + array( + array( + 'type' => 'notebox', + 'name' => 'offline_payment_note', + 'label' => __( 'Note About Bank Transfer Gateway:', 'directorist' ), + 'description' => __( 'You should remember that this payment gateway needs some manual action to complete an order. After getting notification of order using this offline payment gateway, you should check your bank if the money is deposited to your account. Then you should change the order status manually from the "Order History" submenu.', 'directorist' ), + 'status' => 'info', + ), + + array( + 'type' => 'textbox', + 'name' => 'bank_transfer_title', + 'label' => __( 'Gateway Title', 'directorist' ), + 'description' => __( 'Enter the title of this gateway that should be displayed to the user on the front end.', 'directorist' ), + 'default' => 'Bank Transfer', + ), + + array( + 'type' => 'textarea', + 'name' => 'bank_transfer_description', + 'label' => __( 'Gateway Description', 'directorist' ), + 'description' => __( 'Enter some description for your user to transfer funds to your account.', 'directorist' ), + 'default' => $bank_payment_desc, + ), + array( + 'type' => 'textarea', + 'name' => 'bank_transfer_instruction', + 'label' => __( 'Bank Information', 'directorist' ), + 'description' => __( 'Enter your bank information below so that use can make payment directly to your bank account.', 'directorist' ), + 'default' => $bank_account, + ), + + ) + ); + } } diff --git a/includes/helper-functions.php b/includes/helper-functions.php index 198e068dd9..18128bf10c 100644 --- a/includes/helper-functions.php +++ b/includes/helper-functions.php @@ -2,534 +2,568 @@ use Directorist\Helper; use Directorist\database\DB; -defined('ABSPATH') || die('No direct script access allowed!'); +defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); if ( ! function_exists( 'directorist_get_listings_directory_type' ) ) { - function directorist_get_listings_directory_type( $listing_id = 0 ) { + function directorist_get_listings_directory_type( $listing_id = 0 ) { $directory_type = directorist_get_object_terms( $listing_id, ATBDP_DIRECTORY_TYPE, 'term_id' ); return empty( $directory_type ) ? 0 : $directory_type[0]; - } + } } if ( ! function_exists( 'directorist_get_all_page_list' ) ) { - function directorist_get_all_page_list( $listing_id = '' ) { - $pages = get_pages(); - $pages_options = [ - ['value' => '', 'label' => 'Select...'] - ]; - - if ( empty( $pages ) || ! is_array( $pages ) ) return $pages_options; + function directorist_get_all_page_list( $listing_id = '' ) { + $pages = get_pages(); + $pages_options = array( + array( + 'value' => '', + 'label' => 'Select...', + ), + ); + + if ( empty( $pages ) || ! is_array( $pages ) ) { + return $pages_options; + } - foreach ($pages as $page) { - $pages_options[] = array('value' => $page->ID, 'label' => $page->post_title); - } + foreach ( $pages as $page ) { + $pages_options[] = array( + 'value' => $page->ID, + 'label' => $page->post_title, + ); + } - return $pages_options; - } + return $pages_options; + } } if ( ! function_exists( 'atbdp_is_truthy' ) ) { - function atbdp_is_truthy( $data ) { + function atbdp_is_truthy( $data ) { - if ( $data === true || $data === 'true'|| $data === 1 || $data === '1' ) { - return true; - } + if ( $data === true || $data === 'true' || $data === 1 || $data === '1' ) { + return true; + } - return false; - } + return false; + } } if ( ! function_exists( 'e_var_dump' ) ) { - function e_var_dump( $the_var = '' ) { - echo '<pre>'; - print_r( $the_var ); - echo '</pre>'; - } + function e_var_dump( $the_var = '' ) { + echo '<pre>'; + print_r( $the_var ); + echo '</pre>'; + } } if ( ! function_exists( 'directorist_console_log' ) ) { - function directorist_console_log( array $data = [] ) { - $data = json_encode( $data ); ?> - <script> - var data = JSON.parse( '<?php echo esc_js( $data ); ?>' ); - console.log( data ); - </script> - <?php - } + function directorist_console_log( array $data = array() ) { + $data = json_encode( $data ); ?> + <script> + var data = JSON.parse( '<?php echo esc_js( $data ); ?>' ); + console.log( data ); + </script> + <?php + } } if ( ! function_exists( 'atbdp_redirect_after_login' ) ) { - // atbdp_redirect_after_login - function atbdp_redirect_after_login( array $args = [] ) { - $default = [ 'url' => '' ]; - $args = array_merge( $default, $args ); + // atbdp_redirect_after_login + function atbdp_redirect_after_login( array $args = array() ) { + $default = array( 'url' => '' ); + $args = array_merge( $default, $args ); - if ( empty( $args['url'] ) ) { return; } + if ( empty( $args['url'] ) ) { + return; } - set_transient( 'atbdp_redirect_after_login', $args['url'] ); - } + set_transient( 'atbdp_redirect_after_login', $args['url'] ); + } } if ( ! function_exists( 'atbdp_add_flush_message' ) ) { - // atbdp_add_flush_message - function atbdp_add_flush_message( array $args = [] ) { - $default = [ 'key' => '', 'type' => 'info', 'message' => '' ]; - $args = array_merge( $default, $args ); - - if ( empty( $args['key'] ) ) { return; } - if ( empty( $args['message'] ) ) { return; } - - $get_previous_messages = get_transient( 'atbdp_flush_messages' ); - $flush_messages = $get_previous_messages; - - if ( empty( $flush_messages ) ) { - $flush_messages = []; - } + // atbdp_add_flush_message + function atbdp_add_flush_message( array $args = array() ) { + $default = array( + 'key' => '', + 'type' => 'info', + 'message' => '', + ); + $args = array_merge( $default, $args ); + + if ( empty( $args['key'] ) ) { + return; } + if ( empty( $args['message'] ) ) { + return; } + + $get_previous_messages = get_transient( 'atbdp_flush_messages' ); + $flush_messages = $get_previous_messages; + + if ( empty( $flush_messages ) ) { + $flush_messages = array(); + } - $key = $args[ 'key' ]; - $flush_messages[ $key ] = $args; + $key = $args['key']; + $flush_messages[ $key ] = $args; - set_transient( 'atbdp_flush_messages', $flush_messages ); - } + set_transient( 'atbdp_flush_messages', $flush_messages ); + } } if ( ! function_exists( 'atbdp_get_flush_messages' ) ) { - // atbdp_get_flush_messages - function atbdp_get_flush_messages( array $args = [] ) { - $flush_messages = get_transient( 'atbdp_flush_messages' ); - if ( empty( $flush_messages ) ) { return; } - - delete_transient( 'atbdp_flush_messages' ); - - ob_start(); - - echo '<div class="atbdp-flush-message-container">'; - foreach ( $flush_messages as $message_key => $messages ) { ?> - <div class="atbdp-flush-message-item type-<?php echo esc_attr( $messages['type'] ); ?>"> - <?php echo esc_html( $messages['message'] ); ?> - </div> - <?php } - echo '</div>'; + // atbdp_get_flush_messages + function atbdp_get_flush_messages( array $args = array() ) { + $flush_messages = get_transient( 'atbdp_flush_messages' ); + if ( empty( $flush_messages ) ) { + return; } + + delete_transient( 'atbdp_flush_messages' ); + + ob_start(); + + echo '<div class="atbdp-flush-message-container">'; + foreach ( $flush_messages as $message_key => $messages ) { + ?> + <div class="atbdp-flush-message-item type-<?php echo esc_attr( $messages['type'] ); ?>"> + <?php echo esc_html( $messages['message'] ); ?> + </div> + <?php + } + echo '</div>'; - $contents = apply_filters( 'atbdp_flush_message_content', ob_get_clean(), $flush_messages ); - echo directorist_kses( $contents ); - } + $contents = apply_filters( 'atbdp_flush_message_content', ob_get_clean(), $flush_messages ); + echo directorist_kses( $contents ); + } } if ( ! function_exists( 'atbdp_auth_guard' ) ) { - function atbdp_auth_guard( array $args = [] ) { - $flush_message = [ - 'key' => 'logged_in_user_only', - 'type' => 'info', - 'message' => __( 'You need to be logged in to view the content of this page', 'directorist' ), - ]; + function atbdp_auth_guard( array $args = array() ) { + $flush_message = array( + 'key' => 'logged_in_user_only', + 'type' => 'info', + 'message' => __( 'You need to be logged in to view the content of this page', 'directorist' ), + ); global $wp; - $default = [ + $default = array( 'flush_message' => $flush_message, - ]; + ); $args = array_merge( $default, $args ); $current_page = home_url( $wp->request ); - $login_page_id = (int) get_directorist_option( 'user_dashboard' ); + $login_page_id = (int) get_directorist_option( 'user_dashboard' ); - $redirect_url = $login_page_id ? get_page_link( $login_page_id ) : \ATBDP_Permalink::get_dashboard_page_link(); - $redirect_url = add_query_arg( 'redirect', urlencode( $current_page ), $redirect_url ); + $redirect_url = $login_page_id ? get_page_link( $login_page_id ) : \ATBDP_Permalink::get_dashboard_page_link(); + $redirect_url = add_query_arg( 'redirect', urlencode( $current_page ), $redirect_url ); - atbdp_add_flush_message( $args['flush_message'] ); + atbdp_add_flush_message( $args['flush_message'] ); - // atbdp_redirect_after_login( [ 'url' => $current_page ] ); - wp_safe_redirect( $redirect_url ); - die; - } + // atbdp_redirect_after_login( [ 'url' => $current_page ] ); + wp_safe_redirect( $redirect_url ); + die; + } } -function atbdp_add_flush_alert( array $args = [] ) { - $default = [ - 'id' => '', - 'type' => 'success', - 'page' => '', - 'dismissible' => true, - 'message' => '', - ]; +function atbdp_add_flush_alert( array $args = array() ) { + $default = array( + 'id' => '', + 'type' => 'success', + 'page' => '', + 'dismissible' => true, + 'message' => '', + ); - $args = array_merge( $default, $args ); + $args = array_merge( $default, $args ); - if ( empty( $args['id'] ) ) { return; } + if ( empty( $args['id'] ) ) { + return; } - $id = $args['id']; - unset( $args['id'] ); + $id = $args['id']; + unset( $args['id'] ); - $fulsh_messages = get_transient( 'atbdp_flush_alerts' ); + $fulsh_messages = get_transient( 'atbdp_flush_alerts' ); - if ( ! $fulsh_messages ) { - $fulsh_messages = []; - } + if ( ! $fulsh_messages ) { + $fulsh_messages = array(); + } - $fulsh_messages[ $id ] = $args; + $fulsh_messages[ $id ] = $args; - set_transient( 'atbdp_flush_alerts', $fulsh_messages ); + set_transient( 'atbdp_flush_alerts', $fulsh_messages ); } // atbdp_show_the_flush_alert function atbdp_show_the_flush_alert( string $id = '' ) { - if ( ! empty( $id ) ) { return; } + if ( ! empty( $id ) ) { + return; } - $fulsh_alerts = get_transient( 'atbdp_flush_alerts' ); - if ( ! $fulsh_alerts && empty( $fulsh_alerts[ $id ] ) ) { return; } + $fulsh_alerts = get_transient( 'atbdp_flush_alerts' ); + if ( ! $fulsh_alerts && empty( $fulsh_alerts[ $id ] ) ) { + return; } - $fulsh_alert = $fulsh_alerts[ $id ]; + $fulsh_alert = $fulsh_alerts[ $id ]; - atbdp_render_the_flush_alert( $fulsh_alert ); - unset( $fulsh_alerts[ $id ] ); + atbdp_render_the_flush_alert( $fulsh_alert ); + unset( $fulsh_alerts[ $id ] ); - set_transient( 'atbdp_flush_alerts', $fulsh_alerts ); + set_transient( 'atbdp_flush_alerts', $fulsh_alerts ); } // atbdp_show_flush_alerts -function atbdp_show_flush_alerts( array $args = [] ) { - $default = [ 'page' => '' ]; - $args = array_merge( $default, $args ); +function atbdp_show_flush_alerts( array $args = array() ) { + $default = array( 'page' => '' ); + $args = array_merge( $default, $args ); - $fulsh_alerts = get_transient( 'atbdp_flush_alerts' ); + $fulsh_alerts = get_transient( 'atbdp_flush_alerts' ); - if ( $fulsh_alerts ) { - foreach ( $fulsh_alerts as $id => $alert ) { - $alert_page = ! empty( $alert['page'] ) ? $alert['page'] : ''; + if ( $fulsh_alerts ) { + foreach ( $fulsh_alerts as $id => $alert ) { + $alert_page = ! empty( $alert['page'] ) ? $alert['page'] : ''; - if ( ! empty( $args['page'] ) && ( $alert_page !== $args['page'] && 'global' !== $alert_page ) ) { - continue; - } + if ( ! empty( $args['page'] ) && ( $alert_page !== $args['page'] && 'global' !== $alert_page ) ) { + continue; + } - atbdp_render_the_flush_alert( $alert ); - unset( $fulsh_alerts[ $id ] ); - } - } + atbdp_render_the_flush_alert( $alert ); + unset( $fulsh_alerts[ $id ] ); + } + } - set_transient( 'atbdp_flush_alerts', $fulsh_alerts ); + set_transient( 'atbdp_flush_alerts', $fulsh_alerts ); } // atbdp_render_the_flush_alert -function atbdp_render_the_flush_alert( array $alert = [] ) { - $classes = 'notice'; - $classes .= ( ! empty( $alert['type'] ) ) ? ' notice-' . $alert['type'] : ''; - $classes .= ( empty( $alert['dismissible'] ) ) ? '' : ' is-dismissible'; - ?> - <div class="<?php echo esc_attr( $classes ); ?>"> - <p><strong><?php echo directorist_kses( $alert['message'] ); ?></strong></p> - </div> - <?php +function atbdp_render_the_flush_alert( array $alert = array() ) { + $classes = 'notice'; + $classes .= ( ! empty( $alert['type'] ) ) ? ' notice-' . $alert['type'] : ''; + $classes .= ( empty( $alert['dismissible'] ) ) ? '' : ' is-dismissible'; + ?> + <div class="<?php echo esc_attr( $classes ); ?>"> + <p><strong><?php echo directorist_kses( $alert['message'] ); ?></strong></p> + </div> + <?php } // atbdp_load_admin_template -function atbdp_load_admin_template( string $path = '', $data = [] ) { - $file = trailingslashit( ATBDP_VIEWS_DIR ) . "admin-templates/$path.php"; +function atbdp_load_admin_template( string $path = '', $data = array() ) { + $file = trailingslashit( ATBDP_VIEWS_DIR ) . "admin-templates/$path.php"; - if ( file_exists( $file ) ) { - include( $file ); - } + if ( file_exists( $file ) ) { + include $file; + } } -if ( !function_exists('get_help') ) { - function get_help() { - $path = ATBDP_CLASS_DIR . 'class-helper.php'; - if ( file_exists( $path ) ) { - require_once( $path ); - } +if ( ! function_exists( 'get_help' ) ) { + function get_help() { + $path = ATBDP_CLASS_DIR . 'class-helper.php'; + if ( file_exists( $path ) ) { + require_once $path; + } - if ( class_exists( 'ATBDP_Helper' ) ) { - $helper = new ATBDP_Helper; - return $helper; - } + if ( class_exists( 'ATBDP_Helper' ) ) { + $helper = new ATBDP_Helper(); + return $helper; + } - return null; - } + return null; + } } if ( ! function_exists( 'atbdp_polylang_is_active' ) ) : - function atbdp_required_polylang_url() { - if ( class_exists('Polylang') ) { - $pll_current_language = pll_current_language(); - $pll_default_language = pll_default_language(); - - if ( $pll_current_language !== $pll_default_language ) { - return true; - } - } - - return false; - } + function atbdp_required_polylang_url() { + if ( class_exists( 'Polylang' ) ) { + $pll_current_language = pll_current_language(); + $pll_default_language = pll_default_language(); + + if ( $pll_current_language !== $pll_default_language ) { + return true; + } + } + + return false; + } endif; if ( ! function_exists( 'atbdp_get_listing_order' ) ) : - // atbdp_get_listing_order - function atbdp_get_listing_order( $listing_id ) { - $order = new WP_Query([ - 'post_type' => 'atbdp_orders', - 'meta_query' => array( - array( - 'key' => '_listing_id', - 'value' => $listing_id, - 'compare' => '=', - ) - ), - 'per_page' => 1 - - ]); - - return $order->post; - } + // atbdp_get_listing_order + function atbdp_get_listing_order( $listing_id ) { + $order = new WP_Query( + array( + 'post_type' => 'atbdp_orders', + 'meta_query' => array( + array( + 'key' => '_listing_id', + 'value' => $listing_id, + 'compare' => '=', + ), + ), + 'per_page' => 1, + + ) + ); + + return $order->post; + } endif; if ( ! function_exists( 'atbdp_get_listing_status_after_submission' ) ) : -function atbdp_get_listing_status_after_submission( array $args = [] ) { - // Set default values and sanitize input parameters - $args = array_merge( [ - 'id' => 0, - 'edited' => false, // Default to false if not set - ], $args); - - $listing_id = $args['id']; - $listing_status = $args['edited'] ? $args['edit_status'] : $args['create_status']; - $monetization_enabled = directorist_is_monetization_enabled(); - $featured_enabled = directorist_is_featured_listing_enabled(); - $pricing_plans_enabled = is_fee_manager_active(); - - // Determine post status based on monetization settings and plans - if ( $monetization_enabled ) { - if ( $pricing_plans_enabled ) { - return directorist_get_pricing_plan_status( $listing_id, $listing_status ); - } elseif ( $featured_enabled ) { - return directorist_get_featured_listing_status( $listing_id, $listing_status ); - } - } - - return $listing_status; -} + function atbdp_get_listing_status_after_submission( array $args = array() ) { + // Set default values and sanitize input parameters + $args = array_merge( + array( + 'id' => 0, + 'edited' => false, // Default to false if not set + ), + $args + ); + + $listing_id = $args['id']; + $listing_status = $args['edited'] ? $args['edit_status'] : $args['create_status']; + $monetization_enabled = directorist_is_monetization_enabled(); + $featured_enabled = directorist_is_featured_listing_enabled(); + $pricing_plans_enabled = is_fee_manager_active(); + + // Determine post status based on monetization settings and plans + if ( $monetization_enabled ) { + if ( $pricing_plans_enabled ) { + return directorist_get_pricing_plan_status( $listing_id, $listing_status ); + } elseif ( $featured_enabled ) { + return directorist_get_featured_listing_status( $listing_id, $listing_status ); + } + } + + return $listing_status; + } endif; -if (!function_exists('load_dependencies')): - /** - * It loads files from a given directory using require_once. - * @param string|array $files list of the names of file or a single file name to be loaded. Default: all - * @param string $directory the location of the files - * @param string $ext the ext of the files to be loaded - * @return resource|bool it requires all the files in a given directory - */ - function load_dependencies($files = 'all', $directory = ATBDP_CLASS_DIR, $ext = '.php') - { - if (!file_exists($directory)) return; // vail if the directory does not exist - - switch ($files) { - case is_array($files) && 'all' !== strtolower($files[0]): - // include one or more file looping through the $files array - load_some_file($files, $directory); - break; - case !is_array($files) && 'all' !== $files: - //load a single file here - (file_exists($directory . $files . $ext)) ? require_once $directory . $files . $ext : null; - break; - case 'all' == $files || 'all' == strtolower($files[0]): - // load all php file here - load_all_files($directory); - break; - } - - return false; - - } +if ( ! function_exists( 'load_dependencies' ) ) : + /** + * It loads files from a given directory using require_once. + * + * @param string|array $files list of the names of file or a single file name to be loaded. Default: all + * @param string $directory the location of the files + * @param string $ext the ext of the files to be loaded + * @return resource|bool it requires all the files in a given directory + */ + function load_dependencies( $files = 'all', $directory = ATBDP_CLASS_DIR, $ext = '.php' ) { + if ( ! file_exists( $directory ) ) { + return; // vail if the directory does not exist + } + + switch ( $files ) { + case is_array( $files ) && 'all' !== strtolower( $files[0] ): + // include one or more file looping through the $files array + load_some_file( $files, $directory ); + break; + case ! is_array( $files ) && 'all' !== $files: + // load a single file here + ( file_exists( $directory . $files . $ext ) ) ? require_once $directory . $files . $ext : null; + break; + case 'all' == $files || 'all' == strtolower( $files[0] ): + // load all php file here + load_all_files( $directory ); + break; + } + + return false; + } endif; -if (!function_exists('load_all_files')): - /** - * It loads all files that has the extension named $ext from the $dir - * @param string $dir Name of the directory - * @param string $ext Name of the extension of the files to be loaded - */ - function load_all_files($dir = '', $ext = '.php') - { - if (!file_exists($dir)) return; - foreach (scandir($dir) as $file) { - // require once all the files with the given ext. eg. .php - if (preg_match("/{$ext}$/i", $file)) { - require_once($dir . $file); - } - } - } +if ( ! function_exists( 'load_all_files' ) ) : + /** + * It loads all files that has the extension named $ext from the $dir + * + * @param string $dir Name of the directory + * @param string $ext Name of the extension of the files to be loaded + */ + function load_all_files( $dir = '', $ext = '.php' ) { + if ( ! file_exists( $dir ) ) { + return; + } + foreach ( scandir( $dir ) as $file ) { + // require once all the files with the given ext. eg. .php + if ( preg_match( "/{$ext}$/i", $file ) ) { + require_once $dir . $file; + } + } + } endif; -if (!function_exists('load_some_file')): - - /** - * It loads one or more files but not all files that has the $ext from the $dir - * @param string|array $files the array of files that should be loaded - * @param string $dir Name of the directory - * @param string $ext Name of the extension of the files to be loaded - */ - function load_some_file($files = array(), $dir = '', $ext = '.php') - { - if (!file_exists($dir)) return; // vail if directory does not exist - - if (is_array($files)) { // if the given files is an array then - $files_to_loads = array_map(function ($i) use ($ext) { - return $i . $ext; - }, $files);// add '.php' to the end of all files - $found_files = scandir($dir); // get the list of all the files in the given $dir - foreach ($files_to_loads as $file_to_load) { - if(is_array($found_files)) { - in_array($file_to_load, $found_files) ? require_once $dir . $file_to_load : null; - } - } - } - - } +if ( ! function_exists( 'load_some_file' ) ) : + + /** + * It loads one or more files but not all files that has the $ext from the $dir + * + * @param string|array $files the array of files that should be loaded + * @param string $dir Name of the directory + * @param string $ext Name of the extension of the files to be loaded + */ + function load_some_file( $files = array(), $dir = '', $ext = '.php' ) { + if ( ! file_exists( $dir ) ) { + return; // vail if directory does not exist + } + + if ( is_array( $files ) ) { // if the given files is an array then + $files_to_loads = array_map( + function ( $i ) use ( $ext ) { + return $i . $ext; + }, + $files + );// add '.php' to the end of all files + $found_files = scandir( $dir ); // get the list of all the files in the given $dir + foreach ( $files_to_loads as $file_to_load ) { + if ( is_array( $found_files ) ) { + in_array( $file_to_load, $found_files ) ? require_once $dir . $file_to_load : null; + } + } + } + } endif; -if (!function_exists('attc_letter_to_number')): - - /** - * Calculate the column index (number) of a column header string (example: A is 1, AA is 27, ...). - * - * For the opposite, @param string $column Column string. - * @return int $number Column number, 1-based. - * @see number_to_letter(). - * - * @since 1.0.0 - * - */ - function attc_letter_to_number($column) - { - $column = strtoupper($column); - $count = strlen($column); - $number = 0; - for ($i = 0; $i < $count; $i++) { - $number += (ord($column[$count - 1 - $i]) - 64) * pow(26, $i); - } - return $number; - } +if ( ! function_exists( 'attc_letter_to_number' ) ) : + + /** + * Calculate the column index (number) of a column header string (example: A is 1, AA is 27, ...). + * + * For the opposite, @param string $column Column string. + * + * @return int $number Column number, 1-based. + * @see number_to_letter(). + * + * @since 1.0.0 + */ + function attc_letter_to_number( $column ) { + $column = strtoupper( $column ); + $count = strlen( $column ); + $number = 0; + for ( $i = 0; $i < $count; $i++ ) { + $number += ( ord( $column[ $count - 1 - $i ] ) - 64 ) * pow( 26, $i ); + } + return $number; + } endif; -if (!function_exists('attc_number_to_letter')): - - /** - * "Calculate" the column header string of a column index (example: 2 is B, AB is 28, ...). - * - * For the opposite, @param int $number Column number, 1-based. - * @return string $column Column string. - * @see letter_to_number(). - * - * @since 1.0.0 - * - */ - function attc_number_to_letter($number) - { - $column = ''; - while ($number > 0) { - $column = chr(65 + (($number - 1) % 26)) . $column; - $number = floor(($number - 1) / 26); - } - return $column; - } +if ( ! function_exists( 'attc_number_to_letter' ) ) : + + /** + * "Calculate" the column header string of a column index (example: 2 is B, AB is 28, ...). + * + * For the opposite, @param int $number Column number, 1-based. + * + * @return string $column Column string. + * @see letter_to_number(). + * + * @since 1.0.0 + */ + function attc_number_to_letter( $number ) { + $column = ''; + while ( $number > 0 ) { + $column = chr( 65 + ( ( $number - 1 ) % 26 ) ) . $column; + $number = floor( ( $number - 1 ) / 26 ); + } + return $column; + } endif; -if (!function_exists('atbdp_v_d')): - - /** - * It dumps data to the screen in a div that has margin left 200px. - * It is good for dumping data in WordPress dashboard - */ - function atbdp_v_d($a = null) - { - echo "<pre>"; - var_dump($a); - echo "</pre>"; - } +if ( ! function_exists( 'atbdp_v_d' ) ) : + + /** + * It dumps data to the screen in a div that has margin left 200px. + * It is good for dumping data in WordPress dashboard + */ + function atbdp_v_d( $a = null ) { + echo '<pre>'; + var_dump( $a ); + echo '</pre>'; + } endif; -if (!function_exists('list_file_name')): - /** - * It returns a list of names of all files which are not hidden files - * @param string $path - * @return array - */ - function list_file_name($path = __DIR__) - { - $file_names = array(); - foreach (new DirectoryIterator($path) as $fileInfo) { - if ($fileInfo->isDot()) continue; - $file_names[] = $fileInfo->getFilename(); - } - return $file_names; - } +if ( ! function_exists( 'list_file_name' ) ) : + /** + * It returns a list of names of all files which are not hidden files + * + * @param string $path + * @return array + */ + function list_file_name( $path = __DIR__ ) { + $file_names = array(); + foreach ( new DirectoryIterator( $path ) as $fileInfo ) { + if ( $fileInfo->isDot() ) { + continue; + } + $file_names[] = $fileInfo->getFilename(); + } + return $file_names; + } endif; -if (!function_exists('list_file_path')): - /** - * It returns a list of path of all files which are not hidden files - * @param string $path - * @return array - */ - function list_file_path($path = __DIR__) - { - $file_paths = array(); - foreach (new DirectoryIterator($path) as $fileInfo) { - if ($fileInfo->isDot()) continue; - $file_paths[] = $fileInfo->getRealPath(); - } - return $file_paths; - } +if ( ! function_exists( 'list_file_path' ) ) : + /** + * It returns a list of path of all files which are not hidden files + * + * @param string $path + * @return array + */ + function list_file_path( $path = __DIR__ ) { + $file_paths = array(); + foreach ( new DirectoryIterator( $path ) as $fileInfo ) { + if ( $fileInfo->isDot() ) { + continue; + } + $file_paths[] = $fileInfo->getRealPath(); + } + return $file_paths; + } endif; -if (!function_exists('beautiful_datetime')): - /** - * It display a nice date and time - * @param $datetime - * @param string $type - * @param string $separator - * @return string - */ - function beautiful_datetime($datetime, $type = 'mysql', $separator = ' ') - { - if ('mysql' === $type) { - return mysql2date(get_option('date_format'), $datetime) . $separator . mysql2date(get_option('time_format'), $datetime); - } else { - return date_i18n(get_option('date_format'), $datetime) . $separator . date_i18n(get_option('time_format'), $datetime); - } - } +if ( ! function_exists( 'beautiful_datetime' ) ) : + /** + * It display a nice date and time + * + * @param $datetime + * @param string $type + * @param string $separator + * @return string + */ + function beautiful_datetime( $datetime, $type = 'mysql', $separator = ' ' ) { + if ( 'mysql' === $type ) { + return mysql2date( get_option( 'date_format' ), $datetime ) . $separator . mysql2date( get_option( 'time_format' ), $datetime ); + } else { + return date_i18n( get_option( 'date_format' ), $datetime ) . $separator . date_i18n( get_option( 'time_format' ), $datetime ); + } + } endif; -if (!function_exists('aazztech_enc_serialize')) { - /** - * It will serialize and then encode the string and return the encoded data - * @param $data - * @return string - */ - function aazztech_enc_serialize($data) - { - return (!empty($data)) ? base64_encode(serialize($data)) : null; - } -} - -if (!function_exists('aazztech_enc_unserialize')) { - /** - * It will decode the data and then unserialize the data and return it - * @param string $data Encoded strings that should be decoded and then unserialize - * @return mixed - */ - function aazztech_enc_unserialize($data) - { - return (!empty($data)) ? unserialize(base64_decode($data)) : null; - } +if ( ! function_exists( 'aazztech_enc_serialize' ) ) { + /** + * It will serialize and then encode the string and return the encoded data + * + * @param $data + * @return string + */ + function aazztech_enc_serialize( $data ) { + return ( ! empty( $data ) ) ? base64_encode( serialize( $data ) ) : null; + } +} + +if ( ! function_exists( 'aazztech_enc_unserialize' ) ) { + /** + * It will decode the data and then unserialize the data and return it + * + * @param string $data Encoded strings that should be decoded and then unserialize + * @return mixed + */ + function aazztech_enc_unserialize( $data ) { + return ( ! empty( $data ) ) ? unserialize( base64_decode( $data ) ) : null; + } } /** @@ -537,185 +571,191 @@ function aazztech_enc_unserialize($data) * * @return object WP_Query */ -if (!function_exists('atbd_get_related_posts')) { - // get related post based on tags or categories - function atbd_get_related_posts() { +if ( ! function_exists( 'atbd_get_related_posts' ) ) { + // get related post based on tags or categories + function atbd_get_related_posts() { _deprecated_function( __FUNCTION__, '7.4.3' ); return new WP_Query(); - } -} - -if (!function_exists('atbdp_get_option')) { - - /** - * It retrieves an option from the database if it exists and returns false if it is not exist. - * It is a custom function to get the data of custom setting page - * @param string $name The name of the option we would like to get. Eg. map_api_key - * @param string $group The name of the group where the option is saved. eg. general_settings - * @param mixed $default Default value for the option key if the option does not have value then default will be returned - * @return mixed It returns the value of the $name option if it exists in the option $group in the database, false otherwise. - */ - function atbdp_get_option($name, $group, $default = false) - { - // at first get the group of options from the database. - // then check if the data exists in the array and if it exists then return it - // if not, then return false - if (empty($name) || empty($group)) { - if (!empty($default)) return $default; - return false; - } // vail if either $name or option $group is empty - $options_array = (array)get_option($group); - if (array_key_exists($name, $options_array)) { - return $options_array[$name]; - } else { - if (!empty($default)) return $default; - return false; - } - } -} - -function get_directorist_type_option( $type, $name, $default='' ) { - $meta = get_term_meta( $type, $name, true ); - $result = $meta != '' ? $meta : $default; - return $result; -} - -if (!function_exists('get_directorist_option')) { - - /** - * It retrieves an option from the database if it exists and returns false if it is not exist. - * It is a custom function to get the data of custom setting page - * @param string $name The name of the option we would like to get. Eg. map_api_key - * @param mixed $default Default value for the option key if the option does not have value then default will be returned - * @param bool $force_default Whether to use default value when database return anything other than NULL such as '', false etc - * @return mixed It returns the value of the $name option if it exists in the option $group in the database, false otherwise. - */ - function get_directorist_option($name, $default = false, $force_default = false) - { - // at first get the group of options from the database. - // then check if the data exists in the array and if it exists then return it - // if not, then return false - if (empty($name)) { - return $default; - } - // get the option from the database and return it if it is not a null value. Otherwise, return the default value - $options = (array)get_option('atbdp_option'); - $v = (array_key_exists($name, $options)) - ? $v = $options[sanitize_key($name)] - : null; - - $newvalue = apply_filters( 'directorist_option', $v, $name ); - - if ( $newvalue != $v ) { - return $newvalue; - } - - // use default only when the value of the $v is NULL - if (is_null($v)) { - return $default; - } - if ($force_default) { - // use the default value even if the value of $v is falsy value returned from the database - if (empty($v)) { - return $default; - } - } - return (isset($v)) ? $v : $default; // return the data if it is anything but NULL. - } + } } -if ( ! function_exists( 'update_directorist_option' ) ) { - function update_directorist_option( $key = '', $value = '' ) { - $options = ( array ) get_option( 'atbdp_option', [] ); - $options[ $key ] = $value; +if ( ! function_exists( 'atbdp_get_option' ) ) { + + /** + * It retrieves an option from the database if it exists and returns false if it is not exist. + * It is a custom function to get the data of custom setting page + * + * @param string $name The name of the option we would like to get. Eg. map_api_key + * @param string $group The name of the group where the option is saved. eg. general_settings + * @param mixed $default Default value for the option key if the option does not have value then default will be returned + * @return mixed It returns the value of the $name option if it exists in the option $group in the database, false otherwise. + */ + function atbdp_get_option( $name, $group, $default = false ) { + // at first get the group of options from the database. + // then check if the data exists in the array and if it exists then return it + // if not, then return false + if ( empty( $name ) || empty( $group ) ) { + if ( ! empty( $default ) ) { + return $default; + } + return false; + } // vail if either $name or option $group is empty + $options_array = (array) get_option( $group ); + if ( array_key_exists( $name, $options_array ) ) { + return $options_array[ $name ]; + } else { + if ( ! empty( $default ) ) { + return $default; + } + return false; + } + } +} - update_option( 'atbdp_option', $options ); - } +function get_directorist_type_option( $type, $name, $default = '' ) { + $meta = get_term_meta( $type, $name, true ); + $result = $meta != '' ? $meta : $default; + return $result; } +if ( ! function_exists( 'get_directorist_option' ) ) { + + /** + * It retrieves an option from the database if it exists and returns false if it is not exist. + * It is a custom function to get the data of custom setting page + * + * @param string $name The name of the option we would like to get. Eg. map_api_key + * @param mixed $default Default value for the option key if the option does not have value then default will be returned + * @param bool $force_default Whether to use default value when database return anything other than NULL such as '', false etc + * @return mixed It returns the value of the $name option if it exists in the option $group in the database, false otherwise. + */ + function get_directorist_option( $name, $default = false, $force_default = false ) { + // at first get the group of options from the database. + // then check if the data exists in the array and if it exists then return it + // if not, then return false + if ( empty( $name ) ) { + return $default; + } + // get the option from the database and return it if it is not a null value. Otherwise, return the default value + $options = (array) get_option( 'atbdp_option' ); + $v = ( array_key_exists( $name, $options ) ) + ? $v = $options[ sanitize_key( $name ) ] + : null; -if (!function_exists('atbdp_yes_to_bool')) { - function atbdp_yes_to_bool($v = false) - { - if (empty($v)) return false; - return ('yes' == trim($v)) ? true : false; - } + $newvalue = apply_filters( 'directorist_option', $v, $name ); + + if ( $newvalue != $v ) { + return $newvalue; + } + + // use default only when the value of the $v is NULL + if ( is_null( $v ) ) { + return $default; + } + if ( $force_default ) { + // use the default value even if the value of $v is falsy value returned from the database + if ( empty( $v ) ) { + return $default; + } + } + return ( isset( $v ) ) ? $v : $default; // return the data if it is anything but NULL. + } } +if ( ! function_exists( 'update_directorist_option' ) ) { + function update_directorist_option( $key = '', $value = '' ) { + $options = (array) get_option( 'atbdp_option', array() ); + $options[ $key ] = $value; -if (!function_exists('atbdp_pagination')) { - /** - * Prints pagination for custom post - * @param object|WP_Query $custom_post_query - * @param int $paged - * - * @return string - */ - function atbdp_pagination($custom_post_query, $paged = 1) - { - $navigation = ''; - $largeNumber = 999999999; // we need a large number here + update_option( 'atbdp_option', $options ); + } +} - $total = ( isset( $custom_post_query->total_pages ) ) ? $custom_post_query->total_pages : $custom_post_query->max_num_pages; - $paged = ( isset( $custom_post_query->current_page ) ) ? $custom_post_query->current_page : $paged; - $links = paginate_links(array( - 'base' => str_replace($largeNumber, '%#%', esc_url(get_pagenum_link($largeNumber))), - 'format' => '?paged=%#%', - 'current' => max(1, $paged), - 'total' => $total, - 'prev_text' => apply_filters('atbdp_pagination_prev_text', directorist_icon( 'fas fa-chevron-left', false )), - 'next_text' => apply_filters('atbdp_pagination_next_text', directorist_icon( 'fas fa-chevron-right', false )), - )); +if ( ! function_exists( 'atbdp_yes_to_bool' ) ) { + function atbdp_yes_to_bool( $v = false ) { + if ( empty( $v ) ) { + return false; + } + return ( 'yes' == trim( $v ) ) ? true : false; + } +} - if ($links) { - $navigation = _navigation_markup($links, 'pagination', ' '); - } - return apply_filters('atbdp_pagination', $navigation, $links, $custom_post_query, $paged); - } +if ( ! function_exists( 'atbdp_pagination' ) ) { + /** + * Prints pagination for custom post + * + * @param object|WP_Query $custom_post_query + * @param int $paged + * + * @return string + */ + function atbdp_pagination( $custom_post_query, $paged = 1 ) { + $navigation = ''; + $largeNumber = 999999999; // we need a large number here + + $total = ( isset( $custom_post_query->total_pages ) ) ? $custom_post_query->total_pages : $custom_post_query->max_num_pages; + $paged = ( isset( $custom_post_query->current_page ) ) ? $custom_post_query->current_page : $paged; + + $links = paginate_links( + array( + 'base' => str_replace( $largeNumber, '%#%', esc_url( get_pagenum_link( $largeNumber ) ) ), + 'format' => '?paged=%#%', + 'current' => max( 1, $paged ), + 'total' => $total, + 'prev_text' => apply_filters( 'atbdp_pagination_prev_text', directorist_icon( 'fas fa-chevron-left', false ) ), + 'next_text' => apply_filters( 'atbdp_pagination_next_text', directorist_icon( 'fas fa-chevron-right', false ) ), + ) + ); + + if ( $links ) { + $navigation = _navigation_markup( $links, 'pagination', ' ' ); + } + + return apply_filters( 'atbdp_pagination', $navigation, $links, $custom_post_query, $paged ); + } } -if(!function_exists('get_recent_reviews')) { - function get_recent_reviews( $number = 5 ){ - global $wpdb; +if ( ! function_exists( 'get_recent_reviews' ) ) { + function get_recent_reviews( $number = 5 ) { + global $wpdb; - $sql = $wpdb->prepare( - "SELECT * FROM {$wpdb->prefix}atbdp_review + $sql = $wpdb->prepare( + "SELECT * FROM {$wpdb->prefix}atbdp_review ORDER BY id DESC LIMIT %d", - $number - ); + $number + ); - $items = $wpdb->get_results( $sql ); + $items = $wpdb->get_results( $sql ); - return $items; - } - } + return $items; + } +} -if(!function_exists('get_review_by_ids')) { - function get_review_by_ids( $review_ids = [], $number = 5 ){ - global $wpdb; - $ids = implode(",",$review_ids); - $sql = $wpdb->prepare( - "SELECT * FROM {$wpdb->prefix}atbdp_review +if ( ! function_exists( 'get_review_by_ids' ) ) { + function get_review_by_ids( $review_ids = array(), $number = 5 ) { + global $wpdb; + $ids = implode( ',', $review_ids ); + $sql = $wpdb->prepare( + "SELECT * FROM {$wpdb->prefix}atbdp_review WHERE id IN ({$ids}) LIMIT %d", - $number - ); + $number + ); - $items = $wpdb->get_results( $sql ); + $items = $wpdb->get_results( $sql ); - return $items; - } + return $items; + } } -if (!function_exists('get_cat_icon')) { - function get_cat_icon($term_id) - { - $icon = get_term_meta($term_id, 'category_icon', true); - return !empty($icon) ? $icon : ''; - } +if ( ! function_exists( 'get_cat_icon' ) ) { + function get_cat_icon( $term_id ) { + $icon = get_term_meta( $term_id, 'category_icon', true ); + return ! empty( $icon ) ? $icon : ''; + } } if ( ! function_exists( 'str_starts_with' ) ) { @@ -744,22 +784,22 @@ function str_starts_with( $haystack, $needle ) { * * Also supports Unicons 3.0.3 for backward compatibility, but should not be used. * - * @param string $icon Icon class name eg. 'las la-home'. - * @param bool $echo Either echo or return the html. Default true. - * @param string $class Extra wrapper class. Default empty string. + * @param string $icon Icon class name eg. 'las la-home'. + * @param bool $echo Either echo or return the html. Default true. + * @param string $class Extra wrapper class. Default empty string. * * @return string Echo or return icon html string. */ function directorist_icon( $icon, $echo = true, $class = '' ) { - if ( !$icon ) { - return; - } + if ( ! $icon ) { + return; + } $icon_src = \Directorist\Helper::get_icon_src( $icon ); - if ( !$icon_src ) { - return; - } + if ( ! $icon_src ) { + return; + } $class = $class ? 'directorist-icon-mask ' . $class : 'directorist-icon-mask'; @@ -769,392 +809,382 @@ function directorist_icon( $icon, $echo = true, $class = '' ) { esc_url( $icon_src ) ); - if ( $echo ) { - echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped - } - else { - return $html; - } + if ( $echo ) { + echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- already escaped + } else { + return $html; + } } -if (!function_exists('atbdp_sanitize_array')) { - /** - * It sanitize a multi-dimensional array +if ( ! function_exists( 'atbdp_sanitize_array' ) ) { + /** + * It sanitize a multi-dimensional array * * @deprecated 7.3.1 - * @param array &$array The array of the data to sanitize - * @return mixed - */ - function atbdp_sanitize_array( $array ) { + * @param array &$array The array of the data to sanitize + * @return mixed + */ + function atbdp_sanitize_array( $array ) { return directorist_clean( $array ); - } -} - -if (!function_exists('is_directoria_active')) { - /** - * It checks if the Directorist theme is installed currently. - * @return bool It returns true if the directorist theme is active currently. False otherwise. - */ - function is_directoria_active() - { - return wp_get_theme()->get_stylesheet() === 'directoria'; - } -} - -if (!function_exists('is_multiple_images_active')) { - /** - * It checks if the Directorist Multiple images Extension is active and enabled - * @return bool It returns true if the Directorist Multiple images Extension is active and enabled - */ - function is_multiple_images_active() - { - - return true; // plugin is active and enabled - } -} - - -if (!function_exists('is_business_hour_active')) { - /** - * It checks if the Directorist Business Hour Extension is active and enabled - * @return bool It returns true if the Directorist Business Hour Extension is active and enabled - */ - function is_business_hour_active() - { - $enable = get_directorist_option('enable_business_hour'); - if ($enable && class_exists('BD_Business_Hour')) { - return true; - } - } -} - -if (!function_exists('is_empty_v')) { - /** - * It checks if the value of the given data ( array or string etc ) is empty - * @param array $value The value to check if it is empty - * @return bool It returns true if the value of the given data is empty, and false otherwise. - */ - function is_empty_v($value) - { - if (!is_array($value)) return empty($value); - foreach ($value as $key => $val) { - if (!empty($val)) - return false; - } - return true; - } -} - -if (!function_exists('atbdp_get_paged_num')) { - /** - * Get current page number for the pagination. - * - * @return int $paged The current page number for the pagination. - * @since 1.0.0 - * - */ - function atbdp_get_paged_num() - { - - global $paged; - - if (get_query_var('paged')) { - $paged = get_query_var('paged'); - } else if (get_query_var('page')) { - $paged = get_query_var('page'); - } else { - $paged = isset( $_REQUEST['paged'] ) ? directorist_clean( wp_unslash( $_REQUEST['paged'] ) ) : 1; - } - - return absint($paged); - - } - - -} - -if (!function_exists('valid_js_nonce')) { - /** - * It checks if the nonce is set and valid - * @return bool it returns true if the nonce is valid and false otherwise - */ - function valid_js_nonce() - { - if (!empty($_POST['atbdp_nonce_js']) && (wp_verify_nonce($_POST['atbdp_nonce_js'], 'atbdp_nonce_action_js'))) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - return true; - return false; - } -} - -if (!function_exists('atbdp_get_featured_settings_array')) { - /** - * It fetch all the settings related to featured listing. - * @return array it returns an array of settings related to featured listings. - */ - function atbdp_get_featured_settings_array() - { - return array( - 'active' => directorist_is_featured_listing_enabled(), - 'label' => get_directorist_option( 'featured_listing_title', __('Featured', 'directorist') ), - 'desc' => get_directorist_option('featured_listing_desc'), - 'price' => get_directorist_option('featured_listing_price'), - ); - } -} - -if (!function_exists('atbdp_only_logged_in_user')) { - - /** - * It informs a user to logged in and returns false if the user is not logged in. - * if a user is not logged in. - * @param string $message - * @return bool It returns true if a user is logged in and false otherwise. Besides, it display a message to non-logged in users - */ - function atbdp_is_user_logged_in($message = '') - { - if ( ! is_user_logged_in() ) { - // user not logged in; - $error_message = ( empty( $message ) ) - ? sprintf( __( 'You need to be logged in to view the content of this page. You can login/sign up %s', 'directorist' ), apply_filters( "atbdp_login_page_link", "<a href='" . ATBDP_Permalink::get_dashboard_page_link() . "'> " . __( 'Here', 'directorist' ) . "</a>" ) ) - : $message; - $container_fluid = is_directoria_active() ? 'container' : 'container-fluid'; - ?> - <section class="directory_wrapper single_area"> - <div class="<?php echo esc_attr( apply_filters('atbdp_login_message_container_fluid', $container_fluid) ); ?>"> - <div class="row"> - <div class="col-md-12"> - <?php ATBDP()->helper->show_login_message($error_message); ?> - </div> - </div> - </div> <!--ends container-fluid--> - </section> - <?php - return false; - } - return true; - } -} - -if (!function_exists('atbdp_get_months')) { - /** - * Get an array of translatable month names - * @return array - * @since 3.1.0 - */ - function atbdp_get_months() - { - return array( - __("Jan", 'directorist'), - __("Feb", 'directorist'), - __("Mar", 'directorist'), - __("Apr", 'directorist'), - __("May", 'directorist'), - __("Jun", 'directorist'), - __("Jul", 'directorist'), - __("Aug", 'directorist'), - __("Sep", 'directorist'), - __("Oct", 'directorist'), - __("Nov", 'directorist'), - __("Dec", 'directorist') - ); - } -} - -if (!function_exists('calc_listing_expiry_date')) { - /** - * Calculate listing expiry date from the given date - * - * @param string $start_date Date from which the expiry date should be calculated. - * @return string $date It returns expiry date in the mysql date format - * @since 3.1.0 - * - */ - function calc_listing_expiry_date($start_date = NULL, $expire = NULL, $directory_type = '' ) - { - $type = $directory_type ? $directory_type : default_directory_type(); - $exp_days = get_term_meta( $type, 'default_expiration', true ); - $exp_days = !empty( $exp_days ) ? $exp_days : 0; - $expired_date = !empty($expire) ? $expire : $exp_days; - // Current time - $start_date = !empty($start_date) ? $start_date : current_time('mysql'); - // Calculate new date - $date = new DateTime($start_date); - $date->add(new DateInterval("P{$expired_date}D")); // set the interval in days - return $date->format('Y-m-d H:i:s'); - - } -} - -if (!function_exists('get_date_in_mysql_format')) { - /** - * It converts a date array to MySQL date format (Y-m-d H:i:s). - * - * @param array $date Array of date values. - * eg. array( - * 'year' => 0, - * 'month' => 0, - * 'day' => 0, - * 'hour' => 0, - * 'min' => 0, - * 'sec' => 0 - * ); - * @return string $date Formatted MySQL date string. - * @since 3.1.0 - * - */ - function get_date_in_mysql_format($date) - { - - $defaults = array( - 'year' => 0, - 'month' => 0, - 'day' => 0, - 'hour' => 0, - 'min' => 0, - 'sec' => 0 - ); - $date = wp_parse_args($date, $defaults); - - $year = (int)$date['year']; - $year = str_pad($year, 4, '0', STR_PAD_RIGHT); - - $month = (int)$date['month']; - $month = max(1, min(12, $month)); - - $day = (int)$date['day']; - $day = max(1, min(31, $day)); - - $hour = (int)$date['hour']; - $hour = max(1, min(24, $hour)); - - $min = (int)$date['min']; - $min = max(0, min(59, $min)); - - $sec = (int)$date['sec']; - $sec = max(0, min(59, $sec)); - - return sprintf('%04d-%02d-%02d %02d:%02d:%02d', $year, $month, $day, $hour, $min, $sec); - - } -} - -if (!function_exists('atbdp_parse_mysql_date')) { - /** - * Parse MySQL date format. - * - * @param string $date MySQL date string. - * @return array $date Array of date values. - * @since 3.1.0 - * - */ - function atbdp_parse_mysql_date($date) - { - - $date = preg_split('([^0-9])', $date); - - return array( - 'year' => $date[0], - 'month' => $date[1], - 'day' => $date[2], - 'hour' => $date[3], - 'min' => $date[4], - 'sec' => $date[5] - ); - - } -} - -if (!function_exists('currency_has_decimal')) { - /** - * Check if currency has decimals. - * @param string $currency - * @return bool - */ - function currency_has_decimals($currency) - { - if (in_array($currency, array('RIAL', 'SAR', 'HUF', 'JPY', 'TWD'))) { - return false; - } - - return true; - } + } +} + +if ( ! function_exists( 'is_directoria_active' ) ) { + /** + * It checks if the Directorist theme is installed currently. + * + * @return bool It returns true if the directorist theme is active currently. False otherwise. + */ + function is_directoria_active() { + return wp_get_theme()->get_stylesheet() === 'directoria'; + } +} + +if ( ! function_exists( 'is_multiple_images_active' ) ) { + /** + * It checks if the Directorist Multiple images Extension is active and enabled + * + * @return bool It returns true if the Directorist Multiple images Extension is active and enabled + */ + function is_multiple_images_active() { + + return true; // plugin is active and enabled + } +} + + +if ( ! function_exists( 'is_business_hour_active' ) ) { + /** + * It checks if the Directorist Business Hour Extension is active and enabled + * + * @return bool It returns true if the Directorist Business Hour Extension is active and enabled + */ + function is_business_hour_active() { + $enable = get_directorist_option( 'enable_business_hour' ); + if ( $enable && class_exists( 'BD_Business_Hour' ) ) { + return true; + } + } +} + +if ( ! function_exists( 'is_empty_v' ) ) { + /** + * It checks if the value of the given data ( array or string etc ) is empty + * + * @param array $value The value to check if it is empty + * @return bool It returns true if the value of the given data is empty, and false otherwise. + */ + function is_empty_v( $value ) { + if ( ! is_array( $value ) ) { + return empty( $value ); + } + foreach ( $value as $key => $val ) { + if ( ! empty( $val ) ) { + return false; + } + } + return true; + } +} + +if ( ! function_exists( 'atbdp_get_paged_num' ) ) { + /** + * Get current page number for the pagination. + * + * @return int $paged The current page number for the pagination. + * @since 1.0.0 + */ + function atbdp_get_paged_num() { + + global $paged; + + if ( get_query_var( 'paged' ) ) { + $paged = get_query_var( 'paged' ); + } elseif ( get_query_var( 'page' ) ) { + $paged = get_query_var( 'page' ); + } else { + $paged = isset( $_REQUEST['paged'] ) ? directorist_clean( wp_unslash( $_REQUEST['paged'] ) ) : 1; + } + + return absint( $paged ); + } + + +} + +if ( ! function_exists( 'valid_js_nonce' ) ) { + /** + * It checks if the nonce is set and valid + * + * @return bool it returns true if the nonce is valid and false otherwise + */ + function valid_js_nonce() { + if ( ! empty( $_POST['atbdp_nonce_js'] ) && ( wp_verify_nonce( $_POST['atbdp_nonce_js'], 'atbdp_nonce_action_js' ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + return true; + } + return false; + } +} + +if ( ! function_exists( 'atbdp_get_featured_settings_array' ) ) { + /** + * It fetch all the settings related to featured listing. + * + * @return array it returns an array of settings related to featured listings. + */ + function atbdp_get_featured_settings_array() { + return array( + 'active' => directorist_is_featured_listing_enabled(), + 'label' => get_directorist_option( 'featured_listing_title', __( 'Featured', 'directorist' ) ), + 'desc' => get_directorist_option( 'featured_listing_desc' ), + 'price' => get_directorist_option( 'featured_listing_price' ), + ); + } +} + +if ( ! function_exists( 'atbdp_only_logged_in_user' ) ) { + + /** + * It informs a user to logged in and returns false if the user is not logged in. + * if a user is not logged in. + * + * @param string $message + * @return bool It returns true if a user is logged in and false otherwise. Besides, it display a message to non-logged in users + */ + function atbdp_is_user_logged_in( $message = '' ) { + if ( ! is_user_logged_in() ) { + // user not logged in; + $error_message = ( empty( $message ) ) + ? sprintf( __( 'You need to be logged in to view the content of this page. You can login/sign up %s', 'directorist' ), apply_filters( 'atbdp_login_page_link', "<a href='" . ATBDP_Permalink::get_dashboard_page_link() . "'> " . __( 'Here', 'directorist' ) . '</a>' ) ) + : $message; + $container_fluid = is_directoria_active() ? 'container' : 'container-fluid'; + ?> + <section class="directory_wrapper single_area"> + <div class="<?php echo esc_attr( apply_filters( 'atbdp_login_message_container_fluid', $container_fluid ) ); ?>"> + <div class="row"> + <div class="col-md-12"> + <?php ATBDP()->helper->show_login_message( $error_message ); ?> + </div> + </div> + </div> <!--ends container-fluid--> + </section> + <?php + return false; + } + return true; + } +} + +if ( ! function_exists( 'atbdp_get_months' ) ) { + /** + * Get an array of translatable month names + * + * @return array + * @since 3.1.0 + */ + function atbdp_get_months() { + return array( + __( 'Jan', 'directorist' ), + __( 'Feb', 'directorist' ), + __( 'Mar', 'directorist' ), + __( 'Apr', 'directorist' ), + __( 'May', 'directorist' ), + __( 'Jun', 'directorist' ), + __( 'Jul', 'directorist' ), + __( 'Aug', 'directorist' ), + __( 'Sep', 'directorist' ), + __( 'Oct', 'directorist' ), + __( 'Nov', 'directorist' ), + __( 'Dec', 'directorist' ), + ); + } +} + +if ( ! function_exists( 'calc_listing_expiry_date' ) ) { + /** + * Calculate listing expiry date from the given date + * + * @param string $start_date Date from which the expiry date should be calculated. + * @return string $date It returns expiry date in the mysql date format + * @since 3.1.0 + */ + function calc_listing_expiry_date( $start_date = null, $expire = null, $directory_type = '' ) { + $type = $directory_type ? $directory_type : default_directory_type(); + $exp_days = get_term_meta( $type, 'default_expiration', true ); + $exp_days = ! empty( $exp_days ) ? $exp_days : 0; + $expired_date = ! empty( $expire ) ? $expire : $exp_days; + // Current time + $start_date = ! empty( $start_date ) ? $start_date : current_time( 'mysql' ); + // Calculate new date + $date = new DateTime( $start_date ); + $date->add( new DateInterval( "P{$expired_date}D" ) ); // set the interval in days + return $date->format( 'Y-m-d H:i:s' ); + } +} + +if ( ! function_exists( 'get_date_in_mysql_format' ) ) { + /** + * It converts a date array to MySQL date format (Y-m-d H:i:s). + * + * @param array $date Array of date values. + * eg. array( + * 'year' => 0, + * 'month' => 0, + * 'day' => 0, + * 'hour' => 0, + * 'min' => 0, + * 'sec' => 0 + * ); + * @return string $date Formatted MySQL date string. + * @since 3.1.0 + */ + function get_date_in_mysql_format( $date ) { + + $defaults = array( + 'year' => 0, + 'month' => 0, + 'day' => 0, + 'hour' => 0, + 'min' => 0, + 'sec' => 0, + ); + $date = wp_parse_args( $date, $defaults ); + + $year = (int) $date['year']; + $year = str_pad( $year, 4, '0', STR_PAD_RIGHT ); + + $month = (int) $date['month']; + $month = max( 1, min( 12, $month ) ); + + $day = (int) $date['day']; + $day = max( 1, min( 31, $day ) ); + + $hour = (int) $date['hour']; + $hour = max( 1, min( 24, $hour ) ); + + $min = (int) $date['min']; + $min = max( 0, min( 59, $min ) ); + + $sec = (int) $date['sec']; + $sec = max( 0, min( 59, $sec ) ); + + return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $year, $month, $day, $hour, $min, $sec ); + } +} + +if ( ! function_exists( 'atbdp_parse_mysql_date' ) ) { + /** + * Parse MySQL date format. + * + * @param string $date MySQL date string. + * @return array $date Array of date values. + * @since 3.1.0 + */ + function atbdp_parse_mysql_date( $date ) { + + $date = preg_split( '([^0-9])', $date ); + + return array( + 'year' => $date[0], + 'month' => $date[1], + 'day' => $date[2], + 'hour' => $date[3], + 'min' => $date[4], + 'sec' => $date[5], + ); + } +} + +if ( ! function_exists( 'currency_has_decimal' ) ) { + /** + * Check if currency has decimals. + * + * @param string $currency + * @return bool + */ + function currency_has_decimals( $currency ) { + if ( in_array( $currency, array( 'RIAL', 'SAR', 'HUF', 'JPY', 'TWD' ) ) ) { + return false; + } + + return true; + } } /** * Print formatted Price inside a p tag * * @param int|string $price The price amount to display - * @param bool $disable_price whether displaying price is enabled or disabled - * @param string $currency The name of the currency - * @param string $symbol currency symbol - * @param string $c_position currency position - * @param bool $echo Whether to Print value or to Return value. Default is printing value. + * @param bool $disable_price whether displaying price is enabled or disabled + * @param string $currency The name of the currency + * @param string $symbol currency symbol + * @param string $c_position currency position + * @param bool $echo Whether to Print value or to Return value. Default is printing value. * @return mixed */ -function atbdp_display_price($price = '', $disable_price = false, $currency = '', $symbol = '', $c_position = '', $echo = true) -{ - if (empty($price) || $disable_price) return null; // vail if the price is empty or price display is disabled. - - $allow_decimal = get_directorist_option('allow_decimal', 1); - $before = ''; - $after = ''; - if (empty($c_position)) { - $c_position = directorist_get_currency_position(); - } - if (empty($currency)) { - $currency = directorist_get_currency(); - } - if (empty($symbol)) { - $symbol = atbdp_currency_symbol($currency); - } - - ('after' == $c_position) ? $after = $symbol : $before = $symbol; - $price = $before . atbdp_format_amount($price, $allow_decimal) . $after; - $p = sprintf("<span class='directorist-listing-price'>%s</span>", $price); - if ($echo) { - echo wp_kses_post( $p ); - } else { - return $p; - } +function atbdp_display_price( $price = '', $disable_price = false, $currency = '', $symbol = '', $c_position = '', $echo = true ) { + if ( empty( $price ) || $disable_price ) { + return null; // vail if the price is empty or price display is disabled. + } + + $allow_decimal = get_directorist_option( 'allow_decimal', 1 ); + $before = ''; + $after = ''; + if ( empty( $c_position ) ) { + $c_position = directorist_get_currency_position(); + } + if ( empty( $currency ) ) { + $currency = directorist_get_currency(); + } + if ( empty( $symbol ) ) { + $symbol = atbdp_currency_symbol( $currency ); + } + ( 'after' == $c_position ) ? $after = $symbol : $before = $symbol; + $price = $before . atbdp_format_amount( $price, $allow_decimal ) . $after; + $p = sprintf( "<span class='directorist-listing-price'>%s</span>", $price ); + if ( $echo ) { + echo wp_kses_post( $p ); + } else { + return $p; + } } /** * Print formatted Price inside a p tag * - * * @return mixed */ -function atbdp_display_price_range($price_range) -{ - $currency = directorist_get_currency(); - $c_symbol = atbdp_currency_symbol($currency); - if (empty($price_range)) return null; - $output = ''; - if ('skimming' == $price_range) { - $output = - '<span class="directorist-listing-price-range directorist-tooltip" data-label="Skimming"><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span> +function atbdp_display_price_range( $price_range ) { + $currency = directorist_get_currency(); + $c_symbol = atbdp_currency_symbol( $currency ); + if ( empty( $price_range ) ) { + return null; + } + $output = ''; + if ( 'skimming' == $price_range ) { + $output = + '<span class="directorist-listing-price-range directorist-tooltip" data-label="Skimming"><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span> </span>'; - } elseif ('moderate' == $price_range) { - $output = - '<span class="directorist-listing-price-range directorist-tooltip" data-label="Moderate"><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span>' . $c_symbol . '</span> + } elseif ( 'moderate' == $price_range ) { + $output = + '<span class="directorist-listing-price-range directorist-tooltip" data-label="Moderate"><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span>' . $c_symbol . '</span> </span>'; - } elseif ('economy' == $price_range) { - $output = - '<span class="directorist-listing-price-range directorist-tooltip" data-label="Economy"><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span>' . $c_symbol . '</span><span>' . $c_symbol . '</span> + } elseif ( 'economy' == $price_range ) { + $output = + '<span class="directorist-listing-price-range directorist-tooltip" data-label="Economy"><span class="directorist-price-active">' . $c_symbol . '</span><span class="directorist-price-active">' . $c_symbol . '</span><span>' . $c_symbol . '</span><span>' . $c_symbol . '</span> </span>'; - } elseif ('bellow_economy' == $price_range) { + } elseif ( 'bellow_economy' == $price_range ) { - $output = - '<span class="directorist-listing-price-range directorist-tooltip" data-label="Cheap"><span class="directorist-price-active">' . $c_symbol . '</span><span>' . $c_symbol . '</span><span>' . $c_symbol . '</span><span>' . $c_symbol . '</span> + $output = + '<span class="directorist-listing-price-range directorist-tooltip" data-label="Cheap"><span class="directorist-price-active">' . $c_symbol . '</span><span>' . $c_symbol . '</span><span>' . $c_symbol . '</span><span>' . $c_symbol . '</span> </span>'; - } - return $output; - + } + return $output; } @@ -1164,45 +1194,43 @@ function atbdp_display_price_range($price_range) * @param int $term_id Custom Taxonomy term ID. * @return int Listings count. * @since 4.0.0 - * */ -function atbdp_listings_count_by_category( $term_id, $listing_type = '' ) -{ - $args = array( - 'fields' => 'ids', - 'posts_per_page' => -1, - 'post_type' => ATBDP_POST_TYPE, - 'post_status' => 'publish', - ); - - if( ! empty( $listing_type ) && 'all' !== $listing_type ) { - $args['tax_query'] = array( - 'relation' => 'AND', - array( - 'taxonomy' => ATBDP_CATEGORY, - 'field' => 'term_id', - 'terms' => $term_id, - 'include_children' => true - ), - array( - 'taxonomy' => ATBDP_TYPE, - 'field' => 'term_id', - 'terms' => (int) $listing_type, - ) - ); - } else { - $args['tax_query'] = array( - array( - 'taxonomy' => ATBDP_CATEGORY, - 'field' => 'term_id', - 'terms' => $term_id, - 'include_children' => true - ) - ); - } +function atbdp_listings_count_by_category( $term_id, $listing_type = '' ) { + $args = array( + 'fields' => 'ids', + 'posts_per_page' => -1, + 'post_type' => ATBDP_POST_TYPE, + 'post_status' => 'publish', + ); + + if ( ! empty( $listing_type ) && 'all' !== $listing_type ) { + $args['tax_query'] = array( + 'relation' => 'AND', + array( + 'taxonomy' => ATBDP_CATEGORY, + 'field' => 'term_id', + 'terms' => $term_id, + 'include_children' => true, + ), + array( + 'taxonomy' => ATBDP_TYPE, + 'field' => 'term_id', + 'terms' => (int) $listing_type, + ), + ); + } else { + $args['tax_query'] = array( + array( + 'taxonomy' => ATBDP_CATEGORY, + 'field' => 'term_id', + 'terms' => $term_id, + 'include_children' => true, + ), + ); + } $query = new WP_Query( $args ); - return count( $query->posts ); + return count( $query->posts ); } /** @@ -1211,59 +1239,59 @@ function atbdp_listings_count_by_category( $term_id, $listing_type = '' ) * @param array $settings Settings args. * @return string HTML code that contain categories list. * @since 1.0.0 - * */ -function atbdp_list_categories($settings) -{ +function atbdp_list_categories( $settings ) { - if ($settings['depth'] <= 0) { - return; - } + if ( $settings['depth'] <= 0 ) { + return; + } - $args = array( - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => !empty($settings['hide_empty']) ? 1 : 0, - 'parent' => $settings['term_id'], - 'hierarchical' => false - ); + $args = array( + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => ! empty( $settings['hide_empty'] ) ? 1 : 0, + 'parent' => $settings['term_id'], + 'hierarchical' => false, + ); - $terms = get_terms(ATBDP_CATEGORY, $args); - $html = ''; + $terms = get_terms( ATBDP_CATEGORY, $args ); + $html = ''; - if (count($terms) > 0) { + if ( count( $terms ) > 0 ) { - --$settings['depth']; + --$settings['depth']; - $html .= '<ul class="list-unstyled atbdp_child_category">'; + $html .= '<ul class="list-unstyled atbdp_child_category">'; - foreach ($terms as $term) { - $settings['term_id'] = $term->term_id; - $child_category = get_term_children($term->term_id, ATBDP_CATEGORY); - $plus_icon = !empty($child_category) ? '<span class="expander">+</span>' : ''; - $count = 0; - if (!empty($settings['hide_empty']) || !empty($settings['show_count'])) { - $count = atbdp_listings_count_by_category($term->term_id); + foreach ( $terms as $term ) { + $settings['term_id'] = $term->term_id; + $child_category = get_term_children( $term->term_id, ATBDP_CATEGORY ); + $plus_icon = ! empty( $child_category ) ? '<span class="expander">+</span>' : ''; + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_category( $term->term_id ); - if (!empty($settings['hide_empty']) && 0 == $count) continue; - } + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } - $html .= '<li>'; - $html .= '<a href=" ' . ATBDP_Permalink::atbdp_get_category_page($term) . ' ">'; - $html .= $term->name; - if (!empty($settings['show_count'])) { - $html .= ' (' . $count . ')'; - } - $html .= "</a>$plus_icon"; - $html .= atbdp_list_categories($settings); - $html .= '</li>'; - } + $html .= '<li>'; + $html .= '<a href=" ' . ATBDP_Permalink::atbdp_get_category_page( $term ) . ' ">'; + $html .= $term->name; + if ( ! empty( $settings['show_count'] ) ) { + $html .= ' (' . $count . ')'; + } + $html .= "</a>$plus_icon"; + $html .= atbdp_list_categories( $settings ); + $html .= '</li>'; + } - $html .= '</ul>'; + $html .= '</ul>'; - } + } - return $html; + return $html; } /** @@ -1272,45 +1300,44 @@ function atbdp_list_categories($settings) * @param int $term_id Custom Taxonomy term ID. * @return int Listings count. * @since 4.0.0 - * */ function atbdp_listings_count_by_location( $term_id, $listing_type = '' ) { - $args = array( - 'fields' => 'ids', - 'posts_per_page' => -1, - 'post_type' => ATBDP_POST_TYPE, - 'post_status' => 'publish', - ); - - if( ! empty( $listing_type ) && 'all' !== $listing_type ) { - $args['tax_query'] = array( - 'relation' => 'AND', - array( - 'taxonomy' => ATBDP_LOCATION, - 'field' => 'term_id', - 'terms' => $term_id, - 'include_children' => true - ), - array( - 'taxonomy' => ATBDP_TYPE, - 'field' => 'term_id', - 'terms' => (int) $listing_type, - ) - ); - } else { - $args['tax_query'] = array( - array( - 'taxonomy' => ATBDP_LOCATION, - 'field' => 'term_id', - 'terms' => $term_id, - 'include_children' => true - ) - ); - } + $args = array( + 'fields' => 'ids', + 'posts_per_page' => -1, + 'post_type' => ATBDP_POST_TYPE, + 'post_status' => 'publish', + ); + + if ( ! empty( $listing_type ) && 'all' !== $listing_type ) { + $args['tax_query'] = array( + 'relation' => 'AND', + array( + 'taxonomy' => ATBDP_LOCATION, + 'field' => 'term_id', + 'terms' => $term_id, + 'include_children' => true, + ), + array( + 'taxonomy' => ATBDP_TYPE, + 'field' => 'term_id', + 'terms' => (int) $listing_type, + ), + ); + } else { + $args['tax_query'] = array( + array( + 'taxonomy' => ATBDP_LOCATION, + 'field' => 'term_id', + 'terms' => $term_id, + 'include_children' => true, + ), + ); + } $query = new WP_Query( $args ); $count = count( $query->posts ); - return $count; + return $count; } /** @@ -1319,60 +1346,60 @@ function atbdp_listings_count_by_location( $term_id, $listing_type = '' ) { * @param array $settings Settings args. * @return string HTML code that contain categories list. * @since 1.0.0 - * */ -function atbdp_list_locations($settings) -{ +function atbdp_list_locations( $settings ) { - if ($settings['depth'] <= 0) { - return; - } + if ( $settings['depth'] <= 0 ) { + return; + } - $args = array( - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => !empty($settings['hide_empty']) ? 1 : 0, - 'parent' => $settings['term_id'], - 'hierarchical' => false - ); + $args = array( + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => ! empty( $settings['hide_empty'] ) ? 1 : 0, + 'parent' => $settings['term_id'], + 'hierarchical' => false, + ); - $terms = get_terms(ATBDP_LOCATION, $args); + $terms = get_terms( ATBDP_LOCATION, $args ); - $html = ''; + $html = ''; - if (count($terms) > 0) { + if ( count( $terms ) > 0 ) { - --$settings['depth']; + --$settings['depth']; - $html .= '<ul class="list-unstyled atbdp_child_category">'; + $html .= '<ul class="list-unstyled atbdp_child_category">'; - foreach ($terms as $term) { - $settings['term_id'] = $term->term_id; - $child_category = get_term_children($term->term_id, ATBDP_LOCATION); - $plus_icon = !empty($child_category) ? '<span class="expander">+</span>' : ''; - $count = 0; - if (!empty($settings['hide_empty']) || !empty($settings['show_count'])) { - $count = atbdp_listings_count_by_location($term->term_id); + foreach ( $terms as $term ) { + $settings['term_id'] = $term->term_id; + $child_category = get_term_children( $term->term_id, ATBDP_LOCATION ); + $plus_icon = ! empty( $child_category ) ? '<span class="expander">+</span>' : ''; + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_location( $term->term_id ); - if (!empty($settings['hide_empty']) && 0 == $count) continue; - } + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } - $html .= '<li>'; - $html .= '<a href=" ' . ATBDP_Permalink::atbdp_get_location_page($term) . ' ">'; - $html .= $term->name; - if (!empty($settings['show_count'])) { - $html .= ' (' . $count . ')'; - } - $html .= "</a>$plus_icon"; - $html .= atbdp_list_locations($settings); - $html .= '</li>'; - } + $html .= '<li>'; + $html .= '<a href=" ' . ATBDP_Permalink::atbdp_get_location_page( $term ) . ' ">'; + $html .= $term->name; + if ( ! empty( $settings['show_count'] ) ) { + $html .= ' (' . $count . ')'; + } + $html .= "</a>$plus_icon"; + $html .= atbdp_list_locations( $settings ); + $html .= '</li>'; + } - $html .= '</ul>'; + $html .= '</ul>'; - } + } - return $html; + return $html; } /** @@ -1381,41 +1408,42 @@ function atbdp_list_locations($settings) * @param int $term_id Custom Taxonomy term ID. * @return int Listings count. * @since 4.0.0 - * */ -function atbdp_listings_count_by_tag($term_id) -{ - - $args = array( - 'fields' => 'ids', - 'posts_per_page' => -1, - 'post_type' => ATBDP_POST_TYPE, - 'post_status' => 'publish', - 'tax_query' => array( - array( - 'taxonomy' => ATBDP_TAGS, - 'field' => 'term_id', - 'terms' => $term_id, - 'include_children' => true - ) - ), - 'meta_query' => apply_filters('atbdp_listings_with_tag_meta_query', array( - 'relation' => 'OR', - array( - 'key' => '_expiry_date', - 'value' => current_time('mysql'), - 'compare' => '>', // eg. expire date 6 <= current date 7 will return the post - 'type' => 'DATETIME' - ), - array( - 'key' => '_never_expire', - ), - )) - ); +function atbdp_listings_count_by_tag( $term_id ) { + + $args = array( + 'fields' => 'ids', + 'posts_per_page' => -1, + 'post_type' => ATBDP_POST_TYPE, + 'post_status' => 'publish', + 'tax_query' => array( + array( + 'taxonomy' => ATBDP_TAGS, + 'field' => 'term_id', + 'terms' => $term_id, + 'include_children' => true, + ), + ), + 'meta_query' => apply_filters( + 'atbdp_listings_with_tag_meta_query', + array( + 'relation' => 'OR', + array( + 'key' => '_expiry_date', + 'value' => current_time( 'mysql' ), + 'compare' => '>', // eg. expire date 6 <= current date 7 will return the post + 'type' => 'DATETIME', + ), + array( + 'key' => '_never_expire', + ), + ) + ), + ); $query = new WP_Query( $args ); $count = count( $query->posts ); - return $count; + return $count; } /** @@ -1424,59 +1452,59 @@ function atbdp_listings_count_by_tag($term_id) * @param array $settings Settings args. * @return string HTML code that contain categories list. * @since 1.0.0 - * */ -function atbdp_list_tags($settings) -{ +function atbdp_list_tags( $settings ) { - if ($settings['depth'] <= 0) { - return; - } + if ( $settings['depth'] <= 0 ) { + return; + } - $args = array( - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => !empty($settings['hide_empty']) ? 1 : 0, - 'parent' => $settings['term_id'], - 'hierarchical' => false - ); + $args = array( + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => ! empty( $settings['hide_empty'] ) ? 1 : 0, + 'parent' => $settings['term_id'], + 'hierarchical' => false, + ); - $terms = get_terms(ATBDP_TAGS, $args); + $terms = get_terms( ATBDP_TAGS, $args ); - $html = ''; + $html = ''; - if (count($terms) > 0) { + if ( count( $terms ) > 0 ) { - --$settings['depth']; + --$settings['depth']; - $html .= '<ul class="list-unstyled">'; + $html .= '<ul class="list-unstyled">'; - foreach ($terms as $term) { - $settings['term_id'] = $term->term_id; + foreach ( $terms as $term ) { + $settings['term_id'] = $term->term_id; - $count = 0; - if (!empty($settings['hide_empty']) || !empty($settings['show_count'])) { - $count = atbdp_listings_count_by_tag($term->term_id); + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_tag( $term->term_id ); - if (!empty($settings['hide_empty']) && 0 == $count) continue; - } + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } - $html .= '<li>'; - $html .= '<a href=" ' . ATBDP_Permalink::get_tag_archive($settings['term']) . ' ">'; - $html .= $term->name; - if (!empty($settings['show_count'])) { - $html .= ' (' . $count . ')'; - } - $html .= '</a>'; - $html .= atbdp_list_tags($settings); - $html .= '</li>'; - } + $html .= '<li>'; + $html .= '<a href=" ' . ATBDP_Permalink::get_tag_archive( $settings['term'] ) . ' ">'; + $html .= $term->name; + if ( ! empty( $settings['show_count'] ) ) { + $html .= ' (' . $count . ')'; + } + $html .= '</a>'; + $html .= atbdp_list_tags( $settings ); + $html .= '</li>'; + } - $html .= '</ul>'; + $html .= '</ul>'; - } + } - return $html; + return $html; } /** @@ -1485,21 +1513,18 @@ function atbdp_list_tags($settings) * @param string $default_order Default Order. * @return string $order Listings Order. * @since 4.0 - * */ -function atbdp_get_listings_current_order($default_order = '') -{ +function atbdp_get_listings_current_order( $default_order = '' ) { - $order = $default_order; + $order = $default_order; - if ( isset( $_REQUEST['sort'] ) && ! empty( $_REQUEST['sort'] ) ) { - $order = directorist_clean( wp_unslash( $_REQUEST['sort'] ) ); - } else if ( isset( $_REQUEST['order'] ) && ! empty( $_REQUEST['order'] ) ) { - $order = directorist_clean( wp_unslash( $_REQUEST['order'] ) ); - } - - return apply_filters('atbdp_get_listings_current_order', $order); + if ( isset( $_REQUEST['sort'] ) && ! empty( $_REQUEST['sort'] ) ) { + $order = directorist_clean( wp_unslash( $_REQUEST['sort'] ) ); + } elseif ( isset( $_REQUEST['order'] ) && ! empty( $_REQUEST['order'] ) ) { + $order = directorist_clean( wp_unslash( $_REQUEST['order'] ) ); + } + return apply_filters( 'atbdp_get_listings_current_order', $order ); } /** @@ -1507,55 +1532,54 @@ function atbdp_get_listings_current_order($default_order = '') * * @return array $options A list of the orderby options. * @since 1.0.0 - * */ function atbdp_get_listings_orderby_options( $orderby = array() ) { - $orderby_options = array( - 'title-asc' => __( 'A to Z (title)', 'directorist' ), - 'title-desc' => __( 'Z to A (title)', 'directorist' ), - 'date-desc' => __( 'Latest listings', 'directorist' ), - 'date-asc' => __( 'Oldest listings', 'directorist' ), - 'views-desc' => __( 'Popular listings', 'directorist' ), - 'price-asc' => __( 'Price (low to high)', 'directorist' ), - 'price-desc' => __( 'Price (high to low)', 'directorist' ), - 'rand' => __( 'Random listings', 'directorist' ), - ); - - if ( ! is_array( $orderby ) ) { + $orderby_options = array( + 'title-asc' => __( 'A to Z (title)', 'directorist' ), + 'title-desc' => __( 'Z to A (title)', 'directorist' ), + 'date-desc' => __( 'Latest listings', 'directorist' ), + 'date-asc' => __( 'Oldest listings', 'directorist' ), + 'views-desc' => __( 'Popular listings', 'directorist' ), + 'price-asc' => __( 'Price (low to high)', 'directorist' ), + 'price-desc' => __( 'Price (high to low)', 'directorist' ), + 'rand' => __( 'Random listings', 'directorist' ), + ); + + if ( ! is_array( $orderby ) ) { $orderby = (array) $orderby; } - if ( ! in_array( 'a_z', $orderby, true ) ) { - unset( $orderby_options['title-asc'] ); - } - if ( ! in_array( 'z_a', $orderby, true ) ) { - unset( $orderby_options['title-desc'] ); - } - if ( ! in_array( 'latest', $orderby, true ) ) { - unset( $orderby_options['date-desc'] ); - } - if ( ! in_array( 'oldest', $orderby, true ) ) { - unset( $orderby_options['date-asc'] ); - } - if ( ! in_array( 'popular', $orderby, true ) ) { - unset( $orderby_options['views-desc'] ); - } - if ( ! in_array( 'price_low_high', $orderby, true ) ) { - unset( $orderby_options['price-asc'] ); - } - if ( ! in_array( 'price_high_low', $orderby, true ) ) { - unset( $orderby_options['price-desc'] ); - } - if ( ! in_array( 'random', $orderby, true ) ) { - unset( $orderby_options['rand'] ); - } - - $listings_price_disabled = (bool) get_directorist_option( 'disable_list_price', 0 ); + if ( ! in_array( 'a_z', $orderby, true ) ) { + unset( $orderby_options['title-asc'] ); + } + if ( ! in_array( 'z_a', $orderby, true ) ) { + unset( $orderby_options['title-desc'] ); + } + if ( ! in_array( 'latest', $orderby, true ) ) { + unset( $orderby_options['date-desc'] ); + } + if ( ! in_array( 'oldest', $orderby, true ) ) { + unset( $orderby_options['date-asc'] ); + } + if ( ! in_array( 'popular', $orderby, true ) ) { + unset( $orderby_options['views-desc'] ); + } + if ( ! in_array( 'price_low_high', $orderby, true ) ) { + unset( $orderby_options['price-asc'] ); + } + if ( ! in_array( 'price_high_low', $orderby, true ) ) { + unset( $orderby_options['price-desc'] ); + } + if ( ! in_array( 'random', $orderby, true ) ) { + unset( $orderby_options['rand'] ); + } + + $listings_price_disabled = (bool) get_directorist_option( 'disable_list_price', 0 ); if ( $listings_price_disabled || ! directorist_have_listings_with_price() ) { - unset( $orderby_options['price-asc'], $orderby_options['price-desc'] ); - } + unset( $orderby_options['price-asc'], $orderby_options['price-desc'] ); + } - return apply_filters( 'atbdp_get_listings_orderby_options', $orderby_options ); + return apply_filters( 'atbdp_get_listings_orderby_options', $orderby_options ); } function directorist_have_listings_with_price() { @@ -1567,7 +1591,7 @@ function directorist_have_listings_with_price() { 'posts_per_page' => 1, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, - ); + ); $listings_with_price = new WP_Query( $args ); return $listings_with_price->have_posts(); @@ -1579,56 +1603,51 @@ function directorist_have_listings_with_price() { * @param string $view Default View. * @return string $view Grid or List. * @since 4.0.0 - * */ -function atbdp_get_listings_current_view_name($view) -{ - - - if (isset($_REQUEST['view'])) { - $view = directorist_clean( wp_unslash( $_REQUEST['view'] ) ); - } - - $allowed_views = array('list', 'grid', 'map'); - if (class_exists('BD_Map_View')) { - array_push($allowed_views, 'listings_with_map'); - } - if (!in_array($view, $allowed_views)) { - $listing_view = get_directorist_option('default_listing_view'); - $listings_settings = !empty($listing_view) ? $listing_view : 'grid'; - $view = $listings_settings; - } +function atbdp_get_listings_current_view_name( $view ) { + if ( isset( $_REQUEST['view'] ) ) { + $view = directorist_clean( wp_unslash( $_REQUEST['view'] ) ); + } - return $view; + $allowed_views = array( 'list', 'grid', 'map' ); + if ( class_exists( 'BD_Map_View' ) ) { + array_push( $allowed_views, 'listings_with_map' ); + } + if ( ! in_array( $view, $allowed_views ) ) { + $listing_view = get_directorist_option( 'default_listing_view' ); + $listings_settings = ! empty( $listing_view ) ? $listing_view : 'grid'; + $view = $listings_settings; + } + return $view; } function atbdp_calculate_column( $number ) { - switch( $number ) { - case 1: - $columns = 12; - break; - case 2: - $columns = 6; - break; - case 3: - $columns = 4; - break; - case 4: - $columns = 3; - break; - case 5: - $columns = 2; - break; - case 6: - $columns = 2; - break; - default: - $columns = 3; - } - - return $columns; + switch ( $number ) { + case 1: + $columns = 12; + break; + case 2: + $columns = 6; + break; + case 3: + $columns = 4; + break; + case 4: + $columns = 3; + break; + case 5: + $columns = 2; + break; + case 6: + $columns = 2; + break; + default: + $columns = 3; + } + + return $columns; } /** @@ -1636,68 +1655,61 @@ function atbdp_calculate_column( $number ) { * * @return array $view_options List of view Options. * @since 4.0.0 - * */ -function atbdp_get_listings_view_options($view_as_items) -{ - $listing_view = get_directorist_option('default_listing_view'); - $listings_settings = !empty($listing_view) ? $listing_view : 'grid'; - - $options = array('grid', 'list', 'map'); - $display_map = get_directorist_option('display_map_field', 1); - $select_listing_map = get_directorist_option('select_listing_map', 'google'); - - $view_as_items = is_array( $view_as_items ) ? $view_as_items : []; - if (!in_array('listings_grid', $view_as_items)) { - unset($options[0]); - } - if (!in_array('listings_list', $view_as_items)) { - unset($options[1]); - } - if (empty($display_map) || !in_array('listings_map', $view_as_items)) { - unset($options[2]); - } - $options[] = isset($_GET['view']) ? directorist_clean( wp_unslash( $_GET['view'] ) ) : $listings_settings; - $options = array_unique($options); - - $views = array(); - - foreach ($options as $option) { - - switch ($option) { - case 'list' : - $views[$option] = __('List', 'directorist'); - break; - case 'grid' : - $views[$option] = __('Grid', 'directorist'); - break; - case 'map' : - $views[$option] = __('Map', 'directorist'); - break; - } - - } - - return $views; +function atbdp_get_listings_view_options( $view_as_items ) { + $listing_view = get_directorist_option( 'default_listing_view' ); + $listings_settings = ! empty( $listing_view ) ? $listing_view : 'grid'; + + $options = array( 'grid', 'list', 'map' ); + $display_map = get_directorist_option( 'display_map_field', 1 ); + $select_listing_map = get_directorist_option( 'select_listing_map', 'google' ); + + $view_as_items = is_array( $view_as_items ) ? $view_as_items : array(); + if ( ! in_array( 'listings_grid', $view_as_items ) ) { + unset( $options[0] ); + } + if ( ! in_array( 'listings_list', $view_as_items ) ) { + unset( $options[1] ); + } + if ( empty( $display_map ) || ! in_array( 'listings_map', $view_as_items ) ) { + unset( $options[2] ); + } + $options[] = isset( $_GET['view'] ) ? directorist_clean( wp_unslash( $_GET['view'] ) ) : $listings_settings; + $options = array_unique( $options ); + + $views = array(); + + foreach ( $options as $option ) { + + switch ( $option ) { + case 'list': + $views[ $option ] = __( 'List', 'directorist' ); + break; + case 'grid': + $views[ $option ] = __( 'Grid', 'directorist' ); + break; + case 'map': + $views[ $option ] = __( 'Map', 'directorist' ); + break; + } + } + return $views; } /** * @param $var * @return array|string */ -function atbdp_get_view_as($view) -{ - $views = atbdp_get_listings_view_options($view); - $ways = ''; - foreach ($views as $value => $label) { - $active_class = ($view == $value) ? ' active' : ''; - $ways = sprintf('<a class="dropdown-item%s" href="%s">%s</a>', $active_class, add_query_arg('view', $value), $label); - - } - return $ways; - +function atbdp_get_view_as( $view ) { + $views = atbdp_get_listings_view_options( $view ); + $ways = ''; + foreach ( $views as $value => $label ) { + $active_class = ( $view == $value ) ? ' active' : ''; + $ways = sprintf( '<a class="dropdown-item%s" href="%s">%s</a>', $active_class, add_query_arg( 'view', $value ), $label ); + } + return $ways; } /* @@ -1707,13 +1719,12 @@ function atbdp_get_view_as($view) * @param string|array $var Data to sanitize. * @return string|array */ -function directorist_clean($var) -{ - if (is_array($var)) { - return array_map('directorist_clean', $var); - } else { - return is_scalar($var) ? sanitize_text_field($var) : $var; - } +function directorist_clean( $var ) { + if ( is_array( $var ) ) { + return array_map( 'directorist_clean', $var ); + } else { + return is_scalar( $var ) ? sanitize_text_field( $var ) : $var; + } } /* @@ -1723,13 +1734,12 @@ function directorist_clean($var) * @param string|array $var Data to sanitize. * @return string|array */ -function directorist_clean_post( $var ) -{ - if (is_array($var)) { - return array_map('directorist_clean_post', $var); - } else { - return is_scalar($var) ? wp_kses_post( $var ) : $var; - } +function directorist_clean_post( $var ) { + if ( is_array( $var ) ) { + return array_map( 'directorist_clean_post', $var ); + } else { + return is_scalar( $var ) ? wp_kses_post( $var ) : $var; + } } /** @@ -1738,33 +1748,32 @@ function directorist_clean_post( $var ) * @param int $post_id Post ID. * @return mixed Included the favourites and unfavourites button * @since 4.0 - * */ function the_atbdp_favourites_link( $post_id = 0 ) { - if ( $post_id == 0 ) { - global $post; - $post_id = $post->ID; - } + if ( $post_id == 0 ) { + global $post; + $post_id = $post->ID; + } - $favourites = directorist_get_user_favorites( get_current_user_id() ); - if ( in_array( $post_id, $favourites ) ) { - return directorist_icon( 'las la-heart', false, 'directorist-added-to-favorite'); - } else { - return directorist_icon( 'las la-heart', false ); - } + $favourites = directorist_get_user_favorites( get_current_user_id() ); + if ( in_array( $post_id, $favourites ) ) { + return directorist_icon( 'las la-heart', false, 'directorist-added-to-favorite' ); + } else { + return directorist_icon( 'las la-heart', false ); + } } function atbdp_listings_mark_as_favourite( $listing_id ) { - $favourites = directorist_get_user_favorites( get_current_user_id() ); - $fav_class = ''; + $favourites = directorist_get_user_favorites( get_current_user_id() ); + $fav_class = ''; - if ( in_array( $listing_id, $favourites ) ) { - $fav_class = 'atbdp_fav_isActive'; - } + if ( in_array( $listing_id, $favourites ) ) { + $fav_class = 'atbdp_fav_isActive'; + } - $mark_as_fav_link = '<div class="atbdp_add_to_fav_listings"><a class="atbdp_mark_as_fav ' . $fav_class . '" id="atbdp-fav_' . $listing_id . '" data-listing_id="' . $listing_id . '" href=""><span class="atbd_fav_icon"></span><span class="atbd_fav_tooltip"></span></a></div>'; - return $mark_as_fav_link; + $mark_as_fav_link = '<div class="atbdp_add_to_fav_listings"><a class="atbdp_mark_as_fav ' . $fav_class . '" id="atbdp-fav_' . $listing_id . '" data-listing_id="' . $listing_id . '" href=""><span class="atbd_fav_icon"></span><span class="atbd_fav_tooltip"></span></a></div>'; + return $mark_as_fav_link; } /** @@ -1773,99 +1782,97 @@ function atbdp_listings_mark_as_favourite( $listing_id ) { * @param int $listing_id Listing ID. * @return string URL to remove from favourites. * @since 1.0.0 - * */ -function atbdp_get_remove_favourites_page_link($listing_id) -{ +function atbdp_get_remove_favourites_page_link( $listing_id ) { - $link = add_query_arg(array('atbdp_action' => 'remove-favourites', 'atbdp_listing' => $listing_id)); - - return $link; + $link = add_query_arg( + array( + 'atbdp_action' => 'remove-favourites', + 'atbdp_listing' => $listing_id, + ) + ); + return $link; } -if (!function_exists('new_badge')) { - function new_badge() - { - global $post; - $new_listing_time = get_directorist_option('new_listing_day'); - $new_badge_text = get_directorist_option('new_badge_text', 'New'); - $each_hours = 60 * 60 * 24; // seconds in a day - $s_date1 = strtotime(current_time('mysql')); // seconds for date 1 - $s_date2 = strtotime($post->post_date); // seconds for date 2 - $s_date_diff = abs($s_date1 - $s_date2); // different of the two dates in seconds - $days = round($s_date_diff / $each_hours); // divided the different with second in a day - $new = '<span class="atbd_badge atbd_badge_new">' . $new_badge_text . '</span>'; - if ($days <= (int)$new_listing_time) { - return $new; +if ( ! function_exists( 'new_badge' ) ) { + function new_badge() { + global $post; + $new_listing_time = get_directorist_option( 'new_listing_day' ); + $new_badge_text = get_directorist_option( 'new_badge_text', 'New' ); + $each_hours = 60 * 60 * 24; // seconds in a day + $s_date1 = strtotime( current_time( 'mysql' ) ); // seconds for date 1 + $s_date2 = strtotime( $post->post_date ); // seconds for date 2 + $s_date_diff = abs( $s_date1 - $s_date2 ); // different of the two dates in seconds + $days = round( $s_date_diff / $each_hours ); // divided the different with second in a day + $new = '<span class="atbd_badge atbd_badge_new">' . $new_badge_text . '</span>'; + if ( $days <= (int) $new_listing_time ) { + return $new; - } - } + } + } } /** * Generate image crop. * * @param string $attachmentId Image Url. - * @param int $width Image Width. - * @param int $height Image Height. - * @param bool $crop cropping condition. - * @param int $quality Quality. + * @param int $width Image Width. + * @param int $height Image Height. + * @param bool $crop cropping condition. + * @param int $quality Quality. * @return array $resizer return resize. * @since 4.0.0 - * */ -function atbdp_image_cropping($attachmentId, $width, $height, $crop = true, $quality = 100) -{ - $resizer = new Atbdp_Image_resizer($attachmentId); +function atbdp_image_cropping( $attachmentId, $width, $height, $crop = true, $quality = 100 ) { + $resizer = new Atbdp_Image_resizer( $attachmentId ); - return $resizer->resize($width, $height, $crop, $quality); + return $resizer->resize( $width, $height, $crop, $quality ); } -if (!function_exists('is_fee_manager_active')) { - /** - * It checks is user purchased plan included in that feature. - * @return bool It returns true if the above mentioned exists. - */ - function is_fee_manager_active() - { - $FM_disabled_byAdmin = get_directorist_option('fee_manager_enable', 1); - $WFM_disabled_byAdmin = get_directorist_option('woo_pricing_plans_enable', 1); - if (class_exists('ATBDP_Pricing_Plans') && $FM_disabled_byAdmin) { - return true; - } elseif (class_exists('DWPP_Pricing_Plans') && $WFM_disabled_byAdmin) { - return true; - } else { - return false; - } - - } +if ( ! function_exists( 'is_fee_manager_active' ) ) { + /** + * It checks is user purchased plan included in that feature. + * + * @return bool It returns true if the above mentioned exists. + */ + function is_fee_manager_active() { + $FM_disabled_byAdmin = get_directorist_option( 'fee_manager_enable', 1 ); + $WFM_disabled_byAdmin = get_directorist_option( 'woo_pricing_plans_enable', 1 ); + if ( class_exists( 'ATBDP_Pricing_Plans' ) && $FM_disabled_byAdmin ) { + return true; + } elseif ( class_exists( 'DWPP_Pricing_Plans' ) && $WFM_disabled_byAdmin ) { + return true; + } else { + return false; + } + } } if ( ! function_exists( 'atbdp_pricing_plan_is_enabled' ) ) : - // atbdp_pricing_plan_is_enabled - function atbdp_pricing_plan_is_enabled() { - $pricing_plan_is_enabled = get_directorist_option('fee_manager_enable', 1); + // atbdp_pricing_plan_is_enabled + function atbdp_pricing_plan_is_enabled() { + $pricing_plan_is_enabled = get_directorist_option( 'fee_manager_enable', 1 ); - if ( class_exists('ATBDP_Pricing_Plans') && $pricing_plan_is_enabled) { - return true; - } + if ( class_exists( 'ATBDP_Pricing_Plans' ) && $pricing_plan_is_enabled ) { + return true; + } - return false; - } + return false; + } endif; if ( ! function_exists( 'atbdp_wc_pricing_plan_is_enabled' ) ) : - // atbdp_wc_pricing_plan_is_enabled - function atbdp_wc_pricing_plan_is_enabled() { - $wc_pricing_plan_is_enabled = get_directorist_option('woo_pricing_plans_enable', 1); + // atbdp_wc_pricing_plan_is_enabled + function atbdp_wc_pricing_plan_is_enabled() { + $wc_pricing_plan_is_enabled = get_directorist_option( 'woo_pricing_plans_enable', 1 ); - if ( class_exists('DWPP_Pricing_Plans') && $wc_pricing_plan_is_enabled) { - return true; - } + if ( class_exists( 'DWPP_Pricing_Plans' ) && $wc_pricing_plan_is_enabled ) { + return true; + } - return false; - } + return false; + } endif; /** @@ -1883,98 +1890,98 @@ function atbdp_wc_pricing_plan_is_enabled() { * @since 1.5.6 Added to check GD invoices and GD checkout pages. */ -if ( ! function_exists('atbdp_is_page') ) { - function atbdp_is_page( $page_type = '' ) { - global $post; - - // Normalize page type by replacing dashes with underscores for consistency. - $page_type = str_replace( '-', '_', $page_type ); - - // Handle singular page types separately. - if ( $page_type === 'single_listing' ) { - return is_singular( 'at_biz_dir' ); - } - - // Map page types to their corresponding options and shortcodes. - $page_map = [ - 'home' => [ - 'option' => 'search_listing', - 'shortcode' => 'directorist_search_listing', - ], - 'search_result' => [ - 'option' => 'search_result_page', - 'shortcode' => 'directorist_search_result', - ], - 'add_listing' => [ - 'option' => 'add_listing_page', - 'shortcode' => 'directorist_add_listing', - ], - 'all_listing' => [ - 'option' => 'all_listing_page', - 'shortcode' => 'directorist_all_listing', - ], - 'dashboard' => [ - 'option' => 'user_dashboard', - 'shortcode' => 'directorist_user_dashboard', - ], - 'author' => [ - 'option' => 'author_profile_page', - 'shortcode' => 'directorist_author_profile', - ], - 'category' => [ - 'option' => 'all_categories_page', - 'shortcode' => 'directorist_all_categories', - ], - 'single_category' => [ - 'option' => 'single_category_page', - 'shortcode' => 'directorist_category', - ], - 'all_locations' => [ - 'option' => 'all_locations_page', - 'shortcode' => 'directorist_all_locations', - ], - 'single_location' => [ - 'option' => 'single_location_page', - 'shortcode' => 'directorist_location', - ], - 'single_tag' => [ - 'option' => 'single_tag_page', - 'shortcode' => 'directorist_tag', - ], - 'signin_signup' => [ - 'option' => 'signin_signup_page', - 'shortcode' => 'directorist_signin_signup', - ], - 'login' => [ - 'option' => 'signin_signup_page', - 'shortcode' => 'directorist_signin_signup', - ], - 'registration' => [ - 'option' => 'signin_signup_page', - 'shortcode' => 'directorist_signin_signup', - ], - ]; - - // Check if the specified page type matches the current page. - if ( isset( $page_map[ $page_type ] ) ) { - $option = $page_map[ $page_type ]['option']; - $page_id = get_directorist_option( $option ); - - if ( is_page( $page_id ) ) { - return true; - } - - $shortcode = $page_map[ $page_type ]['shortcode']; - $has_shortcode = isset( $post->post_content ) && has_shortcode( $post->post_content, $shortcode ); - - if ( $has_shortcode ) { - return true; - } - } - - // Return false if no match is found. - return false; - } +if ( ! function_exists( 'atbdp_is_page' ) ) { + function atbdp_is_page( $page_type = '' ) { + global $post; + + // Normalize page type by replacing dashes with underscores for consistency. + $page_type = str_replace( '-', '_', $page_type ); + + // Handle singular page types separately. + if ( $page_type === 'single_listing' ) { + return is_singular( 'at_biz_dir' ); + } + + // Map page types to their corresponding options and shortcodes. + $page_map = array( + 'home' => array( + 'option' => 'search_listing', + 'shortcode' => 'directorist_search_listing', + ), + 'search_result' => array( + 'option' => 'search_result_page', + 'shortcode' => 'directorist_search_result', + ), + 'add_listing' => array( + 'option' => 'add_listing_page', + 'shortcode' => 'directorist_add_listing', + ), + 'all_listing' => array( + 'option' => 'all_listing_page', + 'shortcode' => 'directorist_all_listing', + ), + 'dashboard' => array( + 'option' => 'user_dashboard', + 'shortcode' => 'directorist_user_dashboard', + ), + 'author' => array( + 'option' => 'author_profile_page', + 'shortcode' => 'directorist_author_profile', + ), + 'category' => array( + 'option' => 'all_categories_page', + 'shortcode' => 'directorist_all_categories', + ), + 'single_category' => array( + 'option' => 'single_category_page', + 'shortcode' => 'directorist_category', + ), + 'all_locations' => array( + 'option' => 'all_locations_page', + 'shortcode' => 'directorist_all_locations', + ), + 'single_location' => array( + 'option' => 'single_location_page', + 'shortcode' => 'directorist_location', + ), + 'single_tag' => array( + 'option' => 'single_tag_page', + 'shortcode' => 'directorist_tag', + ), + 'signin_signup' => array( + 'option' => 'signin_signup_page', + 'shortcode' => 'directorist_signin_signup', + ), + 'login' => array( + 'option' => 'signin_signup_page', + 'shortcode' => 'directorist_signin_signup', + ), + 'registration' => array( + 'option' => 'signin_signup_page', + 'shortcode' => 'directorist_signin_signup', + ), + ); + + // Check if the specified page type matches the current page. + if ( isset( $page_map[ $page_type ] ) ) { + $option = $page_map[ $page_type ]['option']; + $page_id = get_directorist_option( $option ); + + if ( is_page( $page_id ) ) { + return true; + } + + $shortcode = $page_map[ $page_type ]['shortcode']; + $has_shortcode = isset( $post->post_content ) && has_shortcode( $post->post_content, $shortcode ); + + if ( $has_shortcode ) { + return true; + } + } + + // Return false if no match is found. + return false; + } } /** @@ -1982,116 +1989,113 @@ function atbdp_is_page( $page_type = '' ) { * @return integer $pop_listing_id * @since 4.7.8 */ -if (!function_exists('atbdp_popular_listings')) { - function atbdp_popular_listings( $listing_id ) { - $listing_popular_by = get_directorist_option( 'listing_popular_by' ); - $average = directorist_get_listing_rating( $listing_id ); - $average_review_for_popular = (int) get_directorist_option( 'average_review_for_popular', 4 ); - $view_count = (int) get_post_meta( $listing_id, '_atbdp_post_views_count', true ); - $view_to_popular = (int) get_directorist_option( 'views_for_popular' ); - - if ( 'average_rating' === $listing_popular_by && $average_review_for_popular <= $average ) { - return $listing_id; - } elseif ( 'view_count' === $listing_popular_by && $view_count >= $view_to_popular ) { +if ( ! function_exists( 'atbdp_popular_listings' ) ) { + function atbdp_popular_listings( $listing_id ) { + $listing_popular_by = get_directorist_option( 'listing_popular_by' ); + $average = directorist_get_listing_rating( $listing_id ); + $average_review_for_popular = (int) get_directorist_option( 'average_review_for_popular', 4 ); + $view_count = (int) get_post_meta( $listing_id, '_atbdp_post_views_count', true ); + $view_to_popular = (int) get_directorist_option( 'views_for_popular' ); + + if ( 'average_rating' === $listing_popular_by && $average_review_for_popular <= $average ) { + return $listing_id; + } elseif ( 'view_count' === $listing_popular_by && $view_count >= $view_to_popular ) { return $listing_id; - } elseif ( $average_review_for_popular <= $average && $view_count >= $view_to_popular ) { + } elseif ( $average_review_for_popular <= $average && $view_count >= $view_to_popular ) { return $listing_id; - } + } return 0; - } -} - -function atbdp_get_custom_field_ids($category = 0, $all = false) -{ - // Get global fields - $args = array( - 'post_type' => ATBDP_CUSTOM_FIELD_POST_TYPE, - 'post_status' => 'publish', - 'posts_per_page' => -1, - 'fields' => 'ids', - ); - - if( !$all ){ - $args['meta_query'] = array( - array( - 'key' => 'associate', - 'value' => 'form' - ), - ); - } - - // Get category fields - if ( $category > 0 ) { - $args['meta_query'] = array( - 'relation' => 'OR', - array( - 'key' => 'associate', - 'value' => 'form' - ), - - array( - 'relation' => 'AND', - array( - 'key' => 'category_pass', - 'value' => $category, - 'compare' => 'EXISTS', - ), - array( - 'key' => 'associate', - 'value' => 'categories', - 'compare' => 'LIKE', - ), - ), - ); - } - - $field_ids = ATBDP_Cache_Helper::get_the_transient([ - 'group' => 'atbdp_custom_field_query', - 'name' => 'atbdp_custom_field_ids', - 'query_args' => $args, - 'cache' => apply_filters( 'atbdp_cache_custom_field_ids', true ), - 'value' => function( $data ) { - return get_posts( $data['query_args'] ); - } - ]); - - // Return - if (empty($field_ids)) { - $field_ids = array(0); - } - - return $field_ids; - -} - -function get_advance_search_result_page_link() -{ - - $link = home_url(); - - if (get_option('permalink_structure')) { - - $page_settings = get_directorist_option('advance_search_result');; - - if ($page_settings > 0) { - $link = get_permalink($page_settings); - } - - } - - return $link; + } +} + +function atbdp_get_custom_field_ids( $category = 0, $all = false ) { + // Get global fields + $args = array( + 'post_type' => ATBDP_CUSTOM_FIELD_POST_TYPE, + 'post_status' => 'publish', + 'posts_per_page' => -1, + 'fields' => 'ids', + ); + + if ( ! $all ) { + $args['meta_query'] = array( + array( + 'key' => 'associate', + 'value' => 'form', + ), + ); + } + + // Get category fields + if ( $category > 0 ) { + $args['meta_query'] = array( + 'relation' => 'OR', + array( + 'key' => 'associate', + 'value' => 'form', + ), + + array( + 'relation' => 'AND', + array( + 'key' => 'category_pass', + 'value' => $category, + 'compare' => 'EXISTS', + ), + array( + 'key' => 'associate', + 'value' => 'categories', + 'compare' => 'LIKE', + ), + ), + ); + } + + $field_ids = ATBDP_Cache_Helper::get_the_transient( + array( + 'group' => 'atbdp_custom_field_query', + 'name' => 'atbdp_custom_field_ids', + 'query_args' => $args, + 'cache' => apply_filters( 'atbdp_cache_custom_field_ids', true ), + 'value' => function ( $data ) { + return get_posts( $data['query_args'] ); + }, + ) + ); + + // Return + if ( empty( $field_ids ) ) { + $field_ids = array( 0 ); + } + + return $field_ids; +} + +function get_advance_search_result_page_link() { + + $link = home_url(); + + if ( get_option( 'permalink_structure' ) ) { + + $page_settings = get_directorist_option( 'advance_search_result' ); + + if ( $page_settings > 0 ) { + $link = get_permalink( $page_settings ); + } + } + + return $link; } /** * @return Wp_Query * @since 4.7.7 */ -if (!function_exists('atbdp_get_expired_listings')) { - function atbdp_get_expired_listings($texonomy, $categories) - { - return new WP_Query(array()); - } +if ( ! function_exists( 'atbdp_get_expired_listings' ) ) { + function atbdp_get_expired_listings( $texonomy, $categories ) { + return new WP_Query( array() ); + } } /** @@ -2099,21 +2103,18 @@ function atbdp_get_expired_listings($texonomy, $categories) * * @return string Current Page URL. * @since 5.4.0 - * */ -function atbdp_get_current_url() -{ - - $current_url = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") ? "https://" : "http://"; - $current_url .= ! empty( $_SERVER["SERVER_NAME"] ) ? directorist_clean( wp_unslash( $_SERVER["SERVER_NAME"] ) ) : ''; - $server_port = ! empty( $_SERVER["SERVER_PORT"] ) ? directorist_clean( wp_unslash( $_SERVER["SERVER_PORT"] ) ) : ''; - if ($server_port != "80" && $server_port != "443") { - $current_url .= ":" . $server_port; - } - $current_url .= ! empty( $_SERVER["REQUEST_URI"] ) ? directorist_clean( wp_unslash( $_SERVER["REQUEST_URI"] ) ) : ''; +function atbdp_get_current_url() { - return $current_url; + $current_url = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ? 'https://' : 'http://'; + $current_url .= ! empty( $_SERVER['SERVER_NAME'] ) ? directorist_clean( wp_unslash( $_SERVER['SERVER_NAME'] ) ) : ''; + $server_port = ! empty( $_SERVER['SERVER_PORT'] ) ? directorist_clean( wp_unslash( $_SERVER['SERVER_PORT'] ) ) : ''; + if ( $server_port != '80' && $server_port != '443' ) { + $current_url .= ':' . $server_port; + } + $current_url .= ! empty( $_SERVER['REQUEST_URI'] ) ? directorist_clean( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; + return $current_url; } /** @@ -2121,63 +2122,71 @@ function atbdp_get_current_url() * * @return bool $can_use_yoast "true" if can use Yoast, "false" if not. * @since 5.4.4 - * */ -function atbdp_can_use_yoast() -{ +function atbdp_can_use_yoast() { - $can_use_yoast = false; - $active_plugins = apply_filters('active_plugins', get_option('active_plugins', [])); + $can_use_yoast = false; + $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ); - $yoast_free_is_active = ( in_array('wordpress-seo/wp-seo.php', $active_plugins) ) ? true : false; - $yoast_premium_is_active = ( in_array('wordpress-seo-premium/wp-seo-premium.php', $active_plugins) ) ? true : false; + $yoast_free_is_active = ( in_array( 'wordpress-seo/wp-seo.php', $active_plugins ) ) ? true : false; + $yoast_premium_is_active = ( in_array( 'wordpress-seo-premium/wp-seo-premium.php', $active_plugins ) ) ? true : false; - if ( $yoast_free_is_active || $yoast_premium_is_active ) { - $can_use_yoast = true; - } - - return $can_use_yoast; + if ( $yoast_free_is_active || $yoast_premium_is_active ) { + $can_use_yoast = true; + } + return $can_use_yoast; } // atbdp_yoast_is_active function atbdp_yoast_is_active() { - return atbdp_can_use_yoast(); + return atbdp_can_use_yoast(); } /**arg * * @return bool $can_use_yoast "true" if can use Yoast, "false" if not. * @since 5.5.2 - * */ -function atbdp_can_overwrite_yoast() -{ - $overwrite = false; - $overwrite_yoast = get_directorist_option('overwrite_by_yoast'); - if ( ! empty( $overwrite_yoast ) || ! atbdp_yoast_is_active() ) { - $overwrite = true; - } - - return $overwrite; +function atbdp_can_overwrite_yoast() { + $overwrite = false; + $overwrite_yoast = get_directorist_option( 'overwrite_by_yoast' ); + if ( ! empty( $overwrite_yoast ) || ! atbdp_yoast_is_active() ) { + $overwrite = true; + } + return $overwrite; } function atbdp_disable_overwrite_yoast() { - atbdp_can_overwrite_yoast(); -} - - -if (!function_exists('atbdp_page')) { - function atbdp_page() - { - $pages = array( - get_directorist_option('search_listing'), get_directorist_option('search_result_page'), get_directorist_option('add_listing_page'), get_directorist_option('all_listing_page'), get_directorist_option('all_categories_page'), get_directorist_option('single_category_page'), get_directorist_option('all_locations_page'), get_directorist_option('single_location_page'), get_directorist_option('single_tag_page'), get_directorist_option('author_profile_page'), get_directorist_option('user_dashboard'), get_directorist_option('custom_registration'), get_directorist_option('user_login'), get_directorist_option('checkout_page'), get_directorist_option('payment_receipt_page'), get_directorist_option('transaction_failure_page'), - ); - foreach ($pages as $page) { - return $page; - } - } + atbdp_can_overwrite_yoast(); +} + + +if ( ! function_exists( 'atbdp_page' ) ) { + function atbdp_page() { + $pages = array( + get_directorist_option( 'search_listing' ), + get_directorist_option( 'search_result_page' ), + get_directorist_option( 'add_listing_page' ), + get_directorist_option( 'all_listing_page' ), + get_directorist_option( 'all_categories_page' ), + get_directorist_option( 'single_category_page' ), + get_directorist_option( 'all_locations_page' ), + get_directorist_option( 'single_location_page' ), + get_directorist_option( 'single_tag_page' ), + get_directorist_option( 'author_profile_page' ), + get_directorist_option( 'user_dashboard' ), + get_directorist_option( 'custom_registration' ), + get_directorist_option( 'user_login' ), + get_directorist_option( 'checkout_page' ), + get_directorist_option( 'payment_receipt_page' ), + get_directorist_option( 'transaction_failure_page' ), + ); + foreach ( $pages as $page ) { + return $page; + } + } } /** * @param $id @@ -2185,50 +2194,51 @@ function atbdp_page() * @return integer Return the level of the term * @since 5.5.4 */ -function atbdp_get_tax_level($id, $tax) -{ - $ancestors = get_ancestors($id, $tax); - return count($ancestors) + 1; +function atbdp_get_tax_level( $id, $tax ) { + $ancestors = get_ancestors( $id, $tax ); + return count( $ancestors ) + 1; } /** * @param $data * @since 5.6.5 */ -function send_review_for_approval($data) -{ - $listing_id = $data['post_id']; - $review_id = wp_insert_post(array( - 'post_content' => '', - 'post_title' => get_the_title($listing_id), - 'post_status' => 'publish', - 'post_type' => 'atbdp_listing_review', - 'comment_status' => false, - )); - update_post_meta($review_id, '_review_listing', $listing_id); - $listing_reviewer = $data['name']; - update_post_meta($review_id, '_listing_reviewer', $listing_reviewer); - update_post_meta($review_id, '_review_status', 'pending'); - $reviewer_details = $data['content']; - update_post_meta($review_id, '_reviewer_details', $reviewer_details); - $reviewer_rating = $data['rating']; - update_post_meta($review_id, '_reviewer_rating', $reviewer_rating); - - $post_id = $data['post_id']; - update_post_meta($review_id, '_post_id', $post_id); - - $email = $data['email']; - update_post_meta($review_id, '_email', $email); - - $by_guest = $data['by_guest']; - update_post_meta($review_id, '_by_guest', $by_guest); - - $by_user_id = $data['by_user_id']; - update_post_meta($review_id, '_by_user_id', $by_user_id); - //wp_send_json_success(array('id'=>$data)); - /* $message = array('error' => 0); - $message['approve'] = 'plan'; - wp_send_json_success(array('id'=>$message));*/ +function send_review_for_approval( $data ) { + $listing_id = $data['post_id']; + $review_id = wp_insert_post( + array( + 'post_content' => '', + 'post_title' => get_the_title( $listing_id ), + 'post_status' => 'publish', + 'post_type' => 'atbdp_listing_review', + 'comment_status' => false, + ) + ); + update_post_meta( $review_id, '_review_listing', $listing_id ); + $listing_reviewer = $data['name']; + update_post_meta( $review_id, '_listing_reviewer', $listing_reviewer ); + update_post_meta( $review_id, '_review_status', 'pending' ); + $reviewer_details = $data['content']; + update_post_meta( $review_id, '_reviewer_details', $reviewer_details ); + $reviewer_rating = $data['rating']; + update_post_meta( $review_id, '_reviewer_rating', $reviewer_rating ); + + $post_id = $data['post_id']; + update_post_meta( $review_id, '_post_id', $post_id ); + + $email = $data['email']; + update_post_meta( $review_id, '_email', $email ); + + $by_guest = $data['by_guest']; + update_post_meta( $review_id, '_by_guest', $by_guest ); + + $by_user_id = $data['by_user_id']; + update_post_meta( $review_id, '_by_user_id', $by_user_id ); + // wp_send_json_success(array('id'=>$data)); + /* + $message = array('error' => 0); + $message['approve'] = 'plan'; + wp_send_json_success(array('id'=>$message));*/ } /** @@ -2237,202 +2247,199 @@ function send_review_for_approval($data) * @since 5.7.1 * @return bool */ -if (!function_exists('tract_duplicate_review')) { - function tract_duplicate_review($reviewer, $listing) { +if ( ! function_exists( 'tract_duplicate_review' ) ) { + function tract_duplicate_review( $reviewer, $listing ) { _deprecated_function( __FUNCTION__, '7.4.3' ); return false; - } + } } -function search_category_location_filter($settings, $taxonomy_id, $prefix = '') -{ +function search_category_location_filter( $settings, $taxonomy_id, $prefix = '' ) { $lazy_load_taxonomy_fields = get_directorist_option( 'lazy_load_taxonomy_fields', false, true ); if ( ! empty( $lazy_load_taxonomy_fields ) ) { return ''; } - if ($settings['immediate_category']) { - - if ($settings['term_id'] > $settings['parent'] && !in_array($settings['term_id'], $settings['ancestors'])) { - return; - } - - } - if (ATBDP_CATEGORY == $taxonomy_id) { - $category_slug = get_query_var('atbdp_category'); - $category = get_term_by('slug', $category_slug, ATBDP_CATEGORY); - $category_id = !empty($category->term_id) ? $category->term_id : ''; - $term_id = isset($_GET['in_cat']) ? directorist_clean( wp_unslash( $_GET['in_cat'] ) ) : $category_id; - } else { - $location_slug = get_query_var('atbdp_location'); - $location = get_term_by('slug', $location_slug, ATBDP_LOCATION); - $location_id = !empty($location->term_id) ? $location->term_id : ''; - $term_id = isset($_GET['in_loc']) ? directorist_clean( wp_unslash( $_GET['in_loc'] ) ) : $location_id; - } - - $args = array( - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => $settings['term_id'], - 'hierarchical' => ! empty($settings['hide_empty']) ? true : false - ); - - if (ATBDP_CATEGORY == $taxonomy_id){ - $arg = apply_filters('atbdp_search_listing_category_argument', $args); - } else { - $arg = apply_filters('atbdp_search_listing_location_argument', $args); - } - - $terms = get_terms( $taxonomy_id, $arg ); - - $html = ''; - - if (count($terms) > 0) { - - foreach ($terms as $term) { - $directory_type = get_term_meta( $term->term_id, '_directory_type', true ); - $icon = get_cat_icon( $term->term_id ); - $icon_src = \Directorist\Helper::get_icon_src( $icon ); - $directory_type = ! empty( $directory_type ) ? $directory_type : array(); - if( in_array( $settings['listing_type'], $directory_type ) ) { - $settings['term_id'] = $term->term_id; - - $count = 0; - if (!empty($settings['hide_empty']) || !empty($settings['show_count'])) { - $count = atbdp_listings_count_by_category($term->term_id); + if ( $settings['immediate_category'] ) { - if (!empty($settings['hide_empty']) && 0 == $count) continue; - } - $selected = ($term_id == $term->term_id) ? "selected" : ''; - - $has_custom_field = false; + if ( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { + return; + } + } + if ( ATBDP_CATEGORY == $taxonomy_id ) { + $category_slug = get_query_var( 'atbdp_category' ); + $category = get_term_by( 'slug', $category_slug, ATBDP_CATEGORY ); + $category_id = ! empty( $category->term_id ) ? $category->term_id : ''; + $term_id = isset( $_GET['in_cat'] ) ? directorist_clean( wp_unslash( $_GET['in_cat'] ) ) : $category_id; + } else { + $location_slug = get_query_var( 'atbdp_location' ); + $location = get_term_by( 'slug', $location_slug, ATBDP_LOCATION ); + $location_id = ! empty( $location->term_id ) ? $location->term_id : ''; + $term_id = isset( $_GET['in_loc'] ) ? directorist_clean( wp_unslash( $_GET['in_loc'] ) ) : $location_id; + } - if ( ! empty( $settings['categories_with_custom_field'] ) ) { - $has_custom_field = in_array( (int) $term->term_id, $settings['categories_with_custom_field'], true ); - } + $args = array( + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => $settings['term_id'], + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + ); - $html .= '<option data-icon = "' . esc_attr( $icon_src ). '" data-custom-field="' . esc_attr( $has_custom_field ) . '" value="' . $term->term_id . '" ' . $selected . '>'; + if ( ATBDP_CATEGORY == $taxonomy_id ) { + $arg = apply_filters( 'atbdp_search_listing_category_argument', $args ); + } else { + $arg = apply_filters( 'atbdp_search_listing_location_argument', $args ); + } - $html .= $prefix . $term->name; - if (!empty($settings['show_count'])) { - $html .= ' (' . $count . ')'; - } - $html .= search_category_location_filter($settings, $taxonomy_id, $prefix . ' '); - $html .= '</option>'; - } - } + $terms = get_terms( $taxonomy_id, $arg ); - } + $html = ''; - return $html; + if ( count( $terms ) > 0 ) { -} + foreach ( $terms as $term ) { + $directory_type = get_term_meta( $term->term_id, '_directory_type', true ); + $icon = get_cat_icon( $term->term_id ); + $icon_src = \Directorist\Helper::get_icon_src( $icon ); + $directory_type = ! empty( $directory_type ) ? $directory_type : array(); + if ( in_array( $settings['listing_type'], $directory_type ) ) { + $settings['term_id'] = $term->term_id; -function add_listing_category_location_filter( $lisitng_type, $settings, $taxonomy_id, $term_id, $prefix = '', $plan_cat = array()) -{ - if ($settings['immediate_category']) { + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_category( $term->term_id ); - if ($settings['term_id'] > $settings['parent'] && !in_array($settings['term_id'], $settings['ancestors'])) { - return; - } + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } + $selected = ( $term_id == $term->term_id ) ? 'selected' : ''; - } + $has_custom_field = false; - $args = array( - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => $settings['term_id'], - 'exclude' => $plan_cat, - 'hierarchical' => !empty($settings['hide_empty']) ? true : false - ); + if ( ! empty( $settings['categories_with_custom_field'] ) ) { + $has_custom_field = in_array( (int) $term->term_id, $settings['categories_with_custom_field'], true ); + } - $terms = get_terms($taxonomy_id, $args); - $html = ''; + $html .= '<option data-icon = "' . esc_attr( $icon_src ) . '" data-custom-field="' . esc_attr( $has_custom_field ) . '" value="' . $term->term_id . '" ' . $selected . '>'; - if (count($terms) > 0) { + $html .= $prefix . $term->name; + if ( ! empty( $settings['show_count'] ) ) { + $html .= ' (' . $count . ')'; + } + $html .= search_category_location_filter( $settings, $taxonomy_id, $prefix . ' ' ); + $html .= '</option>'; + } + } + } - foreach ($terms as $term) { - $directory_type = get_term_meta( $term->term_id, '_directory_type', true ); - $directory_type = ! empty( $directory_type ) ? $directory_type : array(); - $directory_type = is_array( $directory_type ) ? $directory_type : array( $directory_type ); - if( in_array( $lisitng_type, $directory_type ) ) { - $settings['term_id'] = $term->term_id; + return $html; +} - $count = 0; - if (!empty($settings['hide_empty']) || !empty($settings['show_count'])) { - $count = atbdp_listings_count_by_category($term->term_id); +function add_listing_category_location_filter( $lisitng_type, $settings, $taxonomy_id, $term_id, $prefix = '', $plan_cat = array() ) { + if ( $settings['immediate_category'] ) { - if (!empty($settings['hide_empty']) && 0 == $count) continue; - } - $selected = in_array($term->term_id, $term_id) ? "selected" : ''; - $html .= sprintf('<option value="%s" %s>', $term->term_id, $selected); - $html .= $prefix . $term->name; - if (!empty($settings['show_count'])) { - $html .= ' (' . $count . ')'; - } - $html .= add_listing_category_location_filter($lisitng_type, $settings, $taxonomy_id, $term_id, $prefix . ' '); - $html .= '</option>'; - } - } + if ( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { + return; + } + } - } + $args = array( + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => $settings['term_id'], + 'exclude' => $plan_cat, + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + ); - return $html; + $terms = get_terms( $taxonomy_id, $args ); + $html = ''; + + if ( count( $terms ) > 0 ) { + + foreach ( $terms as $term ) { + $directory_type = get_term_meta( $term->term_id, '_directory_type', true ); + $directory_type = ! empty( $directory_type ) ? $directory_type : array(); + $directory_type = is_array( $directory_type ) ? $directory_type : array( $directory_type ); + if ( in_array( $lisitng_type, $directory_type ) ) { + $settings['term_id'] = $term->term_id; + + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_category( $term->term_id ); + + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } + $selected = in_array( $term->term_id, $term_id ) ? 'selected' : ''; + $html .= sprintf( '<option value="%s" %s>', $term->term_id, $selected ); + $html .= $prefix . $term->name; + if ( ! empty( $settings['show_count'] ) ) { + $html .= ' (' . $count . ')'; + } + $html .= add_listing_category_location_filter( $lisitng_type, $settings, $taxonomy_id, $term_id, $prefix . ' ' ); + $html .= '</option>'; + } + } + } + return $html; } /* * @since 6.3.0 */ -function atbdp_guest_submission($guest_email) -{ - $string = $guest_email; - $explode = explode("@", $string); - array_pop($explode); - $userName = join('@', $explode); - //check if username already exist - if (username_exists($userName)) { - $random = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), 1, 5); - $userName = $userName . $random; - } - // Check if user exist by email - if (email_exists($guest_email)) { - wp_send_json(array( - 'error' => true, - 'quick_login_required' => true, - 'email' => $guest_email, - 'error_msg' => __('Email already registered. Please login first', 'directorist'), - )); - die(); - } else { - // lets register the user - $reg_errors = new WP_Error; - if (empty($reg_errors->get_error_messages())) { - $password = wp_generate_password(12, false); - $userdata = array( - 'user_login' => $userName, - 'user_email' => $guest_email, - 'user_pass' => $password, - ); - $user_id = wp_insert_user($userdata); // return inserted user id or a WP_Error - wp_set_current_user($user_id, $guest_email); - wp_set_auth_cookie($user_id); - do_action('atbdp_user_registration_completed', $user_id); - update_user_meta($user_id, '_atbdp_generated_password', $password); +function atbdp_guest_submission( $guest_email ) { + $string = $guest_email; + $explode = explode( '@', $string ); + array_pop( $explode ); + $userName = join( '@', $explode ); + // check if username already exist + if ( username_exists( $userName ) ) { + $random = substr( str_shuffle( '0123456789abcdefghijklmnopqrstuvwxyz' ), 1, 5 ); + $userName = $userName . $random; + } + // Check if user exist by email + if ( email_exists( $guest_email ) ) { + wp_send_json( + array( + 'error' => true, + 'quick_login_required' => true, + 'email' => $guest_email, + 'error_msg' => __( 'Email already registered. Please login first', 'directorist' ), + ) + ); + die(); + } else { + // lets register the user + $reg_errors = new WP_Error(); + if ( empty( $reg_errors->get_error_messages() ) ) { + $password = wp_generate_password( 12, false ); + $userdata = array( + 'user_login' => $userName, + 'user_email' => $guest_email, + 'user_pass' => $password, + ); + $user_id = wp_insert_user( $userdata ); // return inserted user id or a WP_Error + wp_set_current_user( $user_id, $guest_email ); + wp_set_auth_cookie( $user_id ); + do_action( 'atbdp_user_registration_completed', $user_id ); + update_user_meta( $user_id, '_atbdp_generated_password', $password ); if ( directorist_is_email_verification_enabled() ) { // Set unverified flag. Once verified this flag will be removed. update_user_meta( $user_id, 'directorist_user_email_unverified', 1 ); } - wp_new_user_notification($user_id, null, 'admin'); // send activation to the admin - ATBDP()->email->custom_wp_new_user_notification_email($user_id); - } - } + wp_new_user_notification( $user_id, null, 'admin' ); // send activation to the admin + ATBDP()->email->custom_wp_new_user_notification_email( $user_id ); + } + } } function atbdp_get_listing_attachment_ids( $listing_id ) { @@ -2443,57 +2450,64 @@ function atbdp_get_listing_attachment_ids( $listing_id ) { $attachment_ids[] = (int) $featured_image; } - $gallery_images = directorist_get_listing_gallery_images( $listing_id ); + $gallery_images = directorist_get_listing_gallery_images( $listing_id ); if ( empty( $gallery_images ) ) { return $attachment_ids; } - $attachment_ids = array_merge( $attachment_ids, $gallery_images ); + $attachment_ids = array_merge( $attachment_ids, $gallery_images ); - return $attachment_ids; + return $attachment_ids; } function get_uninstall_settings_submenus() { - return apply_filters('atbdp_uninstall_settings_fields', array( - array( - 'type' => 'toggle', - 'name' => 'enable_uninstall', - 'label' => __('Remove Data on Uninstall?', 'directorist'), - 'description'=> __('Checked it if you would like Directorist to completely remove all of its data when the plugin is deleted.','directorist'), - 'default' => 0, - ), - ) - ); + return apply_filters( + 'atbdp_uninstall_settings_fields', + array( + array( + 'type' => 'toggle', + 'name' => 'enable_uninstall', + 'label' => __( 'Remove Data on Uninstall?', 'directorist' ), + 'description' => __( 'Checked it if you would like Directorist to completely remove all of its data when the plugin is deleted.', 'directorist' ), + 'default' => 0, + ), + ) + ); } function get_csv_import_settings_submenus() { - return apply_filters('atbdp_csv_import_settings_fields', array( - array( - 'type' => 'toggle', - 'name' => 'csv_import', - 'label' => __('CSV', 'directorist'), - ), - ) - ); -} - -function atbdp_email_html($subject, $message){ - $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); - $header = ''; - $email_header_color = get_directorist_option('email_header_color', '#8569fb'); - $allow_email_header = get_directorist_option('allow_email_header', 1); - if ($allow_email_header){ - $header = apply_filters('atbdp_email_header', '<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_header" style=\'background-color: '.$email_header_color.'; color: #ffffff; border-bottom: 0; font-weight: bold; line-height: 100%; vertical-align: middle; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; border-radius: 3px 3px 0 0;\'> + return apply_filters( + 'atbdp_csv_import_settings_fields', + array( + array( + 'type' => 'toggle', + 'name' => 'csv_import', + 'label' => __( 'CSV', 'directorist' ), + ), + ) + ); +} + +function atbdp_email_html( $subject, $message ) { + $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); + $header = ''; + $email_header_color = get_directorist_option( 'email_header_color', '#8569fb' ); + $allow_email_header = get_directorist_option( 'allow_email_header', 1 ); + if ( $allow_email_header ) { + $header = apply_filters( + 'atbdp_email_header', + '<table border="0" cellpadding="0" cellspacing="0" width="600" id="template_header" style=\'background-color: ' . $email_header_color . '; color: #ffffff; border-bottom: 0; font-weight: bold; line-height: 100%; vertical-align: middle; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; border-radius: 3px 3px 0 0;\'> <tr> <td id="header_wrapper" style="padding: 36px 48px; display: block;"> - <h1 style=\'font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; font-size: 30px; font-weight: 300; line-height: 150%; margin: 0; text-align: left; text-shadow: 0 1px 0 #ab79a1; color: #ffffff;\'>'.$subject.'</h1> + <h1 style=\'font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; font-size: 30px; font-weight: 300; line-height: 150%; margin: 0; text-align: left; text-shadow: 0 1px 0 #ab79a1; color: #ffffff;\'>' . $subject . '</h1> </td> </tr> - </table>'); - } + </table>' + ); + } - return '<!DOCTYPE html> + return '<!DOCTYPE html> <html lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> @@ -2510,7 +2524,7 @@ function atbdp_email_html($subject, $message){ <tr> <td align="center" valign="top"> <!-- Header --> - '.$header.' + ' . $header . ' <!-- End Header --> </td> </tr> @@ -2525,7 +2539,7 @@ function atbdp_email_html($subject, $message){ <tr> <td valign="top" style="padding: 48px 48px 32px;"> <div id="body_content_inner" style=\'color: #636363; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; font-size: 14px; line-height: 150%; text-align: left;\'> -'.$message.' +' . $message . ' </div> </td> </tr> @@ -2564,134 +2578,144 @@ function atbdp_email_html($subject, $message){ </html>'; } -function atbdp_create_required_pages(){ - $options = get_option('atbdp_option'); // we are retrieving all of our custom options because it contains all the page options too. and we can filter this array instead of calling get_directorist_option() over and over. - /* - Remember: We can not add new option to atbdp_option if there is no key matched. Because VafPress will override it. - Use normal update_option() instead if you need to add custom option that is not available in the settings fields of VP Framework. - */ - - $directorist_pages = apply_filters('atbdp_create_custom_pages', array( - 'search_listing' => array( - 'title' => __('Search Home', 'directorist'), - 'content' => '[directorist_search_listing]' - ), - 'search_result_page' => array( - 'title' => __('Search Result', 'directorist'), - 'content' => '[directorist_search_result]' - ), - 'add_listing_page' => array( - 'title' => __('Add Listing', 'directorist'), - 'content' => '[directorist_add_listing]' - ), - 'all_listing_page' => array( - 'title' => __('All Listings', 'directorist'), - 'content' => '[directorist_all_listing]' - ), - /* 'all_categories_page' => array( - 'title' => __('All Categories', 'directorist'), - 'content' => '[directorist_all_categories]' - ), */ - 'single_category_page' => array( - 'title' => __('Single Category', 'directorist'), - 'content' => '[directorist_category]' - ), - /* 'all_locations_page' => array( - 'title' => __('All Locations', 'directorist'), - 'content' => '[directorist_all_locations]' - ), */ - 'single_location_page' => array( - 'title' => __('Single Location', 'directorist'), - 'content' => '[directorist_location]' - ), - 'single_tag_page' => array( - 'title' => __('Single Tag', 'directorist'), - 'content' => '[directorist_tag]' - ), - 'author_profile_page' => array( - 'title' => __('Author Profile', 'directorist'), - 'content' => '[directorist_author_profile]' - ), - 'user_dashboard' => array( - 'title' => __('Dashboard', 'directorist'), - 'content' => '[directorist_user_dashboard]' - ), - 'signin_signup_page' => array( - 'title' => __('Sign In', 'directorist'), - 'content' => '[directorist_signin_signup]' - ), - /* 'checkout_page' => array( - 'title' => __('Checkout', 'directorist'), - 'content' => '[directorist_checkout]' - ), - 'payment_receipt_page' => array( - 'title' => __('Payment Receipt', 'directorist'), - 'content' => '[directorist_payment_receipt]' - ), - 'transaction_failure_page' => array( - 'title' => __('Transaction Failure', 'directorist'), - 'content' => '[directorist_transaction_failure]' - ), */ - )); - $new_settings = 0; // lets keep track of new settings so that we do not update option unnecessarily. - // lets iterate over the array and insert a new page with with the appropriate shortcode if the page id is not available in the option array. - foreach ($directorist_pages as $op_name => $page_settings) { - // $op_name is the page option name in the database. - // if we do not have the page id assigned in the settings with the given page option name, then create an page - // and update the option. - - if (empty($options[$op_name]) || !get_post($options[$op_name])) { - - $id = wp_insert_post( - array( - 'post_title' => $page_settings['title'], - 'post_content' => $page_settings['content'], - 'post_status' => 'publish', - 'post_type' => 'page', - 'comment_status' => 'closed' - ) - ); - // if we have added the page successfully, lets add the page id to the options array to save the page settings in the database after the loop. - if ($id) { - $options[$op_name] = (int)$id; - - /*TRYING TO SET THE DEFAULT PAGE TEMPLATE FOR THIS PAGE WHERE OUR SHORTCODE IS USED */ - // get the template list of the theme and if it has any full width template then assign it. - $page_templates = wp_get_theme()->get_page_templates(); - $custom_template = ''; // place holder for full width template - $temp_type = ('search_listing' == $op_name) ? 'home-page.php' : 'full'; // look for home template for search_listing page - // lets see if we can find any full width template, then use it for the page where our shortcode is used. - foreach ($page_templates as $slug => $name) { - // checkout page and payment receipt page looks better on non full-width template, so skip them. - if (in_array($op_name, array('checkout_page', 'payment_receipt_page'))) break; - if (strpos($slug, $temp_type)) { - $custom_template = $slug; - break; - } - } - if (!empty($custom_template)) update_post_meta($id, '_wp_page_template', sanitize_text_field($custom_template)); - - - } - $new_settings++; - } else { - $replace_shortcode = wp_update_post( - array( - 'ID' => $options[$op_name], - 'post_title' => $page_settings['title'], - 'post_content' => $page_settings['content'], - 'post_status' => 'publish', - 'post_type' => 'page', - 'comment_status' => 'closed' - ), true - ); - } - // if we have new options then lets update the options with new option values. - if ($new_settings) { - update_option('atbdp_option', $options); - }; - update_option('atbdp_pages_version', 1); - } +function atbdp_create_required_pages() { + $options = get_option( 'atbdp_option' ); // we are retrieving all of our custom options because it contains all the page options too. and we can filter this array instead of calling get_directorist_option() over and over. + /* + Remember: We can not add new option to atbdp_option if there is no key matched. Because VafPress will override it. + Use normal update_option() instead if you need to add custom option that is not available in the settings fields of VP Framework. + */ + + $directorist_pages = apply_filters( + 'atbdp_create_custom_pages', + array( + 'search_listing' => array( + 'title' => __( 'Search Home', 'directorist' ), + 'content' => '[directorist_search_listing]', + ), + 'search_result_page' => array( + 'title' => __( 'Search Result', 'directorist' ), + 'content' => '[directorist_search_result]', + ), + 'add_listing_page' => array( + 'title' => __( 'Add Listing', 'directorist' ), + 'content' => '[directorist_add_listing]', + ), + 'all_listing_page' => array( + 'title' => __( 'All Listings', 'directorist' ), + 'content' => '[directorist_all_listing]', + ), + /* + 'all_categories_page' => array( + 'title' => __('All Categories', 'directorist'), + 'content' => '[directorist_all_categories]' + ), */ + 'single_category_page' => array( + 'title' => __( 'Single Category', 'directorist' ), + 'content' => '[directorist_category]', + ), + /* + 'all_locations_page' => array( + 'title' => __('All Locations', 'directorist'), + 'content' => '[directorist_all_locations]' + ), */ + 'single_location_page' => array( + 'title' => __( 'Single Location', 'directorist' ), + 'content' => '[directorist_location]', + ), + 'single_tag_page' => array( + 'title' => __( 'Single Tag', 'directorist' ), + 'content' => '[directorist_tag]', + ), + 'author_profile_page' => array( + 'title' => __( 'Author Profile', 'directorist' ), + 'content' => '[directorist_author_profile]', + ), + 'user_dashboard' => array( + 'title' => __( 'Dashboard', 'directorist' ), + 'content' => '[directorist_user_dashboard]', + ), + 'signin_signup_page' => array( + 'title' => __( 'Sign In', 'directorist' ), + 'content' => '[directorist_signin_signup]', + ), + /* + 'checkout_page' => array( + 'title' => __('Checkout', 'directorist'), + 'content' => '[directorist_checkout]' + ), + 'payment_receipt_page' => array( + 'title' => __('Payment Receipt', 'directorist'), + 'content' => '[directorist_payment_receipt]' + ), + 'transaction_failure_page' => array( + 'title' => __('Transaction Failure', 'directorist'), + 'content' => '[directorist_transaction_failure]' + ), */ + ) + ); + $new_settings = 0; // lets keep track of new settings so that we do not update option unnecessarily. + // lets iterate over the array and insert a new page with with the appropriate shortcode if the page id is not available in the option array. + foreach ( $directorist_pages as $op_name => $page_settings ) { + // $op_name is the page option name in the database. + // if we do not have the page id assigned in the settings with the given page option name, then create an page + // and update the option. + + if ( empty( $options[ $op_name ] ) || ! get_post( $options[ $op_name ] ) ) { + + $id = wp_insert_post( + array( + 'post_title' => $page_settings['title'], + 'post_content' => $page_settings['content'], + 'post_status' => 'publish', + 'post_type' => 'page', + 'comment_status' => 'closed', + ) + ); + // if we have added the page successfully, lets add the page id to the options array to save the page settings in the database after the loop. + if ( $id ) { + $options[ $op_name ] = (int) $id; + + /* + TRYING TO SET THE DEFAULT PAGE TEMPLATE FOR THIS PAGE WHERE OUR SHORTCODE IS USED */ + // get the template list of the theme and if it has any full width template then assign it. + $page_templates = wp_get_theme()->get_page_templates(); + $custom_template = ''; // place holder for full width template + $temp_type = ( 'search_listing' == $op_name ) ? 'home-page.php' : 'full'; // look for home template for search_listing page + // lets see if we can find any full width template, then use it for the page where our shortcode is used. + foreach ( $page_templates as $slug => $name ) { + // checkout page and payment receipt page looks better on non full-width template, so skip them. + if ( in_array( $op_name, array( 'checkout_page', 'payment_receipt_page' ) ) ) { + break; + } + if ( strpos( $slug, $temp_type ) ) { + $custom_template = $slug; + break; + } + } + if ( ! empty( $custom_template ) ) { + update_post_meta( $id, '_wp_page_template', sanitize_text_field( $custom_template ) ); + } + } + ++$new_settings; + } else { + $replace_shortcode = wp_update_post( + array( + 'ID' => $options[ $op_name ], + 'post_title' => $page_settings['title'], + 'post_content' => $page_settings['content'], + 'post_status' => 'publish', + 'post_type' => 'page', + 'comment_status' => 'closed', + ), + true + ); + } + // if we have new options then lets update the options with new option values. + if ( $new_settings ) { + update_option( 'atbdp_option', $options ); + } + update_option( 'atbdp_pages_version', 1 ); + } } /** @@ -2701,263 +2725,267 @@ function atbdp_create_required_pages(){ * * @return bool */ -function atbdp_logged_in_user(){ - return is_user_logged_in(); -} - -function atbdp_thumbnail_card($img_src = '', $_args = array()) -{ - $args = apply_filters('atbdp_preview_image_args', $_args); - - // Default - $is_blur = get_directorist_option('prv_background_type', 'blur'); // blur | color - $is_blur = ('blur' === $is_blur ? true : false); - $container_size_by = get_directorist_option('prv_container_size_by', 'px'); - $by_ratio = ( 'px' === $container_size_by ) ? false : true; - $image_size = get_directorist_option('way_to_show_preview', 'cover'); // contain | full | cover - $ratio_width = get_directorist_option('crop_width', 360); - $ratio_height = get_directorist_option('crop_height', 300); - $blur_background = $is_blur; - $background_color = get_directorist_option('prv_background_color', '#fff'); - $image_quality = get_directorist_option('preview_image_quality', 'directorist_preview'); // medium | large | full - - $thumbnail_img = ''; - - $listing_prv_img = directorist_get_listing_preview_image( get_the_ID() ); - $listing_img = directorist_get_listing_gallery_images( get_the_ID() ); - $default_image_src = get_directorist_option('default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg'); - - if ( is_array( $listing_img ) && ! empty( $listing_img ) ) { - $thumbnail_img = atbdp_get_image_source( $listing_img[0], $image_quality ); - $thumbnail_id = $listing_img[0]; - } - - if ( ! empty( $listing_prv_img ) ) { - $thumbnail_img = atbdp_get_image_source( $listing_prv_img, $image_quality ); - $thumbnail_id = $listing_prv_img; - } - - if ( ! empty( $img_src ) ) { - $thumbnail_img = $img_src; - $thumbnail_id = 0; - } - - if ( empty( $thumbnail_img ) ) { - $thumbnail_img = $default_image_src; - $thumbnail_id = 0; - } - - /* if ( 'cover' === $image_size && false === $by_ratio ) { - $thumbnail_img = atbdp_image_cropping($thumbnail_id, $ratio_width, $ratio_height, true, 100)['url']; - } */ - - if ( empty( $thumbnail_img ) ) { return ''; } - - $image_src = is_array($thumbnail_img) ? $thumbnail_img[0] : $thumbnail_img; - $image_alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true); - $image_alt = ( ! empty( $image_alt ) ) ? esc_attr( $image_alt ) : esc_html( get_the_title( $thumbnail_id ) ); - $image_alt = ( ! empty( $image_alt ) ) ? $image_alt : esc_html( get_the_title() ); - - // Extend Default - if ( isset($args['image']) ) { - $image_src = esc_html(stripslashes($args['image'])); - } - if ( isset($args['image-size']) ) { - $image_size = esc_html(stripslashes($args['image-size'])); - } - if ( isset($args['width']) ) { - $ratio_width = esc_html(stripslashes($args['width'])); - } - if ( isset($args['height']) ) { - $ratio_height = esc_html(stripslashes($args['height'])); - } - if ( isset($args['alt']) ) { - $image_alt = esc_html(stripslashes($args['alt'])); - } - if ( isset($args['blur-background']) ) { - $blur_background = esc_html(stripslashes($args['blur-background'])); - } - if ( isset($args['background-color']) ) { - $background_color = esc_html(stripslashes($args['background-color'])); - } - - // Style - $style = ''; - - if ( $by_ratio ) { - $padding_top_value = (int) $ratio_height / (int) $ratio_width * 100; - $padding_top_css = "padding-top: $padding_top_value%;"; - $style .= $padding_top_css; - } else { - $height_value = (int) $ratio_height; - $height_css = "height: {$height_value}px;"; - $style .= $height_css; - } - - $background_color_css = ''; - if ( $image_size !== 'full' && !$blur_background ) { - $background_color_css = "background-color: $background_color"; - $style .= $background_color_css; - } - - - // Card Front Wrap - $card_front_wrap = "<div class='atbd-thumbnail-card-front-wrap'>"; - $card_front__img = "<img src='$image_src' alt='$image_alt' class='atbd-thumbnail-card-front-img'/>"; - $front_wrap_html = $card_front_wrap . $card_front__img . "</div>"; - - // Card Back Wrap - $card_back_wrap = "<div class='atbd-thumbnail-card-back-wrap'>"; - $card_back__img = "<img src='$image_src' class='atbd-thumbnail-card-back-img'/>"; - $back_wrap_html = $card_back_wrap . $card_back__img . "</div>"; - - $blur_bg = ( $blur_background ) ? $back_wrap_html : ''; - - // Card Contain - $card_contain_wrap = "<div class='atbd-thumbnail-card card-contain' style='$style'>"; - $image_contain_html = $card_contain_wrap . $blur_bg . $front_wrap_html . "</div>"; - - // Card Cover - $card_cover_wrap = "<div class='atbd-thumbnail-card card-cover' style='$style'>"; - $image_cover_html = $card_cover_wrap . $front_wrap_html . "</div>"; - - // Card Full - $card_full_wrap = "<div class='atbd-thumbnail-card card-full' style='$background_color_css'>"; - $image_full_html = $card_full_wrap . $front_wrap_html . "</div>"; - - $the_html = $image_cover_html; - switch ($image_size) { - case 'cover': - $the_html = $image_cover_html; - break; - case 'contain': - $the_html = $image_contain_html; - break; - case 'full': - $the_html = $image_full_html; - break; - } - - echo wp_kses_post( $the_html ); -} - -function atbdp_style_example_image ($src) { - $img = sprintf("<img src='%s'>", $src ); - echo wp_kses_post( $img ); -} - -if(!function_exists('csv_get_data')){ - function csv_get_data( $csv_file = null, $multiple = null, $delimiter = ',' ) { +function atbdp_logged_in_user() { + return is_user_logged_in(); +} + +function atbdp_thumbnail_card( $img_src = '', $_args = array() ) { + $args = apply_filters( 'atbdp_preview_image_args', $_args ); + + // Default + $is_blur = get_directorist_option( 'prv_background_type', 'blur' ); // blur | color + $is_blur = ( 'blur' === $is_blur ? true : false ); + $container_size_by = get_directorist_option( 'prv_container_size_by', 'px' ); + $by_ratio = ( 'px' === $container_size_by ) ? false : true; + $image_size = get_directorist_option( 'way_to_show_preview', 'cover' ); // contain | full | cover + $ratio_width = get_directorist_option( 'crop_width', 360 ); + $ratio_height = get_directorist_option( 'crop_height', 300 ); + $blur_background = $is_blur; + $background_color = get_directorist_option( 'prv_background_color', '#fff' ); + $image_quality = get_directorist_option( 'preview_image_quality', 'directorist_preview' ); // medium | large | full + + $thumbnail_img = ''; + + $listing_prv_img = directorist_get_listing_preview_image( get_the_ID() ); + $listing_img = directorist_get_listing_gallery_images( get_the_ID() ); + $default_image_src = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); + + if ( is_array( $listing_img ) && ! empty( $listing_img ) ) { + $thumbnail_img = atbdp_get_image_source( $listing_img[0], $image_quality ); + $thumbnail_id = $listing_img[0]; + } + + if ( ! empty( $listing_prv_img ) ) { + $thumbnail_img = atbdp_get_image_source( $listing_prv_img, $image_quality ); + $thumbnail_id = $listing_prv_img; + } + + if ( ! empty( $img_src ) ) { + $thumbnail_img = $img_src; + $thumbnail_id = 0; + } + + if ( empty( $thumbnail_img ) ) { + $thumbnail_img = $default_image_src; + $thumbnail_id = 0; + } + + /* + if ( 'cover' === $image_size && false === $by_ratio ) { + $thumbnail_img = atbdp_image_cropping($thumbnail_id, $ratio_width, $ratio_height, true, 100)['url']; + } */ + + if ( empty( $thumbnail_img ) ) { + return ''; } + + $image_src = is_array( $thumbnail_img ) ? $thumbnail_img[0] : $thumbnail_img; + $image_alt = get_post_meta( $thumbnail_id, '_wp_attachment_image_alt', true ); + $image_alt = ( ! empty( $image_alt ) ) ? esc_attr( $image_alt ) : esc_html( get_the_title( $thumbnail_id ) ); + $image_alt = ( ! empty( $image_alt ) ) ? $image_alt : esc_html( get_the_title() ); + + // Extend Default + if ( isset( $args['image'] ) ) { + $image_src = esc_html( stripslashes( $args['image'] ) ); + } + if ( isset( $args['image-size'] ) ) { + $image_size = esc_html( stripslashes( $args['image-size'] ) ); + } + if ( isset( $args['width'] ) ) { + $ratio_width = esc_html( stripslashes( $args['width'] ) ); + } + if ( isset( $args['height'] ) ) { + $ratio_height = esc_html( stripslashes( $args['height'] ) ); + } + if ( isset( $args['alt'] ) ) { + $image_alt = esc_html( stripslashes( $args['alt'] ) ); + } + if ( isset( $args['blur-background'] ) ) { + $blur_background = esc_html( stripslashes( $args['blur-background'] ) ); + } + if ( isset( $args['background-color'] ) ) { + $background_color = esc_html( stripslashes( $args['background-color'] ) ); + } + + // Style + $style = ''; + + if ( $by_ratio ) { + $padding_top_value = (int) $ratio_height / (int) $ratio_width * 100; + $padding_top_css = "padding-top: $padding_top_value%;"; + $style .= $padding_top_css; + } else { + $height_value = (int) $ratio_height; + $height_css = "height: {$height_value}px;"; + $style .= $height_css; + } + + $background_color_css = ''; + if ( $image_size !== 'full' && ! $blur_background ) { + $background_color_css = "background-color: $background_color"; + $style .= $background_color_css; + } + + // Card Front Wrap + $card_front_wrap = "<div class='atbd-thumbnail-card-front-wrap'>"; + $card_front__img = "<img src='$image_src' alt='$image_alt' class='atbd-thumbnail-card-front-img'/>"; + $front_wrap_html = $card_front_wrap . $card_front__img . '</div>'; + + // Card Back Wrap + $card_back_wrap = "<div class='atbd-thumbnail-card-back-wrap'>"; + $card_back__img = "<img src='$image_src' class='atbd-thumbnail-card-back-img'/>"; + $back_wrap_html = $card_back_wrap . $card_back__img . '</div>'; + + $blur_bg = ( $blur_background ) ? $back_wrap_html : ''; + + // Card Contain + $card_contain_wrap = "<div class='atbd-thumbnail-card card-contain' style='$style'>"; + $image_contain_html = $card_contain_wrap . $blur_bg . $front_wrap_html . '</div>'; + + // Card Cover + $card_cover_wrap = "<div class='atbd-thumbnail-card card-cover' style='$style'>"; + $image_cover_html = $card_cover_wrap . $front_wrap_html . '</div>'; + + // Card Full + $card_full_wrap = "<div class='atbd-thumbnail-card card-full' style='$background_color_css'>"; + $image_full_html = $card_full_wrap . $front_wrap_html . '</div>'; + + $the_html = $image_cover_html; + switch ( $image_size ) { + case 'cover': + $the_html = $image_cover_html; + break; + case 'contain': + $the_html = $image_contain_html; + break; + case 'full': + $the_html = $image_full_html; + break; + } + + echo wp_kses_post( $the_html ); +} + +function atbdp_style_example_image( $src ) { + $img = sprintf( "<img src='%s'>", $src ); + echo wp_kses_post( $img ); +} + +if ( ! function_exists( 'csv_get_data' ) ) { + function csv_get_data( $csv_file = null, $multiple = null, $delimiter = ',' ) { if ( empty( $delimiter ) ) { $delimiter = ','; } - $data = $multiple ? array() : ''; - $errors = array(); + $data = $multiple ? array() : ''; + $errors = array(); - if ( ! $csv_file ) { + if ( ! $csv_file ) { return $data; } - // Attempt to change permissions if not readable - if ( ! is_readable( $csv_file ) ) { - chmod( $csv_file, 0744 ); - } + // Attempt to change permissions if not readable + if ( ! is_readable( $csv_file ) ) { + chmod( $csv_file, 0744 ); + } - // Check if file is writable, then open it in 'read only' mode - if ( is_readable( $csv_file ) && $_file = fopen( $csv_file, 'r' ) ) { + // Check if file is writable, then open it in 'read only' mode + if ( is_readable( $csv_file ) && $_file = fopen( $csv_file, 'r' ) ) { - // To sum this part up, all it really does is go row by - // row, column by column, saving all the data - $post = array(); + // To sum this part up, all it really does is go row by + // row, column by column, saving all the data + $post = array(); - // Get first row in CSV, which is of course the headers - $header = fgetcsv( $_file, 0, $delimiter ); + // Get first row in CSV, which is of course the headers + $header = fgetcsv( $_file, 0, $delimiter ); - while ( $row = fgetcsv( $_file, 0, $delimiter ) ) { + while ( $row = fgetcsv( $_file, 0, $delimiter ) ) { - foreach ( $header as $i => $key ) { - $post[ $key ] = $row[ $i ]; - } + foreach ( $header as $i => $key ) { + $post[ $key ] = $row[ $i ]; + } - if ( $multiple ) { - $data[] = $post; - } else { - $data = $post; - } - } + if ( $multiple ) { + $data[] = $post; + } else { + $data = $post; + } + } - fclose( $_file ); - } else { - $errors[] = sprintf( + fclose( $_file ); + } else { + $errors[] = sprintf( esc_html__( "File '%s' could not be opened. Check the file's permissions to make sure it's readable by your server.", 'directorist' ), $csv_file ); - } + } - if ( ! empty( $errors ) ) { - // ... do stuff with the errors - } + if ( ! empty( $errors ) ) { + // ... do stuff with the errors + } - return $data; - } + return $data; + } } // Polyfill - backword comapbility of php7 function -if (!function_exists('array_key_first')) { - function array_key_first(array $arr) { - foreach($arr as $key => $unused) { - return $key; - } - return NULL; - } +if ( ! function_exists( 'array_key_first' ) ) { + function array_key_first( array $arr ) { + foreach ( $arr as $key => $unused ) { + return $key; + } + return null; + } } function directorist_redirect_to_admin_setup_wizard() { - // Delete the redirect transient - delete_transient( '_directorist_setup_page_redirect' ); + // Delete the redirect transient + delete_transient( '_directorist_setup_page_redirect' ); - wp_safe_redirect( add_query_arg( array( 'page' => 'directorist-setup' ), admin_url( 'index.php' ) ) ); - exit; + wp_safe_redirect( add_query_arg( array( 'page' => 'directorist-setup' ), admin_url( 'index.php' ) ) ); + exit; } -function directorist_default_directory(){ +function directorist_default_directory() { return directorist_get_default_directory(); } // @kowsar - remove later @for dev use only -function dvar_dump($data){ - return ''; - echo "<pre>"; - var_dump($data); - echo "</pre>"; -} - -if( ! function_exists( 'atbdp_field_assigned_plan' ) ) { - function atbdp_field_assigned_plan( $field_data, $selected_plan = NULL ) { - if( ! $field_data ) return false; - - $quired_plan = ! empty( $_GET['plan'] ) ? sanitize_key( $_GET['plan'] ) : ''; - $selected_plan = ! empty( $selected_plan ) ? $selected_plan : $quired_plan; - $plans = !empty( $field_data['plans'] ) ? $field_data['plans'] : []; - - if( $plans ) { - foreach ( $plans as $plan ) { - if( $plan['plan_id'] == $selected_plan ) { - return $plan; - } - } - } - } -} -if( !function_exists('directory_types') ){ - function directory_types() { - return directorist_get_directories( array( - 'orderby' => 'date', - 'order' => 'DESC', - ) ); - } +function dvar_dump( $data ) { + return ''; + echo '<pre>'; + var_dump( $data ); + echo '</pre>'; +} + +if ( ! function_exists( 'atbdp_field_assigned_plan' ) ) { + function atbdp_field_assigned_plan( $field_data, $selected_plan = null ) { + if ( ! $field_data ) { + return false; + } + + $quired_plan = ! empty( $_GET['plan'] ) ? sanitize_key( $_GET['plan'] ) : ''; + $selected_plan = ! empty( $selected_plan ) ? $selected_plan : $quired_plan; + $plans = ! empty( $field_data['plans'] ) ? $field_data['plans'] : array(); + + if ( $plans ) { + foreach ( $plans as $plan ) { + if ( $plan['plan_id'] == $selected_plan ) { + return $plan; + } + } + } + } +} +if ( ! function_exists( 'directory_types' ) ) { + function directory_types() { + return directorist_get_directories( + array( + 'orderby' => 'date', + 'order' => 'DESC', + ) + ); + } } if ( ! function_exists( 'directorist_get_default_directory' ) ) { @@ -2975,10 +3003,12 @@ function directorist_get_default_directory( $return = 'id' ) { $fields = 'ids'; } - $directories = directorist_get_directories( array( - 'default_only' => true, - 'fields' => $fields, - ) ); + $directories = directorist_get_directories( + array( + 'default_only' => true, + 'fields' => $fields, + ) + ); if ( empty( $directories ) || is_wp_error( $directories ) || ! isset( $directories[0] ) ) { return 0; @@ -3001,170 +3031,170 @@ function default_directory_type() { } } -if( !function_exists('get_listing_types') ){ - function get_listing_types() { - return directorist_get_directories_for_template(); - } -} - -if( !function_exists('directorist_get_form_fields_by_directory_type') ){ - function directorist_get_form_fields_by_directory_type( $field = 'id', $value = '' ) { - $term = get_term_by( $field, $value, ATBDP_TYPE ); - if( is_wp_error( $term ) || empty( $term ) || is_array( $term ) ) { - return []; - } - if( ! isset( $term->term_id ) ) { - return []; - } - - if ( ! ( $term instanceof \WP_Term ) ) { - return []; - } - - $submission_form = get_term_meta( $term->term_id, 'submission_form_fields', true ); - $submission_form_fields = ! empty( $submission_form['fields'] ) ? $submission_form['fields'] : []; - return $submission_form_fields; - } -} - -if( !function_exists('directorist_legacy_mode') ){ - function directorist_legacy_mode() { - return false; - } -} - -if( !function_exists('directorist_multi_directory') ){ - function directorist_multi_directory() { - return directorist_is_multi_directory_enabled(); - } -} - -if( ! function_exists( 'directorist_warnings' ) ) { - function directorist_warnings() { - $add_listing = get_directorist_option( 'add_listing_page' ); - $user_dashboard = get_directorist_option( 'user_dashboard' ); - $user_profile = get_directorist_option( 'author_profile_page' ); - $single_category_page = get_directorist_option( 'single_category_page' ); - $single_location_page = get_directorist_option( 'single_location_page' ); - $single_tag_page = get_directorist_option( 'single_tag_page' ); - $signin_signup_page = get_directorist_option( 'signin_signup_page' ); - $search_result_page = get_directorist_option( 'search_result_page' ); - $checkout_page = get_directorist_option( 'checkout_page' ); - $payment_receipt_page = get_directorist_option( 'payment_receipt_page' ); - $transaction_failure_page = get_directorist_option( 'transaction_failure_page' ); - $enable_monetization = directorist_is_monetization_enabled(); - $enable_featured_listing = directorist_is_featured_listing_enabled(); - $select_listing_map = get_directorist_option( 'select_listing_map' ); - $map_api_key = get_directorist_option( 'map_api_key' ); - $host = gethostname(); - $connection = @fsockopen( $host, 25, $errno, $errstr, 5 ); - $page_settings_link = esc_url( admin_url() . "/edit.php?post_type=at_biz_dir&page=atbdp-settings#page_settings" ); - $warnings = []; - if( empty( $add_listing ) ) { - $warnings[] = array( - 'title' => __( 'Add listing page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $user_dashboard ) ) { - $warnings[] = array( - 'title' => __( 'Dashboard page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $user_profile ) ) { - $warnings[] = array( - 'title' => __( 'User Profile page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $single_category_page ) ) { - $warnings[] = array( - 'title' => __( 'Single Category page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $single_location_page ) ) { - $warnings[] = array( - 'title' => __( 'Single Location page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $single_tag_page ) ) { - $warnings[] = array( - 'title' => __( 'Single Location page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $signin_signup_page ) ) { - $warnings[] = array( - 'title' => __( 'Sign In & Signup page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $search_result_page ) ) { - $warnings[] = array( - 'title' => __( 'Search Result page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $checkout_page ) && ! empty( $enable_monetization ) && ! empty( $enable_featured_listing ) ) { - $warnings[] = array( - 'title' => __( 'Checkout page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $payment_receipt_page ) && ! empty( $enable_monetization ) && ! empty( $enable_featured_listing ) ) { - $warnings[] = array( - 'title' => __( 'Payment Receipt page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( empty( $transaction_failure_page ) && ! empty( $enable_monetization ) && ! empty( $enable_featured_listing ) ) { - $warnings[] = array( - 'title' => __( 'Transaction Failure page not selected', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => $page_settings_link, - 'link_text' => __( 'Select Page', 'directorist' ) - ); - } - if( 'google' == $select_listing_map && empty( $map_api_key ) ) { - $warnings[] = array( - 'title' => __( 'Map Api Key is missing', 'directorist'), - 'desc' => __( "Contains a collection of relevant data that will help you debug your website accurately and more efficiently.", 'directorist'), - 'link' => esc_url( admin_url() . "/edit.php?post_type=at_biz_dir&page=atbdp-settings#listing_settings__map" ), - 'link_text' => __( 'Give the Api', 'directorist' ) - ); - } - if( ! is_resource( $connection ) ) { - $warnings[] = array( - 'title' => __( 'SMTP not configured', 'directorist'), - 'desc' => __( "SMTP is a TCP/IP protocol responsible for email deliveries. You must configure SMTP to send or receive emails.", 'directorist'), - ); - } - - return apply_filters( 'directorist_warnings', $warnings ); - } +if ( ! function_exists( 'get_listing_types' ) ) { + function get_listing_types() { + return directorist_get_directories_for_template(); + } +} + +if ( ! function_exists( 'directorist_get_form_fields_by_directory_type' ) ) { + function directorist_get_form_fields_by_directory_type( $field = 'id', $value = '' ) { + $term = get_term_by( $field, $value, ATBDP_TYPE ); + if ( is_wp_error( $term ) || empty( $term ) || is_array( $term ) ) { + return array(); + } + if ( ! isset( $term->term_id ) ) { + return array(); + } + + if ( ! ( $term instanceof \WP_Term ) ) { + return array(); + } + + $submission_form = get_term_meta( $term->term_id, 'submission_form_fields', true ); + $submission_form_fields = ! empty( $submission_form['fields'] ) ? $submission_form['fields'] : array(); + return $submission_form_fields; + } +} + +if ( ! function_exists( 'directorist_legacy_mode' ) ) { + function directorist_legacy_mode() { + return false; + } +} + +if ( ! function_exists( 'directorist_multi_directory' ) ) { + function directorist_multi_directory() { + return directorist_is_multi_directory_enabled(); + } +} + +if ( ! function_exists( 'directorist_warnings' ) ) { + function directorist_warnings() { + $add_listing = get_directorist_option( 'add_listing_page' ); + $user_dashboard = get_directorist_option( 'user_dashboard' ); + $user_profile = get_directorist_option( 'author_profile_page' ); + $single_category_page = get_directorist_option( 'single_category_page' ); + $single_location_page = get_directorist_option( 'single_location_page' ); + $single_tag_page = get_directorist_option( 'single_tag_page' ); + $signin_signup_page = get_directorist_option( 'signin_signup_page' ); + $search_result_page = get_directorist_option( 'search_result_page' ); + $checkout_page = get_directorist_option( 'checkout_page' ); + $payment_receipt_page = get_directorist_option( 'payment_receipt_page' ); + $transaction_failure_page = get_directorist_option( 'transaction_failure_page' ); + $enable_monetization = directorist_is_monetization_enabled(); + $enable_featured_listing = directorist_is_featured_listing_enabled(); + $select_listing_map = get_directorist_option( 'select_listing_map' ); + $map_api_key = get_directorist_option( 'map_api_key' ); + $host = gethostname(); + $connection = @fsockopen( $host, 25, $errno, $errstr, 5 ); + $page_settings_link = esc_url( admin_url() . '/edit.php?post_type=at_biz_dir&page=atbdp-settings#page_settings' ); + $warnings = array(); + if ( empty( $add_listing ) ) { + $warnings[] = array( + 'title' => __( 'Add listing page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $user_dashboard ) ) { + $warnings[] = array( + 'title' => __( 'Dashboard page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $user_profile ) ) { + $warnings[] = array( + 'title' => __( 'User Profile page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $single_category_page ) ) { + $warnings[] = array( + 'title' => __( 'Single Category page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $single_location_page ) ) { + $warnings[] = array( + 'title' => __( 'Single Location page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $single_tag_page ) ) { + $warnings[] = array( + 'title' => __( 'Single Location page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $signin_signup_page ) ) { + $warnings[] = array( + 'title' => __( 'Sign In & Signup page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $search_result_page ) ) { + $warnings[] = array( + 'title' => __( 'Search Result page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $checkout_page ) && ! empty( $enable_monetization ) && ! empty( $enable_featured_listing ) ) { + $warnings[] = array( + 'title' => __( 'Checkout page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $payment_receipt_page ) && ! empty( $enable_monetization ) && ! empty( $enable_featured_listing ) ) { + $warnings[] = array( + 'title' => __( 'Payment Receipt page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( empty( $transaction_failure_page ) && ! empty( $enable_monetization ) && ! empty( $enable_featured_listing ) ) { + $warnings[] = array( + 'title' => __( 'Transaction Failure page not selected', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => $page_settings_link, + 'link_text' => __( 'Select Page', 'directorist' ), + ); + } + if ( 'google' == $select_listing_map && empty( $map_api_key ) ) { + $warnings[] = array( + 'title' => __( 'Map Api Key is missing', 'directorist' ), + 'desc' => __( 'Contains a collection of relevant data that will help you debug your website accurately and more efficiently.', 'directorist' ), + 'link' => esc_url( admin_url() . '/edit.php?post_type=at_biz_dir&page=atbdp-settings#listing_settings__map' ), + 'link_text' => __( 'Give the Api', 'directorist' ), + ); + } + if ( ! is_resource( $connection ) ) { + $warnings[] = array( + 'title' => __( 'SMTP not configured', 'directorist' ), + 'desc' => __( 'SMTP is a TCP/IP protocol responsible for email deliveries. You must configure SMTP to send or receive emails.', 'directorist' ), + ); + } + + return apply_filters( 'directorist_warnings', $warnings ); + } } /** @@ -3172,19 +3202,19 @@ function directorist_warnings() { * * @since 7.0.5.3 * - * @param string $type Directory type slug. + * @param string $type Directory type slug. * @param string|null|mixed $base_url Base url for type url. * * @return string Directory type url. */ function directorist_get_directory_type_nav_url( $type = 'all', $base_url = null ) { if ( empty( $base_url ) ) { - $base_url = remove_query_arg( [ 'page', 'paged' ] ); + $base_url = remove_query_arg( array( 'page', 'paged' ) ); $base_url = preg_replace( '~/page/(\d+)/?~', '', $base_url ); $base_url = preg_replace( '~/paged/(\d+)/?~', '', $base_url ); } - $url = add_query_arg( [ 'directory_type' => $type ], $base_url ); + $url = add_query_arg( array( 'directory_type' => $type ), $base_url ); return apply_filters( 'directorist_get_directory_type_nav_url', $url, $type, $base_url ); } @@ -3194,20 +3224,20 @@ function directorist_get_directory_type_nav_url( $type = 'all', $base_url = null * * @since 7.1.3 * - * @param string $query_args Query Args + * @param string $query_args Query Args * @param string|null|mixed $base_url Base url for type url. * * @return string Final URL */ -function directorist_add_query_args_with_no_pagination( $query_args = [], $base_url = null ) { +function directorist_add_query_args_with_no_pagination( $query_args = array(), $base_url = null ) { - if ( empty( $base_url ) ) { + if ( empty( $base_url ) ) { $base_url = ! empty( $_SERVER['REQUEST_URI'] ) ? directorist_clean( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; } - $base_url = remove_query_arg( [ 'page', 'paged' ], $base_url ); - $base_url = preg_replace( '~/page/(\d+)/?~', '', $base_url ); - $base_url = preg_replace( '~/paged/(\d+)/?~', '', $base_url ); + $base_url = remove_query_arg( array( 'page', 'paged' ), $base_url ); + $base_url = preg_replace( '~/page/(\d+)/?~', '', $base_url ); + $base_url = preg_replace( '~/paged/(\d+)/?~', '', $base_url ); $url = add_query_arg( $query_args, $base_url ); @@ -3215,24 +3245,24 @@ function directorist_add_query_args_with_no_pagination( $query_args = [], $base_ } if ( ! function_exists( 'directorist_is_plugin_active' ) ) { - function directorist_is_plugin_active( $plugin ) { - return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || directorist_is_plugin_active_for_network( $plugin ); - } + function directorist_is_plugin_active( $plugin ) { + return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || directorist_is_plugin_active_for_network( $plugin ); + } } if ( ! function_exists( 'directorist_is_plugin_active_for_network' ) ) { - function directorist_is_plugin_active_for_network( $plugin ) { - if ( ! is_multisite() ) { - return false; - } + function directorist_is_plugin_active_for_network( $plugin ) { + if ( ! is_multisite() ) { + return false; + } - $plugins = get_site_option( 'active_sitewide_plugins' ); - if ( isset( $plugins[ $plugin ] ) ) { - return true; - } + $plugins = get_site_option( 'active_sitewide_plugins' ); + if ( isset( $plugins[ $plugin ] ) ) { + return true; + } - return false; - } + return false; + } } /** @@ -3245,7 +3275,7 @@ function directorist_is_plugin_active_for_network( $plugin ) { * @return string Error message. */ function directorist_get_registration_error_message( $error_code ) { - $message = [ + $message = array( '0' => __( 'Something went wrong!', 'directorist' ), '1' => __( 'Registration failed. Please make sure you filed up all the necessary fields marked with <span style="color: red">*</span>', 'directorist' ), '2' => sprintf( @@ -3265,7 +3295,7 @@ function directorist_get_registration_error_message( $error_code ) { '6' => __( 'Email is not valid', 'directorist' ), '7' => __( 'Space is not allowed in username', 'directorist' ), '8' => __( 'Please make sure you filed up the user type', 'directorist' ), - ]; + ); return isset( $message[ $error_code ] ) ? $message[ $error_code ] : ''; } @@ -3278,7 +3308,7 @@ function directorist_get_registration_error_message( $error_code ) { * @return string nonce key with current version */ function directorist_get_nonce_key() { - return 'directorist_nonce_' . ATBDP_VERSION; + return 'directorist_nonce_' . ATBDP_VERSION; } /** @@ -3295,8 +3325,8 @@ function directorist_get_nonce_key() { * @return boolen */ function directorist_verify_nonce( $nonce_field = 'directorist_nonce', $action = '' ) { - $nonce = ! empty( $_REQUEST[ $nonce_field ] ) ? directorist_clean( wp_unslash( $_REQUEST[ $nonce_field ] ) ) : ''; - return wp_verify_nonce( $nonce, ( $action ? $action : directorist_get_nonce_key() ) ); + $nonce = ! empty( $_REQUEST[ $nonce_field ] ) ? directorist_clean( wp_unslash( $_REQUEST[ $nonce_field ] ) ) : ''; + return wp_verify_nonce( $nonce, ( $action ? $action : directorist_get_nonce_key() ) ); } /** @@ -3307,28 +3337,50 @@ function directorist_verify_nonce( $nonce_field = 'directorist_nonce', $action = * @return array */ function directorist_get_supported_file_types_groups( $group = null ) { - $groups = [ - 'image' => [ - 'jpg', 'jpeg', 'gif', 'png', 'bmp', 'ico' - ], - 'audio' => [ - 'ogg', 'mp3', 'wav', 'wma', - ], - 'video' => [ - 'asf', 'avi', 'mkv', 'mp4', 'mpg', 'mpeg', 'wmv', '3gp', - ], - 'document' => [ - 'doc', 'docx', 'odt', 'pdf', 'ppt', 'pptx', 'xls', 'xlsx' - ] - ]; - - $groups = apply_filters( 'directorist_supported_file_types_groups', $groups ); + $groups = array( + 'image' => array( + 'jpg', + 'jpeg', + 'gif', + 'png', + 'bmp', + 'ico', + ), + 'audio' => array( + 'ogg', + 'mp3', + 'wav', + 'wma', + ), + 'video' => array( + 'asf', + 'avi', + 'mkv', + 'mp4', + 'mpg', + 'mpeg', + 'wmv', + '3gp', + ), + 'document' => array( + 'doc', + 'docx', + 'odt', + 'pdf', + 'ppt', + 'pptx', + 'xls', + 'xlsx', + ), + ); + + $groups = apply_filters( 'directorist_supported_file_types_groups', $groups ); if ( is_null( $group ) ) { return $groups; } - return ( isset( $groups[ $group ] ) ? $groups[ $group ] : [] ); + return ( isset( $groups[ $group ] ) ? $groups[ $group ] : array() ); } /** @@ -3343,18 +3395,24 @@ function directorist_get_supported_file_types_groups( $group = null ) { function directorist_get_supported_file_types() { $groups = directorist_get_supported_file_types_groups(); - return array_reduce( $groups, function( $carry, $group ) { - return array_merge( $carry, $group ); - }, [] ); + return array_reduce( + $groups, + function ( $carry, $group ) { + return array_merge( $carry, $group ); + }, + array() + ); } function directorist_has_no_listing() { - $listings = new WP_Query([ - 'post_type' => ATBDP_POST_TYPE, - 'posts_per_page' => 1, - 'no_found_rows' => true, - ]); + $listings = new WP_Query( + array( + 'post_type' => ATBDP_POST_TYPE, + 'posts_per_page' => 1, + 'no_found_rows' => true, + ) + ); $has_no_listing = empty( $listings->posts ); @@ -3500,9 +3558,12 @@ function directorist_delete_user_favorites( $user_id = 0, $listing_id = 0 ) { } $old_favorites = directorist_get_user_favorites( $user_id ); - $new_favorites = array_filter( $old_favorites, static function( $favorite ) use ( $listing_id ) { - return ( $favorite !== $listing_id ); - } ); + $new_favorites = array_filter( + $old_favorites, + static function ( $favorite ) use ( $listing_id ) { + return ( $favorite !== $listing_id ); + } + ); if ( count( $old_favorites ) > count( $new_favorites ) ) { update_user_meta( $user_id, 'atbdp_favourites', $new_favorites ); @@ -3559,7 +3620,7 @@ function directorist_user_notifiable_for( $event_name = '', $user_type = '' ) { $user_type = 'notify_' . (string) $user_type; $event_name = (string) $event_name; - if ( ! in_array( $event_name, get_directorist_option( $user_type, array() ), true ) ) { + if ( ! in_array( $event_name, get_directorist_option( $user_type, array() ), true ) ) { return false; } @@ -3656,76 +3717,78 @@ function directorist_set_listing_views_count( $listing_id = 0 ) { * @return string Listing field key */ function directorist_translate_to_listing_field_key( $header_key = '' ) { - // - $fields_map = apply_filters( 'directorist_listings_field_label_to_key_map', array( - 'date' => 'publish_date', - 'publish_date' => 'publish_date', - 'Published' => 'publish_date', - 'status' => 'listing_status', - 'listing_status' => 'listing_status', - 'Status' => 'listing_status', - 'name' => 'listing_title', - 'title' => 'listing_title', - 'Title' => 'listing_title', - 'details' => 'listing_content', - 'content' => 'listing_content', - 'Description' => 'listing_content', - 'Excerpt' => 'excerpt', - 'price' => 'price', - 'Price' => 'price', - 'price_range' => 'price_range', - 'Price Range' => 'price_range', - 'location' => 'location', - 'Locations' => 'location', - 'tag' => 'tag', - 'Tags' => 'tag', - 'category' => 'category', - 'Categories' => 'category', - 'zip' => 'zip', - 'Zip' => 'zip', - 'phone' => 'phone', - 'Phone' => 'phone', - 'phone2' => 'phone2', - 'Phone2' => 'phone2', - 'fax' => 'fax', - 'Fax' => 'fax', - 'email' => 'email', - 'Email' => 'email', - 'website' => 'website', - 'Website' => 'website', - 'social' => 'social', - 'Socials' => 'social', - 'atbdp_post_views_count' => 'atbdp_post_views_count', - 'views_count' => 'atbdp_post_views_count', - 'Views Count' => 'atbdp_post_views_count', - 'manual_lat' => 'manual_lat', - 'Map Latitude' => 'manual_lat', - 'manual_lng' => 'manual_lng', - 'Map Logitude' => 'manual_lng', - 'hide_map' => 'hide_map', - 'Hide Map?' => 'hide_map', - 'hide_contact_info' => 'hide_contact_owner', - 'Hide Owner Contact Form?' => 'hide_contact_owner', - 'listing_prv_img' => 'listing_img', - 'preview' => 'listing_img', - 'Image' => 'listing_img', - 'listing_img' => 'listing_img', - 'videourl' => 'videourl', - 'Video' => 'videourl', - 'tagline' => 'tagline', - 'Tagline' => 'tagline', - 'address' => 'address', - 'Address' => 'address', - ) ); - - return isset( $fields_map[ $header_key ] ) ? $fields_map[ $header_key ] : ''; + $fields_map = apply_filters( + 'directorist_listings_field_label_to_key_map', + array( + 'date' => 'publish_date', + 'publish_date' => 'publish_date', + 'Published' => 'publish_date', + 'status' => 'listing_status', + 'listing_status' => 'listing_status', + 'Status' => 'listing_status', + 'name' => 'listing_title', + 'title' => 'listing_title', + 'Title' => 'listing_title', + 'details' => 'listing_content', + 'content' => 'listing_content', + 'Description' => 'listing_content', + 'Excerpt' => 'excerpt', + 'price' => 'price', + 'Price' => 'price', + 'price_range' => 'price_range', + 'Price Range' => 'price_range', + 'location' => 'location', + 'Locations' => 'location', + 'tag' => 'tag', + 'Tags' => 'tag', + 'category' => 'category', + 'Categories' => 'category', + 'zip' => 'zip', + 'Zip' => 'zip', + 'phone' => 'phone', + 'Phone' => 'phone', + 'phone2' => 'phone2', + 'Phone2' => 'phone2', + 'fax' => 'fax', + 'Fax' => 'fax', + 'email' => 'email', + 'Email' => 'email', + 'website' => 'website', + 'Website' => 'website', + 'social' => 'social', + 'Socials' => 'social', + 'atbdp_post_views_count' => 'atbdp_post_views_count', + 'views_count' => 'atbdp_post_views_count', + 'Views Count' => 'atbdp_post_views_count', + 'manual_lat' => 'manual_lat', + 'Map Latitude' => 'manual_lat', + 'manual_lng' => 'manual_lng', + 'Map Logitude' => 'manual_lng', + 'hide_map' => 'hide_map', + 'Hide Map?' => 'hide_map', + 'hide_contact_info' => 'hide_contact_owner', + 'Hide Owner Contact Form?' => 'hide_contact_owner', + 'listing_prv_img' => 'listing_img', + 'preview' => 'listing_img', + 'Image' => 'listing_img', + 'listing_img' => 'listing_img', + 'videourl' => 'videourl', + 'Video' => 'videourl', + 'tagline' => 'tagline', + 'Tagline' => 'tagline', + 'address' => 'address', + 'Address' => 'address', + ) + ); + + return isset( $fields_map[ $header_key ] ) ? $fields_map[ $header_key ] : ''; } /** * Get data if set, otherwise return a default value or null. Prevents notices when data is not set. * * @since 7.3.0 - * @param mixed $var Variable. + * @param mixed $var Variable. * @param mixed|null $default Default value. * @return mixed */ @@ -3750,7 +3813,7 @@ function directorist_get_var( &$var, $default = null ) { * @return mixed */ function directorist_maybe_json( $input_data = '', $return_first_item = false, $sanitizer = 'directorist_clean' ) { - return call_user_func( $sanitizer, Helper::maybe_json( $input_data, $return_first_item ) ); + return call_user_func( $sanitizer, Helper::maybe_json( $input_data, $return_first_item ) ); } /** @@ -3759,37 +3822,37 @@ function directorist_maybe_json( $input_data = '', $return_first_item = false, $ * @return array */ function directorist_get_allowed_attributes() { - $allowed_attributes = array( - 'style' => array(), - 'class' => array(), - 'id' => array(), - 'name' => array(), - 'rel' => array(), - 'type' => array(), - 'href' => array(), - 'value' => array(), - 'action' => array(), - 'selected' => array(), - 'checked' => array(), - 'for' => array(), - 'placeholder' => array(), - 'cols' => array(), - 'rows' => array(), - 'maxlength' => array(), - 'required' => array(), - - 'xmlns' => array(), - 'width' => array(), - 'height' => array(), - 'viewBox' => array(), - 'fill' => array(), - 'd' => array(), + $allowed_attributes = array( + 'style' => array(), + 'class' => array(), + 'id' => array(), + 'name' => array(), + 'rel' => array(), + 'type' => array(), + 'href' => array(), + 'value' => array(), + 'action' => array(), + 'selected' => array(), + 'checked' => array(), + 'for' => array(), + 'placeholder' => array(), + 'cols' => array(), + 'rows' => array(), + 'maxlength' => array(), + 'required' => array(), + + 'xmlns' => array(), + 'width' => array(), + 'height' => array(), + 'viewBox' => array(), + 'fill' => array(), + 'd' => array(), 'data-custom-field' => array(), - 'data-icon' => array(), - ); + 'data-icon' => array(), + ); - return apply_filters( 'directorist_get_allowed_attributes', $allowed_attributes ); + return apply_filters( 'directorist_get_allowed_attributes', $allowed_attributes ); } /** @@ -3798,14 +3861,17 @@ function directorist_get_allowed_attributes() { * @return array */ function directorist_get_allowed_form_input_tags() { - $allowed_attributes = directorist_get_allowed_attributes(); + $allowed_attributes = directorist_get_allowed_attributes(); - return apply_filters( 'directorist_get_allowed_form_input_tags', [ - 'input' => $allowed_attributes, - 'select' => $allowed_attributes, - 'option' => $allowed_attributes, - 'textarea' => $allowed_attributes, - ] ); + return apply_filters( + 'directorist_get_allowed_form_input_tags', + array( + 'input' => $allowed_attributes, + 'select' => $allowed_attributes, + 'option' => $allowed_attributes, + 'textarea' => $allowed_attributes, + ) + ); } /** @@ -3814,13 +3880,16 @@ function directorist_get_allowed_form_input_tags() { * @return array */ function directorist_get_allowed_svg_tags() { - $allowed_attributes = directorist_get_allowed_attributes(); + $allowed_attributes = directorist_get_allowed_attributes(); - return apply_filters( 'directorist_get_allowed_svg_tags', [ - 'svg' => $allowed_attributes, - 'g' => $allowed_attributes, - 'path' => $allowed_attributes, - ] ); + return apply_filters( + 'directorist_get_allowed_svg_tags', + array( + 'svg' => $allowed_attributes, + 'g' => $allowed_attributes, + 'path' => $allowed_attributes, + ) + ); } /** @@ -3830,33 +3899,33 @@ function directorist_get_allowed_svg_tags() { */ function directorist_get_allowed_html() { - $allowed_attributes = directorist_get_allowed_attributes(); - - $allowed_html = array( - 'h1' => $allowed_attributes, - 'h2' => $allowed_attributes, - 'h3' => $allowed_attributes, - 'h4' => $allowed_attributes, - 'h5' => $allowed_attributes, - 'h6' => $allowed_attributes, - 'p' => $allowed_attributes, - 'a' => $allowed_attributes, + $allowed_attributes = directorist_get_allowed_attributes(); + + $allowed_html = array( + 'h1' => $allowed_attributes, + 'h2' => $allowed_attributes, + 'h3' => $allowed_attributes, + 'h4' => $allowed_attributes, + 'h5' => $allowed_attributes, + 'h6' => $allowed_attributes, + 'p' => $allowed_attributes, + 'a' => $allowed_attributes, 'ul' => $allowed_attributes, 'li' => $allowed_attributes, - 'span' => $allowed_attributes, - 'form' => $allowed_attributes, - 'div' => $allowed_attributes, - 'label' => $allowed_attributes, - 'button' => $allowed_attributes, - ); + 'span' => $allowed_attributes, + 'form' => $allowed_attributes, + 'div' => $allowed_attributes, + 'label' => $allowed_attributes, + 'button' => $allowed_attributes, + ); - $allowed_html = array_merge( - $allowed_html, - directorist_get_allowed_form_input_tags(), - directorist_get_allowed_svg_tags() - ); + $allowed_html = array_merge( + $allowed_html, + directorist_get_allowed_form_input_tags(), + directorist_get_allowed_svg_tags() + ); - return apply_filters( 'directorist_get_allowed_html', $allowed_html ); + return apply_filters( 'directorist_get_allowed_html', $allowed_html ); } @@ -3877,15 +3946,15 @@ function directorist_get_allowed_html() { */ function directorist_kses( $content, $allowed_html = 'all' ) { - $allowed_html_types = [ - 'all' => directorist_get_allowed_html(), - 'form_input' => directorist_get_allowed_form_input_tags(), - 'svg' => directorist_get_allowed_svg_tags(), - ]; + $allowed_html_types = array( + 'all' => directorist_get_allowed_html(), + 'form_input' => directorist_get_allowed_form_input_tags(), + 'svg' => directorist_get_allowed_svg_tags(), + ); - $allowed_html_type = ( in_array( $allowed_html, $allowed_html_types ) ) ? $allowed_html_types[ $allowed_html ] : $allowed_html_types[ 'all' ]; + $allowed_html_type = ( in_array( $allowed_html, $allowed_html_types ) ) ? $allowed_html_types[ $allowed_html ] : $allowed_html_types['all']; - return wp_kses( $content, $allowed_html_type ); + return wp_kses( $content, $allowed_html_type ); } /* @@ -3937,7 +4006,8 @@ function directorist_esc_json( $json, $html = false ) { */ function directorist_default_preview_size() { return apply_filters( - 'directorist_default_preview_size', array( + 'directorist_default_preview_size', + array( 'width' => 640, 'height' => 360, 'crop' => true, @@ -3951,73 +4021,76 @@ function directorist_default_preview_size() { * @since 7.5 * @return int Page ID */ -function directorist_get_page_id( string $page_name = '' ) : int { - - $page_to_option_map = apply_filters( 'directorist_pages', array( - 'location' => 'single_location_page', - 'category' => 'single_category_page', - 'tag' => 'single_tag_page', - 'form' => 'add_listing_page', - 'listings' => 'all_listing_page', - 'dashboard' => 'user_dashboard', - 'author' => 'author_profile_page', - 'categories' => 'all_categories_page', - 'locations' => 'all_locations_page', - 'registration' => 'custom_registration', - 'login' => 'user_login', - 'search' => 'search_listing', - 'results' => 'search_result_page', - 'checkout' => 'checkout_page', - 'receipt' => 'payment_receipt_page', - 'failed' => 'transaction_failure_page', - 'privacy' => 'privacy_policy', - 'terms' => 'terms_conditions', - )); +function directorist_get_page_id( string $page_name = '' ): int { + + $page_to_option_map = apply_filters( + 'directorist_pages', + array( + 'location' => 'single_location_page', + 'category' => 'single_category_page', + 'tag' => 'single_tag_page', + 'form' => 'add_listing_page', + 'listings' => 'all_listing_page', + 'dashboard' => 'user_dashboard', + 'author' => 'author_profile_page', + 'categories' => 'all_categories_page', + 'locations' => 'all_locations_page', + 'registration' => 'custom_registration', + 'login' => 'user_login', + 'search' => 'search_listing', + 'results' => 'search_result_page', + 'checkout' => 'checkout_page', + 'receipt' => 'payment_receipt_page', + 'failed' => 'transaction_failure_page', + 'privacy' => 'privacy_policy', + 'terms' => 'terms_conditions', + ) + ); - if ( ! isset( $page_to_option_map[ $page_name ] ) ) { - return 0; - } + if ( ! isset( $page_to_option_map[ $page_name ] ) ) { + return 0; + } - $page_id = (int) get_directorist_option( $page_to_option_map[ $page_name ] ); + $page_id = (int) get_directorist_option( $page_to_option_map[ $page_name ] ); - if ( ! $page_id ) { - return 0; - } + if ( ! $page_id ) { + return 0; + } - return (int) apply_filters( 'directorist_page_id', $page_id, $page_name ); + return (int) apply_filters( 'directorist_page_id', $page_id, $page_name ); } -function directorist_password_reset_url( $user, $password_reset = true, $confirm_mail = false) { +function directorist_password_reset_url( $user, $password_reset = true, $confirm_mail = false ) { - if ( ! $user instanceof \Wp_User ) { - return; - } + if ( ! $user instanceof \Wp_User ) { + return; + } - $args = array( - 'user' => base64_encode( $user->user_email ) - ); + $args = array( + 'user' => base64_encode( $user->user_email ), + ); - global $directories_user_rest_keys; + global $directories_user_rest_keys; - if( is_array( $directories_user_rest_keys ) && ! empty( $directories_user_rest_keys[$user->user_email] ) ) { - $args['key'] = $directories_user_rest_keys[$user->user_email]; - } else { - $key = get_password_reset_key( $user ); - $directories_user_rest_keys[$user->user_email] = $key; - $args['key'] = $key; - } + if ( is_array( $directories_user_rest_keys ) && ! empty( $directories_user_rest_keys[ $user->user_email ] ) ) { + $args['key'] = $directories_user_rest_keys[ $user->user_email ]; + } else { + $key = get_password_reset_key( $user ); + $directories_user_rest_keys[ $user->user_email ] = $key; + $args['key'] = $key; + } - if ( $password_reset ) { - $args['password_reset'] = true; - } + if ( $password_reset ) { + $args['password_reset'] = true; + } - if ( $confirm_mail ) { - $args['confirm_mail'] = true; - } + if ( $confirm_mail ) { + $args['confirm_mail'] = true; + } - $reset_password_url = ATBDP_Permalink::get_signin_signup_page_link( $args ); + $reset_password_url = ATBDP_Permalink::get_signin_signup_page_link( $args ); - return apply_filters( 'directorist_password_reset_url', $reset_password_url ); + return apply_filters( 'directorist_password_reset_url', $reset_password_url ); } /** @@ -4028,25 +4101,35 @@ function directorist_password_reset_url( $user, $password_reset = true, $confirm * * @return array */ - function directorist_get_mime_types( $filterby = '', $return_type = '' ) { $allowed_mime_types = get_allowed_mime_types(); if ( ! empty( $filterby ) ) { - $allowed_mime_types = array_filter( $allowed_mime_types, static function( $mime_type, $extensions ) use ( $filterby ) { - return stripos( $mime_type, $filterby ) !== false; - }, ARRAY_FILTER_USE_BOTH ); + $allowed_mime_types = array_filter( + $allowed_mime_types, + static function ( $mime_type, $extensions ) use ( $filterby ) { + return stripos( $mime_type, $filterby ) !== false; + }, + ARRAY_FILTER_USE_BOTH + ); } if ( $return_type === 'extension' || $return_type === '.extension' ) { - $allowed_mime_types = array_reduce( array_keys( $allowed_mime_types ), static function( $carry, $extension ) { - return array_merge( $carry, explode( '|', $extension ) ); - }, array() ); + $allowed_mime_types = array_reduce( + array_keys( $allowed_mime_types ), + static function ( $carry, $extension ) { + return array_merge( $carry, explode( '|', $extension ) ); + }, + array() + ); if ( $return_type === '.extension' ) { - $allowed_mime_types = array_map( static function( $extension ) { - return '.' . $extension; - }, $allowed_mime_types ); + $allowed_mime_types = array_map( + static function ( $extension ) { + return '.' . $extension; + }, + $allowed_mime_types + ); } } @@ -4063,7 +4146,7 @@ function directorist_is_email_verification_enabled() { } /** - * @param int $term_id + * @param int $term_id * @param string $taxonomy * * @return string Term Label @@ -4092,11 +4175,11 @@ function directorist_sanitize_term_item( $item ) { * @return mixed item */ function directorist_maybe_number( $item ) { - if ( ! is_string( $item ) && ! is_numeric( $item ) ) { + if ( ! is_string( $item ) && ! is_numeric( $item ) ) { return $item; } - if ( preg_match( "/[^0-9.]/", $item ) ) { + if ( preg_match( '/[^0-9.]/', $item ) ) { return $item; } @@ -4106,7 +4189,7 @@ function directorist_maybe_number( $item ) { return absint( $item ); } - return ( float ) $item; + return (float) $item; } function directorist_generate_password_reset_code_transient_key( $data ) { @@ -4165,23 +4248,23 @@ function directorist_check_password_reset_pin_code( $user, $pin_code ) { return $wp_hasher->CheckPassword( $reset_key, $reset_key_hash ); } function directorist_validate_youtube_vimeo_url( $url ) { - if ( preg_match( '/^(https?:\/\/)?(www\.)?vimeo\.com\/(\d+)/i', $url ) ) { - return true; - } + if ( preg_match( '/^(https?:\/\/)?(www\.)?vimeo\.com\/(\d+)/i', $url ) ) { + return true; + } - if ( preg_match( '/^(https?:\/\/)?(www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/i', $url ) ) { - return true; - } + if ( preg_match( '/^(https?:\/\/)?(www\.)?youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/i', $url ) ) { + return true; + } - if ( preg_match( '/^https?:\/\/youtu\.be\/([a-zA-Z0-9_-]+)(\?.*)?$/', $url ) ) { - return true; - } + if ( preg_match( '/^https?:\/\/youtu\.be\/([a-zA-Z0-9_-]+)(\?.*)?$/', $url ) ) { + return true; + } if ( preg_match( '/^(https?:\/\/)?(www\.)?youtube\.com\/shorts\/([A-Za-z0-9_-]+)(\S+)?$/i', $url ) ) { - return true; - } + return true; + } - return false; + return false; } function directorist_is_listing_post_type( $listing_id ) { @@ -4210,39 +4293,39 @@ function directorist_background_image_process( $images ) { } function directorist_get_json_from_url( $url ) { - $zip_content = file_get_contents( $url ); + $zip_content = file_get_contents( $url ); - if ( $zip_content === false ) { - return false; - } + if ( $zip_content === false ) { + return false; + } - $temp_zip_path = tempnam( sys_get_temp_dir(), 'unzip_temp' ); + $temp_zip_path = tempnam( sys_get_temp_dir(), 'unzip_temp' ); - if ( ! $temp_zip_path ) { - return false; - } + if ( ! $temp_zip_path ) { + return false; + } - if ( file_put_contents($temp_zip_path, $zip_content) === false ) { - return false; - } + if ( file_put_contents( $temp_zip_path, $zip_content ) === false ) { + return false; + } - $zip = new ZipArchive; + $zip = new ZipArchive(); - if ( $zip->open( $temp_zip_path ) === true ) { + if ( $zip->open( $temp_zip_path ) === true ) { - $json_content = $zip->getFromIndex( 0 ); - $decoded_data = json_decode( $json_content, true ); + $json_content = $zip->getFromIndex( 0 ); + $decoded_data = json_decode( $json_content, true ); - if ( $decoded_data === null ) { - return false; - } + if ( $decoded_data === null ) { + return false; + } - $zip->close(); + $zip->close(); - unlink($temp_zip_path); + unlink( $temp_zip_path ); - return $decoded_data; - } + return $decoded_data; + } } /** @@ -4262,41 +4345,44 @@ function directorist_get_json_from_url( $url ) { * @return array Associative array containing 'select' and 'radio' options. */ -if ( ! function_exists('directorist_calculate_number_options') ) { - function directorist_calculate_number_options( $data ) { - $min_val = ! empty( $data['options']['min_value'] ) ? absint( $data['options']['min_value'] ) : 1; - $max_val = ! empty( $data['options']['max_value'] ) ? absint( $data['options']['max_value'] ) : 100; - - // Calculate step - $step = absint( ! empty( $data['options']['step'] ) ? $data['options']['step'] : ( $max_val - $min_val ) / 5 ); - - if( empty( $data['options']['step'] ) && $max_val < 10 ) { - $step = 1; - } - - // Calculate select options - $select_options = array(); - if( $max_val > $min_val ) { - for ( $i = $min_val; $i <= $max_val; $i += $step ) { - $select_options[] = (int) round( $i ); - } - } - - // Calculate radio options - $radio_options = array(); - if( $max_val > $min_val ) { - for ( $i = $min_val; $i <= $max_val; $i += $step ) { - $range_start = $i; - $range_end = min( $i + $step - 1, $max_val ); - $radio_options[] = array( 'start' => $range_start, 'end' => $range_end ); - } - } - - return array( - 'select' => $select_options, - 'radio' => $radio_options, - ); - } +if ( ! function_exists( 'directorist_calculate_number_options' ) ) { + function directorist_calculate_number_options( $data ) { + $min_val = ! empty( $data['options']['min_value'] ) ? absint( $data['options']['min_value'] ) : 1; + $max_val = ! empty( $data['options']['max_value'] ) ? absint( $data['options']['max_value'] ) : 100; + + // Calculate step + $step = absint( ! empty( $data['options']['step'] ) ? $data['options']['step'] : ( $max_val - $min_val ) / 5 ); + + if ( empty( $data['options']['step'] ) && $max_val < 10 ) { + $step = 1; + } + + // Calculate select options + $select_options = array(); + if ( $max_val > $min_val ) { + for ( $i = $min_val; $i <= $max_val; $i += $step ) { + $select_options[] = (int) round( $i ); + } + } + + // Calculate radio options + $radio_options = array(); + if ( $max_val > $min_val ) { + for ( $i = $min_val; $i <= $max_val; $i += $step ) { + $range_start = $i; + $range_end = min( $i + $step - 1, $max_val ); + $radio_options[] = array( + 'start' => $range_start, + 'end' => $range_end, + ); + } + } + + return array( + 'select' => $select_options, + 'radio' => $radio_options, + ); + } } /** Delete directory even when non empty. @@ -4359,14 +4445,14 @@ function directorist_delete_temporary_upload_dirs() { * @return string The formatted date string, or an empty string if the input value is empty. */ function directorist_format_date( $date = '', $format = '' ) { - $date = strtotime( $date ); - if ( ! $date ) { - return ''; - } + $date = strtotime( $date ); + if ( ! $date ) { + return ''; + } - $format = apply_filters( 'directorist_date_format', ( $format ? $format : get_option( 'date_format' ) ) ); + $format = apply_filters( 'directorist_date_format', ( $format ? $format : get_option( 'date_format' ) ) ); - return date( $format, $date ); + return date( $format, $date ); } /** @@ -4377,40 +4463,44 @@ function directorist_format_date( $date = '', $format = '' ) { * @return string The formatted time string, or an empty string if the input value is empty. */ function directorist_format_time( $time = '', $format = '' ) { - $time = strtotime( $time ); - if ( ! $time ) { - return ''; - } + $time = strtotime( $time ); + if ( ! $time ) { + return ''; + } - $format = apply_filters( 'directorist_time_format', ( $format ? $format : get_option( 'time_format' ) ) ); + $format = apply_filters( 'directorist_time_format', ( $format ? $format : get_option( 'time_format' ) ) ); - return date( $format, $time ); + return date( $format, $time ); } function directorist_filter_listing_empty_metadata( $meta_data ) { - return array_filter( $meta_data, static function( $value, $key ) { - if ( $key === '_hide_contact_owner' && ! $value ) { - return false; - } + return array_filter( + $meta_data, + static function ( $value, $key ) { + if ( $key === '_hide_contact_owner' && ! $value ) { + return false; + } - if ( is_array( $value ) ) { - return ! empty( $value ); - } + if ( is_array( $value ) ) { + return ! empty( $value ); + } - if ( is_null( $value ) ) { - return false; - } + if ( is_null( $value ) ) { + return false; + } - if ( is_string( $value ) && $value === '' ) { - return false; - } + if ( is_string( $value ) && $value === '' ) { + return false; + } - if ( is_numeric( $value ) && $value == 0 ) { - return false; - } + if ( is_numeric( $value ) && $value == 0 ) { + return false; + } - return true; - }, ARRAY_FILTER_USE_BOTH ); + return true; + }, + ARRAY_FILTER_USE_BOTH + ); } function directorist_delete_listing_empty_metadata( $listing_id, array $metadata = array(), array $valid_metadata = array() ) { @@ -4421,113 +4511,113 @@ function directorist_delete_listing_empty_metadata( $listing_id, array $metadata } function directorist_download_plugin( array $args = array() ) { - $status = array( 'success' => false ); + $status = array( 'success' => false ); - $default = array( - 'url' => '', - 'init_wp_filesystem' => true, - ); - $args = array_merge( $default, $args ); + $default = array( + 'url' => '', + 'init_wp_filesystem' => true, + ); + $args = array_merge( $default, $args ); - $allowed_host = array( 'directorist.com', 'wordpress.org', 'downloads.wordpress.org' ); + $allowed_host = array( 'directorist.com', 'wordpress.org', 'downloads.wordpress.org' ); - if ( empty( $args['url'] ) || ! in_array( parse_url( $args['url'], PHP_URL_HOST ), $allowed_host, true ) ) { - $status['success'] = false; - $status['message'] = __( 'Invalid download link', 'directorist' ); + if ( empty( $args['url'] ) || ! in_array( parse_url( $args['url'], PHP_URL_HOST ), $allowed_host, true ) ) { + $status['success'] = false; + $status['message'] = __( 'Invalid download link', 'directorist' ); - return $status; - } + return $status; + } - global $wp_filesystem; + global $wp_filesystem; - if ( $args['init_wp_filesystem'] ) { + if ( $args['init_wp_filesystem'] ) { - if ( ! function_exists( 'WP_Filesystem' ) ) { - include ABSPATH . 'wp-admin/includes/file.php'; - } + if ( ! function_exists( 'WP_Filesystem' ) ) { + include ABSPATH . 'wp-admin/includes/file.php'; + } - WP_Filesystem(); - } + WP_Filesystem(); + } - $plugin_path = WP_CONTENT_DIR . '/plugins'; - $temp_dest = "{$plugin_path}/atbdp-temp-dir"; - $file_url = $args['url']; - $file_name = basename( $file_url ); - $tmp_file = download_url( $file_url ); + $plugin_path = WP_CONTENT_DIR . '/plugins'; + $temp_dest = "{$plugin_path}/atbdp-temp-dir"; + $file_url = $args['url']; + $file_name = basename( $file_url ); + $tmp_file = download_url( $file_url ); - if ( ! is_string( $tmp_file ) ) { - $status['success'] = false; - $status['tmp_file'] = $tmp_file; - $status['file_url'] = $file_url; - $status['message'] = 'Could not download the file'; + if ( ! is_string( $tmp_file ) ) { + $status['success'] = false; + $status['tmp_file'] = $tmp_file; + $status['file_url'] = $file_url; + $status['message'] = 'Could not download the file'; - return $status; - } + return $status; + } - // Make Temp Dir - if ( $wp_filesystem->exists( $temp_dest ) ) { - $wp_filesystem->delete( $temp_dest, true ); - } + // Make Temp Dir + if ( $wp_filesystem->exists( $temp_dest ) ) { + $wp_filesystem->delete( $temp_dest, true ); + } - $wp_filesystem->mkdir( $temp_dest ); + $wp_filesystem->mkdir( $temp_dest ); - if ( ! file_exists( $temp_dest ) ) { - $status['success'] = false; - $status['message'] = __( 'Could not create temp directory', 'directorist' ); + if ( ! file_exists( $temp_dest ) ) { + $status['success'] = false; + $status['message'] = __( 'Could not create temp directory', 'directorist' ); - return $status; - } + return $status; + } - // Sets file temp destination. - $file_path = "{$temp_dest}/{$file_name}"; + // Sets file temp destination. + $file_path = "{$temp_dest}/{$file_name}"; - set_error_handler( - function ( $errno, $errstr, $errfile, $errline ) { - // error was suppressed with the @-operator - if ( 0 === error_reporting() ) { - return false; - } + set_error_handler( + function ( $errno, $errstr, $errfile, $errline ) { + // error was suppressed with the @-operator + if ( 0 === error_reporting() ) { + return false; + } - throw new ErrorException( $errstr, 0, $errno, $errfile, $errline ); - } - ); + throw new ErrorException( $errstr, 0, $errno, $errfile, $errline ); + } + ); - // Copies the file to the final destination and deletes temporary file. - try { - copy( $tmp_file, $file_path ); - } catch ( Exception $e ) { - $status['success'] = false; - $status['message'] = $e->getMessage(); + // Copies the file to the final destination and deletes temporary file. + try { + copy( $tmp_file, $file_path ); + } catch ( Exception $e ) { + $status['success'] = false; + $status['message'] = $e->getMessage(); - return $status; - } + return $status; + } - @unlink( $tmp_file ); - unzip_file( $file_path, $temp_dest ); + @unlink( $tmp_file ); + unzip_file( $file_path, $temp_dest ); - if ( "{$plugin_path}/" !== $file_path || $file_path !== $plugin_path ) { - @unlink( $file_path ); - } + if ( "{$plugin_path}/" !== $file_path || $file_path !== $plugin_path ) { + @unlink( $file_path ); + } - $extracted_file_dir = glob( "{$temp_dest}/*", GLOB_ONLYDIR ); + $extracted_file_dir = glob( "{$temp_dest}/*", GLOB_ONLYDIR ); - foreach ( $extracted_file_dir as $dir_path ) { - $dir_name = basename( $dir_path ); - $dest_path = "{$plugin_path}/{$dir_name}"; + foreach ( $extracted_file_dir as $dir_path ) { + $dir_name = basename( $dir_path ); + $dest_path = "{$plugin_path}/{$dir_name}"; - // Delete Previous Files if Exists - if ( $wp_filesystem->exists( $dest_path ) ) { - $wp_filesystem->delete( $dest_path, true ); - } - } + // Delete Previous Files if Exists + if ( $wp_filesystem->exists( $dest_path ) ) { + $wp_filesystem->delete( $dest_path, true ); + } + } - copy_dir( $temp_dest, $plugin_path ); - $wp_filesystem->delete( $temp_dest, true ); + copy_dir( $temp_dest, $plugin_path ); + $wp_filesystem->delete( $temp_dest, true ); - $status['success'] = true; - $status['message'] = __( 'The plugin has been downloaded successfully', 'directorist' ); + $status['success'] = true; + $status['message'] = __( 'The plugin has been downloaded successfully', 'directorist' ); - return $status; + return $status; } /** @@ -4542,78 +4632,81 @@ function directorist_is_user_registration_enabled() { } function directorist_hex_to_rgb( $hex ) { - $hex = str_replace( "#", "", $hex ); + $hex = str_replace( '#', '', $hex ); - if ( strlen( $hex ) == 3 ) { - $r = hexdec( str_repeat( substr( $hex, 0, 1 ), 2 ) ); - $g = hexdec( str_repeat( substr( $hex, 1, 1 ), 2 ) ); - $b = hexdec( str_repeat( substr( $hex, 2, 1 ), 2 ) ); - } else { - $r = hexdec( substr( $hex, 0, 2 ) ); - $g = hexdec( substr( $hex, 2, 2 ) ); - $b = hexdec( substr( $hex, 4, 2 ) ); - } - return "$r, $g, $b"; + if ( strlen( $hex ) == 3 ) { + $r = hexdec( str_repeat( substr( $hex, 0, 1 ), 2 ) ); + $g = hexdec( str_repeat( substr( $hex, 1, 1 ), 2 ) ); + $b = hexdec( str_repeat( substr( $hex, 2, 1 ), 2 ) ); + } else { + $r = hexdec( substr( $hex, 0, 2 ) ); + $g = hexdec( substr( $hex, 2, 2 ) ); + $b = hexdec( substr( $hex, 4, 2 ) ); + } + return "$r, $g, $b"; } /** * Determine post status based on pricing plan. * - * @param int $listing_id + * @param int $listing_id * @param string $default_status * @return string */ function directorist_get_pricing_plan_status( $listing_id, $default_status ) { - $plan_id = (int) get_post_meta( $listing_id, '_fm_plans', true ); - $plan_meta = get_post_meta( $plan_id ); - $plan_type = ( isset( $plan_meta['plan_type'] ) && isset( $plan_meta['plan_type'][0] ) ) ? $plan_meta['plan_type'][0] : ''; + $plan_id = (int) get_post_meta( $listing_id, '_fm_plans', true ); + $plan_meta = get_post_meta( $plan_id ); + $plan_type = ( isset( $plan_meta['plan_type'] ) && isset( $plan_meta['plan_type'][0] ) ) ? $plan_meta['plan_type'][0] : ''; - $listing_id_for_plan = ( 'pay_per_listng' === $plan_type ) ? $listing_id : false; - $plan_purchased = subscribed_package_or_PPL_plans( get_current_user_id(), 'completed', $plan_id, $listing_id_for_plan ); + $listing_id_for_plan = ( 'pay_per_listng' === $plan_type ) ? $listing_id : false; + $plan_purchased = subscribed_package_or_PPL_plans( get_current_user_id(), 'completed', $plan_id, $listing_id_for_plan ); - return $plan_purchased ? $default_status : 'pending'; + return $plan_purchased ? $default_status : 'pending'; } /** * Determine post status for featured listings. * - * @param int $listing_id + * @param int $listing_id * @param string $default_status * @return string */ function directorist_get_featured_listing_status( $listing_id, $default_status ) { - $order = atbdp_get_listing_order( $listing_id ); + $order = atbdp_get_listing_order( $listing_id ); - if ( $order ) { - $payment_status = get_post_meta( $order->ID, '_payment_status', true ); - return ( 'completed' === $payment_status ) ? $default_status : 'pending'; - } + if ( $order ) { + $payment_status = get_post_meta( $order->ID, '_payment_status', true ); + return ( 'completed' === $payment_status ) ? $default_status : 'pending'; + } - return $default_status; + return $default_status; } function directorist_get_distance_range( $miles ) { - // Set default values for min and max distance - $min_distance = 0; - $max_distance = 100; + // Set default values for min and max distance + $min_distance = 0; + $max_distance = 100; - // Check if the 'miles' parameter is in the "min-max" format - if ( !empty( $miles ) && strpos( $miles, '-' ) !== false ) { - $miles = sanitize_text_field( $miles ); + // Check if the 'miles' parameter is in the "min-max" format + if ( ! empty( $miles ) && strpos( $miles, '-' ) !== false ) { + $miles = sanitize_text_field( $miles ); - list( $min_distance, $max_distance ) = explode( '-', $miles ); - $min_distance = floatval( $min_distance ); - $max_distance = floatval( $max_distance ); - } + list( $min_distance, $max_distance ) = explode( '-', $miles ); + $min_distance = floatval( $min_distance ); + $max_distance = floatval( $max_distance ); + } - return array( 'min' => $min_distance, 'max' => $max_distance ); + return array( + 'min' => $min_distance, + 'max' => $max_distance, + ); } /** * Get listing directory id. * * @since 8.0.3 - * @param int $listing_id + * @param int $listing_id * * @return int */ @@ -4651,7 +4744,7 @@ function directorist_get_listing_gallery_images( $listing_id = 0 ) { $images = get_post_meta( $listing_id, '_listing_img', true ); if ( empty( $images ) || ! is_array( $images ) ) { - return []; + return array(); } $images = wp_parse_id_list( $images ); diff --git a/includes/helpers/trait-icon-helper.php b/includes/helpers/trait-icon-helper.php index 79eadc2d0d..62411e2fbd 100644 --- a/includes/helpers/trait-icon-helper.php +++ b/includes/helpers/trait-icon-helper.php @@ -33,7 +33,7 @@ public static function get_icon_src( $icon ) { private static function get_icon_file( $icon ) { - if( empty( $icon ) || ! is_string( $icon ) ) { + if ( empty( $icon ) || ! is_string( $icon ) ) { return ''; } @@ -58,12 +58,12 @@ private static function get_icon_file( $icon ) { private static function get_font_awesome_file( $icon ) { list( $prefix, $name ) = array_pad( explode( ' ', $icon ), 2, '' ); - if ( ! $name ) { + if ( ! $name ) { return ''; } - $filename = str_replace( 'fa-', '', $name ); - $filename = $filename . '.svg'; + $filename = str_replace( 'fa-', '', $name ); + $filename = $filename . '.svg'; $far_file = 'font-awesome/svgs/regular/' . $filename; $fas_file = 'font-awesome/svgs/solid/' . $filename; @@ -102,12 +102,12 @@ private static function get_font_awesome_file( $icon ) { */ private static function get_line_awesome_file( $icon ) { list( $prefix, $name ) = array_pad( explode( ' ', $icon ), 2, '' ); - - if ( ! $name ) { + + if ( ! $name ) { return ''; } - $filename = str_replace( 'la-', '', $name ); + $filename = str_replace( 'la-', '', $name ); $lar_file = 'line-awesome/svgs/' . $filename . '.svg'; $las_file = 'line-awesome/svgs/' . $filename . '-solid.svg'; @@ -175,8 +175,8 @@ private static function get_line_awesome_legacy_file( $filename ) { */ private static function get_unicons_file( $icon ) { list( $prefix, $name ) = array_pad( explode( ' ', $icon ), 2, '' ); - - if ( ! $name ) { + + if ( ! $name ) { return ''; } diff --git a/includes/helpers/trait-markup-helper.php b/includes/helpers/trait-markup-helper.php index 05d7fe382f..16bcf44057 100644 --- a/includes/helpers/trait-markup-helper.php +++ b/includes/helpers/trait-markup-helper.php @@ -5,7 +5,9 @@ namespace Directorist; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} trait Markup_Helper { @@ -28,19 +30,18 @@ public static function directorist_column( $column ) { if ( is_array( $column ) ) { $result = ''; foreach ( $column as $value ) { - $result .= ' directorist-col-'. $value; + $result .= ' directorist-col-' . $value; } - } - else { - $result = 'directorist-col-'. $column; + } else { + $result = 'directorist-col-' . $column; } - $result = apply_filters( 'directorist_column', $result , $column ); + $result = apply_filters( 'directorist_column', $result, $column ); echo esc_attr( $result ); } public static function directorist_single_column() { - $column = is_active_sidebar('right-sidebar-listing') ? 'lg-8' : 'lg-12'; + $column = is_active_sidebar( 'right-sidebar-listing' ) ? 'lg-8' : 'lg-12'; Helper::directorist_column( $column ); } @@ -48,4 +49,4 @@ public static function search_filter_class( $display_type ) { $result = ( 'overlapping' === $display_type ) ? 'directorist-search-float' : 'directorist-search-slide directorist-search-modal'; echo esc_attr( $result ); } -} \ No newline at end of file +} diff --git a/includes/helpers/trait-uri-helper.php b/includes/helpers/trait-uri-helper.php index 0290289e85..4e1d92b33e 100644 --- a/includes/helpers/trait-uri-helper.php +++ b/includes/helpers/trait-uri-helper.php @@ -5,7 +5,9 @@ namespace Directorist; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} trait URI_Helper { @@ -16,7 +18,7 @@ public static function get_template_contents( $template, $args = array() ) { } public static function template_directory() { - $dir = ATBDP_DIR. 'templates/'; + $dir = ATBDP_DIR . 'templates/'; return $dir; } @@ -30,7 +32,7 @@ public static function template_path( $template_name, $args = array() ) { $template = locate_template( $templates ); if ( ! $template ) { - $template = self::template_directory() . "{$template_name}.php";; + $template = self::template_directory() . "{$template_name}.php"; } return apply_filters( 'directorist_template_file_path', $template, $template_name, $args ); @@ -44,14 +46,18 @@ public static function get_template( $template, $args = array(), $shortcode_key // Load extension template if exist if ( ! empty( $shortcode_key ) ) { - $default = [ 'template_directory' => '', 'file_path' => '', 'base_directory' => '' ]; + $default = array( + 'template_directory' => '', + 'file_path' => '', + 'base_directory' => '', + ); $ex_args = apply_filters( "atbdp_ext_template_path_{$shortcode_key}", $default, $args ); $ex_args = array_merge( $default, $ex_args ); $extension_path = atbdp_get_extension_template_path( $ex_args['template_directory'], $ex_args['file_path'], $ex_args['base_directory'] ); if ( file_exists( $extension_path ) ) { - $old_template_data = isset( $GLOBALS['atbdp_template_data'] ) ? $GLOBALS['atbdp_template_data'] : null; + $old_template_data = isset( $GLOBALS['atbdp_template_data'] ) ? $GLOBALS['atbdp_template_data'] : null; $GLOBALS['atbdp_template_data'] = $args; include $extension_path; @@ -62,7 +68,7 @@ public static function get_template( $template, $args = array(), $shortcode_key } $template = apply_filters( 'directorist_template', $template, $args ); - $file = self::template_path( $template, $args ); + $file = self::template_path( $template, $args ); do_action( 'before_directorist_template_loaded', $template, $file, $args ); @@ -78,12 +84,10 @@ public static function get_theme_template_path_for( $template ) { if ( $template_path ) { return $template_path; - } - elseif ( $singular_path ) { + } elseif ( $singular_path ) { return $singular_path; - } - else { + } else { return $index_path; } } -} \ No newline at end of file +} diff --git a/includes/hooks/class-atbdp-hooks.php b/includes/hooks/class-atbdp-hooks.php index 75e8f2dd55..fb7025749e 100644 --- a/includes/hooks/class-atbdp-hooks.php +++ b/includes/hooks/class-atbdp-hooks.php @@ -1,67 +1,67 @@ <?php if ( ! class_exists( 'ATBDP_Hooks' ) ) : - class ATBDP_Hooks { - public $hooks = []; + class ATBDP_Hooks { + public $hooks = array(); - public function __construct() { - $this->hooks = $this->get_hooks(); - $this->register_hooks( $this->hooks ); - } + public function __construct() { + $this->hooks = $this->get_hooks(); + $this->register_hooks( $this->hooks ); + } - /** - * Get Action Hooks - * - * @return array - */ - public function get_hooks() { - return [ - 'title_update' => [ - 'name' => 'the_title', - 'type' => 'action', - 'callback' => ATBDP_Title_Update::class, - 'priority' => 10, - 'args' => 2, - ], - ]; - } + /** + * Get Action Hooks + * + * @return array + */ + public function get_hooks() { + return array( + 'title_update' => array( + 'name' => 'the_title', + 'type' => 'action', + 'callback' => ATBDP_Title_Update::class, + 'priority' => 10, + 'args' => 2, + ), + ); + } - /** - * Register Hooks - * - * @return void - */ - private function register_hooks( array $hooks ) { - if ( ! count( $hooks ) ) { return; } + /** + * Register Hooks + * + * @return void + */ + private function register_hooks( array $hooks ) { + if ( ! count( $hooks ) ) { + return; } - foreach ( $hooks as $hook ) { - self::add_hook( $hook ); - } - } + foreach ( $hooks as $hook ) { + self::add_hook( $hook ); + } + } - /** - * Add Hook - * - * @return void - */ - public static function add_hook( array $hook = [] ) { - if ( class_exists( $hook['callback'] ) ) { - if ( method_exists( $hook['callback'], 'run' ) ) { - $class_name = $hook['callback']; - $callback = new $class_name(); - $priority = ( isset( $hook['priority'] ) ) ? $hook['priority'] : 10; - $accepted_args = ( isset( $hook['args'] ) ) ? $hook['args'] : 1; + /** + * Add Hook + * + * @return void + */ + public static function add_hook( array $hook = array() ) { + if ( class_exists( $hook['callback'] ) ) { + if ( method_exists( $hook['callback'], 'run' ) ) { + $class_name = $hook['callback']; + $callback = new $class_name(); + $priority = ( isset( $hook['priority'] ) ) ? $hook['priority'] : 10; + $accepted_args = ( isset( $hook['args'] ) ) ? $hook['args'] : 1; - if ( 'action' === $hook['type'] ) { - add_action( $hook['name'], [$callback, 'run'], $priority, $accepted_args ); - } + if ( 'action' === $hook['type'] ) { + add_action( $hook['name'], array( $callback, 'run' ), $priority, $accepted_args ); + } - if ( 'filter' === $hook['type'] ) { - add_filter( $hook['name'], [$callback, 'run'], $priority, $accepted_args ); - } - - } - } - } - } -endif; \ No newline at end of file + if ( 'filter' === $hook['type'] ) { + add_filter( $hook['name'], array( $callback, 'run' ), $priority, $accepted_args ); + } + } + } + } + } +endif; diff --git a/includes/hooks/class-atbdp-title-update.php b/includes/hooks/class-atbdp-title-update.php index 6083cf6bc3..0b737a686a 100644 --- a/includes/hooks/class-atbdp-title-update.php +++ b/includes/hooks/class-atbdp-title-update.php @@ -1,46 +1,46 @@ <?php if ( ! class_exists( 'ATBDP_Title_Update' ) ) : - class ATBDP_Title_Update { - // run - public static function run( $title, $id = null ) { - if ( ! in_the_loop() || ! is_main_query() ) { - return $title; - } - - // global $post; - if ( ! is_admin() && ! is_null( $id ) ) { - $post = get_post( $id ); - if ( $post instanceof WP_Post && ( $post->post_type == 'post' || $post->post_type == 'page' ) ) { - $CAT_page_ID = get_directorist_option('single_category_page'); - $LOC_page_ID = get_directorist_option('single_location_page'); - $Tag_page_ID = get_directorist_option('single_tag_page'); - // Change Location page title - if( $post->ID == $LOC_page_ID ) { - if( $slug = get_query_var( 'atbdp_location' ) ) { - $term = get_term_by( 'slug', $slug, ATBDP_LOCATION ); - $title = !empty($term)?$term->name:''; - } - } - // Change Category page title - if( $post->ID == $CAT_page_ID ) { - if( $slug = get_query_var( 'atbdp_category' ) ) { - $term = get_term_by( 'slug', $slug, ATBDP_CATEGORY ); - $title = !empty($term)?$term->name:''; - } - } - // Change Tag page title - if( $post->ID == $Tag_page_ID ) { - if( $slug = get_query_var( 'atbdp_tag' ) ) { - $term = get_term_by( 'slug', $slug, ATBDP_TAGS ); - $title = !empty($term)?$term->name:''; - } - } - } - } + class ATBDP_Title_Update { + // run + public static function run( $title, $id = null ) { + if ( ! in_the_loop() || ! is_main_query() ) { + return $title; + } - return $title; - } - } + // global $post; + if ( ! is_admin() && ! is_null( $id ) ) { + $post = get_post( $id ); + if ( $post instanceof WP_Post && ( $post->post_type == 'post' || $post->post_type == 'page' ) ) { + $CAT_page_ID = get_directorist_option( 'single_category_page' ); + $LOC_page_ID = get_directorist_option( 'single_location_page' ); + $Tag_page_ID = get_directorist_option( 'single_tag_page' ); + // Change Location page title + if ( $post->ID == $LOC_page_ID ) { + if ( $slug = get_query_var( 'atbdp_location' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_LOCATION ); + $title = ! empty( $term ) ? $term->name : ''; + } + } + // Change Category page title + if ( $post->ID == $CAT_page_ID ) { + if ( $slug = get_query_var( 'atbdp_category' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_CATEGORY ); + $title = ! empty( $term ) ? $term->name : ''; + } + } + // Change Tag page title + if ( $post->ID == $Tag_page_ID ) { + if ( $slug = get_query_var( 'atbdp_tag' ) ) { + $term = get_term_by( 'slug', $slug, ATBDP_TAGS ); + $title = ! empty( $term ) ? $term->name : ''; + } + } + } + } -endif; \ No newline at end of file + return $title; + } + } + +endif; diff --git a/includes/model/Account.php b/includes/model/Account.php index d22dbd06ad..a98b4effe4 100644 --- a/includes/model/Account.php +++ b/includes/model/Account.php @@ -1,20 +1,21 @@ <?php - /** - * @author wpWax - */ + /** + * @author wpWax + */ namespace Directorist; -use \ATBDP_Permalink; +use ATBDP_Permalink; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Account { protected static $instance = null; private function __construct() { - } public static function instance() { @@ -24,7 +25,7 @@ public static function instance() { return self::$instance; } - public function render( $atts = [] ) { + public function render( $atts = array() ) { if ( is_user_logged_in() ) { $error_message = sprintf( __( 'The account page is only accessible to logged-out users.<a href="%s">Go to Dashboard</a>', 'directorist' ), esc_url( ATBDP_Permalink::get_dashboard_page_link() ) ); ob_start(); @@ -32,57 +33,60 @@ public function render( $atts = [] ) { return ob_get_clean(); } - $atts = shortcode_atts( array( - 'active_form' => 'signin', - 'user_role' => get_directorist_option( 'display_user_type', false ) ? 'yes' : 'no', - 'author_role_label' => __( 'I am an author', 'directorist' ), - 'user_role_label' => __( 'I am a user', 'directorist' ), - 'username_label' => get_directorist_option( 'reg_username', __( 'Username', 'directorist' ) ), - 'password' => get_directorist_option( 'display_password_reg', true ) ? 'yes' : 'no', - 'password_label' => get_directorist_option( 'reg_password', __( 'Password', 'directorist' ) ), - 'email_label' => get_directorist_option( 'reg_email', __( 'Email ', 'directorist' ) ), - 'website' => get_directorist_option( 'display_website_reg', false ) ? 'yes' : 'no', - 'website_label' => get_directorist_option( 'reg_website', __( 'Website', 'directorist' ) ), - 'website_required' => get_directorist_option( 'require_website_reg', false ) ? 'yes' : 'no', - 'firstname' => get_directorist_option( 'display_fname_reg', false ) ? 'yes' : 'no', - 'firstname_label' => get_directorist_option( 'reg_fname', __( 'First Name', 'directorist' ) ), - 'firstname_required' => get_directorist_option( 'require_fname_reg', false ) ? 'yes' : 'no', - 'lastname' => get_directorist_option( 'display_lname_reg', false ) ? 'yes' : 'no', - 'lastname_label' => get_directorist_option( 'reg_lname', __( 'Last Name', 'directorist' ) ), - 'lastname_required' => get_directorist_option( 'require_lname_reg', false ) ? 'yes' : 'no', - 'bio' => get_directorist_option( 'display_bio_reg', 0 ) ? 'yes' : 'no', - 'bio_label' => get_directorist_option( 'reg_bio', __( 'About/bio', 'directorist' ) ), - 'bio_required' => get_directorist_option( 'require_bio_reg', 0 ) ? 'yes' : 'no', - 'privacy' => get_directorist_option( 'registration_privacy', 1 ) ? 'yes' : 'no', - 'privacy_label' => get_directorist_option( 'registration_privacy_label', __( 'I agree to the', 'directorist' ) ), - 'privacy_linking_text' => get_directorist_option( 'registration_privacy_label_link', __('Privacy & Policy', 'directorist') ), - 'terms' => get_directorist_option( 'regi_terms_condition', 1 ) ? 'yes' : 'no', - 'terms_label' => get_directorist_option( 'regi_terms_label', __( 'I agree with all', 'directorist' ) ), - 'terms_linking_text' => get_directorist_option( 'regi_terms_label_link', 'terms & conditions' ), - 'signup_button_label' => get_directorist_option( 'reg_signup', __( 'Sign Up', 'directorist' ) ), - 'signin_message' => get_directorist_option( 'login_text', __( 'Already have an account? Please Sign in', 'directorist' ) ), - 'signin_linking_text' => get_directorist_option( 'log_linkingmsg', __( 'Here', 'directorist' ) ), - 'signin_after_signup' => get_directorist_option( 'auto_login', 0 ) ? 'yes' : 'no', - 'signup_redirect_url' => '', - // login atts - 'signin_username_label' => get_directorist_option( 'log_username', __( 'Username or Email Address', 'directorist' ) ), - 'signin_button_label' => get_directorist_option( 'log_button', __( 'Sign In', 'directorist' ) ), - 'signup_label' => get_directorist_option( 'reg_text', __( "Don't have an account?", 'directorist' ) ), - 'signup_linking_text' => get_directorist_option( 'reg_linktxt', __( 'Sign Up', 'directorist' ) ), - // recover password atts - 'enable_recovery_password' => get_directorist_option( 'display_recpass', 1 ) ? 'yes' : 'no', - 'recovery_password_label' => get_directorist_option( 'recpass_text', __( 'Forgot Password?', 'directorist' ) ), - 'recovery_password_description' => get_directorist_option( 'recpass_desc', __( 'Lost your password? Please enter your email address. You will receive a link to create a new password via email.', 'directorist' ) ), - 'recovery_password_email_label' => get_directorist_option( 'recpass_username', __( 'E-mail:', 'directorist' ) ), - 'recovery_password_email_placeholder' => get_directorist_option( 'recpass_placeholder', __( 'eg. mail@example.com', 'directorist' ) ), - 'recovery_password_button_label' => get_directorist_option( 'recpass_button', __( 'Get New Password', 'directorist' ) ), - 'user_type' => '' - ), $atts ); + $atts = shortcode_atts( + array( + 'active_form' => 'signin', + 'user_role' => get_directorist_option( 'display_user_type', false ) ? 'yes' : 'no', + 'author_role_label' => __( 'I am an author', 'directorist' ), + 'user_role_label' => __( 'I am a user', 'directorist' ), + 'username_label' => get_directorist_option( 'reg_username', __( 'Username', 'directorist' ) ), + 'password' => get_directorist_option( 'display_password_reg', true ) ? 'yes' : 'no', + 'password_label' => get_directorist_option( 'reg_password', __( 'Password', 'directorist' ) ), + 'email_label' => get_directorist_option( 'reg_email', __( 'Email ', 'directorist' ) ), + 'website' => get_directorist_option( 'display_website_reg', false ) ? 'yes' : 'no', + 'website_label' => get_directorist_option( 'reg_website', __( 'Website', 'directorist' ) ), + 'website_required' => get_directorist_option( 'require_website_reg', false ) ? 'yes' : 'no', + 'firstname' => get_directorist_option( 'display_fname_reg', false ) ? 'yes' : 'no', + 'firstname_label' => get_directorist_option( 'reg_fname', __( 'First Name', 'directorist' ) ), + 'firstname_required' => get_directorist_option( 'require_fname_reg', false ) ? 'yes' : 'no', + 'lastname' => get_directorist_option( 'display_lname_reg', false ) ? 'yes' : 'no', + 'lastname_label' => get_directorist_option( 'reg_lname', __( 'Last Name', 'directorist' ) ), + 'lastname_required' => get_directorist_option( 'require_lname_reg', false ) ? 'yes' : 'no', + 'bio' => get_directorist_option( 'display_bio_reg', 0 ) ? 'yes' : 'no', + 'bio_label' => get_directorist_option( 'reg_bio', __( 'About/bio', 'directorist' ) ), + 'bio_required' => get_directorist_option( 'require_bio_reg', 0 ) ? 'yes' : 'no', + 'privacy' => get_directorist_option( 'registration_privacy', 1 ) ? 'yes' : 'no', + 'privacy_label' => get_directorist_option( 'registration_privacy_label', __( 'I agree to the', 'directorist' ) ), + 'privacy_linking_text' => get_directorist_option( 'registration_privacy_label_link', __( 'Privacy & Policy', 'directorist' ) ), + 'terms' => get_directorist_option( 'regi_terms_condition', 1 ) ? 'yes' : 'no', + 'terms_label' => get_directorist_option( 'regi_terms_label', __( 'I agree with all', 'directorist' ) ), + 'terms_linking_text' => get_directorist_option( 'regi_terms_label_link', 'terms & conditions' ), + 'signup_button_label' => get_directorist_option( 'reg_signup', __( 'Sign Up', 'directorist' ) ), + 'signin_message' => get_directorist_option( 'login_text', __( 'Already have an account? Please Sign in', 'directorist' ) ), + 'signin_linking_text' => get_directorist_option( 'log_linkingmsg', __( 'Here', 'directorist' ) ), + 'signin_after_signup' => get_directorist_option( 'auto_login', 0 ) ? 'yes' : 'no', + 'signup_redirect_url' => '', + // login atts + 'signin_username_label' => get_directorist_option( 'log_username', __( 'Username or Email Address', 'directorist' ) ), + 'signin_button_label' => get_directorist_option( 'log_button', __( 'Sign In', 'directorist' ) ), + 'signup_label' => get_directorist_option( 'reg_text', __( "Don't have an account?", 'directorist' ) ), + 'signup_linking_text' => get_directorist_option( 'reg_linktxt', __( 'Sign Up', 'directorist' ) ), + // recover password atts + 'enable_recovery_password' => get_directorist_option( 'display_recpass', 1 ) ? 'yes' : 'no', + 'recovery_password_label' => get_directorist_option( 'recpass_text', __( 'Forgot Password?', 'directorist' ) ), + 'recovery_password_description' => get_directorist_option( 'recpass_desc', __( 'Lost your password? Please enter your email address. You will receive a link to create a new password via email.', 'directorist' ) ), + 'recovery_password_email_label' => get_directorist_option( 'recpass_username', __( 'E-mail:', 'directorist' ) ), + 'recovery_password_email_placeholder' => get_directorist_option( 'recpass_placeholder', __( 'eg. mail@example.com', 'directorist' ) ), + 'recovery_password_button_label' => get_directorist_option( 'recpass_button', __( 'Get New Password', 'directorist' ) ), + 'user_type' => '', + ), + $atts + ); - $user_type = ! empty( $_REQUEST['user_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['user_type'] ) ) : $atts['user_type']; + $user_type = ! empty( $_REQUEST['user_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['user_type'] ) ) : $atts['user_type']; $active_form = ( isset( $_GET['signup'] ) && directorist_is_user_registration_enabled() ) ? 'signup' : $atts['active_form']; - $data = [ + $data = array( 'enable_user_type' => $atts['user_role'], 'user_type' => $user_type, 'enable_registration_password' => $atts['password'], @@ -100,11 +104,11 @@ public function render( $atts = [] ) { 'auto_login_after_registration' => $atts['signin_after_signup'], 'redirection_after_registration' => $atts['signup_redirect_url'], 'active_form' => $active_form, - ]; + ); wp_localize_script( 'directorist-account', 'directorist_signin_signup_params', $data ); wp_localize_script( 'jquery', 'directorist_signin_signup_params', $data ); - $args = [ + $args = array( 'log_username' => $atts['signin_username_label'], 'log_password' => $atts['password_label'], 'log_button' => $atts['signin_button_label'], @@ -155,8 +159,8 @@ public function render( $atts = [] ) { 'author_role_label' => $atts['author_role_label'], 'user_role_label' => $atts['user_role_label'], 'active_form' => $active_form, - ]; + ); return Helper::get_template_contents( 'account/login-registration-form', $args ); } -} \ No newline at end of file +} diff --git a/includes/model/All_Authors.php b/includes/model/All_Authors.php index 8cf0df2f64..e625e4ea25 100644 --- a/includes/model/All_Authors.php +++ b/includes/model/All_Authors.php @@ -5,12 +5,13 @@ namespace Directorist; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_All_Authors { public function __construct() { - } public function render_shortcode_all_authors() { @@ -18,10 +19,10 @@ public function render_shortcode_all_authors() { } public static function user_image_src( $user ) { - $id = $user->data->ID; - $image_id = get_user_meta( $id, 'pro_pic', true ); - $image_data = wp_get_attachment_image_src( $image_id, 'full' ); // @kowsar @todo size - $image_src = $image_data ? $image_data[0] : get_avatar_url( $id ); + $id = $user->data->ID; + $image_id = get_user_meta( $id, 'pro_pic', true ); + $image_data = wp_get_attachment_image_src( $image_id, 'full' ); // @kowsar @todo size + $image_src = $image_data ? $image_data[0] : get_avatar_url( $id ); return $image_src ? $image_src : ''; } @@ -71,28 +72,28 @@ public function display_pagination() { } public function author_list( $type = '' ) { - $args = array(); + $args = array(); $all_authors_select_role = get_directorist_option( 'all_authors_select_role', 'all' ); - $all_authors_per_page = get_directorist_option( 'all_authors_per_page', 9 ); + $all_authors_per_page = get_directorist_option( 'all_authors_per_page', 9 ); - $paged = ! empty( $_REQUEST['paged'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['paged'] ) ) : atbdp_get_paged_num(); - $offset = ( $paged - 1 ) * $all_authors_per_page; - $args['paged'] = $paged; - $args['offset'] = $offset; + $paged = ! empty( $_REQUEST['paged'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['paged'] ) ) : atbdp_get_paged_num(); + $offset = ( $paged - 1 ) * $all_authors_per_page; + $args['paged'] = $paged; + $args['offset'] = $offset; - if( 'pagination' != $type ) { - $args['number'] = $all_authors_per_page; + if ( 'pagination' != $type ) { + $args['number'] = $all_authors_per_page; } - $args['orderby'] = 'display_name'; + $args['orderby'] = 'display_name'; if ( 'author' == $all_authors_select_role ) { - $meta_query = array( + $meta_query = array( array( 'key' => '_user_type', 'value' => 'author', - 'compare' => '=' - ) + 'compare' => '=', + ), ); $args['meta_query'] = $meta_query; } elseif ( 'all' != $all_authors_select_role ) { @@ -101,31 +102,32 @@ public function author_list( $type = '' ) { // $args['has_published_posts'] = [ ATBDP_POST_TYPE ]; - if( ! empty( $_REQUEST['alphabet'] ) && 'ALL' != $_REQUEST['alphabet'] ) { - $args['search'] = sanitize_text_field( wp_unslash( $_REQUEST['alphabet'] ) ) . '*'; - $args['search_columns'] = array('display_name'); + if ( ! empty( $_REQUEST['alphabet'] ) && 'ALL' != $_REQUEST['alphabet'] ) { + $args['search'] = sanitize_text_field( wp_unslash( $_REQUEST['alphabet'] ) ) . '*'; + $args['search_columns'] = array( 'display_name' ); } return get_users( $args ); } public function author_pagination( $base = '', $paged = '' ) { - $all_authors_per_page = get_directorist_option( 'all_authors_per_page', 9 ); - $query = $this->author_list('pagination'); - $paged = ! empty( $_REQUEST['paged'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['paged'] ) ) : atbdp_get_paged_num(); - $big = 999999999; - $total_pages = ceil( count( $query ) / $all_authors_per_page ); - - $links = paginate_links( array( - 'base' => ! empty( $_REQUEST['paged'] ) || ! empty( $_REQUEST['alphabet'] ) ? 'page/%#%' : str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), - 'format' => '?paged=%#%', - 'current' => max( 1, $paged ), - 'total' => $total_pages, - 'prev_text' => directorist_icon( 'las la-arrow-left', false ), - 'next_text' => directorist_icon( 'las la-arrow-right', false ), - ) ); + $all_authors_per_page = get_directorist_option( 'all_authors_per_page', 9 ); + $query = $this->author_list( 'pagination' ); + $paged = ! empty( $_REQUEST['paged'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['paged'] ) ) : atbdp_get_paged_num(); + $big = 999999999; + $total_pages = ceil( count( $query ) / $all_authors_per_page ); + + $links = paginate_links( + array( + 'base' => ! empty( $_REQUEST['paged'] ) || ! empty( $_REQUEST['alphabet'] ) ? 'page/%#%' : str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), + 'format' => '?paged=%#%', + 'current' => max( 1, $paged ), + 'total' => $total_pages, + 'prev_text' => directorist_icon( 'las la-arrow-left', false ), + 'next_text' => directorist_icon( 'las la-arrow-right', false ), + ) + ); return $links; } - -} \ No newline at end of file +} diff --git a/includes/model/ListingAuthor.php b/includes/model/ListingAuthor.php index 347543ca72..10a122897d 100644 --- a/includes/model/ListingAuthor.php +++ b/includes/model/ListingAuthor.php @@ -7,7 +7,9 @@ use Directorist\database\DB; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Listing_Author { @@ -28,7 +30,7 @@ private function __construct() { public static function instance() { if ( null == self::$instance ) { - self::$instance = new self; + self::$instance = new self(); } return self::$instance; } @@ -52,7 +54,7 @@ private function get_all_posts() { // extract_user_id public function extract_user_id( $user_id = '' ) { - $user_id = urldecode($user_id); //decode the URL to remove encoded spaces, special characters + $user_id = urldecode( $user_id ); // decode the URL to remove encoded spaces, special characters $extracted_user_id = ( is_numeric( $user_id ) ) ? $user_id : get_current_user_id(); if ( is_string( $user_id ) && ! empty( $user_id ) ) { @@ -76,12 +78,11 @@ public function prepare_data() { $this->id = $this->extract_user_id( get_query_var( 'author_id' ) ); if ( ! $this->id ) { - return \ATBDP_Helper::guard( [ 'type' => '404' ] ); + return \ATBDP_Helper::guard( array( 'type' => '404' ) ); } $this->all_listings = $this->get_all_posts(); $this->get_rating(); - } public function get_listing_types() { @@ -89,13 +90,12 @@ public function get_listing_types() { } public function get_current_listing_type() { - $listing_types = $this->get_listing_types(); - $current = !empty($listing_types) ? array_key_first( $listing_types ) : ''; + $listing_types = $this->get_listing_types(); + $current = ! empty( $listing_types ) ? array_key_first( $listing_types ) : ''; - if ( ! empty( $_GET['directory_type' ] ) ) { - $current = sanitize_text_field( wp_unslash( $_GET['directory_type' ] ) ); - } - else if ( get_query_var( 'directory-type' ) ) { + if ( ! empty( $_GET['directory_type'] ) ) { + $current = sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ); + } elseif ( get_query_var( 'directory-type' ) ) { $current = get_query_var( 'directory-type' ); } else { foreach ( $listing_types as $id => $type ) { @@ -107,8 +107,8 @@ public function get_current_listing_type() { } } - if( ! is_numeric( $current ) ) { - $term = get_term_by( 'slug', $current, ATBDP_TYPE ); + if ( ! is_numeric( $current ) ) { + $term = get_term_by( 'slug', $current, ATBDP_TYPE ); $current = ( ! empty( $term ) ) ? $term->term_id : 0; } @@ -118,7 +118,7 @@ public function get_current_listing_type() { // Hooks ------------ public function archive_type( $listings ) { if ( count( $listings->listing_types ) > 1 && directorist_is_multi_directory_enabled() ) { - Helper::get_template( 'archive/directory-type-nav', array('listings' => $listings) ); + Helper::get_template( 'archive/directory-type-nav', array( 'listings' => $listings ) ); } } @@ -138,7 +138,7 @@ public function get_rating() { $average = directorist_get_listing_rating( $listings_id ); if ( $average > 0 ) { - $reviews_sum += $average; + $reviews_sum += $average; $reviews_count += 1; } } @@ -169,7 +169,7 @@ public function author_listings_query() { 'post_type' => ATBDP_POST_TYPE, 'post_status' => 'publish', 'author' => $this->get_id(), - 'posts_per_page' => (int)get_directorist_option( 'all_listing_page_items', 6 ), + 'posts_per_page' => (int) get_directorist_option( 'all_listing_page_items', 6 ), ); if ( ! empty( $paginate ) ) { @@ -192,7 +192,7 @@ public function author_listings_query() { if ( ! empty( $category ) ) { $args['tax_query'] = $category; } - $meta_queries = array(); + $meta_queries = array(); if ( ! empty( $this->current_listing_type ) ) { $meta_queries['meta_query'] = array( @@ -229,7 +229,7 @@ public function avatar_html() { $u_pro_pic = get_user_meta( $author_id, 'pro_pic', true ); $author_data = get_userdata( $author_id ); $display_name = ! empty( $author_data->display_name ) ? $author_data->display_name : ''; - + if ( ! empty( $u_pro_pic ) ) { $html = wp_get_attachment_image( $u_pro_pic ); } @@ -242,48 +242,48 @@ public function avatar_html() { } public function member_since_text() { - $author_id = $this->id; - $user_registered = get_the_author_meta('user_registered', $author_id); - $member_since_text = sprintf(__('Member since %s ago', 'directorist'), human_time_diff(strtotime($user_registered), current_time('timestamp'))); + $author_id = $this->id; + $user_registered = get_the_author_meta( 'user_registered', $author_id ); + $member_since_text = sprintf( __( 'Member since %s ago', 'directorist' ), human_time_diff( strtotime( $user_registered ), current_time( 'timestamp' ) ) ); return $member_since_text; } public function review_count_html() { - $review_count = $this->total_review; + $review_count = $this->total_review; $review_count_html = sprintf( _nx( '%s Review', '%s Reviews', $review_count, 'author review count', 'directorist' ), $review_count ); return $review_count_html; } public function listing_count_html() { - $listing_count = ! empty( $this->all_listings ) ? $this->all_listings->total : ''; + $listing_count = ! empty( $this->all_listings ) ? $this->all_listings->total : ''; $listing_count_html = sprintf( _nx( '<span>%s</span> Listing', '<span>%s</span> Listings', $listing_count, 'author review count', 'directorist' ), $listing_count ); return $listing_count_html; } public function review_enabled() { - return get_directorist_option('enable_review', 1); + return get_directorist_option( 'enable_review', 1 ); } public function rating_count() { - $rating = $this->rating; + $rating = $this->rating; $rating_count = sprintf( '<span>%s</span>', $rating, 'directorist' ); return $rating_count; } public function display_name() { $author_id = $this->id; - return get_the_author_meta('display_name', $author_id); + return get_the_author_meta( 'display_name', $author_id ); } public function header_template() { $author_id = $this->id; - Helper::get_template( 'author/header', [ 'author' => $this ] ); + Helper::get_template( 'author/header', array( 'author' => $this ) ); } public function about_template() { $author_id = $this->id; - $bio = get_user_meta($author_id, 'description', true); + $bio = get_user_meta( $author_id, 'description', true ); $bio = trim( $bio ); $display_email = get_user_meta( $author_id, 'directorist_display_author_email', true ); @@ -291,26 +291,24 @@ public function about_template() { if ( $display_email == 'public' ) { $email_endabled = true; - } - elseif ( $display_email == 'logged_in' && is_user_logged_in() ) { + } elseif ( $display_email == 'logged_in' && is_user_logged_in() ) { $email_endabled = true; - } - else { + } else { $email_endabled = false; } $args = array( 'author' => $this, 'bio' => nl2br( $bio ), - 'address' => get_user_meta($author_id, 'address', true), - 'phone' => get_user_meta($author_id, 'atbdp_phone', true), + 'address' => get_user_meta( $author_id, 'address', true ), + 'phone' => get_user_meta( $author_id, 'atbdp_phone', true ), 'email_endabled' => $email_endabled, - 'email' => get_the_author_meta('user_email', $author_id), - 'website' => get_the_author_meta('user_url', $author_id), - 'facebook' => get_user_meta($author_id, 'atbdp_facebook', true), - 'twitter' => get_user_meta($author_id, 'atbdp_twitter', true), - 'linkedin' => get_user_meta($author_id, 'atbdp_linkedin', true), - 'youtube' => get_user_meta($author_id, 'atbdp_youtube', true), + 'email' => get_the_author_meta( 'user_email', $author_id ), + 'website' => get_the_author_meta( 'user_url', $author_id ), + 'facebook' => get_user_meta( $author_id, 'atbdp_facebook', true ), + 'twitter' => get_user_meta( $author_id, 'atbdp_twitter', true ), + 'linkedin' => get_user_meta( $author_id, 'atbdp_linkedin', true ), + 'youtube' => get_user_meta( $author_id, 'atbdp_youtube', true ), ); Helper::get_template( 'author/about', $args ); @@ -327,7 +325,7 @@ public function author_listings_template() { public function get_listings() { $query = $this->author_listings_query(); - $listings = new Directorist_Listings( NULL, NULL, $query, ['cache' => false] ); + $listings = new Directorist_Listings( null, null, $query, array( 'cache' => false ) ); return $listings; } @@ -337,7 +335,7 @@ public function cat_filter_enabled() { } public function get_listing_categories() { - return get_terms( ATBDP_CATEGORY , array( 'hide_empty' => 0 ) ); + return get_terms( ATBDP_CATEGORY, array( 'hide_empty' => 0 ) ); } public function listing_pagination_enabled() { @@ -346,10 +344,13 @@ public function listing_pagination_enabled() { public function render_shortcode_author_profile( $atts ) { - $atts = shortcode_atts( array( - 'logged_in_user_only' => '', - 'redirect_page_url' => '', - ), $atts ); + $atts = shortcode_atts( + array( + 'logged_in_user_only' => '', + 'redirect_page_url' => '', + ), + $atts + ); $logged_in_user_only = $atts['logged_in_user_only']; $redirect_page_url = $atts['redirect_page_url']; @@ -361,13 +362,13 @@ public function render_shortcode_author_profile( $atts ) { } if ( 'yes' === $logged_in_user_only && ! is_user_logged_in() ) { - return ATBDP()->helper->guard( array('type' => 'auth') ); + return ATBDP()->helper->guard( array( 'type' => 'auth' ) ); } if ( ! is_user_logged_in() && ! $this->id ) { - return ATBDP()->helper->guard( array('type' => '404') ); + return ATBDP()->helper->guard( array( 'type' => '404' ) ); } return Helper::get_template_contents( 'author-contents', array( 'author' => $this ) ); } -} \ No newline at end of file +} diff --git a/includes/model/ListingDashboard.php b/includes/model/ListingDashboard.php index bc616f93c2..3e1e79eeca 100644 --- a/includes/model/ListingDashboard.php +++ b/includes/model/ListingDashboard.php @@ -8,11 +8,13 @@ use ATBDP_Permalink; use Directorist\database\DB; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Listing_Dashboard { - protected static $instance = null; + protected static $instance = null; public static $display_title = false; public $id; @@ -23,10 +25,10 @@ class Directorist_Listing_Dashboard { public $become_author_button_text; private function __construct() { - $this->id = get_current_user_id(); - $user_type = get_user_meta( get_current_user_id(), '_user_type', true ); - $this->user_type = ! empty( $user_type ) ? $user_type : ''; - $this->become_author_button = get_directorist_option( 'become_author_button', 1); + $this->id = get_current_user_id(); + $user_type = get_user_meta( get_current_user_id(), '_user_type', true ); + $this->user_type = ! empty( $user_type ) ? $user_type : ''; + $this->become_author_button = get_directorist_option( 'become_author_button', 1 ); $this->become_author_button_text = get_directorist_option( 'become_author_button_text', __( 'Become An Author', 'directorist' ) ); } @@ -59,10 +61,10 @@ public function ajax_listing_tab() { 'query' => $this->listings_query( $tab, $paged, $search ), ); - $result = [ + $result = array( 'content' => Helper::get_template_contents( 'dashboard/listing-row', $args ), 'pagination' => $this->listing_pagination( 'page/%#%', $paged ), - ]; + ); wp_send_json_success( $result ); @@ -89,9 +91,9 @@ public function listings_query( $status = 'all', $paged = 1, $search = '' ) { 'orderby' => 'date', ); - if ( $pagination_enabled) { + if ( $pagination_enabled ) { $args['paged'] = $paged; - } else{ + } else { $args['no_found_rows'] = false; } @@ -111,14 +113,13 @@ public function listings_query( $status = 'all', $paged = 1, $search = '' ) { } public function get_listing_price_html() { - $id = get_the_ID(); - $price = get_post_meta( $id, '_price', true ); - $price_range = get_post_meta( $id, '_price_range', true ); + $id = get_the_ID(); + $price = get_post_meta( $id, '_price', true ); + $price_range = get_post_meta( $id, '_price_range', true ); $atbd_listing_pricing = get_post_meta( $id, '_atbd_listing_pricing', true ); - if (!empty($price_range) && ('range' === $atbd_listing_pricing)) { + if ( ! empty( $price_range ) && ( 'range' === $atbd_listing_pricing ) ) { return atbdp_display_price_range( $price_range ); - } - else { + } else { return atbdp_display_price( $price ); } } @@ -158,62 +159,64 @@ public function listing_pagination( $base = '', $paged = '' ) { $paged = $paged ? $paged : atbdp_get_paged_num(); $big = 999999999; - $links = paginate_links(array( - 'base' => $base ? $base : str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), - 'format' => '?paged=%#%', - 'current' => max(1, $paged), - 'total' => $query->max_num_pages, - 'prev_text' => directorist_icon( 'fas fa-chevron-left', false ), - 'next_text' => directorist_icon( 'fas fa-chevron-right', false ), - )); + $links = paginate_links( + array( + 'base' => $base ? $base : str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), + 'format' => '?paged=%#%', + 'current' => max( 1, $paged ), + 'total' => $query->max_num_pages, + 'prev_text' => directorist_icon( 'fas fa-chevron-left', false ), + 'next_text' => directorist_icon( 'fas fa-chevron-right', false ), + ) + ); return $links; } public function get_listing_status_html() { - $id = get_the_ID(); + $id = get_the_ID(); $status_label = get_post_status_object( get_post_status( $id ) )->label; - $html = sprintf('<span class="directorist_badge dashboard-badge directorist_status_%s">%s</span>', strtolower($status_label), $status_label ); + $html = sprintf( '<span class="directorist_badge dashboard-badge directorist_status_%s">%s</span>', strtolower( $status_label ), $status_label ); return $html; } public function get_listing_type() { $type = directorist_get_listing_directory( get_the_ID() ); $term = get_term( $type ); - return !empty( $term->name ) ? $term->name : ''; + return ! empty( $term->name ) ? $term->name : ''; } public function get_listing_thumbnail() { - $id = get_the_ID(); - $type = directorist_get_listing_directory( $id ); + $id = get_the_ID(); + $type = directorist_get_listing_directory( $id ); $default_image_src = Helper::default_preview_image_src( $type ); - $image_quality = get_directorist_option('preview_image_quality', 'directorist_preview'); + $image_quality = get_directorist_option( 'preview_image_quality', 'directorist_preview' ); $listing_prv_img = directorist_get_listing_preview_image( $id ); $listing_img = directorist_get_listing_gallery_images( $id ); if ( is_array( $listing_img ) && ! empty( $listing_img[0] ) ) { $thumbnail_img = atbdp_get_image_source( $listing_img[0], $image_quality ); - $thumbnail_id = $listing_img[0]; + $thumbnail_id = $listing_img[0]; } if ( ! empty( $listing_prv_img ) ) { $thumbnail_img = atbdp_get_image_source( $listing_prv_img, $image_quality ); - $thumbnail_id = $listing_prv_img; + $thumbnail_id = $listing_prv_img; } if ( ! empty( $img_src ) ) { $thumbnail_img = $img_src; - $thumbnail_id = 0; + $thumbnail_id = 0; } if ( empty( $thumbnail_img ) ) { $thumbnail_img = $default_image_src; - $thumbnail_id = 0; + $thumbnail_id = 0; } - $image_src = is_array($thumbnail_img) ? $thumbnail_img['url'] : $thumbnail_img; - $image_alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true); + $image_src = is_array( $thumbnail_img ) ? $thumbnail_img['url'] : $thumbnail_img; + $image_alt = get_post_meta( $thumbnail_id, '_wp_attachment_image_alt', true ); $image_alt = ( ! empty( $image_alt ) ) ? esc_attr( $image_alt ) : esc_html( get_the_title( $thumbnail_id ) ); $image_alt = ( ! empty( $image_alt ) ) ? $image_alt : esc_html( get_the_title() ); @@ -225,7 +228,7 @@ public function fav_listing_items() { $fav_listings = DB::favorite_listings_query(); - if ( $fav_listings->have_posts() ){ + if ( $fav_listings->have_posts() ) { foreach ( $fav_listings->posts as $post ) { $listing_type = directorist_get_listing_directory( $post->ID ); $title = ! empty( $post->post_title ) ? $post->post_title : __( 'Untitled', 'directorist' ); @@ -234,21 +237,20 @@ public function fav_listing_items() { $category_name = ! empty( $cats ) ? $cats[0]->name : 'Uncategorized'; $mark_fav_html = atbdp_listings_mark_as_favourite( $post->ID ); - - if (!empty($cats)) { - $cat_icon = get_cat_icon($cats[0]->term_id); + if ( ! empty( $cats ) ) { + $cat_icon = get_cat_icon( $cats[0]->term_id ); } - $cat_icon = !empty($cat_icon) ? $cat_icon : 'las la-tags'; - $icon = directorist_icon( $cat_icon, false ); + $cat_icon = ! empty( $cat_icon ) ? $cat_icon : 'las la-tags'; + $icon = directorist_icon( $cat_icon, false ); $category_link = ! empty( $cats ) ? esc_url( ATBDP_Permalink::atbdp_get_category_page( $cats[0] ) ) : '#'; $post_link = esc_url( get_post_permalink( $post->ID ) ); - $listing_img = directorist_get_listing_gallery_images( $post->ID ); - $listing_prv_img = directorist_get_listing_preview_image( $post->ID ); - $default_image_src = Helper::default_preview_image_src( $listing_type ); - $crop_width = get_directorist_option( 'crop_width', 360 ); - $crop_height = get_directorist_option( 'crop_height', 300 ); + $listing_img = directorist_get_listing_gallery_images( $post->ID ); + $listing_prv_img = directorist_get_listing_preview_image( $post->ID ); + $default_image_src = Helper::default_preview_image_src( $listing_type ); + $crop_width = get_directorist_option( 'crop_width', 360 ); + $crop_height = get_directorist_option( 'crop_height', 300 ); if ( ! empty( $listing_prv_img ) ) { $prv_image = atbdp_get_image_source( $listing_prv_img, 'large' ); @@ -286,74 +288,74 @@ public function fav_listing_items() { } public function user_info( $type ) { - $id = $this->id; + $id = $this->id; $userdata = get_userdata( $id ); - $result = ''; + $result = ''; switch ( $type ) { case 'display_name': - $result = $userdata->display_name; - break; + $result = $userdata->display_name; + break; case 'username': - $result = $userdata->user_login; - break; + $result = $userdata->user_login; + break; case 'first_name': - $result = $userdata->first_name; - break; + $result = $userdata->first_name; + break; case 'last_name': - $result = $userdata->last_name; - break; + $result = $userdata->last_name; + break; case 'email': - $result = $userdata->user_email; - break; + $result = $userdata->user_email; + break; case 'phone': - $result = get_user_meta( $id, 'atbdp_phone', true ); - break; + $result = get_user_meta( $id, 'atbdp_phone', true ); + break; case 'website': - $result = $userdata->user_url; - break; + $result = $userdata->user_url; + break; case 'address': - $result = get_user_meta( $id, 'address', true ); - break; + $result = get_user_meta( $id, 'address', true ); + break; case 'facebook': - $result = get_user_meta( $id, 'atbdp_facebook', true ); - break; + $result = get_user_meta( $id, 'atbdp_facebook', true ); + break; case 'twitter': - $result = get_user_meta( $id, 'atbdp_twitter', true ); - break; + $result = get_user_meta( $id, 'atbdp_twitter', true ); + break; case 'linkedin': - $result = get_user_meta( $id, 'atbdp_linkedin', true ); - break; + $result = get_user_meta( $id, 'atbdp_linkedin', true ); + break; case 'youtube': - $result = get_user_meta( $id, 'atbdp_youtube', true ); - break; + $result = get_user_meta( $id, 'atbdp_youtube', true ); + break; case 'bio': - $result = get_user_meta( $id, 'description', true ); - break; + $result = get_user_meta( $id, 'description', true ); + break; case 'hide_contact_form': - $result = get_user_meta( $id, 'directorist_hide_contact_form', true ); - break; + $result = get_user_meta( $id, 'directorist_hide_contact_form', true ); + break; case 'display_author_email': - $result = get_user_meta( $id, 'directorist_display_author_email', true ); - break; + $result = get_user_meta( $id, 'directorist_display_author_email', true ); + break; case 'contact_owner_recipient': - $result = get_user_meta( $id, 'directorist_contact_owner_recipient', true ); - break; + $result = get_user_meta( $id, 'directorist_contact_owner_recipient', true ); + break; } return $result; @@ -363,10 +365,10 @@ public function dashboard_tabs() { // Tabs $dashboard_tabs = array(); - $my_listing_tab = get_directorist_option( 'my_listing_tab', 1 ); - $my_profile_tab = get_directorist_option( 'my_profile_tab', 1 ); - $fav_listings_tab = get_directorist_option( 'fav_listings_tab', 1 ); - $announcement_tab = get_directorist_option( 'announcement_tab', 1 ); + $my_listing_tab = get_directorist_option( 'my_listing_tab', 1 ); + $my_profile_tab = get_directorist_option( 'my_profile_tab', 1 ); + $fav_listings_tab = get_directorist_option( 'fav_listings_tab', 1 ); + $announcement_tab = get_directorist_option( 'announcement_tab', 1 ); if ( $my_listing_tab && ( 'general' != $this->user_type && 'become_author' != $this->user_type ) ) { $my_listing_tab_text = get_directorist_option( 'my_listing_tab_text', __( 'My Listing', 'directorist' ) ); @@ -375,57 +377,57 @@ public function dashboard_tabs() { $list_found = $listings->found_posts; $dashboard_tabs['dashboard_my_listings'] = array( - 'title' => sprintf( '%1$s (%2$s)', $my_listing_tab_text, $list_found ), - 'content' => Helper::get_template_contents( 'dashboard/tab-my-listings', [ 'dashboard' => $this ] ), - 'icon' => 'las la-list', + 'title' => sprintf( '%1$s (%2$s)', $my_listing_tab_text, $list_found ), + 'content' => Helper::get_template_contents( 'dashboard/tab-my-listings', array( 'dashboard' => $this ) ), + 'icon' => 'las la-list', ); } if ( $my_profile_tab ) { $dashboard_tabs['dashboard_profile'] = array( - 'title' => get_directorist_option('my_profile_tab_text', __('My Profile', 'directorist')), - 'icon' => 'las la-user', - 'content' => Helper::get_template_contents( 'dashboard/tab-profile', [ 'dashboard' => $this ] ), + 'title' => get_directorist_option( 'my_profile_tab_text', __( 'My Profile', 'directorist' ) ), + 'icon' => 'las la-user', + 'content' => Helper::get_template_contents( 'dashboard/tab-profile', array( 'dashboard' => $this ) ), ); } if ( $fav_listings_tab ) { $dashboard_tabs['dashboard_fav_listings'] = array( - 'title' => get_directorist_option('fav_listings_tab_text', __('Favorite Listings', 'directorist')), - 'content' => Helper::get_template_contents( 'dashboard/tab-fav-listings', [ 'dashboard' => $this ] ), - 'icon' => 'las la-heart', + 'title' => get_directorist_option( 'fav_listings_tab_text', __( 'Favorite Listings', 'directorist' ) ), + 'content' => Helper::get_template_contents( 'dashboard/tab-fav-listings', array( 'dashboard' => $this ) ), + 'icon' => 'las la-heart', ); } $dashboard_tabs['dashboard_preferences'] = array( - 'title' => __( 'Preferences', 'directorist' ), - 'content' => Helper::get_template_contents( 'dashboard/tab-preferences', [ 'dashboard' => $this ] ), - 'icon' => 'las la-sliders-h', + 'title' => __( 'Preferences', 'directorist' ), + 'content' => Helper::get_template_contents( 'dashboard/tab-preferences', array( 'dashboard' => $this ) ), + 'icon' => 'las la-sliders-h', ); return apply_filters( 'directorist_dashboard_tabs', $dashboard_tabs ); } public function get_announcements() { - $announcements = []; + $announcements = array(); $announcements_query = \ATBDP()->announcement::get_announcement_query_data(); $current_user_email = get_the_author_meta( 'user_email', get_current_user_id() ); foreach ( $announcements_query->posts as $announcement ) { - $id = $announcement->ID; + $id = $announcement->ID; $recepents = get_post_meta( $id, '_recepents', true ); - $recepents = ! empty( $recepents ) ? explode( ',', $recepents ) : []; + $recepents = ! empty( $recepents ) ? explode( ',', $recepents ) : array(); - if ( ! empty( $recepents ) && is_array( $recepents ) ) { + if ( ! empty( $recepents ) && is_array( $recepents ) ) { if ( ! in_array( $current_user_email, $recepents ) ) { continue; } } - $announcements[$id] = [ + $announcements[ $id ] = array( 'title' => get_the_title( $id ), 'content' => $announcement->post_content, - ]; + ); } return $announcements; @@ -441,22 +443,21 @@ public function restrict_access_template() { } public function profile_pic_template() { - Helper::get_template( 'dashboard/profile-pic', [ 'dashboard' => $this ] ); + Helper::get_template( 'dashboard/profile-pic', array( 'dashboard' => $this ) ); } public function notice_template() { - if ( isset($_GET['renew'] ) ) { + if ( isset( $_GET['renew'] ) ) { $renew_token_expired = $_GET['renew'] == 'token_expired' ? true : false; - $renew_succeed = $_GET['renew'] == 'success' ? true : false; - } - else { + $renew_succeed = $_GET['renew'] == 'success' ? true : false; + } else { $renew_token_expired = $renew_succeed = false; } $args = array( - 'dashboard' => $this, + 'dashboard' => $this, 'renew_token_expired' => $renew_token_expired, - 'renew_succeed' => $renew_succeed, + 'renew_succeed' => $renew_succeed, ); Helper::get_template( 'dashboard/notice', $args ); @@ -488,15 +489,15 @@ public function confirmation_text() { } public function navigation_template() { - Helper::get_template( 'dashboard/navigation', [ 'dashboard' => $this ] ); + Helper::get_template( 'dashboard/navigation', array( 'dashboard' => $this ) ); } public function main_contents_template() { - Helper::get_template( 'dashboard/main-contents', [ 'dashboard' => $this ] ); + Helper::get_template( 'dashboard/main-contents', array( 'dashboard' => $this ) ); } public function nav_buttons_template() { - Helper::get_template( 'dashboard/nav-buttons', [ 'dashboard' => $this ] ); + Helper::get_template( 'dashboard/nav-buttons', array( 'dashboard' => $this ) ); } public function user_can_submit() { @@ -504,8 +505,7 @@ public function user_can_submit() { if ( $display_submit_btn && 'general' != $this->user_type && 'become_author' != $this->user_type ) { return true; - } - else { + } else { return false; } } @@ -523,14 +523,14 @@ public function display_title() { } public function render_shortcode( $atts ) { - $atts = shortcode_atts( ['show_title' => ''], $atts ); + $atts = shortcode_atts( array( 'show_title' => '' ), $atts ); self::$display_title = ( $atts['show_title'] == 'yes' ) ? true : false; - if (!is_user_logged_in()) { + if ( ! is_user_logged_in() ) { return $this->restrict_access_template(); } - return Helper::get_template_contents( 'dashboard-contents', [ 'dashboard' => $this ] ); + return Helper::get_template_contents( 'dashboard-contents', array( 'dashboard' => $this ) ); } public function can_renew() { @@ -539,10 +539,10 @@ public function can_renew() { // $status = get_post_meta( $post_id, '_listing_status', true ); // if ( 'renewal' == $status || 'expired' == $status ) { - // $can_renew = get_directorist_option( 'can_renew_listing' ); - // if ( $can_renew ) { - // return true; - // } + // $can_renew = get_directorist_option( 'can_renew_listing' ); + // if ( $can_renew ) { + // return true; + // } // } if ( ! directorist_can_user_renew_listings() ) { @@ -566,7 +566,7 @@ public function can_promote() { // $featured = get_post_meta( $post_id, '_featured', true ); // if ( 'renewal' == $status || 'expired' == $status ) { - // return false; + // return false; // } if ( ! directorist_is_featured_listing_enabled() ) { @@ -592,38 +592,38 @@ public function get_renewal_link( $listing_id ) { } public function get_action_dropdown_item() { - $dropdown_items = apply_filters( 'directorist_dashboard_listing_action_items', [], $this ); + $dropdown_items = apply_filters( 'directorist_dashboard_listing_action_items', array(), $this ); $post_id = get_the_ID(); if ( $this->can_renew() ) { $dropdown_items['renew'] = array( - 'class' => '', - 'data_attr' => '', - 'link' => add_query_arg( 'renew_from', 'dashboard', esc_url( $this->get_renewal_link( $post_id ) ) ), - 'icon' => directorist_icon( 'las la-hand-holding-usd', false ), - 'label' => __( 'Renew', 'directorist' ) + 'class' => '', + 'data_attr' => '', + 'link' => add_query_arg( 'renew_from', 'dashboard', esc_url( $this->get_renewal_link( $post_id ) ) ), + 'icon' => directorist_icon( 'las la-hand-holding-usd', false ), + 'label' => __( 'Renew', 'directorist' ), ); } if ( $this->can_promote() ) { $dropdown_items['promote'] = array( - 'class' => '', - 'data_attr' => '', - 'link' => ATBDP_Permalink::get_checkout_page_link( $post_id ), - 'icon' => directorist_icon( 'las la-ad', false ), - 'label' => __( 'Promote', 'directorist' ) + 'class' => '', + 'data_attr' => '', + 'link' => ATBDP_Permalink::get_checkout_page_link( $post_id ), + 'icon' => directorist_icon( 'las la-ad', false ), + 'label' => __( 'Promote', 'directorist' ), ); } $dropdown_items['delete'] = array( - 'class' => '', - 'data_attr' => 'data-task="delete"', - 'link' => '#', - 'icon' => directorist_icon( 'las la-trash', false ), - 'label' => __( 'Delete Listing', 'directorist' ) + 'class' => '', + 'data_attr' => 'data-task="delete"', + 'link' => '#', + 'icon' => directorist_icon( 'las la-trash', false ), + 'label' => __( 'Delete Listing', 'directorist' ), ); return apply_filters( 'directorist_dashboard_listing_action_items_end', $dropdown_items, $this ); } -} \ No newline at end of file +} diff --git a/includes/model/ListingForm.php b/includes/model/ListingForm.php index 6b1d498670..ff73e1a373 100644 --- a/includes/model/ListingForm.php +++ b/includes/model/ListingForm.php @@ -5,13 +5,15 @@ namespace Directorist; -use \ATBDP_Permalink; +use ATBDP_Permalink; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Listing_Form { - protected static $instance = null; + protected static $instance = null; public static $directory_type = ''; public $add_listing_id; @@ -21,15 +23,13 @@ class Directorist_Listing_Form { private function __construct( $id ) { if ( $id ) { - $this->add_listing_id = $id; + $this->add_listing_id = $id; $this->add_listing_post = get_post( $id ); - } - else { + } else { add_action( 'wp', array( $this, 'init' ) ); } $this->current_listing_type = $this->get_current_listing_type(); - } public static function instance( $id = '' ) { @@ -55,12 +55,11 @@ public function get_add_listing_post() { } public function load_color_picker_script( $data ) { - if( !empty( $data['value'] ) ) { + if ( ! empty( $data['value'] ) ) { ?> <script> jQuery(document).ready(function ($) { $('.directorist-color-field-js').wpColorPicker(); }); </script> <?php - } - else { + } else { ?> <script> jQuery(document).ready(function ($) { $('.directorist-color-field-js').wpColorPicker().empty(); }); </script> <?php @@ -292,13 +291,13 @@ public function get_listing_info() { $p_id = $this->get_add_listing_id(); if ( ! empty( $p_id ) ) { - $listing_info['never_expire'] = get_post_meta( $p_id, '_never_expire', true ); - $listing_info['featured'] = get_post_meta( $p_id, '_featured', true ); - $listing_info['listing_type'] = get_post_meta( $p_id, '_listing_type', true ); - $listing_info['price'] = get_post_meta( $p_id, '_price', true ); - $listing_info['videourl'] = get_post_meta( $p_id, '_videourl', true ); - $listing_info['price_range'] = get_post_meta( $p_id, '_price_range', true ); - $listing_info['atbd_listing_pricing'] = get_post_meta( $p_id, '_atbd_listing_pricing', true ); + $listing_info['never_expire'] = get_post_meta( $p_id, '_never_expire', true ); + $listing_info['featured'] = get_post_meta( $p_id, '_featured', true ); + $listing_info['listing_type'] = get_post_meta( $p_id, '_listing_type', true ); + $listing_info['price'] = get_post_meta( $p_id, '_price', true ); + $listing_info['videourl'] = get_post_meta( $p_id, '_videourl', true ); + $listing_info['price_range'] = get_post_meta( $p_id, '_price_range', true ); + $listing_info['atbd_listing_pricing'] = get_post_meta( $p_id, '_atbd_listing_pricing', true ); // TODO: Status has been migrated, remove related code. // $listing_info['listing_status'] = get_post_meta( $p_id, '_listing_status', true ); $listing_info['listing_status'] = get_post_status( $p_id ); @@ -320,7 +319,7 @@ public function get_listing_info() { $listing_info['bdbh'] = get_post_meta( $p_id, '_bdbh', true ); $listing_info['enable247hour'] = get_post_meta( $p_id, '_enable247hour', true ); $listing_info['disable_bz_hour_listing'] = get_post_meta( $p_id, '_disable_bz_hour_listing', true ); - $listing_info['bdbh_version'] = get_post_meta( $p_id, '_bdbh_version', true ); + $listing_info['bdbh_version'] = get_post_meta( $p_id, '_bdbh_version', true ); $listing_info['hide_contact_info'] = get_post_meta( $p_id, '_hide_contact_info', true ); $listing_info['hide_contact_owner'] = get_post_meta( $p_id, '_hide_contact_owner', true ); $listing_info['expiry_date'] = get_post_meta( $p_id, '_expiry_date', true ); @@ -363,7 +362,7 @@ public function add_listing_terms( $taxonomy ) { $terms = get_the_terms( $this->add_listing_id, $taxonomy ); if ( is_wp_error( $terms ) || empty( $terms ) ) { - return []; + return array(); } return $terms; @@ -416,9 +415,8 @@ public function add_listing_has_contact_info( $args ) { } public function featured_listing_description() { - $description = get_directorist_option('featured_listing_desc', ' (Top of the search result and listings pages for a number days and it requires an additional payment.) '); + $description = get_directorist_option( 'featured_listing_desc', ' (Top of the search result and listings pages for a number days and it requires an additional payment.) ' ); return $description; - } public function required_html() { @@ -441,10 +439,9 @@ public function submit_label() { $p_id = $this->get_add_listing_id(); $type = $this->current_listing_type; - if ( !empty($p_id) ) { - $submit_label = __('Preview Changes', 'directorist'); - } - else { + if ( ! empty( $p_id ) ) { + $submit_label = __( 'Preview Changes', 'directorist' ); + } else { $submit_label = get_directorist_type_option( $type, 'submit_button_label', __( 'Save & Preview', 'directorist' ) ); } return $submit_label; @@ -470,19 +467,19 @@ public function submit_template() { Helper::get_template( 'listing-form/submit', $args ); } - public function social_item_template( $index='', $social_info='' ) { - if ( !$social_info ) { - $index = 'socialindex'; - $social_info = [ - 'id' => '', - 'url' => '', - ]; + public function social_item_template( $index = '', $social_info = '' ) { + if ( ! $social_info ) { + $index = 'socialindex'; + $social_info = array( + 'id' => '', + 'url' => '', + ); } $args = array( - 'listing_form' => $this, - 'index' => $index, - 'social_info' => $social_info, + 'listing_form' => $this, + 'index' => $index, + 'social_info' => $social_info, ); Helper::get_template( 'listing-form/social-item', $args ); @@ -493,10 +490,10 @@ public function generate_linktext( $text ) { preg_match_all( $pattern, $text, $matches ); if ( ! empty( $matches[1] ) ) { - foreach( $matches[1] as $match ) { - $label = $this->terms_privacy_name( $match); + foreach ( $matches[1] as $match ) { + $label = $this->terms_privacy_name( $match ); $link = $this->terms_privacy_link( $match ); - $changed[] = sprintf('<a target="_blank" href="%s">%s</a>', $link, $label); + $changed[] = sprintf( '<a target="_blank" href="%s">%s</a>', $link, $label ); } $result = str_replace( $matches[0], $changed, $text ); @@ -515,7 +512,7 @@ private function terms_privacy_name( $name ) { $name = get_directorist_type_option( $this->current_listing_type, 'privacy_name', __( 'Privacy & Policy', 'directorist' ) ); break; default: - $name = ''; + $name = ''; } return $name; } @@ -529,22 +526,22 @@ private function terms_privacy_link( $name ) { $link = get_directorist_type_option( $this->current_listing_type, 'privacy_link', ATBDP_Permalink::get_privacy_policy_page_url() ); break; default: - $link = ''; + $link = ''; } return $link; } public function type_hidden_field() { - $value = get_post_meta( $this->get_add_listing_id(), '_directory_type', true ); + $value = get_post_meta( $this->get_add_listing_id(), '_directory_type', true ); $current_directory_type = $this->get_current_listing_type(); - $default_directory = default_directory_type(); + $default_directory = default_directory_type(); $directory_type = ! empty( $current_directory_type ) ? $current_directory_type : $default_directory; - $current_type = ! empty( $value ) ? $value : $directory_type; + $current_type = ! empty( $value ) ? $value : $directory_type; printf( '<input type="hidden" name="directory_type" value="%s">', esc_attr( $current_type ) ); } public function field_label_template( $data, $label_id = '' ) { - $key = !empty( $data['field_key'] ) ? $data['field_key'] : 'random-'.rand(); + $key = ! empty( $data['field_key'] ) ? $data['field_key'] : 'random-' . rand(); $args = array( 'listing_form' => $this, 'data' => $data, @@ -573,7 +570,7 @@ public function section_template( $section_data ) { $load_section = apply_filters( 'directorist_section_template', true, $args ); - if( $load_section && ! empty( $section_data['fields'] ) ) { + if ( $load_section && ! empty( $section_data['fields'] ) ) { Helper::get_template( 'listing-form/section', $args ); } } @@ -595,11 +592,11 @@ public function all_fields_only_for_admin( $fields ) { } - public function add_listing_category_custom_field_template( $field_data, $listing_id = NULL ) { + public function add_listing_category_custom_field_template( $field_data, $listing_id = null ) { $value = ''; if ( ! empty( $listing_id ) ) { - $value = get_post_meta( $listing_id, '_'.$field_data['field_key'], true ); + $value = get_post_meta( $listing_id, '_' . $field_data['field_key'], true ); } if ( $field_data['field_key'] === 'hide_contact_owner' && $value == 1 ) { @@ -607,7 +604,7 @@ public function add_listing_category_custom_field_template( $field_data, $listin } $field_data['value'] = $value; - $field_data['form'] = $this; + $field_data['form'] = $this; $args = array( 'listing_form' => $this, @@ -616,8 +613,7 @@ public function add_listing_category_custom_field_template( $field_data, $listin if ( $this->is_custom_field( $field_data ) ) { $template = 'listing-form/custom-fields/' . $field_data['widget_name']; - } - else { + } else { $template = 'listing-form/fields/' . $field_data['widget_name']; } @@ -629,42 +625,34 @@ public function add_listing_category_custom_field_template( $field_data, $listin if ( atbdp_has_admin_template( $admin_template ) ) { atbdp_get_admin_template( $admin_template, $args ); - } - else { + } else { Helper::get_template( $template, $args ); } - } - else { - if ( empty( $field_data['only_for_admin'] ) ) { + } elseif ( empty( $field_data['only_for_admin'] ) ) { Helper::get_template( $template, $args ); - } } - } public function field_template( $field_data ) { - if( ! empty( $field_data['assign_to'] ) ) { + if ( ! empty( $field_data['assign_to'] ) ) { return; } $listing_id = $this->get_add_listing_id(); - $value = ''; + $value = ''; $field_data['lazy_load'] = get_directorist_option( 'lazy_load_taxonomy_fields', true ); if ( ! empty( $listing_id ) ) { if ( $field_data['widget_name'] == 'title' ) { $value = $this->add_listing_post->post_title; - } - elseif ( $field_data['widget_name'] == 'description' ) { + } elseif ( $field_data['widget_name'] == 'description' ) { $value = $this->add_listing_post->post_content; - } - elseif ( $field_data['widget_name'] == 'terms_privacy' ) { + } elseif ( $field_data['widget_name'] == 'terms_privacy' ) { $field_data['privacy_checked'] = (bool) get_post_meta( $listing_id, '_privacy_policy', true ); - } - elseif ( !empty( $field_data['field_key'] ) ) { - $value = get_post_meta( $listing_id, '_'.$field_data['field_key'], true ); + } elseif ( ! empty( $field_data['field_key'] ) ) { + $value = get_post_meta( $listing_id, '_' . $field_data['field_key'], true ); if ( empty( $value ) ) { $value = get_post_meta( $listing_id, $field_data['field_key'], true ); @@ -677,37 +665,34 @@ public function field_template( $field_data ) { } $field_data['value'] = $value; - $field_data['form'] = $this; - $field_data = apply_filters( 'directorist_form_field_data', $field_data ); - + $field_data['form'] = $this; + $field_data = apply_filters( 'directorist_form_field_data', $field_data ); if ( $this->is_custom_field( $field_data ) ) { $template = 'listing-form/custom-fields/' . $field_data['widget_name']; - if( 'checkbox' === $field_data['type'] ){ + if ( 'checkbox' === $field_data['type'] ) { - $options_value = is_array( $value ) ? join( ",",$value ) : $value; - $result = explode( ",", $options_value ); + $options_value = is_array( $value ) ? join( ',', $value ) : $value; + $result = explode( ',', $options_value ); - if( ! is_array( $value ) ){ - $pure_string = trim(preg_replace('/\n+/', ' ', $options_value)); - $result = explode( " ", $pure_string ); + if ( ! is_array( $value ) ) { + $pure_string = trim( preg_replace( '/\n+/', ' ', $options_value ) ); + $result = explode( ' ', $pure_string ); } $field_data['value'] = $result; } - - } - else { + } else { $template = 'listing-form/fields/' . $field_data['widget_name']; } $template = apply_filters( 'directorist_field_template', $template, $field_data ); $args = array( - 'listing_form' => $this, - 'data' => $field_data, + 'listing_form' => $this, + 'data' => $field_data, ); if ( is_admin() ) { @@ -716,22 +701,17 @@ public function field_template( $field_data ) { if ( atbdp_has_admin_template( $admin_template ) ) { atbdp_get_admin_template( $admin_template, $args ); - } - else { + } else { Helper::get_template( $template, $args ); } - } - else { + } elseif ( empty( $field_data['only_for_admin'] ) ) { - if ( empty( $field_data['only_for_admin'] ) ) { Helper::get_template( $template, $args ); - } } - } public function is_custom_field( $data ) { - $fields = [ 'checkbox', 'color_picker', 'date', 'file', 'number', 'radio', 'select', 'text', 'textarea', 'time', 'url' ]; + $fields = array( 'checkbox', 'color_picker', 'date', 'file', 'number', 'radio', 'select', 'text', 'textarea', 'time', 'url' ); return in_array( $data['widget_name'], $fields ) ? true : false; } @@ -761,14 +741,12 @@ public function get_current_listing_type() { if ( $listing_type_count == 1 ) { $type = array_key_first( $listing_types ); - } - elseif( ! empty( $get_listing_type ) ) { + } elseif ( ! empty( $get_listing_type ) ) { $type = $get_listing_type; - } - else { + } else { $type = isset( $_REQUEST['directory_type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['directory_type'] ) ) : ''; } - if( !empty( $type ) && ! is_numeric( $type ) ) { + if ( ! empty( $type ) && ! is_numeric( $type ) ) { $term = get_term_by( 'slug', $type, ATBDP_TYPE ); $type = $term->term_id; } @@ -777,15 +755,15 @@ public function get_current_listing_type() { } public function build_form_data( $type ) { - $form_data = []; + $form_data = array(); - if ( !$type ) { + if ( ! $type ) { return $form_data; } $submission_form_fields = get_term_meta( $type, 'submission_form_fields', true ); - if( ! empty( $submission_form_fields['groups'] ) ) { + if ( ! empty( $submission_form_fields['groups'] ) ) { foreach ( $submission_form_fields['groups'] as $group ) { $section = $group; $section['fields'] = array(); @@ -824,17 +802,16 @@ public function get_map_data() { } public function render_shortcode( $atts ) { - $atts = shortcode_atts( ['directory_type' => ''], $atts ); + $atts = shortcode_atts( array( 'directory_type' => '' ), $atts ); self::$directory_type = $atts['directory_type'] ? explode( ',', $atts['directory_type'] ) : ''; $guest_submission = directorist_is_guest_submission_enabled(); - $user_id = get_current_user_id(); + $user_id = get_current_user_id(); $user_type = get_user_meta( $user_id, '_user_type', true ); if ( ! $guest_submission && ! is_user_logged_in() ) { return \ATBDP_Helper::guard( array( 'type' => 'auth' ) ); - } - elseif( ! empty( $user_type ) && ( 'general' == $user_type || 'become_author' == $user_type ) ) { + } elseif ( ! empty( $user_type ) && ( 'general' == $user_type || 'become_author' == $user_type ) ) { return \ATBDP_Helper::guard( array( 'type' => 'user_type' ) ); } @@ -844,7 +821,7 @@ public function render_shortcode( $atts ) { if ( ! empty( $p_id ) ) { $listing = get_post( $p_id ); if ( $listing->post_author != get_current_user_id() && ! current_user_can( 'edit_others_at_biz_dirs' ) ) { - return Helper::get_template_contents( 'listing-form/restrict-access', [ 'listing_form' => $this ] ); + return Helper::get_template_contents( 'listing-form/restrict-access', array( 'listing_form' => $this ) ); } } @@ -856,7 +833,7 @@ public function render_shortcode( $atts ) { // Edit Mode if ( $p_id ) { $terms = get_the_terms( $p_id, ATBDP_TYPE ); - $type = !empty($terms) ? $terms[0]->term_id : ''; + $type = ! empty( $terms ) ? $terms[0]->term_id : ''; $args['form_data'] = $this->build_form_data( $type ); $args['enable_sidebar'] = (bool) get_directorist_type_option( $type, 'enable_sidebar', 1 ); $args['is_edit_mode'] = true; @@ -866,14 +843,14 @@ public function render_shortcode( $atts ) { // if no listing type exists if ( $listing_type_count == 0 ) { - if( ! directory_types() ) { - if( current_user_can('manage_options') || current_user_can('edit_pages') ) { - $args['error_notice'] = sprintf( __('Please add a directory type first %s', 'directorist' ), '<a href="'. admin_url() .'edit.php?post_type=at_biz_dir&page=atbdp-directory-types">Add Now</a>' ); + if ( ! directory_types() ) { + if ( current_user_can( 'manage_options' ) || current_user_can( 'edit_pages' ) ) { + $args['error_notice'] = sprintf( __( 'Please add a directory type first %s', 'directorist' ), '<a href="' . admin_url() . 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types">Add Now</a>' ); } else { - $args['error_notice'] = __('There\'s something unexpected happen. Please contact site admin.', 'directorist'); + $args['error_notice'] = __( 'There\'s something unexpected happen. Please contact site admin.', 'directorist' ); } } else { - $args['error_notice'] = __('Notice: Your given directory type is not valid. Please use a valid directory type', 'directorist'); + $args['error_notice'] = __( 'Notice: Your given directory type is not valid. Please use a valid directory type', 'directorist' ); } return Helper::get_template_contents( 'listing-form/add-listing-notype', $args ); @@ -891,7 +868,7 @@ public function render_shortcode( $atts ) { } // multiple directory available - $template = Helper::get_template_contents( 'listing-form/add-listing-type', [ 'listing_form' => $this ] ); + $template = Helper::get_template_contents( 'listing-form/add-listing-type', array( 'listing_form' => $this ) ); return apply_filters( 'atbdp_add_listing_page_template', $template, $args ); } } diff --git a/includes/model/ListingTaxonomy.php b/includes/model/ListingTaxonomy.php index 7d9338d33b..aff237bca4 100644 --- a/includes/model/ListingTaxonomy.php +++ b/includes/model/ListingTaxonomy.php @@ -5,9 +5,11 @@ namespace Directorist; -use \ATBDP_Permalink; +use ATBDP_Permalink; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Listing_Taxonomy { @@ -39,63 +41,63 @@ class Directorist_Listing_Taxonomy { public function __construct( $atts = array(), $type = 'category' ) { - $categories_view = get_directorist_option('display_categories_as', 'grid'); - $categories_orderby = get_directorist_option('order_category_by', 'id'); - $categories_order = get_directorist_option('sort_category_by', 'asc'); - $categories_columns = get_directorist_option('categories_column_number', 3); - $categories_show_count = !empty( get_directorist_option('display_listing_count', 1 ) ) ? true : false; - $categories_hide_empty = !empty( get_directorist_option('hide_empty_categories') ) ? true : false; - - $locations_view = get_directorist_option('display_locations_as', 'grid'); - $locations_orderby = get_directorist_option('order_location_by', 'id'); - $locations_order = get_directorist_option('sort_location_by', 'asc'); - $locations_columns = get_directorist_option('locations_column_number', 3); - $locations_show_count = !empty( get_directorist_option('display_location_listing_count', 1 ) ) ? true : false; - $locations_hide_empty = !empty( get_directorist_option('hide_empty_locations') ) ? true : false; - $atts = shortcode_atts(array( - 'view' => ( 'category' == $type ) ? $categories_view : $locations_view , - 'orderby' => ( 'category' == $type ) ? $categories_orderby : $locations_orderby, - 'order' => ( 'category' == $type ) ? $categories_order : $locations_order, - 'cat_per_page' => 100, - 'loc_per_page' => 100, - 'columns' => ( 'category' == $type ) ? $categories_columns : $locations_columns, - 'slug' => '', - 'logged_in_user_only' => '', - 'redirect_page_url' => '', - 'directory_type' => '', - 'default_directory_type' => '', - ), $atts); - - $this->atts = $atts; - $this->type = $type; - $this->tax = ($type == 'category') ? ATBDP_CATEGORY : ATBDP_LOCATION; - - $this->view = $atts['view']; - $this->orderby = $atts['orderby']; - $this->order = $atts['order']; - $this->per_page = ($type == 'category') ? $atts['cat_per_page'] : $atts['loc_per_page']; - $this->columns = ! empty( $atts['columns'] ) ? $atts['columns'] : 3; - $this->slug = $atts['slug']; - $this->logged_in_user_only = $atts['logged_in_user_only'] == 'yes' ? true : false; - $this->redirect_page_url = $atts['redirect_page_url']; - $this->directory_type = ! empty( $atts['directory_type'] ) ? explode( ',', $atts['directory_type'] ) : array(); - $this->directory_type_count = ! empty( $this->directory_type ) ? count( $this->directory_type ) : 0; - $this->default_directory_type = $atts['default_directory_type']; - - $this->show_count = ( 'category' == $type ) ? $categories_show_count : $locations_show_count; - $this->hide_empty = ( 'category' == $type ) ? $categories_hide_empty : $locations_hide_empty; - $this->depth = ($type == 'category') ? get_directorist_option('categories_depth_number', 1) : get_directorist_option('locations_depth_number', 1); - $this->listing_types = $this->get_listing_types(); - $this->current_listing_type = $this->get_current_listing_type(); - $this->set_terms(); + $categories_view = get_directorist_option( 'display_categories_as', 'grid' ); + $categories_orderby = get_directorist_option( 'order_category_by', 'id' ); + $categories_order = get_directorist_option( 'sort_category_by', 'asc' ); + $categories_columns = get_directorist_option( 'categories_column_number', 3 ); + $categories_show_count = ! empty( get_directorist_option( 'display_listing_count', 1 ) ) ? true : false; + $categories_hide_empty = ! empty( get_directorist_option( 'hide_empty_categories' ) ) ? true : false; + + $locations_view = get_directorist_option( 'display_locations_as', 'grid' ); + $locations_orderby = get_directorist_option( 'order_location_by', 'id' ); + $locations_order = get_directorist_option( 'sort_location_by', 'asc' ); + $locations_columns = get_directorist_option( 'locations_column_number', 3 ); + $locations_show_count = ! empty( get_directorist_option( 'display_location_listing_count', 1 ) ) ? true : false; + $locations_hide_empty = ! empty( get_directorist_option( 'hide_empty_locations' ) ) ? true : false; + $atts = shortcode_atts( + array( + 'view' => ( 'category' == $type ) ? $categories_view : $locations_view, + 'orderby' => ( 'category' == $type ) ? $categories_orderby : $locations_orderby, + 'order' => ( 'category' == $type ) ? $categories_order : $locations_order, + 'cat_per_page' => 100, + 'loc_per_page' => 100, + 'columns' => ( 'category' == $type ) ? $categories_columns : $locations_columns, + 'slug' => '', + 'logged_in_user_only' => '', + 'redirect_page_url' => '', + 'directory_type' => '', + 'default_directory_type' => '', + ), + $atts + ); + $this->atts = $atts; + $this->type = $type; + $this->tax = ( $type == 'category' ) ? ATBDP_CATEGORY : ATBDP_LOCATION; + + $this->view = $atts['view']; + $this->orderby = $atts['orderby']; + $this->order = $atts['order']; + $this->per_page = ( $type == 'category' ) ? $atts['cat_per_page'] : $atts['loc_per_page']; + $this->columns = ! empty( $atts['columns'] ) ? $atts['columns'] : 3; + $this->slug = $atts['slug']; + $this->logged_in_user_only = $atts['logged_in_user_only'] == 'yes' ? true : false; + $this->redirect_page_url = $atts['redirect_page_url']; + $this->directory_type = ! empty( $atts['directory_type'] ) ? explode( ',', $atts['directory_type'] ) : array(); + $this->directory_type_count = ! empty( $this->directory_type ) ? count( $this->directory_type ) : 0; + $this->default_directory_type = $atts['default_directory_type']; + + $this->show_count = ( 'category' == $type ) ? $categories_show_count : $locations_show_count; + $this->hide_empty = ( 'category' == $type ) ? $categories_hide_empty : $locations_hide_empty; + $this->depth = ( $type == 'category' ) ? get_directorist_option( 'categories_depth_number', 1 ) : get_directorist_option( 'locations_depth_number', 1 ); + $this->listing_types = $this->get_listing_types(); + $this->current_listing_type = $this->get_current_listing_type(); + $this->set_terms(); } public function set_terms( ?int $current_page = null ) { - $current_page = is_int($current_page) ? $current_page : max( 1, get_query_var( 'paged' ) ); - $offset = ( $current_page - 1 ) * $this->per_page; - - + $current_page = is_int( $current_page ) ? $current_page : max( 1, get_query_var( 'paged' ) ); + $offset = ( $current_page - 1 ) * $this->per_page; $args = array( 'orderby' => $this->orderby, @@ -105,16 +107,16 @@ public function set_terms( ?int $current_page = null ) { 'hierarchical' => false, 'slug' => ! empty( $this->slug ) ? explode( ',', $this->slug ) : '', 'number' => $this->per_page, - 'offset' => $offset, + 'offset' => $offset, ); - if( empty( $_GET['directory_type'] ) || 'all' != $_GET['directory_type'] ) { + if ( empty( $_GET['directory_type'] ) || 'all' != $_GET['directory_type'] ) { $args['meta_query'] = array( array( - 'key' => '_directory_type', - 'value' => 'i:' . absint( $this->current_listing_type ) . ';', - 'compare' => 'Like', - ) + 'key' => '_directory_type', + 'value' => 'i:' . absint( $this->current_listing_type ) . ';', + 'compare' => 'Like', + ), ); } @@ -124,137 +126,150 @@ public function set_terms( ?int $current_page = null ) { $args = apply_filters( 'atbdp_all_locations_argument', $args ); } - $all_terms = get_terms( $this->tax, $args ); - $total_terms = wp_count_terms( $this->tax, array_merge( $args, ['number' => 0, 'offset' => 0] ) ); - - $this->terms = array_slice( $all_terms, $offset, $this->per_page) ; - $this->total_pages = ceil( $total_terms / $this->per_page ); - $this->current_page = $current_page; // Store current page for reference + $all_terms = get_terms( $this->tax, $args ); + $total_terms = wp_count_terms( + $this->tax, + array_merge( + $args, + array( + 'number' => 0, + 'offset' => 0, + ) + ) + ); + $this->terms = array_slice( $all_terms, $offset, $this->per_page ); + $this->total_pages = ceil( $total_terms / $this->per_page ); + $this->current_page = $current_page; // Store current page for reference } - public function grid_count_html($term,$total) { + public function grid_count_html( $term, $total ) { $html = ''; if ( $this->type === 'category' ) { - if ($this->show_count) { - $html = "<span class='directorist-category-count'>" . $total . "</span>"; + if ( $this->show_count ) { + $html = "<span class='directorist-category-count'>" . $total . '</span>'; } - /** - * @since 5.0.0 - */ - return apply_filters('atbdp_all_categories_after_category_name', $html, $term); - } - - else { - if ($this->show_count) { - $html = $total; - } - /** - * @since 5.0.0 - */ - return apply_filters('atbdp_all_locations_after_location_name', $html, $term); - } - } - - public function list_count_html($term,$total) { - $html = ''; - if ($this->show_count) { - $html = ' (' . $total . ')'; - } - return $html; - } - - public function subterms_html($term){ - - if ($this->depth <= 0) { - return; - } - - $args = array( - 'orderby' => $this->orderby, - 'order' => $this->order, - 'hide_empty' => $this->hide_empty, - 'parent' => $term->term_id, - 'hierarchical' => false - ); - - $terms = get_terms($this->tax, $args); - $html = ''; - - if (count($terms) > 0) { - - --$this->depth; - - $html .= '<ul class="directorist-taxonomy-list__sub-item">'; - - foreach ($terms as $term) { - - $child_category = get_term_children($term->term_id, $this->tax); - $toggle_class = !empty($child_category) ? 'directorist-taxonomy-list__sub-item-toggle' : ''; - $plus_icon = !empty($child_category) ? '<span class="directorist-taxonomy-list__sub-item-toggler"></span>' : ''; - $count = 0; - if ($this->hide_empty || $this->show_count) { - $count = ( $this->type == 'category' ) ? atbdp_listings_count_by_category( $term->term_id, $this->current_listing_type ) : atbdp_listings_count_by_location( $term->term_id, $this->current_listing_type ); - - if ($this->hide_empty && 0 == $count) continue; + /** + * @since 5.0.0 + */ + return apply_filters( 'atbdp_all_categories_after_category_name', $html, $term ); + } else { + if ( $this->show_count ) { + $html = $total; + } + /** + * @since 5.0.0 + */ + return apply_filters( 'atbdp_all_locations_after_location_name', $html, $term ); + } + } + + public function list_count_html( $term, $total ) { + $html = ''; + if ( $this->show_count ) { + $html = ' (' . $total . ')'; + } + return $html; + } + + public function subterms_html( $term ) { + + if ( $this->depth <= 0 ) { + return; + } + + $args = array( + 'orderby' => $this->orderby, + 'order' => $this->order, + 'hide_empty' => $this->hide_empty, + 'parent' => $term->term_id, + 'hierarchical' => false, + ); + + $terms = get_terms( $this->tax, $args ); + $html = ''; + + if ( count( $terms ) > 0 ) { + + --$this->depth; + + $html .= '<ul class="directorist-taxonomy-list__sub-item">'; + + foreach ( $terms as $term ) { + + $child_category = get_term_children( $term->term_id, $this->tax ); + $toggle_class = ! empty( $child_category ) ? 'directorist-taxonomy-list__sub-item-toggle' : ''; + $plus_icon = ! empty( $child_category ) ? '<span class="directorist-taxonomy-list__sub-item-toggler"></span>' : ''; + $count = 0; + if ( $this->hide_empty || $this->show_count ) { + $count = ( $this->type == 'category' ) ? atbdp_listings_count_by_category( $term->term_id, $this->current_listing_type ) : atbdp_listings_count_by_location( $term->term_id, $this->current_listing_type ); + + if ( $this->hide_empty && 0 == $count ) { + continue; + } } - if( ! empty( $_GET['directory_type'] ) ) { + if ( ! empty( $_GET['directory_type'] ) ) { $directory_type = sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ); } else { $directory_type = ( 1 == $this->directory_type_count ) ? $this->directory_type[0] : ''; } - $permalink = ( $this->type == 'category' ) ? ATBDP_Permalink::atbdp_get_category_page( $term, $directory_type ) : ATBDP_Permalink::atbdp_get_location_page( $term, $directory_type ); + $permalink = ( $this->type == 'category' ) ? ATBDP_Permalink::atbdp_get_category_page( $term, $directory_type ) : ATBDP_Permalink::atbdp_get_location_page( $term, $directory_type ); - $html .= '<li>'; - $html .= '<a href=" ' . $permalink . ' " class=" ' . $toggle_class . '">'; - $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; - if ($this->show_count) { - $html .= ' (' . $count . ')' . $plus_icon; - } - $html .= "</a>"; - $html .= $this->subterms_html($term); - $html .= '</li>'; - } + $html .= '<li>'; + $html .= '<a href=" ' . $permalink . ' " class=" ' . $toggle_class . '">'; + $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; + if ( $this->show_count ) { + $html .= ' (' . $count . ')' . $plus_icon; + } + $html .= '</a>'; + $html .= $this->subterms_html( $term ); + $html .= '</li>'; + } - $html .= '</ul>'; - } + $html .= '</ul>'; + } - return $html; - } + return $html; + } public function pagination() { - $links = paginate_links( array( - 'base' => esc_url_raw( str_replace( 999999999, '%#%', get_pagenum_link( 999999999, false ) ) ), - 'format' => '', - 'current' => $this->current_page, - 'total' => $this->total_pages, - 'prev_text' => apply_filters( 'directorist_pagination_prev_text', directorist_icon( 'fas fa-chevron-left', false ) ), - 'next_text' => apply_filters( 'directorist_pagination_next_text', directorist_icon( 'fas fa-chevron-right', false ) ), - 'type' => 'array', // Generate an array of links instead of a string - ) ); + $links = paginate_links( + array( + 'base' => esc_url_raw( str_replace( 999999999, '%#%', get_pagenum_link( 999999999, false ) ) ), + 'format' => '', + 'current' => $this->current_page, + 'total' => $this->total_pages, + 'prev_text' => apply_filters( 'directorist_pagination_prev_text', directorist_icon( 'fas fa-chevron-left', false ) ), + 'next_text' => apply_filters( 'directorist_pagination_next_text', directorist_icon( 'fas fa-chevron-right', false ) ), + 'type' => 'array', // Generate an array of links instead of a string + ) + ); if ( ! $links ) { return; } - $links = array_map( function( $link ) { - // Match the page number from the URL (handles both query parameters and path structures) - if ( preg_match( '/page\/([0-9]+)/', $link, $matches ) ) { - // Matches URLs like `/page/2/` - $page_number = $matches[1]; - } elseif ( preg_match( '/paged=([0-9]+)/', $link, $matches ) ) { - // Matches URLs like `?paged=2` - $page_number = $matches[1]; - } else { - $page_number = 1; // Default to page 1 if no number is found - } - - // Add the `data-page` attribute - $link = str_replace( '<a ', '<a data-page="' . esc_attr( $page_number ) . '" ', $link ); - return $link; - }, $links ); + $links = array_map( + function ( $link ) { + // Match the page number from the URL (handles both query parameters and path structures) + if ( preg_match( '/page\/([0-9]+)/', $link, $matches ) ) { + // Matches URLs like `/page/2/` + $page_number = $matches[1]; + } elseif ( preg_match( '/paged=([0-9]+)/', $link, $matches ) ) { + // Matches URLs like `?paged=2` + $page_number = $matches[1]; + } else { + $page_number = 1; // Default to page 1 if no number is found + } + + // Add the `data-page` attribute + $link = str_replace( '<a ', '<a data-page="' . esc_attr( $page_number ) . '" ', $link ); + return $link; + }, + $links + ); ?> <div class="directorist-col-12"> @@ -266,13 +281,13 @@ public function pagination() { <?php } - public function tax_data() { - $result = array(); + public function tax_data() { + $result = array(); + + foreach ( $this->terms as $term ) { - foreach ( $this->terms as $term ) { - - $current_listing_type = $this->current_listing_type; - $count = 0; + $current_listing_type = $this->current_listing_type; + $count = 0; if ( $this->hide_empty || $this->show_count ) { $count = ( $this->type == 'category' ) ? atbdp_listings_count_by_category( $term->term_id, $current_listing_type ) : atbdp_listings_count_by_location( $term->term_id, $current_listing_type ); @@ -281,101 +296,100 @@ public function tax_data() { } } - $expired_listings = atbdp_get_expired_listings( $this->tax, $term->term_id ); + $expired_listings = atbdp_get_expired_listings( $this->tax, $term->term_id ); $number_of_expired = $expired_listings->post_count; - $number_of_expired = !empty($number_of_expired) ? $number_of_expired : '0'; - $total = ($count) ? ($count - $number_of_expired) : $count; + $number_of_expired = ! empty( $number_of_expired ) ? $number_of_expired : '0'; + $total = ( $count ) ? ( $count - $number_of_expired ) : $count; - $image = get_term_meta($term->term_id, 'image', true); + $image = get_term_meta( $term->term_id, 'image', true ); if ( $image ) { - $image = atbdp_get_image_source($image, apply_filters("atbdp_{$this->type}_image_size", array('350', '280'))); - $image = !empty($image) ? $image : ''; + $image = atbdp_get_image_source( $image, apply_filters( "atbdp_{$this->type}_image_size", array( '350', '280' ) ) ); + $image = ! empty( $image ) ? $image : ''; } - $child_terms = get_term_children($term->term_id, $this->tax); - + $child_terms = get_term_children( $term->term_id, $this->tax ); + $directory_type = ''; - if ( isset( $this->directory_type ) && is_array( $this->directory_type ) && count( $this->directory_type ) === 1 ) { + if ( isset( $this->directory_type ) && is_array( $this->directory_type ) && count( $this->directory_type ) === 1 ) { $directory_type = sanitize_text_field( wp_unslash( $this->directory_type[0] ) ); } - if( ! empty( $_GET['directory_type'] ) ) { + if ( ! empty( $_GET['directory_type'] ) ) { $directory_type = sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ); - } + } - if( ! empty( $_GET['directory_type'] ) && 'all' == $_GET['directory_type'] ) { + if ( ! empty( $_GET['directory_type'] ) && 'all' == $_GET['directory_type'] ) { $term_directory_types = get_term_meta( $term->term_id, '_directory_type', true ); if ( is_array( $term_directory_types ) ) { $directory_type = $term_directory_types[0]; - if( $directory_type ) { - $type = get_term_by( 'id', $directory_type, ATBDP_TYPE ); - $directory_type = $type ? $type->slug : ''; + if ( $directory_type ) { + $type = get_term_by( 'id', $directory_type, ATBDP_TYPE ); + $directory_type = $type ? $type->slug : ''; } } - } $permalink = ( $this->type == 'category' ) ? ATBDP_Permalink::atbdp_get_category_page( $term, $directory_type ) : ATBDP_Permalink::atbdp_get_location_page( $term, $directory_type ); - + $data = array( - 'term' => $term, - 'has_child' => !empty($child_terms) ? true : false, - 'name' => $term->name, - 'permalink' => $permalink, - 'count' => $total, - 'grid_count_html' => $this->grid_count_html($term,$total), - 'list_count_html' => $this->list_count_html($term,$total), - 'img' => $image, - 'subterm_html' => ($this->view == 'list') ? $this->subterms_html($term) : '', + 'term' => $term, + 'has_child' => ! empty( $child_terms ) ? true : false, + 'name' => $term->name, + 'permalink' => $permalink, + 'count' => $total, + 'grid_count_html' => $this->grid_count_html( $term, $total ), + 'list_count_html' => $this->list_count_html( $term, $total ), + 'img' => $image, + 'subterm_html' => ( $this->view == 'list' ) ? $this->subterms_html( $term ) : '', ); - if ($this->type == 'category') { - $icon = get_term_meta($term->term_id, 'category_icon', true); - $data['has_icon'] = ( !empty( $icon ) && ( 'none' != $icon ) ) ? true : false; + if ( $this->type == 'category' ) { + $icon = get_term_meta( $term->term_id, 'category_icon', true ); + $data['has_icon'] = ( ! empty( $icon ) && ( 'none' != $icon ) ) ? true : false; $data['icon_class'] = $icon; } $result[] = $data; - } + } - return $result; - } + return $result; + } - public function render_shortcode( $atts = [] ) { + public function render_shortcode( $atts = array() ) { // e_var_dump($atts); - if ( $this->logged_in_user_only && ! is_user_logged_in() ) { - return ATBDP()->helper->guard( array('type' => 'auth') ); - } - - if ($this->redirect_page_url) { - $redirect = '<script>window.location="' . esc_url($this->redirect_page_url) . '"</script>'; - return $redirect; - } - - if ( $this->type == 'category' ) { - $column = $this->columns ? $this->columns : 3; - $args = array( - 'taxonomy' => $this, - 'categories' => $this->tax_data(), - 'grid_container' => apply_filters('atbdp_cat_container_fluid', 'container-fluid'), - 'grid_col_class' => $this->columns == 5 ? 'atbdp_col-5' : 'col-md-' . floor(12 / $column ). ' col-sm-6', - 'list_col_class' => 'col-md-' . floor(12 / $column ), - ); - $template_file = 'taxonomies/categories-'. $this->view; - } else { - $args = array( - 'taxonomy' => $this, - 'locations' => $this->tax_data(), - 'grid_col_class' => $this->columns == 5 ? 'atbdp_col-5' : 'col-md-' . floor(12 / $this->columns). ' col-sm-6', - 'list_col_class' => 'col-md-' . floor(12 / $this->columns), - ); - $template_file = 'taxonomies/locations-'. $this->view; - } - - return Helper::get_template_contents( $template_file, $args ); + if ( $this->logged_in_user_only && ! is_user_logged_in() ) { + return ATBDP()->helper->guard( array( 'type' => 'auth' ) ); + } + + if ( $this->redirect_page_url ) { + $redirect = '<script>window.location="' . esc_url( $this->redirect_page_url ) . '"</script>'; + return $redirect; + } + + if ( $this->type == 'category' ) { + $column = $this->columns ? $this->columns : 3; + $args = array( + 'taxonomy' => $this, + 'categories' => $this->tax_data(), + 'grid_container' => apply_filters( 'atbdp_cat_container_fluid', 'container-fluid' ), + 'grid_col_class' => $this->columns == 5 ? 'atbdp_col-5' : 'col-md-' . floor( 12 / $column ) . ' col-sm-6', + 'list_col_class' => 'col-md-' . floor( 12 / $column ), + ); + $template_file = 'taxonomies/categories-' . $this->view; + } else { + $args = array( + 'taxonomy' => $this, + 'locations' => $this->tax_data(), + 'grid_col_class' => $this->columns == 5 ? 'atbdp_col-5' : 'col-md-' . floor( 12 / $this->columns ) . ' col-sm-6', + 'list_col_class' => 'col-md-' . floor( 12 / $this->columns ), + ); + $template_file = 'taxonomies/locations-' . $this->view; + } + + return Helper::get_template_contents( $template_file, $args ); } /** @@ -402,15 +416,13 @@ public function get_current_listing_type() { $listing_types = $this->get_listing_types(); $listing_type_count = count( $listing_types ); - $current = !empty($listing_types) ? array_key_first( $listing_types ) : ''; + $current = ! empty( $listing_types ) ? array_key_first( $listing_types ) : ''; if ( isset( $_GET['directory_type'] ) ) { - $current = sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ) ; - } - else if( $this->default_directory_type ) { + $current = sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ); + } elseif ( $this->default_directory_type ) { $current = $this->default_directory_type; - } - else { + } else { foreach ( $listing_types as $id => $type ) { $is_default = get_term_meta( $id, '_default', true ); @@ -421,17 +433,23 @@ public function get_current_listing_type() { } } - if( ! is_numeric( $current ) && 'all' != $current ) { - $term = get_term_by( 'slug', $current, ATBDP_TYPE ); + if ( ! is_numeric( $current ) && 'all' != $current ) { + $term = get_term_by( 'slug', $current, ATBDP_TYPE ); $current = $term ? $term->term_id : ''; } return $current; } // Hooks ------------ - public static function archive_type($listings) { + public static function archive_type( $listings ) { if ( count( $listings->listing_types ) > 1 && directorist_is_multi_directory_enabled() ) { - Helper::get_template( 'archive/directory-type-nav', array('listings' => $listings, 'all_types' => true ) ); + Helper::get_template( + 'archive/directory-type-nav', + array( + 'listings' => $listings, + 'all_types' => true, + ) + ); } } } \ No newline at end of file diff --git a/includes/model/Listings.php b/includes/model/Listings.php index 65bd3f90f8..01747417f1 100644 --- a/includes/model/Listings.php +++ b/includes/model/Listings.php @@ -8,14 +8,16 @@ use ATBDP_Permalink; use Directorist\database\DB; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Listings { protected $thumbnails_cached = false; - public $query_args = []; - public $query_results = []; - public $options = []; + public $query_args = array(); + public $query_results = array(); + public $options = array(); public $atts; public $type; @@ -24,7 +26,7 @@ class Directorist_Listings { public $listing_types; public $current_listing_type; - // shortcode properties + // shortcode properties public $view; public $_featured; public $filterby; @@ -129,13 +131,13 @@ class Directorist_Listings { 'locations_fields', ); - public function __construct( $atts = array(), $type = 'listing', $query_args = false, array $caching_options = [] ) { - $this->atts = !empty( $atts ) ? $atts : array(); - $this->type = !empty( $type ) ? $type : 'listing'; + public function __construct( $atts = array(), $type = 'listing', $query_args = false, array $caching_options = array() ) { + $this->atts = ! empty( $atts ) ? $atts : array(); + $this->type = ! empty( $type ) ? $type : 'listing'; $this->set_options(); - $current_page = !empty( $this->atts['_current_page'] ) ? $this->atts['_current_page'] : ''; + $current_page = ! empty( $this->atts['_current_page'] ) ? $this->atts['_current_page'] : ''; if ( 'search_result' === $this->type || ( 'instant_search' == $this->type && 'search_result' === $current_page ) ) { $this->update_search_options(); @@ -146,14 +148,10 @@ public function __construct( $atts = array(), $type = 'listing', $query_args = f if ( $query_args ) { $this->query_args = $query_args; - } - else { - if ( $this->type == 'search_result' || $this->type == 'instant_search' || ! empty( $_GET ) ) { + } elseif ( $this->type == 'search_result' || $this->type == 'instant_search' || ! empty( $_GET ) ) { $this->query_args = $this->parse_search_query_args(); - } - else { - $this->query_args = $this->parse_query_args(); - } + } else { + $this->query_args = $this->parse_query_args(); } $this->query_results = $this->get_query_results(); @@ -212,42 +210,42 @@ public function set_options() { $this->options['listings_location_placeholder'] = get_directorist_option( 'listings_location_placeholder', __( 'Select a location', 'directorist' ) ); $this->options['listings_filter_button_text'] = get_directorist_option( 'listings_filter_button_text', __( 'Filters', 'directorist' ) ); $this->options['listing_location_address'] = get_directorist_option( 'listing_location_address', 'map_api' ); - $this->options['disable_single_listing'] = get_directorist_option( 'disable_single_listing') ? true : false; + $this->options['disable_single_listing'] = get_directorist_option( 'disable_single_listing' ) ? true : false; $this->options['disable_contact_info'] = get_directorist_option( 'disable_contact_info', 0 ); $this->options['popular_badge_text'] = get_directorist_option( 'popular_badge_text', __( 'Popular', 'directorist' ) ); $this->options['feature_badge_text'] = get_directorist_option( 'feature_badge_text', __( 'Featured', 'directorist' ) ); - $this->options['readmore_text'] = get_directorist_option( 'readmore_text', __('Read More', 'directorist')); + $this->options['readmore_text'] = get_directorist_option( 'readmore_text', __( 'Read More', 'directorist' ) ); $this->options['info_display_in_single_line'] = get_directorist_option( 'info_display_in_single_line', 0 ) ? 'atbd_single_line_card_info' : ''; $this->options['display_author_image'] = get_directorist_option( 'display_author_image', 1 ) ? true : false; $this->options['display_tagline_field'] = get_directorist_option( 'display_tagline_field', 0 ) ? true : false; - $this->options['display_readmore'] = get_directorist_option( 'display_readmore', 0) ? true : false; + $this->options['display_readmore'] = get_directorist_option( 'display_readmore', 0 ) ? true : false; $this->options['address_location'] = get_directorist_option( 'address_location', 'contact' ); - $this->options['excerpt_limit'] = get_directorist_option( 'excerpt_limit', 20); + $this->options['excerpt_limit'] = get_directorist_option( 'excerpt_limit', 20 ); $this->options['g_currency'] = directorist_get_currency(); - $this->options['use_def_lat_long'] = get_directorist_option('use_def_lat_long', 1) ? true : false; - $this->options['display_map_info'] = get_directorist_option('display_map_info', 1) ? true : false; - $this->options['display_image_map'] = get_directorist_option('display_image_map', 1) ? true : false; - $this->options['display_title_map'] = get_directorist_option('display_title_map', 1) ? true : false; - $this->options['display_address_map'] = get_directorist_option('display_address_map', 1) ? true : false; - $this->options['display_direction_map'] = get_directorist_option('display_direction_map', 1) ? true : false; - $this->options['display_favorite_badge_map'] = get_directorist_option('display_favorite_badge_map', 1) ? true : false; - $this->options['display_user_avatar_map'] = get_directorist_option('display_user_avatar_map', 1) ? true : false; - $this->options['display_review_map'] = get_directorist_option('display_review_map', 1) ? true : false; - $this->options['display_price_map'] = get_directorist_option('display_price_map', 1) ? true : false; - $this->options['display_phone_map'] = get_directorist_option('display_phone_map', 1) ? true : false; - $this->options['crop_width'] = get_directorist_option('crop_width', 360); - $this->options['crop_height'] = get_directorist_option('crop_height', 360); - $this->options['map_view_zoom_level'] = get_directorist_option('map_view_zoom_level', 16); - $this->options['default_preview_image'] = get_directorist_option('default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg'); + $this->options['use_def_lat_long'] = get_directorist_option( 'use_def_lat_long', 1 ) ? true : false; + $this->options['display_map_info'] = get_directorist_option( 'display_map_info', 1 ) ? true : false; + $this->options['display_image_map'] = get_directorist_option( 'display_image_map', 1 ) ? true : false; + $this->options['display_title_map'] = get_directorist_option( 'display_title_map', 1 ) ? true : false; + $this->options['display_address_map'] = get_directorist_option( 'display_address_map', 1 ) ? true : false; + $this->options['display_direction_map'] = get_directorist_option( 'display_direction_map', 1 ) ? true : false; + $this->options['display_favorite_badge_map'] = get_directorist_option( 'display_favorite_badge_map', 1 ) ? true : false; + $this->options['display_user_avatar_map'] = get_directorist_option( 'display_user_avatar_map', 1 ) ? true : false; + $this->options['display_review_map'] = get_directorist_option( 'display_review_map', 1 ) ? true : false; + $this->options['display_price_map'] = get_directorist_option( 'display_price_map', 1 ) ? true : false; + $this->options['display_phone_map'] = get_directorist_option( 'display_phone_map', 1 ) ? true : false; + $this->options['crop_width'] = get_directorist_option( 'crop_width', 360 ); + $this->options['crop_height'] = get_directorist_option( 'crop_height', 360 ); + $this->options['map_view_zoom_level'] = get_directorist_option( 'map_view_zoom_level', 16 ); + $this->options['default_preview_image'] = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); $this->options['font_type'] = 'line'; - $this->options['display_publish_date'] = get_directorist_option('display_publish_date', 1) ? true : false; - $this->options['default_latitude'] = get_directorist_option('default_latitude', 40.7127753); - $this->options['default_longitude'] = get_directorist_option('default_longitude', -74.0059728); + $this->options['display_publish_date'] = get_directorist_option( 'display_publish_date', 1 ) ? true : false; + $this->options['default_latitude'] = get_directorist_option( 'default_latitude', 40.7127753 ); + $this->options['default_longitude'] = get_directorist_option( 'default_longitude', -74.0059728 ); $this->options['listing_instant_search'] = 'yes'; - $this->options['all_listing_layout'] = get_directorist_option( 'all_listing_layout', 'left_sidebar' ); + $this->options['all_listing_layout'] = get_directorist_option( 'all_listing_layout', 'left_sidebar' ); $this->options['listing_sidebar_top_search_bar'] = get_directorist_option( 'listing_hide_top_search_bar', false ); - $this->options['sidebar_filter_text'] = get_directorist_option( 'listings_sidebar_filter_text', 'Filters' ); - $this->options['display_listings_count'] = get_directorist_option( 'display_listings_count', true ); + $this->options['sidebar_filter_text'] = get_directorist_option( 'listings_sidebar_filter_text', 'Filters' ); + $this->options['display_listings_count'] = get_directorist_option( 'display_listings_count', true ); $this->options['marker_clustering'] = get_directorist_option( 'marker_clustering', true ) ? 'markerclusterer' : ''; } @@ -274,10 +272,10 @@ public function update_search_options() { $this->options['listing_columns'] = get_directorist_option( 'search_listing_columns', 2 ); $this->options['paginate_listings'] = ! empty( get_directorist_option( 'paginate_search_results', 1 ) ) ? 'yes' : ''; $this->options['listings_per_page'] = get_directorist_option( 'search_posts_num', 6 ); - $this->options['all_listing_layout'] = get_directorist_option( 'search_result_layout', 'left_sidebar' ); + $this->options['all_listing_layout'] = get_directorist_option( 'search_result_layout', 'left_sidebar' ); $this->options['listing_sidebar_top_search_bar'] = get_directorist_option( 'search_result_hide_top_search_bar', false ); - $this->options['sidebar_filter_text'] = get_directorist_option( 'search_result_sidebar_filter_text', 'Filters' ); - $this->options['display_listings_count'] = get_directorist_option( 'display_search_result_listings_count', true ); + $this->options['sidebar_filter_text'] = get_directorist_option( 'search_result_sidebar_filter_text', 'Filters' ); + $this->options['display_listings_count'] = get_directorist_option( 'display_search_result_listings_count', true ); $this->options['listing_header_title'] = get_directorist_option( 'search_result_listing_title', __( 'Items Found', 'directorist' ) ); } @@ -319,7 +317,7 @@ public function prepare_atts_data() { 'sidebar' => $this->options['all_listing_layout'], ); - $defaults = apply_filters( 'atbdp_all_listings_params', $defaults ); + $defaults = apply_filters( 'atbdp_all_listings_params', $defaults ); $this->params = shortcode_atts( $defaults, $this->atts ); $this->view = atbdp_get_listings_current_view_name( $this->params['view'] ); @@ -331,10 +329,10 @@ public function prepare_atts_data() { $this->show_pagination = $this->params['show_pagination'] == 'yes' ? true : false; $this->header = $this->params['header'] == 'yes' ? true : false; $this->header_title = $this->params['header_title']; - $this->categories = !empty( $this->params['category'] ) ? explode( ',', $this->params['category'] ) : ''; - $this->tags = !empty( $this->params['tag'] ) ? explode( ',', $this->params['tag'] ) : ''; - $this->locations = !empty( $this->params['location'] ) ? explode( ',', $this->params['location'] ) : ''; - $this->ids = !empty( $this->params['ids'] ) ? explode( ',', $this->params['ids'] ) : ''; + $this->categories = ! empty( $this->params['category'] ) ? explode( ',', $this->params['category'] ) : ''; + $this->tags = ! empty( $this->params['tag'] ) ? explode( ',', $this->params['tag'] ) : ''; + $this->locations = ! empty( $this->params['location'] ) ? explode( ',', $this->params['location'] ) : ''; + $this->ids = ! empty( $this->params['ids'] ) ? explode( ',', $this->params['ids'] ) : ''; $this->columns = (int) atbdp_calculate_column( $this->params['columns'] ); $this->featured_only = $this->params['featured_only']; $this->popular_only = $this->params['popular_only']; @@ -345,41 +343,41 @@ public function prepare_atts_data() { $this->redirect_page_url = $this->params['redirect_page_url']; $this->listings_map_height = ( ! empty( $this->params['map_height'] ) ) ? (int) $this->params['map_height'] : $defaults['map_height']; $this->map_zoom_level = ( ! empty( $this->params['map_zoom_level'] ) ) ? (int) $this->params['map_zoom_level'] : $defaults['map_zoom_level']; - $this->directory_type = !empty( $this->params['directory_type'] ) ? explode( ',', $this->params['directory_type'] ) : ''; - $this->default_directory_type = !empty( $this->params['default_directory_type'] ) ? $this->params['default_directory_type'] : ''; - $this->instant_search = !empty( $this->params['instant_search'] ) ? $this->params['instant_search'] : ''; - $this->radius_search_based_on = !empty( $this->params['radius_search_based_on'] ) ? $this->params['radius_search_based_on'] : 'address'; - $this->sidebar = !empty( $this->params['sidebar'] ) ? $this->params['sidebar'] : 'no_sidebar'; + $this->directory_type = ! empty( $this->params['directory_type'] ) ? explode( ',', $this->params['directory_type'] ) : ''; + $this->default_directory_type = ! empty( $this->params['default_directory_type'] ) ? $this->params['default_directory_type'] : ''; + $this->instant_search = ! empty( $this->params['instant_search'] ) ? $this->params['instant_search'] : ''; + $this->radius_search_based_on = ! empty( $this->params['radius_search_based_on'] ) ? $this->params['radius_search_based_on'] : 'address'; + $this->sidebar = ! empty( $this->params['sidebar'] ) ? $this->params['sidebar'] : 'no_sidebar'; } public function prepare_data() { - $this->listing_types = $this->get_listing_types(); - $this->current_listing_type = $this->get_current_listing_type(); - - $this->has_featured = $this->options['enable_featured_listing']; - $this->has_featured = $this->has_featured || is_fee_manager_active() ? $this->_featured : $this->has_featured; - $this->popular_by = $this->options['listing_popular_by']; - $this->average_review_for_popular = $this->options['average_review_for_popular']; - $this->view_to_popular = $this->options['views_for_popular']; - $this->radius_search_unit = $this->options['radius_search_unit']; - $this->default_radius_distance = $this->options['listing_default_radius_distance']; - $this->select_listing_map = $this->options['select_listing_map']; - $this->filters_display = $this->options['listings_display_filter']; - $this->search_more_filters_fields = $this->options['listing_filters_fields']; - $this->has_filters_button = $this->advanced_filter; - $this->has_filters_icon = $this->options['listing_filters_icon']; - $this->filter_button_text = $this->options['listings_filter_button_text']; - $this->paged = atbdp_get_paged_num(); - $this->display_sortby_dropdown = $this->options['display_sort_by']; - $this->display_viewas_dropdown = $this->options['display_view_as']; - $this->sort_by_text = $this->options['sort_by_text']; - $this->view_as_text = $this->options['view_as_text']; - $this->view_as = $this->options['grid_view_as']; - $view_as_items = $this->options['listings_view_as_items']; - $this->sort_by_items = $this->options['listings_sort_by_items']; - $this->views = atbdp_get_listings_view_options( $view_as_items ); - $this->category_placeholder = $this->options['listings_category_placeholder']; - $this->location_placeholder = $this->options['listings_location_placeholder']; + $this->listing_types = $this->get_listing_types(); + $this->current_listing_type = $this->get_current_listing_type(); + + $this->has_featured = $this->options['enable_featured_listing']; + $this->has_featured = $this->has_featured || is_fee_manager_active() ? $this->_featured : $this->has_featured; + $this->popular_by = $this->options['listing_popular_by']; + $this->average_review_for_popular = $this->options['average_review_for_popular']; + $this->view_to_popular = $this->options['views_for_popular']; + $this->radius_search_unit = $this->options['radius_search_unit']; + $this->default_radius_distance = $this->options['listing_default_radius_distance']; + $this->select_listing_map = $this->options['select_listing_map']; + $this->filters_display = $this->options['listings_display_filter']; + $this->search_more_filters_fields = $this->options['listing_filters_fields']; + $this->has_filters_button = $this->advanced_filter; + $this->has_filters_icon = $this->options['listing_filters_icon']; + $this->filter_button_text = $this->options['listings_filter_button_text']; + $this->paged = atbdp_get_paged_num(); + $this->display_sortby_dropdown = $this->options['display_sort_by']; + $this->display_viewas_dropdown = $this->options['display_view_as']; + $this->sort_by_text = $this->options['sort_by_text']; + $this->view_as_text = $this->options['view_as_text']; + $this->view_as = $this->options['grid_view_as']; + $view_as_items = $this->options['listings_view_as_items']; + $this->sort_by_items = $this->options['listings_sort_by_items']; + $this->views = atbdp_get_listings_view_options( $view_as_items ); + $this->category_placeholder = $this->options['listings_category_placeholder']; + $this->location_placeholder = $this->options['listings_location_placeholder']; // $this->categories_fields = search_category_location_filter( $this->search_category_location_args(), ATBDP_CATEGORY ); // $this->locations_fields = search_category_location_filter( $this->search_category_location_args(), ATBDP_LOCATION ); $this->c_symbol = atbdp_currency_symbol( $this->options['g_currency'] ); @@ -409,39 +407,38 @@ public function set_loop_data() { $author_id = get_the_author_meta( 'ID' ); $author_data = get_userdata( $author_id ); - $author_first_name = ! empty( $author_data ) ? $author_data->first_name : ''; - $author_last_name = ! empty( $author_data ) ? $author_data->last_name : ''; - $author_display_name = ! empty( $author_data->display_name ) ? $author_data->display_name : ''; - - $u_pro_pic = get_user_meta( $author_id, 'pro_pic', true ); - $u_pro_pic = ! empty( $u_pro_pic ) ? wp_get_attachment_image_src( $u_pro_pic, 'thumbnail' ) : ''; - $bdbh = get_post_meta( $id, '_bdbh', true ); + $author_first_name = ! empty( $author_data ) ? $author_data->first_name : ''; + $author_last_name = ! empty( $author_data ) ? $author_data->last_name : ''; + $author_display_name = ! empty( $author_data->display_name ) ? $author_data->display_name : ''; + $u_pro_pic = get_user_meta( $author_id, 'pro_pic', true ); + $u_pro_pic = ! empty( $u_pro_pic ) ? wp_get_attachment_image_src( $u_pro_pic, 'thumbnail' ) : ''; + $bdbh = get_post_meta( $id, '_bdbh', true ); - $listing_type = $this->current_listing_type; - $card_fields = get_term_meta( $listing_type, 'listings_card_grid_view', true ); - $list_fields = get_term_meta( $listing_type, 'listings_card_list_view', true ); + $listing_type = $this->current_listing_type; + $card_fields = get_term_meta( $listing_type, 'listings_card_grid_view', true ); + $list_fields = get_term_meta( $listing_type, 'listings_card_list_view', true ); $get_directory_type = get_term_by( 'id', $this->current_listing_type, ATBDP_TYPE ); - $directory_type = ! empty( $get_directory_type ) ? $get_directory_type->slug : ''; - $this->loop = array( - 'id' => $id, - 'card_fields' => $card_fields, - 'list_fields' => $list_fields, - 'permalink' => get_permalink( $id ), - 'title' => get_the_title(), - 'cats' => get_the_terms( $id, ATBDP_CATEGORY ), - 'locs' => get_the_terms( $id, ATBDP_LOCATION ), - 'featured' => get_post_meta( $id, '_featured', true ), - 'listing_img' => directorist_get_listing_gallery_images( $id ), - 'listing_prv_img' => directorist_get_listing_preview_image( $id ), - 'tagline' => get_post_meta( $id, '_tagline', true ), - 'category' => get_post_meta( $id, '_admin_category_select', true ), - 'post_view' => directorist_get_listing_views_count( $id ), + $directory_type = ! empty( $get_directory_type ) ? $get_directory_type->slug : ''; + $this->loop = array( + 'id' => $id, + 'card_fields' => $card_fields, + 'list_fields' => $list_fields, + 'permalink' => get_permalink( $id ), + 'title' => get_the_title(), + 'cats' => get_the_terms( $id, ATBDP_CATEGORY ), + 'locs' => get_the_terms( $id, ATBDP_LOCATION ), + 'featured' => get_post_meta( $id, '_featured', true ), + 'listing_img' => directorist_get_listing_gallery_images( $id ), + 'listing_prv_img' => directorist_get_listing_preview_image( $id ), + 'tagline' => get_post_meta( $id, '_tagline', true ), + 'category' => get_post_meta( $id, '_admin_category_select', true ), + 'post_view' => directorist_get_listing_views_count( $id ), 'business_hours' => ! empty( $bdbh ) ? atbdp_sanitize_array( $bdbh ) : array(), 'enable247hour' => get_post_meta( $id, '_enable247hour', true ), 'disable_bz_hour_listing' => get_post_meta( $id, '_disable_bz_hour_listing', true ), - 'bdbh_version' => get_post_meta( $id, '_bdbh_version', true ), + 'bdbh_version' => get_post_meta( $id, '_bdbh_version', true ), 'author_id' => $author_id, 'author_data' => $author_data, 'author_full_name' => $author_first_name . ' ' . $author_last_name, @@ -455,8 +452,8 @@ public function set_loop_data() { public function get_review_data() { // Review - $average = directorist_get_listing_rating( get_the_ID() ); - $reviews_count = directorist_get_listing_review_count( get_the_ID() ); + $average = directorist_get_listing_rating( get_the_ID() ); + $reviews_count = directorist_get_listing_review_count( get_the_ID() ); // Icons $icon_empty_star = directorist_icon( 'fas fa-star', false, 'star-empty' ); @@ -464,32 +461,32 @@ public function get_review_data() { $icon_full_star = directorist_icon( 'fas fa-star', false, 'star-full' ); // Stars - $star_1 = ( $average > 0 && $average < 1) ? $icon_half_star : $icon_empty_star; - $star_1 = ( $average >= 1) ? $icon_full_star : $star_1; + $star_1 = ( $average > 0 && $average < 1 ) ? $icon_half_star : $icon_empty_star; + $star_1 = ( $average >= 1 ) ? $icon_full_star : $star_1; - $star_2 = ( $average > 1 && $average < 2) ? $icon_half_star : $icon_empty_star; - $star_2 = ( $average >= 2) ? $icon_full_star : $star_2; + $star_2 = ( $average > 1 && $average < 2 ) ? $icon_half_star : $icon_empty_star; + $star_2 = ( $average >= 2 ) ? $icon_full_star : $star_2; - $star_3 = ( $average > 2 && $average < 3) ? $icon_half_star : $icon_empty_star; - $star_3 = ( $average >= 3) ? $icon_full_star : $star_3; + $star_3 = ( $average > 2 && $average < 3 ) ? $icon_half_star : $icon_empty_star; + $star_3 = ( $average >= 3 ) ? $icon_full_star : $star_3; - $star_4 = ( $average > 3 && $average < 4) ? $icon_half_star : $icon_empty_star; - $star_4 = ( $average >= 4) ? $icon_full_star : $star_4; + $star_4 = ( $average > 3 && $average < 4 ) ? $icon_half_star : $icon_empty_star; + $star_4 = ( $average >= 4 ) ? $icon_full_star : $star_4; $star_5 = ( $average > 4 && $average < 5 ) ? $icon_half_star : $icon_empty_star; $star_5 = ( $average >= 5 ) ? $icon_full_star : $star_5; $review_stars = "{$star_1}{$star_2}{$star_3}{$star_4}{$star_5}"; - return [ + return array( 'review_stars' => $review_stars, 'total_reviews' => $reviews_count, 'average_reviews' => number_format( $average, 1 ), 'review_text' => _nx( 'Review', 'Reviews', $reviews_count, 'Listing grid review text', 'directorist' ), - ]; + ); } - private function execute_meta_query_args(&$args, &$meta_queries) { + private function execute_meta_query_args( &$args, &$meta_queries ) { if ( 'rand' === $this->orderby ) { $current_order = atbdp_get_listings_current_order( $this->orderby ); } else { @@ -504,9 +501,9 @@ private function execute_meta_query_args(&$args, &$meta_queries) { // TODO: Status has been migrated, remove related code. // $meta_queries['expired'] = array( - // 'key' => '_listing_status', - // 'value' => 'expired', - // 'compare' => '!=', + // 'key' => '_listing_status', + // 'value' => 'expired', + // 'compare' => '!=', // ); if ( $this->has_featured ) { @@ -573,44 +570,42 @@ private function execute_meta_query_args(&$args, &$meta_queries) { 'compare' => '<=', ); } - } else { - if ( 'average_rating' === $this->popular_by ) { + } elseif ( 'average_rating' === $this->popular_by ) { $meta_queries['_rating'] = array( 'key' => directorist_get_rating_field_meta_key(), 'value' => $this->average_review_for_popular, 'type' => 'NUMERIC', 'compare' => '<=', ); - } elseif ( 'view_count' === $this->popular_by ) { - $meta_queries['views'] = array( - 'key' => directorist_get_listing_views_count_meta_key(), - 'value' => $this->view_to_popular, - 'type' => 'NUMERIC', - 'compare' => '>=', - ); + } elseif ( 'view_count' === $this->popular_by ) { + $meta_queries['views'] = array( + 'key' => directorist_get_listing_views_count_meta_key(), + 'value' => $this->view_to_popular, + 'type' => 'NUMERIC', + 'compare' => '>=', + ); - $args['orderby'] = array( - 'views' => 'DESC', - ); - } else { - $meta_queries['views'] = array( - 'key' => directorist_get_listing_views_count_meta_key(), - 'value' => (int) $this->view_to_popular, - 'type' => 'NUMERIC', - 'compare' => '>=', - ); + $args['orderby'] = array( + 'views' => 'DESC', + ); + } else { + $meta_queries['views'] = array( + 'key' => directorist_get_listing_views_count_meta_key(), + 'value' => (int) $this->view_to_popular, + 'type' => 'NUMERIC', + 'compare' => '>=', + ); - $args['orderby'] = array( - 'views' => 'DESC', - ); + $args['orderby'] = array( + 'views' => 'DESC', + ); - $meta_queries['_rating'] = array( - 'key' => directorist_get_rating_field_meta_key(), - 'value' => $this->average_review_for_popular, - 'type' => 'NUMERIC', - 'compare' => '<=', - ); - } + $meta_queries['_rating'] = array( + 'key' => directorist_get_rating_field_meta_key(), + 'value' => $this->average_review_for_popular, + 'type' => 'NUMERIC', + 'compare' => '<=', + ); } } @@ -781,7 +776,7 @@ public function parse_query_args() { $meta_queries = array(); $this->execute_meta_query_args( $args, $meta_queries ); - $meta_queries = apply_filters( 'atbdp_all_listings_meta_queries', $meta_queries ); + $meta_queries = apply_filters( 'atbdp_all_listings_meta_queries', $meta_queries ); $count_meta_queries = count( $meta_queries ); if ( $count_meta_queries ) { @@ -793,8 +788,8 @@ public function parse_query_args() { * * @since 7.4.2 * - * @param array $args All listing query arguments - * @param object $this Listings object + * @param array $args All listing query arguments + * @param object $this Listings object */ $args = apply_filters( 'directorist_all_listings_query_arguments', $args, $this ); @@ -816,7 +811,7 @@ public function parse_search_query_args() { if ( ! empty( $_REQUEST['ids'] ) ) { $args['post__in'] = wp_parse_id_list( wp_unslash( $_REQUEST['ids'] ) ); - $this->ids = $args['post__in']; + $this->ids = $args['post__in']; } if ( ! empty( $_REQUEST['q'] ) ) { @@ -903,20 +898,20 @@ public function parse_search_query_args() { $custom_fields = array_filter( wp_unslash( $_REQUEST['custom_field'] ) ); foreach ( $custom_fields as $key => $values ) { - $key = sanitize_text_field( $key ); - $meta_query = []; + $key = sanitize_text_field( $key ); + $meta_query = array(); if ( is_array( $values ) ) { if ( count( $values ) > 1 ) { $sub_meta_queries = array( - 'relation' => 'OR' + 'relation' => 'OR', ); foreach ( $values as $value ) { $sub_meta_queries[] = array( 'key' => '_' . $key, 'value' => sanitize_text_field( $value ), - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } @@ -925,12 +920,12 @@ public function parse_search_query_args() { $meta_query = array( 'key' => '_' . $key, 'value' => sanitize_text_field( $values[0] ), - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } } else { $field_type = str_replace( 'custom-', '', $key ); - $field_type = preg_replace( '/([!^0-9])|(-)/', '', $field_type ); //replaces any additional numbering to just keep the field name, for example if previous line gives us "text-2", this line makes it "text" + $field_type = preg_replace( '/([!^0-9])|(-)/', '', $field_type ); // replaces any additional numbering to just keep the field name, for example if previous line gives us "text-2", this line makes it "text" // Check if $values contains a hyphen if ( strpos( $values, '-' ) !== false ) { // If $values is in the format "40-50", create a range query @@ -947,7 +942,7 @@ public function parse_search_query_args() { $meta_query = array( 'key' => '_' . $key, 'value' => sanitize_text_field( $values ), - 'compare' => $operator + 'compare' => $operator, ); } } @@ -976,30 +971,28 @@ public function parse_search_query_args() { $price = array_map( 'intval', wp_unslash( $_REQUEST['price'] ) ); $price = array_filter( $price ); - if ($n = count($price)) { + if ( $n = count( $price ) ) { if ( 2 == $n ) { $meta_queries[] = array( 'key' => '_price', 'value' => $price, 'type' => 'NUMERIC', - 'compare' => 'BETWEEN' + 'compare' => 'BETWEEN', ); - } else { - if (empty($price[0])) { + } elseif ( empty( $price[0] ) ) { $meta_queries[] = array( 'key' => '_price', 'value' => $price[1], 'type' => 'NUMERIC', - 'compare' => '<=' + 'compare' => '<=', ); - } else { - $meta_queries[] = array( - 'key' => '_price', - 'value' => $price[0], - 'type' => 'NUMERIC', - 'compare' => '>=' - ); - } + } else { + $meta_queries[] = array( + 'key' => '_price', + 'value' => $price[0], + 'type' => 'NUMERIC', + 'compare' => '>=', + ); } } } @@ -1008,7 +1001,7 @@ public function parse_search_query_args() { $meta_queries['_price_range'] = array( 'key' => '_price_range', 'value' => sanitize_text_field( wp_unslash( $_REQUEST['price_range'] ) ), - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } @@ -1016,7 +1009,7 @@ public function parse_search_query_args() { $meta_queries['_website'] = array( 'key' => '_website', 'value' => sanitize_text_field( wp_unslash( $_REQUEST['website'] ) ), - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } @@ -1024,24 +1017,24 @@ public function parse_search_query_args() { $meta_queries['_email'] = array( 'key' => '_email', 'value' => sanitize_text_field( wp_unslash( $_REQUEST['email'] ) ), - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } if ( ! empty( $_REQUEST['phone'] ) ) { - $phone = sanitize_text_field( wp_unslash( $_REQUEST['phone'] ) ); + $phone = sanitize_text_field( wp_unslash( $_REQUEST['phone'] ) ); $meta_queries['_phone'] = array( 'relation' => 'OR', array( 'key' => '_phone2', 'value' => $phone, - 'compare' => 'LIKE' + 'compare' => 'LIKE', ), array( 'key' => '_phone', 'value' => $phone, - 'compare' => 'LIKE' - ) + 'compare' => 'LIKE', + ), ); } @@ -1049,26 +1042,25 @@ public function parse_search_query_args() { $meta_queries['_fax'] = array( 'key' => '_fax', 'value' => sanitize_text_field( wp_unslash( $_REQUEST['fax'] ) ), - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } if ( 'address' == $this->radius_search_based_on && ! empty( $_REQUEST['miles'] ) && ! empty( $_REQUEST['address'] ) && ! empty( $_REQUEST['cityLat'] ) && ! empty( $_REQUEST['cityLng'] ) ) { - $distance = directorist_get_distance_range( $_REQUEST['miles'] ); -; $args['atbdp_geo_query'] = array( - 'lat_field' => '_manual_lat', - 'lng_field' => '_manual_lng', - 'latitude' => sanitize_text_field( wp_unslash( $_REQUEST['cityLat'] ) ), - 'longitude' => sanitize_text_field( wp_unslash( $_REQUEST['cityLng'] ) ), + $distance = directorist_get_distance_range( $_REQUEST['miles'] ); $args['atbdp_geo_query'] = array( + 'lat_field' => '_manual_lat', + 'lng_field' => '_manual_lng', + 'latitude' => sanitize_text_field( wp_unslash( $_REQUEST['cityLat'] ) ), + 'longitude' => sanitize_text_field( wp_unslash( $_REQUEST['cityLng'] ) ), 'min_distance' => $distance['min'], // Minimum distance extracted from URL - 'max_distance' => $distance['max'], // Maximum distance extracted from URL - 'units' => $this->radius_search_unit + 'max_distance' => $distance['max'], // Maximum distance extracted from URL + 'units' => $this->radius_search_unit, ); - } elseif ( ! empty($_REQUEST['address']) ) { + } elseif ( ! empty( $_REQUEST['address'] ) ) { $meta_queries['_address'] = array( 'key' => '_address', 'value' => sanitize_text_field( wp_unslash( $_REQUEST['address'] ) ), - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } @@ -1079,30 +1071,30 @@ public function parse_search_query_args() { 'latitude' => sanitize_text_field( wp_unslash( $_REQUEST['zip_cityLat'] ) ), 'longitude' => sanitize_text_field( wp_unslash( $_REQUEST['zip_cityLng'] ) ), 'distance' => sanitize_text_field( wp_unslash( $_REQUEST['miles'] ) ), - 'units' => $this->radius_search_unit + 'units' => $this->radius_search_unit, ); } elseif ( ! empty( $_REQUEST['zip'] ) ) { $meta_queries['_zip'] = array( 'key' => '_zip', 'value' => sanitize_text_field( wp_unslash( $_REQUEST['zip'] ) ), - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } if ( ! empty( $_REQUEST['search_by_rating'] ) ) { - $rating_query = directorist_clean( wp_unslash( $_REQUEST['search_by_rating'] ) ); + $rating_query = directorist_clean( wp_unslash( $_REQUEST['search_by_rating'] ) ); $meta_queries['_rating'] = array( 'key' => directorist_get_rating_field_meta_key(), 'value' => $rating_query, 'type' => 'NUMERIC', - 'compare' => 'IN' + 'compare' => 'IN', ); } $meta_queries = apply_filters( 'atbdp_search_listings_meta_queries', $meta_queries ); if ( count( $meta_queries ) ) { $meta_queries['relation'] = 'AND'; - $args['meta_query'] = $meta_queries; + $args['meta_query'] = $meta_queries; } return apply_filters( 'atbdp_listing_search_query_argument', $args ); @@ -1113,16 +1105,16 @@ public function archive_view_template() { Helper::get_template( $template_file, array( 'listings' => $this ) ); } - public function render_shortcode( $atts = [] ) { + public function render_shortcode( $atts = array() ) { ob_start(); - if (!empty($this->redirect_page_url)) { - $redirect = '<script>window.location="' . esc_url($this->redirect_page_url) . '"</script>'; + if ( ! empty( $this->redirect_page_url ) ) { + $redirect = '<script>window.location="' . esc_url( $this->redirect_page_url ) . '"</script>'; return $redirect; } if ( $this->logged_in_user_only && ! is_user_logged_in() ) { - return \ATBDP_Helper::guard([ 'type' => 'auth' ]); + return \ATBDP_Helper::guard( array( 'type' => 'auth' ) ); } if ( ! empty( $atts['shortcode'] ) ) { @@ -1139,7 +1131,7 @@ public function render_shortcode( $atts = [] ) { case 'no_sidebar': $template = 'archive-contents'; break; - default : + default: $template = 'sidebar-archive-contents'; } @@ -1155,14 +1147,14 @@ public function render_list_view( $post_ids ) { // Exit early or log an error if the input is invalid return; } - + foreach ( $post_ids as $listing_id ) { ?> <div class="directorist-col-12 directorist-all-listing-col"> <?php $this->loop_template( 'list', $listing_id ); ?> </div> <?php - } + } } public function render_grid_view( $post_ids ) { @@ -1170,18 +1162,18 @@ public function render_grid_view( $post_ids ) { // Exit early or log an error if the input is invalid return; } - + foreach ( $post_ids as $listing_id ) { ?> <div class="<?php Helper::directorist_column( $this->columns ); ?> directorist-all-listing-col"> <?php $this->loop_template( 'grid', $listing_id ); ?> </div> <?php - } + } } public function have_posts() { - return !empty( $this->query_results->ids ) ? true : false; + return ! empty( $this->query_results->ids ) ? true : false; } public function post_ids() { @@ -1192,7 +1184,7 @@ public function has_sidebar() { return $this->query_results->ids; } - public function loop_template( $loop = 'grid', $id = NULL ) { + public function loop_template( $loop = 'grid', $id = null ) { if ( ! $id ) { return; } @@ -1205,14 +1197,13 @@ public function loop_template( $loop = 'grid', $id = NULL ) { $this->set_loop_data(); - if ( $loop == 'grid' && !empty( $this->loop['card_fields'] ) ) { + if ( $loop == 'grid' && ! empty( $this->loop['card_fields'] ) ) { $active_template = $this->loop['card_fields']['active_template']; - $template = ( $active_template == 'grid_view_with_thumbnail' && $this->display_preview_image ) ? 'loop-grid' : 'loop-grid-nothumb'; + $template = ( $active_template == 'grid_view_with_thumbnail' && $this->display_preview_image ) ? 'loop-grid' : 'loop-grid-nothumb'; Helper::get_template( 'archive/' . $template, array( 'listings' => $this ) ); - } - elseif ( $loop == 'list' && !empty( $this->loop['list_fields'] ) ) { + } elseif ( $loop == 'list' && ! empty( $this->loop['list_fields'] ) ) { $active_template = $this->loop['list_fields']['active_template']; - $template = ( $active_template == 'list_view_with_thumbnail' && $this->display_preview_image ) ? 'loop-list' : 'loop-list-nothumb'; + $template = ( $active_template == 'list_view_with_thumbnail' && $this->display_preview_image ) ? 'loop-list' : 'loop-list-nothumb'; Helper::get_template( 'archive/' . $template, array( 'listings' => $this ) ); } @@ -1220,11 +1211,11 @@ public function loop_template( $loop = 'grid', $id = NULL ) { } - public function setup_loop( array $args = [] ) { - $default = [ - 'template' => 'grid' - ]; - $args = array_merge( $default, $args ); + public function setup_loop( array $args = array() ) { + $default = array( + 'template' => 'grid', + ); + $args = array_merge( $default, $args ); $listings = $this->query_results; if ( ! empty( $listings->ids ) ) : @@ -1234,32 +1225,32 @@ public function setup_loop( array $args = [] ) { } $original_post = $GLOBALS['post']; - $counter = 0; + $counter = 0; foreach ( $listings->ids as $listings_id ) : - $counter++; + ++$counter; $GLOBALS['post'] = get_post( $listings_id ); setup_postdata( $GLOBALS['post'] ); $this->set_loop_data(); if ( $args['template'] == 'grid' ) { $active_template = $this->loop['card_fields']['active_template']; - $template = $active_template == 'grid_view_with_thumbnail' ? 'grid' : 'grid-nothumb'; - } - elseif ( $args['template'] == 'list' ) { + $template = $active_template == 'grid_view_with_thumbnail' ? 'grid' : 'grid-nothumb'; + } elseif ( $args['template'] == 'list' ) { $active_template = $this->loop['list_fields']['active_template']; - $template = $active_template == 'list_view_with_thumbnail' ? 'list' : 'list-nothumb'; - } - else { + $template = $active_template == 'list_view_with_thumbnail' ? 'list' : 'list-nothumb'; + } else { $template = $args['template']; } - Helper::get_template( "archive/fields/" . $template, array('listings' => $this) ); + Helper::get_template( 'archive/fields/' . $template, array( 'listings' => $this ) ); endforeach; $GLOBALS['post'] = $original_post; - wp_reset_postdata(); - else: - ?><p class="atbdp_nlf"><?php esc_html_e('No listing found.', 'directorist'); ?></p><?php + wp_reset_postdata(); + else : + ?> + <p class="atbdp_nlf"><?php esc_html_e( 'No listing found.', 'directorist' ); ?></p> + <?php endif; } @@ -1293,16 +1284,16 @@ public function dropdown_toggle_button_icon_class() { public function get_sort_by_link_list() { $link_list = array(); - $options = atbdp_get_listings_orderby_options( $this->sort_by_items ); + $options = atbdp_get_listings_orderby_options( $this->sort_by_items ); $queryString = isset( $_SERVER['QUERY_STRING'] ) ? sanitize_text_field( wp_unslash( $_SERVER['QUERY_STRING'] ) ) : ''; - parse_str($queryString, $arguments); - $actual_link = !empty( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; + parse_str( $queryString, $arguments ); + $actual_link = ! empty( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; foreach ( $options as $value => $label ) { - $arguments['sort'] = $value; + $arguments['sort'] = $value; - $link_item['link'] = add_query_arg( $arguments, $actual_link ); - $link_item['label'] = $label; - $link_item['key'] = $value; + $link_item['link'] = add_query_arg( $arguments, $actual_link ); + $link_item['label'] = $label; + $link_item['key'] = $value; array_push( $link_list, $link_item ); } @@ -1326,11 +1317,11 @@ public function get_current_listing_type() { if ( is_singular( ATBDP_POST_TYPE ) ) { $directory = get_post_meta( get_the_ID(), '_directory_type', true ); - } else if ( ! empty( $_REQUEST['directory_type'] ) ) { + } elseif ( ! empty( $_REQUEST['directory_type'] ) ) { $directory = sanitize_text_field( wp_unslash( $_REQUEST['directory_type'] ) ); - } else if ( ! empty( $this->default_directory_type ) ) { + } elseif ( ! empty( $this->default_directory_type ) ) { $directory = $this->default_directory_type; - } else if ( ! empty( $this->directory_type ) ) { + } elseif ( ! empty( $this->directory_type ) ) { $directory = array_key_first( $this->get_listing_types() ); } @@ -1350,7 +1341,7 @@ public function get_directory_type_slug() { $current_directory_type = $this->get_current_listing_type(); if ( is_numeric( $current_directory_type ) ) { - $term = get_term_by( 'id', $current_directory_type, ATBDP_TYPE) ; + $term = get_term_by( 'id', $current_directory_type, ATBDP_TYPE ); $current_directory_type = $term->slug; } @@ -1370,15 +1361,14 @@ public function search_category_location_args() { 'immediate_category' => 0, 'active_term_id' => 0, 'ancestors' => array(), - 'listing_type' => $this->listing_types + 'listing_type' => $this->listing_types, ); } public function render_map() { if ( 'google' == $this->select_listing_map ) { $this->load_google_map(); - } - else { + } else { $this->load_openstreet_map(); } } @@ -1386,55 +1376,55 @@ public function render_map() { public function map_base_lat_long() { $ids = $this->post_ids(); - if ( !empty( $ids ) ) { - $id = $ids[0]; - $lat_long = [ + if ( ! empty( $ids ) ) { + $id = $ids[0]; + $lat_long = array( 'latitude' => get_post_meta( $id, '_manual_lat', true ), 'longitude' => get_post_meta( $id, '_manual_lng', true ), - ]; + ); } else { - $lat_long = [ + $lat_long = array( 'latitude' => get_directorist_option( 'default_latitude', 40.7127753 ), 'longitude' => get_directorist_option( 'default_longitude', -74.0059728 ), - ]; + ); } return $lat_long; } public function map_options() { - $data = [ - 'map_type' => $this->select_listing_map, - 'crop_width' => get_directorist_option( 'crop_width', 360 ), - 'crop_height' => get_directorist_option( 'crop_height', 360 ), - 'display_map' => get_directorist_option( 'display_map_info', true ), - 'display_image' => get_directorist_option( 'display_image_map', true ), - 'display_title' => get_directorist_option( 'display_title_map', true ), - 'display_address' => get_directorist_option( 'display_address_map', true ), - 'display_direction' => get_directorist_option( 'display_direction_map', true ), - 'display_favorite_badge_map' => get_directorist_option( 'display_favorite_badge_map', true ), - 'display_user_avatar_map' => get_directorist_option( 'display_user_avatar_map', true ), - 'display_review_map' => get_directorist_option( 'display_review_map', true ), - 'display_price_map' => get_directorist_option( 'display_price_map', true ), - 'display_phone_map' => get_directorist_option( 'display_phone_map', true ), - 'zoom_level' => $this->map_zoom_level, - 'default_image' => get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ), - 'base_latitude' => $this->map_base_lat_long()['latitude'], - 'base_longitude' => $this->map_base_lat_long()['longitude'], - 'default_latitude' => get_directorist_option( 'default_latitude', 40.7127753 ), - 'default_longitude' => get_directorist_option( 'default_longitude', -74.0059728 ), - 'force_default_location' => get_directorist_option( 'use_def_lat_long', true ), - 'disable_single_listing' => $this->disable_single_listing, - 'openstreet_script' => DIRECTORIST_VENDOR_JS . 'openstreet-map/subGroup-markercluster-controlLayers-realworld.388.js?ver=' . DIRECTORIST_SCRIPT_VERSION, - ]; + $data = array( + 'map_type' => $this->select_listing_map, + 'crop_width' => get_directorist_option( 'crop_width', 360 ), + 'crop_height' => get_directorist_option( 'crop_height', 360 ), + 'display_map' => get_directorist_option( 'display_map_info', true ), + 'display_image' => get_directorist_option( 'display_image_map', true ), + 'display_title' => get_directorist_option( 'display_title_map', true ), + 'display_address' => get_directorist_option( 'display_address_map', true ), + 'display_direction' => get_directorist_option( 'display_direction_map', true ), + 'display_favorite_badge_map' => get_directorist_option( 'display_favorite_badge_map', true ), + 'display_user_avatar_map' => get_directorist_option( 'display_user_avatar_map', true ), + 'display_review_map' => get_directorist_option( 'display_review_map', true ), + 'display_price_map' => get_directorist_option( 'display_price_map', true ), + 'display_phone_map' => get_directorist_option( 'display_phone_map', true ), + 'zoom_level' => $this->map_zoom_level, + 'default_image' => get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ), + 'base_latitude' => $this->map_base_lat_long()['latitude'], + 'base_longitude' => $this->map_base_lat_long()['longitude'], + 'default_latitude' => get_directorist_option( 'default_latitude', 40.7127753 ), + 'default_longitude' => get_directorist_option( 'default_longitude', -74.0059728 ), + 'force_default_location' => get_directorist_option( 'use_def_lat_long', true ), + 'disable_single_listing' => $this->disable_single_listing, + 'openstreet_script' => DIRECTORIST_VENDOR_JS . 'openstreet-map/subGroup-markercluster-controlLayers-realworld.388.js?ver=' . DIRECTORIST_SCRIPT_VERSION, + ); return $data; } public function load_openstreet_map() { - $card = json_encode( $this->openstreet_map_card_data() ); + $card = json_encode( $this->openstreet_map_card_data() ); $options = json_encode( $this->map_options() ); - $style = 'height:' . $this->listings_map_height . 'px'; + $style = 'height:' . $this->listings_map_height . 'px'; ?> <div id="map" style="<?php echo esc_attr( $style ); ?>" data-card="<?php echo directorist_esc_json( $card ); ?>" data-options="<?php echo directorist_esc_json( $options ); ?>"> <div id="gmap_full_screen_button"> @@ -1446,28 +1436,28 @@ public function load_openstreet_map() { } public function get_map_options() { - $opt['select_listing_map'] = $this->select_listing_map; - $opt['crop_width'] = $this->options['crop_width']; - $opt['crop_height'] = $this->options['crop_height']; - $opt['display_map_info'] = $this->options['display_map_info']; - $opt['display_image_map'] = $this->options['display_image_map']; - $opt['display_title_map'] = $this->options['display_title_map']; - $opt['display_address_map'] = $this->options['display_address_map']; - $opt['display_direction_map'] = $this->options['display_direction_map']; - $opt['display_favorite_badge_map'] = $this->options['display_favorite_badge_map']; - $opt['display_user_avatar_map'] = $this->options['display_user_avatar_map']; - $opt['display_review_map'] = $this->options['display_review_map']; - $opt['display_price_map'] = $this->options['display_price_map']; - $opt['display_phone_map'] = $this->options['display_phone_map']; - $opt['zoom'] = $this->map_zoom_level; - $opt['default_image'] = $this->options['default_preview_image']; - $opt['default_lat'] = $this->options['default_latitude']; - $opt['default_long'] = $this->options['default_longitude']; - $opt['use_def_lat_long'] = $this->options['use_def_lat_long']; + $opt['select_listing_map'] = $this->select_listing_map; + $opt['crop_width'] = $this->options['crop_width']; + $opt['crop_height'] = $this->options['crop_height']; + $opt['display_map_info'] = $this->options['display_map_info']; + $opt['display_image_map'] = $this->options['display_image_map']; + $opt['display_title_map'] = $this->options['display_title_map']; + $opt['display_address_map'] = $this->options['display_address_map']; + $opt['display_direction_map'] = $this->options['display_direction_map']; + $opt['display_favorite_badge_map'] = $this->options['display_favorite_badge_map']; + $opt['display_user_avatar_map'] = $this->options['display_user_avatar_map']; + $opt['display_review_map'] = $this->options['display_review_map']; + $opt['display_price_map'] = $this->options['display_price_map']; + $opt['display_phone_map'] = $this->options['display_phone_map']; + $opt['zoom'] = $this->map_zoom_level; + $opt['default_image'] = $this->options['default_preview_image']; + $opt['default_lat'] = $this->options['default_latitude']; + $opt['default_long'] = $this->options['default_longitude']; + $opt['use_def_lat_long'] = $this->options['use_def_lat_long']; $opt['disable_single_listing'] = $this->disable_single_listing; - $map_is_disabled = ( empty( $opt['display_map_info'] ) && ( empty($opt['display_image_map'] ) || empty( $opt['display_title_map'] ) || empty( $opt['display_address_map'] ) || empty( $opt['display_direction_map'] ) || empty( $opt['display_favorite_badge_map'] ) || empty( $opt['display_user_avatar_map'] ) || empty( $opt['display_review_map'] ) || empty( $opt['display_price_map'] ) || empty( $opt['display_phone_map'] ) ) ) ? true : false; + $map_is_disabled = ( empty( $opt['display_map_info'] ) && ( empty( $opt['display_image_map'] ) || empty( $opt['display_title_map'] ) || empty( $opt['display_address_map'] ) || empty( $opt['display_direction_map'] ) || empty( $opt['display_favorite_badge_map'] ) || empty( $opt['display_user_avatar_map'] ) || empty( $opt['display_review_map'] ) || empty( $opt['display_price_map'] ) || empty( $opt['display_phone_map'] ) ) ) ? true : false; $opt['map_is_disabled'] = $map_is_disabled; return apply_filters( 'atbdp_map_options', $opt ); @@ -1478,11 +1468,11 @@ public function loop_map_cat_icon() { $cat_icon = ''; - if ( !empty( $cats ) ) { + if ( ! empty( $cats ) ) { $cat_icon = get_term_meta( $cats[0]->term_id, 'category_icon', true ); } - $cat_icon = !empty( $cat_icon ) ? $cat_icon : 'fas fa-map-pin'; + $cat_icon = ! empty( $cat_icon ) ? $cat_icon : 'fas fa-map-pin'; /** * Get category icon for map marker. * @@ -1493,15 +1483,15 @@ public function loop_map_cat_icon() { * * @return string CATEGORY ICON NAME */ - return apply_filters( "directorist_listings_map_view_marker_icon", $cat_icon, $cats ); + return apply_filters( 'directorist_listings_map_view_marker_icon', $cat_icon, $cats ); } public function openstreet_map_card_data() { $opt = $this->get_map_options(); - $lat_lon = []; + $lat_lon = array(); - $map_data = []; + $map_data = array(); $listings = $this->query_results; @@ -1517,46 +1507,46 @@ public function openstreet_map_card_data() { $GLOBALS['post'] = get_post( $listings_id ); setup_postdata( $GLOBALS['post'] ); $this->set_loop_data(); - $ls_data = []; + $ls_data = array(); - $ls_data['manual_lat'] = get_post_meta($listings_id, '_manual_lat', true); - $ls_data['manual_lng'] = get_post_meta($listings_id, '_manual_lng', true); + $ls_data['manual_lat'] = get_post_meta( $listings_id, '_manual_lat', true ); + $ls_data['manual_lng'] = get_post_meta( $listings_id, '_manual_lng', true ); $ls_data['listing_img'] = directorist_get_listing_gallery_images( $listings_id ); $ls_data['listing_prv_img'] = directorist_get_listing_preview_image( $listings_id ); - $ls_data['address'] = get_post_meta($listings_id, '_address', true); - $ls_data['phone'] = get_post_meta($listings_id, '_phone', true); + $ls_data['address'] = get_post_meta( $listings_id, '_address', true ); + $ls_data['phone'] = get_post_meta( $listings_id, '_phone', true ); $ls_data['font_type'] = $this->options['font_type']; $ls_data['listings'] = $this; - $lat_lon = [ + $lat_lon = array( 'lat' => $ls_data['manual_lat'], - 'lon' => $ls_data['manual_lng'] - ]; + 'lon' => $ls_data['manual_lng'], + ); $ls_data['lat_lon'] = $lat_lon; - if ( ! empty( $ls_data['listing_prv_img']) ) { + if ( ! empty( $ls_data['listing_prv_img'] ) ) { $ls_data['prv_image'] = atbdp_get_image_source( $ls_data['listing_prv_img'], 'large' ); } - $listing_type = directorist_get_listing_directory( $listings_id ); - $ls_data['default_image'] = Helper::default_preview_image_src( $listing_type ); + $listing_type = directorist_get_listing_directory( $listings_id ); + $ls_data['default_image'] = Helper::default_preview_image_src( $listing_type ); if ( ! empty( $ls_data['listing_img'][0] ) ) { - $ls_data['gallery_img'] = atbdp_get_image_source($ls_data['listing_img'][0], 'medium'); + $ls_data['gallery_img'] = atbdp_get_image_source( $ls_data['listing_img'][0], 'medium' ); } - $cat_icon = directorist_icon( $this->loop_map_cat_icon(), false ); + $cat_icon = directorist_icon( $this->loop_map_cat_icon(), false ); $ls_data['cat_icon'] = $cat_icon; $opt['ls_data'] = $ls_data; - $map_data[] = [ + $map_data[] = array( 'content' => Helper::get_template_contents( 'archive/fields/openstreet-map', $opt ), 'latitude' => get_post_meta( $listings_id, '_manual_lat', true ), 'longitude' => get_post_meta( $listings_id, '_manual_lng', true ), 'cat_icon' => $cat_icon, - ]; + ); endforeach; @@ -1568,13 +1558,12 @@ public function openstreet_map_card_data() { } public function load_google_map() { - $opt = $this->get_map_options(); + $opt = $this->get_map_options(); $disable_info_window = 'no'; - if (empty($opt['display_map_info'])) { + if ( empty( $opt['display_map_info'] ) ) { $disable_info_window = 'yes'; - } - elseif ( empty($opt['display_image_map'] || $opt['display_title_map'] || $opt['display_address_map'] || $opt['display_direction_map'] || $opt['display_favorite_badge_map'] || $opt['display_user_avatar_map'] || $opt['display_review_map'] || $opt['display_price_map'] || $opt['display_phone_map'] ) ){ + } elseif ( empty( $opt['display_image_map'] || $opt['display_title_map'] || $opt['display_address_map'] || $opt['display_direction_map'] || $opt['display_favorite_badge_map'] || $opt['display_user_avatar_map'] || $opt['display_review_map'] || $opt['display_price_map'] || $opt['display_phone_map'] ) ) { $disable_info_window = 'yes'; } @@ -1584,13 +1573,13 @@ public function load_google_map() { 'zoom' => $opt['zoom'], 'default_latitude' => $this->options['default_latitude'], 'default_longitude' => $this->options['default_longitude'], - 'use_def_lat_long' => $this->options['use_def_lat_long'], + 'use_def_lat_long' => $this->options['use_def_lat_long'], ); Helper::add_hidden_data_to_dom( 'atbdp_map', $data ); - $map_height = !empty( $this->listings_map_height ) ? $this->listings_map_height: ''; + $map_height = ! empty( $this->listings_map_height ) ? $this->listings_map_height : ''; ?> - <div class="atbdp-body atbdp-map embed-responsive embed-responsive-16by9 atbdp-margin-bottom" data-type="<?php echo $this->options['marker_clustering']; ?>" style="height: <?php echo esc_attr( $map_height );?>px;"> + <div class="atbdp-body atbdp-map embed-responsive embed-responsive-16by9 atbdp-margin-bottom" data-type="<?php echo $this->options['marker_clustering']; ?>" style="height: <?php echo esc_attr( $map_height ); ?>px;"> <?php $listings = $this->query_results; @@ -1606,34 +1595,34 @@ public function load_google_map() { $GLOBALS['post'] = get_post( $listings_id ); setup_postdata( $GLOBALS['post'] ); $this->set_loop_data(); - $ls_data = []; + $ls_data = array(); $ls_data['post_id'] = $listings_id; - $ls_data['manual_lat'] = get_post_meta($listings_id, '_manual_lat', true); - $ls_data['manual_lng'] = get_post_meta($listings_id, '_manual_lng', true); + $ls_data['manual_lat'] = get_post_meta( $listings_id, '_manual_lat', true ); + $ls_data['manual_lng'] = get_post_meta( $listings_id, '_manual_lng', true ); $ls_data['listing_img'] = directorist_get_listing_gallery_images( $listings_id ); $ls_data['listing_prv_img'] = directorist_get_listing_preview_image( $listings_id ); - $ls_data['phone'] = get_post_meta($listings_id, '_phone', true); + $ls_data['phone'] = get_post_meta( $listings_id, '_phone', true ); $ls_data['crop_width'] = $this->options['crop_width']; $ls_data['crop_height'] = $this->options['crop_height']; - $ls_data['address'] = get_post_meta($listings_id, '_address', true); + $ls_data['address'] = get_post_meta( $listings_id, '_address', true ); $ls_data['font_type'] = $this->options['font_type']; - $ls_data['fa_or_la'] = ('line' === $ls_data['font_type']) ? "la " : "fa "; - $ls_data['cats'] = get_the_terms($listings_id, ATBDP_CATEGORY); + $ls_data['fa_or_la'] = ( 'line' === $ls_data['font_type'] ) ? 'la ' : 'fa '; + $ls_data['cats'] = get_the_terms( $listings_id, ATBDP_CATEGORY ); $ls_data['listings'] = $this; - $cat_icon = directorist_icon( $this->loop_map_cat_icon(), false ); + $cat_icon = directorist_icon( $this->loop_map_cat_icon(), false ); $ls_data['cat_icon'] = json_encode( $cat_icon ); - $listing_type = directorist_get_listing_directory( $listings_id ); + $listing_type = directorist_get_listing_directory( $listings_id ); $ls_data['default_img'] = Helper::default_preview_image_src( $listing_type ); - if (!empty($ls_data['listing_prv_img'])) { - $ls_data['prv_image'] = atbdp_get_image_source($ls_data['listing_prv_img'], 'large'); + if ( ! empty( $ls_data['listing_prv_img'] ) ) { + $ls_data['prv_image'] = atbdp_get_image_source( $ls_data['listing_prv_img'], 'large' ); } - if (!empty($ls_data['listing_img'][0])) { - $ls_data['gallery_img'] = atbdp_get_image_source($ls_data['listing_img'][0], 'medium'); + if ( ! empty( $ls_data['listing_img'][0] ) ) { + $ls_data['gallery_img'] = atbdp_get_image_source( $ls_data['listing_img'][0], 'medium' ); } if ( ! empty( $ls_data['manual_lat'] ) && ! empty( $ls_data['manual_lng'] ) ) { @@ -1646,103 +1635,104 @@ public function load_google_map() { $GLOBALS['post'] = $original_post; wp_reset_postdata(); endif; - echo "</div>"; - } + echo '</div>'; + } - public function get_favorite_badge() { - Helper::get_template( 'archive/fields/favorite_badge', array( 'listings' => $this ) ); - } + public function get_favorite_badge() { + Helper::get_template( 'archive/fields/favorite_badge', array( 'listings' => $this ) ); + } - public function get_user_avatar() { - Helper::get_template( 'archive/fields/user_avatar', array( 'listings' => $this ) ); - } + public function get_user_avatar() { + Helper::get_template( 'archive/fields/user_avatar', array( 'listings' => $this ) ); + } - public function get_listing_review() { - Helper::get_template( 'archive/fields/rating', array( 'listings' => $this ) ); - } + public function get_listing_review() { + Helper::get_template( 'archive/fields/rating', array( 'listings' => $this ) ); + } + + public function get_price() { + Helper::get_template( 'archive/fields/pricing', array( 'listings' => $this ) ); + } - public function get_price() { - Helper::get_template( 'archive/fields/pricing', array( 'listings' => $this ) ); + protected function cache_thumbnails() { + if ( $this->thumbnails_cached || empty( $this->query_results->ids ) ) { + return; } - protected function cache_thumbnails() { - if ( $this->thumbnails_cached || empty( $this->query_results->ids ) ) { - return; + $thumb_ids = array(); + foreach ( $this->query_results->ids as $id ) { + $id = directorist_get_listing_thumbnail_id( $id ); + if ( $id ) { + $thumb_ids[] = $id; } + } - $thumb_ids = array(); - foreach ( $this->query_results->ids as $id ) { - $id = directorist_get_listing_thumbnail_id( $id ); - if ( $id ) { - $thumb_ids[] = $id; - } - } + if ( ! empty( $thumb_ids ) ) { + _prime_post_caches( $thumb_ids, false, true ); + } - if ( ! empty( $thumb_ids ) ) { - _prime_post_caches( $thumb_ids, false, true ); - } + $this->thumbnails_cached = true; + } - $this->thumbnails_cached = true; - } + function loop_get_the_thumbnail( $class = '' ) { + $default_image_src = Helper::default_preview_image_src( $this->current_listing_type ); - function loop_get_the_thumbnail( $class = '' ) { - $default_image_src = Helper::default_preview_image_src( $this->current_listing_type ); + $id = get_the_ID(); + $image_quality = get_directorist_option( 'preview_image_quality', 'directorist_preview' ); + $listing_prv_img = directorist_get_listing_preview_image( $id ); + $listing_img = directorist_get_listing_gallery_images( $id ); - $id = get_the_ID(); - $image_quality = get_directorist_option('preview_image_quality', 'directorist_preview'); - $listing_prv_img = directorist_get_listing_preview_image( $id ); - $listing_img = directorist_get_listing_gallery_images( $id ); + $thumbnail_img_id = array_filter( array_merge( (array) $listing_prv_img, (array) $listing_img ) ); + $link_start = '<a href="' . esc_url( $this->loop['permalink'] ) . '"><figure>'; + $link_end = '</figure></a>'; + if ( empty( $thumbnail_img_id ) ) { + $thumbnail_img_id = $default_image_src; + $image_alt = esc_html( get_the_title( $id ) ); + $image = "<img src='$default_image_src' alt='$image_alt' class='$class' />"; + if ( ! $this->disable_single_listing ) { + $image = $link_start . $image . $link_end; + } + return $image; + } + $thumbnail_img_id = array_filter( + $thumbnail_img_id, + function ( $value ) { + return is_numeric( $value ); + } + ); - $thumbnail_img_id = array_filter( array_merge( (array) $listing_prv_img, (array) $listing_img ) ); - $link_start = '<a href="'. esc_url( $this->loop['permalink'] ) .'"><figure>'; - $link_end = '</figure></a>'; + $image_count = count( $thumbnail_img_id ); - if ( empty( $thumbnail_img_id ) ) { - $thumbnail_img_id = $default_image_src; - $image_alt = esc_html( get_the_title( $id ) ); - $image = "<img src='$default_image_src' alt='$image_alt' class='$class' />"; - if ( ! $this->disable_single_listing ) { - $image = $link_start . $image . $link_end; - } - return $image; + if ( 1 === (int) $image_count ) { + $image_src = atbdp_get_image_source( reset( $thumbnail_img_id ), $image_quality ); + $image_alt = get_post_meta( reset( $thumbnail_img_id ), '_wp_attachment_image_alt', true ); + $image_alt = ( ! empty( $image_alt ) ) ? esc_attr( $image_alt ) : esc_html( get_the_title( reset( $thumbnail_img_id ) ) ); + $image = "<img src='$image_src' alt='$image_alt' class='$class' />"; + if ( ! $this->disable_single_listing ) { + $image = $link_start . $image . $link_end; } + return $image; + } else { + $output = "<div class='directorist-swiper directorist-swiper-listing' data-sw-items='1' data-sw-margin='2' data-sw-loop='true' data-sw-perslide='1' data-sw-speed='500' data-sw-autoplay='false' data-sw-responsive='{}'> + <div class='swiper-wrapper'>"; - $thumbnail_img_id = array_filter($thumbnail_img_id, function($value) { - return is_numeric($value); - }); + foreach ( $thumbnail_img_id as $img_id ) { - $image_count = count( $thumbnail_img_id ); + $image_src = atbdp_get_image_source( $img_id, $image_quality ); + $image_alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true ); + $image_alt = ! empty( $image_alt ) ? esc_attr( $image_alt ) : esc_html( get_the_title( $img_id ) ); + $image = "<img src='$image_src' alt='$image_alt' class='$class' />"; - if ( 1 === (int) $image_count ) { - $image_src = atbdp_get_image_source( reset( $thumbnail_img_id ), $image_quality ); - $image_alt = get_post_meta( reset( $thumbnail_img_id ), '_wp_attachment_image_alt', true ); - $image_alt = ( ! empty( $image_alt ) ) ? esc_attr( $image_alt ) : esc_html( get_the_title( reset( $thumbnail_img_id ) ) ); - $image = "<img src='$image_src' alt='$image_alt' class='$class' />"; if ( ! $this->disable_single_listing ) { $image = $link_start . $image . $link_end; } - return $image; - } else { - $output = "<div class='directorist-swiper directorist-swiper-listing' data-sw-items='1' data-sw-margin='2' data-sw-loop='true' data-sw-perslide='1' data-sw-speed='500' data-sw-autoplay='false' data-sw-responsive='{}'> - <div class='swiper-wrapper'>"; - foreach ( $thumbnail_img_id as $img_id ) { - - $image_src = atbdp_get_image_source( $img_id, $image_quality ); - $image_alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true ); - $image_alt = ! empty( $image_alt ) ? esc_attr( $image_alt ) : esc_html( get_the_title( $img_id ) ); - $image = "<img src='$image_src' alt='$image_alt' class='$class' />"; - - if ( ! $this->disable_single_listing ) { - $image = $link_start . $image . $link_end; - } - - $output .= "<div class='swiper-slide'>$image</div>"; - } + $output .= "<div class='swiper-slide'>$image</div>"; + } - $output .= "</div> + $output .= "</div> <div class='directorist-swiper__navigation'> <div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-listing'>" . directorist_icon( 'las la-angle-left', false ) . "</div> <div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-listing'>" . directorist_icon( 'las la-angle-right', false ) . "</div> @@ -1751,44 +1741,42 @@ function loop_get_the_thumbnail( $class = '' ) { <div class='directorist-swiper__pagination directorist-swiper__pagination--listing'></div> </div>"; - return $output; + return $output; - } } + } - public function loop_thumb_card_template() { - Helper::get_template( 'archive/fields/thumb-card', array('listings' => $this) ); - } + public function loop_thumb_card_template() { + Helper::get_template( 'archive/fields/thumb-card', array( 'listings' => $this ) ); + } - public function loop_get_published_date( $data ) { - $publish_date_format = $data['date_type']; - if ('days_ago' === $publish_date_format) { - $text = sprintf(__('Posted %s ago', 'directorist'), human_time_diff(get_the_time('U'), current_time('timestamp'))); - } - else { - $text = get_the_date(); - } - return $text; + public function loop_get_published_date( $data ) { + $publish_date_format = $data['date_type']; + if ( 'days_ago' === $publish_date_format ) { + $text = sprintf( __( 'Posted %s ago', 'directorist' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) ); + } else { + $text = get_the_date(); } + return $text; + } - public function loop_get_title() { - if ( ! $this->disable_single_listing ) { - $title = sprintf('<a href="%s"%s>%s</a>', apply_filters( 'directorist_archive_single_listing_url', $this->loop['permalink'], $this->loop['id'], 'title' ), $this->loop_link_attr(), $this->loop['title']); - } - else { - $title = $this->loop['title']; - } - return $title; + public function loop_get_title() { + if ( ! $this->disable_single_listing ) { + $title = sprintf( '<a href="%s"%s>%s</a>', apply_filters( 'directorist_archive_single_listing_url', $this->loop['permalink'], $this->loop['id'], 'title' ), $this->loop_link_attr(), $this->loop['title'] ); + } else { + $title = $this->loop['title']; } + return $title; + } - public function loop_get_tagline() { - return $this->loop['tagline']; - } + public function loop_get_tagline() { + return $this->loop['tagline']; + } - public function loop_is_favourite() { - $favourites = directorist_get_user_favorites( get_current_user_id() ); - return in_array( get_the_id() , $favourites ); - } + public function loop_is_favourite() { + $favourites = directorist_get_user_favorites( get_current_user_id() ); + return in_array( get_the_id(), $favourites ); + } /** * Unused method @@ -1797,93 +1785,89 @@ public function loop_is_favourite() { * * @return string */ - public function item_found_title_for_search($count) { - $cat_name = $loc_name = ''; - - if ( isset($_GET['in_cat'] ) ) { - $cat_id = intval($_GET['in_cat']); - $cat = get_term_by('id', $cat_id, ATBDP_CATEGORY); - if ( $cat ) { - $cat_name = $cat->name; - } - } - - if ( isset($_GET['in_loc'] ) ) { - $loc_id = intval($_GET['in_cat']); - $loc = get_term_by('id', $loc_id, ATBDP_LOCATION); - if ( $loc ) { - $loc_name = $loc->name; - } - } - elseif ( isset($_GET['address'] ) ) { - $loc_name = sanitize_text_field( wp_unslash( $_GET['address'] ) ); - } - - if ( $cat_name && $loc_name ) { - $title = sprintf( _nx( '%s result for %s in %s', '%s results for %s in %s', $count, 'search result header', 'directorist' ), $count, $cat_name, $loc_name ); - } - elseif ( $cat_name ) { - $title = sprintf( _nx( '%s result for %s', '%s results for %s', $count, 'search result header', 'directorist' ), $count, $cat_name ); - } - elseif ( $loc_name ) { - $title = sprintf( _nx( '%s result in %s', '%s results in %s', $count, 'search result header', 'directorist' ), $count, $loc_name ); - } - else { - $title = sprintf( _nx( '%s result', '%s results', $count, 'search result header', 'directorist' ), $count ); + public function item_found_title_for_search( $count ) { + $cat_name = $loc_name = ''; + + if ( isset( $_GET['in_cat'] ) ) { + $cat_id = intval( $_GET['in_cat'] ); + $cat = get_term_by( 'id', $cat_id, ATBDP_CATEGORY ); + if ( $cat ) { + $cat_name = $cat->name; } + } - if ( ! empty( $this->header_title ) ) { - $title = sprintf('<span>%s</span> %s', $count, $this->header_title); + if ( isset( $_GET['in_loc'] ) ) { + $loc_id = intval( $_GET['in_cat'] ); + $loc = get_term_by( 'id', $loc_id, ATBDP_LOCATION ); + if ( $loc ) { + $loc_name = $loc->name; } - - return $title; + } elseif ( isset( $_GET['address'] ) ) { + $loc_name = sanitize_text_field( wp_unslash( $_GET['address'] ) ); } - public function item_found_title() { - $count = $this->query_results->total; - $title = sprintf('<span>%s</span> %s', $count, $this->header_title ); - return apply_filters('directorist_listings_found_text', $title ); + if ( $cat_name && $loc_name ) { + $title = sprintf( _nx( '%1$s result for %2$s in %3$s', '%1$s results for %2$s in %3$s', $count, 'search result header', 'directorist' ), $count, $cat_name, $loc_name ); + } elseif ( $cat_name ) { + $title = sprintf( _nx( '%1$s result for %2$s', '%1$s results for %2$s', $count, 'search result header', 'directorist' ), $count, $cat_name ); + } elseif ( $loc_name ) { + $title = sprintf( _nx( '%1$s result in %2$s', '%1$s results in %2$s', $count, 'search result header', 'directorist' ), $count, $loc_name ); + } else { + $title = sprintf( _nx( '%s result', '%s results', $count, 'search result header', 'directorist' ), $count ); } - public function has_masonry() { - return ( $this->view_as == 'masonry_grid' ) ? true : false; + if ( ! empty( $this->header_title ) ) { + $title = sprintf( '<span>%s</span> %s', $count, $this->header_title ); } - public function masonary_grid_attr() { - return ($this->view_as !== 'masonry_grid') ? '' : ' data-uk-grid'; - } + return $title; + } - public function grid_view_class() { - return $this->view_as == 'masonry_grid' ? 'directorist-grid-masonary' : 'directorist-grid-normal'; - } + public function item_found_title() { + $count = $this->query_results->total; + $title = sprintf( '<span>%s</span> %s', $count, $this->header_title ); + return apply_filters( 'directorist_listings_found_text', $title ); + } - public function pagination_infinite_scroll_class() { - return ! empty( $this->show_pagination ) - && isset( $this->options['pagination_type'] ) - && $this->options['pagination_type'] === 'infinite_scroll' - ? 'directorist-infinite-scroll' - : ''; - } - public function get_the_location() { - return get_the_term_list( get_the_ID(), ATBDP_LOCATION, '', ', ', '' ); - } + public function has_masonry() { + return ( $this->view_as == 'masonry_grid' ) ? true : false; + } - public function loop_wrapper_class() { - $class = []; + public function masonary_grid_attr() { + return ( $this->view_as !== 'masonry_grid' ) ? '' : ' data-uk-grid'; + } - if ( $this->loop['featured'] ) { - $class[] = 'directorist-featured'; - } + public function grid_view_class() { + return $this->view_as == 'masonry_grid' ? 'directorist-grid-masonary' : 'directorist-grid-normal'; + } - if ( $this->info_display_in_single_line ) { - $class[] = 'directorist-single-line'; - } + public function pagination_infinite_scroll_class() { + return ! empty( $this->show_pagination ) + && isset( $this->options['pagination_type'] ) + && $this->options['pagination_type'] === 'infinite_scroll' + ? 'directorist-infinite-scroll' + : ''; + } + public function get_the_location() { + return get_the_term_list( get_the_ID(), ATBDP_LOCATION, '', ', ', '' ); + } - $class = apply_filters( 'directorist_loop_wrapper_class', $class, $this->current_listing_type ); + public function loop_wrapper_class() { + $class = array(); + + if ( $this->loop['featured'] ) { + $class[] = 'directorist-featured'; + } - return implode( ' ' , $class ); + if ( $this->info_display_in_single_line ) { + $class[] = 'directorist-single-line'; } + $class = apply_filters( 'directorist_loop_wrapper_class', $class, $this->current_listing_type ); + + return implode( ' ', $class ); + } + /** * Displays the class names for the listings wrapper element. * @@ -1891,10 +1875,10 @@ public function loop_wrapper_class() { * * @param string|string[] $class Space-separated string or array of class names to add to the class list. */ - public function wrapper_class( $class = '' ) { - // Separates class names with a single space, collates class names for wrapper tag element. - echo 'class="' . esc_attr( implode( ' ', $this->get_wrapper_class( $class ) ) ) . '"'; - } + public function wrapper_class( $class = '' ) { + // Separates class names with a single space, collates class names for wrapper tag element. + echo 'class="' . esc_attr( implode( ' ', $this->get_wrapper_class( $class ) ) ) . '"'; + } /** * Retrieves an array of the class names for the listings wrapper element. @@ -1904,217 +1888,215 @@ public function wrapper_class( $class = '' ) { * @param string|string[] $class Space-separated string or array of class names to add to the class list. * @return string[] Array of class names. */ - public function get_wrapper_class( $class = '' ) { - $classes = array( - 'directorist-archive-contents directorist-contents-wrap directorist-w-100', - ); + public function get_wrapper_class( $class = '' ) { + $classes = array( + 'directorist-archive-contents directorist-contents-wrap directorist-w-100', + ); - if ( 'yes' === $this->instant_search ) { - $classes[] = 'directorist-instant-search'; - } + if ( 'yes' === $this->instant_search ) { + $classes[] = 'directorist-instant-search'; + } - if ( ! empty( $class ) ) { - if ( ! is_array( $class ) ) { - $class = preg_split( '#\s+#', $class ); - } - $classes = array_merge( $classes, $class ); - } else { - // Ensure that we always coerce class to being an array. - $class = array(); + if ( ! empty( $class ) ) { + if ( ! is_array( $class ) ) { + $class = preg_split( '#\s+#', $class ); } + $classes = array_merge( $classes, $class ); + } else { + // Ensure that we always coerce class to being an array. + $class = array(); + } - $classes = array_map( 'esc_attr', $classes ); + $classes = array_map( 'esc_attr', $classes ); - /** - * Filters the list of CSS listings wrapper class names for the wrapper. - * - * @since 7.2.0 - * - * @param string[] $classes An array of listings wrapper class names. - * @param string[] $class An array of additional class names added to the listings wrapper. - * @param object $this An instantce of Directorist_Listings - */ - $classes = apply_filters( 'directorist_listings_wrapper_class', $classes, $class, $this ); + /** + * Filters the list of CSS listings wrapper class names for the wrapper. + * + * @since 7.2.0 + * + * @param string[] $classes An array of listings wrapper class names. + * @param string[] $class An array of additional class names added to the listings wrapper. + * @param object $this An instantce of Directorist_Listings + */ + $classes = apply_filters( 'directorist_listings_wrapper_class', $classes, $class, $this ); - return array_unique( $classes ); - } + return array_unique( $classes ); + } - public function data_atts() { - $this->atts['_current_page'] = $this->type; // search_result or listing - $this->atts['category_custom_fields_relations'] = directorist_get_category_custom_field_relations( $this->current_listing_type ); - // Separates class names with a single space, collates class names for wrapper tag element. - echo 'data-atts="' . esc_attr( json_encode( $this->atts ) ) . '"'; - } + public function data_atts() { + $this->atts['_current_page'] = $this->type; // search_result or listing + $this->atts['category_custom_fields_relations'] = directorist_get_category_custom_field_relations( $this->current_listing_type ); + // Separates class names with a single space, collates class names for wrapper tag element. + echo 'data-atts="' . esc_attr( json_encode( $this->atts ) ) . '"'; + } - public function loop_link_attr() { - $attr = " " . apply_filters('grid_view_title_link_add_attr', ''); - return trim($attr); - } + public function loop_link_attr() { + $attr = ' ' . apply_filters( 'grid_view_title_link_add_attr', '' ); + return trim( $attr ); + } - public function loop_thumbnail_link_attr() { - return trim( ' ' . apply_filters( 'grid_view_thumbnail_link_add_attr', '' ) ); - } + public function loop_thumbnail_link_attr() { + return trim( ' ' . apply_filters( 'grid_view_thumbnail_link_add_attr', '' ) ); + } - public function loop_title_link_attr() { - return trim( ' ' . apply_filters( 'grid_view_title_link_add_attr', '' ) ); - } + public function loop_title_link_attr() { + return trim( ' ' . apply_filters( 'grid_view_title_link_add_attr', '' ) ); + } - public function header_container_class() { - _deprecated_function( __METHOD__, '7.3.1' ); - } + public function header_container_class() { + _deprecated_function( __METHOD__, '7.3.1' ); + } - public function has_listings_header() { - $has_filter_button = ( ! empty( $this->listing_filters_button ) && ! empty( $this->search_more_filters_fields ) ); + public function has_listings_header() { + $has_filter_button = ( ! empty( $this->listing_filters_button ) && ! empty( $this->search_more_filters_fields ) ); - return ( $has_filter_button || ! empty( $this->header_title ) ) ? true : false; - } + return ( $has_filter_button || ! empty( $this->header_title ) ) ? true : false; + } - public function has_header_toolbar() { - return ( $this->display_viewas_dropdown || $this->display_sortby_dropdown ) ? true : false; - } + public function has_header_toolbar() { + return ( $this->display_viewas_dropdown || $this->display_sortby_dropdown ) ? true : false; + } - public function render_card_field( $field, $before = '', $after = '' ) { - if ( $field['type'] == 'badge' ) { - $this->render_badge_template($field); - } else { - $original_field = ''; - $submission_form_fields = get_term_meta( $this->current_listing_type, 'submission_form_fields', true ); + public function render_card_field( $field, $before = '', $after = '' ) { + if ( $field['type'] == 'badge' ) { + $this->render_badge_template( $field ); + } else { + $original_field = ''; + $submission_form_fields = get_term_meta( $this->current_listing_type, 'submission_form_fields', true ); - if ( isset( $field['original_widget_key'] ) && isset( $submission_form_fields['fields'][$field['original_widget_key']] ) ) { - $original_field = $submission_form_fields['fields'][$field['original_widget_key']]; - } + if ( isset( $field['original_widget_key'] ) && isset( $submission_form_fields['fields'][ $field['original_widget_key'] ] ) ) { + $original_field = $submission_form_fields['fields'][ $field['original_widget_key'] ]; + } - if ( ! empty( $original_field ) ) { - $field['original_field'] = $original_field; - } + if ( ! empty( $original_field ) ) { + $field['original_field'] = $original_field; + } - $load_template = true; + $load_template = true; - if ( ! empty( $original_field['field_key'] ) ) { - $meta_field_key = $original_field['field_key']; - } else if ( ! empty( $field['field_key'] ) ) { - $meta_field_key = $field['field_key']; - } else { - $meta_field_key = $field['widget_key']; - } + if ( ! empty( $original_field['field_key'] ) ) { + $meta_field_key = $original_field['field_key']; + } elseif ( ! empty( $field['field_key'] ) ) { + $meta_field_key = $field['field_key']; + } else { + $meta_field_key = $field['widget_key']; + } - $value = get_post_meta( get_the_id(), '_' . $meta_field_key, true ); - if ( empty( $value ) ) { - $value = get_post_meta( get_the_id(), $meta_field_key, true ); - } + $value = get_post_meta( get_the_id(), '_' . $meta_field_key, true ); + if ( empty( $value ) ) { + $value = get_post_meta( get_the_id(), $meta_field_key, true ); + } - if ( 'listings_location' === $field['widget_name'] ) { - $location = get_the_terms( get_the_id(), ATBDP_LOCATION ); - if ( ! is_wp_error( $location ) && ! empty( $location ) ) { - $value = true; - } + if ( 'listings_location' === $field['widget_name'] ) { + $location = get_the_terms( get_the_id(), ATBDP_LOCATION ); + if ( ! is_wp_error( $location ) && ! empty( $location ) ) { + $value = true; } + } - // If $load_template is false then what's the point going forward? why don't we return here! - if ( ! $value && $field['type'] === 'list-item' && 'posted_date' !== $field['widget_name'] ) { - return; // Return early, return wisely. - $load_template = false; - } + // If $load_template is false then what's the point going forward? why don't we return here! + if ( ! $value && $field['type'] === 'list-item' && 'posted_date' !== $field['widget_name'] ) { + return; // Return early, return wisely. + $load_template = false; + } - $args = array( - 'listings' => $this, - 'post_id' => get_the_id(), - 'data' => $field, - 'value' => $value, - 'label' => ( ! empty( $field['show_label'] ) ? $field['label'] : '' ), - 'icon' => directorist_get_var( $field['icon'] ), - 'original_field' => $submission_form_fields, - 'before' => $before, - 'after' => $after, - ); + $args = array( + 'listings' => $this, + 'post_id' => get_the_id(), + 'data' => $field, + 'value' => $value, + 'label' => ( ! empty( $field['show_label'] ) ? $field['label'] : '' ), + 'icon' => directorist_get_var( $field['icon'] ), + 'original_field' => $submission_form_fields, + 'before' => $before, + 'after' => $after, + ); - // Didn't find any $data within this method. - // if ( isset( $data['original_field'] ) && isset( $data['original_field']['widget_name'] ) ) { - // $widget_name = $data['original_field']['widget_name']; - // } + // Didn't find any $data within this method. + // if ( isset( $data['original_field'] ) && isset( $data['original_field']['widget_name'] ) ) { + // $widget_name = $data['original_field']['widget_name']; + // } - $widget_name = $field['widget_name']; - if ( $this->is_custom_field( $field ) ) { - $field_type = directorist_get_var( $field['original_field']['type'] ); + $widget_name = $field['widget_name']; + if ( $this->is_custom_field( $field ) ) { + $field_type = directorist_get_var( $field['original_field']['type'] ); - if ( 'checkbox' === $field_type ) { - if ( ! is_array( $value ) ) { - $value = array_filter( explode( ',', $value ) ); - } + if ( 'checkbox' === $field_type ) { + if ( ! is_array( $value ) ) { + $value = array_filter( explode( ',', $value ) ); + } - $options_value = ''; - $options = (array) directorist_get_var( $field['original_field']['options'], array() ); - foreach ( $options as $option ) { - if ( in_array( $option['option_value'], $value, true ) ) { - $options_value .= $option['option_label'] . ', '; - } + $options_value = ''; + $options = (array) directorist_get_var( $field['original_field']['options'], array() ); + foreach ( $options as $option ) { + if ( in_array( $option['option_value'], $value, true ) ) { + $options_value .= $option['option_label'] . ', '; } - - $args['value'] = rtrim( $options_value, ', ' ); } - $template = 'archive/custom-fields/' . $widget_name; - } else { - $template = 'archive/fields/' . $widget_name; + $args['value'] = rtrim( $options_value, ', ' ); } - if ( $load_template ) { - // Print $before and $after here so that empty li or other wrapper tags are not printed. - //echo wp_kses_post( $before ); - Helper::get_template( $template, $args ); - //echo wp_kses_post( $after ); - } + $template = 'archive/custom-fields/' . $widget_name; + } else { + $template = 'archive/fields/' . $widget_name; } - } - - public function is_custom_field( $data ) { - $fields = [ 'checkbox', 'color_picker', 'date', 'file', 'number', 'radio', 'select', 'text', 'textarea', 'time', 'url' ]; - $widget_name = $data['widget_name']; - if ( isset( $data['original_field'] ) && isset( $data['original_field']['widget_name'] ) ) { - $widget_name = $data['original_field']['widget_name']; + if ( $load_template ) { + // Print $before and $after here so that empty li or other wrapper tags are not printed. + // echo wp_kses_post( $before ); + Helper::get_template( $template, $args ); + // echo wp_kses_post( $after ); } + } + } + + public function is_custom_field( $data ) { + $fields = array( 'checkbox', 'color_picker', 'date', 'file', 'number', 'radio', 'select', 'text', 'textarea', 'time', 'url' ); + $widget_name = $data['widget_name']; - return in_array( $widget_name, $fields, true ); + if ( isset( $data['original_field'] ) && isset( $data['original_field']['widget_name'] ) ) { + $widget_name = $data['original_field']['widget_name']; } - public function has_whatsapp( $data ) { - if ( !empty( $data['original_field']['whatsapp'] ) ) { - return true; - } - else { - return false; - } + return in_array( $widget_name, $fields, true ); + } + + public function has_whatsapp( $data ) { + if ( ! empty( $data['original_field']['whatsapp'] ) ) { + return true; + } else { + return false; } + } - public function print_label( $label ) { - if ( $label ) { - $label_text = $label . ' : '; - $label_text = apply_filters( 'directorist_loop_label', $label_text, $label ); - echo wp_kses_post( $label_text ); - } - else { - return; - } + public function print_label( $label ) { + if ( $label ) { + $label_text = $label . ' : '; + $label_text = apply_filters( 'directorist_loop_label', $label_text, $label ); + echo wp_kses_post( $label_text ); + } else { + return; } + } - public function render_loop_fields( $fields, $before = '', $after = '' ) { - if ( ! empty( $fields ) ) { - foreach ( $fields as $field ) { - $this->render_card_field( $field, $before, $after ); - } + public function render_loop_fields( $fields, $before = '', $after = '' ) { + if ( ! empty( $fields ) ) { + foreach ( $fields as $field ) { + $this->render_card_field( $field, $before, $after ); } } + } - public function render_badge_template( $field ) { - global $post; - $id = get_the_ID(); + public function render_badge_template( $field ) { + global $post; + $id = get_the_ID(); - // for development purpose - do_action( 'atbdp_all_listings_badge_template', $field ); + // for development purpose + do_action( 'atbdp_all_listings_badge_template', $field ); - switch ($field['widget_key']) { - case 'popular_badge': + switch ( $field['widget_key'] ) { + case 'popular_badge': $field['class'] = 'popular'; $field['label'] = Helper::popular_badge_text(); if ( Helper::is_popular( $id ) ) { @@ -2122,10 +2104,10 @@ public function render_badge_template( $field ) { } break; - case 'featured_badge': - $field['class'] = 'featured'; - $field['label'] = Helper::featured_badge_text(); - $field['featured_badge_type'] = get_directorist_option( 'feature_badge_type', 'icon_badge'); + case 'featured_badge': + $field['class'] = 'featured'; + $field['label'] = Helper::featured_badge_text(); + $field['featured_badge_type'] = get_directorist_option( 'feature_badge_type', 'icon_badge' ); $field['featured_badge_class'] = ( 'text_badge' === $field['featured_badge_type'] ) ? 'directorist-badge-featured--only-text' : ''; if ( Helper::is_featured( $id ) ) { @@ -2133,298 +2115,314 @@ public function render_badge_template( $field ) { } break; - case 'new_badge': + case 'new_badge': $field['class'] = 'new'; $field['label'] = Helper::new_badge_text(); if ( Helper::is_new( $id ) ) { Helper::get_template( 'archive/fields/badge', $field ); } break; - } - - } - - public function listing_wrapper_class() { - echo ($this->loop['featured']) ? 'directorist-featured-listings' : ''; } + } - public function grid_container_fluid() { - $container = is_directoria_active() ? 'container' : 'container-fluid'; - return apply_filters( 'atbdp_listings_grid_container_fluid', $container ); - } + public function listing_wrapper_class() { + echo ( $this->loop['featured'] ) ? 'directorist-featured-listings' : ''; + } - public function sidebar_class() { - $class = 'no-sidebar-contents'; + public function grid_container_fluid() { + $container = is_directoria_active() ? 'container' : 'container-fluid'; + return apply_filters( 'atbdp_listings_grid_container_fluid', $container ); + } - if ( $this->sidebar ) { + public function sidebar_class() { + $class = 'no-sidebar-contents'; - switch ( $this->sidebar ) { - case 'left_sidebar': - $class = 'left-sidebar-contents'; - break; - case 'right_sidebar': - $class = 'right-sidebar-contents'; - break; - } + if ( $this->sidebar ) { + switch ( $this->sidebar ) { + case 'left_sidebar': + $class = 'left-sidebar-contents'; + break; + case 'right_sidebar': + $class = 'right-sidebar-contents'; + break; } - - return $class; } - public function hide_top_search_bar_on_sidebar_layout() { - return $this->options['listing_sidebar_top_search_bar'] ? $this->options['listing_sidebar_top_search_bar'] : false; - } + return $class; + } - public function sortby_dropdown_template() { - Helper::get_template( 'archive/sortby-dropdown', array( 'listings' => $this ) ); - } + public function hide_top_search_bar_on_sidebar_layout() { + return $this->options['listing_sidebar_top_search_bar'] ? $this->options['listing_sidebar_top_search_bar'] : false; + } - public function viewas_dropdown_template() { - Helper::get_template( 'archive/viewas-dropdown', array( 'listings' => $this ) ); - } + public function sortby_dropdown_template() { + Helper::get_template( 'archive/sortby-dropdown', array( 'listings' => $this ) ); + } - public function display_search_button() { - // Check if the layout is 'no_sidebar', in which case the button should always be displayed - if ( $this->options['all_listing_layout'] === 'no_sidebar' ) { - return true; - } + public function viewas_dropdown_template() { + Helper::get_template( 'archive/viewas-dropdown', array( 'listings' => $this ) ); + } - // If the layout is 'right_sidebar' or 'left_sidebar' and instant search is disabled, display the button - if ( in_array( $this->options['all_listing_layout'], ['right_sidebar', 'left_sidebar'] ) - && empty( $this->options['listing_instant_search'] ) ) { - return true; - } + public function display_search_button() { + // Check if the layout is 'no_sidebar', in which case the button should always be displayed + if ( $this->options['all_listing_layout'] === 'no_sidebar' ) { + return true; + } - // In all other cases, don't display the button - return false; + // If the layout is 'right_sidebar' or 'left_sidebar' and instant search is disabled, display the button + if ( in_array( $this->options['all_listing_layout'], array( 'right_sidebar', 'left_sidebar' ) ) + && empty( $this->options['listing_instant_search'] ) ) { + return true; } - public function search_form_template() { - // only catch atts with the prefix 'filter_' - $search_field_atts = array_filter( $this->atts, function( $key ) { + // In all other cases, don't display the button + return false; + } + + public function search_form_template() { + // only catch atts with the prefix 'filter_' + $search_field_atts = array_filter( + $this->atts, + function ( $key ) { return substr( $key, 0, 7 ) == 'filter_'; - }, ARRAY_FILTER_USE_KEY ); + }, + ARRAY_FILTER_USE_KEY + ); - $args = array( - 'listings' => $this, - 'searchform' => new Directorist_Listing_Search_Form( $this->type, $this->current_listing_type, $search_field_atts ), - ); - Helper::get_template( 'archive/search-form', $args ); - } + $args = array( + 'listings' => $this, + 'searchform' => new Directorist_Listing_Search_Form( $this->type, $this->current_listing_type, $search_field_atts ), + ); + Helper::get_template( 'archive/search-form', $args ); + } - public function basic_search_form_template() { - // only catch atts with the prefix 'filter_' - $search_field_atts = array_filter( $this->atts, function( $key ) { + public function basic_search_form_template() { + // only catch atts with the prefix 'filter_' + $search_field_atts = array_filter( + $this->atts, + function ( $key ) { return substr( $key, 0, 7 ) == 'filter_'; - }, ARRAY_FILTER_USE_KEY ); + }, + ARRAY_FILTER_USE_KEY + ); - $args = array( - 'listings' => $this, - 'searchform' => new Directorist_Listing_Search_Form( 'search_result', $this->current_listing_type, $search_field_atts ), - ); - Helper::get_template( 'archive/basic-search-form', $args ); - } + $args = array( + 'listings' => $this, + 'searchform' => new Directorist_Listing_Search_Form( 'search_result', $this->current_listing_type, $search_field_atts ), + ); + Helper::get_template( 'archive/basic-search-form', $args ); + } - public function advance_search_form_template() { - // only catch atts with the prefix 'filter_' - $search_field_atts = array_filter( $this->atts, function( $key ) { + public function advance_search_form_template() { + // only catch atts with the prefix 'filter_' + $search_field_atts = array_filter( + $this->atts, + function ( $key ) { return substr( $key, 0, 7 ) == 'filter_'; - }, ARRAY_FILTER_USE_KEY ); + }, + ARRAY_FILTER_USE_KEY + ); - $args = array( - 'listings' => $this, - 'searchform' => new Directorist_Listing_Search_Form( 'search_result', $this->current_listing_type, $search_field_atts ), - ); - Helper::get_template( 'archive/advance-search-form', $args ); - } + $args = array( + 'listings' => $this, + 'searchform' => new Directorist_Listing_Search_Form( 'search_result', $this->current_listing_type, $search_field_atts ), + ); + Helper::get_template( 'archive/advance-search-form', $args ); + } - public function filter_btn_html() { - if ( $this->has_filters_icon ) { - return sprintf( '%s %s', directorist_icon( 'las la-filter', false ), $this->filter_button_text ); - } - else { - return $this->filter_button_text; - } + public function filter_btn_html() { + if ( $this->has_filters_icon ) { + return sprintf( '%s %s', directorist_icon( 'las la-filter', false ), $this->filter_button_text ); + } else { + return $this->filter_button_text; } + } - public function mobile_view_filter_template() { - // only catch atts with the prefix 'filter_' - $search_field_atts = array_filter( $this->atts, function( $key ) { + public function mobile_view_filter_template() { + // only catch atts with the prefix 'filter_' + $search_field_atts = array_filter( + $this->atts, + function ( $key ) { return substr( $key, 0, 7 ) == 'filter_'; - }, ARRAY_FILTER_USE_KEY ); + }, + ARRAY_FILTER_USE_KEY + ); - $args = array( - 'listings' => $this, - 'searchform' => new Directorist_Listing_Search_Form( $this->type, $this->current_listing_type, $search_field_atts ), - ); - Helper::get_template( 'archive/mobile-search-form', $args ); - } + $args = array( + 'listings' => $this, + 'searchform' => new Directorist_Listing_Search_Form( $this->type, $this->current_listing_type, $search_field_atts ), + ); + Helper::get_template( 'archive/mobile-search-form', $args ); + } - public function directory_type_nav_template() { - if ( count( $this->listing_types ) > 1 && directorist_is_multi_directory_enabled() ) { - Helper::get_template( 'archive/directory-type-nav', array('listings' => $this) ); - } + public function directory_type_nav_template() { + if ( count( $this->listing_types ) > 1 && directorist_is_multi_directory_enabled() ) { + Helper::get_template( 'archive/directory-type-nav', array( 'listings' => $this ) ); } + } - public function header_bar_template() { - if ( !$this->header ) { - return; - } - - Helper::get_template( 'archive/header-bar', array('listings' => $this) ); + public function header_bar_template() { + if ( ! $this->header ) { + return; } - public function listings_header_title() { - $html = "<span class='directorist-header-found-title'>" . wp_kses_post( $this->item_found_title() ) . "</span>"; - $html = apply_filters( 'directorist_listings_header_title', $html ); + Helper::get_template( 'archive/header-bar', array( 'listings' => $this ) ); + } - return $html; - } + public function listings_header_title() { + $html = "<span class='directorist-header-found-title'>" . wp_kses_post( $this->item_found_title() ) . '</span>'; + $html = apply_filters( 'directorist_listings_header_title', $html ); + + return $html; + } - public function full_search_form_template() { - // only catch atts with the prefix 'filter_' - $search_field_atts = array_filter( $this->atts, function( $key ) { + public function full_search_form_template() { + // only catch atts with the prefix 'filter_' + $search_field_atts = array_filter( + $this->atts, + function ( $key ) { return substr( $key, 0, 7 ) == 'filter_'; - }, ARRAY_FILTER_USE_KEY ); + }, + ARRAY_FILTER_USE_KEY + ); - $args = array( - 'listings' => $this, - 'searchform' => new Directorist_Listing_Search_Form( $this->type, $this->current_listing_type, $search_field_atts ), - ); + $args = array( + 'listings' => $this, + 'searchform' => new Directorist_Listing_Search_Form( $this->type, $this->current_listing_type, $search_field_atts ), + ); - Helper::get_template( 'archive/search-form', $args ); - } + Helper::get_template( 'archive/search-form', $args ); + } - public function single_line_display_class() { - return $this->info_display_in_single_line ? 'directorist-single-line' : ''; - } + public function single_line_display_class() { + return $this->info_display_in_single_line ? 'directorist-single-line' : ''; + } - public function pagination( $echo = true ) { - $navigation = ''; - $paged = 1; - $largeNumber = 999999999; + public function pagination( $echo = true ) { + $navigation = ''; + $paged = 1; + $largeNumber = 999999999; - $total = ( isset( $this->query_results->total_pages ) ) ? $this->query_results->total_pages : $this->query_results->max_num_pages; - $paged = ( isset( $this->query_results->current_page ) ) ? $this->query_results->current_page : $paged; + $total = ( isset( $this->query_results->total_pages ) ) ? $this->query_results->total_pages : $this->query_results->max_num_pages; + $paged = ( isset( $this->query_results->current_page ) ) ? $this->query_results->current_page : $paged; - $links = paginate_links(array( - 'base' => str_replace($largeNumber, '%#%', esc_url(get_pagenum_link($largeNumber))), + $links = paginate_links( + array( + 'base' => str_replace( $largeNumber, '%#%', esc_url( get_pagenum_link( $largeNumber ) ) ), 'format' => '?paged=%#%', - 'current' => max(1, $paged), + 'current' => max( 1, $paged ), 'total' => $total, - 'prev_text' => apply_filters('directorist_pagination_prev_text', directorist_icon( 'fas fa-chevron-left', false )), - 'next_text' => apply_filters('directorist_pagination_next_text', directorist_icon( 'fas fa-chevron-right', false )), - )); - - if ( $links ) { - $navigation = '<nav class="directorist-pagination" aria-label="Listings Pagination">'.$links.'</nav>'; - } + 'prev_text' => apply_filters( 'directorist_pagination_prev_text', directorist_icon( 'fas fa-chevron-left', false ) ), + 'next_text' => apply_filters( 'directorist_pagination_next_text', directorist_icon( 'fas fa-chevron-right', false ) ), + ) + ); + if ( $links ) { + $navigation = '<nav class="directorist-pagination" aria-label="Listings Pagination">' . $links . '</nav>'; + } - $result = apply_filters('directorist_pagination', $navigation, $links, $this->query_results, $paged ); + $result = apply_filters( 'directorist_pagination', $navigation, $links, $this->query_results, $paged ); - if ( $echo ) { - echo wp_kses_post( $result ); - } - else { - return $result; - } + if ( $echo ) { + echo wp_kses_post( $result ); + } else { + return $result; } + } - // Hooks ------------ - public static function archive_type($listings) { - if ( count( $listings->listing_types ) > 1 && directorist_is_multi_directory_enabled() ) { - Helper::get_template( 'archive/listing-types', array('listings' => $listings) ); - } + // Hooks ------------ + public static function archive_type( $listings ) { + if ( count( $listings->listing_types ) > 1 && directorist_is_multi_directory_enabled() ) { + Helper::get_template( 'archive/listing-types', array( 'listings' => $listings ) ); } + } - public static function archive_header($listings) { - if ( !$listings->header ) { - return; - } - - Helper::get_template( 'archive/listings-header', array('listings' => $listings) ); + public static function archive_header( $listings ) { + if ( ! $listings->header ) { + return; } - public static function featured_badge( $content ) { - $featured = get_post_meta( get_the_ID(), '_featured', true ); - $feature_badge_text = get_directorist_option( 'feature_badge_text', __( 'Featured', 'directorist' ) ); + Helper::get_template( 'archive/listings-header', array( 'listings' => $listings ) ); + } - if ( $featured ) { - $badge_html = '<span class="atbd_badge atbd_badge_featured">' . $feature_badge_text. '</span>'; - return $content . $badge_html; - } + public static function featured_badge( $content ) { + $featured = get_post_meta( get_the_ID(), '_featured', true ); + $feature_badge_text = get_directorist_option( 'feature_badge_text', __( 'Featured', 'directorist' ) ); - return $content; + if ( $featured ) { + $badge_html = '<span class="atbd_badge atbd_badge_featured">' . $feature_badge_text . '</span>'; + return $content . $badge_html; } - public static function popular_badge( $content ) { - $popular_listing_id = atbdp_popular_listings(get_the_ID()); - $popular_badge_text = get_directorist_option( 'popular_badge_text', __( 'Popular', 'directorist' ) ); + return $content; + } - if ( $popular_listing_id === get_the_ID() ) { - $badge = '<span class="atbd_badge atbd_badge_popular">' . $popular_badge_text . '</span>'; - return $content . $badge; - } + public static function popular_badge( $content ) { + $popular_listing_id = atbdp_popular_listings( get_the_ID() ); + $popular_badge_text = get_directorist_option( 'popular_badge_text', __( 'Popular', 'directorist' ) ); - return $content; + if ( $popular_listing_id === get_the_ID() ) { + $badge = '<span class="atbd_badge atbd_badge_popular">' . $popular_badge_text . '</span>'; + return $content . $badge; } - public static function new_listing_badge( $content ) { - global $post; + return $content; + } - $new_listing_time = get_directorist_option('new_listing_day'); - $new_badge_text = get_directorist_option('new_badge_text', 'New'); - $each_hours = 60 * 60 * 24; // seconds in a day - $s_date1 = strtotime(current_time('mysql')); // seconds for date 1 - $s_date2 = strtotime($post->post_date); // seconds for date 2 - $s_date_diff = abs($s_date1 - $s_date2); // different of the two dates in seconds - $days = round($s_date_diff / $each_hours); // divided the different with second in a day - $new = '<span class="atbd_badge atbd_badge_new">' . $new_badge_text . '</span>'; - if ($days <= (int)$new_listing_time) { - return $content .= $new; + public static function new_listing_badge( $content ) { + global $post; - } + $new_listing_time = get_directorist_option( 'new_listing_day' ); + $new_badge_text = get_directorist_option( 'new_badge_text', 'New' ); + $each_hours = 60 * 60 * 24; // seconds in a day + $s_date1 = strtotime( current_time( 'mysql' ) ); // seconds for date 1 + $s_date2 = strtotime( $post->post_date ); // seconds for date 2 + $s_date_diff = abs( $s_date1 - $s_date2 ); // different of the two dates in seconds + $days = round( $s_date_diff / $each_hours ); // divided the different with second in a day + $new = '<span class="atbd_badge atbd_badge_new">' . $new_badge_text . '</span>'; + if ( $days <= (int) $new_listing_time ) { + return $content .= $new; - return $content; - } + } - public static function featured_badge_list_view( $content ) { - $featured = get_post_meta(get_the_ID(), '_featured', true); - $feature_badge_text = get_directorist_option('feature_badge_text', 'Featured'); + return $content; + } - if ( $featured ) { - $badge = "<span class='atbd_badge atbd_badge_featured'>$feature_badge_text</span>"; - $content .= $badge; - } + public static function featured_badge_list_view( $content ) { + $featured = get_post_meta( get_the_ID(), '_featured', true ); + $feature_badge_text = get_directorist_option( 'feature_badge_text', 'Featured' ); - return $content; - } + if ( $featured ) { + $badge = "<span class='atbd_badge atbd_badge_featured'>$feature_badge_text</span>"; + $content .= $badge; + } - public static function populer_badge_list_view( $content ) { - $popular_badge_text = get_directorist_option('popular_badge_text', 'Popular'); + return $content; + } - if ( atbdp_popular_listings(get_the_ID()) === get_the_ID() ) { - $badge = "<span class='atbd_badge atbd_badge_popular'>$popular_badge_text</span>"; - $content .= $badge; - } + public static function populer_badge_list_view( $content ) { + $popular_badge_text = get_directorist_option( 'popular_badge_text', 'Popular' ); - return $content; - } + if ( atbdp_popular_listings( get_the_ID() ) === get_the_ID() ) { + $badge = "<span class='atbd_badge atbd_badge_popular'>$popular_badge_text</span>"; + $content .= $badge; + } - public static function new_badge_list_view( $content ) { - $content .= new_badge(); + return $content; + } - return $content; - } + public static function new_badge_list_view( $content ) { + $content .= new_badge(); - public static function list_view_business_hours() { - _deprecated_function( __METHOD__, '7.3.1' ); - } + return $content; + } - public static function mark_as_favourite_button() { + public static function list_view_business_hours() { _deprecated_function( __METHOD__, '7.3.1' ); - } + } + public static function mark_as_favourite_button() { + _deprecated_function( __METHOD__, '7.3.1' ); + } } \ No newline at end of file diff --git a/includes/model/SearchForm.php b/includes/model/SearchForm.php index c5c670899d..b76279386f 100644 --- a/includes/model/SearchForm.php +++ b/includes/model/SearchForm.php @@ -5,12 +5,14 @@ namespace Directorist; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Listing_Search_Form { // Search Shortcode - public $options = []; + public $options = array(); public $type; public $listing_type; public $form_data; @@ -113,83 +115,83 @@ public function __get( $prop ) { // set_default_options public function set_default_options() { - $this->options['more_filters_fields'] = get_directorist_option( 'listing_filters_fields', array( 'search_text', 'search_category', 'search_location', 'search_price', 'search_price_range', 'search_rating', 'search_tag', 'search_custom_fields', 'radius_search' ) ); - $this->options['search_fields'] = get_directorist_option('search_tsc_fields', array('search_text', 'search_category', 'search_location')); - $this->options['search_filters'] = get_directorist_option('listings_filters_button', array('search_reset_filters', 'search_apply_filters')); - $this->options['search_listing_text'] = get_directorist_option('search_listing_text', __('Search Listing', 'directorist')); - $this->options['search_more_filter'] = !empty( get_directorist_option( 'search_more_filter', 1 ) ) ? 'yes' : ''; - $this->options['search_more_filters'] = get_directorist_option('search_more_filters', __('More Filters', 'directorist')); - $this->options['search_button'] = !empty( get_directorist_option( 'search_button', 1 ) ) ? 'yes' : ''; - $this->options['search_placeholder'] = get_directorist_option('listings_search_text_placeholder', __('What are you looking for?', 'directorist')); - $this->options['filters_buttons'] = get_directorist_option( 'listings_filters_button', array( 'reset_button', 'apply_button' ) ); - - $this->options['more_filters_button'] = get_directorist_option( 'listing_filters_button', 1 ); - $this->options['display_more_filter_icon'] = get_directorist_option('listing_filters_icon', 1); - $this->options['display_search_button_icon'] = get_directorist_option('listing_filters_icon', 1); - $this->options['open_filter_fields'] = get_directorist_option('listings_display_filter', 'sliding'); - - $this->options['reset_filters_text'] = get_directorist_option('listings_reset_text', __('Reset Filters', 'directorist')); - $this->options['reset_sidebar_filters_text'] = get_directorist_option( 'listings_sidebar_reset_text', __('Clear All', 'directorist') ); - $this->options['apply_filters_text'] = get_directorist_option( 'listings_apply_text', __( 'Apply Filters', 'directorist' ) ); + $this->options['more_filters_fields'] = get_directorist_option( 'listing_filters_fields', array( 'search_text', 'search_category', 'search_location', 'search_price', 'search_price_range', 'search_rating', 'search_tag', 'search_custom_fields', 'radius_search' ) ); + $this->options['search_fields'] = get_directorist_option( 'search_tsc_fields', array( 'search_text', 'search_category', 'search_location' ) ); + $this->options['search_filters'] = get_directorist_option( 'listings_filters_button', array( 'search_reset_filters', 'search_apply_filters' ) ); + $this->options['search_listing_text'] = get_directorist_option( 'search_listing_text', __( 'Search Listing', 'directorist' ) ); + $this->options['search_more_filter'] = ! empty( get_directorist_option( 'search_more_filter', 1 ) ) ? 'yes' : ''; + $this->options['search_more_filters'] = get_directorist_option( 'search_more_filters', __( 'More Filters', 'directorist' ) ); + $this->options['search_button'] = ! empty( get_directorist_option( 'search_button', 1 ) ) ? 'yes' : ''; + $this->options['search_placeholder'] = get_directorist_option( 'listings_search_text_placeholder', __( 'What are you looking for?', 'directorist' ) ); + $this->options['filters_buttons'] = get_directorist_option( 'listings_filters_button', array( 'reset_button', 'apply_button' ) ); + + $this->options['more_filters_button'] = get_directorist_option( 'listing_filters_button', 1 ); + $this->options['display_more_filter_icon'] = get_directorist_option( 'listing_filters_icon', 1 ); + $this->options['display_search_button_icon'] = get_directorist_option( 'listing_filters_icon', 1 ); + $this->options['open_filter_fields'] = get_directorist_option( 'listings_display_filter', 'sliding' ); + + $this->options['reset_filters_text'] = get_directorist_option( 'listings_reset_text', __( 'Reset Filters', 'directorist' ) ); + $this->options['reset_sidebar_filters_text'] = get_directorist_option( 'listings_sidebar_reset_text', __( 'Clear All', 'directorist' ) ); + $this->options['apply_filters_text'] = get_directorist_option( 'listings_apply_text', __( 'Apply Filters', 'directorist' ) ); } // update_options_for_search_result_page public function update_options_for_search_result_page() { - $this->options['more_filters_fields'] = get_directorist_option('search_result_filters_fields', array('search_price', 'search_price_range', 'search_rating', 'search_tag', 'search_custom_fields', 'radius_search')); - $this->options['search_filters'] = get_directorist_option('search_result_filters_button', array( 'reset_button', 'apply_button' ), true); - $this->options['more_filters_button'] = get_directorist_option( 'search_result_filters_button_display', 1 ); - $this->options['reset_filters_text'] = get_directorist_option('sresult_reset_text', __('Reset Filters', 'directorist')); - $this->options['reset_sidebar_filters_text'] = get_directorist_option( 'sresult_sidebar_reset_text', __('Clear All', 'directorist') ); - $this->options['apply_filters_text'] = get_directorist_option( 'sresult_apply_text', __( 'Apply Filters', 'directorist' ) ); + $this->options['more_filters_fields'] = get_directorist_option( 'search_result_filters_fields', array( 'search_price', 'search_price_range', 'search_rating', 'search_tag', 'search_custom_fields', 'radius_search' ) ); + $this->options['search_filters'] = get_directorist_option( 'search_result_filters_button', array( 'reset_button', 'apply_button' ), true ); + $this->options['more_filters_button'] = get_directorist_option( 'search_result_filters_button_display', 1 ); + $this->options['reset_filters_text'] = get_directorist_option( 'sresult_reset_text', __( 'Reset Filters', 'directorist' ) ); + $this->options['reset_sidebar_filters_text'] = get_directorist_option( 'sresult_sidebar_reset_text', __( 'Clear All', 'directorist' ) ); + $this->options['apply_filters_text'] = get_directorist_option( 'sresult_apply_text', __( 'Apply Filters', 'directorist' ) ); } // update_options_for_search_form public function update_options_for_search_form() { - $this->options['more_filters_fields'] = get_directorist_option('search_more_filters_fields', array( 'search_price', 'search_price_range', 'search_rating', 'search_tag', 'search_custom_fields', 'radius_search')); + $this->options['more_filters_fields'] = get_directorist_option( 'search_more_filters_fields', array( 'search_price', 'search_price_range', 'search_rating', 'search_tag', 'search_custom_fields', 'radius_search' ) ); - $this->options['search_filters'] = get_directorist_option('search_filters', array('search_reset_filters', 'search_apply_filters'), true ); + $this->options['search_filters'] = get_directorist_option( 'search_filters', array( 'search_reset_filters', 'search_apply_filters' ), true ); $this->options['more_filters_button'] = get_directorist_option( 'search_more_filter', 1 ); - $this->options['display_more_filter_icon'] = get_directorist_option('search_more_filter_icon', 1); - $this->options['display_search_button_icon'] = get_directorist_option('search_button_icon', 1); - $this->options['open_filter_fields'] = get_directorist_option('home_display_filter', 'sliding'); + $this->options['display_more_filter_icon'] = get_directorist_option( 'search_more_filter_icon', 1 ); + $this->options['display_search_button_icon'] = get_directorist_option( 'search_button_icon', 1 ); + $this->options['open_filter_fields'] = get_directorist_option( 'home_display_filter', 'sliding' ); - $this->options['reset_filters_text'] = get_directorist_option( 'search_reset_text', __('Reset Filters', 'directorist')); - $this->options['apply_filters_text'] = get_directorist_option( 'search_apply_filter', __( 'Apply Filters', 'directorist' ) ); + $this->options['reset_filters_text'] = get_directorist_option( 'search_reset_text', __( 'Reset Filters', 'directorist' ) ); + $this->options['apply_filters_text'] = get_directorist_option( 'search_apply_filter', __( 'Apply Filters', 'directorist' ) ); } // prepare_search_data - public function prepare_search_data($atts) { + public function prepare_search_data( $atts ) { $search_more_filters_fields = $this->options['more_filters_fields']; $search_filters = $this->options['search_filters']; $search_fields = $search_more_filters_fields; - $reset_filters_button = in_array('reset_button', $search_filters) ? 'yes' : ''; - $apply_filters_button = in_array('apply_button', $search_filters) ? 'yes' : ''; + $reset_filters_button = in_array( 'reset_button', $search_filters ) ? 'yes' : ''; + $apply_filters_button = in_array( 'apply_button', $search_filters ) ? 'yes' : ''; if ( 'search_form' === $this->type ) { - $search_fields = $this->options['search_fields']; - $reset_filters_button = in_array('search_reset_filters', $search_filters) ? 'yes' : ''; - $apply_filters_button = in_array('search_apply_filters', $search_filters) ? 'yes' : ''; + $search_fields = $this->options['search_fields']; + $reset_filters_button = in_array( 'search_reset_filters', $search_filters ) ? 'yes' : ''; + $apply_filters_button = in_array( 'search_apply_filters', $search_filters ) ? 'yes' : ''; } $this->defaults = array( - 'show_title_subtitle' => 'yes', - 'search_bar_title' => get_directorist_option('search_title', __("Search here", 'directorist')), - 'search_bar_sub_title' => get_directorist_option('search_subtitle', __("Find the best match of your interest", 'directorist')), - 'search_button' => $this->options['search_button'], - 'search_button_text' => $this->options['search_listing_text'], - 'more_filters_button' => ( $this->options['more_filters_button'] ) ? 'yes' : '', - 'more_filters_text' => $this->options['search_more_filters'], - 'reset_filters_button' => $reset_filters_button, - 'apply_filters_button' => $apply_filters_button, - 'reset_filters_text' => $this->options['reset_filters_text'], - 'apply_filters_text' => $this->options['apply_filters_text'], - 'logged_in_user_only' => '', - 'redirect_page_url' => '', - 'more_filters_display' => $this->options['open_filter_fields'], - 'directory_type' => '', - 'default_directory_type' => '', - 'show_popular_category' => ! empty( get_directorist_option('show_popular_category', 1 ) ) ? 'yes' : '' + 'show_title_subtitle' => 'yes', + 'search_bar_title' => get_directorist_option( 'search_title', __( 'Search here', 'directorist' ) ), + 'search_bar_sub_title' => get_directorist_option( 'search_subtitle', __( 'Find the best match of your interest', 'directorist' ) ), + 'search_button' => $this->options['search_button'], + 'search_button_text' => $this->options['search_listing_text'], + 'more_filters_button' => ( $this->options['more_filters_button'] ) ? 'yes' : '', + 'more_filters_text' => $this->options['search_more_filters'], + 'reset_filters_button' => $reset_filters_button, + 'apply_filters_button' => $apply_filters_button, + 'reset_filters_text' => $this->options['reset_filters_text'], + 'apply_filters_text' => $this->options['apply_filters_text'], + 'logged_in_user_only' => '', + 'redirect_page_url' => '', + 'more_filters_display' => $this->options['open_filter_fields'], + 'directory_type' => '', + 'default_directory_type' => '', + 'show_popular_category' => ! empty( get_directorist_option( 'show_popular_category', 1 ) ) ? 'yes' : '', ); $this->params = shortcode_atts( $this->defaults, $this->atts ); @@ -200,40 +202,40 @@ public function prepare_search_data($atts) { $this->has_reset_filters_button = $this->params['reset_filters_button'] == 'yes' ? true : false; $this->has_apply_filters_button = $this->params['apply_filters_button'] == 'yes' ? true : false; $this->logged_in_user_only = $this->params['logged_in_user_only'] == 'yes' ? true : false; - $this->show_connector = !empty( get_directorist_option('show_connector', 1) ) ? true : false; + $this->show_connector = ! empty( get_directorist_option( 'show_connector', 1 ) ) ? true : false; $this->show_popular_category = ( 'yes' == $this->params['show_popular_category'] ) ? true : false; - $this->search_bar_title = $this->params['search_bar_title']; - $this->search_bar_sub_title = $this->params['search_bar_sub_title']; - $this->search_button_text = $this->params['search_button_text']; - $this->more_filters_text = $this->params['more_filters_text']; - $this->reset_filters_text = $this->params['reset_filters_text']; - $this->apply_filters_text = $this->params['apply_filters_text']; - $this->more_filters_display = $this->params['more_filters_display']; - $this->redirect_page_url = $this->params['redirect_page_url']; - $this->directory_type = !empty( $this->params['directory_type'] ) ? explode( ',', $this->params['directory_type'] ) : ''; - $this->default_directory_type = !empty( $this->params['default_directory_type'] ) ? $this->params['default_directory_type'] : ''; - - $this->category_id = ''; - $this->category_class = 'search_fields bdas-category-search directorist-category-select'; - $this->location_id = ''; - $this->location_class = 'search_fields directorist-location-select'; - $this->connectors_title = get_directorist_option('connectors_title', __('Or', 'directorist')); - $this->popular_cat_title = get_directorist_option('popular_cat_title', __('Browse by popular categories', 'directorist')); - $this->popular_cat_num = get_directorist_option('popular_cat_num', 10); + $this->search_bar_title = $this->params['search_bar_title']; + $this->search_bar_sub_title = $this->params['search_bar_sub_title']; + $this->search_button_text = $this->params['search_button_text']; + $this->more_filters_text = $this->params['more_filters_text']; + $this->reset_filters_text = $this->params['reset_filters_text']; + $this->apply_filters_text = $this->params['apply_filters_text']; + $this->more_filters_display = $this->params['more_filters_display']; + $this->redirect_page_url = $this->params['redirect_page_url']; + $this->directory_type = ! empty( $this->params['directory_type'] ) ? explode( ',', $this->params['directory_type'] ) : ''; + $this->default_directory_type = ! empty( $this->params['default_directory_type'] ) ? $this->params['default_directory_type'] : ''; + + $this->category_id = ''; + $this->category_class = 'search_fields bdas-category-search directorist-category-select'; + $this->location_id = ''; + $this->location_class = 'search_fields directorist-location-select'; + $this->connectors_title = get_directorist_option( 'connectors_title', __( 'Or', 'directorist' ) ); + $this->popular_cat_title = get_directorist_option( 'popular_cat_title', __( 'Browse by popular categories', 'directorist' ) ); + $this->popular_cat_num = get_directorist_option( 'popular_cat_num', 10 ); } public function prepare_listing_data() { $filters_buttons = get_directorist_option( 'listings_filters_button', array( 'reset_button', 'apply_button' ), true ); $this->has_reset_filters_button = in_array( 'reset_button', $filters_buttons ) ? true : false; $this->has_apply_filters_button = in_array( 'apply_button', $filters_buttons ) ? true : false; - $this->reset_filters_text = get_directorist_option('listings_reset_text', __('Reset Filters', 'directorist')); + $this->reset_filters_text = get_directorist_option( 'listings_reset_text', __( 'Reset Filters', 'directorist' ) ); $this->apply_filters_text = get_directorist_option( 'listings_apply_text', __( 'Apply Filters', 'directorist' ) ); - $this->category_id = 'cat-type'; - $this->category_class = 'directory_field bdas-category-search directorist-category-select'; - $this->location_id = 'loc-type'; - $this->location_class = 'directory_field bdas-category-location directorist-location-select'; + $this->category_id = 'cat-type'; + $this->category_class = 'directory_field bdas-category-search directorist-category-select'; + $this->location_id = 'loc-type'; + $this->location_class = 'directory_field bdas-category-location directorist-location-select'; } public function build_search_data( $data ) { @@ -272,10 +274,12 @@ public function get_default_directory() { } if ( $this->directory_type && is_array( $this->directory_type ) ) { - $directories = directorist_get_directories( array( - 'fields' => 'ids', - 'slug' => $this->directory_type, - ) ); + $directories = directorist_get_directories( + array( + 'fields' => 'ids', + 'slug' => $this->directory_type, + ) + ); if ( ! is_wp_error( $directories ) && ! empty( $directories ) && ! in_array( $default_directory_id, $directories, true ) ) { $default_directory_id = $directories[0]; @@ -286,46 +290,45 @@ public function get_default_directory() { } public function build_form_data() { - $form_data = array(); + $form_data = array(); $search_form_fields = get_term_meta( $this->listing_type, 'search_form_fields', true ); $submission_form_fields = get_term_meta( $this->listing_type, 'submission_form_fields', true ); - if ( !empty( $search_form_fields['fields'] ) ) { + if ( ! empty( $search_form_fields['fields'] ) ) { foreach ( $search_form_fields['fields'] as $key => $value ) { - if ( ! is_array( $value) ) { + if ( ! is_array( $value ) ) { continue; } - $search_form_fields['fields'][$key]['field_key'] = ''; - $search_form_fields['fields'][$key]['options'] = []; + $search_form_fields['fields'][ $key ]['field_key'] = ''; + $search_form_fields['fields'][ $key ]['options'] = array(); $form_key = isset( $value['original_widget_key'] ) ? $value['original_widget_key'] : ''; - unset( $search_form_fields['fields'][$key]['widget_key'] ); - unset( $search_form_fields['fields'][$key]['original_widget_key'] ); + unset( $search_form_fields['fields'][ $key ]['widget_key'] ); + unset( $search_form_fields['fields'][ $key ]['original_widget_key'] ); if ( $form_key ) { - if ( !empty( $submission_form_fields['fields'][$form_key]['field_key'] ) ) { - $search_form_fields['fields'][$key]['field_key'] = $submission_form_fields['fields'][$form_key]['field_key']; + if ( ! empty( $submission_form_fields['fields'][ $form_key ]['field_key'] ) ) { + $search_form_fields['fields'][ $key ]['field_key'] = $submission_form_fields['fields'][ $form_key ]['field_key']; } - if ( !empty( $submission_form_fields['fields'][$form_key] ) ) { - $search_form_fields['fields'][$key]['options'] = $submission_form_fields['fields'][$form_key]; + if ( ! empty( $submission_form_fields['fields'][ $form_key ] ) ) { + $search_form_fields['fields'][ $key ]['options'] = $submission_form_fields['fields'][ $form_key ]; } } - } } - if ( !empty( $search_form_fields['groups'] ) ) { + if ( ! empty( $search_form_fields['groups'] ) ) { foreach ( $search_form_fields['groups'] as $group ) { $section = $group; $section['fields'] = array(); foreach ( $group['fields'] as $field ) { - $search_field = $search_form_fields['fields'][$field]; + $search_field = $search_form_fields['fields'][ $field ]; if ( $this->is_field_allowed_in_atts( $search_field['widget_name'] ) ) { $section['fields'][ $field ] = $search_field; @@ -342,62 +345,62 @@ public function build_form_data() { public function is_field_allowed_in_atts( $widget_name ) { $atts = ! empty( $this->atts[ 'filter_' . $widget_name ] ) ? $this->atts[ 'filter_' . $widget_name ] : ''; - if ( 'no' == $atts ){ + if ( 'no' == $atts ) { return false; } return true; } public function buttons_template() { - if ($this->has_reset_filters_button || $this->has_apply_filters_button) { - Helper::get_template( 'search-form/buttons', array('searchform' => $this) ); + if ( $this->has_reset_filters_button || $this->has_apply_filters_button ) { + Helper::get_template( 'search-form/buttons', array( 'searchform' => $this ) ); } } public function range_slider_unit( $data ) { - $radius_search_unit = !empty( $data['radius_search_unit'] ) ? $data['radius_search_unit'] : ''; + $radius_search_unit = ! empty( $data['radius_search_unit'] ) ? $data['radius_search_unit'] : ''; return ( 'kilometers' == $radius_search_unit ) ? __( 'Kilometers', 'directorist' ) : __( 'Miles', 'directorist' ); } - public function range_slider_minValue( $data ){ - return !empty( $_REQUEST['miles'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['miles'] ) ) : $data['default_radius_distance']; + public function range_slider_minValue( $data ) { + return ! empty( $_REQUEST['miles'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['miles'] ) ) : $data['default_radius_distance']; } public function range_slider_data( $data ) { - $data = [ - 'miles' => $this->range_slider_unit( $data ), + $data = array( + 'miles' => $this->range_slider_unit( $data ), 'minValue' => $this->range_slider_minValue( $data ), - ]; + ); - return json_encode( $data );; + return json_encode( $data ); } public function get_pricing_type() { $submission_form_fields = get_term_meta( $this->listing_type, 'submission_form_fields', true ); - $ptype = !empty( $submission_form_fields['fields']['pricing']['pricing_type'] ) ? $submission_form_fields['fields']['pricing']['pricing_type'] : 'both'; + $ptype = ! empty( $submission_form_fields['fields']['pricing']['pricing_type'] ) ? $submission_form_fields['fields']['pricing']['pricing_type'] : 'both'; return $ptype; } // custom field assign to category - public function assign_to_category(){ - $submission_form_fields = get_term_meta( $this->listing_type , 'submission_form_fields', true ); - $category_id = isset( $_REQUEST['cat_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['cat_id'] ) ) : ''; - $custom_field_key = array(); - $assign_to_cat = array(); - - if( $submission_form_fields['fields'] ) { - foreach( $submission_form_fields['fields'] as $field ) { - if( ! empty( $field['assign_to'] ) && $category_id != $field['category'] ) { + public function assign_to_category() { + $submission_form_fields = get_term_meta( $this->listing_type, 'submission_form_fields', true ); + $category_id = isset( $_REQUEST['cat_id'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['cat_id'] ) ) : ''; + $custom_field_key = array(); + $assign_to_cat = array(); + + if ( $submission_form_fields['fields'] ) { + foreach ( $submission_form_fields['fields'] as $field ) { + if ( ! empty( $field['assign_to'] ) && $category_id != $field['category'] ) { $custom_field_key[] = $field['field_key']; - $assign_to_cat[] = $field['category']; + $assign_to_cat[] = $field['category']; } } } $category_custom_field = array( - 'custom_field_key' => $custom_field_key, - 'assign_to_cat' => $assign_to_cat, + 'custom_field_key' => $custom_field_key, + 'assign_to_cat' => $assign_to_cat, ); return $category_custom_field; } @@ -408,30 +411,28 @@ public function field_template( $field_data ) { $field_data['lazy_load'] = get_directorist_option( 'lazy_load_taxonomy_fields', true ); if ( $this->is_custom_field( $field_data ) ) { - if ( !empty( $_REQUEST['custom_field'][$key] ) ) { - $value = is_array( $_REQUEST['custom_field'][$key] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['custom_field'][$key] ) ) : sanitize_text_field( wp_unslash( $_REQUEST['custom_field'][$key] ) ); + if ( ! empty( $_REQUEST['custom_field'][ $key ] ) ) { + $value = is_array( $_REQUEST['custom_field'][ $key ] ) ? array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['custom_field'][ $key ] ) ) : sanitize_text_field( wp_unslash( $_REQUEST['custom_field'][ $key ] ) ); } else { $value = ''; } + } else { + $value = $key && isset( $_REQUEST[ $key ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $key ] ) ) : ''; } - else { - $value = $key && isset( $_REQUEST[$key] ) ? sanitize_text_field( wp_unslash( $_REQUEST[$key] ) ): ''; - } - $args = array( - 'searchform' => $this, - 'data' => $field_data, - 'value' => $value, - 'empty_label' => empty( $field_data['label'] ) ? 'input-has-noLabel' : '', + 'searchform' => $this, + 'data' => $field_data, + 'value' => $value, + 'empty_label' => empty( $field_data['label'] ) ? 'input-has-noLabel' : '', ); // if ( $this->is_custom_field( $field_data ) && ( ! in_array( $field_data['field_key'], $this->assign_to_category()['custom_field_key'] ) ) ) { - // if( ! empty( $field_data['type'] ) && 'number' != $field_data['type'] ) { - // $template = 'search-form/custom-fields/number/' . $field_data['type']; - // } else { - // $template = 'search-form/custom-fields/' . $field_data['widget_name']; - // } + // if( ! empty( $field_data['type'] ) && 'number' != $field_data['type'] ) { + // $template = 'search-form/custom-fields/number/' . $field_data['type']; + // } else { + // $template = 'search-form/custom-fields/' . $field_data['widget_name']; + // } // } if ( $this->is_custom_field( $field_data ) ) { @@ -449,7 +450,7 @@ public function field_template( $field_data ) { } public function is_custom_field( $data ) { - $fields = [ 'checkbox', 'color_picker', 'date', 'file', 'number', 'radio', 'select', 'text', 'textarea', 'time', 'url' ]; + $fields = array( 'checkbox', 'color_picker', 'date', 'file', 'number', 'radio', 'select', 'text', 'textarea', 'time', 'url' ); return in_array( $data['widget_name'], $fields, true ); } @@ -470,45 +471,45 @@ public function directory_type_nav_template() { return; } - Helper::get_template( 'search-form/directory-type-nav', [ 'searchform' => $this ] ); + Helper::get_template( 'search-form/directory-type-nav', array( 'searchform' => $this ) ); } public function has_more_filters_icon() { $more_filters_icon = $this->options['display_more_filter_icon']; - return !empty( $more_filters_icon ) ? true : false; + return ! empty( $more_filters_icon ) ? true : false; } public function has_search_button_icon() { $search_button_icon = $this->options['display_search_button_icon']; - return !empty( $search_button_icon ) ? true : false; + return ! empty( $search_button_icon ) ? true : false; } public function get_basic_fields() { return ! empty( $this->form_data[0]['fields'] ) && is_array( $this->form_data[0]['fields'] ) - ? $this->form_data[0]['fields'] - : []; + ? $this->form_data[0]['fields'] + : array(); } public function get_advance_fields() { return ! empty( $this->form_data[1]['fields'] ) && is_array( $this->form_data[1]['fields'] ) - ? $this->form_data[1]['fields'] - : []; + ? $this->form_data[1]['fields'] + : array(); } public function more_buttons_template() { - Helper::get_template( 'search-form/more-buttons', [ 'searchform' => $this ] ); + Helper::get_template( 'search-form/more-buttons', array( 'searchform' => $this ) ); } public function advanced_search_form_basic_fields_template() { - Helper::get_template( 'search-form/basic-search', array('searchform' => $this) ); + Helper::get_template( 'search-form/basic-search', array( 'searchform' => $this ) ); } public function advanced_search_form_fields_template() { - Helper::get_template( 'search-form/adv-search', array('searchform' => $this) ); + Helper::get_template( 'search-form/adv-search', array( 'searchform' => $this ) ); } public function top_categories() { - $top_categories = []; + $top_categories = array(); $args = array( 'type' => ATBDP_POST_TYPE, @@ -516,7 +517,7 @@ public function top_categories() { 'orderby' => 'count', 'order' => 'desc', 'hide_empty' => 1, - 'number' => (int)$this->popular_cat_num, + 'number' => (int) $this->popular_cat_num, 'taxonomy' => ATBDP_CATEGORY, 'no_found_rows' => true, ); @@ -524,11 +525,11 @@ public function top_categories() { $cats = get_categories( $args ); foreach ( $cats as $cat ) { - $directory_type = get_term_meta( $cat->term_id, '_directory_type', true ); - $directory_type = ! empty( $directory_type ) ? $directory_type : array(); - $listing_type_id = $this->listing_type; + $directory_type = get_term_meta( $cat->term_id, '_directory_type', true ); + $directory_type = ! empty( $directory_type ) ? $directory_type : array(); + $listing_type_id = $this->listing_type; - if( in_array( $listing_type_id, $directory_type ) ) { + if ( in_array( $listing_type_id, $directory_type ) ) { $top_categories[] = $cat; } } @@ -539,13 +540,13 @@ public function top_categories() { public function top_categories_template() { if ( $this->show_popular_category ) { $top_categories = $this->top_categories(); - $title = get_directorist_option( 'popular_cat_title', __( 'Browse by popular categories', 'directorist' ) ); + $title = get_directorist_option( 'popular_cat_title', __( 'Browse by popular categories', 'directorist' ) ); - if ( !empty($top_categories) ) { + if ( ! empty( $top_categories ) ) { $args = array( - 'searchform' => $this, - 'top_categories' => $top_categories, - 'title' => $title, + 'searchform' => $this, + 'top_categories' => $top_categories, + 'title' => $title, ); Helper::get_template( 'search-form/top-cats', $args ); } @@ -566,11 +567,11 @@ public function search_category_location_args() { 'active_term_id' => 0, 'ancestors' => array(), 'listing_type' => $this->listing_type, - 'categories_with_custom_field' => array_values( directorist_get_category_custom_field_relations( $this->listing_type ) ) + 'categories_with_custom_field' => array_values( directorist_get_category_custom_field_relations( $this->listing_type ) ), ); } - public function price_value($arg) { + public function price_value( $arg ) { if ( $arg == 'min' ) { return isset( $_REQUEST['price'][0] ) ? sanitize_text_field( wp_unslash( $_REQUEST['price'][0] ) ) : ''; } @@ -582,9 +583,9 @@ public function price_value($arg) { return ''; } - public function the_price_range_input($range) { + public function the_price_range_input( $range ) { $checked = ! empty( $_REQUEST['price_range'] ) && $_REQUEST['price_range'] == $range ? ' checked="checked"' : ''; - printf('<input type="radio" name="price_range" value="%s"%s>', esc_attr( $range ), esc_attr( $checked ) ); + printf( '<input type="radio" name="price_range" value="%s"%s>', esc_attr( $range ), esc_attr( $checked ) ); } public function get_atts_data() { @@ -593,18 +594,18 @@ public function get_atts_data() { return json_encode( $this->params ); } - public function render_search_shortcode( $atts = [] ) { + public function render_search_shortcode( $atts = array() ) { if ( $this->logged_in_user_only && ! is_user_logged_in() ) { - return ATBDP()->helper->guard( array('type' => 'auth') ); + return ATBDP()->helper->guard( array( 'type' => 'auth' ) ); } - if ($this->redirect_page_url) { - $redirect = '<script>window.location="' . esc_url($this->redirect_page_url) . '"</script>'; + if ( $this->redirect_page_url ) { + $redirect = '<script>window.location="' . esc_url( $this->redirect_page_url ) . '"</script>'; return $redirect; } - return Helper::get_template_contents( 'search-form-contents', [ 'searchform' => $this ] ); + return Helper::get_template_contents( 'search-form-contents', array( 'searchform' => $this ) ); } public function listing_type_slug() { @@ -625,19 +626,19 @@ public function border_class() { return empty( $search_border ) ? 'directorist-no-search-border' : 'directorist-with-search-border'; } - public function category_icon_class($cat) { - $icon = get_cat_icon($cat->term_id); - $icon_type = substr($icon, 0, 2); - $icon_class = ('la' === $icon_type) ? $icon_type . ' ' . $icon : 'fa ' . $icon; + public function category_icon_class( $cat ) { + $icon = get_cat_icon( $cat->term_id ); + $icon_type = substr( $icon, 0, 2 ); + $icon_class = ( 'la' === $icon_type ) ? $icon_type . ' ' . $icon : 'fa ' . $icon; return $icon_class; } public function zip_code_class() { - $class = 'directorist-form-element'; - $radius_search = $this->build_search_data( 'radius_search' ); + $class = 'directorist-form-element'; + $radius_search = $this->build_search_data( 'radius_search' ); $radius_search_based_on = ! empty( $radius_search['radius_search_based_on'] ) ? $radius_search['radius_search_based_on'] : 'address'; - if( ! empty( $radius_search ) && 'zip' == $radius_search_based_on ) { + if ( ! empty( $radius_search ) && 'zip' == $radius_search_based_on ) { $class .= ' zip-radius-search'; } return $class; @@ -649,35 +650,35 @@ public function rating_field_data() { $rating_options = array( array( 'checked' => ( is_array( $search_by_rating ) && in_array( '5', $search_by_rating, true ) ) ? ' checked' : '', - 'value' => '5', - 'label' => __( '5 Star', 'directorist' ), + 'value' => '5', + 'label' => __( '5 Star', 'directorist' ), ), array( 'checked' => ( is_array( $search_by_rating ) && in_array( '4', $search_by_rating, true ) ) ? ' checked' : '', - 'value' => '4', - 'label' => __( '4 Star & Up', 'directorist' ), + 'value' => '4', + 'label' => __( '4 Star & Up', 'directorist' ), ), array( - 'checked' => ( is_array( $search_by_rating ) && in_array( '3', $search_by_rating, true ) ) ? ' checked' : '', - 'value' => '3', - 'label' => __( '3 Star & Up', 'directorist' ), + 'checked' => ( is_array( $search_by_rating ) && in_array( '3', $search_by_rating, true ) ) ? ' checked' : '', + 'value' => '3', + 'label' => __( '3 Star & Up', 'directorist' ), ), array( - 'checked' => ( is_array( $search_by_rating ) && in_array( '2', $search_by_rating, true ) ) ? ' checked' : '', - 'value' => '2', - 'label' => __( '2 Star & Up', 'directorist' ), + 'checked' => ( is_array( $search_by_rating ) && in_array( '2', $search_by_rating, true ) ) ? ' checked' : '', + 'value' => '2', + 'label' => __( '2 Star & Up', 'directorist' ), ), array( - 'checked' => ( is_array( $search_by_rating ) && in_array( '1', $search_by_rating, true ) ) ? ' checked' : '', - 'value' => '1', - 'label' => __( '1 Star & Up', 'directorist' ), + 'checked' => ( is_array( $search_by_rating ) && in_array( '1', $search_by_rating, true ) ) ? ' checked' : '', + 'value' => '1', + 'label' => __( '1 Star & Up', 'directorist' ), ), ); return $rating_options; } - public function listing_tag_terms($tag_source='all_tags') { + public function listing_tag_terms( $tag_source = 'all_tags' ) { $category_slug = get_query_var( 'atbdp_category' ); $category = get_term_by( 'slug', $category_slug, ATBDP_CATEGORY ); $category_id = ! empty( $category->term_id ) ? $category->term_id : ''; @@ -696,7 +697,7 @@ public function listing_tag_terms($tag_source='all_tags') { ), ); - $tag_posts = get_posts( $tag_args ); + $tag_posts = get_posts( $tag_args ); if ( ! empty( $tag_posts ) ) { foreach ( $tag_posts as $tag_post ) { $tag_id[] = $tag_post->ID; @@ -728,7 +729,10 @@ public static function get_selected_location_option_data() { } public static function get_taxonomy_select_option_data( $id ) { - $item = [ 'id' => '', 'label' => '' ]; + $item = array( + 'id' => '', + 'label' => '', + ); if ( empty( $id ) ) { return $item; @@ -740,8 +744,8 @@ public static function get_taxonomy_select_option_data( $id ) { return $item; } - $item[ 'id' ] = $taxonomy->term_id; - $item[ 'label' ] = $taxonomy->name; + $item['id'] = $taxonomy->term_id; + $item['label'] = $taxonomy->name; return $item; } diff --git a/includes/model/SingleListing.php b/includes/model/SingleListing.php index 708225e4cf..5db7a9e3ad 100644 --- a/includes/model/SingleListing.php +++ b/includes/model/SingleListing.php @@ -5,9 +5,11 @@ namespace Directorist; -use \ATBDP_Permalink; +use ATBDP_Permalink; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Directorist_Single_Listing { @@ -96,7 +98,7 @@ public function build_content_data() { } $single_fields['fields'][ $key ]['field_key'] = ''; - $single_fields['fields'][ $key ]['options'] = []; + $single_fields['fields'][ $key ]['options'] = array(); unset( $single_fields['fields'][ $key ]['widget_key'] ); unset( $single_fields['fields'][ $key ]['original_widget_key'] ); @@ -151,19 +153,18 @@ public function section_template( $section_data ) { $args = array( 'listing' => $this, 'section_data' => $section_data, - 'icon' => !empty( $section_data['icon'] ) ? $section_data['icon'] : '', - 'label' => !empty( $section_data['label'] ) ? $section_data['label'] : '', - 'id' => !empty( $section_data['custom_block_id'] ) ? $section_data['custom_block_id'] : '', - 'class' => !empty( $section_data['custom_block_classes'] ) ? $section_data['custom_block_classes'] : '', + 'icon' => ! empty( $section_data['icon'] ) ? $section_data['icon'] : '', + 'label' => ! empty( $section_data['label'] ) ? $section_data['label'] : '', + 'id' => ! empty( $section_data['custom_block_id'] ) ? $section_data['custom_block_id'] : '', + 'class' => ! empty( $section_data['custom_block_classes'] ) ? $section_data['custom_block_classes'] : '', ); if ( $section_data['type'] == 'general_group' ) { if ( $this->section_has_contents( $section_data ) ) { Helper::get_template( 'single/section-general', $args ); } - } - else { - $template = 'single/section-'. $section_data['widget_name']; + } else { + $template = 'single/section-' . $section_data['widget_name']; $template = apply_filters( 'directorist_single_section_template', $template, $section_data ); Helper::get_template( $template, $args ); } @@ -186,34 +187,34 @@ public function section_has_contents( $section_data ) { break; } - if( 'tag' === $field['widget_name'] ) { + if ( 'tag' === $field['widget_name'] ) { $tags = get_the_terms( $this->id, ATBDP_TAGS ); - if( $tags ) { + if ( $tags ) { $has_contents = true; break; } } - if( 'image_upload' === $field['widget_name'] ) { - if( $this->get_contents() ) { + if ( 'image_upload' === $field['widget_name'] ) { + if ( $this->get_contents() ) { $has_contents = true; break; } } - if( 'description' === $field['widget_name'] ) { - if( $this->get_contents() ) { + if ( 'description' === $field['widget_name'] ) { + if ( $this->get_contents() ) { $has_contents = true; break; } } - if( 'map' === $field['widget_name'] ) { - $address = get_post_meta( $this->id, '_address', true ); + if ( 'map' === $field['widget_name'] ) { + $address = get_post_meta( $this->id, '_address', true ); $manual_lat = get_post_meta( $this->id, '_manual_lat', true ); $manual_lng = get_post_meta( $this->id, '_manual_lng', true ); - if( $address || ( $manual_lat && $manual_lng ) ) { + if ( $address || ( $manual_lat && $manual_lng ) ) { $has_contents = true; break; } @@ -224,15 +225,14 @@ public function section_has_contents( $section_data ) { } public function has_whatsapp( $data ) { - if ( !empty( $data['form_data']['whatsapp'] ) ) { + if ( ! empty( $data['form_data']['whatsapp'] ) ) { return true; - } - else { + } else { return false; } } - public function get_field_value( $data = [] ) { + public function get_field_value( $data = array() ) { $post_id = $this->id; $value = ''; @@ -245,11 +245,11 @@ public function get_field_value( $data = [] ) { return $data['content']; } - if ( !empty( $data['field_key'] ) ) { - $value = get_post_meta( $post_id, '_'.$data['field_key'], true ); + if ( ! empty( $data['field_key'] ) ) { + $value = get_post_meta( $post_id, '_' . $data['field_key'], true ); if ( empty( $value ) ) { - $value = get_post_meta( $post_id, $data['field_key'], true ); //@kowsar @todo - remove double getmeta later + $value = get_post_meta( $post_id, $data['field_key'], true ); // @kowsar @todo - remove double getmeta later } } @@ -259,38 +259,37 @@ public function get_field_value( $data = [] ) { public function field_template( $data ) { $value = ''; - if( 'tag' === $data['widget_name'] ) { + if ( 'tag' === $data['widget_name'] ) { $tags = get_the_terms( $this->id, ATBDP_TAGS ); - if( $tags ) { + if ( $tags ) { $value = true; } - } elseif( 'map' === $data['widget_name'] ) { + } elseif ( 'map' === $data['widget_name'] ) { $manual_lat = get_post_meta( $this->id, '_manual_lat', true ); $manual_lng = get_post_meta( $this->id, '_manual_lng', true ); - $hide_map = get_post_meta( $this->id, '_hide_map', true ); - if( ( $manual_lat && $manual_lng ) && ! $hide_map ) { + $hide_map = get_post_meta( $this->id, '_hide_map', true ); + if ( ( $manual_lat && $manual_lng ) && ! $hide_map ) { $value = true; } - } elseif( 'image_upload' === $data['widget_name'] ) { - $listing_img = directorist_get_listing_gallery_images( $this->id ); - $preview_img = directorist_get_listing_preview_image( $this->id ); - if( $listing_img || $preview_img ) { + } elseif ( 'image_upload' === $data['widget_name'] ) { + $listing_img = directorist_get_listing_gallery_images( $this->id ); + $preview_img = directorist_get_listing_preview_image( $this->id ); + if ( $listing_img || $preview_img ) { $value = true; } - } elseif( 'description' === $data['widget_name'] ) { - if( $this->get_contents() ) { + } elseif ( 'description' === $data['widget_name'] ) { + if ( $this->get_contents() ) { $value = true; } - } - else { + } else { $value = $this->get_field_value( $data ); } $load_template = true; - $group = !empty( $data['widget_group'] ) ? $data['widget_group'] : ''; + $group = ! empty( $data['widget_group'] ) ? $data['widget_group'] : ''; - if( ( ( $group === 'custom' ) || ( $group === 'preset' ) ) && !$value ) { + if ( ( ( $group === 'custom' ) || ( $group === 'preset' ) ) && ! $value ) { $load_template = false; } @@ -305,95 +304,93 @@ public function field_template( $data ) { 'display_address_map' => get_directorist_option( 'display_address_map', 1 ), 'display_direction_map' => get_directorist_option( 'display_direction_map', 1 ), 'address' => get_post_meta( $this->id, '_address', true ), - 'manual_lat' => ! empty( $manual_lat ) ? $manual_lat : '', - 'manual_lng' => ! empty( $manual_lng ) ? $manual_lng : '', + 'manual_lat' => ! empty( $manual_lat ) ? $manual_lat : '', + 'manual_lng' => ! empty( $manual_lng ) ? $manual_lng : '', ); if ( $this->is_custom_field( $data ) ) { $template = 'single/custom-fields/' . $data['widget_name']; - } - else { + } else { $template = 'single/fields/' . $data['widget_name']; } $template = apply_filters( 'directorist_single_item_template', $template, $data ); - if( $load_template ) { + if ( $load_template ) { Helper::get_template( $template, $args ); } } public function is_custom_field( $data ) { - $fields = [ 'checkbox', 'color_picker', 'date', 'file', 'number', 'radio', 'select', 'text', 'textarea', 'time', 'url' ]; + $fields = array( 'checkbox', 'color_picker', 'date', 'file', 'number', 'radio', 'select', 'text', 'textarea', 'time', 'url' ); $is_custom_field = in_array( $data['widget_name'], $fields ) ? true : false; return $is_custom_field; } public function get_custom_field_value( $type, $data ) { $result = ''; - $value = is_array( $data['value'] ) ? join( ",", $data['value'] ) : $data['value']; + $value = is_array( $data['value'] ) ? join( ',', $data['value'] ) : $data['value']; switch ( $type ) { case 'radio': case 'select': - if(!empty($data['options'])) { - foreach( $data['options'] as $option ) { - $key = $option['option_value']; - if( $key === $value ) { - $result = $option['option_label']; - break; + if ( ! empty( $data['options'] ) ) { + foreach ( $data['options'] as $option ) { + $key = $option['option_value']; + if ( $key === $value ) { + $result = $option['option_label']; + break; + } } } - } - break; + break; case 'checkbox': - $option_value = []; - foreach( $data['options'] as $option ) { - $key = $option['option_value']; - if( in_array( $key, explode( ',', $value ) ) ) { - $space = str_repeat(' ', 1); - $option_value[] = $space . $option['option_label']; + $option_value = array(); + foreach ( $data['options'] as $option ) { + $key = $option['option_value']; + if ( in_array( $key, explode( ',', $value ) ) ) { + $space = str_repeat( ' ', 1 ); + $option_value[] = $space . $option['option_label']; + } } - } - $output = join( ',', $option_value ); - $result = $output ? $output : $value; - break; + $output = join( ',', $option_value ); + $result = $output ? $output : $value; + break; } return $result; } public function get_socials() { - return get_post_meta( $this->id, '_social', true); + return get_post_meta( $this->id, '_social', true ); } public function section_id( $id ) { if ( $id ) { printf( 'id="%s"', esc_attr( $id ) ); - } - else { + } else { return; } } public function get_address( $data ) { $value = $data['value']; - if (!empty($data['address_link_with_map'])) { - $value = '<a target="google_map" href="https://www.google.com/maps/search/' . esc_html($value) . '">' . esc_html($value) . '</a>'; + if ( ! empty( $data['address_link_with_map'] ) ) { + $value = '<a target="google_map" href="https://www.google.com/maps/search/' . esc_html( $value ) . '">' . esc_html( $value ) . '</a>'; } return $value; } public function get_cat_list() { // @cache @kowsar - $cat_list = get_the_term_list( $this->id, ATBDP_CATEGORY, '', ', '); + $cat_list = get_the_term_list( $this->id, ATBDP_CATEGORY, '', ', ' ); return $cat_list; } public function get_location_list() { // @cache @kowsar - $loc_list = get_the_term_list( $this->id, ATBDP_LOCATION, '', ', '); + $loc_list = get_the_term_list( $this->id, ATBDP_LOCATION, '', ', ' ); return $loc_list; } @@ -470,17 +467,17 @@ public function social_share_data() { $result = array( 'facebook' => array( - 'title' => __('Facebook', 'directorist'), + 'title' => __( 'Facebook', 'directorist' ), 'icon' => 'lab la-facebook', 'link' => "https://www.facebook.com/share.php?u={$link}&title={$title}", ), - 'twitter' => array( - 'title' => __('Twitter', 'directorist'), + 'twitter' => array( + 'title' => __( 'Twitter', 'directorist' ), 'icon' => 'lab la-twitter', 'link' => 'https://twitter.com/intent/tweet?text=' . $title . '&url=' . $link, ), 'linkedin' => array( - 'title' => __('LinkedIn', 'directorist'), + 'title' => __( 'LinkedIn', 'directorist' ), 'icon' => 'lab la-linkedin', 'link' => "http://www.linkedin.com/shareArticle?mini=true&url={$link}&title={$title}", ), @@ -492,13 +489,13 @@ public function social_share_data() { public function quick_actions_template() { $actions = $this->listing_header( '', 'quick-widgets-placeholder', 'quick-action-placeholder' ); - $args = array( - 'listing' => $this, - 'actions' => $actions, + $args = array( + 'listing' => $this, + 'actions' => $actions, ); - if( $actions ) { - Helper::get_template('single/quick-actions', $args ); + if ( $actions ) { + Helper::get_template( 'single/quick-actions', $args ); } } @@ -511,8 +508,8 @@ public function quick_info_template() { 'info' => $quick_info, ); - if( $quick_info ) { - Helper::get_template('single/quick-info', $args ); + if ( $quick_info ) { + Helper::get_template( 'single/quick-info', $args ); } } @@ -520,7 +517,7 @@ public function get_slider_data( $data = null ) { $show_slider = get_directorist_option( 'dsiplay_slider_single_page', true ); - if( ! $show_slider ) { + if ( ! $show_slider ) { return; } @@ -534,9 +531,9 @@ public function get_slider_data( $data = null ) { // Get the preview images $preview_img_id = directorist_get_listing_preview_image( $listing_id ); - $preview_img_link = ! empty($preview_img_id) ? atbdp_get_image_source( $preview_img_id, $image_size ) : ''; - $preview_img_alt = get_post_meta($preview_img_id, '_wp_attachment_image_alt', true); - $preview_img_alt = ( ! empty( $preview_img_alt ) ) ? $preview_img_alt : get_the_title( $preview_img_id ); + $preview_img_link = ! empty( $preview_img_id ) ? atbdp_get_image_source( $preview_img_id, $image_size ) : ''; + $preview_img_alt = get_post_meta( $preview_img_id, '_wp_attachment_image_alt', true ); + $preview_img_alt = ( ! empty( $preview_img_alt ) ) ? $preview_img_alt : get_the_title( $preview_img_id ); // Get the gallery images $listing_img = directorist_get_listing_gallery_images( $listing_id ); @@ -545,12 +542,12 @@ public function get_slider_data( $data = null ) { foreach ( $listing_imgs as $img_id ) { $alt = get_post_meta( $img_id, '_wp_attachment_image_alt', true ); - $alt = ( ! empty( $alt ) ) ? $alt : get_the_title( $img_id ); + $alt = ( ! empty( $alt ) ) ? $alt : get_the_title( $img_id ); - $image_links[] = [ - 'alt' => ( ! empty( $alt ) ) ? $alt : $listing_title, + $image_links[] = array( + 'alt' => ( ! empty( $alt ) ) ? $alt : $listing_title, 'src' => atbdp_get_image_source( $img_id, $image_size ), - ]; + ); } // Get the options @@ -560,7 +557,7 @@ public function get_slider_data( $data = null ) { // Set the options $data = array( - 'images' => [], + 'images' => array(), 'alt' => $listing_title, 'background-size' => get_directorist_option( 'single_slider_image_size', 'cover' ), 'blur-background' => ( 'blur' === $background_type ) ? '1' : '0', @@ -578,19 +575,19 @@ public function get_slider_data( $data = null ) { } if ( ! empty( $preview_img_link ) ) { - $preview_img = [ + $preview_img = array( 'alt' => $preview_img_alt, 'src' => $preview_img_link, - ]; + ); array_unshift( $data['images'], $preview_img ); } if ( count( $data['images'] ) < 1 ) { - $data['images'][] = [ + $data['images'][] = array( 'alt' => $listing_title, 'src' => $default_image, - ]; + ); } $data['padding-top'] = ( $data['height'] / $data['width'] ) * 100; @@ -617,7 +614,7 @@ public function slider_field_template( $slider = null ) { 'data' => $this->get_slider_data( $slider ), ); - Helper::get_template('single/slider', $args ); + Helper::get_template( 'single/slider', $args ); } public function has_badge( $data ) { @@ -635,7 +632,7 @@ public function display_new_badge( $data ) { } public function display_featured_badge( $data ) { - $featured_badge = !empty( $data['featured_badge'] ) ? $data['featured_badge'] : ''; + $featured_badge = ! empty( $data['featured_badge'] ) ? $data['featured_badge'] : ''; return $featured_badge && Helper::is_featured( $this->id ); } @@ -644,48 +641,47 @@ public function display_popular_badge( $data ) { } public function has_price_range() { - $id = $this->id; - $plan_average_price = is_fee_manager_active() ? is_plan_allowed_average_price_range($this->fm_plan) : true; + $id = $this->id; + $plan_average_price = is_fee_manager_active() ? is_plan_allowed_average_price_range( $this->fm_plan ) : true; - if (!empty($this->price_range) && ('range' === $this->atbd_listing_pricing) && $plan_average_price) { + if ( ! empty( $this->price_range ) && ( 'range' === $this->atbd_listing_pricing ) && $plan_average_price ) { return true; - } - else { + } else { return false; } } public function price_range_html() { - $id = $this->id; + $id = $this->id; $currency = directorist_get_currency(); - $c_symbol = atbdp_currency_symbol($currency); + $c_symbol = atbdp_currency_symbol( $currency ); $active = '<span class="directorist-price-active">' . $c_symbol . '</span>'; $inactive = '<span>' . $c_symbol . '</span>'; - $output = ''; + $output = ''; - switch ($this->price_range) { + switch ( $this->price_range ) { case 'skimming': - $output = $active.$active.$active.$active; - break; + $output = $active . $active . $active . $active; + break; case 'moderate': - $output = $active.$active.$active.$inactive; - break; + $output = $active . $active . $active . $inactive; + break; case 'economy': - $output = $active.$active.$inactive.$inactive; - break; + $output = $active . $active . $inactive . $inactive; + break; case 'bellow_economy': - $output = $active.$inactive.$inactive.$inactive; - break; + $output = $active . $inactive . $inactive . $inactive; + break; } - $result = sprintf('<div class="directorist-listing-price-range directorist-tooltip" data-label="%s">%s</div>', ucfirst( $this->price_range ), $output); + $result = sprintf( '<div class="directorist-listing-price-range directorist-tooltip" data-label="%s">%s</div>', ucfirst( $this->price_range ), $output ); return $result; } public function contact_owner_form_disabled() { - $author_id = get_post_field( 'post_author', $this->id ); - $hide_contact_form = get_user_meta( $author_id, 'directorist_hide_contact_form', true ); + $author_id = get_post_field( 'post_author', $this->id ); + $hide_contact_form = get_user_meta( $author_id, 'directorist_hide_contact_form', true ); if ( ! empty( $hide_contact_form ) && 'yes' == $hide_contact_form ) { return true; @@ -694,13 +690,13 @@ public function contact_owner_form_disabled() { return false; } - public function contact_owner_fields( $field_data = [] ) { + public function contact_owner_fields( $field_data = array() ) { $default_fields = array( - 'name' => array( - 'enable' => true, + 'name' => array( + 'enable' => true, 'placeholder' => __( 'Name', 'directorist' ), ), - 'email' => array( + 'email' => array( 'placeholder' => __( 'Email', 'directorist' ), ), 'message' => array( @@ -708,7 +704,11 @@ public function contact_owner_fields( $field_data = [] ) { ), ); - $field_keys = ['contact_name' => 'name', 'contact_email' => 'email', 'contact_message' => 'message']; + $field_keys = array( + 'contact_name' => 'name', + 'contact_email' => 'email', + 'contact_message' => 'message', + ); foreach ( $field_keys as $key => $field ) { if ( ! empty( $field_data[ $key ] ) ) { @@ -732,17 +732,16 @@ public function has_price() { public function author_has_socials() { if ( $this->author_info( 'facebook' ) || $this->author_info( 'twitter' ) || $this->author_info( 'linkedIn' ) || $this->author_info( 'youtube' ) ) { return true; - } - else { + } else { return false; } } - public function author_display_email( $section_data = [] ) { + public function author_display_email( $section_data = array() ) { $email_display_type = ! empty( $section_data['display_email'] ) ?? true; - $email = $this->author_info( 'name' ); + $email = $this->author_info( 'name' ); - if ( !$email ) { + if ( ! $email ) { return false; } @@ -755,49 +754,49 @@ public function author_display_email( $section_data = [] ) { public function author_info( $arg ) { $author_id = $this->author_id; - $result = ''; + $result = ''; switch ( $arg ) { case 'member_since': - $user_registered = get_the_author_meta('user_registered', $author_id); - $result = human_time_diff(strtotime($user_registered), current_time('timestamp')); - break; + $user_registered = get_the_author_meta( 'user_registered', $author_id ); + $result = human_time_diff( strtotime( $user_registered ), current_time( 'timestamp' ) ); + break; case 'name': - $result = get_the_author_meta('display_name', $author_id); - break; + $result = get_the_author_meta( 'display_name', $author_id ); + break; case 'address': - $result = get_user_meta($author_id, 'address', true); - break; + $result = get_user_meta( $author_id, 'address', true ); + break; case 'phone': - $result = get_user_meta($author_id, 'atbdp_phone', true); - break; + $result = get_user_meta( $author_id, 'atbdp_phone', true ); + break; case 'email': - $result = get_the_author_meta('user_email', $author_id); - break; + $result = get_the_author_meta( 'user_email', $author_id ); + break; case 'website': - $result = get_the_author_meta('user_url', $author_id); - break; + $result = get_the_author_meta( 'user_url', $author_id ); + break; case 'facebook': - $result = get_user_meta($author_id, 'atbdp_facebook', true); - break; + $result = get_user_meta( $author_id, 'atbdp_facebook', true ); + break; case 'twitter': - $result = get_user_meta($author_id, 'atbdp_twitter', true); - break; + $result = get_user_meta( $author_id, 'atbdp_twitter', true ); + break; case 'linkedin': - $result = get_user_meta($author_id, 'atbdp_linkedin', true); - break; + $result = get_user_meta( $author_id, 'atbdp_linkedin', true ); + break; case 'youtube': - $result = get_user_meta($author_id, 'atbdp_youtube', true); - break; + $result = get_user_meta( $author_id, 'atbdp_youtube', true ); + break; } return $result; @@ -805,21 +804,20 @@ public function author_info( $arg ) { public function price_html() { $id = $this->id; - $allow_decimal = get_directorist_option('allow_decimal', 1); + $allow_decimal = get_directorist_option( 'allow_decimal', 1 ); $c_position = directorist_get_currency_position(); $currency = directorist_get_currency(); - $symbol = atbdp_currency_symbol($currency); + $symbol = atbdp_currency_symbol( $currency ); $before = $after = ''; - if ('after' == $c_position) { + if ( 'after' == $c_position ) { $after = $symbol; - } - else { + } else { $before = $symbol; } - $price = $before . atbdp_format_amount($this->price, $allow_decimal) . $after; - $price_html = apply_filters('atbdp_listing_price', sprintf("<span class='directorist-listing-price'>%s</span>", $price)); + $price = $before . atbdp_format_amount( $this->price, $allow_decimal ) . $after; + $price_html = apply_filters( 'atbdp_listing_price', sprintf( "<span class='directorist-listing-price'>%s</span>", $price ) ); return $price_html; } @@ -830,10 +828,10 @@ public function get_review_section_data() { if ( isset( $section_data['widget_name'] ) && $section_data['widget_name'] == 'review' ) { $data = array( 'section_data' => $section_data, - 'icon' => !empty( $section_data['icon'] ) ? $section_data['icon'] : '', - 'label' => !empty( $section_data['label'] ) ? $section_data['label'] : '', - 'id' => !empty( $section_data['custom_block_id'] ) ? $section_data['custom_block_id'] : 'reviews', - 'class' => !empty( $section_data['custom_block_classes'] ) ? $section_data['custom_block_classes'] : '', + 'icon' => ! empty( $section_data['icon'] ) ? $section_data['icon'] : '', + 'label' => ! empty( $section_data['label'] ) ? $section_data['label'] : '', + 'id' => ! empty( $section_data['custom_block_id'] ) ? $section_data['custom_block_id'] : 'reviews', + 'class' => ! empty( $section_data['custom_block_classes'] ) ? $section_data['custom_block_classes'] : '', ); } } @@ -861,23 +859,29 @@ public function submit_link() { $listing_id = isset( $_GET['p'] ) ? sanitize_text_field( wp_unslash( $_GET['p'] ) ) : $listing_id; if ( empty( $payment ) ) { - $redirect_page = get_directorist_option('edit_listing_redirect', 'view_listing'); - - if ( 'view_listing' === $redirect_page){ - $link = add_query_arg( array( - 'p' => $listing_id, - 'post_id' => $listing_id, - 'reviewed' => 'yes', - 'edited' => $edited ? 'yes' : 'no' - ), $redirect ); - } else{ + $redirect_page = get_directorist_option( 'edit_listing_redirect', 'view_listing' ); + + if ( 'view_listing' === $redirect_page ) { + $link = add_query_arg( + array( + 'p' => $listing_id, + 'post_id' => $listing_id, + 'reviewed' => 'yes', + 'edited' => $edited ? 'yes' : 'no', + ), + $redirect + ); + } else { $link = $redirect; } } else { - $link = add_query_arg( array( - 'atbdp_listing_id' => $listing_id, - 'reviewed' => 'yes' - ), $redirect ); + $link = add_query_arg( + array( + 'atbdp_listing_id' => $listing_id, + 'reviewed' => 'yes', + ), + $redirect + ); } } @@ -885,28 +889,27 @@ public function submit_link() { } public function has_redirect_link() { - return isset( $_GET['redirect'] ) ; + return isset( $_GET['redirect'] ); } public function edit_link() { - $id = $this->id; - $redirect = isset($_GET['redirect']) ? sanitize_text_field( wp_unslash( $_GET['redirect'] ) ) : ''; - $edit_link = !empty($payment) ? add_query_arg('redirect', $redirect, ATBDP_Permalink::get_edit_listing_page_link($id)) : ATBDP_Permalink::get_edit_listing_page_link($id); + $id = $this->id; + $redirect = isset( $_GET['redirect'] ) ? sanitize_text_field( wp_unslash( $_GET['redirect'] ) ) : ''; + $edit_link = ! empty( $payment ) ? add_query_arg( 'redirect', $redirect, ATBDP_Permalink::get_edit_listing_page_link( $id ) ) : ATBDP_Permalink::get_edit_listing_page_link( $id ); return $edit_link; } public function edit_text() { - return isset( $_GET['redirect'] ) ; + return isset( $_GET['redirect'] ); } public function current_user_is_author() { - $id = $this->id; + $id = $this->id; $author_id = get_post_field( 'post_author', $id ); if ( is_user_logged_in() && $author_id == get_current_user_id() ) { return true; - } - else { + } else { return false; } } @@ -916,11 +919,11 @@ public function display_back_link() { } public function has_sidebar() { - return is_active_sidebar('right-sidebar-listing'); + return is_active_sidebar( 'right-sidebar-listing' ); } public function content_col_class() { - return is_active_sidebar('right-sidebar-listing') ? Helper::directorist_column(8) : Helper::directorist_column(12); + return is_active_sidebar( 'right-sidebar-listing' ) ? Helper::directorist_column( 8 ) : Helper::directorist_column( 12 ); } public function notice_template() { @@ -929,7 +932,7 @@ public function notice_template() { 'notice_text' => $this->notice_text(), ); - Helper::get_template('single/notice', $args ); + Helper::get_template( 'single/notice', $args ); } public function notice_text() { @@ -958,7 +961,7 @@ public function notice_text() { public function listing_header( $key = '', $group = '', $subgroup = '' ) { - foreach( $this->header_data as $data ) { + foreach ( $this->header_data as $data ) { if ( empty( $data['placeholderKey'] ) ) { continue; @@ -969,7 +972,7 @@ public function listing_header( $key = '', $group = '', $subgroup = '' ) { } if ( $subgroup and ! empty( $data['placeholders'] ) ) { - foreach ( $data['placeholders'] as $placeholder ) { + foreach ( $data['placeholders'] as $placeholder ) { if ( $placeholder['placeholderKey'] !== $subgroup ) { continue; } @@ -978,37 +981,34 @@ public function listing_header( $key = '', $group = '', $subgroup = '' ) { return $placeholder['selectedWidgets']; } - foreach( $placeholder['selectedWidgets'] as $index => $widget ) { + foreach ( $placeholder['selectedWidgets'] as $index => $widget ) { if ( $widget['widget_key'] === $key ) { return $widget; } } - } } if ( empty( $data['selectedWidgets'] ) ) { - return []; + return array(); } if ( ! $key ) { return $data['selectedWidgets']; } - foreach( $data['selectedWidgets'] as $index => $widget ) { + foreach ( $data['selectedWidgets'] as $index => $widget ) { if ( $widget['widget_key'] === $key ) { return $widget; } } - } - } public function header_template() { - $display_title = $this->listing_header( 'title', 'listing-title-placeholder' ); - $args = array( + $display_title = $this->listing_header( 'title', 'listing-title-placeholder' ); + $args = array( 'listing' => $this, 'use_listing_title' => true, 'section_title' => '', @@ -1018,12 +1018,12 @@ public function header_template() { 'display_content' => false, ); - return Helper::get_template('single/header', $args); + return Helper::get_template( 'single/header', $args ); } public function render_shortcode_single_listing() { - if ( !is_singular( ATBDP_POST_TYPE ) ) { + if ( ! is_singular( ATBDP_POST_TYPE ) ) { return; } @@ -1031,7 +1031,7 @@ public function render_shortcode_single_listing() { 'listing' => $this, ); - return Helper::get_template_contents('single/single-listing', $args); + return Helper::get_template_contents( 'single/single-listing', $args ); } public function get_title() { @@ -1043,11 +1043,11 @@ public function display_review() { } public function guest_review_enabled() { - return get_directorist_option('guest_review', 0); + return get_directorist_option( 'guest_review', 0 ); } public function owner_review_enabled() { - return get_directorist_option('enable_owner_review', 1); + return get_directorist_option( 'enable_owner_review', 1 ); } public function current_review() { @@ -1059,7 +1059,7 @@ public function current_review() { } public function reviewer_name() { - return wp_get_current_user()->display_name;; + return wp_get_current_user()->display_name; } public function review_count() { @@ -1067,12 +1067,12 @@ public function review_count() { } public function review_count_text() { - $review_count_text = _nx('Review', 'Reviews', $this->review_count(), 'Number of reviews', 'directorist'); + $review_count_text = _nx( 'Review', 'Reviews', $this->review_count(), 'Number of reviews', 'directorist' ); return $review_count_text; } public function review_approve_immediately() { - return get_directorist_option('approve_immediately', 1); + return get_directorist_option( 'approve_immediately', 1 ); } /** @@ -1112,57 +1112,56 @@ public function get_contents() { return apply_filters( 'directorist_the_content', $content ); } - public function get_custom_field_type_value($field_id, $field_type, $field_details) - { - switch ($field_type) { + public function get_custom_field_type_value( $field_id, $field_type, $field_details ) { + switch ( $field_type ) { case 'color': - $result = sprintf('<div class="atbd_field_type_color" style="background-color: %s;"></div>', $field_details); - break; + $result = sprintf( '<div class="atbd_field_type_color" style="background-color: %s;"></div>', $field_details ); + break; case 'date': - $result = date(get_option('date_format'), strtotime($field_details)); - break; + $result = date( get_option( 'date_format' ), strtotime( $field_details ) ); + break; case 'time': - $result = date('h:i A', strtotime($field_details)); - break; + $result = date( 'h:i A', strtotime( $field_details ) ); + break; case 'url': - $result = sprintf('<a href="%s" target="_blank">%s</a>', esc_url($field_details), esc_url($field_details)); - break; + $result = sprintf( '<a href="%s" target="_blank">%s</a>', esc_url( $field_details ), esc_url( $field_details ) ); + break; case 'file': - $done = str_replace('|||', '', $field_details); - $name_arr = explode('/', $done); - $filename = end($name_arr); - $result = sprintf('<a href="%s" target="_blank" download>%s</a>', esc_url($done), $filename); - break; + $done = str_replace( '|||', '', $field_details ); + $name_arr = explode( '/', $done ); + $filename = end( $name_arr ); + $result = sprintf( '<a href="%s" target="_blank" download>%s</a>', esc_url( $done ), $filename ); + break; case 'checkbox': - $choices = get_post_meta($field_id, 'choices', true); - $choices = explode("\n", $choices); - $values = explode("\n", $field_details); - $values = array_map('trim', $values); - $output = array(); - foreach ($choices as $choice) { - if (strpos($choice, ':') !== false) { - $_choice = explode(':', $choice); - $_choice = array_map('trim', $_choice); - - $_value = $_choice[0]; - $_label = $_choice[1]; - } else { - $_value = trim($choice); - $_label = $_value; - } - $_checked = ''; - if (in_array($_value, $values)) { - $space = str_repeat(' ', 1); - $output[] = "{$space}$_value"; + $choices = get_post_meta( $field_id, 'choices', true ); + $choices = explode( "\n", $choices ); + $values = explode( "\n", $field_details ); + $values = array_map( 'trim', $values ); + $output = array(); + foreach ( $choices as $choice ) { + if ( strpos( $choice, ':' ) !== false ) { + $_choice = explode( ':', $choice ); + $_choice = array_map( 'trim', $_choice ); + + $_value = $_choice[0]; + $_label = $_choice[1]; + } else { + $_value = trim( $choice ); + $_label = $_value; + } + $_checked = ''; + if ( in_array( $_value, $values ) ) { + $space = str_repeat( ' ', 1 ); + $output[] = "{$space}$_value"; + } } - } - $result = join(',', $output); - break; + $result = join( ',', $output ); + break; default: $result = do_shortcode( $field_details ); @@ -1183,14 +1182,14 @@ public function get_custom_field_data() { } public function map_data() { - $id = $this->id; + $id = $this->id; $manual_lat = get_post_meta( $id, '_manual_lat', true ); $manual_lng = get_post_meta( $id, '_manual_lng', true ); $phone = get_post_meta( $id, '_phone', true ); - $address = get_post_meta($id, '_address', true); - $ad = !empty($address) ? esc_html($address) : ''; + $address = get_post_meta( $id, '_address', true ); + $ad = ! empty( $address ) ? esc_html( $address ) : ''; $display_map_info = apply_filters( 'atbdp_listing_map_info_window', get_directorist_option( 'display_map_info', 1 ) ); $display_image_map = get_directorist_option( 'display_image_map', 1 ); @@ -1203,27 +1202,27 @@ public function map_data() { $display_phone_map = get_directorist_option( 'display_phone_map', 1 ); $display_favorite_badge_map = get_directorist_option( 'display_favorite_badge_map', 1 ); - $listing_prv_img = directorist_get_listing_preview_image( $id ); - $default_image = get_directorist_option('default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg'); - $listing_prv_imgurl = !empty($listing_prv_img) ? atbdp_get_image_source($listing_prv_img, 'small') : ''; - $listing_prv_imgurl = atbdp_image_cropping($listing_prv_img, 150, 150, true, 100)['url']; - $img_url = !empty($listing_prv_imgurl) ? $listing_prv_imgurl : $default_image; - $image = "<figure><img src=" . $img_url . " /></figure>"; + $listing_prv_img = directorist_get_listing_preview_image( $id ); + $default_image = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); + $listing_prv_imgurl = ! empty( $listing_prv_img ) ? atbdp_get_image_source( $listing_prv_img, 'small' ) : ''; + $listing_prv_imgurl = atbdp_image_cropping( $listing_prv_img, 150, 150, true, 100 )['url']; + $img_url = ! empty( $listing_prv_imgurl ) ? $listing_prv_imgurl : $default_image; + $image = '<figure><img src=' . $img_url . ' /></figure>'; if ( empty( $display_image_map ) ) { $image = ''; } $t = get_the_title(); - $t = ! empty( $t ) ? $t : __('No Title', 'directorist'); + $t = ! empty( $t ) ? $t : __( 'No Title', 'directorist' ); if ( empty( $display_title_map ) ) { $t = ''; } - $info_content = ""; + $info_content = ''; $info_content .= "<div class='map-info-wrapper map-listing-card-single'>"; // favorite badge - if( ! empty( $display_favorite_badge_map ) ) { + if ( ! empty( $display_favorite_badge_map ) ) { $info_content .= $this->favorite_badge_template_map(); } @@ -1252,42 +1251,41 @@ public function map_data() { $info_content .= $this->price_html(); } - $info_content .= "</div>"; + $info_content .= '</div>'; } $info_content .= "<div class='map-listing-card-single__content__info'>"; - if( ! empty( $phone ) && ! empty( $display_phone_map ) ) { + if ( ! empty( $phone ) && ! empty( $display_phone_map ) ) { $info_content .= "<div class='directorist-info-item map-listing-card-single__content__phone'>" . directorist_icon( 'fas fa-phone-alt', false ) . "<div class='directorist-info-item'><a href='tel:{$phone}'>{$phone}</a></div></div>"; } - if (!empty($display_address_map) && !empty($ad)) { - $info_content .= "<div class='directorist-info-item map-listing-card-single__content__address'>" .directorist_icon('fas fa-map-marker-alt', false). "<div class='directorist-info-item'>"; - $info_content .= apply_filters("atbdp_address_in_map_info_window", "<a href='http://www.google.com/maps?daddr={$manual_lat},{$manual_lng}' target='_blank'>{$ad}</a></div></div>"); + if ( ! empty( $display_address_map ) && ! empty( $ad ) ) { + $info_content .= "<div class='directorist-info-item map-listing-card-single__content__address'>" . directorist_icon( 'fas fa-map-marker-alt', false ) . "<div class='directorist-info-item'>"; + $info_content .= apply_filters( 'atbdp_address_in_map_info_window', "<a href='http://www.google.com/maps?daddr={$manual_lat},{$manual_lng}' target='_blank'>{$ad}</a></div></div>" ); } - $info_content .= "</div>"; - + $info_content .= '</div>'; - $cats = get_the_terms($this->id, ATBDP_CATEGORY); + $cats = get_the_terms( $this->id, ATBDP_CATEGORY ); $cat_icon = ''; // if (!empty($cats)) { - // $cat_icon = get_cat_icon($cats[0]->term_id); + // $cat_icon = get_cat_icon($cats[0]->term_id); // } - $cat_icon = !empty($cat_icon) ? $cat_icon : 'fas fa-map-pin'; + $cat_icon = ! empty( $cat_icon ) ? $cat_icon : 'fas fa-map-pin'; $cat_icon = directorist_icon( $cat_icon, false ); $args = array( 'listing' => $this, - 'default_latitude' => get_directorist_option('default_latitude', '40.7127753'), - 'default_longitude' => get_directorist_option('default_longitude', '-74.0059728'), + 'default_latitude' => get_directorist_option( 'default_latitude', '40.7127753' ), + 'default_longitude' => get_directorist_option( 'default_longitude', '-74.0059728' ), 'manual_lat' => $manual_lat, 'manual_lng' => $manual_lng, - 'listing_location_text' => apply_filters('atbdp_single_listing_map_section_text', get_directorist_option('listing_location_text', __('Location', 'directorist'))), - 'select_listing_map' => get_directorist_option('select_listing_map', 'google'), + 'listing_location_text' => apply_filters( 'atbdp_single_listing_map_section_text', get_directorist_option( 'listing_location_text', __( 'Location', 'directorist' ) ) ), + 'select_listing_map' => get_directorist_option( 'select_listing_map', 'google' ), 'info_content' => $info_content, 'display_map_info' => $display_map_info, - 'map_zoom_level' => get_directorist_option('map_zoom_level', 16), + 'map_zoom_level' => get_directorist_option( 'map_zoom_level', 16 ), 'cat_icon' => $cat_icon, ); @@ -1296,8 +1294,8 @@ public function map_data() { public function get_review_template() { // Review - $average = directorist_get_listing_rating( $this->id ); - $reviews_count = directorist_get_listing_review_count( $this->id ); + $average = directorist_get_listing_rating( $this->id ); + $reviews_count = directorist_get_listing_review_count( $this->id ); // Icons $icon_empty_star = directorist_icon( 'fas fa-star', false, 'star-empty' ); @@ -1305,17 +1303,17 @@ public function get_review_template() { $icon_full_star = directorist_icon( 'fas fa-star', false, 'star-full' ); // Stars - $star_1 = ( $average >= 0.5 && $average < 1) ? $icon_half_star : $icon_empty_star; - $star_1 = ( $average >= 1) ? $icon_full_star : $star_1; + $star_1 = ( $average >= 0.5 && $average < 1 ) ? $icon_half_star : $icon_empty_star; + $star_1 = ( $average >= 1 ) ? $icon_full_star : $star_1; - $star_2 = ( $average >= 1.5 && $average < 2) ? $icon_half_star : $icon_empty_star; - $star_2 = ( $average >= 2) ? $icon_full_star : $star_2; + $star_2 = ( $average >= 1.5 && $average < 2 ) ? $icon_half_star : $icon_empty_star; + $star_2 = ( $average >= 2 ) ? $icon_full_star : $star_2; - $star_3 = ( $average >= 2.5 && $average < 3) ? $icon_half_star : $icon_empty_star; - $star_3 = ( $average >= 3) ? $icon_full_star : $star_3; + $star_3 = ( $average >= 2.5 && $average < 3 ) ? $icon_half_star : $icon_empty_star; + $star_3 = ( $average >= 3 ) ? $icon_full_star : $star_3; - $star_4 = ( $average >= 3.5 && $average < 4) ? $icon_half_star : $icon_empty_star; - $star_4 = ( $average >= 4) ? $icon_full_star : $star_4; + $star_4 = ( $average >= 3.5 && $average < 4 ) ? $icon_half_star : $icon_empty_star; + $star_4 = ( $average >= 4 ) ? $icon_full_star : $star_4; $star_5 = ( $average >= 4.5 && $average < 5 ) ? $icon_half_star : $icon_empty_star; $star_5 = ( $average >= 5 ) ? $icon_full_star : $star_5; @@ -1354,7 +1352,7 @@ public function review_template() { public function loop_is_favourite() { $favourites = directorist_get_user_favorites( get_current_user_id() ); - return in_array( $this->id , $favourites ); + return in_array( $this->id, $favourites ); } /** @@ -1370,12 +1368,12 @@ public function favorite_badge_template_map() { public function user_avatar() { - $user_pro_pic = get_user_meta( $this->author_id, 'pro_pic', true ); - $u_pro_pic = ! empty( $u_pro_pic ) ? wp_get_attachment_image_src( $u_pro_pic, 'thumbnail' ) : ''; - $author_data = get_userdata( $this->author_id ); + $user_pro_pic = get_user_meta( $this->author_id, 'pro_pic', true ); + $u_pro_pic = ! empty( $u_pro_pic ) ? wp_get_attachment_image_src( $u_pro_pic, 'thumbnail' ) : ''; + $author_data = get_userdata( $this->author_id ); - $author_first_name = ! empty( $author_data ) ? $author_data->first_name : ''; - $author_last_name = ! empty( $author_data ) ? $author_data->last_name : ''; + $author_first_name = ! empty( $author_data ) ? $author_data->first_name : ''; + $author_last_name = ! empty( $author_data ) ? $author_data->last_name : ''; $args = array( 'author_link' => ATBDP_Permalink::get_user_profile_page_link( $this->author_id ), @@ -1389,31 +1387,31 @@ public function user_avatar() { return ob_get_clean(); } - public function get_related_listings( $data = [] ) { + public function get_related_listings( $data = array() ) { $number = ! empty( $data['similar_listings_number_of_listings_to_show'] ) ? $data['similar_listings_number_of_listings_to_show'] : 3; $same_author = ! empty( $data['listing_from_same_author'] ) ? true : false; $logic = ! empty( $data['similar_listings_logics'] ) ? $data['similar_listings_logics'] : 'OR'; $relationship = ( $logic == 'AND' ) ? 'AND' : 'OR'; $id = $this->id; - $atbd_cats = get_the_terms($id, ATBDP_CATEGORY); - $atbd_tags = get_the_terms($id, ATBDP_TAGS); + $atbd_cats = get_the_terms( $id, ATBDP_CATEGORY ); + $atbd_tags = get_the_terms( $id, ATBDP_TAGS ); $atbd_cats_ids = array(); $atbd_tags_ids = array(); - if (!empty($atbd_cats)) { - foreach ($atbd_cats as $atbd_cat) { + if ( ! empty( $atbd_cats ) ) { + foreach ( $atbd_cats as $atbd_cat ) { $atbd_cats_ids[] = $atbd_cat->term_id; } } - if (!empty($atbd_tags)) { - foreach ($atbd_tags as $atbd_tag) { + if ( ! empty( $atbd_tags ) ) { + foreach ( $atbd_tags as $atbd_tag ) { $atbd_tags_ids[] = $atbd_tag->term_id; } } $args = array( - 'post_type' => ATBDP_POST_TYPE, - 'tax_query' => array( + 'post_type' => ATBDP_POST_TYPE, + 'tax_query' => array( 'relation' => $relationship, array( 'taxonomy' => ATBDP_CATEGORY, @@ -1426,30 +1424,30 @@ public function get_related_listings( $data = [] ) { 'terms' => $atbd_tags_ids, ), ), - 'posts_per_page' => (int)$number, - 'post__not_in' => array($id), + 'posts_per_page' => (int) $number, + 'post__not_in' => array( $id ), ); - if( !empty( $same_author ) ){ - $args['author'] = get_post_field( 'post_author', $id ); + if ( ! empty( $same_author ) ) { + $args['author'] = get_post_field( 'post_author', $id ); } - $meta_queries = array(); + $meta_queries = array(); $meta_queries['directory_type'] = array( - 'key' => '_directory_type', - 'value' => $this->type, - 'compare' => '=', - ); + 'key' => '_directory_type', + 'value' => $this->type, + 'compare' => '=', + ); - $meta_queries = apply_filters('atbdp_related_listings_meta_queries', $meta_queries); - $count_meta_queries = count($meta_queries); - if ($count_meta_queries) { - $args['meta_query'] = ($count_meta_queries > 1) ? array_merge(array('relation' => 'AND'), $meta_queries) : $meta_queries; + $meta_queries = apply_filters( 'atbdp_related_listings_meta_queries', $meta_queries ); + $count_meta_queries = count( $meta_queries ); + if ( $count_meta_queries ) { + $args['meta_query'] = ( $count_meta_queries > 1 ) ? array_merge( array( 'relation' => 'AND' ), $meta_queries ) : $meta_queries; } $args = apply_filters( 'directorist_related_listing_args', $args, $this ); - $related = new Directorist_Listings( [], 'related', $args, ['cache' => false] ); + $related = new Directorist_Listings( array(), 'related', $args, array( 'cache' => false ) ); return $related; } @@ -1458,14 +1456,14 @@ public function related_slider_attr() { $atts = array( 'columns' => get_directorist_type_option( $this->type, 'similar_listings_number_of_columns', 3 ), 'prevArrow' => sprintf( '<a class="directorist-slc__nav directorist-slc__nav--left">%s</a>', directorist_icon( 'las la-angle-left', false ) ), - 'nextArrow' => sprintf( '<a class="directorist-slc__nav directorist-slc__nav--right">%s</a>', directorist_icon( 'las la-angle-right', false ) ), + 'nextArrow' => sprintf( '<a class="directorist-slc__nav directorist-slc__nav--right">%s</a>', directorist_icon( 'las la-angle-right', false ) ), ); return json_encode( $atts ); } public function get_related_columns() { $columns = get_directorist_type_option( $this->type, 'similar_listings_number_of_columns', 3 ); - return 12/$columns; + return 12 / $columns; } public function load_map_resources() { @@ -1475,4 +1473,4 @@ public function load_map_resources() { public function load_related_listings_script() { _deprecated_function( __METHOD__, '7.3' ); } -} \ No newline at end of file +} diff --git a/includes/modules/appsero/src/Client.php b/includes/modules/appsero/src/Client.php index de83749dd6..97f45ce268 100644 --- a/includes/modules/appsero/src/Client.php +++ b/includes/modules/appsero/src/Client.php @@ -9,277 +9,277 @@ */ class Client { - /** - * The client version - * - * @var string - */ - public $version = '1.2.4'; - - /** - * Hash identifier of the plugin - * - * @var string - */ - public $hash; - - /** - * Name of the plugin - * - * @var string - */ - public $name; - - /** - * The plugin/theme file path - * - * @example .../wp-content/plugins/test-slug/test-slug.php - * - * @var string - */ - public $file; - - /** - * Main plugin file - * - * @example test-slug/test-slug.php - * - * @var string - */ - public $basename; - - /** - * Slug of the plugin - * - * @example test-slug - * - * @var string - */ - public $slug; - - /** - * The project version - * - * @var string - */ - public $project_version; - - /** - * The project type - * - * @var string - */ - public $type; - - /** - * Textdomain - * - * @var string - */ - public $textdomain; - - /** - * The Object of Insights Class - * - * @var object - */ - private $insights; - - /** - * The Object of Updater Class - * - * @var object - */ - private $updater; - - /** - * The Object of License Class - * - * @var object - */ - private $license; - - /** - * Initialize the class - * - * @param string $hash hash of the plugin - * @param string $name readable name of the plugin - * @param string $file main plugin file path - */ - public function __construct( $hash, $name, $file ) { - $this->hash = $hash; - $this->name = $name; - $this->file = $file; - - $this->set_basename_and_slug(); - } - - /** - * Initialize insights class - * - * @return Directorist\Appsero\Insights - */ - public function insights() { - if ( ! class_exists( __NAMESPACE__ . '\Insights' ) ) { - require_once __DIR__ . '/Insights.php'; - } - - // if already instantiated, return the cached one - if ( $this->insights ) { - return $this->insights; - } - - $this->insights = new Insights( $this ); - - return $this->insights; - } - - /** - * Initialize plugin/theme updater - * - * @return Directorist\Appsero\Updater - */ - public function updater() { - if ( ! class_exists( __NAMESPACE__ . '\Updater' ) ) { - require_once __DIR__ . '/Updater.php'; - } - - // if already instantiated, return the cached one - if ( $this->updater ) { - return $this->updater; - } - - $this->updater = new Updater( $this ); - - return $this->updater; - } - - /** - * Initialize license checker - * - * @return Directorist\Appsero\License - */ - public function license() { - if ( ! class_exists( __NAMESPACE__ . '\License' ) ) { - require_once __DIR__ . '/License.php'; - } - - // if already instantiated, return the cached one - if ( $this->license ) { - return $this->license; - } - - $this->license = new License( $this ); - - return $this->license; - } - - /** - * API Endpoint - * - * @return string - */ - public function endpoint() { - $endpoint = apply_filters( 'appsero_endpoint', 'https://api.appsero.com' ); - - return trailingslashit( $endpoint ); - } - - /** - * Set project basename, slug and version - * - * @return void - */ - protected function set_basename_and_slug() { - if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) { - $this->basename = plugin_basename( $this->file ); - - list( $this->slug, $mainfile ) = explode( '/', $this->basename ); - - require_once ABSPATH . 'wp-admin/includes/plugin.php'; - - $plugin_data = get_plugin_data( $this->file, false, false ); - - $this->project_version = $plugin_data['Version']; - $this->type = 'plugin'; - } else { - $this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file ); - - list( $this->slug, $mainfile ) = explode( '/', $this->basename ); - - $theme = wp_get_theme( $this->slug ); - - $this->project_version = $theme->version; - $this->type = 'theme'; - } - - $this->textdomain = $this->slug; - } - - /** - * Send request to remote endpoint - * - * @param array $params - * @param string $route - * - * @return array|WP_Error array of results including HTTP headers or WP_Error if the request failed - */ - public function send_request( $params, $route, $blocking = false ) { - $url = $this->endpoint() . $route; - - $headers = [ - 'user-agent' => 'Appsero/' . md5( esc_url( home_url() ) ) . ';', - 'Accept' => 'application/json', - ]; - - $response = wp_remote_post( - $url, - [ - 'method' => 'POST', - 'timeout' => 30, - 'redirection' => 5, - 'httpversion' => '1.0', - 'blocking' => $blocking, - 'headers' => $headers, - 'body' => array_merge( $params, [ 'client' => $this->version ] ), - 'cookies' => [], - ] - ); - - return $response; - } - - /** - * Check if the current server is localhost - * - * @return bool - */ - public function is_local_server() { - $is_local = isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], [ '127.0.0.1', '::1' ], true ); - - return apply_filters( 'appsero_is_local', $is_local ); - } - - /** - * Translate function _e() - */ + /** + * The client version + * + * @var string + */ + public $version = '1.2.4'; + + /** + * Hash identifier of the plugin + * + * @var string + */ + public $hash; + + /** + * Name of the plugin + * + * @var string + */ + public $name; + + /** + * The plugin/theme file path + * + * @example .../wp-content/plugins/test-slug/test-slug.php + * + * @var string + */ + public $file; + + /** + * Main plugin file + * + * @example test-slug/test-slug.php + * + * @var string + */ + public $basename; + + /** + * Slug of the plugin + * + * @example test-slug + * + * @var string + */ + public $slug; + + /** + * The project version + * + * @var string + */ + public $project_version; + + /** + * The project type + * + * @var string + */ + public $type; + + /** + * Textdomain + * + * @var string + */ + public $textdomain; + + /** + * The Object of Insights Class + * + * @var object + */ + private $insights; + + /** + * The Object of Updater Class + * + * @var object + */ + private $updater; + + /** + * The Object of License Class + * + * @var object + */ + private $license; + + /** + * Initialize the class + * + * @param string $hash hash of the plugin + * @param string $name readable name of the plugin + * @param string $file main plugin file path + */ + public function __construct( $hash, $name, $file ) { + $this->hash = $hash; + $this->name = $name; + $this->file = $file; + + $this->set_basename_and_slug(); + } + + /** + * Initialize insights class + * + * @return Directorist\Appsero\Insights + */ + public function insights() { + if ( ! class_exists( __NAMESPACE__ . '\Insights' ) ) { + require_once __DIR__ . '/Insights.php'; + } + + // if already instantiated, return the cached one + if ( $this->insights ) { + return $this->insights; + } + + $this->insights = new Insights( $this ); + + return $this->insights; + } + + /** + * Initialize plugin/theme updater + * + * @return Directorist\Appsero\Updater + */ + public function updater() { + if ( ! class_exists( __NAMESPACE__ . '\Updater' ) ) { + require_once __DIR__ . '/Updater.php'; + } + + // if already instantiated, return the cached one + if ( $this->updater ) { + return $this->updater; + } + + $this->updater = new Updater( $this ); + + return $this->updater; + } + + /** + * Initialize license checker + * + * @return Directorist\Appsero\License + */ + public function license() { + if ( ! class_exists( __NAMESPACE__ . '\License' ) ) { + require_once __DIR__ . '/License.php'; + } + + // if already instantiated, return the cached one + if ( $this->license ) { + return $this->license; + } + + $this->license = new License( $this ); + + return $this->license; + } + + /** + * API Endpoint + * + * @return string + */ + public function endpoint() { + $endpoint = apply_filters( 'appsero_endpoint', 'https://api.appsero.com' ); + + return trailingslashit( $endpoint ); + } + + /** + * Set project basename, slug and version + * + * @return void + */ + protected function set_basename_and_slug() { + if ( strpos( $this->file, WP_CONTENT_DIR . '/themes/' ) === false ) { + $this->basename = plugin_basename( $this->file ); + + list( $this->slug, $mainfile ) = explode( '/', $this->basename ); + + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + + $plugin_data = get_plugin_data( $this->file, false, false ); + + $this->project_version = $plugin_data['Version']; + $this->type = 'plugin'; + } else { + $this->basename = str_replace( WP_CONTENT_DIR . '/themes/', '', $this->file ); + + list( $this->slug, $mainfile ) = explode( '/', $this->basename ); + + $theme = wp_get_theme( $this->slug ); + + $this->project_version = $theme->version; + $this->type = 'theme'; + } + + $this->textdomain = $this->slug; + } + + /** + * Send request to remote endpoint + * + * @param array $params + * @param string $route + * + * @return array|WP_Error array of results including HTTP headers or WP_Error if the request failed + */ + public function send_request( $params, $route, $blocking = false ) { + $url = $this->endpoint() . $route; + + $headers = array( + 'user-agent' => 'Appsero/' . md5( esc_url( home_url() ) ) . ';', + 'Accept' => 'application/json', + ); + + $response = wp_remote_post( + $url, + array( + 'method' => 'POST', + 'timeout' => 30, + 'redirection' => 5, + 'httpversion' => '1.0', + 'blocking' => $blocking, + 'headers' => $headers, + 'body' => array_merge( $params, array( 'client' => $this->version ) ), + 'cookies' => array(), + ) + ); + + return $response; + } + + /** + * Check if the current server is localhost + * + * @return bool + */ + public function is_local_server() { + $is_local = isset( $_SERVER['REMOTE_ADDR'] ) && in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ), true ); + + return apply_filters( 'appsero_is_local', $is_local ); + } + + /** + * Translate function _e() + */ // phpcs:ignore public function _etrans( $text ) { - call_user_func( '_e', $text, $this->textdomain ); - } + call_user_func( '_e', $text, $this->textdomain ); + } - /** - * Translate function __() - */ + /** + * Translate function __() + */ // phpcs:ignore public function _trans( $text ) { - return call_user_func( '__', $text, $this->textdomain ); - } - - /** - * Set project textdomain - */ - public function set_textdomain( $textdomain ) { - $this->textdomain = $textdomain; - } + return call_user_func( '__', $text, $this->textdomain ); + } + + /** + * Set project textdomain + */ + public function set_textdomain( $textdomain ) { + $this->textdomain = $textdomain; + } } diff --git a/includes/modules/appsero/src/Insights.php b/includes/modules/appsero/src/Insights.php index 76124b2f71..5c105e589b 100644 --- a/includes/modules/appsero/src/Insights.php +++ b/includes/modules/appsero/src/Insights.php @@ -9,1287 +9,1247 @@ * No personal information is being tracked by this class, only general settings, active plugins, environment details * and admin email. */ -class Insights -{ - - /** - * The notice text - * - * @var string - */ - public $notice; - - /** - * Wheather to the notice or not - * - * @var bool - */ - protected $show_notice = true; - - /** - * If extra data needs to be sent - * - * @var array - */ - protected $extra_data = []; - - /** - * Directorist\Appsero\Client - * - * @var object - */ - protected $client; - - /** - * @var bool - */ - private $plugin_data = false; - - /** - * Initialize the class - * - * @param null $name - * @param null $file - */ - public function __construct($client, $name = null, $file = null) - { - if (is_string($client) && !empty($name) && !empty($file)) { - $client = new Client($client, $name, $file); - } - - if (is_object($client) && is_a($client, 'Directorist\Appsero\Client')) { - $this->client = $client; - } - } - - /** - * Don't show the notice - * - * @return \self - */ - public function hide_notice() - { - $this->show_notice = false; - - return $this; - } - - /** - * Add plugin data if needed - * - * @return \self - */ - public function add_plugin_data() - { - $this->plugin_data = true; - - return $this; - } - - /** - * Add extra data if needed - * - * @param array $data - * - * @return \self - */ - public function add_extra($data = []) - { - $this->extra_data = $data; - - return $this; - } - - /** - * Set custom notice text - * - * @param string $text - * - * @return \self - */ - public function notice($text = '') - { - $this->notice = $text; - - return $this; - } - - /** - * Initialize insights - * - * @return void - */ - public function init() - { - if ($this->client->type === 'plugin') { - $this->init_plugin(); - } elseif ($this->client->type === 'theme') { - $this->init_theme(); - } - } - - /** - * Initialize theme hooks - * - * @return void - */ - public function init_theme() - { - $this->init_common(); - - add_action('switch_theme', [$this, 'deactivation_cleanup']); - add_action('switch_theme', [$this, 'theme_deactivated'], 12, 3); - } - - /** - * Initialize plugin hooks - * - * @return void - */ - public function init_plugin() - { - // plugin deactivate popup - // if ( ! $this->is_local_server() ) { - // add_filter( 'plugin_action_links_' . $this->client->basename, [ $this, 'plugin_action_links' ] ); - // add_action( 'admin_footer', [ $this, 'deactivate_scripts' ] ); - // } - - add_filter('plugin_action_links_' . $this->client->basename, [$this, 'plugin_action_links']); - add_action('admin_footer', [$this, 'deactivate_scripts']); - - $this->init_common(); - - register_activation_hook($this->client->file, [$this, 'activate_plugin']); - register_deactivation_hook($this->client->file, [$this, 'deactivation_cleanup']); - } - - /** - * Initialize common hooks - * - * @return void - */ - protected function init_common() - { - if ($this->show_notice) { - // tracking notice - add_action('admin_notices', [$this, 'admin_notice']); - } - - add_action('admin_init', [$this, 'handle_optin_optout']); - - // uninstall reason - add_action('wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', [$this, 'uninstall_reason_submission']); - - // cron events - add_filter('cron_schedules', [$this, 'add_weekly_schedule']); - add_action($this->client->slug . '_tracker_send_event', [$this, 'send_tracking_data']); - // add_action( 'admin_init', array( $this, 'send_tracking_data' ) ); // test - } - - /** - * Send tracking data to AppSero server - * - * @param bool $override - * - * @return void - */ - public function send_tracking_data($override = false) - { - if (!$this->tracking_allowed() && !$override) { - return; - } - - // Send a maximum of once per week - $last_send = $this->get_last_send(); - - if ($last_send && $last_send > strtotime('-1 week')) { - return; - } - - $tracking_data = $this->get_tracking_data(); - - $response = $this->client->send_request($tracking_data, 'track'); - - update_option($this->client->slug . '_tracking_last_send', time()); - } - - /** - * Get the tracking data points - * - * @return array - */ - protected function get_tracking_data() - { - $all_plugins = $this->get_all_plugins(); - - $users = get_users( - [ - 'role' => 'administrator', - 'orderby' => 'ID', - 'order' => 'ASC', - 'number' => 1, - 'paged' => 1, - ] - ); - - $admin_user = (is_array($users) && !empty($users)) ? $users[0] : false; - $first_name = ''; - $last_name = ''; - - if ($admin_user) { - $first_name = $admin_user->first_name ? $admin_user->first_name : $admin_user->display_name; - $last_name = $admin_user->last_name; - } - - $data = [ - 'url' => esc_url(home_url()), - 'site' => $this->get_site_name(), - 'admin_email' => get_option('admin_email'), - 'first_name' => $first_name, - 'last_name' => $last_name, - 'hash' => $this->client->hash, - 'server' => $this->get_server_info(), - 'wp' => $this->get_wp_info(), - 'users' => $this->get_user_counts(), - 'active_plugins' => count($all_plugins['active_plugins']), - 'inactive_plugins' => count($all_plugins['inactive_plugins']), - 'ip_address' => $this->get_user_ip_address(), - 'project_version' => $this->client->project_version, - 'tracking_skipped' => false, - 'is_local' => $this->is_local_server(), - ]; - - // Add Plugins - if ($this->plugin_data) { - $plugins_data = []; - - foreach ($all_plugins['active_plugins'] as $slug => $plugin) { - $slug = strstr($slug, '/', true); - - if (!$slug) { - continue; - } - - $plugins_data[$slug] = [ - 'name' => isset($plugin['name']) ? $plugin['name'] : '', - 'version' => isset($plugin['version']) ? $plugin['version'] : '', - ]; - } - - if (array_key_exists($this->client->slug, $plugins_data)) { - unset($plugins_data[$this->client->slug]); - } - - $data['plugins'] = $plugins_data; - } - - // Add Metadata - $extra = $this->get_extra_data(); - - if ($extra) { - $data['extra'] = $extra; - } - - // Check this has previously skipped tracking - $skipped = get_option($this->client->slug . '_tracking_skipped'); - - if ($skipped === 'yes') { - delete_option($this->client->slug . '_tracking_skipped'); - - $data['tracking_skipped'] = true; - } - - return apply_filters($this->client->slug . '_tracker_data', $data); - } - - /** - * If a child class wants to send extra data - * - * @return mixed - */ - protected function get_extra_data() - { - if (is_callable($this->extra_data)) { - return call_user_func($this->extra_data); - } - - if (is_array($this->extra_data)) { - return $this->extra_data; - } - - return []; - } - - /** - * Explain the user which data we collect - * - * @return array - */ - protected function data_we_collect() - { - $data = [ - 'Server environment details (php, mysql, server, WordPress versions)', - 'Number of users in your site', - 'Site language', - 'Number of active and inactive plugins', - 'Site name and URL', - 'Your name and email address', - ]; - - if ($this->plugin_data) { - array_splice($data, 4, 0, ["active plugins' name"]); - } - - return $data; - } - - /** - * Check if the user has opted into tracking - * - * @return bool - */ - public function tracking_allowed() - { - $allow_tracking = get_option($this->client->slug . '_allow_tracking', 'no'); - - return $allow_tracking === 'yes'; - } - - /** - * Get the last time a tracking was sent - * - * @return false|string - */ - private function get_last_send() - { - return get_option($this->client->slug . '_tracking_last_send', false); - } - - /** - * Check if the notice has been dismissed or enabled - * - * @return bool - */ - public function notice_dismissed() - { - $hide_notice = get_option($this->client->slug . '_tracking_notice', null); - - if ('hide' === $hide_notice) { - return true; - } - - return false; - } - - /** - * Check if the current server is localhost - * - * @return bool - */ - private function is_local_server() - { - $host = isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : 'localhost'; - $ip = isset($_SERVER['SERVER_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_ADDR'])) : '127.0.0.1'; - $is_local = false; - - if ( - in_array($ip, ['127.0.0.1', '::1'], true) - || !strpos($host, '.') - || in_array(strrchr($host, '.'), ['.test', '.testing', '.local', '.localhost', '.localdomain'], true) - ) { - $is_local = true; - } - - return apply_filters('appsero_is_local', $is_local); - } - - /** - * Schedule the event weekly - * - * @return void - */ - private function schedule_event() - { - $hook_name = wp_unslash($this->client->slug . '_tracker_send_event'); - - if (!wp_next_scheduled($hook_name)) { - wp_schedule_event(time(), 'weekly', $hook_name); - } - } - - /** - * Clear any scheduled hook - * - * @return void - */ - private function clear_schedule_event() - { - wp_clear_scheduled_hook($this->client->slug . '_tracker_send_event'); - } - - /** - * Display the admin notice to users that have not opted-in or out - * - * @return void - */ - public function admin_notice() - { - if ($this->notice_dismissed()) { - return; - } - - if ($this->tracking_allowed()) { - return; - } - - if (!current_user_can('manage_options')) { - return; - } - - // don't show tracking if a local server - // if ( $this->is_local_server() ) { - // return; - // } - - $optin_url = wp_nonce_url(add_query_arg($this->client->slug . '_tracker_optin', 'true'), '_wpnonce'); - $optout_url = wp_nonce_url(add_query_arg($this->client->slug . '_tracker_optout', 'true'), '_wpnonce'); - - if (empty($this->notice)) { - $notice = sprintf($this->client->_trans('Want to help make <strong>%1$s</strong> even more awesome? Allow %1$s to collect diagnostic data and usage information.'), $this->client->name); - } else { - $notice = $this->notice; - } - - $policy_url = 'https://appsero.com/privacy-policy/'; - - $notice .= ' (<a class="' . $this->client->slug . '-insights-data-we-collect" href="#">' . $this->client->_trans('what we collect') . '</a>)'; - $notice .= '<p class="description" style="display:none;">' . implode(', ', $this->data_we_collect()) . '. '; - $notice .= 'We are using Appsero to collect your data. <a href="' . $policy_url . '" target="_blank">Learn more</a> about how Appsero collects and handle your data.</p>'; - - echo '<div class="updated"><p>'; - echo $notice; - echo '</p><p class="submit">'; - echo ' <a href="' . esc_url($optin_url) . '" class="button-primary button-large">' . $this->client->_trans('Allow') . '</a>'; - echo ' <a href="' . esc_url($optout_url) . '" class="button-secondary button-large">' . $this->client->_trans('No thanks') . '</a>'; - echo '</p></div>'; - - echo "<script type='text/javascript'>jQuery('." . $this->client->slug . "-insights-data-we-collect').on('click', function(e) { +class Insights { + + + /** + * The notice text + * + * @var string + */ + public $notice; + + /** + * Wheather to the notice or not + * + * @var bool + */ + protected $show_notice = true; + + /** + * If extra data needs to be sent + * + * @var array + */ + protected $extra_data = array(); + + /** + * Directorist\Appsero\Client + * + * @var object + */ + protected $client; + + /** + * @var bool + */ + private $plugin_data = false; + + /** + * Initialize the class + * + * @param null $name + * @param null $file + */ + public function __construct( $client, $name = null, $file = null ) { + if ( is_string( $client ) && ! empty( $name ) && ! empty( $file ) ) { + $client = new Client( $client, $name, $file ); + } + + if ( is_object( $client ) && is_a( $client, 'Directorist\Appsero\Client' ) ) { + $this->client = $client; + } + } + + /** + * Don't show the notice + * + * @return \self + */ + public function hide_notice() { + $this->show_notice = false; + + return $this; + } + + /** + * Add plugin data if needed + * + * @return \self + */ + public function add_plugin_data() { + $this->plugin_data = true; + + return $this; + } + + /** + * Add extra data if needed + * + * @param array $data + * + * @return \self + */ + public function add_extra( $data = array() ) { + $this->extra_data = $data; + + return $this; + } + + /** + * Set custom notice text + * + * @param string $text + * + * @return \self + */ + public function notice( $text = '' ) { + $this->notice = $text; + + return $this; + } + + /** + * Initialize insights + * + * @return void + */ + public function init() { + if ( $this->client->type === 'plugin' ) { + $this->init_plugin(); + } elseif ( $this->client->type === 'theme' ) { + $this->init_theme(); + } + } + + /** + * Initialize theme hooks + * + * @return void + */ + public function init_theme() { + $this->init_common(); + + add_action( 'switch_theme', array( $this, 'deactivation_cleanup' ) ); + add_action( 'switch_theme', array( $this, 'theme_deactivated' ), 12, 3 ); + } + + /** + * Initialize plugin hooks + * + * @return void + */ + public function init_plugin() { + // plugin deactivate popup + // if ( ! $this->is_local_server() ) { + // add_filter( 'plugin_action_links_' . $this->client->basename, [ $this, 'plugin_action_links' ] ); + // add_action( 'admin_footer', [ $this, 'deactivate_scripts' ] ); + // } + + add_filter( 'plugin_action_links_' . $this->client->basename, array( $this, 'plugin_action_links' ) ); + add_action( 'admin_footer', array( $this, 'deactivate_scripts' ) ); + + $this->init_common(); + + register_activation_hook( $this->client->file, array( $this, 'activate_plugin' ) ); + register_deactivation_hook( $this->client->file, array( $this, 'deactivation_cleanup' ) ); + } + + /** + * Initialize common hooks + * + * @return void + */ + protected function init_common() { + if ( $this->show_notice ) { + // tracking notice + add_action( 'admin_notices', array( $this, 'admin_notice' ) ); + } + + add_action( 'admin_init', array( $this, 'handle_optin_optout' ) ); + + // uninstall reason + add_action( 'wp_ajax_' . $this->client->slug . '_submit-uninstall-reason', array( $this, 'uninstall_reason_submission' ) ); + + // cron events + add_filter( 'cron_schedules', array( $this, 'add_weekly_schedule' ) ); + add_action( $this->client->slug . '_tracker_send_event', array( $this, 'send_tracking_data' ) ); + // add_action( 'admin_init', array( $this, 'send_tracking_data' ) ); // test + } + + /** + * Send tracking data to AppSero server + * + * @param bool $override + * + * @return void + */ + public function send_tracking_data( $override = false ) { + if ( ! $this->tracking_allowed() && ! $override ) { + return; + } + + // Send a maximum of once per week + $last_send = $this->get_last_send(); + + if ( $last_send && $last_send > strtotime( '-1 week' ) ) { + return; + } + + $tracking_data = $this->get_tracking_data(); + + $response = $this->client->send_request( $tracking_data, 'track' ); + + update_option( $this->client->slug . '_tracking_last_send', time() ); + } + + /** + * Get the tracking data points + * + * @return array + */ + protected function get_tracking_data() { + $all_plugins = $this->get_all_plugins(); + + $users = get_users( + array( + 'role' => 'administrator', + 'orderby' => 'ID', + 'order' => 'ASC', + 'number' => 1, + 'paged' => 1, + ) + ); + + $admin_user = ( is_array( $users ) && ! empty( $users ) ) ? $users[0] : false; + $first_name = ''; + $last_name = ''; + + if ( $admin_user ) { + $first_name = $admin_user->first_name ? $admin_user->first_name : $admin_user->display_name; + $last_name = $admin_user->last_name; + } + + $data = array( + 'url' => esc_url( home_url() ), + 'site' => $this->get_site_name(), + 'admin_email' => get_option( 'admin_email' ), + 'first_name' => $first_name, + 'last_name' => $last_name, + 'hash' => $this->client->hash, + 'server' => $this->get_server_info(), + 'wp' => $this->get_wp_info(), + 'users' => $this->get_user_counts(), + 'active_plugins' => count( $all_plugins['active_plugins'] ), + 'inactive_plugins' => count( $all_plugins['inactive_plugins'] ), + 'ip_address' => $this->get_user_ip_address(), + 'project_version' => $this->client->project_version, + 'tracking_skipped' => false, + 'is_local' => $this->is_local_server(), + ); + + // Add Plugins + if ( $this->plugin_data ) { + $plugins_data = array(); + + foreach ( $all_plugins['active_plugins'] as $slug => $plugin ) { + $slug = strstr( $slug, '/', true ); + + if ( ! $slug ) { + continue; + } + + $plugins_data[ $slug ] = array( + 'name' => isset( $plugin['name'] ) ? $plugin['name'] : '', + 'version' => isset( $plugin['version'] ) ? $plugin['version'] : '', + ); + } + + if ( array_key_exists( $this->client->slug, $plugins_data ) ) { + unset( $plugins_data[ $this->client->slug ] ); + } + + $data['plugins'] = $plugins_data; + } + + // Add Metadata + $extra = $this->get_extra_data(); + + if ( $extra ) { + $data['extra'] = $extra; + } + + // Check this has previously skipped tracking + $skipped = get_option( $this->client->slug . '_tracking_skipped' ); + + if ( $skipped === 'yes' ) { + delete_option( $this->client->slug . '_tracking_skipped' ); + + $data['tracking_skipped'] = true; + } + + return apply_filters( $this->client->slug . '_tracker_data', $data ); + } + + /** + * If a child class wants to send extra data + * + * @return mixed + */ + protected function get_extra_data() { + if ( is_callable( $this->extra_data ) ) { + return call_user_func( $this->extra_data ); + } + + if ( is_array( $this->extra_data ) ) { + return $this->extra_data; + } + + return array(); + } + + /** + * Explain the user which data we collect + * + * @return array + */ + protected function data_we_collect() { + $data = array( + 'Server environment details (php, mysql, server, WordPress versions)', + 'Number of users in your site', + 'Site language', + 'Number of active and inactive plugins', + 'Site name and URL', + 'Your name and email address', + ); + + if ( $this->plugin_data ) { + array_splice( $data, 4, 0, array( "active plugins' name" ) ); + } + + return $data; + } + + /** + * Check if the user has opted into tracking + * + * @return bool + */ + public function tracking_allowed() { + $allow_tracking = get_option( $this->client->slug . '_allow_tracking', 'no' ); + + return $allow_tracking === 'yes'; + } + + /** + * Get the last time a tracking was sent + * + * @return false|string + */ + private function get_last_send() { + return get_option( $this->client->slug . '_tracking_last_send', false ); + } + + /** + * Check if the notice has been dismissed or enabled + * + * @return bool + */ + public function notice_dismissed() { + $hide_notice = get_option( $this->client->slug . '_tracking_notice', null ); + + if ( 'hide' === $hide_notice ) { + return true; + } + + return false; + } + + /** + * Check if the current server is localhost + * + * @return bool + */ + private function is_local_server() { + $host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : 'localhost'; + $ip = isset( $_SERVER['SERVER_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_ADDR'] ) ) : '127.0.0.1'; + $is_local = false; + + if ( + in_array( $ip, array( '127.0.0.1', '::1' ), true ) + || ! strpos( $host, '.' ) + || in_array( strrchr( $host, '.' ), array( '.test', '.testing', '.local', '.localhost', '.localdomain' ), true ) + ) { + $is_local = true; + } + + return apply_filters( 'appsero_is_local', $is_local ); + } + + /** + * Schedule the event weekly + * + * @return void + */ + private function schedule_event() { + $hook_name = wp_unslash( $this->client->slug . '_tracker_send_event' ); + + if ( ! wp_next_scheduled( $hook_name ) ) { + wp_schedule_event( time(), 'weekly', $hook_name ); + } + } + + /** + * Clear any scheduled hook + * + * @return void + */ + private function clear_schedule_event() { + wp_clear_scheduled_hook( $this->client->slug . '_tracker_send_event' ); + } + + /** + * Display the admin notice to users that have not opted-in or out + * + * @return void + */ + public function admin_notice() { + if ( $this->notice_dismissed() ) { + return; + } + + if ( $this->tracking_allowed() ) { + return; + } + + if ( ! current_user_can( 'manage_options' ) ) { + return; + } + + // don't show tracking if a local server + // if ( $this->is_local_server() ) { + // return; + // } + + $optin_url = wp_nonce_url( add_query_arg( $this->client->slug . '_tracker_optin', 'true' ), '_wpnonce' ); + $optout_url = wp_nonce_url( add_query_arg( $this->client->slug . '_tracker_optout', 'true' ), '_wpnonce' ); + + if ( empty( $this->notice ) ) { + $notice = sprintf( $this->client->_trans( 'Want to help make <strong>%1$s</strong> even more awesome? Allow %1$s to collect diagnostic data and usage information.' ), $this->client->name ); + } else { + $notice = $this->notice; + } + + $policy_url = 'https://appsero.com/privacy-policy/'; + + $notice .= ' (<a class="' . $this->client->slug . '-insights-data-we-collect" href="#">' . $this->client->_trans( 'what we collect' ) . '</a>)'; + $notice .= '<p class="description" style="display:none;">' . implode( ', ', $this->data_we_collect() ) . '. '; + $notice .= 'We are using Appsero to collect your data. <a href="' . $policy_url . '" target="_blank">Learn more</a> about how Appsero collects and handle your data.</p>'; + + echo '<div class="updated"><p>'; + echo $notice; + echo '</p><p class="submit">'; + echo ' <a href="' . esc_url( $optin_url ) . '" class="button-primary button-large">' . $this->client->_trans( 'Allow' ) . '</a>'; + echo ' <a href="' . esc_url( $optout_url ) . '" class="button-secondary button-large">' . $this->client->_trans( 'No thanks' ) . '</a>'; + echo '</p></div>'; + + echo "<script type='text/javascript'>jQuery('." . $this->client->slug . "-insights-data-we-collect').on('click', function(e) { e.preventDefault(); jQuery(this).parents('.updated').find('p.description').slideToggle('fast'); }); </script> "; - } - - /** - * Handle the optin/optout - * - * @return void - */ - public function handle_optin_optout() - { - if (!isset($_GET['_wpnonce'])) { - return; - } - - if (!wp_verify_nonce(sanitize_key($_GET['_wpnonce']), '_wpnonce')) { - return; - } - - if (isset($_GET[$this->client->slug . '_tracker_optin']) && $_GET[$this->client->slug . '_tracker_optin'] === 'true') { - $this->optin(); - - wp_safe_redirect(remove_query_arg($this->client->slug . '_tracker_optin')); - exit; - } - - if (isset($_GET[$this->client->slug . '_tracker_optout']) && isset($_GET[$this->client->slug . '_tracker_optout']) && $_GET[$this->client->slug . '_tracker_optout'] === 'true') { - $this->optout(); - - wp_safe_redirect(remove_query_arg($this->client->slug . '_tracker_optout')); - exit; - } - } - - /** - * Tracking optin - * - * @return void - */ - public function optin() - { - update_option($this->client->slug . '_allow_tracking', 'yes'); - update_option($this->client->slug . '_tracking_notice', 'hide'); - - $this->clear_schedule_event(); - $this->schedule_event(); - $this->send_tracking_data(); - - /* - * Fires when the user has opted in tracking. - */ - do_action($this->client->slug . '_tracker_optin', $this->get_tracking_data()); - } - - /** - * Optout from tracking - * - * @return void - */ - public function optout() - { - update_option($this->client->slug . '_allow_tracking', 'no'); - update_option($this->client->slug . '_tracking_notice', 'hide'); - - $this->send_tracking_skipped_request(); - - $this->clear_schedule_event(); - - /* - * Fires when the user has opted out tracking. - */ - do_action($this->client->slug . '_tracker_optout'); - } - - /** - * Get the number of post counts - * - * @param string $post_type - * - * @return int - */ - public function get_post_count($post_type) - { - global $wpdb; - - return (int) $wpdb->get_var( - $wpdb->prepare( - "SELECT count(ID) FROM $wpdb->posts WHERE post_type = %s and post_status = %s", - [$post_type, 'publish'] - ) - ); - } - - /** - * Get server related info. - * - * @return array - */ - private static function get_server_info() - { - global $wpdb; - - $server_data = []; - - if (isset($_SERVER['SERVER_SOFTWARE']) && !empty($_SERVER['SERVER_SOFTWARE'])) { + } + + /** + * Handle the optin/optout + * + * @return void + */ + public function handle_optin_optout() { + if ( ! isset( $_GET['_wpnonce'] ) ) { + return; + } + + if ( ! wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), '_wpnonce' ) ) { + return; + } + + if ( isset( $_GET[ $this->client->slug . '_tracker_optin' ] ) && $_GET[ $this->client->slug . '_tracker_optin' ] === 'true' ) { + $this->optin(); + + wp_safe_redirect( remove_query_arg( $this->client->slug . '_tracker_optin' ) ); + exit; + } + + if ( isset( $_GET[ $this->client->slug . '_tracker_optout' ] ) && isset( $_GET[ $this->client->slug . '_tracker_optout' ] ) && $_GET[ $this->client->slug . '_tracker_optout' ] === 'true' ) { + $this->optout(); + + wp_safe_redirect( remove_query_arg( $this->client->slug . '_tracker_optout' ) ); + exit; + } + } + + /** + * Tracking optin + * + * @return void + */ + public function optin() { + update_option( $this->client->slug . '_allow_tracking', 'yes' ); + update_option( $this->client->slug . '_tracking_notice', 'hide' ); + + $this->clear_schedule_event(); + $this->schedule_event(); + $this->send_tracking_data(); + + /* + * Fires when the user has opted in tracking. + */ + do_action( $this->client->slug . '_tracker_optin', $this->get_tracking_data() ); + } + + /** + * Optout from tracking + * + * @return void + */ + public function optout() { + update_option( $this->client->slug . '_allow_tracking', 'no' ); + update_option( $this->client->slug . '_tracking_notice', 'hide' ); + + $this->send_tracking_skipped_request(); + + $this->clear_schedule_event(); + + /* + * Fires when the user has opted out tracking. + */ + do_action( $this->client->slug . '_tracker_optout' ); + } + + /** + * Get the number of post counts + * + * @param string $post_type + * + * @return int + */ + public function get_post_count( $post_type ) { + global $wpdb; + + return (int) $wpdb->get_var( + $wpdb->prepare( + "SELECT count(ID) FROM $wpdb->posts WHERE post_type = %s and post_status = %s", + array( $post_type, 'publish' ) + ) + ); + } + + /** + * Get server related info. + * + * @return array + */ + private static function get_server_info() { + global $wpdb; + + $server_data = array(); + + if ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) { // phpcs:ignore $server_data['software'] = $_SERVER['SERVER_SOFTWARE']; - } - - if (function_exists('phpversion')) { - $server_data['php_version'] = phpversion(); - } - - $server_data['mysql_version'] = $wpdb->db_version(); - - $server_data['php_max_upload_size'] = size_format(wp_max_upload_size()); - $server_data['php_default_timezone'] = date_default_timezone_get(); - $server_data['php_soap'] = class_exists('SoapClient') ? 'Yes' : 'No'; - $server_data['php_fsockopen'] = function_exists('fsockopen') ? 'Yes' : 'No'; - $server_data['php_curl'] = function_exists('curl_init') ? 'Yes' : 'No'; - - return $server_data; - } - - /** - * Get WordPress related data. - * - * @return array - */ - private function get_wp_info() - { - $wp_data = []; - - $wp_data['memory_limit'] = WP_MEMORY_LIMIT; - $wp_data['debug_mode'] = (defined('WP_DEBUG') && WP_DEBUG) ? 'Yes' : 'No'; - $wp_data['locale'] = get_locale(); - $wp_data['version'] = get_bloginfo('version'); - $wp_data['multisite'] = is_multisite() ? 'Yes' : 'No'; - $wp_data['theme_slug'] = get_stylesheet(); - - $theme = wp_get_theme($wp_data['theme_slug']); - - $wp_data['theme_name'] = $theme->get('Name'); - $wp_data['theme_version'] = $theme->get('Version'); - $wp_data['theme_uri'] = $theme->get('ThemeURI'); - $wp_data['theme_author'] = $theme->get('Author'); - - return $wp_data; - } - - /** - * Get the list of active and inactive plugins - * - * @return array - */ - private function get_all_plugins() - { - // Ensure get_plugins function is loaded - if (!function_exists('get_plugins')) { - include ABSPATH . '/wp-admin/includes/plugin.php'; - } - - $plugins = get_plugins(); - $active_plugins_keys = get_option('active_plugins', []); - $active_plugins = []; - - foreach ($plugins as $k => $v) { - // Take care of formatting the data how we want it. - $formatted = []; - $formatted['name'] = wp_strip_all_tags($v['Name']); - - if (isset($v['Version'])) { - $formatted['version'] = wp_strip_all_tags($v['Version']); - } - - if (isset($v['Author'])) { - $formatted['author'] = wp_strip_all_tags($v['Author']); - } - - if (isset($v['Network'])) { - $formatted['network'] = wp_strip_all_tags($v['Network']); - } - - if (isset($v['PluginURI'])) { - $formatted['plugin_uri'] = wp_strip_all_tags($v['PluginURI']); - } - - if (in_array($k, $active_plugins_keys, true)) { - // Remove active plugins from list so we can show active and inactive separately - unset($plugins[$k]); - $active_plugins[$k] = $formatted; - } else { - $plugins[$k] = $formatted; - } - } - - return [ - 'active_plugins' => $active_plugins, - 'inactive_plugins' => $plugins, - ]; - } - - /** - * Get user totals based on user role. - * - * @return array - */ - public function get_user_counts() - { - $user_count = []; - $user_count_data = count_users(); - $user_count['total'] = $user_count_data['total_users']; - - // Get user count based on user role - foreach ($user_count_data['avail_roles'] as $role => $count) { - if (!$count) { - continue; - } - - $user_count[$role] = $count; - } - - return $user_count; - } - - /** - * Add weekly cron schedule - * - * @param array $schedules - * - * @return array - */ - public function add_weekly_schedule($schedules) - { - $schedules['weekly'] = [ - 'interval' => DAY_IN_SECONDS * 7, - 'display' => 'Once Weekly', - ]; - - return $schedules; - } - - /** - * Plugin activation hook - * - * @return void - */ - public function activate_plugin() - { - $allowed = get_option($this->client->slug . '_allow_tracking', 'no'); - - // if it wasn't allowed before, do nothing - if ('yes' !== $allowed) { - return; - } - - // re-schedule and delete the last sent time so we could force send again - $hook_name = $this->client->slug . '_tracker_send_event'; - - if (!wp_next_scheduled($hook_name)) { - wp_schedule_event(time(), 'weekly', $hook_name); - } - - delete_option($this->client->slug . '_tracking_last_send'); - - $this->send_tracking_data(true); - } - - /** - * Clear our options upon deactivation - * - * @return void - */ - public function deactivation_cleanup() - { - $this->clear_schedule_event(); - - if ('theme' === $this->client->type) { - delete_option($this->client->slug . '_tracking_last_send'); - delete_option($this->client->slug . '_allow_tracking'); - } - - delete_option($this->client->slug . '_tracking_notice'); - } - - /** - * Hook into action links and modify the deactivate link - * - * @param array $links - * - * @return array - */ - public function plugin_action_links($links) - { - if (array_key_exists('deactivate', $links)) { - $links['deactivate'] = str_replace('<a', '<a class="' . $this->client->slug . '-deactivate-link"', $links['deactivate']); - } - - return $links; - } - - /** - * Plugin uninstall reasons - * - * @return array - */ - private function get_uninstall_reasons() - { - $reasons = [ - [ - 'id' => 'could-not-understand', - 'text' => $this->client->_trans("Couldn't understand"), - 'placeholder' => $this->client->_trans('Would you like us to assist you?'), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 10.6 23 9.6 22.9 8.8 22.7L8.8 22.6C9.3 22.5 9.7 22.3 10 21.9 10.3 21.6 10.4 21.3 10.4 20.9 10.8 21 11.1 21 11.5 21 16.7 21 21 16.7 21 11.5 21 6.3 16.7 2 11.5 2 6.3 2 2 6.3 2 11.5 2 13 2.3 14.3 2.9 15.6 2.7 16 2.4 16.3 2.2 16.8L2.1 17.1 2.1 17.3C2 17.5 2 17.7 2 18 0.7 16.1 0 13.9 0 11.5 0 5.1 5.1 0 11.5 0ZM6 13.6C6 13.7 6.1 13.8 6.1 13.9 6.3 14.5 6.2 15.7 6.1 16.4 6.1 16.6 6 16.9 6 17.1 6 17.1 6.1 17.1 6.1 17.1 7.1 16.9 8.2 16 9.3 15.5 9.8 15.2 10.4 15 10.9 15 11.2 15 11.4 15 11.6 15.2 11.9 15.4 12.1 16 11.6 16.4 11.5 16.5 11.3 16.6 11.1 16.7 10.5 17 9.9 17.4 9.3 17.7 9 17.9 9 18.1 9.1 18.5 9.2 18.9 9.3 19.4 9.3 19.8 9.4 20.3 9.3 20.8 9 21.2 8.8 21.5 8.5 21.6 8.1 21.7 7.9 21.8 7.6 21.9 7.3 21.9L6.5 22C6.3 22 6 21.9 5.8 21.9 5 21.8 4.4 21.5 3.9 20.9 3.3 20.4 3.1 19.6 3 18.8L3 18.5C3 18.2 3 17.9 3.1 17.7L3.1 17.6C3.2 17.1 3.5 16.7 3.7 16.3 4 15.9 4.2 15.4 4.3 15 4.4 14.6 4.4 14.5 4.6 14.2 4.6 13.9 4.7 13.7 4.9 13.6 5.2 13.2 5.7 13.2 6 13.6ZM11.7 11.2C13.1 11.2 14.3 11.7 15.2 12.9 15.3 13 15.4 13.1 15.4 13.2 15.4 13.4 15.3 13.8 15.2 13.8 15 13.9 14.9 13.8 14.8 13.7 14.6 13.5 14.4 13.2 14.1 13.1 13.5 12.6 12.8 12.3 12 12.2 10.7 12.1 9.5 12.3 8.4 12.8 8.3 12.8 8.2 12.8 8.1 12.8 7.9 12.8 7.8 12.4 7.8 12.2 7.7 12.1 7.8 11.9 8 11.8 8.4 11.7 8.8 11.5 9.2 11.4 10 11.2 10.9 11.1 11.7 11.2ZM16.3 5.9C17.3 5.9 18 6.6 18 7.6 18 8.5 17.3 9.3 16.3 9.3 15.4 9.3 14.7 8.5 14.7 7.6 14.7 6.6 15.4 5.9 16.3 5.9ZM8.3 5C9.2 5 9.9 5.8 9.9 6.7 9.9 7.7 9.2 8.4 8.2 8.4 7.3 8.4 6.6 7.7 6.6 6.7 6.6 5.8 7.3 5 8.3 5Z"/></g></g></svg>', - ], - [ - 'id' => 'found-better-plugin', - 'text' => $this->client->_trans('Found a better plugin'), - 'placeholder' => $this->client->_trans('Which plugin?'), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M17.1 14L22.4 19.3C23.2 20.2 23.2 21.5 22.4 22.4 21.5 23.2 20.2 23.2 19.3 22.4L19.3 22.4 14 17.1C15.3 16.3 16.3 15.3 17.1 14L17.1 14ZM8.6 0C13.4 0 17.3 3.9 17.3 8.6 17.3 13.4 13.4 17.2 8.6 17.2 3.9 17.2 0 13.4 0 8.6 0 3.9 3.9 0 8.6 0ZM8.6 2.2C5.1 2.2 2.2 5.1 2.2 8.6 2.2 12.2 5.1 15.1 8.6 15.1 12.2 15.1 15.1 12.2 15.1 8.6 15.1 5.1 12.2 2.2 8.6 2.2ZM8.6 3.6L8.6 5C6.6 5 5 6.6 5 8.6L5 8.6 3.6 8.6C3.6 5.9 5.9 3.6 8.6 3.6L8.6 3.6Z"/></g></g></svg>', - ], - [ - 'id' => 'not-have-that-feature', - 'text' => $this->client->_trans('Missing a specific feature'), - 'placeholder' => $this->client->_trans('Could you tell us more about that feature?'), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="17" viewBox="0 0 24 17"><g fill="none"><g fill="#3B86FF"><path d="M19.4 0C19.7 0.6 19.8 1.3 19.8 2 19.8 3.2 19.4 4.4 18.5 5.3 17.6 6.2 16.5 6.7 15.2 6.7 15.2 6.7 15.2 6.7 15.2 6.7 14 6.7 12.9 6.2 12 5.3 11.2 4.4 10.7 3.3 10.7 2 10.7 1.3 10.8 0.6 11.1 0L7.6 0 7 0 6.5 0 6.5 5.7C6.3 5.6 5.9 5.3 5.6 5.1 5 4.6 4.3 4.3 3.5 4.3 3.5 4.3 3.5 4.3 3.4 4.3 1.6 4.4 0 5.9 0 7.9 0 8.6 0.2 9.2 0.5 9.7 1.1 10.8 2.2 11.5 3.5 11.5 4.3 11.5 5 11.2 5.6 10.8 6 10.5 6.3 10.3 6.5 10.2L6.5 10.2 6.5 17 6.5 17 7 17 7.6 17 22.5 17C23.3 17 24 16.3 24 15.5L24 0 19.4 0Z"/></g></g></svg>', - ], - [ - 'id' => 'is-not-working', - 'text' => $this->client->_trans('Not working'), - 'placeholder' => $this->client->_trans('Could you tell us a bit more whats not working?'), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 5.1 23 0 17.9 0 11.5 0 5.1 5.1 0 11.5 0ZM11.8 14.4C11.2 14.4 10.7 14.8 10.7 15.4 10.7 16 11.2 16.4 11.8 16.4 12.4 16.4 12.8 16 12.8 15.4 12.8 14.8 12.4 14.4 11.8 14.4ZM12 7C10.1 7 9.1 8.1 9 9.6L10.5 9.6C10.5 8.8 11.1 8.3 11.9 8.3 12.7 8.3 13.2 8.8 13.2 9.5 13.2 10.1 13 10.4 12.2 10.9 11.3 11.4 10.9 12 11 12.9L11 13.4 12.5 13.4 12.5 13C12.5 12.4 12.7 12.1 13.5 11.6 14.4 11.1 14.9 10.4 14.9 9.4 14.9 8 13.7 7 12 7Z"/></g></g></svg>', - ], - [ - 'id' => 'looking-for-other', - 'text' => $this->client->_trans('Not what I was looking'), - 'placeholder' => $this->client->_trans('Could you tell us a bit more?'), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="17" viewBox="0 0 24 17"><g fill="none"><g fill="#3B86FF"><path d="M23.5 9C23.5 9 23.5 8.9 23.5 8.9 23.5 8.9 23.5 8.9 23.5 8.9 23.4 8.6 23.2 8.3 23 8 22.2 6.5 20.6 3.7 19.8 2.6 18.8 1.3 17.7 0 16.1 0 15.7 0 15.3 0.1 14.9 0.2 13.8 0.6 12.6 1.2 12.3 2.7L11.7 2.7C11.4 1.2 10.2 0.6 9.1 0.2 8.7 0.1 8.3 0 7.9 0 6.3 0 5.2 1.3 4.2 2.6 3.4 3.7 1.8 6.5 1 8 0.8 8.3 0.6 8.6 0.5 8.9 0.5 8.9 0.5 8.9 0.5 8.9 0.5 8.9 0.5 9 0.5 9 0.2 9.7 0 10.5 0 11.3 0 14.4 2.5 17 5.5 17 7.3 17 8.8 16.1 9.8 14.8L14.2 14.8C15.2 16.1 16.7 17 18.5 17 21.5 17 24 14.4 24 11.3 24 10.5 23.8 9.7 23.5 9ZM5.5 15C3.6 15 2 13.2 2 11 2 8.8 3.6 7 5.5 7 7.4 7 9 8.8 9 11 9 13.2 7.4 15 5.5 15ZM18.5 15C16.6 15 15 13.2 15 11 15 8.8 16.6 7 18.5 7 20.4 7 22 8.8 22 11 22 13.2 20.4 15 18.5 15Z"/></g></g></svg>', - ], - [ - 'id' => 'did-not-work-as-expected', - 'text' => $this->client->_trans("Didn't work as expected"), - 'placeholder' => $this->client->_trans('What did you expect?'), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 5.1 23 0 17.9 0 11.5 0 5.1 5.1 0 11.5 0ZM11.5 2C6.3 2 2 6.3 2 11.5 2 16.7 6.3 21 11.5 21 16.7 21 21 16.7 21 11.5 21 6.3 16.7 2 11.5 2ZM12.5 12.9L12.7 5 10.2 5 10.5 12.9 12.5 12.9ZM11.5 17.4C12.4 17.4 13 16.8 13 15.9 13 15 12.4 14.4 11.5 14.4 10.6 14.4 10 15 10 15.9 10 16.8 10.6 17.4 11.5 17.4Z"/></g></g></svg>', - ], - [ - 'id' => 'other', - 'text' => $this->client->_trans('Others'), - 'placeholder' => $this->client->_trans('Could you tell us a bit more?'), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="23" viewBox="0 0 24 6"><g fill="none"><g fill="#3B86FF"><path d="M3 0C4.7 0 6 1.3 6 3 6 4.7 4.7 6 3 6 1.3 6 0 4.7 0 3 0 1.3 1.3 0 3 0ZM12 0C13.7 0 15 1.3 15 3 15 4.7 13.7 6 12 6 10.3 6 9 4.7 9 3 9 1.3 10.3 0 12 0ZM21 0C22.7 0 24 1.3 24 3 24 4.7 22.7 6 21 6 19.3 6 18 4.7 18 3 18 1.3 19.3 0 21 0Z"/></g></g></svg>', - ], - ]; - - return $reasons; - } - - /** - * Plugin deactivation uninstall reason submission - * - * @return void - */ - public function uninstall_reason_submission() - { - if (!isset($_POST['nonce'])) { - return; - } - - if (!isset($_POST['reason_id'])) { - wp_send_json_error(); - } - - if (!wp_verify_nonce(sanitize_key(wp_unslash($_POST['nonce'])), 'appsero-security-nonce')) { - wp_send_json_error('Nonce verification failed'); - } - - if (!current_user_can('manage_options')) { - wp_send_json_error('You are not allowed for this task'); - } - - $data = $this->get_tracking_data(); - $data['reason_id'] = sanitize_text_field(wp_unslash($_POST['reason_id'])); - $data['reason_info'] = isset($_REQUEST['reason_info']) ? trim(sanitize_text_field(wp_unslash($_REQUEST['reason_info']))) : ''; - - $this->client->send_request($data, 'deactivate'); - - /* - * Fire after the plugin _uninstall_reason_submitted - */ - do_action($this->client->slug . '_uninstall_reason_submitted', $data); - - wp_send_json_success(); - } - - /** - * Handle the plugin deactivation feedback - * - * @return void - */ - public function deactivate_scripts() - { - global $pagenow; - - if ('plugins.php' !== $pagenow) { - return; - } - - $this->deactivation_modal_styles(); - $reasons = $this->get_uninstall_reasons(); - $custom_reasons = apply_filters('appsero_custom_deactivation_reasons', [], $this->client); -?> - - <div class="wd-dr-modal" id="<?php echo $this->client->slug; ?>-wd-dr-modal"> - <div class="wd-dr-modal-wrap"> - <div class="wd-dr-modal-header"> - <h3><?php $this->client->_etrans('Goodbyes are always hard. If you have a moment, please let us know how we can improve.'); ?></h3> - </div> - - <div class="wd-dr-modal-body"> - <ul class="wd-de-reasons"> - <?php foreach ($reasons as $reason) { ?> - <li data-placeholder="<?php echo esc_attr($reason['placeholder']); ?>"> - <label> - <input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> - <div class="wd-de-reason-icon"><?php echo $reason['icon']; ?></div> - <div class="wd-de-reason-text"><?php echo $reason['text']; ?></div> - </label> - </li> - <?php } ?> - </ul> - <?php if ($custom_reasons && is_array($custom_reasons)) { ?> - <ul class="wd-de-reasons wd-de-others-reasons"> - <?php foreach ($custom_reasons as $reason) { ?> - <li data-placeholder="<?php echo esc_attr($reason['placeholder']); ?>" data-customreason="true"> - <label> - <input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> - <div class="wd-de-reason-icon"><?php echo $reason['icon']; ?></div> - <div class="wd-de-reason-text"><?php echo $reason['text']; ?></div> - </label> - </li> - <?php } ?> - </ul> - <?php } ?> - <div class="wd-dr-modal-reason-input"><textarea></textarea></div> - <p class="wd-dr-modal-reasons-bottom"> - <?php - echo sprintf( - $this->client->_trans('We share your data with <a href="%1$s" target="_blank">Appsero</a> to troubleshoot problems & make product improvements. <a href="%2$s" target="_blank">Learn more</a> about how Appsero handles your data.'), - esc_url('https://appsero.com/'), - esc_url('https://appsero.com/privacy-policy') - ); - ?> - </p> - </div> - - <div class="wd-dr-modal-footer"> - <a href="#" class="dont-bother-me wd-dr-button-secondary"><?php $this->client->_etrans('Skip & Deactivate'); ?></a> - <button class="wd-dr-button-secondary wd-dr-cancel-modal"><?php $this->client->_etrans('Cancel'); ?></button> - <button class="wd-dr-submit-modal"><?php $this->client->_etrans('Submit & Deactivate'); ?></button> - </div> - </div> - </div> - - <script type="text/javascript"> - (function($) { - $(function() { - var modal = $('#<?php echo $this->client->slug; ?>-wd-dr-modal'); - var deactivateLink = ''; - - // Open modal - $('#the-list').on('click', 'a.<?php echo $this->client->slug; ?>-deactivate-link', function(e) { - e.preventDefault(); - - modal.addClass('modal-active'); - deactivateLink = $(this).attr('href'); - modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left'); - }); - - // Close modal; Cancel - modal.on('click', 'button.wd-dr-cancel-modal', function(e) { - e.preventDefault(); - modal.removeClass('modal-active'); - }); - - // Reason change - modal.on('click', 'input[type="radio"]', function() { - var parent = $(this).parents('li'); - var isCustomReason = parent.data('customreason'); - var inputValue = $(this).val(); - - if (isCustomReason) { - $('ul.wd-de-reasons.wd-de-others-reasons li').removeClass('wd-de-reason-selected'); - } else { - $('ul.wd-de-reasons li').removeClass('wd-de-reason-selected'); - - if ("other" != inputValue) { - $('ul.wd-de-reasons.wd-de-others-reasons').css('display', 'none'); - } - } - - // Show if has custom reasons - if ("other" == inputValue) { - $('ul.wd-de-reasons.wd-de-others-reasons').css('display', 'flex'); - } - - parent.addClass('wd-de-reason-selected'); - $('.wd-dr-modal-reason-input').show(); - - $('.wd-dr-modal-reason-input textarea').attr('placeholder', parent.data('placeholder')).focus(); - }); - - // Submit response - modal.on('click', 'button.wd-dr-submit-modal', function(e) { - e.preventDefault(); - - var button = $(this); - - if (button.hasClass('disabled')) { - return; - } - - var $radio = $('input[type="radio"]:checked', modal); - var $input = $('.wd-dr-modal-reason-input textarea'); - - $.ajax({ - url: ajaxurl, - type: 'POST', - data: { - nonce: '<?php echo wp_create_nonce('appsero-security-nonce'); ?>', - action: '<?php echo $this->client->slug; ?>_submit-uninstall-reason', - reason_id: (0 === $radio.length) ? 'none' : $radio.val(), - reason_info: (0 !== $input.length) ? $input.val().trim() : '' - }, - beforeSend: function() { - button.addClass('disabled'); - button.text('Processing...'); - }, - complete: function() { - window.location.href = deactivateLink; - } - }); - }); - }); - }(jQuery)); - </script> - - <?php - } - - /** - * Run after theme deactivated - * - * @param string $new_name - * @param object $new_theme - * @param object $old_theme - * - * @return void - */ - public function theme_deactivated($new_name, $new_theme, $old_theme) - { - // Make sure this is appsero theme - if ($old_theme->get_template() === $this->client->slug) { - $this->client->send_request($this->get_tracking_data(), 'deactivate'); - } - } - - /** - * Get user IP Address - */ - private function get_user_ip_address() - { - $response = wp_remote_get('https://icanhazip.com/'); - - if (is_wp_error($response)) { - return ''; - } - - $ip = trim(wp_remote_retrieve_body($response)); - - if (!filter_var($ip, FILTER_VALIDATE_IP)) { - return ''; - } - - return $ip; - } - - /** - * Get site name - */ - private function get_site_name() - { - $site_name = get_bloginfo('name'); - - if (empty($site_name)) { - $site_name = get_bloginfo('description'); - $site_name = wp_trim_words($site_name, 3, ''); - } - - if (empty($site_name)) { - $site_name = esc_url(home_url()); - } - - return $site_name; - } - - /** - * Send request to appsero if user skip to send tracking data - */ - private function send_tracking_skipped_request() - { - $skipped = get_option($this->client->slug . '_tracking_skipped'); - - $data = [ - 'hash' => $this->client->hash, - 'previously_skipped' => false, - ]; - - if ($skipped === 'yes') { - $data['previously_skipped'] = true; - } else { - update_option($this->client->slug . '_tracking_skipped', 'yes'); - } - - $this->client->send_request($data, 'tracking-skipped'); - } - - /** - * Deactivation modal styles - */ - private function deactivation_modal_styles() - { - ?> - <style type="text/css"> - .wd-dr-modal { - position: fixed; - z-index: 99999; - top: 0; - right: 0; - bottom: 0; - left: 0; - background: rgba(0, 0, 0, 0.5); - display: none; - box-sizing: border-box; - overflow: scroll; - } - - .wd-dr-modal * { - box-sizing: border-box; - } - - .wd-dr-modal.modal-active { - display: block; - } - - .wd-dr-modal-wrap { - max-width: 870px; - width: 100%; - position: relative; - margin: 10% auto; - background: #fff; - } - - .wd-dr-modal-header { - border-bottom: 1px solid #E8E8E8; - padding: 20px 20px 18px 20px; - } - - .wd-dr-modal-header h3 { - line-height: 1.8; - margin: 0; - color: #4A5568; - } - - .wd-dr-modal-body { - padding: 5px 20px 20px 20px; - } - - .wd-dr-modal-body .reason-input { - margin-top: 5px; - margin-left: 20px; - } - - .wd-dr-modal-footer { - border-top: 1px solid #E8E8E8; - padding: 20px; - text-align: right; - } - - .wd-dr-modal-reasons-bottom { - margin: 0; - } - - ul.wd-de-reasons { - display: flex; - margin: 0 -5px 0 -5px; - padding: 15px 0 20px 0; - } - - ul.wd-de-reasons.wd-de-others-reasons { - padding-top: 0; - display: none; - } - - ul.wd-de-reasons li { - padding: 0 5px; - margin: 0; - width: 14.26%; - } - - ul.wd-de-reasons label { - position: relative; - border: 1px solid #E8E8E8; - border-radius: 4px; - display: block; - text-align: center; - height: 100%; - padding: 15px 3px 8px 3px; - } - - ul.wd-de-reasons label:after { - width: 0; - height: 0; - border-left: 8px solid transparent; - border-right: 8px solid transparent; - border-top: 10px solid #3B86FF; - position: absolute; - left: 50%; - top: 100%; - margin-left: -8px; - } - - ul.wd-de-reasons label input[type="radio"] { - position: absolute; - left: 0; - right: 0; - visibility: hidden; - } - - .wd-de-reason-text { - color: #4A5568; - font-size: 13px; - } - - .wd-de-reason-icon { - margin-bottom: 7px; - } - - ul.wd-de-reasons li.wd-de-reason-selected label { - background-color: #3B86FF; - border-color: #3B86FF; - } - - li.wd-de-reason-selected .wd-de-reason-icon svg, - li.wd-de-reason-selected .wd-de-reason-icon svg g { - fill: #fff; - } - - li.wd-de-reason-selected .wd-de-reason-text { - color: #fff; - } - - ul.wd-de-reasons li.wd-de-reason-selected label:after { - content: ""; - } - - .wd-dr-modal-reason-input { - margin-bottom: 15px; - display: none; - } - - .wd-dr-modal-reason-input textarea { - background: #FAFAFA; - border: 1px solid #287EB8; - border-radius: 4px; - width: 100%; - height: 100px; - color: #524242; - font-size: 13px; - line-height: 1.4; - padding: 11px 15px; - resize: none; - } - - .wd-dr-modal-reason-input textarea:focus { - outline: 0 none; - box-shadow: 0 0 0; - } - - .wd-dr-button-secondary, - .wd-dr-button-secondary:hover { - border: 1px solid #EBEBEB; - border-radius: 3px; - font-size: 13px; - line-height: 1.5; - color: #718096; - padding: 5px 12px; - cursor: pointer; - background-color: transparent; - text-decoration: none; - } - - .wd-dr-submit-modal, - .wd-dr-submit-modal:hover { - border: 1px solid #3B86FF; - background-color: #3B86FF; - border-radius: 3px; - font-size: 13px; - line-height: 1.5; - color: #fff; - padding: 5px 12px; - cursor: pointer; - margin-left: 4px; - } - </style> -<?php - } + } + + if ( function_exists( 'phpversion' ) ) { + $server_data['php_version'] = phpversion(); + } + + $server_data['mysql_version'] = $wpdb->db_version(); + + $server_data['php_max_upload_size'] = size_format( wp_max_upload_size() ); + $server_data['php_default_timezone'] = date_default_timezone_get(); + $server_data['php_soap'] = class_exists( 'SoapClient' ) ? 'Yes' : 'No'; + $server_data['php_fsockopen'] = function_exists( 'fsockopen' ) ? 'Yes' : 'No'; + $server_data['php_curl'] = function_exists( 'curl_init' ) ? 'Yes' : 'No'; + + return $server_data; + } + + /** + * Get WordPress related data. + * + * @return array + */ + private function get_wp_info() { + $wp_data = array(); + + $wp_data['memory_limit'] = WP_MEMORY_LIMIT; + $wp_data['debug_mode'] = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No'; + $wp_data['locale'] = get_locale(); + $wp_data['version'] = get_bloginfo( 'version' ); + $wp_data['multisite'] = is_multisite() ? 'Yes' : 'No'; + $wp_data['theme_slug'] = get_stylesheet(); + + $theme = wp_get_theme( $wp_data['theme_slug'] ); + + $wp_data['theme_name'] = $theme->get( 'Name' ); + $wp_data['theme_version'] = $theme->get( 'Version' ); + $wp_data['theme_uri'] = $theme->get( 'ThemeURI' ); + $wp_data['theme_author'] = $theme->get( 'Author' ); + + return $wp_data; + } + + /** + * Get the list of active and inactive plugins + * + * @return array + */ + private function get_all_plugins() { + // Ensure get_plugins function is loaded + if ( ! function_exists( 'get_plugins' ) ) { + include ABSPATH . '/wp-admin/includes/plugin.php'; + } + + $plugins = get_plugins(); + $active_plugins_keys = get_option( 'active_plugins', array() ); + $active_plugins = array(); + + foreach ( $plugins as $k => $v ) { + // Take care of formatting the data how we want it. + $formatted = array(); + $formatted['name'] = wp_strip_all_tags( $v['Name'] ); + + if ( isset( $v['Version'] ) ) { + $formatted['version'] = wp_strip_all_tags( $v['Version'] ); + } + + if ( isset( $v['Author'] ) ) { + $formatted['author'] = wp_strip_all_tags( $v['Author'] ); + } + + if ( isset( $v['Network'] ) ) { + $formatted['network'] = wp_strip_all_tags( $v['Network'] ); + } + + if ( isset( $v['PluginURI'] ) ) { + $formatted['plugin_uri'] = wp_strip_all_tags( $v['PluginURI'] ); + } + + if ( in_array( $k, $active_plugins_keys, true ) ) { + // Remove active plugins from list so we can show active and inactive separately + unset( $plugins[ $k ] ); + $active_plugins[ $k ] = $formatted; + } else { + $plugins[ $k ] = $formatted; + } + } + + return array( + 'active_plugins' => $active_plugins, + 'inactive_plugins' => $plugins, + ); + } + + /** + * Get user totals based on user role. + * + * @return array + */ + public function get_user_counts() { + $user_count = array(); + $user_count_data = count_users(); + $user_count['total'] = $user_count_data['total_users']; + + // Get user count based on user role + foreach ( $user_count_data['avail_roles'] as $role => $count ) { + if ( ! $count ) { + continue; + } + + $user_count[ $role ] = $count; + } + + return $user_count; + } + + /** + * Add weekly cron schedule + * + * @param array $schedules + * + * @return array + */ + public function add_weekly_schedule( $schedules ) { + $schedules['weekly'] = array( + 'interval' => DAY_IN_SECONDS * 7, + 'display' => 'Once Weekly', + ); + + return $schedules; + } + + /** + * Plugin activation hook + * + * @return void + */ + public function activate_plugin() { + $allowed = get_option( $this->client->slug . '_allow_tracking', 'no' ); + + // if it wasn't allowed before, do nothing + if ( 'yes' !== $allowed ) { + return; + } + + // re-schedule and delete the last sent time so we could force send again + $hook_name = $this->client->slug . '_tracker_send_event'; + + if ( ! wp_next_scheduled( $hook_name ) ) { + wp_schedule_event( time(), 'weekly', $hook_name ); + } + + delete_option( $this->client->slug . '_tracking_last_send' ); + + $this->send_tracking_data( true ); + } + + /** + * Clear our options upon deactivation + * + * @return void + */ + public function deactivation_cleanup() { + $this->clear_schedule_event(); + + if ( 'theme' === $this->client->type ) { + delete_option( $this->client->slug . '_tracking_last_send' ); + delete_option( $this->client->slug . '_allow_tracking' ); + } + + delete_option( $this->client->slug . '_tracking_notice' ); + } + + /** + * Hook into action links and modify the deactivate link + * + * @param array $links + * + * @return array + */ + public function plugin_action_links( $links ) { + if ( array_key_exists( 'deactivate', $links ) ) { + $links['deactivate'] = str_replace( '<a', '<a class="' . $this->client->slug . '-deactivate-link"', $links['deactivate'] ); + } + + return $links; + } + + /** + * Plugin uninstall reasons + * + * @return array + */ + private function get_uninstall_reasons() { + $reasons = array( + array( + 'id' => 'could-not-understand', + 'text' => $this->client->_trans( "Couldn't understand" ), + 'placeholder' => $this->client->_trans( 'Would you like us to assist you?' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 10.6 23 9.6 22.9 8.8 22.7L8.8 22.6C9.3 22.5 9.7 22.3 10 21.9 10.3 21.6 10.4 21.3 10.4 20.9 10.8 21 11.1 21 11.5 21 16.7 21 21 16.7 21 11.5 21 6.3 16.7 2 11.5 2 6.3 2 2 6.3 2 11.5 2 13 2.3 14.3 2.9 15.6 2.7 16 2.4 16.3 2.2 16.8L2.1 17.1 2.1 17.3C2 17.5 2 17.7 2 18 0.7 16.1 0 13.9 0 11.5 0 5.1 5.1 0 11.5 0ZM6 13.6C6 13.7 6.1 13.8 6.1 13.9 6.3 14.5 6.2 15.7 6.1 16.4 6.1 16.6 6 16.9 6 17.1 6 17.1 6.1 17.1 6.1 17.1 7.1 16.9 8.2 16 9.3 15.5 9.8 15.2 10.4 15 10.9 15 11.2 15 11.4 15 11.6 15.2 11.9 15.4 12.1 16 11.6 16.4 11.5 16.5 11.3 16.6 11.1 16.7 10.5 17 9.9 17.4 9.3 17.7 9 17.9 9 18.1 9.1 18.5 9.2 18.9 9.3 19.4 9.3 19.8 9.4 20.3 9.3 20.8 9 21.2 8.8 21.5 8.5 21.6 8.1 21.7 7.9 21.8 7.6 21.9 7.3 21.9L6.5 22C6.3 22 6 21.9 5.8 21.9 5 21.8 4.4 21.5 3.9 20.9 3.3 20.4 3.1 19.6 3 18.8L3 18.5C3 18.2 3 17.9 3.1 17.7L3.1 17.6C3.2 17.1 3.5 16.7 3.7 16.3 4 15.9 4.2 15.4 4.3 15 4.4 14.6 4.4 14.5 4.6 14.2 4.6 13.9 4.7 13.7 4.9 13.6 5.2 13.2 5.7 13.2 6 13.6ZM11.7 11.2C13.1 11.2 14.3 11.7 15.2 12.9 15.3 13 15.4 13.1 15.4 13.2 15.4 13.4 15.3 13.8 15.2 13.8 15 13.9 14.9 13.8 14.8 13.7 14.6 13.5 14.4 13.2 14.1 13.1 13.5 12.6 12.8 12.3 12 12.2 10.7 12.1 9.5 12.3 8.4 12.8 8.3 12.8 8.2 12.8 8.1 12.8 7.9 12.8 7.8 12.4 7.8 12.2 7.7 12.1 7.8 11.9 8 11.8 8.4 11.7 8.8 11.5 9.2 11.4 10 11.2 10.9 11.1 11.7 11.2ZM16.3 5.9C17.3 5.9 18 6.6 18 7.6 18 8.5 17.3 9.3 16.3 9.3 15.4 9.3 14.7 8.5 14.7 7.6 14.7 6.6 15.4 5.9 16.3 5.9ZM8.3 5C9.2 5 9.9 5.8 9.9 6.7 9.9 7.7 9.2 8.4 8.2 8.4 7.3 8.4 6.6 7.7 6.6 6.7 6.6 5.8 7.3 5 8.3 5Z"/></g></g></svg>', + ), + array( + 'id' => 'found-better-plugin', + 'text' => $this->client->_trans( 'Found a better plugin' ), + 'placeholder' => $this->client->_trans( 'Which plugin?' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M17.1 14L22.4 19.3C23.2 20.2 23.2 21.5 22.4 22.4 21.5 23.2 20.2 23.2 19.3 22.4L19.3 22.4 14 17.1C15.3 16.3 16.3 15.3 17.1 14L17.1 14ZM8.6 0C13.4 0 17.3 3.9 17.3 8.6 17.3 13.4 13.4 17.2 8.6 17.2 3.9 17.2 0 13.4 0 8.6 0 3.9 3.9 0 8.6 0ZM8.6 2.2C5.1 2.2 2.2 5.1 2.2 8.6 2.2 12.2 5.1 15.1 8.6 15.1 12.2 15.1 15.1 12.2 15.1 8.6 15.1 5.1 12.2 2.2 8.6 2.2ZM8.6 3.6L8.6 5C6.6 5 5 6.6 5 8.6L5 8.6 3.6 8.6C3.6 5.9 5.9 3.6 8.6 3.6L8.6 3.6Z"/></g></g></svg>', + ), + array( + 'id' => 'not-have-that-feature', + 'text' => $this->client->_trans( 'Missing a specific feature' ), + 'placeholder' => $this->client->_trans( 'Could you tell us more about that feature?' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="17" viewBox="0 0 24 17"><g fill="none"><g fill="#3B86FF"><path d="M19.4 0C19.7 0.6 19.8 1.3 19.8 2 19.8 3.2 19.4 4.4 18.5 5.3 17.6 6.2 16.5 6.7 15.2 6.7 15.2 6.7 15.2 6.7 15.2 6.7 14 6.7 12.9 6.2 12 5.3 11.2 4.4 10.7 3.3 10.7 2 10.7 1.3 10.8 0.6 11.1 0L7.6 0 7 0 6.5 0 6.5 5.7C6.3 5.6 5.9 5.3 5.6 5.1 5 4.6 4.3 4.3 3.5 4.3 3.5 4.3 3.5 4.3 3.4 4.3 1.6 4.4 0 5.9 0 7.9 0 8.6 0.2 9.2 0.5 9.7 1.1 10.8 2.2 11.5 3.5 11.5 4.3 11.5 5 11.2 5.6 10.8 6 10.5 6.3 10.3 6.5 10.2L6.5 10.2 6.5 17 6.5 17 7 17 7.6 17 22.5 17C23.3 17 24 16.3 24 15.5L24 0 19.4 0Z"/></g></g></svg>', + ), + array( + 'id' => 'is-not-working', + 'text' => $this->client->_trans( 'Not working' ), + 'placeholder' => $this->client->_trans( 'Could you tell us a bit more whats not working?' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 5.1 23 0 17.9 0 11.5 0 5.1 5.1 0 11.5 0ZM11.8 14.4C11.2 14.4 10.7 14.8 10.7 15.4 10.7 16 11.2 16.4 11.8 16.4 12.4 16.4 12.8 16 12.8 15.4 12.8 14.8 12.4 14.4 11.8 14.4ZM12 7C10.1 7 9.1 8.1 9 9.6L10.5 9.6C10.5 8.8 11.1 8.3 11.9 8.3 12.7 8.3 13.2 8.8 13.2 9.5 13.2 10.1 13 10.4 12.2 10.9 11.3 11.4 10.9 12 11 12.9L11 13.4 12.5 13.4 12.5 13C12.5 12.4 12.7 12.1 13.5 11.6 14.4 11.1 14.9 10.4 14.9 9.4 14.9 8 13.7 7 12 7Z"/></g></g></svg>', + ), + array( + 'id' => 'looking-for-other', + 'text' => $this->client->_trans( 'Not what I was looking' ), + 'placeholder' => $this->client->_trans( 'Could you tell us a bit more?' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="17" viewBox="0 0 24 17"><g fill="none"><g fill="#3B86FF"><path d="M23.5 9C23.5 9 23.5 8.9 23.5 8.9 23.5 8.9 23.5 8.9 23.5 8.9 23.4 8.6 23.2 8.3 23 8 22.2 6.5 20.6 3.7 19.8 2.6 18.8 1.3 17.7 0 16.1 0 15.7 0 15.3 0.1 14.9 0.2 13.8 0.6 12.6 1.2 12.3 2.7L11.7 2.7C11.4 1.2 10.2 0.6 9.1 0.2 8.7 0.1 8.3 0 7.9 0 6.3 0 5.2 1.3 4.2 2.6 3.4 3.7 1.8 6.5 1 8 0.8 8.3 0.6 8.6 0.5 8.9 0.5 8.9 0.5 8.9 0.5 8.9 0.5 8.9 0.5 9 0.5 9 0.2 9.7 0 10.5 0 11.3 0 14.4 2.5 17 5.5 17 7.3 17 8.8 16.1 9.8 14.8L14.2 14.8C15.2 16.1 16.7 17 18.5 17 21.5 17 24 14.4 24 11.3 24 10.5 23.8 9.7 23.5 9ZM5.5 15C3.6 15 2 13.2 2 11 2 8.8 3.6 7 5.5 7 7.4 7 9 8.8 9 11 9 13.2 7.4 15 5.5 15ZM18.5 15C16.6 15 15 13.2 15 11 15 8.8 16.6 7 18.5 7 20.4 7 22 8.8 22 11 22 13.2 20.4 15 18.5 15Z"/></g></g></svg>', + ), + array( + 'id' => 'did-not-work-as-expected', + 'text' => $this->client->_trans( "Didn't work as expected" ), + 'placeholder' => $this->client->_trans( 'What did you expect?' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 23 23"><g fill="none"><g fill="#3B86FF"><path d="M11.5 0C17.9 0 23 5.1 23 11.5 23 17.9 17.9 23 11.5 23 5.1 23 0 17.9 0 11.5 0 5.1 5.1 0 11.5 0ZM11.5 2C6.3 2 2 6.3 2 11.5 2 16.7 6.3 21 11.5 21 16.7 21 21 16.7 21 11.5 21 6.3 16.7 2 11.5 2ZM12.5 12.9L12.7 5 10.2 5 10.5 12.9 12.5 12.9ZM11.5 17.4C12.4 17.4 13 16.8 13 15.9 13 15 12.4 14.4 11.5 14.4 10.6 14.4 10 15 10 15.9 10 16.8 10.6 17.4 11.5 17.4Z"/></g></g></svg>', + ), + array( + 'id' => 'other', + 'text' => $this->client->_trans( 'Others' ), + 'placeholder' => $this->client->_trans( 'Could you tell us a bit more?' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="23" viewBox="0 0 24 6"><g fill="none"><g fill="#3B86FF"><path d="M3 0C4.7 0 6 1.3 6 3 6 4.7 4.7 6 3 6 1.3 6 0 4.7 0 3 0 1.3 1.3 0 3 0ZM12 0C13.7 0 15 1.3 15 3 15 4.7 13.7 6 12 6 10.3 6 9 4.7 9 3 9 1.3 10.3 0 12 0ZM21 0C22.7 0 24 1.3 24 3 24 4.7 22.7 6 21 6 19.3 6 18 4.7 18 3 18 1.3 19.3 0 21 0Z"/></g></g></svg>', + ), + ); + + return $reasons; + } + + /** + * Plugin deactivation uninstall reason submission + * + * @return void + */ + public function uninstall_reason_submission() { + if ( ! isset( $_POST['nonce'] ) ) { + return; + } + + if ( ! isset( $_POST['reason_id'] ) ) { + wp_send_json_error(); + } + + if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'appsero-security-nonce' ) ) { + wp_send_json_error( 'Nonce verification failed' ); + } + + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json_error( 'You are not allowed for this task' ); + } + + $data = $this->get_tracking_data(); + $data['reason_id'] = sanitize_text_field( wp_unslash( $_POST['reason_id'] ) ); + $data['reason_info'] = isset( $_REQUEST['reason_info'] ) ? trim( sanitize_text_field( wp_unslash( $_REQUEST['reason_info'] ) ) ) : ''; + + $this->client->send_request( $data, 'deactivate' ); + + /* + * Fire after the plugin _uninstall_reason_submitted + */ + do_action( $this->client->slug . '_uninstall_reason_submitted', $data ); + + wp_send_json_success(); + } + + /** + * Handle the plugin deactivation feedback + * + * @return void + */ + public function deactivate_scripts() { + global $pagenow; + + if ( 'plugins.php' !== $pagenow ) { + return; + } + + $this->deactivation_modal_styles(); + $reasons = $this->get_uninstall_reasons(); + $custom_reasons = apply_filters( 'appsero_custom_deactivation_reasons', array(), $this->client ); + ?> + + <div class="wd-dr-modal" id="<?php echo $this->client->slug; ?>-wd-dr-modal"> + <div class="wd-dr-modal-wrap"> + <div class="wd-dr-modal-header"> + <h3><?php $this->client->_etrans( 'Goodbyes are always hard. If you have a moment, please let us know how we can improve.' ); ?></h3> + </div> + + <div class="wd-dr-modal-body"> + <ul class="wd-de-reasons"> + <?php foreach ( $reasons as $reason ) { ?> + <li data-placeholder="<?php echo esc_attr( $reason['placeholder'] ); ?>"> + <label> + <input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> + <div class="wd-de-reason-icon"><?php echo $reason['icon']; ?></div> + <div class="wd-de-reason-text"><?php echo $reason['text']; ?></div> + </label> + </li> + <?php } ?> + </ul> + <?php if ( $custom_reasons && is_array( $custom_reasons ) ) { ?> + <ul class="wd-de-reasons wd-de-others-reasons"> + <?php foreach ( $custom_reasons as $reason ) { ?> + <li data-placeholder="<?php echo esc_attr( $reason['placeholder'] ); ?>" data-customreason="true"> + <label> + <input type="radio" name="selected-reason" value="<?php echo $reason['id']; ?>"> + <div class="wd-de-reason-icon"><?php echo $reason['icon']; ?></div> + <div class="wd-de-reason-text"><?php echo $reason['text']; ?></div> + </label> + </li> + <?php } ?> + </ul> + <?php } ?> + <div class="wd-dr-modal-reason-input"><textarea></textarea></div> + <p class="wd-dr-modal-reasons-bottom"> + <?php + printf( + $this->client->_trans( 'We share your data with <a href="%1$s" target="_blank">Appsero</a> to troubleshoot problems & make product improvements. <a href="%2$s" target="_blank">Learn more</a> about how Appsero handles your data.' ), + esc_url( 'https://appsero.com/' ), + esc_url( 'https://appsero.com/privacy-policy' ) + ); + ?> + </p> + </div> + + <div class="wd-dr-modal-footer"> + <a href="#" class="dont-bother-me wd-dr-button-secondary"><?php $this->client->_etrans( 'Skip & Deactivate' ); ?></a> + <button class="wd-dr-button-secondary wd-dr-cancel-modal"><?php $this->client->_etrans( 'Cancel' ); ?></button> + <button class="wd-dr-submit-modal"><?php $this->client->_etrans( 'Submit & Deactivate' ); ?></button> + </div> + </div> + </div> + + <script type="text/javascript"> + (function($) { + $(function() { + var modal = $('#<?php echo $this->client->slug; ?>-wd-dr-modal'); + var deactivateLink = ''; + + // Open modal + $('#the-list').on('click', 'a.<?php echo $this->client->slug; ?>-deactivate-link', function(e) { + e.preventDefault(); + + modal.addClass('modal-active'); + deactivateLink = $(this).attr('href'); + modal.find('a.dont-bother-me').attr('href', deactivateLink).css('float', 'left'); + }); + + // Close modal; Cancel + modal.on('click', 'button.wd-dr-cancel-modal', function(e) { + e.preventDefault(); + modal.removeClass('modal-active'); + }); + + // Reason change + modal.on('click', 'input[type="radio"]', function() { + var parent = $(this).parents('li'); + var isCustomReason = parent.data('customreason'); + var inputValue = $(this).val(); + + if (isCustomReason) { + $('ul.wd-de-reasons.wd-de-others-reasons li').removeClass('wd-de-reason-selected'); + } else { + $('ul.wd-de-reasons li').removeClass('wd-de-reason-selected'); + + if ("other" != inputValue) { + $('ul.wd-de-reasons.wd-de-others-reasons').css('display', 'none'); + } + } + + // Show if has custom reasons + if ("other" == inputValue) { + $('ul.wd-de-reasons.wd-de-others-reasons').css('display', 'flex'); + } + + parent.addClass('wd-de-reason-selected'); + $('.wd-dr-modal-reason-input').show(); + + $('.wd-dr-modal-reason-input textarea').attr('placeholder', parent.data('placeholder')).focus(); + }); + + // Submit response + modal.on('click', 'button.wd-dr-submit-modal', function(e) { + e.preventDefault(); + + var button = $(this); + + if (button.hasClass('disabled')) { + return; + } + + var $radio = $('input[type="radio"]:checked', modal); + var $input = $('.wd-dr-modal-reason-input textarea'); + + $.ajax({ + url: ajaxurl, + type: 'POST', + data: { + nonce: '<?php echo wp_create_nonce( 'appsero-security-nonce' ); ?>', + action: '<?php echo $this->client->slug; ?>_submit-uninstall-reason', + reason_id: (0 === $radio.length) ? 'none' : $radio.val(), + reason_info: (0 !== $input.length) ? $input.val().trim() : '' + }, + beforeSend: function() { + button.addClass('disabled'); + button.text('Processing...'); + }, + complete: function() { + window.location.href = deactivateLink; + } + }); + }); + }); + }(jQuery)); + </script> + + <?php + } + + /** + * Run after theme deactivated + * + * @param string $new_name + * @param object $new_theme + * @param object $old_theme + * + * @return void + */ + public function theme_deactivated( $new_name, $new_theme, $old_theme ) { + // Make sure this is appsero theme + if ( $old_theme->get_template() === $this->client->slug ) { + $this->client->send_request( $this->get_tracking_data(), 'deactivate' ); + } + } + + /** + * Get user IP Address + */ + private function get_user_ip_address() { + $response = wp_remote_get( 'https://icanhazip.com/' ); + + if ( is_wp_error( $response ) ) { + return ''; + } + + $ip = trim( wp_remote_retrieve_body( $response ) ); + + if ( ! filter_var( $ip, FILTER_VALIDATE_IP ) ) { + return ''; + } + + return $ip; + } + + /** + * Get site name + */ + private function get_site_name() { + $site_name = get_bloginfo( 'name' ); + + if ( empty( $site_name ) ) { + $site_name = get_bloginfo( 'description' ); + $site_name = wp_trim_words( $site_name, 3, '' ); + } + + if ( empty( $site_name ) ) { + $site_name = esc_url( home_url() ); + } + + return $site_name; + } + + /** + * Send request to appsero if user skip to send tracking data + */ + private function send_tracking_skipped_request() { + $skipped = get_option( $this->client->slug . '_tracking_skipped' ); + + $data = array( + 'hash' => $this->client->hash, + 'previously_skipped' => false, + ); + + if ( $skipped === 'yes' ) { + $data['previously_skipped'] = true; + } else { + update_option( $this->client->slug . '_tracking_skipped', 'yes' ); + } + + $this->client->send_request( $data, 'tracking-skipped' ); + } + + /** + * Deactivation modal styles + */ + private function deactivation_modal_styles() { + ?> + <style type="text/css"> + .wd-dr-modal { + position: fixed; + z-index: 99999; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: rgba(0, 0, 0, 0.5); + display: none; + box-sizing: border-box; + overflow: scroll; + } + + .wd-dr-modal * { + box-sizing: border-box; + } + + .wd-dr-modal.modal-active { + display: block; + } + + .wd-dr-modal-wrap { + max-width: 870px; + width: 100%; + position: relative; + margin: 10% auto; + background: #fff; + } + + .wd-dr-modal-header { + border-bottom: 1px solid #E8E8E8; + padding: 20px 20px 18px 20px; + } + + .wd-dr-modal-header h3 { + line-height: 1.8; + margin: 0; + color: #4A5568; + } + + .wd-dr-modal-body { + padding: 5px 20px 20px 20px; + } + + .wd-dr-modal-body .reason-input { + margin-top: 5px; + margin-left: 20px; + } + + .wd-dr-modal-footer { + border-top: 1px solid #E8E8E8; + padding: 20px; + text-align: right; + } + + .wd-dr-modal-reasons-bottom { + margin: 0; + } + + ul.wd-de-reasons { + display: flex; + margin: 0 -5px 0 -5px; + padding: 15px 0 20px 0; + } + + ul.wd-de-reasons.wd-de-others-reasons { + padding-top: 0; + display: none; + } + + ul.wd-de-reasons li { + padding: 0 5px; + margin: 0; + width: 14.26%; + } + + ul.wd-de-reasons label { + position: relative; + border: 1px solid #E8E8E8; + border-radius: 4px; + display: block; + text-align: center; + height: 100%; + padding: 15px 3px 8px 3px; + } + + ul.wd-de-reasons label:after { + width: 0; + height: 0; + border-left: 8px solid transparent; + border-right: 8px solid transparent; + border-top: 10px solid #3B86FF; + position: absolute; + left: 50%; + top: 100%; + margin-left: -8px; + } + + ul.wd-de-reasons label input[type="radio"] { + position: absolute; + left: 0; + right: 0; + visibility: hidden; + } + + .wd-de-reason-text { + color: #4A5568; + font-size: 13px; + } + + .wd-de-reason-icon { + margin-bottom: 7px; + } + + ul.wd-de-reasons li.wd-de-reason-selected label { + background-color: #3B86FF; + border-color: #3B86FF; + } + + li.wd-de-reason-selected .wd-de-reason-icon svg, + li.wd-de-reason-selected .wd-de-reason-icon svg g { + fill: #fff; + } + + li.wd-de-reason-selected .wd-de-reason-text { + color: #fff; + } + + ul.wd-de-reasons li.wd-de-reason-selected label:after { + content: ""; + } + + .wd-dr-modal-reason-input { + margin-bottom: 15px; + display: none; + } + + .wd-dr-modal-reason-input textarea { + background: #FAFAFA; + border: 1px solid #287EB8; + border-radius: 4px; + width: 100%; + height: 100px; + color: #524242; + font-size: 13px; + line-height: 1.4; + padding: 11px 15px; + resize: none; + } + + .wd-dr-modal-reason-input textarea:focus { + outline: 0 none; + box-shadow: 0 0 0; + } + + .wd-dr-button-secondary, + .wd-dr-button-secondary:hover { + border: 1px solid #EBEBEB; + border-radius: 3px; + font-size: 13px; + line-height: 1.5; + color: #718096; + padding: 5px 12px; + cursor: pointer; + background-color: transparent; + text-decoration: none; + } + + .wd-dr-submit-modal, + .wd-dr-submit-modal:hover { + border: 1px solid #3B86FF; + background-color: #3B86FF; + border-radius: 3px; + font-size: 13px; + line-height: 1.5; + color: #fff; + padding: 5px 12px; + cursor: pointer; + margin-left: 4px; + } + </style> + <?php + } } diff --git a/includes/modules/appsero/src/License.php b/includes/modules/appsero/src/License.php index b40a25d6ff..f5b9604e79 100644 --- a/includes/modules/appsero/src/License.php +++ b/includes/modules/appsero/src/License.php @@ -9,801 +9,801 @@ */ class License { - /** - * Directorist\Appsero\Client - * - * @var object - */ - protected $client; - - /** - * Arguments of create menu - * - * @var array - */ - protected $menu_args; - - /** - * `option_name` of `wp_options` table - * - * @var string - */ - protected $option_key; - - /** - * Error message of HTTP request - * - * @var string - */ - public $error; - - /** - * Success message on form submit - * - * @var string - */ - public $success; - - /** - * Corn schedule hook name - * - * @var string - */ - protected $schedule_hook; - - /** - * Set value for valid license - * - * @var bool - */ - private $is_valid_license = null; - - /** - * Initialize the class - * - * @param Client $client - */ - public function __construct( Client $client ) { - $this->client = $client; - - $this->option_key = 'appsero_' . md5( $this->client->slug ) . '_manage_license'; - - $this->schedule_hook = $this->client->slug . '_license_check_event'; - - // Creating WP Ajax Endpoint to refresh license remotely - add_action( 'wp_ajax_appsero_refresh_license_' . $this->client->hash, [ $this, 'refresh_license_api' ] ); - - // Run hook to check license status daily - add_action( $this->schedule_hook, [ $this, 'check_license_status' ] ); - - // Active/Deactive corn schedule - $this->run_schedule(); - } - - /** - * Set the license option key. - * - * If someone wants to override the default generated key. - * - * @param string $key - * - * @since 1.3.0 - * - * @return License - */ - public function set_option_key( $key ) { - $this->option_key = $key; - - return $this; - } - - /** - * Get the license key - * - * @since 1.3.0 - * - * @return string|null - */ - public function get_license() { - return get_option( $this->option_key, null ); - } - - /** - * Check license - * - * @return array - */ - public function check( $license_key ) { - $route = 'public/license/' . $this->client->hash . '/check'; - - return $this->send_request( $license_key, $route ); - } - - /** - * Active a license - * - * @return array - */ - public function activate( $license_key ) { - $route = 'public/license/' . $this->client->hash . '/activate'; - - return $this->send_request( $license_key, $route ); - } - - /** - * Deactivate a license - * - * @return array - */ - public function deactivate( $license_key ) { - $route = 'public/license/' . $this->client->hash . '/deactivate'; - - return $this->send_request( $license_key, $route ); - } - - /** - * Send common request - * - * @return array - */ - protected function send_request( $license_key, $route ) { - $params = [ - 'license_key' => $license_key, - 'url' => esc_url( home_url() ), - 'is_local' => $this->client->is_local_server(), - ]; - - $response = $this->client->send_request( $params, $route, true ); - - if ( is_wp_error( $response ) ) { - return [ - 'success' => false, - 'error' => $response->get_error_message(), - ]; - } - - $response = json_decode( wp_remote_retrieve_body( $response ), true ); - - if ( empty( $response ) || isset( $response['exception'] ) ) { - return [ - 'success' => false, - 'error' => $this->client->_trans( 'Unknown error occurred, Please try again.' ), - ]; - } - - if ( isset( $response['errors'] ) && isset( $response['errors']['license_key'] ) ) { - $response = [ - 'success' => false, - 'error' => $response['errors']['license_key'][0], - ]; - } - - return $response; - } - - /** - * License Refresh Endpoint - */ - public function refresh_license_api() { - $this->check_license_status(); - - wp_send_json_success( - [ - 'message' => 'License refreshed successfully.', - ], - 200 - ); - } - - /** - * Add settings page for license - * - * @param array $args - * - * @return void - */ - public function add_settings_page( $args = [] ) { - $defaults = [ - 'type' => 'menu', // Can be: menu, options, submenu - 'page_title' => 'Manage License', - 'menu_title' => 'Manage License', - 'capability' => 'manage_options', - 'menu_slug' => $this->client->slug . '-manage-license', - 'icon_url' => '', - 'position' => null, - 'parent_slug' => '', - ]; - - $this->menu_args = wp_parse_args( $args, $defaults ); - - add_action( 'admin_menu', [ $this, 'admin_menu' ], 99 ); - } - - /** - * Admin Menu hook - * - * @return void - */ - public function admin_menu() { - switch ( $this->menu_args['type'] ) { - case 'menu': - $this->create_menu_page(); - break; - - case 'submenu': - $this->create_submenu_page(); - break; - - case 'options': - $this->create_options_page(); - break; - } - } - - /** - * License menu output - */ - public function menu_output() { - // process form data if submitted - if ( isset( $_POST['_nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_nonce'] ) ), $this->client->name ) ) { - $form_data = [ - '_nonce' => sanitize_key( wp_unslash( $_POST['_nonce'] ) ), - '_action' => isset( $_POST['_action'] ) ? sanitize_text_field( wp_unslash( $_POST['_action'] ) ) : '', - 'license_key' => isset( $_POST['license_key'] ) ? sanitize_text_field( wp_unslash( $_POST['license_key'] ) ) : '', - ]; - $this->license_form_submit( $form_data ); - } - - $license = $this->get_license(); - $action = ( $license && isset( $license['status'] ) && 'activate' === $license['status'] ) ? 'deactive' : 'active'; - $this->licenses_style(); - ?> - - <div class="wrap appsero-license-settings-wrapper"> - <h1>License Settings</h1> - - <?php - $this->show_license_page_notices(); - do_action( 'before_appsero_license_section' ); - ?> - - <div class="appsero-license-settings appsero-license-section"> - <?php $this->show_license_page_card_header( $license ); ?> - - <div class="appsero-license-details"> - <p> - <?php printf( $this->client->_trans( 'Activate <strong>%s</strong> by your license key to get professional support and automatic update from your WordPress dashboard.' ), $this->client->name ); ?> - </p> - <form method="post" novalidate="novalidate" spellcheck="false"> - <input type="hidden" name="_action" value="<?php echo $action; ?>"> - <input type="hidden" name="_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>"> - <div class="license-input-fields"> - <div class="license-input-key"> - <svg enable-background="new 0 0 512 512" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> - <path d="m463.75 48.251c-64.336-64.336-169.01-64.335-233.35 1e-3 -43.945 43.945-59.209 108.71-40.181 167.46l-185.82 185.82c-2.813 2.813-4.395 6.621-4.395 10.606v84.858c0 8.291 6.709 15 15 15h84.858c3.984 0 7.793-1.582 10.605-4.395l21.211-21.226c3.237-3.237 4.819-7.778 4.292-12.334l-2.637-22.793 31.582-2.974c7.178-0.674 12.847-6.343 13.521-13.521l2.974-31.582 22.793 2.651c4.233 0.571 8.496-0.85 11.704-3.691 3.193-2.856 5.024-6.929 5.024-11.206v-27.929h27.422c3.984 0 7.793-1.582 10.605-4.395l38.467-37.958c58.74 19.043 122.38 4.929 166.33-39.046 64.336-64.335 64.336-169.01 0-233.35zm-42.435 106.07c-17.549 17.549-46.084 17.549-63.633 0s-17.549-46.084 0-63.633 46.084-17.549 63.633 0 17.548 46.084 0 63.633z"/> - </svg> - <input type="text" value="<?php echo $this->get_input_license_value( $action, $license ); ?>" - placeholder="<?php echo esc_attr( $this->client->_trans( 'Enter your license key to activate' ) ); ?>" name="license_key" - <?php echo ( 'deactive' === $action ) ? 'readonly="readonly"' : ''; ?> - /> - </div> - <button type="submit" name="submit" class="<?php echo 'deactive' === $action ? 'deactive-button' : ''; ?>"> - <?php echo $action === 'active' ? $this->client->_trans( 'Activate License' ) : $this->client->_trans( 'Deactivate License' ); ?> - </button> - </div> - </form> - - <?php - if ( 'deactive' === $action && isset( $license['remaining'] ) ) { - $this->show_active_license_info( $license ); - } - ?> - </div> - </div> <!-- /.appsero-license-settings --> - - <?php do_action( 'after_appsero_license_section' ); ?> - </div> - <?php - } - - /** - * License form submit - */ - public function license_form_submit( $form_data = array() ) { - if ( ! isset( $form_data['_nonce'] ) ) { - return; - } - - if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $form_data['_nonce'] ) ), $this->client->name ) ) { - $this->error = $this->client->_trans( 'Nonce vefification failed.' ); - - return; - } - - if ( ! current_user_can( 'manage_options' ) ) { - $this->error = $this->client->_trans( 'You don\'t have permission to manage license.' ); - - return; - } - - $license_key = ! empty( $form_data['license_key'] ) ? sanitize_text_field( wp_unslash( $form_data['license_key'] ) ) : ''; - $action = ! empty( $form_data['_action'] ) ? sanitize_text_field( wp_unslash( $form_data['_action'] ) ) : ''; - - switch ( $action ) { - case 'active': - $this->active_client_license( $license_key ); - break; - - case 'deactive': - $this->deactive_client_license(); - break; - - case 'refresh': - $this->refresh_client_license(); - break; - } - } - - /** - * Check license status on schedule - */ - public function check_license_status() { - $license = $this->get_license(); - - if ( isset( $license['key'] ) && ! empty( $license['key'] ) ) { - $response = $this->check( $license['key'] ); - - if ( isset( $response['success'] ) && $response['success'] ) { - $license['status'] = 'activate'; - $license['remaining'] = $response['remaining']; - $license['activation_limit'] = $response['activation_limit']; - $license['expiry_days'] = $response['expiry_days']; - $license['title'] = $response['title']; - $license['source_id'] = $response['source_identifier']; - $license['recurring'] = $response['recurring']; - } else { - $license['status'] = 'deactivate'; - $license['expiry_days'] = 0; - } - - update_option( $this->option_key, $license, false ); - } - } - - /** - * Check this is a valid license - */ - public function is_valid() { - if ( null !== $this->is_valid_license ) { - return $this->is_valid_license; - } - - $license = $this->get_license(); - - if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) { - $this->is_valid_license = true; - } else { - $this->is_valid_license = false; - } - - return $this->is_valid_license; - } - - /** - * Check this is a valid license - */ - public function is_valid_by( $option, $value ) { - $license = $this->get_license(); - - if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) { - if ( isset( $license[ $option ] ) && $license[ $option ] === $value ) { - return true; - } - } - - return false; - } - - /** - * Styles for licenses page - */ - private function licenses_style() { - ?> - <style type="text/css"> - .appsero-license-section { - width: 100%; - max-width: 1100px; - min-height: 1px; - box-sizing: border-box; - } - .appsero-license-settings { - background-color: #fff; - box-shadow: 0px 3px 10px rgba(16, 16, 16, 0.05); - } - .appsero-license-settings * { - box-sizing: border-box; - } - .appsero-license-title { - background-color: #F8FAFB; - border-bottom: 2px solid #EAEAEA; - display: flex; - align-items: center; - padding: 10px 20px; - } - .appsero-license-title svg { - width: 30px; - height: 30px; - fill: #0082BF; - } - .appsero-license-title span { - font-size: 17px; - color: #444444; - margin-left: 10px; - } - .appsero-license-details { - padding: 20px; - } - .appsero-license-details p { - font-size: 15px; - margin: 0 0 20px 0; - } - .license-input-key { - position: relative; - flex: 0 0 72%; - max-width: 72%; - } - .license-input-key input { - background-color: #F9F9F9; - padding: 10px 15px 10px 48px; - border: 1px solid #E8E5E5; - border-radius: 3px; - height: 45px; - font-size: 16px; - color: #71777D; - width: 100%; - box-shadow: 0 0 0 transparent; - } - .license-input-key input:focus { - outline: 0 none; - border: 1px solid #E8E5E5; - box-shadow: 0 0 0 transparent; - } - .license-input-key svg { - width: 22px; - height: 22px; - fill: #0082BF; - position: absolute; - left: 14px; - top: 13px; - } - .license-input-fields { - display: flex; - justify-content: space-between; - margin-bottom: 30px; - max-width: 850px; - width: 100%; - } - .license-input-fields button { - color: #fff; - font-size: 17px; - padding: 8px; - height: 46px; - background-color: #0082BF; - border-radius: 3px; - cursor: pointer; - flex: 0 0 25%; - max-width: 25%; - border: 1px solid #0082BF; - } - .license-input-fields button.deactive-button { - background-color: #E40055; - border-color: #E40055; - } - .license-input-fields button:focus { - outline: 0 none; - } - .active-license-info { - display: flex; - } - .single-license-info { - min-width: 220px; - flex: 0 0 30%; - } - .single-license-info h3 { - font-size: 18px; - margin: 0 0 12px 0; - } - .single-license-info p { - margin: 0; - color: #00C000; - } - .single-license-info p.occupied { - color: #E40055; - } - .appsero-license-right-form { - margin-left: auto; - } - .appsero-license-refresh-button { - padding: 6px 10px 4px 10px; - border: 1px solid #0082BF; - border-radius: 3px; - margin-left: auto; - background-color: #0082BF; - color: #fff; - cursor: pointer; - } - .appsero-license-refresh-button .dashicons { - color: #fff; - margin-left: 0; - } - </style> - <?php - } - - /** - * Show active license information - */ - private function show_active_license_info( $license ) { - ?> - <div class="active-license-info"> - <div class="single-license-info"> - <h3><?php $this->client->_etrans( 'Activations Remaining' ); ?></h3> - <?php if ( empty( $license['activation_limit'] ) ) { ?> - <p><?php $this->client->_etrans( 'Unlimited' ); ?></p> - <?php } else { ?> - <p class="<?php echo $license['remaining'] ? '' : 'occupied'; ?>"> - <?php printf( $this->client->_trans( '%1$d out of %2$d' ), $license['remaining'], $license['activation_limit'] ); ?> - </p> - <?php } ?> - </div> - <div class="single-license-info"> - <h3><?php $this->client->_etrans( 'Expires in' ); ?></h3> - <?php - if ( false !== $license['expiry_days'] ) { - $occupied = $license['expiry_days'] > 21 ? '' : 'occupied'; - echo '<p class="' . $occupied . '">' . $license['expiry_days'] . ' days</p>'; - } else { - echo '<p>' . $this->client->_trans( 'Never' ) . '</p>'; - } - ?> - </div> - </div> - <?php - } - - /** - * Show license settings page notices - */ - private function show_license_page_notices() { - if ( ! empty( $this->error ) ) { - ?> - <div class="notice notice-error is-dismissible appsero-license-section"> - <p><?php echo $this->error; ?></p> - </div> + /** + * Directorist\Appsero\Client + * + * @var object + */ + protected $client; + + /** + * Arguments of create menu + * + * @var array + */ + protected $menu_args; + + /** + * `option_name` of `wp_options` table + * + * @var string + */ + protected $option_key; + + /** + * Error message of HTTP request + * + * @var string + */ + public $error; + + /** + * Success message on form submit + * + * @var string + */ + public $success; + + /** + * Corn schedule hook name + * + * @var string + */ + protected $schedule_hook; + + /** + * Set value for valid license + * + * @var bool + */ + private $is_valid_license = null; + + /** + * Initialize the class + * + * @param Client $client + */ + public function __construct( Client $client ) { + $this->client = $client; + + $this->option_key = 'appsero_' . md5( $this->client->slug ) . '_manage_license'; + + $this->schedule_hook = $this->client->slug . '_license_check_event'; + + // Creating WP Ajax Endpoint to refresh license remotely + add_action( 'wp_ajax_appsero_refresh_license_' . $this->client->hash, array( $this, 'refresh_license_api' ) ); + + // Run hook to check license status daily + add_action( $this->schedule_hook, array( $this, 'check_license_status' ) ); + + // Active/Deactive corn schedule + $this->run_schedule(); + } + + /** + * Set the license option key. + * + * If someone wants to override the default generated key. + * + * @param string $key + * + * @since 1.3.0 + * + * @return License + */ + public function set_option_key( $key ) { + $this->option_key = $key; + + return $this; + } + + /** + * Get the license key + * + * @since 1.3.0 + * + * @return string|null + */ + public function get_license() { + return get_option( $this->option_key, null ); + } + + /** + * Check license + * + * @return array + */ + public function check( $license_key ) { + $route = 'public/license/' . $this->client->hash . '/check'; + + return $this->send_request( $license_key, $route ); + } + + /** + * Active a license + * + * @return array + */ + public function activate( $license_key ) { + $route = 'public/license/' . $this->client->hash . '/activate'; + + return $this->send_request( $license_key, $route ); + } + + /** + * Deactivate a license + * + * @return array + */ + public function deactivate( $license_key ) { + $route = 'public/license/' . $this->client->hash . '/deactivate'; + + return $this->send_request( $license_key, $route ); + } + + /** + * Send common request + * + * @return array + */ + protected function send_request( $license_key, $route ) { + $params = array( + 'license_key' => $license_key, + 'url' => esc_url( home_url() ), + 'is_local' => $this->client->is_local_server(), + ); + + $response = $this->client->send_request( $params, $route, true ); + + if ( is_wp_error( $response ) ) { + return array( + 'success' => false, + 'error' => $response->get_error_message(), + ); + } + + $response = json_decode( wp_remote_retrieve_body( $response ), true ); + + if ( empty( $response ) || isset( $response['exception'] ) ) { + return array( + 'success' => false, + 'error' => $this->client->_trans( 'Unknown error occurred, Please try again.' ), + ); + } + + if ( isset( $response['errors'] ) && isset( $response['errors']['license_key'] ) ) { + $response = array( + 'success' => false, + 'error' => $response['errors']['license_key'][0], + ); + } + + return $response; + } + + /** + * License Refresh Endpoint + */ + public function refresh_license_api() { + $this->check_license_status(); + + wp_send_json_success( + array( + 'message' => 'License refreshed successfully.', + ), + 200 + ); + } + + /** + * Add settings page for license + * + * @param array $args + * + * @return void + */ + public function add_settings_page( $args = array() ) { + $defaults = array( + 'type' => 'menu', // Can be: menu, options, submenu + 'page_title' => 'Manage License', + 'menu_title' => 'Manage License', + 'capability' => 'manage_options', + 'menu_slug' => $this->client->slug . '-manage-license', + 'icon_url' => '', + 'position' => null, + 'parent_slug' => '', + ); + + $this->menu_args = wp_parse_args( $args, $defaults ); + + add_action( 'admin_menu', array( $this, 'admin_menu' ), 99 ); + } + + /** + * Admin Menu hook + * + * @return void + */ + public function admin_menu() { + switch ( $this->menu_args['type'] ) { + case 'menu': + $this->create_menu_page(); + break; + + case 'submenu': + $this->create_submenu_page(); + break; + + case 'options': + $this->create_options_page(); + break; + } + } + + /** + * License menu output + */ + public function menu_output() { + // process form data if submitted + if ( isset( $_POST['_nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['_nonce'] ) ), $this->client->name ) ) { + $form_data = array( + '_nonce' => sanitize_key( wp_unslash( $_POST['_nonce'] ) ), + '_action' => isset( $_POST['_action'] ) ? sanitize_text_field( wp_unslash( $_POST['_action'] ) ) : '', + 'license_key' => isset( $_POST['license_key'] ) ? sanitize_text_field( wp_unslash( $_POST['license_key'] ) ) : '', + ); + $this->license_form_submit( $form_data ); + } + + $license = $this->get_license(); + $action = ( $license && isset( $license['status'] ) && 'activate' === $license['status'] ) ? 'deactive' : 'active'; + $this->licenses_style(); + ?> + + <div class="wrap appsero-license-settings-wrapper"> + <h1>License Settings</h1> + + <?php + $this->show_license_page_notices(); + do_action( 'before_appsero_license_section' ); + ?> + + <div class="appsero-license-settings appsero-license-section"> + <?php $this->show_license_page_card_header( $license ); ?> + + <div class="appsero-license-details"> + <p> + <?php printf( $this->client->_trans( 'Activate <strong>%s</strong> by your license key to get professional support and automatic update from your WordPress dashboard.' ), $this->client->name ); ?> + </p> + <form method="post" novalidate="novalidate" spellcheck="false"> + <input type="hidden" name="_action" value="<?php echo $action; ?>"> + <input type="hidden" name="_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>"> + <div class="license-input-fields"> + <div class="license-input-key"> + <svg enable-background="new 0 0 512 512" version="1.1" viewBox="0 0 512 512" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> + <path d="m463.75 48.251c-64.336-64.336-169.01-64.335-233.35 1e-3 -43.945 43.945-59.209 108.71-40.181 167.46l-185.82 185.82c-2.813 2.813-4.395 6.621-4.395 10.606v84.858c0 8.291 6.709 15 15 15h84.858c3.984 0 7.793-1.582 10.605-4.395l21.211-21.226c3.237-3.237 4.819-7.778 4.292-12.334l-2.637-22.793 31.582-2.974c7.178-0.674 12.847-6.343 13.521-13.521l2.974-31.582 22.793 2.651c4.233 0.571 8.496-0.85 11.704-3.691 3.193-2.856 5.024-6.929 5.024-11.206v-27.929h27.422c3.984 0 7.793-1.582 10.605-4.395l38.467-37.958c58.74 19.043 122.38 4.929 166.33-39.046 64.336-64.335 64.336-169.01 0-233.35zm-42.435 106.07c-17.549 17.549-46.084 17.549-63.633 0s-17.549-46.084 0-63.633 46.084-17.549 63.633 0 17.548 46.084 0 63.633z"/> + </svg> + <input type="text" value="<?php echo $this->get_input_license_value( $action, $license ); ?>" + placeholder="<?php echo esc_attr( $this->client->_trans( 'Enter your license key to activate' ) ); ?>" name="license_key" + <?php echo ( 'deactive' === $action ) ? 'readonly="readonly"' : ''; ?> + /> + </div> + <button type="submit" name="submit" class="<?php echo 'deactive' === $action ? 'deactive-button' : ''; ?>"> + <?php echo $action === 'active' ? $this->client->_trans( 'Activate License' ) : $this->client->_trans( 'Deactivate License' ); ?> + </button> + </div> + </form> + + <?php + if ( 'deactive' === $action && isset( $license['remaining'] ) ) { + $this->show_active_license_info( $license ); + } + ?> + </div> + </div> <!-- /.appsero-license-settings --> + + <?php do_action( 'after_appsero_license_section' ); ?> + </div> + <?php + } + + /** + * License form submit + */ + public function license_form_submit( $form_data = array() ) { + if ( ! isset( $form_data['_nonce'] ) ) { + return; + } + + if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $form_data['_nonce'] ) ), $this->client->name ) ) { + $this->error = $this->client->_trans( 'Nonce vefification failed.' ); + + return; + } + + if ( ! current_user_can( 'manage_options' ) ) { + $this->error = $this->client->_trans( 'You don\'t have permission to manage license.' ); + + return; + } + + $license_key = ! empty( $form_data['license_key'] ) ? sanitize_text_field( wp_unslash( $form_data['license_key'] ) ) : ''; + $action = ! empty( $form_data['_action'] ) ? sanitize_text_field( wp_unslash( $form_data['_action'] ) ) : ''; + + switch ( $action ) { + case 'active': + $this->active_client_license( $license_key ); + break; + + case 'deactive': + $this->deactive_client_license(); + break; + + case 'refresh': + $this->refresh_client_license(); + break; + } + } + + /** + * Check license status on schedule + */ + public function check_license_status() { + $license = $this->get_license(); + + if ( isset( $license['key'] ) && ! empty( $license['key'] ) ) { + $response = $this->check( $license['key'] ); + + if ( isset( $response['success'] ) && $response['success'] ) { + $license['status'] = 'activate'; + $license['remaining'] = $response['remaining']; + $license['activation_limit'] = $response['activation_limit']; + $license['expiry_days'] = $response['expiry_days']; + $license['title'] = $response['title']; + $license['source_id'] = $response['source_identifier']; + $license['recurring'] = $response['recurring']; + } else { + $license['status'] = 'deactivate'; + $license['expiry_days'] = 0; + } + + update_option( $this->option_key, $license, false ); + } + } + + /** + * Check this is a valid license + */ + public function is_valid() { + if ( null !== $this->is_valid_license ) { + return $this->is_valid_license; + } + + $license = $this->get_license(); + + if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) { + $this->is_valid_license = true; + } else { + $this->is_valid_license = false; + } + + return $this->is_valid_license; + } + + /** + * Check this is a valid license + */ + public function is_valid_by( $option, $value ) { + $license = $this->get_license(); + + if ( ! empty( $license['key'] ) && isset( $license['status'] ) && $license['status'] === 'activate' ) { + if ( isset( $license[ $option ] ) && $license[ $option ] === $value ) { + return true; + } + } + + return false; + } + + /** + * Styles for licenses page + */ + private function licenses_style() { + ?> + <style type="text/css"> + .appsero-license-section { + width: 100%; + max-width: 1100px; + min-height: 1px; + box-sizing: border-box; + } + .appsero-license-settings { + background-color: #fff; + box-shadow: 0px 3px 10px rgba(16, 16, 16, 0.05); + } + .appsero-license-settings * { + box-sizing: border-box; + } + .appsero-license-title { + background-color: #F8FAFB; + border-bottom: 2px solid #EAEAEA; + display: flex; + align-items: center; + padding: 10px 20px; + } + .appsero-license-title svg { + width: 30px; + height: 30px; + fill: #0082BF; + } + .appsero-license-title span { + font-size: 17px; + color: #444444; + margin-left: 10px; + } + .appsero-license-details { + padding: 20px; + } + .appsero-license-details p { + font-size: 15px; + margin: 0 0 20px 0; + } + .license-input-key { + position: relative; + flex: 0 0 72%; + max-width: 72%; + } + .license-input-key input { + background-color: #F9F9F9; + padding: 10px 15px 10px 48px; + border: 1px solid #E8E5E5; + border-radius: 3px; + height: 45px; + font-size: 16px; + color: #71777D; + width: 100%; + box-shadow: 0 0 0 transparent; + } + .license-input-key input:focus { + outline: 0 none; + border: 1px solid #E8E5E5; + box-shadow: 0 0 0 transparent; + } + .license-input-key svg { + width: 22px; + height: 22px; + fill: #0082BF; + position: absolute; + left: 14px; + top: 13px; + } + .license-input-fields { + display: flex; + justify-content: space-between; + margin-bottom: 30px; + max-width: 850px; + width: 100%; + } + .license-input-fields button { + color: #fff; + font-size: 17px; + padding: 8px; + height: 46px; + background-color: #0082BF; + border-radius: 3px; + cursor: pointer; + flex: 0 0 25%; + max-width: 25%; + border: 1px solid #0082BF; + } + .license-input-fields button.deactive-button { + background-color: #E40055; + border-color: #E40055; + } + .license-input-fields button:focus { + outline: 0 none; + } + .active-license-info { + display: flex; + } + .single-license-info { + min-width: 220px; + flex: 0 0 30%; + } + .single-license-info h3 { + font-size: 18px; + margin: 0 0 12px 0; + } + .single-license-info p { + margin: 0; + color: #00C000; + } + .single-license-info p.occupied { + color: #E40055; + } + .appsero-license-right-form { + margin-left: auto; + } + .appsero-license-refresh-button { + padding: 6px 10px 4px 10px; + border: 1px solid #0082BF; + border-radius: 3px; + margin-left: auto; + background-color: #0082BF; + color: #fff; + cursor: pointer; + } + .appsero-license-refresh-button .dashicons { + color: #fff; + margin-left: 0; + } + </style> + <?php + } + + /** + * Show active license information + */ + private function show_active_license_info( $license ) { + ?> + <div class="active-license-info"> + <div class="single-license-info"> + <h3><?php $this->client->_etrans( 'Activations Remaining' ); ?></h3> + <?php if ( empty( $license['activation_limit'] ) ) { ?> + <p><?php $this->client->_etrans( 'Unlimited' ); ?></p> + <?php } else { ?> + <p class="<?php echo $license['remaining'] ? '' : 'occupied'; ?>"> + <?php printf( $this->client->_trans( '%1$d out of %2$d' ), $license['remaining'], $license['activation_limit'] ); ?> + </p> + <?php } ?> + </div> + <div class="single-license-info"> + <h3><?php $this->client->_etrans( 'Expires in' ); ?></h3> + <?php + if ( false !== $license['expiry_days'] ) { + $occupied = $license['expiry_days'] > 21 ? '' : 'occupied'; + echo '<p class="' . $occupied . '">' . $license['expiry_days'] . ' days</p>'; + } else { + echo '<p>' . $this->client->_trans( 'Never' ) . '</p>'; + } + ?> + </div> + </div> + <?php + } + + /** + * Show license settings page notices + */ + private function show_license_page_notices() { + if ( ! empty( $this->error ) ) { + ?> + <div class="notice notice-error is-dismissible appsero-license-section"> + <p><?php echo $this->error; ?></p> + </div> <?php - } + } - if ( ! empty( $this->success ) ) { - ?> - <div class="notice notice-success is-dismissible appsero-license-section"> - <p><?php echo $this->success; ?></p> - </div> + if ( ! empty( $this->success ) ) { + ?> + <div class="notice notice-success is-dismissible appsero-license-section"> + <p><?php echo $this->success; ?></p> + </div> <?php - } - echo '<br />'; - } - - /** - * Card header - */ - private function show_license_page_card_header( $license ) { - ?> - <div class="appsero-license-title"> - <svg enable-background="new 0 0 299.995 299.995" version="1.1" viewBox="0 0 300 300" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> - <path d="m150 161.48c-8.613 0-15.598 6.982-15.598 15.598 0 5.776 3.149 10.807 7.817 13.505v17.341h15.562v-17.341c4.668-2.697 7.817-7.729 7.817-13.505 0-8.616-6.984-15.598-15.598-15.598z"/> - <path d="m150 85.849c-13.111 0-23.775 10.665-23.775 23.775v25.319h47.548v-25.319c-1e-3 -13.108-10.665-23.775-23.773-23.775z"/> - <path d="m150 1e-3c-82.839 0-150 67.158-150 150 0 82.837 67.156 150 150 150s150-67.161 150-150c0-82.839-67.161-150-150-150zm46.09 227.12h-92.173c-9.734 0-17.626-7.892-17.626-17.629v-56.919c0-8.491 6.007-15.582 14.003-17.25v-25.697c0-27.409 22.3-49.711 49.711-49.711 27.409 0 49.709 22.3 49.709 49.711v25.697c7.993 1.673 14 8.759 14 17.25v56.919h2e-3c0 9.736-7.892 17.629-17.626 17.629z"/> - </svg> - <span><?php echo $this->client->_trans( 'Activate License' ); ?></span> - - <?php if ( $license && $license['key'] ) { ?> - <form method="post" class="appsero-license-right-form" novalidate="novalidate" spellcheck="false"> - <input type="hidden" name="_action" value="refresh"> - <input type="hidden" name="_appsero_license_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>"> - <button type="submit" name="submit" class="appsero-license-refresh-button"> - <span class="dashicons dashicons-update"></span> - <?php echo $this->client->_trans( 'Refresh License' ); ?> - </button> - </form> - <?php } ?> - - </div> - <?php - } - - /** - * Active client license - */ - private function active_client_license( $license_key ) { - if ( empty( $license_key ) ) { - $this->error = $this->client->_trans( 'The license key field is required.' ); - - return; - } - - $response = $this->activate( $license_key ); - - if ( ! $response['success'] ) { - $this->error = $response['error'] ? $response['error'] : $this->client->_trans( 'Unknown error occurred.' ); - - return; - } - - $data = [ - 'key' => $license_key, - 'status' => 'activate', - 'remaining' => $response['remaining'], - 'activation_limit' => $response['activation_limit'], - 'expiry_days' => $response['expiry_days'], - 'title' => $response['title'], - 'source_id' => $response['source_identifier'], - 'recurring' => $response['recurring'], - ]; - - update_option( $this->option_key, $data, false ); - - $this->success = $this->client->_trans( 'License activated successfully.' ); - } - - /** - * Deactive client license - */ - private function deactive_client_license() { - $license = $this->get_license(); - - if ( empty( $license['key'] ) ) { - $this->error = $this->client->_trans( 'License key not found.' ); - - return; - } - - $response = $this->deactivate( $license['key'] ); - - $data = [ - 'key' => '', - 'status' => 'deactivate', - ]; - - update_option( $this->option_key, $data, false ); - - if ( ! $response['success'] ) { - $this->error = $response['error'] ? $response['error'] : $this->client->_trans( 'Unknown error occurred.' ); - - return; - } - - $this->success = $this->client->_trans( 'License deactivated successfully.' ); - } - - /** - * Refresh Client License - */ - private function refresh_client_license() { - $license = $this->get_license(); - - if ( ! $license || ! isset( $license['key'] ) || empty( $license['key'] ) ) { - $this->error = $this->client->_trans( 'License key not found' ); - - return; - } - - $this->check_license_status(); - - $this->success = $this->client->_trans( 'License refreshed successfully.' ); - } - - /** - * Add license menu page - */ - private function create_menu_page() { - call_user_func( - 'add_menu_page', - $this->menu_args['page_title'], - $this->menu_args['menu_title'], - $this->menu_args['capability'], - $this->menu_args['menu_slug'], - [ $this, 'menu_output' ], - $this->menu_args['icon_url'], - $this->menu_args['position'] - ); - } - - /** - * Add submenu page - */ - private function create_submenu_page() { - call_user_func( - 'add_submenu_page', - $this->menu_args['parent_slug'], - $this->menu_args['page_title'], - $this->menu_args['menu_title'], - $this->menu_args['capability'], - $this->menu_args['menu_slug'], - [ $this, 'menu_output' ], - $this->menu_args['position'] - ); - } - - /** - * Add submenu page - */ - private function create_options_page() { - call_user_func( - 'add_options_page', - $this->menu_args['page_title'], - $this->menu_args['menu_title'], - $this->menu_args['capability'], - $this->menu_args['menu_slug'], - [ $this, 'menu_output' ], - $this->menu_args['position'] - ); - } - - /** - * Schedule daily sicense checker event - */ - public function schedule_cron_event() { - if ( ! wp_next_scheduled( $this->schedule_hook ) ) { - wp_schedule_event( time(), 'daily', $this->schedule_hook ); - - wp_schedule_single_event( time() + 20, $this->schedule_hook ); - } - } - - /** - * Clear any scheduled hook - */ - public function clear_scheduler() { - wp_clear_scheduled_hook( $this->schedule_hook ); - } - - /** - * Enable/Disable schedule - */ - private function run_schedule() { - switch ( $this->client->type ) { - case 'plugin': - register_activation_hook( $this->client->file, [ $this, 'schedule_cron_event' ] ); - register_deactivation_hook( $this->client->file, [ $this, 'clear_scheduler' ] ); - break; - - case 'theme': - add_action( 'after_switch_theme', [ $this, 'schedule_cron_event' ] ); - add_action( 'switch_theme', [ $this, 'clear_scheduler' ] ); - break; - } - } - - /** - * Get input license key - * - * @return $license - */ - private function get_input_license_value( $action, $license ) { - if ( 'active' === $action ) { - return isset( $license['key'] ) ? $license['key'] : ''; - } - - if ( 'deactive' === $action ) { - $key_length = strlen( $license['key'] ); - - return str_pad( - substr( $license['key'], 0, $key_length / 2 ), - $key_length, - '*' - ); - } - - return ''; - } + } + echo '<br />'; + } + + /** + * Card header + */ + private function show_license_page_card_header( $license ) { + ?> + <div class="appsero-license-title"> + <svg enable-background="new 0 0 299.995 299.995" version="1.1" viewBox="0 0 300 300" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"> + <path d="m150 161.48c-8.613 0-15.598 6.982-15.598 15.598 0 5.776 3.149 10.807 7.817 13.505v17.341h15.562v-17.341c4.668-2.697 7.817-7.729 7.817-13.505 0-8.616-6.984-15.598-15.598-15.598z"/> + <path d="m150 85.849c-13.111 0-23.775 10.665-23.775 23.775v25.319h47.548v-25.319c-1e-3 -13.108-10.665-23.775-23.773-23.775z"/> + <path d="m150 1e-3c-82.839 0-150 67.158-150 150 0 82.837 67.156 150 150 150s150-67.161 150-150c0-82.839-67.161-150-150-150zm46.09 227.12h-92.173c-9.734 0-17.626-7.892-17.626-17.629v-56.919c0-8.491 6.007-15.582 14.003-17.25v-25.697c0-27.409 22.3-49.711 49.711-49.711 27.409 0 49.709 22.3 49.709 49.711v25.697c7.993 1.673 14 8.759 14 17.25v56.919h2e-3c0 9.736-7.892 17.629-17.626 17.629z"/> + </svg> + <span><?php echo $this->client->_trans( 'Activate License' ); ?></span> + + <?php if ( $license && $license['key'] ) { ?> + <form method="post" class="appsero-license-right-form" novalidate="novalidate" spellcheck="false"> + <input type="hidden" name="_action" value="refresh"> + <input type="hidden" name="_appsero_license_nonce" value="<?php echo wp_create_nonce( $this->client->name ); ?>"> + <button type="submit" name="submit" class="appsero-license-refresh-button"> + <span class="dashicons dashicons-update"></span> + <?php echo $this->client->_trans( 'Refresh License' ); ?> + </button> + </form> + <?php } ?> + + </div> + <?php + } + + /** + * Active client license + */ + private function active_client_license( $license_key ) { + if ( empty( $license_key ) ) { + $this->error = $this->client->_trans( 'The license key field is required.' ); + + return; + } + + $response = $this->activate( $license_key ); + + if ( ! $response['success'] ) { + $this->error = $response['error'] ? $response['error'] : $this->client->_trans( 'Unknown error occurred.' ); + + return; + } + + $data = array( + 'key' => $license_key, + 'status' => 'activate', + 'remaining' => $response['remaining'], + 'activation_limit' => $response['activation_limit'], + 'expiry_days' => $response['expiry_days'], + 'title' => $response['title'], + 'source_id' => $response['source_identifier'], + 'recurring' => $response['recurring'], + ); + + update_option( $this->option_key, $data, false ); + + $this->success = $this->client->_trans( 'License activated successfully.' ); + } + + /** + * Deactive client license + */ + private function deactive_client_license() { + $license = $this->get_license(); + + if ( empty( $license['key'] ) ) { + $this->error = $this->client->_trans( 'License key not found.' ); + + return; + } + + $response = $this->deactivate( $license['key'] ); + + $data = array( + 'key' => '', + 'status' => 'deactivate', + ); + + update_option( $this->option_key, $data, false ); + + if ( ! $response['success'] ) { + $this->error = $response['error'] ? $response['error'] : $this->client->_trans( 'Unknown error occurred.' ); + + return; + } + + $this->success = $this->client->_trans( 'License deactivated successfully.' ); + } + + /** + * Refresh Client License + */ + private function refresh_client_license() { + $license = $this->get_license(); + + if ( ! $license || ! isset( $license['key'] ) || empty( $license['key'] ) ) { + $this->error = $this->client->_trans( 'License key not found' ); + + return; + } + + $this->check_license_status(); + + $this->success = $this->client->_trans( 'License refreshed successfully.' ); + } + + /** + * Add license menu page + */ + private function create_menu_page() { + call_user_func( + 'add_menu_page', + $this->menu_args['page_title'], + $this->menu_args['menu_title'], + $this->menu_args['capability'], + $this->menu_args['menu_slug'], + array( $this, 'menu_output' ), + $this->menu_args['icon_url'], + $this->menu_args['position'] + ); + } + + /** + * Add submenu page + */ + private function create_submenu_page() { + call_user_func( + 'add_submenu_page', + $this->menu_args['parent_slug'], + $this->menu_args['page_title'], + $this->menu_args['menu_title'], + $this->menu_args['capability'], + $this->menu_args['menu_slug'], + array( $this, 'menu_output' ), + $this->menu_args['position'] + ); + } + + /** + * Add submenu page + */ + private function create_options_page() { + call_user_func( + 'add_options_page', + $this->menu_args['page_title'], + $this->menu_args['menu_title'], + $this->menu_args['capability'], + $this->menu_args['menu_slug'], + array( $this, 'menu_output' ), + $this->menu_args['position'] + ); + } + + /** + * Schedule daily sicense checker event + */ + public function schedule_cron_event() { + if ( ! wp_next_scheduled( $this->schedule_hook ) ) { + wp_schedule_event( time(), 'daily', $this->schedule_hook ); + + wp_schedule_single_event( time() + 20, $this->schedule_hook ); + } + } + + /** + * Clear any scheduled hook + */ + public function clear_scheduler() { + wp_clear_scheduled_hook( $this->schedule_hook ); + } + + /** + * Enable/Disable schedule + */ + private function run_schedule() { + switch ( $this->client->type ) { + case 'plugin': + register_activation_hook( $this->client->file, array( $this, 'schedule_cron_event' ) ); + register_deactivation_hook( $this->client->file, array( $this, 'clear_scheduler' ) ); + break; + + case 'theme': + add_action( 'after_switch_theme', array( $this, 'schedule_cron_event' ) ); + add_action( 'switch_theme', array( $this, 'clear_scheduler' ) ); + break; + } + } + + /** + * Get input license key + * + * @return $license + */ + private function get_input_license_value( $action, $license ) { + if ( 'active' === $action ) { + return isset( $license['key'] ) ? $license['key'] : ''; + } + + if ( 'deactive' === $action ) { + $key_length = strlen( $license['key'] ); + + return str_pad( + substr( $license['key'], 0, $key_length / 2 ), + $key_length, + '*' + ); + } + + return ''; + } } diff --git a/includes/modules/appsero/src/Updater.php b/includes/modules/appsero/src/Updater.php index d7b7c3e530..a9aec3af67 100644 --- a/includes/modules/appsero/src/Updater.php +++ b/includes/modules/appsero/src/Updater.php @@ -11,252 +11,252 @@ */ class Updater { - /** - * Directorist\Appsero\Client - * - * @var object - */ - protected $client; - - /** - * Cache key - * - * @var string - */ - protected $cache_key; - - /** - * Initialize the class - * - * @param Directorist\Appsero\Client - */ - public function __construct( Client $client ) { - $this->client = $client; - $this->cache_key = 'appsero_' . md5( $this->client->slug ) . '_version_info'; - - // Run hooks. - if ( $this->client->type === 'plugin' ) { - $this->run_plugin_hooks(); - } elseif ( $this->client->type === 'theme' ) { - $this->run_theme_hooks(); - } - } - - /** - * Set up WordPress filter to hooks to get update. - * - * @return void - */ - public function run_plugin_hooks() { - add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_plugin_update' ] ); - add_filter( 'plugins_api', [ $this, 'plugins_api_filter' ], 10, 3 ); - } - - /** - * Set up WordPress filter to hooks to get update. - * - * @return void - */ - public function run_theme_hooks() { - add_filter( 'pre_set_site_transient_update_themes', [ $this, 'check_theme_update' ] ); - } - - /** - * Check for Update for this specific project - */ - public function check_plugin_update( $transient_data ) { - global $pagenow; - - if ( ! is_object( $transient_data ) ) { - $transient_data = new stdClass(); - } - - if ( 'plugins.php' === $pagenow && is_multisite() ) { - return $transient_data; - } - - if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->basename ] ) ) { - return $transient_data; - } - - $version_info = $this->get_version_info(); - - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { - unset( $version_info->sections ); - - // If new version available then set to `response` - if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) { - $transient_data->response[ $this->client->basename ] = $version_info; - } else { - // If new version is not available then set to `no_update` - $transient_data->no_update[ $this->client->basename ] = $version_info; - } - - $transient_data->last_checked = time(); - $transient_data->checked[ $this->client->basename ] = $this->client->project_version; - } - - return $transient_data; - } - - /** - * Get version info from database - * - * @return object or Boolean - */ - private function get_cached_version_info() { - global $pagenow; - - // If updater page then fetch from API now - if ( 'update-core.php' === $pagenow ) { - return false; // Force to fetch data - } - - $value = get_transient( $this->cache_key ); - - if ( ! $value && ! isset( $value->name ) ) { - return false; // Cache is expired - } - - // We need to turn the icons into an array - if ( isset( $value->icons ) ) { - $value->icons = (array) $value->icons; - } - - // We need to turn the banners into an array - if ( isset( $value->banners ) ) { - $value->banners = (array) $value->banners; - } - - if ( isset( $value->sections ) ) { - $value->sections = (array) $value->sections; - } - - return $value; - } - - /** - * Set version info to database - */ - private function set_cached_version_info( $value ) { - if ( ! $value ) { - return; - } - - set_transient( $this->cache_key, $value, 3 * HOUR_IN_SECONDS ); - } - - /** - * Get plugin info from Appsero - */ - private function get_project_latest_version() { - $license = $this->client->license()->get_license(); - - $params = [ - 'version' => $this->client->project_version, - 'name' => $this->client->name, - 'slug' => $this->client->slug, - 'basename' => $this->client->basename, - 'license_key' => ! empty( $license ) && isset( $license['key'] ) ? $license['key'] : '', - ]; - - $route = 'update/' . $this->client->hash . '/check'; - - $response = $this->client->send_request( $params, $route, true ); - - if ( is_wp_error( $response ) ) { - return false; - } - - $response = json_decode( wp_remote_retrieve_body( $response ) ); - - if ( ! isset( $response->slug ) ) { - return false; - } - - if ( isset( $response->icons ) ) { - $response->icons = (array) $response->icons; - } - - if ( isset( $response->banners ) ) { - $response->banners = (array) $response->banners; - } - - if ( isset( $response->sections ) ) { - $response->sections = (array) $response->sections; - } - - return $response; - } - - /** - * Updates information on the "View version x.x details" page with custom data. - * - * @param mixed $data - * @param string $action - * @param object $args - * - * @return object $data - */ - public function plugins_api_filter( $data, $action = '', $args = null ) { - if ( $action !== 'plugin_information' ) { - return $data; - } - - if ( ! isset( $args->slug ) || ( $args->slug !== $this->client->slug ) ) { - return $data; - } - - return $this->get_version_info(); - } - - /** - * Check theme upate - */ - public function check_theme_update( $transient_data ) { - global $pagenow; - - if ( ! is_object( $transient_data ) ) { - $transient_data = new stdClass(); - } - - if ( 'themes.php' === $pagenow && is_multisite() ) { - return $transient_data; - } - - if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->slug ] ) ) { - return $transient_data; - } - - $version_info = $this->get_version_info(); - - if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { - // If new version available then set to `response` - if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) { - $transient_data->response[ $this->client->slug ] = (array) $version_info; - } else { - // If new version is not available then set to `no_update` - $transient_data->no_update[ $this->client->slug ] = (array) $version_info; - } - - $transient_data->last_checked = time(); - $transient_data->checked[ $this->client->slug ] = $this->client->project_version; - } - - return $transient_data; - } - - /** - * Get version information - */ - private function get_version_info() { - $version_info = $this->get_cached_version_info(); - - if ( false === $version_info ) { - $version_info = $this->get_project_latest_version(); - $this->set_cached_version_info( $version_info ); - } - - return $version_info; - } + /** + * Directorist\Appsero\Client + * + * @var object + */ + protected $client; + + /** + * Cache key + * + * @var string + */ + protected $cache_key; + + /** + * Initialize the class + * + * @param Directorist\Appsero\Client + */ + public function __construct( Client $client ) { + $this->client = $client; + $this->cache_key = 'appsero_' . md5( $this->client->slug ) . '_version_info'; + + // Run hooks. + if ( $this->client->type === 'plugin' ) { + $this->run_plugin_hooks(); + } elseif ( $this->client->type === 'theme' ) { + $this->run_theme_hooks(); + } + } + + /** + * Set up WordPress filter to hooks to get update. + * + * @return void + */ + public function run_plugin_hooks() { + add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_plugin_update' ) ); + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); + } + + /** + * Set up WordPress filter to hooks to get update. + * + * @return void + */ + public function run_theme_hooks() { + add_filter( 'pre_set_site_transient_update_themes', array( $this, 'check_theme_update' ) ); + } + + /** + * Check for Update for this specific project + */ + public function check_plugin_update( $transient_data ) { + global $pagenow; + + if ( ! is_object( $transient_data ) ) { + $transient_data = new stdClass(); + } + + if ( 'plugins.php' === $pagenow && is_multisite() ) { + return $transient_data; + } + + if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->basename ] ) ) { + return $transient_data; + } + + $version_info = $this->get_version_info(); + + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { + unset( $version_info->sections ); + + // If new version available then set to `response` + if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) { + $transient_data->response[ $this->client->basename ] = $version_info; + } else { + // If new version is not available then set to `no_update` + $transient_data->no_update[ $this->client->basename ] = $version_info; + } + + $transient_data->last_checked = time(); + $transient_data->checked[ $this->client->basename ] = $this->client->project_version; + } + + return $transient_data; + } + + /** + * Get version info from database + * + * @return object or Boolean + */ + private function get_cached_version_info() { + global $pagenow; + + // If updater page then fetch from API now + if ( 'update-core.php' === $pagenow ) { + return false; // Force to fetch data + } + + $value = get_transient( $this->cache_key ); + + if ( ! $value && ! isset( $value->name ) ) { + return false; // Cache is expired + } + + // We need to turn the icons into an array + if ( isset( $value->icons ) ) { + $value->icons = (array) $value->icons; + } + + // We need to turn the banners into an array + if ( isset( $value->banners ) ) { + $value->banners = (array) $value->banners; + } + + if ( isset( $value->sections ) ) { + $value->sections = (array) $value->sections; + } + + return $value; + } + + /** + * Set version info to database + */ + private function set_cached_version_info( $value ) { + if ( ! $value ) { + return; + } + + set_transient( $this->cache_key, $value, 3 * HOUR_IN_SECONDS ); + } + + /** + * Get plugin info from Appsero + */ + private function get_project_latest_version() { + $license = $this->client->license()->get_license(); + + $params = array( + 'version' => $this->client->project_version, + 'name' => $this->client->name, + 'slug' => $this->client->slug, + 'basename' => $this->client->basename, + 'license_key' => ! empty( $license ) && isset( $license['key'] ) ? $license['key'] : '', + ); + + $route = 'update/' . $this->client->hash . '/check'; + + $response = $this->client->send_request( $params, $route, true ); + + if ( is_wp_error( $response ) ) { + return false; + } + + $response = json_decode( wp_remote_retrieve_body( $response ) ); + + if ( ! isset( $response->slug ) ) { + return false; + } + + if ( isset( $response->icons ) ) { + $response->icons = (array) $response->icons; + } + + if ( isset( $response->banners ) ) { + $response->banners = (array) $response->banners; + } + + if ( isset( $response->sections ) ) { + $response->sections = (array) $response->sections; + } + + return $response; + } + + /** + * Updates information on the "View version x.x details" page with custom data. + * + * @param mixed $data + * @param string $action + * @param object $args + * + * @return object $data + */ + public function plugins_api_filter( $data, $action = '', $args = null ) { + if ( $action !== 'plugin_information' ) { + return $data; + } + + if ( ! isset( $args->slug ) || ( $args->slug !== $this->client->slug ) ) { + return $data; + } + + return $this->get_version_info(); + } + + /** + * Check theme upate + */ + public function check_theme_update( $transient_data ) { + global $pagenow; + + if ( ! is_object( $transient_data ) ) { + $transient_data = new stdClass(); + } + + if ( 'themes.php' === $pagenow && is_multisite() ) { + return $transient_data; + } + + if ( ! empty( $transient_data->response ) && ! empty( $transient_data->response[ $this->client->slug ] ) ) { + return $transient_data; + } + + $version_info = $this->get_version_info(); + + if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) { + // If new version available then set to `response` + if ( version_compare( $this->client->project_version, $version_info->new_version, '<' ) ) { + $transient_data->response[ $this->client->slug ] = (array) $version_info; + } else { + // If new version is not available then set to `no_update` + $transient_data->no_update[ $this->client->slug ] = (array) $version_info; + } + + $transient_data->last_checked = time(); + $transient_data->checked[ $this->client->slug ] = $this->client->project_version; + } + + return $transient_data; + } + + /** + * Get version information + */ + private function get_version_info() { + $version_info = $this->get_cached_version_info(); + + if ( false === $version_info ) { + $version_info = $this->get_project_latest_version(); + $this->set_cached_version_info( $version_info ); + } + + return $version_info; + } } diff --git a/includes/modules/background-process/wp-async-request.php b/includes/modules/background-process/wp-async-request.php index aeded4b140..1776017e43 100644 --- a/includes/modules/background-process/wp-async-request.php +++ b/includes/modules/background-process/wp-async-request.php @@ -177,5 +177,4 @@ public function maybe_handle() { * during the async request. */ abstract protected function handle(); - -} \ No newline at end of file +} diff --git a/includes/modules/background-process/wp-background-process.php b/includes/modules/background-process/wp-background-process.php index 9d0bcd5cdf..20d2ac4a7b 100644 --- a/includes/modules/background-process/wp-background-process.php +++ b/includes/modules/background-process/wp-background-process.php @@ -195,7 +195,7 @@ protected function is_queue_empty() { $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; - $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM %s WHERE %s LIKE %s", $table, $column, $key ) ); + $count = $wpdb->get_var( $wpdb->prepare( 'SELECT COUNT(*) FROM %s WHERE %s LIKE %s', $table, $column, $key ) ); return ( $count > 0 ) ? false : true; } @@ -266,14 +266,21 @@ protected function get_batch() { $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; - $query = $wpdb->get_row( $wpdb->prepare( " + $query = $wpdb->get_row( + $wpdb->prepare( + ' SELECT * FROM %s WHERE %s LIKE %s ORDER BY %s ASC LIMIT 1 - ", $table, $column, $key, $key_column - ) ); + ', + $table, + $column, + $key, + $key_column + ) + ); $batch = new stdClass(); $batch->key = $query->$column; @@ -472,7 +479,6 @@ protected function clear_scheduled_event() { * Cancel Process * * Stop processing queue items, clear cronjob and delete batch. - * */ public function cancel_process() { if ( ! $this->is_queue_empty() ) { @@ -482,7 +488,6 @@ public function cancel_process() { wp_clear_scheduled_hook( $this->cron_hook_identifier ); } - } /** @@ -498,5 +503,4 @@ public function cancel_process() { * @return mixed */ abstract protected function task( $item ); - -} \ No newline at end of file +} diff --git a/includes/modules/multi-directory-setup/builder-custom-fields.php b/includes/modules/multi-directory-setup/builder-custom-fields.php index 292df17604..00f1c7f441 100644 --- a/includes/modules/multi-directory-setup/builder-custom-fields.php +++ b/includes/modules/multi-directory-setup/builder-custom-fields.php @@ -6,55 +6,60 @@ exit; } -$custom_field_meta_key_field = apply_filters( 'directorist_custom_field_meta_key_field_args', [ - 'type' => 'hidden', - 'label' => __( 'Key', 'directorist' ), - 'value' => 'custom-text', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] -]); +$custom_field_meta_key_field = apply_filters( + 'directorist_custom_field_meta_key_field_args', + array( + 'type' => 'hidden', + 'label' => __( 'Key', 'directorist' ), + 'value' => 'custom-text', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ) +); -function get_assign_to_field( array $args = [] ) { - $default = [ - 'type' => 'radio', - 'label' => __('Assign to', 'directorist'), - 'value' => 'form', - 'options' => [ - [ - 'label' => __('Form', 'directorist'), +function get_assign_to_field( array $args = array() ) { + $default = array( + 'type' => 'radio', + 'label' => __( 'Assign to', 'directorist' ), + 'value' => 'form', + 'options' => array( + array( + 'label' => __( 'Form', 'directorist' ), 'value' => 'form', - ], - [ - 'label' => __('Category', 'directorist'), + ), + array( + 'label' => __( 'Category', 'directorist' ), 'value' => 'category', - ], - ], - ]; + ), + ), + ); return array_merge( $default, $args ); } -function get_category_select_field( array $args = [] ) { - $default = [ +function get_category_select_field( array $args = array() ) { + $default = array( 'type' => 'select', - 'label' => __('Select Category', 'directorist'), + 'label' => __( 'Select Category', 'directorist' ), 'value' => '', 'options' => get_cetagory_options(), - ]; + ); return array_merge( $default, $args ); } function get_cetagory_options() { - $terms = get_terms( [ - 'taxonomy' => ATBDP_CATEGORY, - 'hide_empty' => false, - ] ); + $terms = get_terms( + array( + 'taxonomy' => ATBDP_CATEGORY, + 'hide_empty' => false, + ) + ); $directory_type = isset( $_GET['listing_type_id'] ) ? absint( $_GET['listing_type_id'] ) : directorist_get_default_directory(); - $options = []; + $options = array(); if ( is_wp_error( $terms ) ) { return $options; @@ -68,685 +73,780 @@ function get_cetagory_options() { $term_directory_types = get_term_meta( $term->term_id, '_directory_type', true ); if ( is_array( $term_directory_types ) && in_array( $directory_type, $term_directory_types, true ) ) { - $options[] = [ + $options[] = array( 'id' => $term->term_id, 'value' => $term->term_id, 'label' => $term->name, - ]; + ); } - } return $options; } function get_file_upload_field_options() { - $options = [ - [ + $options = array( + array( 'label' => __( 'All types', 'directorist' ), 'value' => 'all_types', - ], - [ + ), + array( 'label' => __( 'Image types', 'directorist' ), 'value' => 'image', - ], - [ + ), + array( 'label' => __( 'Audio types', 'directorist' ), 'value' => 'audio', - ], - [ + ), + array( 'label' => __( 'Video types', 'directorist' ), 'value' => 'video', - ], - [ + ), + array( 'label' => __( 'Document types', 'directorist' ), 'value' => 'document', - ], - ]; + ), + ); foreach ( directorist_get_supported_file_types() as $file_type ) { - $options[] = [ + $options[] = array( 'label' => $file_type, 'value' => $file_type, - ]; + ); } return $options; } -return apply_filters( 'atbdp_form_custom_widgets', array( - 'text' => [ - 'label' => __( 'Text', 'directorist' ), - 'icon' => 'uil uil-text', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-text', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Text', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], +return apply_filters( + 'atbdp_form_custom_widgets', + array( + 'text' => array( + 'label' => __( 'Text', 'directorist' ), + 'icon' => 'uil uil-text', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-text', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Text', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'textarea' => [ - 'label' => __( 'Textarea', 'directorist' ), - 'icon' => 'uil uil-align-left', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'textarea', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-textarea', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Textarea', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'rows' => [ - 'type' => 'number', - 'label' => __( 'Rows', 'directorist' ), - 'value' => 8, - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'textarea' => array( + 'label' => __( 'Textarea', 'directorist' ), + 'icon' => 'uil uil-align-left', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'textarea', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-textarea', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Textarea', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'rows' => array( + 'type' => 'number', + 'label' => __( 'Rows', 'directorist' ), + 'value' => 8, + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'number' => [ - 'label' => __( 'Number', 'directorist' ), - 'icon' => 'uil uil-0-plus', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'number', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-number', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Number', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'min_value' => [ - 'type' => 'number', - 'label' => __( 'Min Value', 'directorist' ), - 'value' => '', - ], - 'max_value' => [ - 'type' => 'number', - 'label' => __( 'Max Value', 'directorist' ), - 'value' => '', - ], - 'step' => [ - 'type' => 'number', - 'label' => __( 'Step', 'directorist' ), - 'value' => 1, - ], - 'prepend' => [ - 'type' => 'text', - 'label' => __( 'Prepend', 'directorist' ), - 'description' => __( 'Appears before The Input', 'directorist' ), - 'value' => "", - ], - 'append' => [ - 'type' => 'text', - 'label' => __( 'Append', 'directorist' ), - 'description' => __( 'Appears after The Input', 'directorist' ), - 'value' => "", - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'number' => array( + 'label' => __( 'Number', 'directorist' ), + 'icon' => 'uil uil-0-plus', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'number', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-number', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Number', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'min_value' => array( + 'type' => 'number', + 'label' => __( 'Min Value', 'directorist' ), + 'value' => '', + ), + 'max_value' => array( + 'type' => 'number', + 'label' => __( 'Max Value', 'directorist' ), + 'value' => '', + ), + 'step' => array( + 'type' => 'number', + 'label' => __( 'Step', 'directorist' ), + 'value' => 1, + ), + 'prepend' => array( + 'type' => 'text', + 'label' => __( 'Prepend', 'directorist' ), + 'description' => __( 'Appears before The Input', 'directorist' ), + 'value' => '', + ), + 'append' => array( + 'type' => 'text', + 'label' => __( 'Append', 'directorist' ), + 'description' => __( 'Appears after The Input', 'directorist' ), + 'value' => '', + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'url' => [ - 'label' => __( 'URL', 'directorist' ), - 'icon' => 'uil uil-link-add', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-url', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'URL', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'target' => [ - 'type' => 'toggle', - 'label' => __( 'Open in new tab', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'url' => array( + 'label' => __( 'URL', 'directorist' ), + 'icon' => 'uil uil-link-add', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-url', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'URL', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'target' => array( + 'type' => 'toggle', + 'label' => __( 'Open in new tab', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'date' => [ - 'label' => __( 'Date', 'directorist' ), - 'icon' => 'uil uil-calender', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'date', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-date', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Date', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'date' => array( + 'label' => __( 'Date', 'directorist' ), + 'icon' => 'uil uil-calender', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'date', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-date', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Date', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'time' => [ - 'label' => __( 'Time', 'directorist' ), - 'icon' => 'uil uil-clock', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'time', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-time', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Time', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'time' => array( + 'label' => __( 'Time', 'directorist' ), + 'icon' => 'uil uil-clock', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'time', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-time', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Time', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'color_picker' => [ - 'label' => __( 'Color Picker', 'directorist' ), - 'icon' => 'uil uil-palette', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'color', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-color-picker', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Color', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'color_picker' => array( + 'label' => __( 'Color Picker', 'directorist' ), + 'icon' => 'uil uil-palette', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'color', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-color-picker', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Color', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'select' => [ - 'label' => __( 'Dropdown', 'directorist' ), - 'icon' => 'uil uil-file-check-alt', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'select', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-select', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Select', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'options' => [ - 'type' => 'multi-fields', - 'label' => __('Options', 'directorist'), - 'add-new-button-label' => __( 'Add Option', 'directorist' ), - 'options' => [ - 'option_value' => [ - 'type' => 'text', - 'label' => __( 'Value', 'directorist' ), - 'value' => '', - ], - 'option_label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => '', - ], - ] - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'select' => array( + 'label' => __( 'Dropdown', 'directorist' ), + 'icon' => 'uil uil-file-check-alt', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'select', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-select', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Select', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'options' => array( + 'type' => 'multi-fields', + 'label' => __( 'Options', 'directorist' ), + 'add-new-button-label' => __( 'Add Option', 'directorist' ), + 'options' => array( + 'option_value' => array( + 'type' => 'text', + 'label' => __( 'Value', 'directorist' ), + 'value' => '', + ), + 'option_label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => '', + ), + ), + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'checkbox' => [ - 'label' => __( 'Checkbox', 'directorist' ), - 'icon' => 'uil uil-check-square', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'checkbox', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-checkbox', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Checkbox', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'options' => [ - 'type' => 'multi-fields', - 'label' => __('Options', 'directorist'), - 'add-new-button-label' => __( 'Add Option', 'directorist' ), - 'options' => [ - 'option_value' => [ - 'type' => 'text', - 'label' => __( 'Value', 'directorist' ), - 'value' => '', - ], - 'option_label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => '', - ], - ] - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'checkbox' => array( + 'label' => __( 'Checkbox', 'directorist' ), + 'icon' => 'uil uil-check-square', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'checkbox', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-checkbox', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Checkbox', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'options' => array( + 'type' => 'multi-fields', + 'label' => __( 'Options', 'directorist' ), + 'add-new-button-label' => __( 'Add Option', 'directorist' ), + 'options' => array( + 'option_value' => array( + 'type' => 'text', + 'label' => __( 'Value', 'directorist' ), + 'value' => '', + ), + 'option_label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => '', + ), + ), + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'radio' => [ - 'label' => __( 'Radio', 'directorist' ), - 'icon' => 'uil uil-circle', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'radio', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-radio', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Radio', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'options' => [ - 'type' => 'multi-fields', - 'label' => __('Options', 'directorist'), - 'add-new-button-label' => __( 'Add Option', 'directorist' ), - 'options' => [ - 'option_value' => [ - 'type' => 'text', - 'label' => __( 'Value', 'directorist' ), - 'value' => '', - ], - 'option_label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => '', - ], - ] - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'assign_to' => [ - 'type' => 'toggle', - 'label' => __('Assign to Category', 'directorist'), - 'value' => false, - ], - 'category' => get_category_select_field([ - 'show_if' => [ - 'where' => "self.assign_to", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ]), - ] - ], + 'radio' => array( + 'label' => __( 'Radio', 'directorist' ), + 'icon' => 'uil uil-circle', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'radio', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-radio', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Radio', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'options' => array( + 'type' => 'multi-fields', + 'label' => __( 'Options', 'directorist' ), + 'add-new-button-label' => __( 'Add Option', 'directorist' ), + 'options' => array( + 'option_value' => array( + 'type' => 'text', + 'label' => __( 'Value', 'directorist' ), + 'value' => '', + ), + 'option_label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => '', + ), + ), + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'assign_to' => array( + 'type' => 'toggle', + 'label' => __( 'Assign to Category', 'directorist' ), + 'value' => false, + ), + 'category' => get_category_select_field( + array( + 'show_if' => array( + 'where' => 'self.assign_to', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ) + ), + ), + ), - 'file' => [ - 'label' => __( 'File Upload', 'directorist' ), - 'icon' => 'uil uil-paperclip', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'file', - ], - 'field_key' => array_merge( $custom_field_meta_key_field, [ - 'value' => 'custom-file', - ]), - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'File Upload', - ], - 'description' => [ - 'type' => 'text', - 'label' => __( 'Description', 'directorist' ), - 'value' => '', - ], - 'file_type' => [ - 'type' => 'select', - 'label' => __( 'Select a file type', 'directorist' ), - 'description' => __( 'By selecting a file type you are going to allow your users to upload only that or those type(s) of file.', 'directorist' ), - 'value' => 'image', - 'options' => get_file_upload_field_options(), - ], - 'file_size' => [ - 'type' => 'text', - 'label' => __( 'File Size', 'directorist' ), - 'description' => __('Set maximum file size to upload', 'directorist'), - 'value' => '2mb', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ] - ], -)); + 'file' => array( + 'label' => __( 'File Upload', 'directorist' ), + 'icon' => 'uil uil-paperclip', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'file', + ), + 'field_key' => array_merge( + $custom_field_meta_key_field, + array( + 'value' => 'custom-file', + ) + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'File Upload', + ), + 'description' => array( + 'type' => 'text', + 'label' => __( 'Description', 'directorist' ), + 'value' => '', + ), + 'file_type' => array( + 'type' => 'select', + 'label' => __( 'Select a file type', 'directorist' ), + 'description' => __( 'By selecting a file type you are going to allow your users to upload only that or those type(s) of file.', 'directorist' ), + 'value' => 'image', + 'options' => get_file_upload_field_options(), + ), + 'file_size' => array( + 'type' => 'text', + 'label' => __( 'File Size', 'directorist' ), + 'description' => __( 'Set maximum file size to upload', 'directorist' ), + 'value' => '2mb', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), + ) +); diff --git a/includes/modules/multi-directory-setup/builder-preset-fields.php b/includes/modules/multi-directory-setup/builder-preset-fields.php index a9e179aaa8..dc5e13e8e5 100644 --- a/includes/modules/multi-directory-setup/builder-preset-fields.php +++ b/includes/modules/multi-directory-setup/builder-preset-fields.php @@ -6,953 +6,1019 @@ exit; } -return apply_filters( 'atbdp_form_preset_widgets', array( - 'title' => [ - 'label' => __( 'Title', 'directorist' ), - 'icon' => 'las la-text-height', - 'canTrash' => false, - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'listing_title', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Title', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => true, - ], - ], - ], +return apply_filters( + 'atbdp_form_preset_widgets', + array( + 'title' => array( + 'label' => __( 'Title', 'directorist' ), + 'icon' => 'las la-text-height', + 'canTrash' => false, + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'listing_title', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Title', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => true, + ), + ), + ), - 'description' => [ - 'label' => __( 'Description', 'directorist' ), - 'icon' => 'uil uil-align-left', - 'show' => true, - 'options' => [ - 'type' => [ - 'type' => 'select', - 'label' => __( 'Type', 'directorist' ), - 'value' => 'wp_editor', - 'options' => [ - [ - 'label' => __('Textarea', 'directorist'), - 'value' => 'textarea', - ], - [ - 'label' => __('WP Editor', 'directorist'), - 'value' => 'wp_editor', - ], - ] - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'listing_content', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Description', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - 'show_if' => [ - 'where' => "self.type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'textarea'], - ], - ], - ], - 'required' => [ - 'type' => 'toggle', - 'name' => 'required', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ] - ], + 'description' => array( + 'label' => __( 'Description', 'directorist' ), + 'icon' => 'uil uil-align-left', + 'show' => true, + 'options' => array( + 'type' => array( + 'type' => 'select', + 'label' => __( 'Type', 'directorist' ), + 'value' => 'wp_editor', + 'options' => array( + array( + 'label' => __( 'Textarea', 'directorist' ), + 'value' => 'textarea', + ), + array( + 'label' => __( 'WP Editor', 'directorist' ), + 'value' => 'wp_editor', + ), + ), + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'listing_content', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Description', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + 'show_if' => array( + 'where' => 'self.type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'textarea', + ), + ), + ), + ), + 'required' => array( + 'type' => 'toggle', + 'name' => 'required', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'tagline' => [ - 'label' => __( 'Tagline', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'show' => true, - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'tagline', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tagline', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], + 'tagline' => array( + 'label' => __( 'Tagline', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'show' => true, + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'tagline', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tagline', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), - ], - ], + ), + ), - 'pricing' => [ - 'label' => __( 'Pricing', 'directorist' ), - 'icon' => 'uil uil-bill', - 'options' => [ - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'pricing', - 'rules' => [ - 'unique' => true, - 'required' => false, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Pricing', - ], - 'pricing_type' => [ - 'type' => 'select', - 'label' => __( 'Select Pricing Type', 'directorist' ), - 'value' => 'both', - // 'show-default-option' => true, - 'options' => [ - ['value' => 'both', 'label' => 'Both'], - ['value' => 'price_unit', 'label' => 'Price Unit'], - ['value' => 'price_range', 'label' => 'Price Range'], - ], - ], - 'price_range_label' => [ - 'type' => 'text', - 'show_if' => [ - 'where' => "self.pricing_type", - 'compare' => 'or', - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'both'], - ['key' => 'value', 'compare' => '=', 'value' => 'price_range'], - ], - ], - 'label' => __( 'Price Range Label', 'directorist' ), - 'value' => 'Price Range', - ], - 'price_range_placeholder' => [ - 'type' => 'text', - 'show_if' => [ - 'where' => "self.pricing_type", - 'compare' => 'or', - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'both'], - ['key' => 'value', 'compare' => '=', 'value' => 'price_range'], - ], - ], - 'label' => __( 'Price Range Placeholder', 'directorist' ), - 'value' => 'Select Price Range', - ], - 'price_unit_field_type' => [ - 'type' => 'select', - 'label' => __( 'Price Unit Field Type', 'directorist' ), - 'show_if' => [ - 'where' => "self.pricing_type", - 'compare' => 'or', - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'both'], - ['key' => 'value', 'compare' => '=', 'value' => 'price_unit'], - ], - ], - 'value' => 'number', - 'options' => [ - ['value' => 'number', 'label' => 'Number',], - ['value' => 'text', 'label' => 'Text',], - ], - ], - 'price_unit_field_label' => [ - 'type' => 'text', - 'label' => __( 'Price Unit Field label', 'directorist' ), - 'show_if' => [ - 'where' => "self.pricing_type", - 'compare' => 'or', - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'both'], - ['key' => 'value', 'compare' => '=', 'value' => 'price_unit'], - ], - ], - 'value' => 'Price [USD]', - ], - 'price_unit_field_placeholder' => [ - 'type' => 'text', - 'label' => __( 'Price Unit Field Placeholder', 'directorist' ), - 'show_if' => [ - 'where' => "self.pricing_type", - 'compare' => 'or', - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'both'], - ['key' => 'value', 'compare' => '=', 'value' => 'price_unit'], - ], - ], - 'value' => 'Price of this listing. Eg. 100', - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'modules' => [ - 'type' => 'hidden', - 'value' => [ - 'price_unit' => [ - 'label' => __( 'Price Unit', 'directorist' ), - 'type' => 'text', - 'field_key' => 'price_unit', - ], - 'price_range' => [ - 'label' => __( 'Price Range', 'directorist' ), - 'type' => 'text', - 'field_key' => 'price_range', - ], - ], - ], - ] - ], + 'pricing' => array( + 'label' => __( 'Pricing', 'directorist' ), + 'icon' => 'uil uil-bill', + 'options' => array( + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'pricing', + 'rules' => array( + 'unique' => true, + 'required' => false, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Pricing', + ), + 'pricing_type' => array( + 'type' => 'select', + 'label' => __( 'Select Pricing Type', 'directorist' ), + 'value' => 'both', + // 'show-default-option' => true, + 'options' => array( + array( + 'value' => 'both', + 'label' => 'Both', + ), + array( + 'value' => 'price_unit', + 'label' => 'Price Unit', + ), + array( + 'value' => 'price_range', + 'label' => 'Price Range', + ), + ), + ), + 'price_range_label' => array( + 'type' => 'text', + 'show_if' => array( + 'where' => 'self.pricing_type', + 'compare' => 'or', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'both', + ), + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'price_range', + ), + ), + ), + 'label' => __( 'Price Range Label', 'directorist' ), + 'value' => 'Price Range', + ), + 'price_range_placeholder' => array( + 'type' => 'text', + 'show_if' => array( + 'where' => 'self.pricing_type', + 'compare' => 'or', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'both', + ), + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'price_range', + ), + ), + ), + 'label' => __( 'Price Range Placeholder', 'directorist' ), + 'value' => 'Select Price Range', + ), + 'price_unit_field_type' => array( + 'type' => 'select', + 'label' => __( 'Price Unit Field Type', 'directorist' ), + 'show_if' => array( + 'where' => 'self.pricing_type', + 'compare' => 'or', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'both', + ), + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'price_unit', + ), + ), + ), + 'value' => 'number', + 'options' => array( + array( + 'value' => 'number', + 'label' => 'Number', + ), + array( + 'value' => 'text', + 'label' => 'Text', + ), + ), + ), + 'price_unit_field_label' => array( + 'type' => 'text', + 'label' => __( 'Price Unit Field label', 'directorist' ), + 'show_if' => array( + 'where' => 'self.pricing_type', + 'compare' => 'or', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'both', + ), + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'price_unit', + ), + ), + ), + 'value' => 'Price [USD]', + ), + 'price_unit_field_placeholder' => array( + 'type' => 'text', + 'label' => __( 'Price Unit Field Placeholder', 'directorist' ), + 'show_if' => array( + 'where' => 'self.pricing_type', + 'compare' => 'or', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'both', + ), + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'price_unit', + ), + ), + ), + 'value' => 'Price of this listing. Eg. 100', + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'modules' => array( + 'type' => 'hidden', + 'value' => array( + 'price_unit' => array( + 'label' => __( 'Price Unit', 'directorist' ), + 'type' => 'text', + 'field_key' => 'price_unit', + ), + 'price_range' => array( + 'label' => __( 'Price Range', 'directorist' ), + 'type' => 'text', + 'field_key' => 'price_range', + ), + ), + ), + ), + ), - 'excerpt' => [ - 'label' => __( 'Excerpt', 'directorist' ), - 'icon' => 'uil uil-paragraph', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'textarea', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'excerpt', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Excerpt', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'excerpt' => array( + 'label' => __( 'Excerpt', 'directorist' ), + 'icon' => 'uil uil-paragraph', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'textarea', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'excerpt', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Excerpt', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'location' => [ - 'label' => 'Location', - 'icon' => 'uil uil-map-marker', - 'options' => [ - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'tax_input[at_biz_dir-location][]', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Location', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'type' => [ - 'type' => 'radio', - 'value' => 'multiple', - 'label' => __( 'Selection Type', 'directorist' ), - 'options' => [ - [ - 'label' => __('Single Selection', 'directorist'), - 'value' => 'single', - ], - [ - 'label' => __('Multi Selection', 'directorist'), - 'value' => 'multiple', - ] - ] - ], - 'create_new_loc' => [ - 'type' => 'toggle', - 'label' => __( 'Allow New', 'directorist' ), - 'value' => false, - ], - 'max_location_creation' => [ - 'type' => 'number', - 'label' => __( 'Maximum Number', 'directorist' ), - 'placeholder' => 'Here 0 means unlimited', - 'value' => '0', - 'show_if' => [ - 'where' => "self.type", - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => 'multiple'], - ], - ], - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'location' => array( + 'label' => 'Location', + 'icon' => 'uil uil-map-marker', + 'options' => array( + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'tax_input[at_biz_dir-location][]', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Location', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'type' => array( + 'type' => 'radio', + 'value' => 'multiple', + 'label' => __( 'Selection Type', 'directorist' ), + 'options' => array( + array( + 'label' => __( 'Single Selection', 'directorist' ), + 'value' => 'single', + ), + array( + 'label' => __( 'Multi Selection', 'directorist' ), + 'value' => 'multiple', + ), + ), + ), + 'create_new_loc' => array( + 'type' => 'toggle', + 'label' => __( 'Allow New', 'directorist' ), + 'value' => false, + ), + 'max_location_creation' => array( + 'type' => 'number', + 'label' => __( 'Maximum Number', 'directorist' ), + 'placeholder' => 'Here 0 means unlimited', + 'value' => '0', + 'show_if' => array( + 'where' => 'self.type', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => 'multiple', + ), + ), + ), + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'tag' => [ - 'label' => __( 'Tag', 'directorist' ), - 'icon' => 'las la-tag', - 'options' => [ - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'tax_input[at_biz_dir-tags][]', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Tag', - ], - 'type' => [ - 'type' => 'radio', - 'value' => 'multiple', - 'label' => __( 'Selection Type', 'directorist' ), - 'options' => [ - [ - 'label' => __('Single Selection', 'directorist'), - 'value' => 'single', - ], - [ - 'label' => __('Multi Selection', 'directorist'), - 'value' => 'multiple', - ] - ] - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'allow_new' => [ - 'type' => 'toggle', - 'label' => __( 'Allow New', 'directorist' ), - 'value' => true, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'tag' => array( + 'label' => __( 'Tag', 'directorist' ), + 'icon' => 'las la-tag', + 'options' => array( + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'tax_input[at_biz_dir-tags][]', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Tag', + ), + 'type' => array( + 'type' => 'radio', + 'value' => 'multiple', + 'label' => __( 'Selection Type', 'directorist' ), + 'options' => array( + array( + 'label' => __( 'Single Selection', 'directorist' ), + 'value' => 'single', + ), + array( + 'label' => __( 'Multi Selection', 'directorist' ), + 'value' => 'multiple', + ), + ), + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'allow_new' => array( + 'type' => 'toggle', + 'label' => __( 'Allow New', 'directorist' ), + 'value' => true, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'category' => [ - 'label' => __( 'Category', 'directorist' ), - 'icon' => 'uil uil-folder-open', - 'options' => [ - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'admin_category_select[]', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Category', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'type' => [ - 'type' => 'radio', - 'value' => 'multiple', - 'label' => __( 'Selection Type', 'directorist' ), - 'options' => [ - [ - 'label' => __('Single Selection', 'directorist'), - 'value' => 'single', - ], - [ - 'label' => __('Multi Selection', 'directorist'), - 'value' => 'multiple', - ] - ] - ], - 'create_new_cat' => [ - 'type' => 'toggle', - 'label' => __( 'Allow New', 'directorist' ), - 'value' => false, - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'category' => array( + 'label' => __( 'Category', 'directorist' ), + 'icon' => 'uil uil-folder-open', + 'options' => array( + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'admin_category_select[]', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Category', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'type' => array( + 'type' => 'radio', + 'value' => 'multiple', + 'label' => __( 'Selection Type', 'directorist' ), + 'options' => array( + array( + 'label' => __( 'Single Selection', 'directorist' ), + 'value' => 'single', + ), + array( + 'label' => __( 'Multi Selection', 'directorist' ), + 'value' => 'multiple', + ), + ), + ), + 'create_new_cat' => array( + 'type' => 'toggle', + 'label' => __( 'Allow New', 'directorist' ), + 'value' => false, + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'map' => [ - 'label' => __( 'Map', 'directorist' ), - 'icon' => 'uil uil-map', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'map', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'map', - ], - 'label' => [ - 'type' => 'hidden', - 'value' => __( 'Map', 'directorist' ), - ], - 'lat_long' => [ - 'type' => 'text', - 'label' => __( 'Enter Coordinates Label', 'directorist' ), - 'value' => __( 'Or Enter Coordinates (latitude and longitude) Manually', 'directorist' ), - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'map' => array( + 'label' => __( 'Map', 'directorist' ), + 'icon' => 'uil uil-map', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'map', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'map', + ), + 'label' => array( + 'type' => 'hidden', + 'value' => __( 'Map', 'directorist' ), + ), + 'lat_long' => array( + 'type' => 'text', + 'label' => __( 'Enter Coordinates Label', 'directorist' ), + 'value' => __( 'Or Enter Coordinates (latitude and longitude) Manually', 'directorist' ), + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'address' => [ - 'label' => __( 'Address', 'directorist' ), - 'icon' => 'uil uil-map-pin', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'address', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Address', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => __( 'Listing address eg. New York, USA', 'directorist' ), - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'address' => array( + 'label' => __( 'Address', 'directorist' ), + 'icon' => 'uil uil-map-pin', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'address', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Address', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => __( 'Listing address eg. New York, USA', 'directorist' ), + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'zip' => [ - 'label' => __( 'Zip or Post Code', 'directorist' ), - 'icon' => 'uil uil-map-pin', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'zip', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Zip/Post Code', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'zip' => array( + 'label' => __( 'Zip or Post Code', 'directorist' ), + 'icon' => 'uil uil-map-pin', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'zip', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Zip/Post Code', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'phone' => [ - 'label' => 'Phone', - 'icon' => 'uil uil-phone', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'tel', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'phone', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Phone', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'whatsapp' => [ - 'type' => 'toggle', - 'label' => __( 'Link with WhatsApp', 'directorist' ), - 'value' => false, - ], - ], - ], + 'phone' => array( + 'label' => 'Phone', + 'icon' => 'uil uil-phone', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'tel', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'phone', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Phone', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'whatsapp' => array( + 'type' => 'toggle', + 'label' => __( 'Link with WhatsApp', 'directorist' ), + 'value' => false, + ), + ), + ), - 'phone2' => [ - 'label' => 'Phone 2', - 'icon' => 'uil uil-phone', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'tel', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'phone2', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Phone 2', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - 'whatsapp' => [ - 'type' => 'toggle', - 'label' => __( 'Link with WhatsApp', 'directorist' ), - 'value' => false, - ], - ], - ], + 'phone2' => array( + 'label' => 'Phone 2', + 'icon' => 'uil uil-phone', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'tel', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'phone2', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Phone 2', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + 'whatsapp' => array( + 'type' => 'toggle', + 'label' => __( 'Link with WhatsApp', 'directorist' ), + 'value' => false, + ), + ), + ), - 'fax' => [ - 'label' => 'Fax', - 'icon' => 'uil uil-print', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'number', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'fax', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Fax', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'fax' => array( + 'label' => 'Fax', + 'icon' => 'uil uil-print', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'number', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'fax', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Fax', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'email' => [ - 'label' => 'Email', - 'icon' => 'uil uil-envelope', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'email', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'email', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Email', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist'), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'email' => array( + 'label' => 'Email', + 'icon' => 'uil uil-envelope', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'email', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'email', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Email', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'website' => [ - 'label' => 'Website', - 'icon' => 'uil uil-globe', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'website', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Website', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => '', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'website' => array( + 'label' => 'Website', + 'icon' => 'uil uil-globe', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'website', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Website', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => '', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'social_info' => [ - 'label' => 'Social Info', - 'icon' => 'uil uil-users-alt', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'add_new', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'social', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Social Info', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'social_info' => array( + 'label' => 'Social Info', + 'icon' => 'uil uil-users-alt', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'add_new', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'social', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Social Info', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'image_upload' => [ - 'label' => __( 'Images', 'directirst' ), - 'icon' => 'uil uil-image', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'media', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'listing_img', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'hidden', - 'value' => __( 'Images', 'directorist' ), - ], - 'select_files_label' => [ - 'type' => 'text', - 'label' => __( 'Select Files Label', 'directorist' ), - 'value' => 'Select Files', - ], - 'max_image_limit' => [ - 'type' => 'number', - 'label' => __( 'Max Image Limit', 'directorist' ), - 'value' => 5, - ], - 'max_per_image_limit' => [ - 'type' => 'number', - 'label' => __( 'Max Upload Size Per Image in MB', 'directorist' ), - 'description' => __( 'Here 0 means unlimited.', 'directorist' ), - 'value' => 0, - ], - 'max_total_image_limit' => [ - 'type' => 'number', - 'label' => __( 'Total Upload Size in MB', 'directorist' ), - 'value' => 2, - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ] - ], - ], + 'image_upload' => array( + 'label' => __( 'Images', 'directirst' ), + 'icon' => 'uil uil-image', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'media', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'listing_img', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'hidden', + 'value' => __( 'Images', 'directorist' ), + ), + 'select_files_label' => array( + 'type' => 'text', + 'label' => __( 'Select Files Label', 'directorist' ), + 'value' => 'Select Files', + ), + 'max_image_limit' => array( + 'type' => 'number', + 'label' => __( 'Max Image Limit', 'directorist' ), + 'value' => 5, + ), + 'max_per_image_limit' => array( + 'type' => 'number', + 'label' => __( 'Max Upload Size Per Image in MB', 'directorist' ), + 'description' => __( 'Here 0 means unlimited.', 'directorist' ), + 'value' => 0, + ), + 'max_total_image_limit' => array( + 'type' => 'number', + 'label' => __( 'Total Upload Size in MB', 'directorist' ), + 'value' => 2, + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'video' => [ - 'label' => 'Video', - 'icon' => 'uil uil-video', - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'videourl', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Video', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Only YouTube & Vimeo URLs.', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'only_for_admin' => [ - 'type' => 'toggle', - 'label' => __( 'Admin Only', 'directorist' ), - 'value' => false, - ], - ], - ], + 'video' => array( + 'label' => 'Video', + 'icon' => 'uil uil-video', + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'videourl', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Video', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Only YouTube & Vimeo URLs.', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'only_for_admin' => array( + 'type' => 'toggle', + 'label' => __( 'Admin Only', 'directorist' ), + 'value' => false, + ), + ), + ), - 'terms_privacy' => [ - 'label' => __( 'Terms & Privacy', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'show' => true, - 'options' => [ - 'type' => [ - 'type' => 'hidden', - 'value' => 'text', - ], - 'field_key' => [ - 'type' => 'hidden', - 'value' => 'privacy_policy', - 'rules' => [ - 'unique' => true, - 'required' => true, - ] - ], - 'text' => [ - 'label' => __( 'Text', 'directorist' ), - 'type' => 'textarea', - 'editor' => 'wp_editor', - 'editorID' => 'wp_editor_terms_privacy', - 'value' => sprintf( - __( 'I agree to the <a href="%s" target="_blank">Privacy Policy</a> and <a href="%s" target="_blank">Terms of Service</a>', 'directorist' ), - ATBDP_Permalink::get_privacy_policy_page_url(), - ATBDP_Permalink::get_terms_and_conditions_page_url(), - ), - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - ], -)); + 'terms_privacy' => array( + 'label' => __( 'Terms & Privacy', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'show' => true, + 'options' => array( + 'type' => array( + 'type' => 'hidden', + 'value' => 'text', + ), + 'field_key' => array( + 'type' => 'hidden', + 'value' => 'privacy_policy', + 'rules' => array( + 'unique' => true, + 'required' => true, + ), + ), + 'text' => array( + 'label' => __( 'Text', 'directorist' ), + 'type' => 'textarea', + 'editor' => 'wp_editor', + 'editorID' => 'wp_editor_terms_privacy', + 'value' => sprintf( + __( 'I agree to the <a href="%1$s" target="_blank">Privacy Policy</a> and <a href="%2$s" target="_blank">Terms of Service</a>', 'directorist' ), + ATBDP_Permalink::get_privacy_policy_page_url(), + ATBDP_Permalink::get_terms_and_conditions_page_url(), + ), + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + ), + ) +); diff --git a/includes/modules/multi-directory-setup/class-ai-builder.php b/includes/modules/multi-directory-setup/class-ai-builder.php index 09ebbe6083..15fe55286e 100644 --- a/includes/modules/multi-directory-setup/class-ai-builder.php +++ b/includes/modules/multi-directory-setup/class-ai-builder.php @@ -22,7 +22,7 @@ class AI_Builder { /** * Preset fields map */ - protected static $preset_fields = [ + protected static $preset_fields = array( 'title' => 'title', 'description' => 'description', 'tagline' => 'tagline', @@ -42,11 +42,11 @@ class AI_Builder { 'socialinfo' => 'social_info', 'images' => 'image_upload', 'video' => 'video', - ]; + ); public static function init() { - add_action( 'wp_ajax_directorist_ai_directory_form', [ __CLASS__, 'form_handler' ] ); - add_action( 'wp_ajax_directorist_ai_directory_creation', [ __CLASS__, 'create_directory' ] ); + add_action( 'wp_ajax_directorist_ai_directory_form', array( __CLASS__, 'form_handler' ) ); + add_action( 'wp_ajax_directorist_ai_directory_creation', array( __CLASS__, 'create_directory' ) ); } public static function form_handler() { @@ -56,17 +56,20 @@ public static function form_handler() { ob_start(); - atbdp_load_admin_template( 'post-types-manager/ai/step-one', [] ); + atbdp_load_admin_template( 'post-types-manager/ai/step-one', array() ); $form = ob_get_clean(); - wp_send_json_success( ['form' => $form ] ); + wp_send_json_success( array( 'form' => $form ) ); } protected static function prepare_keywords( $keywords ) { - $keywords = array_map( static function( $keyword ) { - return '"' . trim( $keyword ) . '"'; - }, explode( ',', $keywords ) ); + $keywords = array_map( + static function ( $keyword ) { + return '"' . trim( $keyword ) . '"'; + }, + explode( ',', $keywords ) + ); return implode( ',', $keywords ); } @@ -77,21 +80,24 @@ public static function create_directory() { wp_send_json_error( 'You are not authorized.', 401 ); } - $prompt = ! empty( $_POST['prompt'] ) ? sanitize_textarea_field( $_POST['prompt'] ) : ''; - $keywords = ! empty( $_POST['keywords'] ) ? static::prepare_keywords( $_POST['keywords'] ) : ''; - $pinned = ! empty( $_POST['pinned'] ) ? $_POST['pinned'] : ''; - $step = ! empty( $_POST['step'] ) ? absint( $_POST['step'] ) : ''; - $name = ! empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : ''; - $fields = ! empty( $_POST['fields'] ) ? $_POST['fields'] : []; + $prompt = ! empty( $_POST['prompt'] ) ? sanitize_textarea_field( $_POST['prompt'] ) : ''; + $keywords = ! empty( $_POST['keywords'] ) ? static::prepare_keywords( $_POST['keywords'] ) : ''; + $pinned = ! empty( $_POST['pinned'] ) ? $_POST['pinned'] : ''; + $step = ! empty( $_POST['step'] ) ? absint( $_POST['step'] ) : ''; + $name = ! empty( $_POST['name'] ) ? sanitize_text_field( $_POST['name'] ) : ''; + $fields = ! empty( $_POST['fields'] ) ? $_POST['fields'] : array(); if ( 1 === $step ) { $response = static::ai_create_keywords( $prompt ); if ( is_wp_error( $response ) ) { - wp_send_json_error( [ - 'message' => $response->get_error_message(), - 'code' => $response->get_error_code() - ], ( $response->get_error_code() === 'limit_exceeded' ? 429 : 400 ) ); + wp_send_json_error( + array( + 'message' => $response->get_error_message(), + 'code' => $response->get_error_code(), + ), + ( $response->get_error_code() === 'limit_exceeded' ? 429 : 400 ) + ); } else { wp_send_json_success( $response ); } @@ -101,10 +107,13 @@ public static function create_directory() { $response = static::ai_create_fields( $keywords, $pinned ); if ( is_wp_error( $response ) ) { - wp_send_json_error( [ - 'message' => $response->get_error_message(), - 'code' => $response->get_error_code() - ], ( $response->get_error_code() === 'limit_exceeded' ? 429 : 400 ) ); + wp_send_json_error( + array( + 'message' => $response->get_error_message(), + 'code' => $response->get_error_code(), + ), + ( $response->get_error_code() === 'limit_exceeded' ? 429 : 400 ) + ); } else { wp_send_json_success( $response ); } @@ -115,82 +124,90 @@ public static function create_directory() { $id = ! empty( $data['id'] ) ? $data['id'] : ''; - wp_send_json_success( [ - 'url' => esc_url_raw( admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types&listing_type_id=' . $id . '&action=edit' ) ), - ] ); + wp_send_json_success( + array( + 'url' => esc_url_raw( admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types&listing_type_id=' . $id . '&action=edit' ) ), + ) + ); } } - public static function merge_new_fields($existing_config, $new_fields) { - $new_fields_array = json_decode(stripslashes($new_fields), true); + public static function merge_new_fields( $existing_config, $new_fields ) { + $new_fields_array = json_decode( stripslashes( $new_fields ), true ); - if (is_null($new_fields_array)) { + if ( is_null( $new_fields_array ) ) { // throw new Exception('Failed to decode new fields JSON: ' . json_last_error_msg()); } // Reformat new fields to match the old format and ensure unique field keys for same type fields - $type_counts = []; - $formatted_fields = []; - foreach ($new_fields_array as $key => $field) { - $type = strtolower($field['type']); - if (!isset($type_counts[$type])) { - $type_counts[$type] = 0; + $type_counts = array(); + $formatted_fields = array(); + foreach ( $new_fields_array as $key => $field ) { + $type = strtolower( $field['type'] ); + if ( ! isset( $type_counts[ $type ] ) ) { + $type_counts[ $type ] = 0; } else { - $type_counts[$type]++; + ++$type_counts[ $type ]; } - $suffix = $type_counts[$type] > 0 ? '-' . $type_counts[$type] : ''; + $suffix = $type_counts[ $type ] > 0 ? '-' . $type_counts[ $type ] : ''; $field_key = "custom-{$type}{$suffix}"; // Handle specific structures for checkbox, radio, and select fields - if (in_array($type, ['checkbox', 'radio', 'select']) && isset($field['options']) && is_array($field['options'])) { - $field['options'] = array_map(function ($option) { - if (is_array($option)) { - return [ - 'option_value' => $option['option_value'] ?? $option['value'], - 'option_label' => $option['option_label'] ?? $option['label'] - ]; - } - return [ - 'option_value' => $option, - 'option_label' => $option - ]; - }, $field['options']); + if ( in_array( $type, array( 'checkbox', 'radio', 'select' ) ) && isset( $field['options'] ) && is_array( $field['options'] ) ) { + $field['options'] = array_map( + function ( $option ) { + if ( is_array( $option ) ) { + return array( + 'option_value' => $option['option_value'] ?? $option['value'], + 'option_label' => $option['option_label'] ?? $option['label'], + ); + } + return array( + 'option_value' => $option, + 'option_label' => $option, + ); + }, + $field['options'] + ); } - $formatted_fields[$field_key] = array_merge($field, [ - 'widget_group' => 'custom', - 'widget_name' => $type, - 'field_key' => $field_key, - 'widget_key' => $key, - ]); + $formatted_fields[ $field_key ] = array_merge( + $field, + array( + 'widget_group' => 'custom', + 'widget_name' => $type, + 'field_key' => $field_key, + 'widget_key' => $key, + ) + ); } // Group the fields based on 'group_name' - $groups = []; - foreach ($formatted_fields as $field_key => $field) { + $groups = array(); + foreach ( $formatted_fields as $field_key => $field ) { $group_name = $field['group_name']; - if (!isset($groups[$group_name])) { - $groups[$group_name] = [ - "type" => "general_group", - "label" => $group_name, - "fields" => [], - "defaultGroupLabel" => "Section", - "disableTrashIfGroupHasWidgets" => [ - [ - "widget_name" => "title", - "widget_group" => "preset" - ] - ], - "icon" => "las la-pen-nib", - ]; + if ( ! isset( $groups[ $group_name ] ) ) { + $groups[ $group_name ] = array( + 'type' => 'general_group', + 'label' => $group_name, + 'fields' => array(), + 'defaultGroupLabel' => 'Section', + 'disableTrashIfGroupHasWidgets' => array( + array( + 'widget_name' => 'title', + 'widget_group' => 'preset', + ), + ), + 'icon' => 'las la-pen-nib', + ); } - $groups[$group_name]['fields'][] = $field_key; + $groups[ $group_name ]['fields'][] = $field_key; } // Keep old title and description fields $title_description_fields = array_intersect_key( - $existing_config['submission_form_fields']['fields'] ?? [], - array_flip(['title', 'description']) + $existing_config['submission_form_fields']['fields'] ?? array(), + array_flip( array( 'title', 'description' ) ) ); // Replace the old fields with new fields, keeping title and description @@ -199,52 +216,61 @@ public static function merge_new_fields($existing_config, $new_fields) { $formatted_fields ); - $existing_config['submission_form_fields']['groups'] = array_values($groups); + $existing_config['submission_form_fields']['groups'] = array_values( $groups ); // Update the single listing layout to use the new fields $single_listing_fields = array_merge( - $existing_config['single_listings_contents']['fields'] ?? [], - array_map(function ($field) { - return [ - 'icon' => $field['icon'] ?? '', - 'widget_group' => $field['widget_group'], - 'widget_name' => $field['widget_name'], - 'original_widget_key' => $field['field_key'], - 'widget_key' => $field['field_key'], - ]; - }, $formatted_fields) + $existing_config['single_listings_contents']['fields'] ?? array(), + array_map( + function ( $field ) { + return array( + 'icon' => $field['icon'] ?? '', + 'widget_group' => $field['widget_group'], + 'widget_name' => $field['widget_name'], + 'original_widget_key' => $field['field_key'], + 'widget_key' => $field['field_key'], + ); + }, + $formatted_fields + ) ); $existing_config['single_listings_contents']['fields'] = $single_listing_fields; - $existing_config['single_listings_contents']['groups'] = array_values($groups); + $existing_config['single_listings_contents']['groups'] = array_values( $groups ); return $existing_config; } public static function merge_new_fields_v2( $structure, $new_fields ) { - $new_fields_array = json_decode(stripslashes($new_fields), true); + $new_fields_array = json_decode( stripslashes( $new_fields ), true ); - if (is_null($new_fields_array)) { - return []; + if ( is_null( $new_fields_array ) ) { + return array(); } - array_walk($new_fields_array, function (&$field, $key) { - // Generate the field_key dynamically by type and prefix "custom-" - $type = strtolower($field['type']); - $field_key = "custom-{$type}"; - - $field = array_merge($field, [ - 'widget_group' => 'custom', - 'widget_name' => $type, - 'field_key' => $field_key, - 'widget_key' => $key, - ]); - }); + array_walk( + $new_fields_array, + function ( &$field, $key ) { + // Generate the field_key dynamically by type and prefix "custom-" + $type = strtolower( $field['type'] ); + $field_key = "custom-{$type}"; + + $field = array_merge( + $field, + array( + 'widget_group' => 'custom', + 'widget_name' => $type, + 'field_key' => $field_key, + 'widget_key' => $key, + ) + ); + } + ); // Keep old title and description fields $title_description_fields = array_intersect_key( - $structure['submission_form_fields']['fields'] ?? [], - array_flip(['title', 'description']) + $structure['submission_form_fields']['fields'] ?? array(), + array_flip( array( 'title', 'description' ) ) ); // Replace the old fields with new fields, keeping title and description @@ -254,21 +280,21 @@ public static function merge_new_fields_v2( $structure, $new_fields ) { ); // Replace old groups with a new group containing the new fields and keeping title and description - $structure['submission_form_fields']['groups'] = [ - [ - "type" => "general_group", - "label" => "General Information", - "fields" => array_merge(['title', 'description'], array_keys($new_fields_array)), - "defaultGroupLabel" => "Section", - "disableTrashIfGroupHasWidgets" => [ - [ - "widget_name" => "title", - "widget_group" => "preset" - ] - ], - "icon" => "las la-pen-nib", - ] - ]; + $structure['submission_form_fields']['groups'] = array( + array( + 'type' => 'general_group', + 'label' => 'General Information', + 'fields' => array_merge( array( 'title', 'description' ), array_keys( $new_fields_array ) ), + 'defaultGroupLabel' => 'Section', + 'disableTrashIfGroupHasWidgets' => array( + array( + 'widget_name' => 'title', + 'widget_group' => 'preset', + ), + ), + 'icon' => 'las la-pen-nib', + ), + ); return $structure; } @@ -288,11 +314,13 @@ public static function build_directory( $name, $fields ) { DirectoryManager::load_builder_data(); - $directory = DirectoryManager::add_directory( [ - 'directory_name' => $name, - 'fields_value' => $directory_config, - 'is_json' => false - ] ); + $directory = DirectoryManager::add_directory( + array( + 'directory_name' => $name, + 'fields_value' => $directory_config, + 'is_json' => false, + ) + ); if ( $directory['status']['success'] ) { $term_id = $directory['term_id']; @@ -300,30 +328,32 @@ public static function build_directory( $name, $fields ) { $term_id = $directory['status']['term_id']; } - return [ + return array( 'structure' => $directory_config, 'new_fields' => $form_fields['fields'], 'updated_config' => $directory_config, 'id' => $term_id, - ]; + ); } public static function ai_create_fields( $keywords, $pinned = null ) { - $response = static::request_fields( [ - 'keywords' => $keywords, - 'pinned' => $pinned, - ] ); + $response = static::request_fields( + array( + 'keywords' => $keywords, + 'pinned' => $pinned, + ) + ); if ( is_wp_error( $response ) ) { return $response; } if ( empty( $response['response']['fields'] ) || ! is_array( $response['response']['fields'] ) ) { - return [ - 'fields' => [], + return array( + 'fields' => array(), 'html' => '', - 'request_count' => $response['request_count'] - ]; + 'request_count' => $response['request_count'], + ); } ob_start(); @@ -334,15 +364,15 @@ public static function ai_create_fields( $keywords, $pinned = null ) { $html = ob_get_clean(); - return [ + return array( 'fields' => $response['response']['fields'], 'html' => $html, - 'request_count' => $response['request_count'] - ]; + 'request_count' => $response['request_count'], + ); } public static function ai_create_keywords( $prompt ) { - $response = static::request_keywords( ['prompt' => $prompt] ); + $response = static::request_keywords( array( 'prompt' => $prompt ) ); if ( is_wp_error( $response ) ) { return $response; @@ -353,24 +383,25 @@ public static function ai_create_keywords( $prompt ) { if ( ! empty( $response['response']['keywords'] ) ) { foreach ( $response['response']['keywords'] as $keyword ) { ?> <li class="free-enabled"><?php echo ucwords( $keyword ); ?></li> - <?php } + <?php + } } $html = ob_get_clean(); - return [ + return array( 'html' => $html, - 'request_count' => $response['request_count'] - ]; + 'request_count' => $response['request_count'], + ); } protected static function prepare_form_fields( $fields ) { $form_fields_file = DIRECTORIST_ASSETS_DIR . 'sample-data/listing-form-fields.json'; $form_fields = json_decode( file_get_contents( $form_fields_file ), 1 ); - $prepared_fields = []; - $prepared_groups = []; - $counter = []; + $prepared_fields = array(); + $prepared_groups = array(); + $counter = array(); $should_include_group = false; foreach ( $fields as $field ) { @@ -390,26 +421,29 @@ protected static function prepare_form_fields( $fields ) { $should_include_group = true; } - // Handle custom fields + // Handle custom fields } elseif ( isset( $form_fields[ $field['type'] ] ) ) { $_field = $form_fields[ $field['type'] ]; $_field['label'] = $field['label']; - if ( in_array( $field['type'], [ 'select', 'radio', 'checkbox' ], true ) && + if ( in_array( $field['type'], array( 'select', 'radio', 'checkbox' ), true ) && isset( $field['options'] ) && is_array( $field['options'] ) ) { - $_field['options'] = array_map( static function( $option ) { - return [ - 'option_value' => $option, - 'option_label' => $option - ]; - }, $field['options'] ); + $_field['options'] = array_map( + static function ( $option ) { + return array( + 'option_value' => $option, + 'option_label' => $option, + ); + }, + $field['options'] + ); } // "text_2": { - // "type": "text", - // "field_key": "custom-text-2", - // "widget_key": "text_2" + // "type": "text", + // "field_key": "custom-text-2", + // "widget_key": "text_2" // }, if ( isset( $counter[ $field['type'] ] ) ) { @@ -432,32 +466,32 @@ protected static function prepare_form_fields( $fields ) { if ( isset( $prepared_groups[ $field['group'] ] ) ) { $prepared_groups[ $field['group'] ]['fields'][] = $field_name; } else { - $prepared_groups[ $field['group'] ] = [ + $prepared_groups[ $field['group'] ] = array( 'label' => $field['group'], - 'fields' => [ $field_name ], - ]; + 'fields' => array( $field_name ), + ); } } $should_include_group = false; } - return [ + return array( 'groups' => array_values( $prepared_groups ), 'fields' => $prepared_fields, - ]; + ); } protected static function prepare_single_fields( $form_fields ) { - $fields = []; - $ignorable_fields = [ + $fields = array(); + $ignorable_fields = array( 'title' => false, 'tagline' => false, 'image_upload' => false, 'location' => false, 'category' => false, 'pricing' => false, - ]; + ); // Prepare fields foreach ( $form_fields['fields'] as $field_key => $field ) { @@ -467,13 +501,13 @@ protected static function prepare_single_fields( $form_fields ) { continue; } - $fields[ $field_key ] = [ + $fields[ $field_key ] = array( 'icon' => 'las la-tag', 'widget_group' => 'preset_widgets', 'widget_name' => $field['widget_name'], 'original_widget_key' => $field_key, - 'widget_key' => $field_key - ]; + 'widget_key' => $field_key, + ); if ( $field_key === 'address' ) { $fields[ $field_key ]['address_link_with_map'] = false; @@ -485,7 +519,7 @@ protected static function prepare_single_fields( $form_fields ) { } // Prepare groups - $groups = []; + $groups = array(); $ignorable_field_keys = array_keys( $ignorable_fields ); $section_id = 0; @@ -496,15 +530,15 @@ protected static function prepare_single_fields( $form_fields ) { continue; } - $groups[] = [ + $groups[] = array( 'type' => 'general_group', 'label' => $group['label'], 'fields' => array_values( $group_fields ), 'section_id' => ++$section_id, - ]; + ); } - $groups[] = [ + $groups[] = array( 'type' => 'section', 'label' => 'Author Info', 'section_id' => ++$section_id, @@ -512,195 +546,195 @@ protected static function prepare_single_fields( $form_fields ) { 'display_email' => true, 'widget_group' => 'other_widgets', 'widget_name' => 'author_info', - 'fields' => [] - ]; + 'fields' => array(), + ); - $groups[] = [ - 'type' => 'section', - 'label' => 'Contact Listings Owner Form', - 'fields' => [ + $groups[] = array( + 'type' => 'section', + 'label' => 'Contact Listings Owner Form', + 'fields' => array( 'contact_name', 'contact_email', 'contact_message', - ], + ), 'section_id' => ++$section_id, 'icon' => 'las la-phone', - 'accepted_widgets' => [ - [ + 'accepted_widgets' => array( + array( 'widget_group' => 'other_widgets', 'widget_name' => 'contact_listings_owner', 'widget_child_name' => 'contact_name', - ], - [ + ), + array( 'widget_group' => 'other_widgets', 'widget_name' => 'contact_listings_owner', 'widget_child_name' => 'contact_email', - ], - [ + ), + array( 'widget_group' => 'other_widgets', 'widget_name' => 'contact_listings_owner', 'widget_child_name' => 'contact_message', - ], - ], - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - ]; - - // Contact form fields - $fields['contact_name'] = [ - 'enable' => 1, - 'placeholder' => 'Name', + ), + ), 'widget_group' => 'other_widgets', 'widget_name' => 'contact_listings_owner', - 'widget_child_name'=> 'contact_name', - 'widget_key' => 'contact_name', - ]; + ); - $fields['contact_email'] = [ - 'placeholder' => 'Email', - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'widget_child_name'=> 'contact_email', - 'widget_key' => 'contact_email', - ]; + // Contact form fields + $fields['contact_name'] = array( + 'enable' => 1, + 'placeholder' => 'Name', + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_name', + 'widget_key' => 'contact_name', + ); - $fields['contact_message'] = [ - 'placeholder' => 'Message...', - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'widget_child_name'=> 'contact_message', - 'widget_key' => 'contact_message', - ]; + $fields['contact_email'] = array( + 'placeholder' => 'Email', + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_email', + 'widget_key' => 'contact_email', + ); + + $fields['contact_message'] = array( + 'placeholder' => 'Message...', + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_message', + 'widget_key' => 'contact_message', + ); // Prepare header $header = static::prepare_single_header_fields( $ignorable_fields ); - return [ + return array( 'header' => $header, 'groups' => $groups, - 'fields' => $fields - ]; + 'fields' => $fields, + ); } protected static function prepare_single_header_fields( $header_fields ) { - $fields = [ - 'quick-widgets-placeholder' => [ + $fields = array( + 'quick-widgets-placeholder' => array( 'type' => 'placeholder_group', 'placeholderKey' => 'quick-widgets-placeholder', - 'placeholders' => [ - [ - 'type' => 'placeholder_group', - 'placeholderKey' => 'quick-info-placeholder', - 'selectedWidgets' => [ - [ + 'placeholders' => array( + array( + 'type' => 'placeholder_group', + 'placeholderKey' => 'quick-info-placeholder', + 'selectedWidgets' => array( + array( 'type' => 'button', 'label' => 'Back', 'widget_name' => 'back', 'widget_key' => 'back', - ], - ], - ], - [ - 'type' => 'placeholder_group', - 'placeholderKey' => 'quick-action-placeholder', - 'selectedWidgets' => [ - [ + ), + ), + ), + array( + 'type' => 'placeholder_group', + 'placeholderKey' => 'quick-action-placeholder', + 'selectedWidgets' => array( + array( 'type' => 'button', 'label' => 'Bookmark', 'widget_name' => 'bookmark', 'widget_key' => 'bookmark', - ], - [ + ), + array( 'type' => 'badge', 'label' => 'Share', 'widget_name' => 'share', 'widget_key' => 'share', 'icon' => 'las la-share', - ], - [ + ), + array( 'type' => 'badge', 'label' => 'Report', 'widget_name' => 'report', 'widget_key' => 'report', 'icon' => 'las la-flag', - ], - ], - ], - ], - ], - 'slider-placeholder' => [ - 'type' => 'placeholder_item', - 'placeholderKey' => 'slider-placeholder', - 'selectedWidgets' => [ - [ - 'type' => 'thumbnail', - 'label' => 'Listing Image/Slider', - 'widget_name' => 'slider', - 'widget_key' => 'slider', + ), + ), + ), + ), + ), + 'slider-placeholder' => array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'slider-placeholder', + 'selectedWidgets' => array( + array( + 'type' => 'thumbnail', + 'label' => 'Listing Image/Slider', + 'widget_name' => 'slider', + 'widget_key' => 'slider', 'footer_thumbnail' => true, - ], - ], - ], - 'listing-title-placeholder' => [ - 'type' => 'placeholder_item', - 'placeholderKey' => 'listing-title-placeholder', - 'selectedWidgets' => [ - [ - 'type' => 'title', - 'label' => 'Listing Title', - 'widget_name' => 'title', - 'widget_key' => 'title', + ), + ), + ), + 'listing-title-placeholder' => array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'listing-title-placeholder', + 'selectedWidgets' => array( + array( + 'type' => 'title', + 'label' => 'Listing Title', + 'widget_name' => 'title', + 'widget_key' => 'title', 'enable_tagline' => true, - ], - ], - ], - 'more-widgets-placeholder' => [ - 'type' => 'placeholder_item', - 'placeholderKey' => 'more-widgets-placeholder', - 'selectedWidgets' => [ - [ + ), + ), + ), + 'more-widgets-placeholder' => array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'more-widgets-placeholder', + 'selectedWidgets' => array( + array( 'type' => 'badge', 'label' => 'Pricing', 'widget_name' => 'price', 'widget_key' => 'price', - ], - [ + ), + array( 'type' => 'ratings-count', 'label' => 'Rating', 'widget_name' => 'ratings_count', 'widget_key' => 'ratings_count', - ], - [ - 'type' => 'badge', - 'label' => 'Badges', - 'widget_name' => 'badges', - 'widget_key' => 'badges', - 'new_badge' => true, - 'popular_badge' => true, + ), + array( + 'type' => 'badge', + 'label' => 'Badges', + 'widget_name' => 'badges', + 'widget_key' => 'badges', + 'new_badge' => true, + 'popular_badge' => true, 'featured_badge' => true, - ], - [ + ), + array( 'type' => 'badge', 'label' => 'Category', 'widget_name' => 'category', 'widget_key' => 'category', - ], - [ + ), + array( 'type' => 'badge', 'label' => 'Location', 'widget_name' => 'location', 'widget_key' => 'location', - ], - ], - ], - ]; + ), + ), + ), + ); if ( ! $header_fields['image_upload'] ) { - $fields['slider-placeholder']['selectedWidgets'] = []; + $fields['slider-placeholder']['selectedWidgets'] = array(); } if ( ! $header_fields['title'] ) { - $fields['listing-title-placeholder']['selectedWidgets'] = []; + $fields['listing-title-placeholder']['selectedWidgets'] = array(); } if ( $header_fields['title'] && $header_fields['tagline'] ) { @@ -722,42 +756,42 @@ protected static function prepare_single_header_fields( $header_fields ) { protected static function render_fields( $fields ) { $icons_map = array( - 'title' => 'las la-text-height', - 'description' => 'uil uil-align-left', - 'tagline' => 'uil uil-text-fields', - 'pricing' => 'uil uil-bill', - 'excerpt' => 'uil uil-paragraph', - 'location' => 'uil uil-map-marker', - 'tag' => 'las la-tag', - 'category' => 'uil uil-folder-open', - 'map' => 'uil uil-map', - 'address' => 'uil uil-map-pin', - 'zip' => 'uil uil-map-pin', - 'phone' => 'uil uil-phone', - 'phone2' => 'uil uil-phone', - 'fax' => 'uil uil-print', - 'email' => 'uil uil-envelope', - 'website' => 'uil uil-globe', - 'social_info' => 'uil uil-users-alt', - 'image_upload' => 'uil uil-image', - 'video' => 'uil uil-video', - 'terms_privacy' => 'uil uil-text-fields', - 'text' => 'uil uil-text', - 'textarea' => 'uil uil-align-left', - 'number' => 'uil uil-0-plus', - 'url' => 'uil uil-link-add', - 'date' => 'uil uil-calender', - 'time' => 'uil uil-clock', - 'color_picker' => 'uil uil-palette', - 'select' => 'uil uil-list-ui-alt', - 'checkbox' => 'uil uil-check-square', - 'radio' => 'uil uil-dot-circle', - 'file_upload' => 'uil uil-file-upload' - ); + 'title' => 'las la-text-height', + 'description' => 'uil uil-align-left', + 'tagline' => 'uil uil-text-fields', + 'pricing' => 'uil uil-bill', + 'excerpt' => 'uil uil-paragraph', + 'location' => 'uil uil-map-marker', + 'tag' => 'las la-tag', + 'category' => 'uil uil-folder-open', + 'map' => 'uil uil-map', + 'address' => 'uil uil-map-pin', + 'zip' => 'uil uil-map-pin', + 'phone' => 'uil uil-phone', + 'phone2' => 'uil uil-phone', + 'fax' => 'uil uil-print', + 'email' => 'uil uil-envelope', + 'website' => 'uil uil-globe', + 'social_info' => 'uil uil-users-alt', + 'image_upload' => 'uil uil-image', + 'video' => 'uil uil-video', + 'terms_privacy' => 'uil uil-text-fields', + 'text' => 'uil uil-text', + 'textarea' => 'uil uil-align-left', + 'number' => 'uil uil-0-plus', + 'url' => 'uil uil-link-add', + 'date' => 'uil uil-calender', + 'time' => 'uil uil-clock', + 'color_picker' => 'uil uil-palette', + 'select' => 'uil uil-list-ui-alt', + 'checkbox' => 'uil uil-check-square', + 'radio' => 'uil uil-dot-circle', + 'file_upload' => 'uil uil-file-upload', + ); foreach ( $fields as $field ) { $label = $field['label'] ?? ''; - $options = empty( $field['options'] ) ? [] : $field['options']; + $options = empty( $field['options'] ) ? array() : $field['options']; $icon = $icons_map[ ( static::$preset_fields[ $field['type'] ] ?? $field['type'] ) ] ?? 'uil uil-paragraph'; ?> <div class="directorist-ai-generate-box__item"> @@ -817,9 +851,9 @@ protected static function request_fields( $params ) { protected static function request( $endpoint = 'keywords', $params = array() ) { $headers = array( - 'user-agent' => 'Directorist\\' . ATBDP_VERSION, - 'Accept' => 'application/json', - 'Content-Type' => 'application/json' + 'user-agent' => 'Directorist\\' . ATBDP_VERSION, + 'Accept' => 'application/json', + 'Content-Type' => 'application/json', ); $config = array( @@ -843,11 +877,11 @@ protected static function request( $endpoint = 'keywords', $params = array() ) { } // Decode the JSON string into a PHP array. - $response = json_decode( $response, true ); + $response = json_decode( $response, true ); - if ( JSON_ERROR_NONE !== json_last_error() ) { + if ( JSON_ERROR_NONE !== json_last_error() ) { return new WP_Error( 'invalid_data', 'Malformed JSON response', 400 ); - } + } if ( static::is_response_error( $response ) ) { return static::get_response_wp_error( $response ); diff --git a/includes/modules/multi-directory-setup/class-builder-data.php b/includes/modules/multi-directory-setup/class-builder-data.php index 8bb55b9d1b..02065294a5 100644 --- a/includes/modules/multi-directory-setup/class-builder-data.php +++ b/includes/modules/multi-directory-setup/class-builder-data.php @@ -1,2979 +1,3269 @@ <?php namespace Directorist\Multi_Directory; + use ATBDP_Permalink; use function PHPSTORM_META\type; class Builder_Data { - protected static $fields = []; - protected static $layouts = []; - protected static $config = []; - protected static $options = []; - - public function __construct() { - self::prepare_data(); - } - - protected static function prepare_data() { - $form_field_widgets = [ - 'preset' => [ - 'title' => __( 'Preset Fields', 'directorist' ), - 'description' => __( 'Click on a field to use it', 'directorist' ), - 'allowMultiple' => false, - 'widgets' => require_once __DIR__ . '/builder-preset-fields.php', - ], - - 'custom' => [ - 'title' => __( 'Custom Fields', 'directorist' ), - 'description' => __( 'Click on a field type you want to create.', 'directorist' ), - 'allowMultiple' => true, - 'widgets' => require_once __DIR__ . '/builder-custom-fields.php', - - ], - ]; - - $single_listings_contents_widgets = [ - 'preset_widgets' => [ - 'title' => __( 'Preset Fields', 'directorist' ), - 'description' => __( 'Click on a field to use it', 'directorist' ), - 'allowMultiple' => false, - 'template' => 'submission_form_fields', - 'widgets' => apply_filters( 'atbdp_single_listing_content_widgets', [ - - 'image_upload' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-tag', - ], - 'footer_thumbnail' => [ - 'type' => 'toggle', - 'label' => __( 'Footer Thumbnail', 'directorist' ), - 'value' => true, - ], - ] - ], - 'description' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-tag', - ], - ] - ], - - 'tag' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-tag', - ], - ], - ], - 'address' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-map', - ], - 'address_link_with_map' => [ - 'type' => 'toggle', - 'label' => __( 'Address Linked with Map', 'directorist' ), - 'value' => false, - ], - ], - ], - 'map' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-map', - ], - ], - ], - 'zip' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-street-view', - ], - ], - ], - 'phone' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-phone', - ], - ], - ], - 'phone2' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-phone', - ], - ], - ], - 'fax' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-fax', - ], - ], - ], - 'email' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-envelope', - ], - ], - ], - 'website' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-globe', - ], - 'use_nofollow' => [ - 'type' => 'toggle', - 'label' => __( 'Use rel="nofollow" in Website Link', 'directorist' ), - 'value' => false, - ], - ], - ], - 'social_info' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-share-alt', - ], - ], - ], - 'video' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-video', - ], - ], - ], - 'text' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-text-height', - ], - ], - ], - 'textarea' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-align-center', - ], - ], - ], - 'number' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-list-ol', - ], - ], - ], - 'url' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-link', - ], - ], - ], - 'date' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-calendar', - ], - ], - ], - 'time' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-clock', - ], - ], - ], - 'color_picker' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-palette', - ], - ], - ], - 'select' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-clipboard-check', - ], - ], - ], - 'checkbox' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-check-square', - ], - ], - ], - 'radio' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-circle', - ], - ], - ], - 'file' => [ - 'options' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-file-alt', - ], - ], - ], - ] ), - ], - 'other_widgets' => [ - 'title' => __( 'Other Fields', 'directorist' ), - 'description' => __( 'Click on a field to use it', 'directorist' ), - 'allowMultiple' => false, - 'widgets' => apply_filters( 'atbdp_single_listing_other_fields_widget', [ - 'custom_content' => [ - 'type' => 'widget', - 'label' => __( 'Custom Content', 'directorist' ), - 'icon' => 'las la-align-right', - 'allowMultiple' => true, - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => '', - ], - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => '', - ], - 'content' => [ - 'type' => 'textarea', - 'label' => __( 'Content', 'directorist' ), - 'value' => '', - 'description' => __( 'You can use any text or shortcode', 'directorist' ), - ], - ], - ], - 'review' => [ - 'type' => 'section', - 'label' => __( 'Review', 'directorist' ), - 'icon' => 'las la-star', - 'options' => [ - 'custom_block_id' => [ - 'type' => 'text', - 'label' => __( 'Custom block ID', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - 'custom_block_classes' => [ - 'type' => 'text', - 'label' => __( 'Custom block Classes', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - 'review_cookies_consent' => [ - 'label' => __( 'Show Cookies Consent', 'directorist' ), - 'type' => 'toggle', - 'value' => false, - ], - 'review_enable_gdpr_consent' => [ - 'label' => __( 'Enable GDPR Consent', 'directorist' ), - 'type' => 'toggle', - 'value' => false, - ], - 'review_gdpr_consent_label' => [ - 'label' => __( 'Consent Label', 'directorist' ), - 'type' => 'textarea', - 'editor' => 'wp_editor', - 'editorID' => 'wp_editor_terms_privacy', - 'value' => sprintf( - __( 'I have read and agree to the <a href="%s" target="_blank">Privacy Policy</a> and <a href="%s" target="_blank">Terms of Service</a>', 'directorist' ), - ATBDP_Permalink::get_privacy_policy_page_url(), - ATBDP_Permalink::get_terms_and_conditions_page_url(), - ), - ], - ], - - 'accepted_widgets' => [ - [ - 'widget_group' => 'other_widgets', - 'widget_name' => 'review', - 'widget_child_name' => 'review_comment', - ], - [ - 'widget_group' => 'other_widgets', - 'widget_name' => 'review', - 'widget_child_name' => 'review_email', - ], - [ - 'widget_group' => 'other_widgets', - 'widget_name' => 'review', - 'widget_child_name' => 'review_name', - ], - [ - 'widget_group' => 'other_widgets', - 'widget_name' => 'review', - 'widget_child_name' => 'review_website', - ], - ], - 'widgets' => [ - 'review_comment' => [ - 'label' => __( 'Comment', 'directorist' ), - 'canTrash' => false, - 'canMove' => false, - 'options' => [ - 'placeholder' => [ - 'label' => __( 'Placeholder', 'directorist' ), - 'type' => 'text', - 'value' => '', - ], - ] - ], - 'review_email' => [ - 'label' => __( 'Email', 'directorist' ), - 'canTrash' => false, - 'canMove' => false, - 'options' => [ - 'label' => [ - 'label' => __( 'Label', 'directorist' ), - 'type' => 'text', - 'value' => '', - ], - 'placeholder' => [ - 'label' => __( 'Placeholder', 'directorist' ), - 'type' => 'text', - 'value' => '', - ], - ] - ], - 'review_name' => [ - 'label' => __( 'Name', 'directorist' ), - 'canTrash' => false, - 'canMove' => false, - 'options' => [ - 'label' => [ - 'label' => __( 'Label', 'directorist' ), - 'type' => 'text', - 'value' => '', - ], - 'placeholder' => [ - 'label' => __( 'Placeholder', 'directorist' ), - 'type' => 'text', - 'value' => '', - ], - ] - ], - 'review_website' => [ - 'label' => __( 'Website', 'directorist' ), - 'canTrash' => false, - 'canMove' => false, - 'options' => [ - 'enable' => [ - 'label' => __( 'Show Website Field?', 'directorist' ), - 'type' => 'toggle', - 'value' => false, - ], - 'label' => [ - 'label' => __( 'Label', 'directorist' ), - 'type' => 'text', - 'value' => '', - ], - 'placeholder' => [ - 'label' => __( 'Placeholder', 'directorist' ), - 'type' => 'text', - 'value' => '', - ], - ] - ], - ] - - ], - 'author_info' => [ - 'type' => 'section', - 'label' => __( 'Author Info', 'directorist' ), - 'icon' => 'las la-user', - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Author Info', - ], - 'display_email' => [ - 'type' => 'toggle', - 'label' => __( 'Display Email', 'directorist' ), - 'value' => true, - ], - 'custom_block_id' => [ - 'type' => 'text', - 'label' => __( 'Custom block ID', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - 'custom_block_classes' => [ - 'type' => 'text', - 'label' => __( 'Custom block Classes', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - ], - ], - 'contact_listings_owner' => [ - 'type' => 'section', - 'label' => __( 'Contact Listings Owner Form', 'directorist' ), - 'icon' => 'las la-phone', - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Contact Listings Owner Form', - ], - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-phone', - ], - 'custom_block_id' => [ - 'type' => 'text', - 'label' => __( 'Custom block ID', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - 'custom_block_classes' => [ - 'type' => 'text', - 'label' => __( 'Custom block Classes', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - ], - 'accepted_widgets' => [ - [ - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'widget_child_name' => 'contact_name', - ], - [ - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'widget_child_name' => 'contact_email', - ], - [ - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'widget_child_name' => 'contact_message', - ], - ], - 'widgets' => [ - 'contact_name' => [ - 'label' => __( 'Name', 'directorist' ), - 'canTrash' => false, - 'canMove' => false, - 'options' => [ - 'enable' => [ - 'label' => __( 'Enable', 'directorist' ), - 'type' => 'toggle', - 'value' => true, - ], - 'placeholder' => [ - 'label' => __( 'Placeholder', 'directorist' ), - 'type' => 'text', - 'value' => __( 'Name', 'directorist' ), - ], - ] - ], - 'contact_email' => [ - 'label' => __( 'Email', 'directorist' ), - 'canTrash' => false, - 'canMove' => false, - 'options' => [ - 'placeholder' => [ - 'label' => __( 'Placeholder', 'directorist' ), - 'type' => 'text', - 'value' => __( 'Email', 'directorist' ), - ], - ] - ], - 'contact_message' => [ - 'label' => __( 'Message', 'directorist' ), - 'canTrash' => false, - 'canMove' => false, - 'options' => [ - 'placeholder' => [ - 'label' => __( 'Placeholder', 'directorist' ), - 'type' => 'text', - 'value' => __( 'Message...', 'directorist' ), - ], - ] - ], - ] - ], - 'related_listings' => [ - 'type' => 'section', - 'label' => __( 'Related Listings', 'directorist' ), - 'icon' => 'las la-copy', - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Related Listings', - ], - 'custom_block_id' => [ - 'type' => 'text', - 'label' => __( 'Custom block ID', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - 'custom_block_classes' => [ - 'type' => 'text', - 'label' => __( 'Custom block Classes', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - 'similar_listings_logics' => [ - 'type' => 'radio', - 'name' => 'similar_listings_logics', - 'label' => __( 'Related listings criteria', 'directorist' ), - 'options' => [ - ['id' => 'match_category_nd_location', 'label' => __( 'Match both category and tag', 'directorist' ), 'value' => 'AND'], - ['id' => 'match_category_or_location', 'label' => __( 'Match either category or tag', 'directorist' ), 'value' => 'OR'], - ], - 'value' => 'OR', - ], - 'listing_from_same_author' => [ - 'type' => 'toggle', - 'label' => __( 'Display listings by the same author', 'directorist' ), - 'value' => false, - ], - 'similar_listings_number_of_listings_to_show' => [ - 'type' => 'range', - 'min' => 0, - 'max' => 20, - 'label' => __( 'Number of listings to display', 'directorist' ), - 'value' => 3, - ], - 'similar_listings_number_of_columns' => [ - 'type' => 'range', - 'min' => 1, - 'max' => 4, - 'label' => __( 'Number of columns', 'directorist' ), - 'value' => 2, - ], - ], - ], - ] ), - ], - ]; - - $search_form_widgets = apply_filters( 'directorist_search_form_widgets', [ - 'available_widgets' => [ - 'title' => __( 'Preset Fields', 'directorist' ), - 'description' => __( 'Click on a field to use it', 'directorist' ), - 'allowMultiple' => false, - 'template' => 'submission_form_fields', - 'widgets' => [ - 'title' => [ - 'label' => __( 'Search Box', 'directorist' ), - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'label', 'directorist' ), - 'value' => 'Title', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'What are you looking for?', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - ], - - 'category' => [ - 'options' => [ - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => '', - 'sync' => false, - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Category', - ], - ], - ], - - 'location' => [ - 'options' => [ - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Location', - 'sync' => false, - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Location', - ], - 'location_source' => [ - 'type' => 'select', - 'label' => __( 'Location Source', 'directorist' ), - 'options' => [ - [ - 'label' => __( 'Display from Listing Location', 'directorist' ), - 'value' => 'from_listing_location', - ], - [ - 'label' => __( 'Display from Map API', 'directorist' ), - 'value' => 'from_map_api', - ], - ], - 'value' => 'from_map_api', - ], - ], - ], - - 'tag' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - ], - ], - - 'pricing' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Pricing', - ], - 'price_range_min_placeholder' => [ - 'type' => 'text', - 'label' => __( 'Price Range Min Placeholder', 'directorist' ), - 'value' => 'Min', - ], - 'price_range_max_placeholder' => [ - 'type' => 'text', - 'label' => __( 'Price Range Max Placeholder', 'directorist' ), - 'value' => 'Max', - ], - ], - ], - - 'zip' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Zip', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - ], - - 'phone' => [ - 'draggable' => false, - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Phone', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - ], - - 'phone2' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Phone 2', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - ], - - 'email' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Email', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - ], - - 'fax' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Fax', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Fax', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - ], - - 'website' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Website', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - ], - - 'text' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Text', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - 'number' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Number', - ], - 'type' => [ - 'type' => 'select', - 'label' => __( 'Search Type', 'directorist' ), - 'value' => 'number', - 'options' => [ - ['value' => 'number', 'label' => 'Input'], - ['value' => 'range', 'label' => 'Range'], - ['value' => 'dropdown', 'label' => 'Dropdown'], - ['value' => 'radio', 'label' => 'Radio'], - ], - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - - 'url' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'URL', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - - 'date' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Date', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - - 'time' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Time', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - - 'color_picker' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - - 'select' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'placeholder' => [ - 'type' => 'text', - 'label' => __( 'Placeholder', 'directorist' ), - 'value' => 'Select', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - - 'checkbox' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - - 'radio' => [ - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Tag', - ], - 'required' => [ - 'type' => 'toggle', - 'label' => __( 'Required', 'directorist' ), - 'value' => false, - ], - ], - - ], - - ], - ], - 'other_widgets' => [ - 'title' => __( 'Other Fields', 'directorist' ), - 'description' => __( 'Click on a field to use it', 'directorist' ), - 'allowMultiple' => false, - 'widgets' => [ - 'review' => [ - 'label' => 'Review', - 'icon' => 'las la-star', - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Review', - ], - ], - ], - 'radius_search' => [ - 'label' => __( 'Radius Search', 'directorist' ), - 'icon' => 'las la-map', - 'options' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Radius Search', - ], - 'default_radius_distance' => [ - 'type' => 'range', - 'label' => __( 'Default Radius Distance', 'directorist' ), - 'min' => 0, - 'max' => apply_filters( 'directorist_search_default_radius_distance', 750 ), - 'value' => 0, - ], - 'max_radius_distance' => [ - 'type' => 'range', - 'label' => __( 'Maximum Radius Distance', 'directorist' ), - 'min' => 0, - 'max' => 10000, - 'value' => 1000, - ], - 'radius_search_unit' => [ - 'type' => 'select', - 'label' => __( 'Radius Search Unit', 'directorist' ), - 'value' => 'miles', - 'options' => [ - ['value' => 'miles', 'label' => 'Miles'], - ['value' => 'kilometers', 'label' => 'Kilometers'], - ], - ], - 'radius_search_based_on' => [ - 'type' => 'radio', - 'label' => __( 'Radius Search Based on', 'directorist' ), - 'value' => 'address', - 'options' => [ - ['value' => 'address', 'label' => 'Address'], - ['value' => 'zip', 'label' => 'Zip Code'], - ], - ], - ], - ], - ], - ], - ] ); - - $listing_card_widget = apply_filters( 'directorist_listing_card_widgets', [ - 'listing_title' => [ - 'type' => 'title', - 'label' => __( 'Listing Title', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_listing_title', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'title'], - ], - ], - 'options' => [ - 'title' => __( 'Listing Title Settings', 'directorist' ), - 'fields' => [ - 'show_tagline' => [ - 'type' => 'toggle', - 'label' => __( 'Show Tagline', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'excerpt' => [ - 'type' => 'excerpt', - 'label' => __( 'Excerpt', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_listing_excerpt', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'excerpt'], - ], - ], - 'options' => [ - 'title' => __( 'Excerpt Settings', 'directorist' ), - 'fields' => [ - 'words_limit' => [ - 'type' => 'range', - 'label' => __( 'Words Limit', 'directorist' ), - 'min' => 5, - 'max' => 200, - 'value' => 20, - ], - 'show_readmore' => [ - 'type' => 'toggle', - 'label' => __( 'Show Readmore', 'directorist' ), - 'value' => true, - ], - 'show_readmore_text' => [ - 'type' => 'text', - 'label' => __( 'Read More Text', 'directorist' ), - 'value' => '...', - ], - ], - ], - ], - - 'listings_location' => [ - 'type' => 'list-item', - 'label' => __( 'Listings Location', 'directorist' ), - 'icon' => 'uil uil-location-point', - 'hook' => 'atbdp_listings_location', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'location'], - ], - ], - 'options' => [ - 'title' => __( 'Listings Location Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-map-marker', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'posted_date' => [ - 'type' => 'list-item', - 'label' => __( 'Posted Date', 'directorist' ), - 'icon' => 'las la-clock', - 'hook' => 'atbdp_listings_posted_date', - 'options' => [ - 'title' => __( 'Posted Date', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-clock', - ], - 'date_type' => [ - 'type' => 'radio', - 'label' => __( 'Date Type', 'directorist' ), - 'options' => [ - ['id' => 'atbdp_days_ago', 'label' => 'Days Ago', 'value' => 'days_ago'], - ['id' => 'atbdp_posted_date', 'label' => 'Posted Date', 'value' => 'post_date'], - ], - 'value' => 'post_date', - ], - ], - ], - ], - - 'website' => [ - 'type' => 'list-item', - 'label' => __( 'Listings Website', 'directorist' ), - 'icon' => 'las la-globe', - 'hook' => 'atbdp_listings_website', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'website'], - ], - ], - 'options' => [ - 'title' => __( 'Listings Website Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-globe', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'zip' => [ - 'type' => 'list-item', - 'label' => __( 'Listings Zip', 'directorist' ), - 'icon' => 'las la-at', - 'hook' => 'atbdp_listings_zip', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'zip'], - ], - ], - 'options' => [ - 'title' => __( 'Listings Zip Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-at', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'email' => [ - 'type' => 'list-item', - 'label' => __( 'Listings Email', 'directorist' ), - 'icon' => 'las la-envelope', - 'hook' => 'atbdp_listings_email', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'email'], - ], - ], - 'options' => [ - 'title' => __( 'Listings Email Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-envelope', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'fax' => [ - 'type' => 'list-item', - 'label' => __( 'Listings Fax', 'directorist' ), - 'icon' => 'las la-fax', - 'hook' => 'atbdp_listings_fax', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'fax'], - ], - ], - 'options' => [ - 'title' => __( 'Listings Fax Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-fax', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'phone' => [ - 'type' => 'list-item', - 'label' => __( 'Listings Phone', 'directorist' ), - 'icon' => 'las la-phone', - 'hook' => 'atbdp_listings_phone', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'phone'], - ], - ], - 'options' => [ - 'title' => __( 'Listings Phone Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-phone', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'phone2' => [ - 'type' => 'list-item', - 'label' => __( 'Listings Phone 2', 'directorist' ), - 'icon' => 'las la-phone', - 'hook' => 'atbdp_listings_phone2', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'phone2'], - ], - ], - 'options' => [ - 'title' => __( 'Listings Phone 2 Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-phone', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'address' => [ - 'type' => 'list-item', - 'label' => __( 'Listings Address', 'directorist' ), - 'icon' => 'las la-map-marker', - 'hook' => 'atbdp_listings_map_address', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'address'], - ], - ], - 'options' => [ - 'title' => __( 'Listings Address Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-map-marker', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'pricing' => [ - 'type' => 'price', - 'label' => __( 'Pricing', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_single_listings_price', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'pricing'], - ], - ], - ], - - 'rating' => [ - 'type' => 'rating', - 'label' => __( 'Rating', 'directorist' ), - 'hook' => 'atbdp_listings_rating', - 'icon' => 'uil uil-text-fields', - ], - - 'featured_badge' => [ - 'type' => 'badge', - 'label' => __( 'Featured', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_featured_badge', - ], - - 'new_badge' => [ - 'type' => 'badge', - 'label' => __( 'New', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_new_badge', - ], - - 'popular_badge' => [ - 'type' => 'badge', - 'label' => __( 'Popular', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_popular_badge', - ], - - 'favorite_badge' => [ - 'type' => 'icon', - 'label' => __( 'Favorite', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_favorite_badge', - ], - - 'view_count' => [ - 'type' => 'view-count', - 'label' => __( 'View Count', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_view_count', - 'options' => [ - 'title' => __( 'View Count Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-heart', - ], - ], - ], - ], - - 'category' => [ - 'type' => 'category', - 'label' => __( 'Category', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_category', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'category'], - ], - ], - 'options' => [ - 'title' => __( 'Category Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-folder', - ], - ], - ], - ], - - 'user_avatar' => [ - 'type' => 'avatar', - 'label' => __( 'User Avatar', 'directorist' ), - 'icon' => 'uil uil-text-fields', - 'hook' => 'atbdp_user_avatar', - 'can_move' => false, - 'options' => [ - 'title' => __( 'User Avatar Settings', 'directorist' ), - 'fields' => [ - 'align' => [ - 'type' => 'radio', - 'label' => __( 'Align', 'directorist' ), - 'value' => 'center', - 'options' => [ - ['id' => 'atbdp_user_avatar_align_right', 'label' => __( 'Right', 'directorist' ), 'value' => 'right'], - ['id' => 'atbdp_user_avatar_align_center', 'label' => __( 'Center', 'directorist' ), 'value' => 'center'], - ['id' => 'atbdp_user_avatar_align_left', 'label' => __( 'Left', 'directorist' ), 'value' => 'left'], - ], - ], - ], - ], - ], - - // Custom Fields - 'text' => [ - 'type' => 'list-item', - 'label' => __( 'Text', 'directorist' ), - 'icon' => 'las la-comment', - 'hook' => 'atbdp_custom_text', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'text'], - ], - ], - 'options' => [ - 'title' => __( 'Text Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-comment', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'number' => [ - 'type' => 'list-item', - 'label' => __( 'Number', 'directorist' ), - 'icon' => 'las la-file-word', - 'hook' => 'atbdp_custom_number', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'number'], - ], - ], - 'options' => [ - 'title' => 'Number Settings', - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-file-word', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'url' => [ - 'type' => 'list-item', - 'label' => __( 'URL', 'directorist' ), - 'icon' => 'las la-link', - 'hook' => 'atbdp_custom_url', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'url'], - ], - ], - 'options' => [ - 'title' => __( 'URL Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-link', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'date' => [ - 'type' => 'list-item', - 'label' => __( 'Date', 'directorist' ), - 'icon' => 'las la-calendar-check', - 'hook' => 'atbdp_custom_date', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'date'], - ], - ], - 'options' => [ - 'title' => __( 'Date Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-calendar-check', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'time' => [ - 'type' => 'list-item', - 'label' => __( 'Time', 'directorist' ), - 'icon' => 'las la-clock', - 'hook' => 'atbdp_custom_time', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'time'], - ], - ], - 'options' => [ - 'title' => __( 'Time Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-clock', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'color_picker' => [ - 'type' => 'list-item', - 'label' => __( 'Color Picker', 'directorist' ), - 'icon' => 'las la-palette', - 'hook' => 'atbdp_custom_color', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'color'], - ], - ], - 'options' => [ - 'title' => __( 'Color Picker Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-palette', - ], - ], - ], - ], - - 'select' => [ - 'type' => 'list-item', - 'label' => __( 'Select', 'directorist' ), - 'icon' => 'las la-check-circle', - 'hook' => 'atbdp_custom_select', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'select'], - ], - ], - 'options' => [ - 'title' => __( 'Select Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-check-circle', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'checkbox' => [ - 'type' => 'list-item', - 'label' => __( 'Checkbox', 'directorist' ), - 'icon' => 'las la-check-square', - 'hook' => 'atbdp_custom_checkbox', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'checkbox'], - ], - ], - 'options' => [ - 'title' => 'Checkbox Settings', - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-check-square', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - - 'radio' => [ - 'type' => 'list-item', - 'label' => __( 'Radio', 'directorist' ), - 'icon' => 'las la-circle', - 'hook' => 'atbdp_custom_radio', - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'radio'], - ], - ], - 'options' => [ - 'title' => __( 'Radio Settings', 'directorist' ), - 'fields' => [ - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Icon', 'directorist' ), - 'value' => 'las la-circle', - ], - 'show_label' => [ - 'type' => 'toggle', - 'label' => __( 'Show Label', 'directorist' ), - 'value' => false, - ], - ], - ], - ], - ] ); - - $listing_card_conditional_widget = $listing_card_widget; - - if ( ! empty( $listing_card_conditional_widget['user_avatar'] ) ) { - $listing_card_conditional_widget['user_avatar']['can_move'] = true; - - if ( ! empty( $listing_card_conditional_widget['user_avatar']['options'] ) ) { - unset( $listing_card_conditional_widget['user_avatar']['options'] ); - } - - } - - // Card Layouts - $listing_card_grid_view_with_thumbnail_layout = [ - 'thumbnail' => [ - 'top_right' => [ - 'label' => __( 'Top Right', 'directorist' ), - 'maxWidget' => 3, - 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', - 'acceptedWidgets' => ['favorite_badge', 'popular_badge', 'featured_badge', 'new_badge'], - ], - 'top_left' => [ - 'maxWidget' => 3, - 'acceptedWidgets' => ['favorite_badge', 'popular_badge', 'featured_badge', 'new_badge'], - ], - 'bottom_right' => [ - 'maxWidget' => 2, - 'acceptedWidgets' => ['favorite_badge', 'popular_badge', 'featured_badge', 'new_badge'], - ], - 'bottom_left' => [ - 'maxWidget' => 3, - 'acceptedWidgets' => ['favorite_badge', 'popular_badge', 'featured_badge', 'new_badge'], - ], - 'avatar' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['user_avatar'], - ], - ], - - 'body' => [ - 'top' => [ - 'maxWidget' => 0, - 'acceptedWidgets' => [ - "listing_title", "favorite_badge", "popular_badge", "featured_badge", "new_badge", "rating", "pricing", "posted_date", - ], - ], - 'bottom' => [ - 'maxWidget' => 0, - 'acceptedWidgets' => [ - 'listings_location', 'phone', 'phone2', 'website', 'zip', 'fax', 'address', 'email', - 'text', 'textarea', 'number', 'url', 'date', 'time', 'color', 'select', 'checkbox', 'radio', 'file', 'posted_date', - ], - ], - 'excerpt' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['excerpt'], - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'excerpt'], - ], - ], - ], - ], - - 'footer' => [ - 'right' => [ - 'maxWidget' => 2, - 'acceptedWidgets' => ['category', 'favorite_badge', 'view_count'], - ], - - 'left' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['category', 'favorite_badge', 'view_count'], - ], - ], - ]; - - $listing_card_grid_view_without_thumbnail_layout = [ - 'body' => [ - 'avatar' => [ - 'label' => __( 'Avatar', 'directorist' ), - 'maxWidget' => 1, - 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', - 'acceptedWidgets' => [ "user_avatar" ], - ], - 'title' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['listing_title'], - ], - 'quick_actions' => [ - 'maxWidget' => 2, - 'acceptedWidgets' => ['favorite_badge'], - ], - 'quick_info' => [ - 'acceptedWidgets' => ['favorite_badge', 'popular_badge', 'featured_badge', 'new_badge', 'rating', 'pricing'], - ], - 'bottom' => [ - 'maxWidget' => 0, - 'acceptedWidgets' => [ - 'listings_location', 'phone', 'phone2', 'website', 'zip', 'fax', 'address', 'email', - 'text', 'textarea', 'number', 'url', 'date', 'time', 'color', 'select', 'checkbox', 'radio', 'file', 'posted_date', - ], - ], - 'excerpt' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['excerpt'], - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'excerpt'], - ], - ], - ], - ], - - 'footer' => [ - 'right' => [ - 'maxWidget' => 2, - 'acceptedWidgets' => ['category', 'favorite_badge', 'view_count'], - ], - - 'left' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['category', 'favorite_badge', 'view_count'], - ], - ], - ]; - - $listing_card_list_view_with_thumbnail_layout = [ - 'thumbnail' => [ - 'top_right' => [ - 'label' => __( 'Top Right', 'directorist' ), - 'maxWidget' => 3, - 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', - 'acceptedWidgets' => ['favorite_badge', 'popular_badge', 'featured_badge', 'new_badge'], - ], - ], - - 'body' => [ - 'top' => [ - 'label' => __( 'Body Top', 'directorist' ), - 'maxWidget' => 0, - 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', - 'acceptedWidgets' => ["listing_title", "favorite_badge", "popular_badge", "featured_badge", "new_badge", "rating", "pricing", "posted_date"], - ], - 'right' => [ - 'label' => __( 'Body Right', 'directorist' ), - 'maxWidget' => 2, - 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', - 'acceptedWidgets' => ['favorite_badge', 'popular_badge', 'featured_badge', 'new_badge'], - ], - 'bottom' => [ - 'label' => __( 'Body Bottom', 'directorist' ), - 'maxWidget' => 0, - 'acceptedWidgets' => [ - 'listings_location', 'phone', 'phone2', 'website', 'zip', 'fax', 'address', 'email', - 'text', 'textarea', 'number', 'url', 'date', 'time', 'color', 'select', 'checkbox', 'radio', 'file', 'posted_date', - ], - ], - 'excerpt' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['excerpt'], - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'excerpt'], - ], - ], - ], - ], - - 'footer' => [ - 'right' => [ - 'maxWidget' => 2, - 'acceptedWidgets' => ['user_avatar', 'category', 'favorite_badge', 'view_count'], - ], - - 'left' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['category', 'favorite_badge', 'view_count'], - ], - ], - ]; - - $listing_card_list_view_without_thumbnail_layout = [ - 'body' => [ - 'top' => [ - 'label' => __( 'Body Top', 'directorist' ), - 'maxWidget' => 0, - 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', - 'acceptedWidgets' => ['listing_title', 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge', 'rating', 'pricing'], - ], - 'right' => [ - 'label' => __( 'Body Right', 'directorist' ), - 'maxWidget' => 2, - 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', - 'acceptedWidgets' => ['favorite_badge', 'popular_badge', 'featured_badge', 'new_badge'], - ], - 'bottom' => [ - 'label' => __( 'Body Bottom', 'directorist' ), - 'maxWidget' => 0, - 'acceptedWidgets' => [ - 'listings_location', 'phone', 'phone2', 'website', 'zip', 'fax', 'address', 'email', - 'text', 'textarea', 'number', 'url', 'date', 'time', 'color', 'select', 'checkbox', 'radio', 'file', 'posted_date', - ], - ], - 'excerpt' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['excerpt'], - 'show_if' => [ - 'where' => 'submission_form_fields.value.fields', - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'excerpt'], - ], - ], - ], - ], - - 'footer' => [ - 'right' => [ - 'maxWidget' => 2, - 'acceptedWidgets' => ['user_avatar', 'category', 'favorite_badge', 'view_count'], - ], - - 'left' => [ - 'maxWidget' => 1, - 'acceptedWidgets' => ['category', 'favorite_badge', 'view_count'], - ], - ], - ]; - - self::$fields = apply_filters( 'atbdp_listing_type_settings_field_list', [ - 'icon' => [ - 'label' => '', - 'type' => 'icon', - 'value' => '', - 'placeholder' => __( 'las la-home', 'directorist' ), - 'rules' => [ - 'required' => false, - ], - ], - 'preview_image' => [ - 'button-label' => __( 'Select', 'directorist' ), - 'type' => 'wp-media-picker', - 'default-img' => DIRECTORIST_ASSETS . 'images/grid.jpg', - 'value' => '', - ], - - 'import_export' => [ - 'button-label' => __( 'Export', 'directorist' ), - 'export-file-name' => 'directory', - 'type' => 'export', - ], - - 'default_expiration' => [ - 'type' => 'number', - 'value' => 30, - 'placeholder' => '365', - 'rules' => [ - 'required' => true, - ], - ], - - 'new_listing_status' => [ - 'label' => __( 'New listing', 'directorist' ), - 'type' => 'select', - 'value' => 'pending', - 'options' => [ - [ - 'label' => __( 'Pending', 'directorist' ), - 'value' => 'pending', - ], - [ - 'label' => __( 'Publish', 'directorist' ), - 'value' => 'publish', - ], - ], - ], - - 'edit_listing_status' => [ - 'label' => __( 'Edited listing', 'directorist' ), - 'type' => 'select', - 'value' => 'pending', - 'options' => [ - [ - 'label' => __( 'Pending', 'directorist' ), - 'value' => 'pending', - ], - [ - 'label' => __( 'Publish', 'directorist' ), - 'value' => 'publish', - ], - ], - ], - - 'global_listing_type' => [ - 'label' => __( 'Global Listing Type', 'directorist' ), - 'type' => 'toggle', - 'value' => '', - ], - - 'submission_form_fields' => apply_filters( 'atbdp_listing_type_form_fields', [ - 'type' => 'form-builder', - 'widgets' => $form_field_widgets, - 'generalSettings' => [ - 'minGroup' => 1, - 'addNewGroupButtonLabel' => __( 'Add Section', 'directorist' ), - 'restricted_fields_warning_text' => __( 'You can not add in this section', 'directorist' ), - ], - 'groupSettings' => [ - 'defaultGroupLabel' => 'Section', - 'disableTrashIfGroupHasWidgets' => [ - ['widget_name' => 'title', 'widget_group' => 'preset'], - ], - ], - 'groupFields' => [ - 'label' => [ - 'type' => 'text', - 'label' => 'Group Name', - 'value' => 'Section', - ], - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Block/Section Icon', 'directorist' ), - 'value' => '', - ], - ], - 'value' => [ - 'fields' => [ - 'title' => [ - 'widget_group' => 'preset', - 'widget_name' => 'title', - 'type' => 'text', - 'field_key' => 'listing_title', - 'required' => true, - 'label' => 'Title', - 'placeholder' => '', - ], - ], - 'groups' => [ - [ - 'label' => 'General Section', - 'lock' => true, - 'fields' => ['title'], - 'plans' => [], - ], - ], - ], - - ] ), - - // Submission Settings - 'enable_sidebar' => [ - 'label' => __('Enable Sidebar', 'directorist'), - 'type' => 'toggle', - 'value' => true, - ], - 'preview_mode' => [ - 'label' => __( 'Enable Listing Preview', 'directorist' ), - 'type' => 'toggle', - 'value' => true, - ], - - // Submit Button - 'submit_button_label_old' => [ - 'label' => __( 'Submit Button Label', 'directorist' ), - 'type' => 'text', - 'value' => __( 'Save & Preview', 'directorist' ), - ], - - 'submit_button_label' => [ - 'label' => __( 'Submit Button Label', 'directorist' ), - 'type' => 'editable-button', - 'value' => __( 'Update', 'directorist' ), - ], - - 'single_listings_contents' => [ - 'type' => 'form-builder', - 'widgets' => $single_listings_contents_widgets, - 'generalSettings' => [ - 'addNewGroupButtonLabel' => __( 'Add Section', 'directorist' ), - ], - 'groupFields' => [ - 'label' => [ - 'type' => 'text', - 'label' => __( 'Label', 'directorist' ), - 'value' => 'Section', - ], - 'icon' => [ - 'type' => 'icon', - 'label' => __( 'Block/Section Icon', 'directorist' ), - 'value' => '', - ], - 'section_id' => [ - 'type' => 'text', - 'disable' => true, - 'label' => 'Section ID', - 'value' => '', - 'field_type' => 'advanced', - ], - 'custom_block_id' => [ - 'type' => 'text', - 'label' => __( 'Custom block ID', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - 'custom_block_classes' => [ - 'type' => 'text', - 'label' => __( 'Custom block Classes', 'directorist' ), - 'value' => '', - 'field_type' => 'advanced', - ], - 'shortcode' => [ - 'type' => 'shortcode-list', - 'label' => __( 'Shortcode', 'directorist' ), - 'description' => __( 'Click the wizerd button to generate the shortcode.', 'directorist' ), - 'buttonLabel' => '<i class="fas fa-magic"></i>', - 'shortcodes' => [ - [ - 'shortcode' => '[directorist_single_listing_section label="@@shortcode_label@@" key="@@shortcode_key@@"]', - 'mapAtts' => [ - [ - 'map' => 'self.section_id', - 'where' => [ - 'key' => 'value', - 'mapTo' => '@@shortcode_key@@', - ], - ], - [ - 'map' => 'self.label', - 'where' => [ - 'key' => 'value', - 'mapTo' => '@@shortcode_label@@', - ], - ], - ], - ], - ], - - 'show_if' => [ - 'where' => 'enable_single_listing_page', - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - - ], - ], - 'value' => [], - ], - 'enable_single_listing_page' => [ - 'type' => 'toggle', - 'label' => __( 'Enable Custom Single Listing Page', 'directorist' ), - 'description' => __( 'Enabling this option will replace the default single listing page. After enabling you must create and assign a new page with generated shortcodes to display single listing content. -', 'directorist' ), - 'labelType' => 'h3', - 'value' => false, - ], - 'single_listing_page' => [ - 'label' => __( 'Single listing page', 'directorist' ), - 'type' => 'select', - 'value' => '', - 'showDefaultOption' => true, - 'options' => directorist_get_all_page_list(), - 'show_if' => [ - 'where' => 'enable_single_listing_page', - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - - 'single_listings_shortcodes' => [ - 'type' => 'shortcode-list', - 'buttonLabel' => '<i class="fas fa-magic"></i>', - 'label' => __( 'Generate shortcodes', 'directorist' ), - 'description' => __( 'Generate single listing shortcodes', 'directorist' ), - 'shortcodes' => [ - '[directorist_single_listings_header]', - [ - 'shortcode' => '[directorist_single_listing_section label="@@shortcode_label@@" key="@@shortcode_key@@"]', - 'mapAtts' => [ - [ - 'mapAll' => 'single_listings_contents.value.groups', - 'where' => [ - [ - 'key' => 'section_id', - 'mapTo' => '@@shortcode_key@@', - ], - [ - 'key' => 'label', - 'mapTo' => '@@shortcode_label@@', - ], - ], - ], - ], - ], - ], - - 'show_if' => [ - 'where' => 'enable_single_listing_page', - 'conditions' => [ - ['key' => 'value', 'compare' => '=', 'value' => true], - ], - ], - ], - - 'search_form_fields' => [ - 'type' => 'form-builder', - 'generalSettings' => [ - 'allowAddNewGroup' => false, - ], - 'groupSettings' => [ - 'defaultGroupLabel' => 'Section', - 'canTrash' => false, - 'draggable' => false, - ], - 'widgets' => $search_form_widgets, - 'value' => [ - 'groups' => [ - [ - 'label' => __( 'Search Bar', 'directorist' ), - 'lock' => true, - 'draggable' => false, - 'fields' => [], - ], - [ - 'label' => __( 'Search Filter', 'directorist' ), - 'lock' => true, - 'draggable' => false, - 'fields' => [], - ], - ], - ], - ], - - 'single_listing_header' => apply_filters( 'directorist_listing_header_layout', [ - 'type' => 'card-builder', - 'template' => 'listing-header', - 'value' => '', - 'card-options' => [ - 'general' => [ - 'back' => [ - 'type' => "badge", - 'label' => __( "Back", 'directorist' ), - 'options' => [ - 'title' => __( "Back Button Settings", "directorist" ), - 'fields' => [ - 'label' => [ - 'type' => "toggle", - 'label' => __( "Enable", "directorist" ), - 'value' => true, - ], - ], - ], - ], - 'section_title' => [ - 'type' => "title", - 'label' => __( "Section Title", "directorist" ), - 'options' => [ - 'title' => __( "Section Title Options", "directorist" ), - 'fields' => [ - 'use_listing_title' => [ - 'type' => "toggle", - 'label' => __( "Use Listing Title", "directorist" ), - 'value' => false, - ], - 'label' => [ - 'type' => "text", - 'label' => __( "Label", "directorist" ), - 'value' => "Section Title", - 'show_if' => [ - 'where' => "single_listing_header.value.options.general.section_title", - 'conditions' => [ - ['key' => 'use_listing_title', 'compare' => '=', 'value' => false], - ], - ], - ], - 'icon' => [ - 'type' => "icon", - 'label' => __( "Icon", "directorist" ), - 'value' => "", - ], - ], - ], - ], - ], - 'content_settings' => [ - 'listing_title' => [ - 'type' => "title", - 'label' => __( "Listing Title", "directorist" ), - 'options' => [ - 'title' => __( "Listing Title Settings", "directorist" ), - 'fields' => [ - 'enable_title' => [ - 'type' => "toggle", - 'label' => __( "Show Title", "directorist" ), - 'value' => true, - ], - 'enable_tagline' => [ - 'type' => "toggle", - 'label' => __( "Show Tagline", "directorist" ), - 'value' => true, - ], - ], - ], - ], - ], - ], - 'options_layout' => [ - 'header' => ['back', 'section_title'], - 'contents_area' => ['title_and_tagline', 'description'], - ], - 'widgets' => [ - 'back' => [ - 'type' => "button", - 'label' => __( "Back", "directorist" ), - 'icon' => 'las la-arrow-left', - ], - 'title' => [ - 'type' => "title", - 'label' => __( "Listing Title", "directorist" ), - 'icon' => 'las la-heading', - 'options' => [ - 'title' => __( "Listing Title Settings", "directorist" ), - 'fields' => [ - 'enable_tagline' => [ - 'type' => "toggle", - 'label' => __( "Show Tagline", "directorist" ), - 'value' => true, - ], - ], - ], - ], - 'slider' => [ - 'type' => "thumbnail", - 'label' => __( "Listing Image/Slider", "directorist" ), - 'icon' => 'las la-image', - 'options' => [ - 'title' => __( "Image/Slider Settings", "directorist" ), - 'fields' => [ - 'footer_thumbnail' => [ - 'type' => "toggle", - 'label' => __( "Show Thumbnail", "directorist" ), - 'value' => true, - ], - ], - ], - ], - - 'bookmark' => [ - 'type' => "button", - 'label' => __( "Bookmark", "directorist" ), - 'icon' => 'las la-bookmark', - ], - 'share' => [ - 'type' => "badge", - 'label' => __( "Share", "directorist" ), - 'icon' => 'las la-share', - 'options' => [ - 'title' => __( "Share Settings", "directorist" ), - 'fields' => [ - 'share_icon' => [ - 'type' => "icon", - 'label' => __( "Icon", "directorist" ), - 'value' => 'las la-share', - ], - ], - ], - ], - 'report' => [ - 'type' => "badge", - 'label' => __( "Report", "directorist" ), - 'icon' => 'las la-flag', - 'options' => [ - 'title' => __( "Report Settings", "directorist" ), - 'fields' => [ - 'report_icon' => [ - 'type' => "icon", - 'label' => __( "Icon", "directorist" ), - 'value' => 'las la-flag', - ], - ], - ], - ], - - 'price' => [ - 'type' => "badge", - 'label' => __( "Pricing", "directorist" ), - 'icon' => 'uil uil-text-fields', - ], - 'badges' => [ - 'type' => "badge", - 'label' => __( "Badges", "directorist" ), - 'icon' => 'uil uil-text-fields', - 'options' => [ - 'title' => __( "Badge Settings", "directorist" ), - 'fields' => [ - 'new_badge' => [ - 'type' => "toggle", - 'label' => __( "Display New Badge", "directorist" ), - 'value' => true, - ], - 'popular_badge' => [ - 'type' => "toggle", - 'label' => __( "Display Popular Badge", "directorist" ), - 'value' => true, - ], - 'featured_badge' => [ - 'type' => "toggle", - 'label' => __( "Display Featured Badge", "directorist" ), - 'value' => true, - ], - ], - ], - ], - 'ratings_count' => [ - 'type' => "ratings-count", - 'label' => __( "Rating", "directorist" ), - 'icon' => 'uil uil-text-fields', - ], - 'category' => [ - 'type' => "badge", - 'label' => __( "Listings Category", "directorist" ), - 'icon' => 'uil uil-text-fields', - 'show_if' => [ - 'where' => "submission_form_fields.value.fields", - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'category'], - ], - ], - ], - 'location' => [ - 'type' => "badge", - 'label' => __( "Listings Location", "directorist" ), - 'icon' => 'uil uil-text-fields', - 'show_if' => [ - 'where' => "submission_form_fields.value.fields", - 'conditions' => [ - ['key' => '_any.widget_name', 'compare' => '=', 'value' => 'location'], - ], - ], - ], - ], - - 'layout' => [ - [ - 'type' => 'placeholder_group', - 'placeholderKey' => 'quick-widgets-placeholder', - 'placeholders' => [ - [ - 'type' => 'placeholder_item', - 'placeholderKey' => 'quick-info-placeholder', - 'label' => __( 'Quick info', 'directorist' ), - 'maxWidget' => 1, - 'maxWidgetInfoText' => "Up to __DATA__ item{s} can be added", - 'acceptedWidgets' => ['back'], - ], - [ - 'type' => 'placeholder_item', - 'placeholderKey' => 'quick-action-placeholder', - 'label' => __( 'Quick Action', 'directorist' ), - 'maxWidget' => 0, - 'maxWidgetInfoText' => "Up to __DATA__ item{s} can be added", - 'acceptedWidgets' => [ 'bookmark', 'share', 'report' ], - ], - ], - ], - [ - 'type' => 'placeholder_item', - 'placeholderKey' => 'listing-title-placeholder', - 'label' => __( 'Listing Title', 'directorist' ), - 'maxWidget' => 1, - 'maxWidgetInfoText' => "Up to __DATA__ item{s} can be added", - 'acceptedWidgets' => ['title'], - ], - [ - 'type' => 'placeholder_item', - 'placeholderKey' => 'more-widgets-placeholder', - 'label' => __( 'More Widgets', 'directorist' ), - 'maxWidget' => 0, - 'maxWidgetInfoText' => "Up to __DATA__ item{s} can be added", - 'acceptedWidgets' => [ 'location', 'category', 'ratings_count', 'badges', 'price' ], - 'rejectedWidgets' => ['slider'], - ], - [ - 'type' => 'placeholder_item', - 'label' => 'Slider Widget', - 'placeholderKey' => 'slider-placeholder', - 'selectedWidgets' => ['slider'], - 'acceptedWidgets' => ['slider'], - 'maxWidget' => 1, - 'canDelete' => true, - 'insertByButton' => true, - 'insertButton' => [ - 'label' => 'Add Image/Slider' - ], - ], - ], - ] ), - - 'listings_card_grid_view' => apply_filters( 'directorist_listing_card_layouts', [ - 'type' => 'card-builder', - 'card_templates' => [ - 'grid_view_with_thumbnail' => [ - 'label' => __( 'With Preview Image', 'directorist' ), - 'template' => 'grid-view-with-thumbnail', - 'widgets' => $listing_card_widget, - 'layout' => $listing_card_grid_view_with_thumbnail_layout, - ], - 'grid_view_without_thumbnail' => [ - 'label' => __( 'Without Preview Image', 'directorist' ), - 'template' => 'grid-view-without-thumbnail', - 'widgets' => $listing_card_conditional_widget, - 'layout' => $listing_card_grid_view_without_thumbnail_layout, - ], - ], - ] ), - - 'listings_card_list_view' => apply_filters( 'directorist_listing_list_layouts', [ - 'type' => 'card-builder', - 'card_templates' => [ - 'list_view_with_thumbnail' => [ - 'label' => __( 'With Preview Image', 'directorist' ), - 'template' => 'list-view-with-thumbnail', - 'widgets' => $listing_card_conditional_widget, - 'layout' => $listing_card_list_view_with_thumbnail_layout, - ], - 'list_view_without_thumbnail' => [ - 'label' => __( 'Without Preview Image', 'directorist' ), - 'template' => 'list-view-without-thumbnail', - 'widgets' => $listing_card_conditional_widget, - 'layout' => $listing_card_list_view_without_thumbnail_layout, - ], - ], - ] ), - - ] ); - - self::$layouts = apply_filters( 'directorist_builder_layouts', [ - 'general' => [ - 'label' => 'General', - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + protected static $fields = array(); + protected static $layouts = array(); + protected static $config = array(); + protected static $options = array(); + + public function __construct() { + self::prepare_data(); + } + + protected static function prepare_data() { + $form_field_widgets = array( + 'preset' => array( + 'title' => __( 'Preset Fields', 'directorist' ), + 'description' => __( 'Click on a field to use it', 'directorist' ), + 'allowMultiple' => false, + 'widgets' => require_once __DIR__ . '/builder-preset-fields.php', + ), + + 'custom' => array( + 'title' => __( 'Custom Fields', 'directorist' ), + 'description' => __( 'Click on a field type you want to create.', 'directorist' ), + 'allowMultiple' => true, + 'widgets' => require_once __DIR__ . '/builder-custom-fields.php', + + ), + ); + + $single_listings_contents_widgets = array( + 'preset_widgets' => array( + 'title' => __( 'Preset Fields', 'directorist' ), + 'description' => __( 'Click on a field to use it', 'directorist' ), + 'allowMultiple' => false, + 'template' => 'submission_form_fields', + 'widgets' => apply_filters( + 'atbdp_single_listing_content_widgets', + array( + + 'image_upload' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-tag', + ), + 'footer_thumbnail' => array( + 'type' => 'toggle', + 'label' => __( 'Footer Thumbnail', 'directorist' ), + 'value' => true, + ), + ), + ), + 'description' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-tag', + ), + ), + ), + + 'tag' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-tag', + ), + ), + ), + 'address' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-map', + ), + 'address_link_with_map' => array( + 'type' => 'toggle', + 'label' => __( 'Address Linked with Map', 'directorist' ), + 'value' => false, + ), + ), + ), + 'map' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-map', + ), + ), + ), + 'zip' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-street-view', + ), + ), + ), + 'phone' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-phone', + ), + ), + ), + 'phone2' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-phone', + ), + ), + ), + 'fax' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-fax', + ), + ), + ), + 'email' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-envelope', + ), + ), + ), + 'website' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-globe', + ), + 'use_nofollow' => array( + 'type' => 'toggle', + 'label' => __( 'Use rel="nofollow" in Website Link', 'directorist' ), + 'value' => false, + ), + ), + ), + 'social_info' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-share-alt', + ), + ), + ), + 'video' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-video', + ), + ), + ), + 'text' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-text-height', + ), + ), + ), + 'textarea' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-align-center', + ), + ), + ), + 'number' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-list-ol', + ), + ), + ), + 'url' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-link', + ), + ), + ), + 'date' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-calendar', + ), + ), + ), + 'time' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-clock', + ), + ), + ), + 'color_picker' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-palette', + ), + ), + ), + 'select' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-clipboard-check', + ), + ), + ), + 'checkbox' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-check-square', + ), + ), + ), + 'radio' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-circle', + ), + ), + ), + 'file' => array( + 'options' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-file-alt', + ), + ), + ), + ) + ), + ), + 'other_widgets' => array( + 'title' => __( 'Other Fields', 'directorist' ), + 'description' => __( 'Click on a field to use it', 'directorist' ), + 'allowMultiple' => false, + 'widgets' => apply_filters( + 'atbdp_single_listing_other_fields_widget', + array( + 'custom_content' => array( + 'type' => 'widget', + 'label' => __( 'Custom Content', 'directorist' ), + 'icon' => 'las la-align-right', + 'allowMultiple' => true, + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => '', + ), + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => '', + ), + 'content' => array( + 'type' => 'textarea', + 'label' => __( 'Content', 'directorist' ), + 'value' => '', + 'description' => __( 'You can use any text or shortcode', 'directorist' ), + ), + ), + ), + 'review' => array( + 'type' => 'section', + 'label' => __( 'Review', 'directorist' ), + 'icon' => 'las la-star', + 'options' => array( + 'custom_block_id' => array( + 'type' => 'text', + 'label' => __( 'Custom block ID', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + 'custom_block_classes' => array( + 'type' => 'text', + 'label' => __( 'Custom block Classes', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + 'review_cookies_consent' => array( + 'label' => __( 'Show Cookies Consent', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'review_enable_gdpr_consent' => array( + 'label' => __( 'Enable GDPR Consent', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'review_gdpr_consent_label' => array( + 'label' => __( 'Consent Label', 'directorist' ), + 'type' => 'textarea', + 'editor' => 'wp_editor', + 'editorID' => 'wp_editor_terms_privacy', + 'value' => sprintf( + __( 'I have read and agree to the <a href="%1$s" target="_blank">Privacy Policy</a> and <a href="%2$s" target="_blank">Terms of Service</a>', 'directorist' ), + ATBDP_Permalink::get_privacy_policy_page_url(), + ATBDP_Permalink::get_terms_and_conditions_page_url(), + ), + ), + ), + + 'accepted_widgets' => array( + array( + 'widget_group' => 'other_widgets', + 'widget_name' => 'review', + 'widget_child_name' => 'review_comment', + ), + array( + 'widget_group' => 'other_widgets', + 'widget_name' => 'review', + 'widget_child_name' => 'review_email', + ), + array( + 'widget_group' => 'other_widgets', + 'widget_name' => 'review', + 'widget_child_name' => 'review_name', + ), + array( + 'widget_group' => 'other_widgets', + 'widget_name' => 'review', + 'widget_child_name' => 'review_website', + ), + ), + 'widgets' => array( + 'review_comment' => array( + 'label' => __( 'Comment', 'directorist' ), + 'canTrash' => false, + 'canMove' => false, + 'options' => array( + 'placeholder' => array( + 'label' => __( 'Placeholder', 'directorist' ), + 'type' => 'text', + 'value' => '', + ), + ), + ), + 'review_email' => array( + 'label' => __( 'Email', 'directorist' ), + 'canTrash' => false, + 'canMove' => false, + 'options' => array( + 'label' => array( + 'label' => __( 'Label', 'directorist' ), + 'type' => 'text', + 'value' => '', + ), + 'placeholder' => array( + 'label' => __( 'Placeholder', 'directorist' ), + 'type' => 'text', + 'value' => '', + ), + ), + ), + 'review_name' => array( + 'label' => __( 'Name', 'directorist' ), + 'canTrash' => false, + 'canMove' => false, + 'options' => array( + 'label' => array( + 'label' => __( 'Label', 'directorist' ), + 'type' => 'text', + 'value' => '', + ), + 'placeholder' => array( + 'label' => __( 'Placeholder', 'directorist' ), + 'type' => 'text', + 'value' => '', + ), + ), + ), + 'review_website' => array( + 'label' => __( 'Website', 'directorist' ), + 'canTrash' => false, + 'canMove' => false, + 'options' => array( + 'enable' => array( + 'label' => __( 'Show Website Field?', 'directorist' ), + 'type' => 'toggle', + 'value' => false, + ), + 'label' => array( + 'label' => __( 'Label', 'directorist' ), + 'type' => 'text', + 'value' => '', + ), + 'placeholder' => array( + 'label' => __( 'Placeholder', 'directorist' ), + 'type' => 'text', + 'value' => '', + ), + ), + ), + ), + + ), + 'author_info' => array( + 'type' => 'section', + 'label' => __( 'Author Info', 'directorist' ), + 'icon' => 'las la-user', + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Author Info', + ), + 'display_email' => array( + 'type' => 'toggle', + 'label' => __( 'Display Email', 'directorist' ), + 'value' => true, + ), + 'custom_block_id' => array( + 'type' => 'text', + 'label' => __( 'Custom block ID', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + 'custom_block_classes' => array( + 'type' => 'text', + 'label' => __( 'Custom block Classes', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + ), + ), + 'contact_listings_owner' => array( + 'type' => 'section', + 'label' => __( 'Contact Listings Owner Form', 'directorist' ), + 'icon' => 'las la-phone', + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Contact Listings Owner Form', + ), + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-phone', + ), + 'custom_block_id' => array( + 'type' => 'text', + 'label' => __( 'Custom block ID', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + 'custom_block_classes' => array( + 'type' => 'text', + 'label' => __( 'Custom block Classes', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + ), + 'accepted_widgets' => array( + array( + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_name', + ), + array( + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_email', + ), + array( + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_message', + ), + ), + 'widgets' => array( + 'contact_name' => array( + 'label' => __( 'Name', 'directorist' ), + 'canTrash' => false, + 'canMove' => false, + 'options' => array( + 'enable' => array( + 'label' => __( 'Enable', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'placeholder' => array( + 'label' => __( 'Placeholder', 'directorist' ), + 'type' => 'text', + 'value' => __( 'Name', 'directorist' ), + ), + ), + ), + 'contact_email' => array( + 'label' => __( 'Email', 'directorist' ), + 'canTrash' => false, + 'canMove' => false, + 'options' => array( + 'placeholder' => array( + 'label' => __( 'Placeholder', 'directorist' ), + 'type' => 'text', + 'value' => __( 'Email', 'directorist' ), + ), + ), + ), + 'contact_message' => array( + 'label' => __( 'Message', 'directorist' ), + 'canTrash' => false, + 'canMove' => false, + 'options' => array( + 'placeholder' => array( + 'label' => __( 'Placeholder', 'directorist' ), + 'type' => 'text', + 'value' => __( 'Message...', 'directorist' ), + ), + ), + ), + ), + ), + 'related_listings' => array( + 'type' => 'section', + 'label' => __( 'Related Listings', 'directorist' ), + 'icon' => 'las la-copy', + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Related Listings', + ), + 'custom_block_id' => array( + 'type' => 'text', + 'label' => __( 'Custom block ID', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + 'custom_block_classes' => array( + 'type' => 'text', + 'label' => __( 'Custom block Classes', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + 'similar_listings_logics' => array( + 'type' => 'radio', + 'name' => 'similar_listings_logics', + 'label' => __( 'Related listings criteria', 'directorist' ), + 'options' => array( + array( + 'id' => 'match_category_nd_location', + 'label' => __( 'Match both category and tag', 'directorist' ), + 'value' => 'AND', + ), + array( + 'id' => 'match_category_or_location', + 'label' => __( 'Match either category or tag', 'directorist' ), + 'value' => 'OR', + ), + ), + 'value' => 'OR', + ), + 'listing_from_same_author' => array( + 'type' => 'toggle', + 'label' => __( 'Display listings by the same author', 'directorist' ), + 'value' => false, + ), + 'similar_listings_number_of_listings_to_show' => array( + 'type' => 'range', + 'min' => 0, + 'max' => 20, + 'label' => __( 'Number of listings to display', 'directorist' ), + 'value' => 3, + ), + 'similar_listings_number_of_columns' => array( + 'type' => 'range', + 'min' => 1, + 'max' => 4, + 'label' => __( 'Number of columns', 'directorist' ), + 'value' => 2, + ), + ), + ), + ) + ), + ), + ); + + $search_form_widgets = apply_filters( + 'directorist_search_form_widgets', + array( + 'available_widgets' => array( + 'title' => __( 'Preset Fields', 'directorist' ), + 'description' => __( 'Click on a field to use it', 'directorist' ), + 'allowMultiple' => false, + 'template' => 'submission_form_fields', + 'widgets' => array( + 'title' => array( + 'label' => __( 'Search Box', 'directorist' ), + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'label', 'directorist' ), + 'value' => 'Title', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'What are you looking for?', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + ), + + 'category' => array( + 'options' => array( + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => '', + 'sync' => false, + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Category', + ), + ), + ), + + 'location' => array( + 'options' => array( + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Location', + 'sync' => false, + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Location', + ), + 'location_source' => array( + 'type' => 'select', + 'label' => __( 'Location Source', 'directorist' ), + 'options' => array( + array( + 'label' => __( 'Display from Listing Location', 'directorist' ), + 'value' => 'from_listing_location', + ), + array( + 'label' => __( 'Display from Map API', 'directorist' ), + 'value' => 'from_map_api', + ), + ), + 'value' => 'from_map_api', + ), + ), + ), + + 'tag' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + ), + ), + + 'pricing' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Pricing', + ), + 'price_range_min_placeholder' => array( + 'type' => 'text', + 'label' => __( 'Price Range Min Placeholder', 'directorist' ), + 'value' => 'Min', + ), + 'price_range_max_placeholder' => array( + 'type' => 'text', + 'label' => __( 'Price Range Max Placeholder', 'directorist' ), + 'value' => 'Max', + ), + ), + ), + + 'zip' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Zip', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + ), + + 'phone' => array( + 'draggable' => false, + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Phone', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + ), + + 'phone2' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Phone 2', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + ), + + 'email' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Email', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + ), + + 'fax' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Fax', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Fax', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + ), + + 'website' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Website', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + ), + + 'text' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Text', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + 'number' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Number', + ), + 'type' => array( + 'type' => 'select', + 'label' => __( 'Search Type', 'directorist' ), + 'value' => 'number', + 'options' => array( + array( + 'value' => 'number', + 'label' => 'Input', + ), + array( + 'value' => 'range', + 'label' => 'Range', + ), + array( + 'value' => 'dropdown', + 'label' => 'Dropdown', + ), + array( + 'value' => 'radio', + 'label' => 'Radio', + ), + ), + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + + 'url' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'URL', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + + 'date' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Date', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + + 'time' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Time', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + + 'color_picker' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + + 'select' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'placeholder' => array( + 'type' => 'text', + 'label' => __( 'Placeholder', 'directorist' ), + 'value' => 'Select', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + + 'checkbox' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + + 'radio' => array( + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Tag', + ), + 'required' => array( + 'type' => 'toggle', + 'label' => __( 'Required', 'directorist' ), + 'value' => false, + ), + ), + + ), + + ), + ), + 'other_widgets' => array( + 'title' => __( 'Other Fields', 'directorist' ), + 'description' => __( 'Click on a field to use it', 'directorist' ), + 'allowMultiple' => false, + 'widgets' => array( + 'review' => array( + 'label' => 'Review', + 'icon' => 'las la-star', + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Review', + ), + ), + ), + 'radius_search' => array( + 'label' => __( 'Radius Search', 'directorist' ), + 'icon' => 'las la-map', + 'options' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Radius Search', + ), + 'default_radius_distance' => array( + 'type' => 'range', + 'label' => __( 'Default Radius Distance', 'directorist' ), + 'min' => 0, + 'max' => apply_filters( 'directorist_search_default_radius_distance', 750 ), + 'value' => 0, + ), + 'max_radius_distance' => array( + 'type' => 'range', + 'label' => __( 'Maximum Radius Distance', 'directorist' ), + 'min' => 0, + 'max' => 10000, + 'value' => 1000, + ), + 'radius_search_unit' => array( + 'type' => 'select', + 'label' => __( 'Radius Search Unit', 'directorist' ), + 'value' => 'miles', + 'options' => array( + array( + 'value' => 'miles', + 'label' => 'Miles', + ), + array( + 'value' => 'kilometers', + 'label' => 'Kilometers', + ), + ), + ), + 'radius_search_based_on' => array( + 'type' => 'radio', + 'label' => __( 'Radius Search Based on', 'directorist' ), + 'value' => 'address', + 'options' => array( + array( + 'value' => 'address', + 'label' => 'Address', + ), + array( + 'value' => 'zip', + 'label' => 'Zip Code', + ), + ), + ), + ), + ), + ), + ), + ) + ); + + $listing_card_widget = apply_filters( + 'directorist_listing_card_widgets', + array( + 'listing_title' => array( + 'type' => 'title', + 'label' => __( 'Listing Title', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_listing_title', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'title', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listing Title Settings', 'directorist' ), + 'fields' => array( + 'show_tagline' => array( + 'type' => 'toggle', + 'label' => __( 'Show Tagline', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'excerpt' => array( + 'type' => 'excerpt', + 'label' => __( 'Excerpt', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_listing_excerpt', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'excerpt', + ), + ), + ), + 'options' => array( + 'title' => __( 'Excerpt Settings', 'directorist' ), + 'fields' => array( + 'words_limit' => array( + 'type' => 'range', + 'label' => __( 'Words Limit', 'directorist' ), + 'min' => 5, + 'max' => 200, + 'value' => 20, + ), + 'show_readmore' => array( + 'type' => 'toggle', + 'label' => __( 'Show Readmore', 'directorist' ), + 'value' => true, + ), + 'show_readmore_text' => array( + 'type' => 'text', + 'label' => __( 'Read More Text', 'directorist' ), + 'value' => '...', + ), + ), + ), + ), + + 'listings_location' => array( + 'type' => 'list-item', + 'label' => __( 'Listings Location', 'directorist' ), + 'icon' => 'uil uil-location-point', + 'hook' => 'atbdp_listings_location', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'location', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listings Location Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-map-marker', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'posted_date' => array( + 'type' => 'list-item', + 'label' => __( 'Posted Date', 'directorist' ), + 'icon' => 'las la-clock', + 'hook' => 'atbdp_listings_posted_date', + 'options' => array( + 'title' => __( 'Posted Date', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-clock', + ), + 'date_type' => array( + 'type' => 'radio', + 'label' => __( 'Date Type', 'directorist' ), + 'options' => array( + array( + 'id' => 'atbdp_days_ago', + 'label' => 'Days Ago', + 'value' => 'days_ago', + ), + array( + 'id' => 'atbdp_posted_date', + 'label' => 'Posted Date', + 'value' => 'post_date', + ), + ), + 'value' => 'post_date', + ), + ), + ), + ), + + 'website' => array( + 'type' => 'list-item', + 'label' => __( 'Listings Website', 'directorist' ), + 'icon' => 'las la-globe', + 'hook' => 'atbdp_listings_website', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'website', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listings Website Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-globe', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'zip' => array( + 'type' => 'list-item', + 'label' => __( 'Listings Zip', 'directorist' ), + 'icon' => 'las la-at', + 'hook' => 'atbdp_listings_zip', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'zip', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listings Zip Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-at', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'email' => array( + 'type' => 'list-item', + 'label' => __( 'Listings Email', 'directorist' ), + 'icon' => 'las la-envelope', + 'hook' => 'atbdp_listings_email', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'email', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listings Email Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-envelope', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'fax' => array( + 'type' => 'list-item', + 'label' => __( 'Listings Fax', 'directorist' ), + 'icon' => 'las la-fax', + 'hook' => 'atbdp_listings_fax', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'fax', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listings Fax Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-fax', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'phone' => array( + 'type' => 'list-item', + 'label' => __( 'Listings Phone', 'directorist' ), + 'icon' => 'las la-phone', + 'hook' => 'atbdp_listings_phone', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'phone', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listings Phone Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-phone', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'phone2' => array( + 'type' => 'list-item', + 'label' => __( 'Listings Phone 2', 'directorist' ), + 'icon' => 'las la-phone', + 'hook' => 'atbdp_listings_phone2', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'phone2', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listings Phone 2 Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-phone', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'address' => array( + 'type' => 'list-item', + 'label' => __( 'Listings Address', 'directorist' ), + 'icon' => 'las la-map-marker', + 'hook' => 'atbdp_listings_map_address', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'address', + ), + ), + ), + 'options' => array( + 'title' => __( 'Listings Address Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-map-marker', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'pricing' => array( + 'type' => 'price', + 'label' => __( 'Pricing', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_single_listings_price', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'pricing', + ), + ), + ), + ), + + 'rating' => array( + 'type' => 'rating', + 'label' => __( 'Rating', 'directorist' ), + 'hook' => 'atbdp_listings_rating', + 'icon' => 'uil uil-text-fields', + ), + + 'featured_badge' => array( + 'type' => 'badge', + 'label' => __( 'Featured', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_featured_badge', + ), + + 'new_badge' => array( + 'type' => 'badge', + 'label' => __( 'New', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_new_badge', + ), + + 'popular_badge' => array( + 'type' => 'badge', + 'label' => __( 'Popular', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_popular_badge', + ), + + 'favorite_badge' => array( + 'type' => 'icon', + 'label' => __( 'Favorite', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_favorite_badge', + ), + + 'view_count' => array( + 'type' => 'view-count', + 'label' => __( 'View Count', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_view_count', + 'options' => array( + 'title' => __( 'View Count Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-heart', + ), + ), + ), + ), + + 'category' => array( + 'type' => 'category', + 'label' => __( 'Category', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_category', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'category', + ), + ), + ), + 'options' => array( + 'title' => __( 'Category Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-folder', + ), + ), + ), + ), + + 'user_avatar' => array( + 'type' => 'avatar', + 'label' => __( 'User Avatar', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'hook' => 'atbdp_user_avatar', + 'can_move' => false, + 'options' => array( + 'title' => __( 'User Avatar Settings', 'directorist' ), + 'fields' => array( + 'align' => array( + 'type' => 'radio', + 'label' => __( 'Align', 'directorist' ), + 'value' => 'center', + 'options' => array( + array( + 'id' => 'atbdp_user_avatar_align_right', + 'label' => __( 'Right', 'directorist' ), + 'value' => 'right', + ), + array( + 'id' => 'atbdp_user_avatar_align_center', + 'label' => __( 'Center', 'directorist' ), + 'value' => 'center', + ), + array( + 'id' => 'atbdp_user_avatar_align_left', + 'label' => __( 'Left', 'directorist' ), + 'value' => 'left', + ), + ), + ), + ), + ), + ), + + // Custom Fields + 'text' => array( + 'type' => 'list-item', + 'label' => __( 'Text', 'directorist' ), + 'icon' => 'las la-comment', + 'hook' => 'atbdp_custom_text', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'text', + ), + ), + ), + 'options' => array( + 'title' => __( 'Text Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-comment', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'number' => array( + 'type' => 'list-item', + 'label' => __( 'Number', 'directorist' ), + 'icon' => 'las la-file-word', + 'hook' => 'atbdp_custom_number', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'number', + ), + ), + ), + 'options' => array( + 'title' => 'Number Settings', + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-file-word', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'url' => array( + 'type' => 'list-item', + 'label' => __( 'URL', 'directorist' ), + 'icon' => 'las la-link', + 'hook' => 'atbdp_custom_url', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'url', + ), + ), + ), + 'options' => array( + 'title' => __( 'URL Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-link', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'date' => array( + 'type' => 'list-item', + 'label' => __( 'Date', 'directorist' ), + 'icon' => 'las la-calendar-check', + 'hook' => 'atbdp_custom_date', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'date', + ), + ), + ), + 'options' => array( + 'title' => __( 'Date Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-calendar-check', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'time' => array( + 'type' => 'list-item', + 'label' => __( 'Time', 'directorist' ), + 'icon' => 'las la-clock', + 'hook' => 'atbdp_custom_time', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'time', + ), + ), + ), + 'options' => array( + 'title' => __( 'Time Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-clock', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'color_picker' => array( + 'type' => 'list-item', + 'label' => __( 'Color Picker', 'directorist' ), + 'icon' => 'las la-palette', + 'hook' => 'atbdp_custom_color', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'color', + ), + ), + ), + 'options' => array( + 'title' => __( 'Color Picker Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-palette', + ), + ), + ), + ), + + 'select' => array( + 'type' => 'list-item', + 'label' => __( 'Select', 'directorist' ), + 'icon' => 'las la-check-circle', + 'hook' => 'atbdp_custom_select', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'select', + ), + ), + ), + 'options' => array( + 'title' => __( 'Select Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-check-circle', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'checkbox' => array( + 'type' => 'list-item', + 'label' => __( 'Checkbox', 'directorist' ), + 'icon' => 'las la-check-square', + 'hook' => 'atbdp_custom_checkbox', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'checkbox', + ), + ), + ), + 'options' => array( + 'title' => 'Checkbox Settings', + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-check-square', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + + 'radio' => array( + 'type' => 'list-item', + 'label' => __( 'Radio', 'directorist' ), + 'icon' => 'las la-circle', + 'hook' => 'atbdp_custom_radio', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'radio', + ), + ), + ), + 'options' => array( + 'title' => __( 'Radio Settings', 'directorist' ), + 'fields' => array( + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-circle', + ), + 'show_label' => array( + 'type' => 'toggle', + 'label' => __( 'Show Label', 'directorist' ), + 'value' => false, + ), + ), + ), + ), + ) + ); + + $listing_card_conditional_widget = $listing_card_widget; + + if ( ! empty( $listing_card_conditional_widget['user_avatar'] ) ) { + $listing_card_conditional_widget['user_avatar']['can_move'] = true; + + if ( ! empty( $listing_card_conditional_widget['user_avatar']['options'] ) ) { + unset( $listing_card_conditional_widget['user_avatar']['options'] ); + } + } + + // Card Layouts + $listing_card_grid_view_with_thumbnail_layout = array( + 'thumbnail' => array( + 'top_right' => array( + 'label' => __( 'Top Right', 'directorist' ), + 'maxWidget' => 3, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge' ), + ), + 'top_left' => array( + 'maxWidget' => 3, + 'acceptedWidgets' => array( 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge' ), + ), + 'bottom_right' => array( + 'maxWidget' => 2, + 'acceptedWidgets' => array( 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge' ), + ), + 'bottom_left' => array( + 'maxWidget' => 3, + 'acceptedWidgets' => array( 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge' ), + ), + 'avatar' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'user_avatar' ), + ), + ), + + 'body' => array( + 'top' => array( + 'maxWidget' => 0, + 'acceptedWidgets' => array( + 'listing_title', + 'favorite_badge', + 'popular_badge', + 'featured_badge', + 'new_badge', + 'rating', + 'pricing', + 'posted_date', + ), + ), + 'bottom' => array( + 'maxWidget' => 0, + 'acceptedWidgets' => array( + 'listings_location', + 'phone', + 'phone2', + 'website', + 'zip', + 'fax', + 'address', + 'email', + 'text', + 'textarea', + 'number', + 'url', + 'date', + 'time', + 'color', + 'select', + 'checkbox', + 'radio', + 'file', + 'posted_date', + ), + ), + 'excerpt' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'excerpt' ), + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'excerpt', + ), + ), + ), + ), + ), + + 'footer' => array( + 'right' => array( + 'maxWidget' => 2, + 'acceptedWidgets' => array( 'category', 'favorite_badge', 'view_count' ), + ), + + 'left' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'category', 'favorite_badge', 'view_count' ), + ), + ), + ); + + $listing_card_grid_view_without_thumbnail_layout = array( + 'body' => array( + 'avatar' => array( + 'label' => __( 'Avatar', 'directorist' ), + 'maxWidget' => 1, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'user_avatar' ), + ), + 'title' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'listing_title' ), + ), + 'quick_actions' => array( + 'maxWidget' => 2, + 'acceptedWidgets' => array( 'favorite_badge' ), + ), + 'quick_info' => array( + 'acceptedWidgets' => array( 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge', 'rating', 'pricing' ), + ), + 'bottom' => array( + 'maxWidget' => 0, + 'acceptedWidgets' => array( + 'listings_location', + 'phone', + 'phone2', + 'website', + 'zip', + 'fax', + 'address', + 'email', + 'text', + 'textarea', + 'number', + 'url', + 'date', + 'time', + 'color', + 'select', + 'checkbox', + 'radio', + 'file', + 'posted_date', + ), + ), + 'excerpt' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'excerpt' ), + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'excerpt', + ), + ), + ), + ), + ), + + 'footer' => array( + 'right' => array( + 'maxWidget' => 2, + 'acceptedWidgets' => array( 'category', 'favorite_badge', 'view_count' ), + ), + + 'left' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'category', 'favorite_badge', 'view_count' ), + ), + ), + ); + + $listing_card_list_view_with_thumbnail_layout = array( + 'thumbnail' => array( + 'top_right' => array( + 'label' => __( 'Top Right', 'directorist' ), + 'maxWidget' => 3, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge' ), + ), + ), + + 'body' => array( + 'top' => array( + 'label' => __( 'Body Top', 'directorist' ), + 'maxWidget' => 0, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'listing_title', 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge', 'rating', 'pricing', 'posted_date' ), + ), + 'right' => array( + 'label' => __( 'Body Right', 'directorist' ), + 'maxWidget' => 2, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge' ), + ), + 'bottom' => array( + 'label' => __( 'Body Bottom', 'directorist' ), + 'maxWidget' => 0, + 'acceptedWidgets' => array( + 'listings_location', + 'phone', + 'phone2', + 'website', + 'zip', + 'fax', + 'address', + 'email', + 'text', + 'textarea', + 'number', + 'url', + 'date', + 'time', + 'color', + 'select', + 'checkbox', + 'radio', + 'file', + 'posted_date', + ), + ), + 'excerpt' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'excerpt' ), + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'excerpt', + ), + ), + ), + ), + ), + + 'footer' => array( + 'right' => array( + 'maxWidget' => 2, + 'acceptedWidgets' => array( 'user_avatar', 'category', 'favorite_badge', 'view_count' ), + ), + + 'left' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'category', 'favorite_badge', 'view_count' ), + ), + ), + ); + + $listing_card_list_view_without_thumbnail_layout = array( + 'body' => array( + 'top' => array( + 'label' => __( 'Body Top', 'directorist' ), + 'maxWidget' => 0, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'listing_title', 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge', 'rating', 'pricing' ), + ), + 'right' => array( + 'label' => __( 'Body Right', 'directorist' ), + 'maxWidget' => 2, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'favorite_badge', 'popular_badge', 'featured_badge', 'new_badge' ), + ), + 'bottom' => array( + 'label' => __( 'Body Bottom', 'directorist' ), + 'maxWidget' => 0, + 'acceptedWidgets' => array( + 'listings_location', + 'phone', + 'phone2', + 'website', + 'zip', + 'fax', + 'address', + 'email', + 'text', + 'textarea', + 'number', + 'url', + 'date', + 'time', + 'color', + 'select', + 'checkbox', + 'radio', + 'file', + 'posted_date', + ), + ), + 'excerpt' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'excerpt' ), + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'excerpt', + ), + ), + ), + ), + ), + + 'footer' => array( + 'right' => array( + 'maxWidget' => 2, + 'acceptedWidgets' => array( 'user_avatar', 'category', 'favorite_badge', 'view_count' ), + ), + + 'left' => array( + 'maxWidget' => 1, + 'acceptedWidgets' => array( 'category', 'favorite_badge', 'view_count' ), + ), + ), + ); + + self::$fields = apply_filters( + 'atbdp_listing_type_settings_field_list', + array( + 'icon' => array( + 'label' => '', + 'type' => 'icon', + 'value' => '', + 'placeholder' => __( 'las la-home', 'directorist' ), + 'rules' => array( + 'required' => false, + ), + ), + 'preview_image' => array( + 'button-label' => __( 'Select', 'directorist' ), + 'type' => 'wp-media-picker', + 'default-img' => DIRECTORIST_ASSETS . 'images/grid.jpg', + 'value' => '', + ), + + 'import_export' => array( + 'button-label' => __( 'Export', 'directorist' ), + 'export-file-name' => 'directory', + 'type' => 'export', + ), + + 'default_expiration' => array( + 'type' => 'number', + 'value' => 30, + 'placeholder' => '365', + 'rules' => array( + 'required' => true, + ), + ), + + 'new_listing_status' => array( + 'label' => __( 'New listing', 'directorist' ), + 'type' => 'select', + 'value' => 'pending', + 'options' => array( + array( + 'label' => __( 'Pending', 'directorist' ), + 'value' => 'pending', + ), + array( + 'label' => __( 'Publish', 'directorist' ), + 'value' => 'publish', + ), + ), + ), + + 'edit_listing_status' => array( + 'label' => __( 'Edited listing', 'directorist' ), + 'type' => 'select', + 'value' => 'pending', + 'options' => array( + array( + 'label' => __( 'Pending', 'directorist' ), + 'value' => 'pending', + ), + array( + 'label' => __( 'Publish', 'directorist' ), + 'value' => 'publish', + ), + ), + ), + + 'global_listing_type' => array( + 'label' => __( 'Global Listing Type', 'directorist' ), + 'type' => 'toggle', + 'value' => '', + ), + + 'submission_form_fields' => apply_filters( + 'atbdp_listing_type_form_fields', + array( + 'type' => 'form-builder', + 'widgets' => $form_field_widgets, + 'generalSettings' => array( + 'minGroup' => 1, + 'addNewGroupButtonLabel' => __( 'Add Section', 'directorist' ), + 'restricted_fields_warning_text' => __( 'You can not add in this section', 'directorist' ), + ), + 'groupSettings' => array( + 'defaultGroupLabel' => 'Section', + 'disableTrashIfGroupHasWidgets' => array( + array( + 'widget_name' => 'title', + 'widget_group' => 'preset', + ), + ), + ), + 'groupFields' => array( + 'label' => array( + 'type' => 'text', + 'label' => 'Group Name', + 'value' => 'Section', + ), + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Block/Section Icon', 'directorist' ), + 'value' => '', + ), + ), + 'value' => array( + 'fields' => array( + 'title' => array( + 'widget_group' => 'preset', + 'widget_name' => 'title', + 'type' => 'text', + 'field_key' => 'listing_title', + 'required' => true, + 'label' => 'Title', + 'placeholder' => '', + ), + ), + 'groups' => array( + array( + 'label' => 'General Section', + 'lock' => true, + 'fields' => array( 'title' ), + 'plans' => array(), + ), + ), + ), + + ) + ), + + // Submission Settings + 'enable_sidebar' => array( + 'label' => __( 'Enable Sidebar', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + 'preview_mode' => array( + 'label' => __( 'Enable Listing Preview', 'directorist' ), + 'type' => 'toggle', + 'value' => true, + ), + + // Submit Button + 'submit_button_label_old' => array( + 'label' => __( 'Submit Button Label', 'directorist' ), + 'type' => 'text', + 'value' => __( 'Save & Preview', 'directorist' ), + ), + + 'submit_button_label' => array( + 'label' => __( 'Submit Button Label', 'directorist' ), + 'type' => 'editable-button', + 'value' => __( 'Update', 'directorist' ), + ), + + 'single_listings_contents' => array( + 'type' => 'form-builder', + 'widgets' => $single_listings_contents_widgets, + 'generalSettings' => array( + 'addNewGroupButtonLabel' => __( 'Add Section', 'directorist' ), + ), + 'groupFields' => array( + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Section', + ), + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Block/Section Icon', 'directorist' ), + 'value' => '', + ), + 'section_id' => array( + 'type' => 'text', + 'disable' => true, + 'label' => 'Section ID', + 'value' => '', + 'field_type' => 'advanced', + ), + 'custom_block_id' => array( + 'type' => 'text', + 'label' => __( 'Custom block ID', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + 'custom_block_classes' => array( + 'type' => 'text', + 'label' => __( 'Custom block Classes', 'directorist' ), + 'value' => '', + 'field_type' => 'advanced', + ), + 'shortcode' => array( + 'type' => 'shortcode-list', + 'label' => __( 'Shortcode', 'directorist' ), + 'description' => __( 'Click the wizerd button to generate the shortcode.', 'directorist' ), + 'buttonLabel' => '<i class="fas fa-magic"></i>', + 'shortcodes' => array( + array( + 'shortcode' => '[directorist_single_listing_section label="@@shortcode_label@@" key="@@shortcode_key@@"]', + 'mapAtts' => array( + array( + 'map' => 'self.section_id', + 'where' => array( + 'key' => 'value', + 'mapTo' => '@@shortcode_key@@', + ), + ), + array( + 'map' => 'self.label', + 'where' => array( + 'key' => 'value', + 'mapTo' => '@@shortcode_label@@', + ), + ), + ), + ), + ), + + 'show_if' => array( + 'where' => 'enable_single_listing_page', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + + ), + ), + 'value' => array(), + ), + 'enable_single_listing_page' => array( + 'type' => 'toggle', + 'label' => __( 'Enable Custom Single Listing Page', 'directorist' ), + 'description' => __( + 'Enabling this option will replace the default single listing page. After enabling you must create and assign a new page with generated shortcodes to display single listing content. +', + 'directorist' + ), + 'labelType' => 'h3', + 'value' => false, + ), + 'single_listing_page' => array( + 'label' => __( 'Single listing page', 'directorist' ), + 'type' => 'select', + 'value' => '', + 'showDefaultOption' => true, + 'options' => directorist_get_all_page_list(), + 'show_if' => array( + 'where' => 'enable_single_listing_page', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + + 'single_listings_shortcodes' => array( + 'type' => 'shortcode-list', + 'buttonLabel' => '<i class="fas fa-magic"></i>', + 'label' => __( 'Generate shortcodes', 'directorist' ), + 'description' => __( 'Generate single listing shortcodes', 'directorist' ), + 'shortcodes' => array( + '[directorist_single_listings_header]', + array( + 'shortcode' => '[directorist_single_listing_section label="@@shortcode_label@@" key="@@shortcode_key@@"]', + 'mapAtts' => array( + array( + 'mapAll' => 'single_listings_contents.value.groups', + 'where' => array( + array( + 'key' => 'section_id', + 'mapTo' => '@@shortcode_key@@', + ), + array( + 'key' => 'label', + 'mapTo' => '@@shortcode_label@@', + ), + ), + ), + ), + ), + ), + + 'show_if' => array( + 'where' => 'enable_single_listing_page', + 'conditions' => array( + array( + 'key' => 'value', + 'compare' => '=', + 'value' => true, + ), + ), + ), + ), + + 'search_form_fields' => array( + 'type' => 'form-builder', + 'generalSettings' => array( + 'allowAddNewGroup' => false, + ), + 'groupSettings' => array( + 'defaultGroupLabel' => 'Section', + 'canTrash' => false, + 'draggable' => false, + ), + 'widgets' => $search_form_widgets, + 'value' => array( + 'groups' => array( + array( + 'label' => __( 'Search Bar', 'directorist' ), + 'lock' => true, + 'draggable' => false, + 'fields' => array(), + ), + array( + 'label' => __( 'Search Filter', 'directorist' ), + 'lock' => true, + 'draggable' => false, + 'fields' => array(), + ), + ), + ), + ), + + 'single_listing_header' => apply_filters( + 'directorist_listing_header_layout', + array( + 'type' => 'card-builder', + 'template' => 'listing-header', + 'value' => '', + 'card-options' => array( + 'general' => array( + 'back' => array( + 'type' => 'badge', + 'label' => __( 'Back', 'directorist' ), + 'options' => array( + 'title' => __( 'Back Button Settings', 'directorist' ), + 'fields' => array( + 'label' => array( + 'type' => 'toggle', + 'label' => __( 'Enable', 'directorist' ), + 'value' => true, + ), + ), + ), + ), + 'section_title' => array( + 'type' => 'title', + 'label' => __( 'Section Title', 'directorist' ), + 'options' => array( + 'title' => __( 'Section Title Options', 'directorist' ), + 'fields' => array( + 'use_listing_title' => array( + 'type' => 'toggle', + 'label' => __( 'Use Listing Title', 'directorist' ), + 'value' => false, + ), + 'label' => array( + 'type' => 'text', + 'label' => __( 'Label', 'directorist' ), + 'value' => 'Section Title', + 'show_if' => array( + 'where' => 'single_listing_header.value.options.general.section_title', + 'conditions' => array( + array( + 'key' => 'use_listing_title', + 'compare' => '=', + 'value' => false, + ), + ), + ), + ), + 'icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => '', + ), + ), + ), + ), + ), + 'content_settings' => array( + 'listing_title' => array( + 'type' => 'title', + 'label' => __( 'Listing Title', 'directorist' ), + 'options' => array( + 'title' => __( 'Listing Title Settings', 'directorist' ), + 'fields' => array( + 'enable_title' => array( + 'type' => 'toggle', + 'label' => __( 'Show Title', 'directorist' ), + 'value' => true, + ), + 'enable_tagline' => array( + 'type' => 'toggle', + 'label' => __( 'Show Tagline', 'directorist' ), + 'value' => true, + ), + ), + ), + ), + ), + ), + 'options_layout' => array( + 'header' => array( 'back', 'section_title' ), + 'contents_area' => array( 'title_and_tagline', 'description' ), + ), + 'widgets' => array( + 'back' => array( + 'type' => 'button', + 'label' => __( 'Back', 'directorist' ), + 'icon' => 'las la-arrow-left', + ), + 'title' => array( + 'type' => 'title', + 'label' => __( 'Listing Title', 'directorist' ), + 'icon' => 'las la-heading', + 'options' => array( + 'title' => __( 'Listing Title Settings', 'directorist' ), + 'fields' => array( + 'enable_tagline' => array( + 'type' => 'toggle', + 'label' => __( 'Show Tagline', 'directorist' ), + 'value' => true, + ), + ), + ), + ), + 'slider' => array( + 'type' => 'thumbnail', + 'label' => __( 'Listing Image/Slider', 'directorist' ), + 'icon' => 'las la-image', + 'options' => array( + 'title' => __( 'Image/Slider Settings', 'directorist' ), + 'fields' => array( + 'footer_thumbnail' => array( + 'type' => 'toggle', + 'label' => __( 'Show Thumbnail', 'directorist' ), + 'value' => true, + ), + ), + ), + ), + + 'bookmark' => array( + 'type' => 'button', + 'label' => __( 'Bookmark', 'directorist' ), + 'icon' => 'las la-bookmark', + ), + 'share' => array( + 'type' => 'badge', + 'label' => __( 'Share', 'directorist' ), + 'icon' => 'las la-share', + 'options' => array( + 'title' => __( 'Share Settings', 'directorist' ), + 'fields' => array( + 'share_icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-share', + ), + ), + ), + ), + 'report' => array( + 'type' => 'badge', + 'label' => __( 'Report', 'directorist' ), + 'icon' => 'las la-flag', + 'options' => array( + 'title' => __( 'Report Settings', 'directorist' ), + 'fields' => array( + 'report_icon' => array( + 'type' => 'icon', + 'label' => __( 'Icon', 'directorist' ), + 'value' => 'las la-flag', + ), + ), + ), + ), + + 'price' => array( + 'type' => 'badge', + 'label' => __( 'Pricing', 'directorist' ), + 'icon' => 'uil uil-text-fields', + ), + 'badges' => array( + 'type' => 'badge', + 'label' => __( 'Badges', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'options' => array( + 'title' => __( 'Badge Settings', 'directorist' ), + 'fields' => array( + 'new_badge' => array( + 'type' => 'toggle', + 'label' => __( 'Display New Badge', 'directorist' ), + 'value' => true, + ), + 'popular_badge' => array( + 'type' => 'toggle', + 'label' => __( 'Display Popular Badge', 'directorist' ), + 'value' => true, + ), + 'featured_badge' => array( + 'type' => 'toggle', + 'label' => __( 'Display Featured Badge', 'directorist' ), + 'value' => true, + ), + ), + ), + ), + 'ratings_count' => array( + 'type' => 'ratings-count', + 'label' => __( 'Rating', 'directorist' ), + 'icon' => 'uil uil-text-fields', + ), + 'category' => array( + 'type' => 'badge', + 'label' => __( 'Listings Category', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'category', + ), + ), + ), + ), + 'location' => array( + 'type' => 'badge', + 'label' => __( 'Listings Location', 'directorist' ), + 'icon' => 'uil uil-text-fields', + 'show_if' => array( + 'where' => 'submission_form_fields.value.fields', + 'conditions' => array( + array( + 'key' => '_any.widget_name', + 'compare' => '=', + 'value' => 'location', + ), + ), + ), + ), + ), + + 'layout' => array( + array( + 'type' => 'placeholder_group', + 'placeholderKey' => 'quick-widgets-placeholder', + 'placeholders' => array( + array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'quick-info-placeholder', + 'label' => __( 'Quick info', 'directorist' ), + 'maxWidget' => 1, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'back' ), + ), + array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'quick-action-placeholder', + 'label' => __( 'Quick Action', 'directorist' ), + 'maxWidget' => 0, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'bookmark', 'share', 'report' ), + ), + ), + ), + array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'listing-title-placeholder', + 'label' => __( 'Listing Title', 'directorist' ), + 'maxWidget' => 1, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'title' ), + ), + array( + 'type' => 'placeholder_item', + 'placeholderKey' => 'more-widgets-placeholder', + 'label' => __( 'More Widgets', 'directorist' ), + 'maxWidget' => 0, + 'maxWidgetInfoText' => 'Up to __DATA__ item{s} can be added', + 'acceptedWidgets' => array( 'location', 'category', 'ratings_count', 'badges', 'price' ), + 'rejectedWidgets' => array( 'slider' ), + ), + array( + 'type' => 'placeholder_item', + 'label' => 'Slider Widget', + 'placeholderKey' => 'slider-placeholder', + 'selectedWidgets' => array( 'slider' ), + 'acceptedWidgets' => array( 'slider' ), + 'maxWidget' => 1, + 'canDelete' => true, + 'insertByButton' => true, + 'insertButton' => array( + 'label' => 'Add Image/Slider', + ), + ), + ), + ) + ), + + 'listings_card_grid_view' => apply_filters( + 'directorist_listing_card_layouts', + array( + 'type' => 'card-builder', + 'card_templates' => array( + 'grid_view_with_thumbnail' => array( + 'label' => __( 'With Preview Image', 'directorist' ), + 'template' => 'grid-view-with-thumbnail', + 'widgets' => $listing_card_widget, + 'layout' => $listing_card_grid_view_with_thumbnail_layout, + ), + 'grid_view_without_thumbnail' => array( + 'label' => __( 'Without Preview Image', 'directorist' ), + 'template' => 'grid-view-without-thumbnail', + 'widgets' => $listing_card_conditional_widget, + 'layout' => $listing_card_grid_view_without_thumbnail_layout, + ), + ), + ) + ), + + 'listings_card_list_view' => apply_filters( + 'directorist_listing_list_layouts', + array( + 'type' => 'card-builder', + 'card_templates' => array( + 'list_view_with_thumbnail' => array( + 'label' => __( 'With Preview Image', 'directorist' ), + 'template' => 'list-view-with-thumbnail', + 'widgets' => $listing_card_conditional_widget, + 'layout' => $listing_card_list_view_with_thumbnail_layout, + ), + 'list_view_without_thumbnail' => array( + 'label' => __( 'Without Preview Image', 'directorist' ), + 'template' => 'list-view-without-thumbnail', + 'widgets' => $listing_card_conditional_widget, + 'layout' => $listing_card_list_view_without_thumbnail_layout, + ), + ), + ) + ), + + ) + ); + + self::$layouts = apply_filters( + 'directorist_builder_layouts', + array( + 'general' => array( + 'label' => 'General', + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> <path fill-rule="evenodd" clip-rule="evenodd" d="M7.65155 0.890914C7.87975 0.829127 8.12027 0.829127 8.34847 0.890914C8.61339 0.962641 8.83642 1.13775 9.01443 1.2775C9.03142 1.29084 9.048 1.30386 9.06418 1.31644L13.5857 4.83319C13.6031 4.84673 13.6204 4.86013 13.6375 4.87343C13.8886 5.06828 14.1098 5.23995 14.2747 5.46282C14.4193 5.6584 14.5271 5.87874 14.5927 6.11301C14.6674 6.37996 14.6671 6.65996 14.6667 6.97779C14.6667 6.99948 14.6667 7.02133 14.6667 7.04338V11.8924C14.6667 12.2438 14.6667 12.547 14.6463 12.7967C14.6248 13.0602 14.5772 13.3224 14.4487 13.5746C14.2569 13.951 13.951 14.2569 13.5747 14.4487C13.3224 14.5772 13.0603 14.6248 12.7967 14.6463C12.547 14.6667 12.2438 14.6667 11.8924 14.6667H4.10763C3.75621 14.6667 3.45304 14.6667 3.20333 14.6463C2.93976 14.6248 2.67762 14.5772 2.42536 14.4487C2.04904 14.2569 1.74308 13.951 1.55133 13.5746C1.4228 13.3224 1.37526 13.0602 1.35372 12.7967C1.33332 12.547 1.33333 12.2438 1.33334 11.8924L1.33334 7.04338C1.33334 7.02133 1.33332 6.99947 1.3333 6.97779C1.33295 6.65996 1.33265 6.37995 1.40737 6.11301C1.47295 5.87874 1.58071 5.6584 1.72537 5.46282C1.89021 5.23995 2.11142 5.06828 2.36251 4.87342C2.37964 4.86013 2.39691 4.84672 2.41431 4.83319L6.93585 1.31644C6.95202 1.30386 6.9686 1.29084 6.9856 1.2775C7.1636 1.13775 7.38664 0.962641 7.65155 0.890914ZM6.66668 13.3333H9.33335V9.06667C9.33335 8.86898 9.33283 8.76081 9.32648 8.68309C9.32622 8.67999 9.32597 8.67706 9.32571 8.6743C9.32295 8.67404 9.32002 8.67379 9.31692 8.67353C9.2392 8.66718 9.13103 8.66667 8.93334 8.66667H7.06668C6.86899 8.66667 6.76082 8.66718 6.6831 8.67353C6.68001 8.67379 6.67708 8.67404 6.67431 8.6743C6.67406 8.67706 6.6738 8.67999 6.67355 8.68309C6.6672 8.76081 6.66668 8.86898 6.66668 9.06667V13.3333ZM10.6667 13.3333L10.6667 9.04541C10.6667 8.87715 10.6667 8.71329 10.6554 8.57451C10.6429 8.42212 10.6136 8.24229 10.5214 8.06135C10.3935 7.81046 10.1896 7.60649 9.93867 7.47866C9.75772 7.38646 9.57789 7.35708 9.4255 7.34463C9.28672 7.33329 9.12286 7.33331 8.9546 7.33333H7.04542C6.87717 7.33331 6.7133 7.33329 6.57453 7.34463C6.42213 7.35708 6.24231 7.38646 6.06136 7.47866C5.81047 7.60649 5.6065 7.81046 5.47867 8.06135C5.38647 8.24229 5.35709 8.42212 5.34464 8.57451C5.3333 8.71328 5.33332 8.87714 5.33334 9.0454L5.33335 13.3333H4.13335C3.74898 13.3333 3.50079 13.3328 3.3119 13.3174C3.13079 13.3026 3.06365 13.2775 3.03068 13.2607C2.90524 13.1968 2.80326 13.0948 2.73934 12.9693C2.72255 12.9364 2.69743 12.8692 2.68263 12.6881C2.6672 12.4992 2.66668 12.251 2.66668 11.8667V7.04338C2.66668 6.62272 2.67247 6.53988 2.69135 6.47241C2.71321 6.39432 2.74913 6.32088 2.79735 6.25568C2.83901 6.19935 2.90085 6.14392 3.2329 5.88566L7.75444 2.36891C7.87904 2.272 7.94504 2.22117 7.99515 2.1877C7.99684 2.18656 7.99847 2.18549 8.00001 2.18447C8.00156 2.18549 8.00318 2.18656 8.00488 2.1877C8.05498 2.22117 8.12098 2.272 8.24559 2.36891L12.7671 5.88566C13.0992 6.14392 13.161 6.19935 13.2027 6.25568C13.2509 6.32087 13.2868 6.39432 13.3087 6.47241C13.3276 6.53988 13.3333 6.62272 13.3333 7.04338V11.8667C13.3333 12.251 13.3328 12.4992 13.3174 12.6881C13.3026 12.8692 13.2775 12.9364 13.2607 12.9693C13.1968 13.0948 13.0948 13.1968 12.9693 13.2607C12.9364 13.2775 12.8692 13.3026 12.6881 13.3174C12.4992 13.3328 12.251 13.3333 11.8667 13.3333H10.6667Z" fill="currentColor"/> </svg>', - 'container' => 'short-wide', - 'sections' => [ - 'labels' => [ - 'title' => __( 'Directory icon', 'directorist' ), - 'description' => __( 'Select a directory type icon to display in all listings, add listing, and search pages.', 'directorist' ), - 'fields' => ['icon'], - ], - - 'listing_status' => [ - 'title' => __( 'Default listing status', 'directorist' ), - 'fields' => [ - 'new_listing_status', - 'edit_listing_status', - ], - ], - - 'expiration' => [ - 'title' => __( 'Default listing expiration days', 'directorist' ), - 'description' => __( 'Set the number of days before a listing automatically expires.', 'directorist' ), - 'fields' => [ - 'default_expiration', - ], - ], - - 'default_preview' => [ - 'title' => __( 'Default listing preview image', 'directorist' ), - 'description' => __( 'This image will appear when a listing does not have a preview image uploaded. Leave it empty to hide the preview image.', 'directorist' ), - 'fields' => [ - 'preview_image', - ], - ], - - 'export_import' => [ - 'title' => __( 'Export the config file', 'directorist' ), - 'description' => __( 'Export all the form, layout and settings', 'directorist' ), - 'fields' => [ - 'import_export', - ], - ], - ], - ], - - 'submission_form' => [ - 'label' => __( 'Add Listing Form', 'directorist' ), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + 'container' => 'short-wide', + 'sections' => array( + 'labels' => array( + 'title' => __( 'Directory icon', 'directorist' ), + 'description' => __( 'Select a directory type icon to display in all listings, add listing, and search pages.', 'directorist' ), + 'fields' => array( 'icon' ), + ), + + 'listing_status' => array( + 'title' => __( 'Default listing status', 'directorist' ), + 'fields' => array( + 'new_listing_status', + 'edit_listing_status', + ), + ), + + 'expiration' => array( + 'title' => __( 'Default listing expiration days', 'directorist' ), + 'description' => __( 'Set the number of days before a listing automatically expires.', 'directorist' ), + 'fields' => array( + 'default_expiration', + ), + ), + + 'default_preview' => array( + 'title' => __( 'Default listing preview image', 'directorist' ), + 'description' => __( 'This image will appear when a listing does not have a preview image uploaded. Leave it empty to hide the preview image.', 'directorist' ), + 'fields' => array( + 'preview_image', + ), + ), + + 'export_import' => array( + 'title' => __( 'Export the config file', 'directorist' ), + 'description' => __( 'Export all the form, layout and settings', 'directorist' ), + 'fields' => array( + 'import_export', + ), + ), + ), + ), + + 'submission_form' => array( + 'label' => __( 'Add Listing Form', 'directorist' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> <path fill-rule="evenodd" clip-rule="evenodd" d="M5.83913 0.666626H10.1609C10.6975 0.666618 11.1404 0.666611 11.5012 0.696089C11.8759 0.726706 12.2204 0.792415 12.544 0.957276C13.0457 1.21294 13.4537 1.62089 13.7094 2.12265C13.8742 2.44621 13.9399 2.79068 13.9705 3.16541C14 3.5262 14 3.9691 14 4.50574V6.99996C14 7.36815 13.7015 7.66663 13.3333 7.66663C12.9651 7.66663 12.6667 7.36815 12.6667 6.99996V4.53329C12.6667 3.96224 12.6661 3.57404 12.6416 3.27399C12.6178 2.98171 12.5745 2.83224 12.5213 2.72797C12.3935 2.47709 12.1895 2.27312 11.9387 2.14528C11.8344 2.09216 11.6849 2.04887 11.3926 2.02499C11.0926 2.00048 10.7044 1.99996 10.1333 1.99996H5.86667C5.29561 1.99996 4.90742 2.00048 4.60736 2.02499C4.31508 2.04887 4.16561 2.09216 4.06135 2.14528C3.81046 2.27312 3.60649 2.47709 3.47866 2.72797C3.42553 2.83224 3.38225 2.98171 3.35837 3.27399C3.33385 3.57404 3.33333 3.96224 3.33333 4.53329V11.4666C3.33333 12.0377 3.33385 12.4259 3.35837 12.7259C3.38225 13.0182 3.42553 13.1677 3.47866 13.2719C3.60649 13.5228 3.81046 13.7268 4.06135 13.8546C4.16561 13.9078 4.31508 13.951 4.60736 13.9749C4.90742 13.9994 5.29561 14 5.86667 14H8C8.36819 14 8.66667 14.2984 8.66667 14.6666C8.66667 15.0348 8.36819 15.3333 8 15.3333H5.83912C5.30248 15.3333 4.85958 15.3333 4.49878 15.3038C4.12405 15.2732 3.77958 15.2075 3.45603 15.0426C2.95426 14.787 2.54631 14.379 2.29065 13.8773C2.12579 13.5537 2.06008 13.2092 2.02946 12.8345C1.99998 12.4737 1.99999 12.0308 2 11.4942V4.50576C1.99999 3.96911 1.99998 3.52621 2.02946 3.16541C2.06008 2.79068 2.12579 2.44621 2.29065 2.12265C2.54631 1.62089 2.95426 1.21294 3.45603 0.957276C3.77958 0.792415 4.12405 0.726706 4.49878 0.696089C4.85958 0.666611 5.30249 0.666618 5.83913 0.666626ZM4.66667 4.66663C4.66667 4.29844 4.96514 3.99996 5.33333 3.99996H10.6667C11.0349 3.99996 11.3333 4.29844 11.3333 4.66663C11.3333 5.03482 11.0349 5.33329 10.6667 5.33329H5.33333C4.96514 5.33329 4.66667 5.03482 4.66667 4.66663ZM4.66667 7.33329C4.66667 6.9651 4.96514 6.66663 5.33333 6.66663H9.33333C9.70152 6.66663 10 6.9651 10 7.33329C10 7.70148 9.70152 7.99996 9.33333 7.99996H5.33333C4.96514 7.99996 4.66667 7.70148 4.66667 7.33329ZM4.66667 9.99996C4.66667 9.63177 4.96514 9.33329 5.33333 9.33329H6.66667C7.03486 9.33329 7.33333 9.63177 7.33333 9.99996C7.33333 10.3682 7.03486 10.6666 6.66667 10.6666H5.33333C4.96514 10.6666 4.66667 10.3682 4.66667 9.99996ZM12 9.33329C12.3682 9.33329 12.6667 9.63177 12.6667 9.99996V11.3333H14C14.3682 11.3333 14.6667 11.6318 14.6667 12C14.6667 12.3681 14.3682 12.6666 14 12.6666H12.6667V14C12.6667 14.3681 12.3682 14.6666 12 14.6666C11.6318 14.6666 11.3333 14.3681 11.3333 14V12.6666H10C9.63181 12.6666 9.33333 12.3681 9.33333 12C9.33333 11.6318 9.63181 11.3333 10 11.3333H11.3333V9.99996C11.3333 9.63177 11.6318 9.33329 12 9.33329Z" fill="currentColor"/> </svg>', - 'container' => 'full-width', - 'video' => [ - 'url' => 'https://www.youtube.com/embed/0rjSHUPZgoE', - 'button_text' => __( 'Watch Tutorial', 'directorist' ), - 'title' => __( 'Add Listing Form Tutorial', 'directorist' ), - 'description' => __( 'Watch the video to learn how to create add listing form.', 'directorist' ), - ], - 'sections' => [ - 'form_fields' => [ - 'title' => __( 'Add listing form', 'directorist' ), - 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/form-and-layout-builder/">' . __( 'Need help?', 'directorist' ) . ' </a>', - 'fields' => [ - 'submission_form_fields' - ], - ], - 'form_options' => [ - 'fields' => [ - 'preview_mode', - 'submit_button_label', - ] - ] - ], - ], - - 'single_page_layout' => [ - 'label' => __( 'Single Page Layout', 'directorist' ), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + 'container' => 'full-width', + 'video' => array( + 'url' => 'https://www.youtube.com/embed/0rjSHUPZgoE', + 'button_text' => __( 'Watch Tutorial', 'directorist' ), + 'title' => __( 'Add Listing Form Tutorial', 'directorist' ), + 'description' => __( 'Watch the video to learn how to create add listing form.', 'directorist' ), + ), + 'sections' => array( + 'form_fields' => array( + 'title' => __( 'Add listing form', 'directorist' ), + 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/form-and-layout-builder/">' . __( 'Need help?', 'directorist' ) . ' </a>', + 'fields' => array( + 'submission_form_fields', + ), + ), + 'form_options' => array( + 'fields' => array( + 'preview_mode', + 'submit_button_label', + ), + ), + ), + ), + + 'single_page_layout' => array( + 'label' => __( 'Single Page Layout', 'directorist' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> <path fill-rule="evenodd" clip-rule="evenodd" d="M10.8276 1.33337H5.17249C4.63584 1.33337 4.19293 1.33336 3.83214 1.36284C3.45741 1.39345 3.11294 1.45916 2.78938 1.62402C2.28761 1.87969 1.87967 2.28763 1.624 2.7894C1.45914 3.11296 1.39343 3.45743 1.36282 3.83216C1.33334 4.19295 1.33335 4.63585 1.33335 5.17249V10.8276C1.33335 11.3642 1.33334 11.8071 1.36282 12.1679C1.39343 12.5427 1.45914 12.8871 1.624 13.2107C1.87967 13.7124 2.28761 14.1204 2.78938 14.3761C3.11294 14.5409 3.45741 14.6066 3.83214 14.6372C4.19293 14.6667 4.63583 14.6667 5.17247 14.6667H10.8276C11.3642 14.6667 11.8071 14.6667 12.1679 14.6372C12.5426 14.6066 12.8871 14.5409 13.2107 14.3761C13.7124 14.1204 14.1204 13.7124 14.376 13.2107C14.5409 12.8871 14.6066 12.5427 14.6372 12.1679C14.6667 11.8071 14.6667 11.3642 14.6667 10.8276V5.17251C14.6667 4.63586 14.6667 4.19295 14.6372 3.83216C14.6066 3.45743 14.5409 3.11296 14.376 2.7894C14.1204 2.28763 13.7124 1.87969 13.2107 1.62402C12.8871 1.45916 12.5426 1.39345 12.1679 1.36284C11.8071 1.33336 11.3642 1.33337 10.8276 1.33337ZM9.33335 13.3334H5.20002C4.62897 13.3334 4.24077 13.3329 3.94071 13.3083C3.64844 13.2845 3.49897 13.2412 3.3947 13.188C3.14382 13.0602 2.93984 12.8562 2.81201 12.6054C2.75889 12.5011 2.7156 12.3516 2.69172 12.0593C2.66721 11.7593 2.66669 11.3711 2.66669 10.8V5.20004C2.66669 4.62899 2.66721 4.24079 2.69172 3.94073C2.7156 3.64846 2.75889 3.49899 2.81201 3.39472C2.93984 3.14384 3.14382 2.93986 3.3947 2.81203C3.49897 2.75891 3.64844 2.71562 3.94071 2.69174C4.24077 2.66723 4.62897 2.66671 5.20002 2.66671H9.33335L9.33335 13.3334ZM10.6667 2.66671L10.6667 13.3334H10.8C11.3711 13.3334 11.7593 13.3329 12.0593 13.3083C12.3516 13.2845 12.5011 13.2412 12.6053 13.188C12.8562 13.0602 13.0602 12.8562 13.188 12.6054C13.2412 12.5011 13.2844 12.3516 13.3083 12.0593C13.3328 11.7593 13.3334 11.3711 13.3334 10.8V5.20004C13.3334 4.62899 13.3328 4.24079 13.3083 3.94073C13.2844 3.64846 13.2412 3.49899 13.188 3.39472C13.0602 3.14384 12.8562 2.93986 12.6053 2.81203C12.5011 2.75891 12.3516 2.71562 12.0593 2.69174C11.7593 2.66723 11.3711 2.66671 10.8 2.66671H10.6667ZM8.33335 4.66671C8.33335 4.29852 8.03488 4.00004 7.66669 4.00004H4.33335C3.96516 4.00004 3.66669 4.29852 3.66669 4.66671C3.66669 5.0349 3.96516 5.33337 4.33335 5.33337H7.66669C8.03488 5.33337 8.33335 5.0349 8.33335 4.66671ZM8.33335 7.33337C8.33335 6.96518 8.03488 6.66671 7.66669 6.66671H4.33335C3.96516 6.66671 3.66669 6.96518 3.66669 7.33337C3.66669 7.70156 3.96516 8.00004 4.33335 8.00004H7.66669C8.03488 8.00004 8.33335 7.70156 8.33335 7.33337ZM8.33335 10C8.33335 9.63185 8.03488 9.33337 7.66669 9.33337H4.33335C3.96516 9.33337 3.66669 9.63185 3.66669 10C3.66669 10.3682 3.96516 10.6667 4.33335 10.6667H7.66669C8.03488 10.6667 8.33335 10.3682 8.33335 10Z" fill="currentColor"/> </svg>', - 'submenu' => [ - 'listing_header' => [ - 'label' => __( 'Listing Header', 'directorist' ), - 'container' => 'full-width', - 'video' => [ - 'url' => 'https://www.youtube.com/embed/NtLXjEAPQzc', - 'button_text' => __( 'Watch Tutorial', 'directorist' ), - 'title' => __( 'Listing Header Tutorial', 'directorist' ), - 'description' => __( 'Watch the video to learn how to create listing header.', 'directorist' ), - ], - 'learn_more' => [ - 'url' => 'https://directorist.com/features/', - 'title' => __( 'What is it?', 'directorist' ), - ], - 'sections' => [ - 'listing_header' => [ - 'title' => __( 'Listing Header', 'directorist' ), - 'title_align' => 'center', - 'fields' => [ - 'single_listing_header', - ], - ], - ], - ], - 'contents' => [ - 'label' => __( 'Contents', 'directorist' ), - 'container' => 'full-width', - 'video' => [ - 'url' => 'https://www.youtube.com/embed/82CFngofqbM', - 'button_text' => __( 'Watch Tutorial', 'directorist' ), - 'title' => __( 'Contents Tutorial', 'directorist' ), - 'description' => __( 'Watch the video to learn how to create a custom contents.', 'directorist' ), - ], - 'learn_more' => [ - 'url' => 'https://directorist.com/solutions/', - 'title' => __( 'What is it?', 'directorist' ), - ], - 'sections' => [ - 'contents' => [ - 'title' => __( 'Contents', 'directorist' ), - 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/single-listings-layout/"> ' . __( 'Need help?', 'directorist' ) . ' </a>', - 'fields' => [ - 'single_listings_contents', - ], - ], - ], - ], - 'similar_listings' => [ - 'label' => __( 'Custom Single Listing Page', 'directorist' ), - 'container' => 'short-wide', - 'sections' => [ - 'page_settings' => [ - 'fields' => [ - 'enable_single_listing_page', - 'single_listing_page', - 'single_listings_shortcodes', - ], - ], - ], - ], - ], - ], - 'listings_card_layout' => [ - 'label' => __( 'All Listing Layout', 'directorist' ), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + 'submenu' => array( + 'listing_header' => array( + 'label' => __( 'Listing Header', 'directorist' ), + 'container' => 'full-width', + 'video' => array( + 'url' => 'https://www.youtube.com/embed/NtLXjEAPQzc', + 'button_text' => __( 'Watch Tutorial', 'directorist' ), + 'title' => __( 'Listing Header Tutorial', 'directorist' ), + 'description' => __( 'Watch the video to learn how to create listing header.', 'directorist' ), + ), + 'learn_more' => array( + 'url' => 'https://directorist.com/features/', + 'title' => __( 'What is it?', 'directorist' ), + ), + 'sections' => array( + 'listing_header' => array( + 'title' => __( 'Listing Header', 'directorist' ), + 'title_align' => 'center', + 'fields' => array( + 'single_listing_header', + ), + ), + ), + ), + 'contents' => array( + 'label' => __( 'Contents', 'directorist' ), + 'container' => 'full-width', + 'video' => array( + 'url' => 'https://www.youtube.com/embed/82CFngofqbM', + 'button_text' => __( 'Watch Tutorial', 'directorist' ), + 'title' => __( 'Contents Tutorial', 'directorist' ), + 'description' => __( 'Watch the video to learn how to create a custom contents.', 'directorist' ), + ), + 'learn_more' => array( + 'url' => 'https://directorist.com/solutions/', + 'title' => __( 'What is it?', 'directorist' ), + ), + 'sections' => array( + 'contents' => array( + 'title' => __( 'Contents', 'directorist' ), + 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/single-listings-layout/"> ' . __( 'Need help?', 'directorist' ) . ' </a>', + 'fields' => array( + 'single_listings_contents', + ), + ), + ), + ), + 'similar_listings' => array( + 'label' => __( 'Custom Single Listing Page', 'directorist' ), + 'container' => 'short-wide', + 'sections' => array( + 'page_settings' => array( + 'fields' => array( + 'enable_single_listing_page', + 'single_listing_page', + 'single_listings_shortcodes', + ), + ), + ), + ), + ), + ), + 'listings_card_layout' => array( + 'label' => __( 'All Listing Layout', 'directorist' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> <path fill-rule="evenodd" clip-rule="evenodd" d="M1.33331 3.99996C1.33331 3.26358 1.93027 2.66663 2.66665 2.66663C3.40303 2.66663 3.99998 3.26358 3.99998 3.99996C3.99998 4.73634 3.40303 5.33329 2.66665 5.33329C1.93027 5.33329 1.33331 4.73634 1.33331 3.99996ZM5.33331 3.99996C5.33331 3.63177 5.63179 3.33329 5.99998 3.33329H14C14.3682 3.33329 14.6666 3.63177 14.6666 3.99996C14.6666 4.36815 14.3682 4.66663 14 4.66663L5.99998 4.66663C5.63179 4.66663 5.33331 4.36815 5.33331 3.99996ZM1.33331 7.99996C1.33331 7.26358 1.93027 6.66663 2.66665 6.66663C3.40303 6.66663 3.99998 7.26358 3.99998 7.99996C3.99998 8.73634 3.40303 9.33329 2.66665 9.33329C1.93027 9.33329 1.33331 8.73634 1.33331 7.99996ZM5.33331 7.99996C5.33331 7.63177 5.63179 7.33329 5.99998 7.33329L14 7.33329C14.3682 7.33329 14.6666 7.63177 14.6666 7.99996C14.6666 8.36815 14.3682 8.66663 14 8.66663L5.99998 8.66663C5.63179 8.66663 5.33331 8.36815 5.33331 7.99996ZM1.33331 12C1.33331 11.2636 1.93027 10.6666 2.66665 10.6666C3.40303 10.6666 3.99998 11.2636 3.99998 12C3.99998 12.7363 3.40303 13.3333 2.66665 13.3333C1.93027 13.3333 1.33331 12.7363 1.33331 12ZM5.33331 12C5.33331 11.6318 5.63179 11.3333 5.99998 11.3333L14 11.3333C14.3682 11.3333 14.6666 11.6318 14.6666 12C14.6666 12.3681 14.3682 12.6666 14 12.6666L5.99998 12.6666C5.63179 12.6666 5.33331 12.3681 5.33331 12Z" fill="currentColor"/> </svg>', - 'submenu' => [ - 'grid_view' => [ - 'label' => __( 'All Listing Grid Layout', 'directorist' ), - 'container' => 'full-width', - 'video' => [ - 'url' => 'https://www.youtube.com/embed/SijKFqgwXVQ', - 'button_text' => __( 'Watch Tutorial', 'directorist' ), - 'title' => __( 'All Listing Grid Tutorial', 'directorist' ), - 'description' => __( 'Watch the video to learn how to create all listing grid.', 'directorist' ), - ], - 'learn_more' => [ - 'url' => 'https://directorist.com/customers/', - 'title' => __( 'What is it?', 'directorist' ), - ], - 'sections' => [ - 'listings_card' => [ - 'title' => __( 'All Listing Grid Layout', 'directorist' ), - 'title_align' => 'center', - 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/multiple-directories/"> ' . __( 'Need help?', 'directorist' ) . ' </a>' . __( 'Read the documentation or open a ticket in our helpdesk.', 'directorist' ), - 'fields' => [ - 'listings_card_grid_view', - ], - ], - ], - ], - 'list_view' => [ - 'label' => __( 'All Listing List Layout', 'directorist' ), - 'container' => 'full-width', - 'video' => [ - 'url' => 'https://www.youtube.com/embed/T9VovVonLV0', - 'button_text' => __( 'Watch Tutorial', 'directorist' ), - 'title' => __( 'All Listing List Tutorial', 'directorist' ), - 'description' => __( 'Watch the video to learn how to create all listing list.', 'directorist' ), - ], - 'learn_more' => [ - 'url' => 'https://directorist.com/pricing/', - 'title' => __( 'What is it?', 'directorist' ), - ], - 'sections' => [ - 'listings_card' => [ - 'title' => __( 'All Listing List Layout', 'directorist' ), - 'title_align' => 'center', - 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/multiple-directories/"> ' . __( 'Need help?', 'directorist' ) . ' </a>' . __( 'Read the documentation or open a ticket in our helpdesk.', 'directorist' ), - 'fields' => [ - 'listings_card_list_view', - ], - ], - ], - ], - ], - - ], - 'search_forms' => [ - 'label' => __( 'Search Form', 'directorist' ), - 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + 'submenu' => array( + 'grid_view' => array( + 'label' => __( 'All Listing Grid Layout', 'directorist' ), + 'container' => 'full-width', + 'video' => array( + 'url' => 'https://www.youtube.com/embed/SijKFqgwXVQ', + 'button_text' => __( 'Watch Tutorial', 'directorist' ), + 'title' => __( 'All Listing Grid Tutorial', 'directorist' ), + 'description' => __( 'Watch the video to learn how to create all listing grid.', 'directorist' ), + ), + 'learn_more' => array( + 'url' => 'https://directorist.com/customers/', + 'title' => __( 'What is it?', 'directorist' ), + ), + 'sections' => array( + 'listings_card' => array( + 'title' => __( 'All Listing Grid Layout', 'directorist' ), + 'title_align' => 'center', + 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/multiple-directories/"> ' . __( 'Need help?', 'directorist' ) . ' </a>' . __( 'Read the documentation or open a ticket in our helpdesk.', 'directorist' ), + 'fields' => array( + 'listings_card_grid_view', + ), + ), + ), + ), + 'list_view' => array( + 'label' => __( 'All Listing List Layout', 'directorist' ), + 'container' => 'full-width', + 'video' => array( + 'url' => 'https://www.youtube.com/embed/T9VovVonLV0', + 'button_text' => __( 'Watch Tutorial', 'directorist' ), + 'title' => __( 'All Listing List Tutorial', 'directorist' ), + 'description' => __( 'Watch the video to learn how to create all listing list.', 'directorist' ), + ), + 'learn_more' => array( + 'url' => 'https://directorist.com/pricing/', + 'title' => __( 'What is it?', 'directorist' ), + ), + 'sections' => array( + 'listings_card' => array( + 'title' => __( 'All Listing List Layout', 'directorist' ), + 'title_align' => 'center', + 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/multiple-directories/"> ' . __( 'Need help?', 'directorist' ) . ' </a>' . __( 'Read the documentation or open a ticket in our helpdesk.', 'directorist' ), + 'fields' => array( + 'listings_card_list_view', + ), + ), + ), + ), + ), + + ), + 'search_forms' => array( + 'label' => __( 'Search Form', 'directorist' ), + 'icon' => '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> <path fill-rule="evenodd" clip-rule="evenodd" d="M7.33331 2.66671C4.75598 2.66671 2.66665 4.75605 2.66665 7.33337C2.66665 9.9107 4.75598 12 7.33331 12C8.59061 12 9.73178 11.5028 10.5709 10.6943C10.5885 10.6715 10.6077 10.6495 10.6286 10.6286C10.6495 10.6077 10.6714 10.5885 10.6942 10.571C11.5028 9.73184 12 8.59067 12 7.33337C12 4.75605 9.91064 2.66671 7.33331 2.66671ZM12.0212 11.0785C12.8423 10.0521 13.3333 8.75005 13.3333 7.33337C13.3333 4.01967 10.647 1.33337 7.33331 1.33337C4.0196 1.33337 1.33331 4.01967 1.33331 7.33337C1.33331 10.6471 4.0196 13.3334 7.33331 13.3334C8.74999 13.3334 10.052 12.8424 11.0784 12.0213L13.5286 14.4714C13.7889 14.7318 14.211 14.7318 14.4714 14.4714C14.7317 14.2111 14.7317 13.789 14.4714 13.5286L12.0212 11.0785Z" fill="currentColor"/> </svg>', - 'container' => 'full-width', - 'video' => [ - 'url' => 'https://www.youtube.com/embed/bWRDFgFIvcI', - 'button_text' => __( 'Watch Tutorial', 'directorist' ), - 'title' => __( 'Search Form Tutorial', 'directorist' ), - 'description' => __( 'Watch the video to learn how to create search form.', 'directorist' ), - ], - 'sections' => [ - 'form_fields' => [ - 'title' => __( 'Search Form', 'directorist' ), - 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/search-form-layout/"> ' . __( 'Need help?', 'directorist' ) . ' </a>', - 'fields' => [ - 'search_form_fields', - ], - ], - ], - ], - ] ); - - self::$fields = apply_filters( 'directorist/builder/fields', self::$fields ); - - self::$layouts = apply_filters( 'directorist/builder/layouts', self::$layouts ); - - // Conditional Fields - // ----------------------------- - // Guest Submission - if ( get_directorist_option( 'guest_listings', 1 ) == '1' ) { - self::$fields['guest_email_label'] = [ - 'label' => __( 'Guest Email Label', 'directorist' ), - 'type' => 'text', - 'value' => 'Email Address', - ]; - - self::$fields['guest_email_placeholder'] = [ - 'label' => __( 'Guest Email Placeholder', 'directorist' ), - 'type' => 'text', - 'value' => 'Enter email address', - ]; - } - - self::$options = [ - 'name' => [ - 'type' => 'text', - 'placeholder' => 'Name *', - 'value' => '', - 'rules' => [ - 'required' => true, - ], - 'input_style' => [ - 'class_names' => 'cptm-form-control-light', - ], - 'is-hidden' => true, - ], - ]; - - $config = [ - 'submission' => [ - 'url' => admin_url( 'admin-ajax.php' ), - 'with' => [ - 'action' => 'save_post_type_data', - 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ), - ], - ], - 'fields_group' => [ - 'general_config' => [ - 'icon', - 'singular_name', - 'plural_name', - 'permalink', - 'preview_image', - ], - ], - ]; - - /** - * Filter directory builder `config` data. - * - * @since 7.0.6.0 - */ - $config = apply_filters( 'directorist/builder/config', $config ); - - self::$config = $config; - } - - protected static function get_assign_to_field( array $args = [] ) { - $default = [ - 'type' => 'radio', - 'label' => __('Assign to', 'directorist'), - 'value' => 'form', - 'options' => [ - [ - 'label' => __('Form', 'directorist'), - 'value' => 'form', - ], - [ - 'label' => __('Category', 'directorist'), - 'value' => 'category', - ], - ], - ]; - - return array_merge( $default, $args ); - } + 'container' => 'full-width', + 'video' => array( + 'url' => 'https://www.youtube.com/embed/bWRDFgFIvcI', + 'button_text' => __( 'Watch Tutorial', 'directorist' ), + 'title' => __( 'Search Form Tutorial', 'directorist' ), + 'description' => __( 'Watch the video to learn how to create search form.', 'directorist' ), + ), + 'sections' => array( + 'form_fields' => array( + 'title' => __( 'Search Form', 'directorist' ), + 'description' => '<a target="_blank" href="https://directorist.com/documentation/directorist/form-and-layout-builder/search-form-layout/"> ' . __( 'Need help?', 'directorist' ) . ' </a>', + 'fields' => array( + 'search_form_fields', + ), + ), + ), + ), + ) + ); + + self::$fields = apply_filters( 'directorist/builder/fields', self::$fields ); + + self::$layouts = apply_filters( 'directorist/builder/layouts', self::$layouts ); + + // Conditional Fields + // ----------------------------- + // Guest Submission + if ( get_directorist_option( 'guest_listings', 1 ) == '1' ) { + self::$fields['guest_email_label'] = array( + 'label' => __( 'Guest Email Label', 'directorist' ), + 'type' => 'text', + 'value' => 'Email Address', + ); + + self::$fields['guest_email_placeholder'] = array( + 'label' => __( 'Guest Email Placeholder', 'directorist' ), + 'type' => 'text', + 'value' => 'Enter email address', + ); + } + + self::$options = array( + 'name' => array( + 'type' => 'text', + 'placeholder' => 'Name *', + 'value' => '', + 'rules' => array( + 'required' => true, + ), + 'input_style' => array( + 'class_names' => 'cptm-form-control-light', + ), + 'is-hidden' => true, + ), + ); + + $config = array( + 'submission' => array( + 'url' => admin_url( 'admin-ajax.php' ), + 'with' => array( + 'action' => 'save_post_type_data', + 'directorist_nonce' => wp_create_nonce( directorist_get_nonce_key() ), + ), + ), + 'fields_group' => array( + 'general_config' => array( + 'icon', + 'singular_name', + 'plural_name', + 'permalink', + 'preview_image', + ), + ), + ); + + /** + * Filter directory builder `config` data. + * + * @since 7.0.6.0 + */ + $config = apply_filters( 'directorist/builder/config', $config ); + + self::$config = $config; + } + + protected static function get_assign_to_field( array $args = array() ) { + $default = array( + 'type' => 'radio', + 'label' => __( 'Assign to', 'directorist' ), + 'value' => 'form', + 'options' => array( + array( + 'label' => __( 'Form', 'directorist' ), + 'value' => 'form', + ), + array( + 'label' => __( 'Category', 'directorist' ), + 'value' => 'category', + ), + ), + ); + + return array_merge( $default, $args ); + } protected static function get_file_upload_field_options() { - $options = [ - [ + $options = array( + array( 'label' => __( 'All types', 'directorist' ), 'value' => 'all_types', - ], - [ + ), + array( 'label' => __( 'Image types', 'directorist' ), 'value' => 'image', - ], - [ + ), + array( 'label' => __( 'Audio types', 'directorist' ), 'value' => 'audio', - ], - [ + ), + array( 'label' => __( 'Video types', 'directorist' ), 'value' => 'video', - ], - [ + ), + array( 'label' => __( 'Document types', 'directorist' ), 'value' => 'document', - ], - ]; + ), + ); foreach ( directorist_get_supported_file_types() as $file_type ) { - $options[] = [ + $options[] = array( 'label' => $file_type, 'value' => $file_type, - ]; + ); } return $options; } - public function get_fields() { - return self::$fields; - } - - public function get_layouts() { - return self::$layouts; - } + public function get_fields() { + return self::$fields; + } - public function get_config() { - return self::$config; - } + public function get_layouts() { + return self::$layouts; + } - public function get_options() { - return self::$options; - } + public function get_config() { + return self::$config; + } - public static function get() { - self::prepare_data(); - return [ - 'fields' => self::$fields, - 'layouts' => self::$layouts, - 'config' => self::$config, - 'options' => self::$options, - ]; - } + public function get_options() { + return self::$options; + } + public static function get() { + self::prepare_data(); + return array( + 'fields' => self::$fields, + 'layouts' => self::$layouts, + 'config' => self::$config, + 'options' => self::$options, + ); + } } diff --git a/includes/modules/multi-directory-setup/class-multi-directory-manager.php b/includes/modules/multi-directory-setup/class-multi-directory-manager.php index b6cbf5f0d3..291faded38 100644 --- a/includes/modules/multi-directory-setup/class-multi-directory-manager.php +++ b/includes/modules/multi-directory-setup/class-multi-directory-manager.php @@ -3,827 +3,863 @@ namespace Directorist\Multi_Directory; class Multi_Directory_Manager { - use Multi_Directory_Helper; - - public static $fields = []; - public static $layouts = []; - public static $config = []; - public static $options = []; - - public static $migration = null; - - - public function __construct() { - self::$migration = new Multi_Directory_Migration([ 'multi_directory_manager' => $this ]); - } - - // run - public function run() { - add_action( 'init', [$this, 'register_directory_taxonomy'] ); - add_action( 'init', [$this, 'setup_migration'] ); - - if ( ! is_admin() ) { - return; - } - - add_filter( 'cptm_fields_before_update', [$this, 'cptm_fields_before_update'], 20, 1 ); - - add_action( 'admin_menu', [$this, 'add_menu_pages'] ); - add_action( 'admin_post_delete_listing_type', [$this, 'handle_delete_listing_type_request'] ); - - // Ajax - add_action( 'wp_ajax_save_post_type_data', [ $this, 'save_post_type_data' ] ); - add_action( 'wp_ajax_save_imported_post_type_data', [ $this, 'save_imported_post_type_data' ] ); - add_action( 'wp_ajax_directorist_force_migrate', [ $this, 'handle_force_migration' ] ); - add_action( 'wp_ajax_directorist_directory_type_library', [ $this, 'directorist_directory_type_library' ] ); - } - - public static function builder_data_backup( $term_id ) { - $submission_form_fields = get_term_meta( $term_id , 'submission_form_fields', true ); - $single_listings_contents = get_term_meta( $term_id, 'single_listings_contents', true ); - $single_listing_header = get_term_meta( $term_id, 'single_listing_header', true ); - - // Fetch existing backup data from the option - $existing_backup_data = get_option( 'directorist_builder_backup_data', [] ); - - // Decode the JSON data if it exists - $existing_backup_data = ! empty( $existing_backup_data ) ? json_decode( $existing_backup_data, true ) : []; - - if( ! empty( $submission_form_fields ) && ! empty( $single_listings_contents ) && ! empty( $single_listing_header ) ) { - $existing_backup_data[$term_id] = [ - 'submission_form_fields' => $submission_form_fields, - 'single_listings_contents' => $single_listings_contents, - 'single_listing_header' => $single_listing_header, - ]; - // Convert the backup data to JSON format - $json_backup_data = wp_json_encode( $existing_backup_data ); - - // Save the JSON backup data in options - update_option( 'directorist_builder_backup_data', $json_backup_data ); - } - } - - // custom field assign to category migration - public static function migrate_custom_field( $term_id ) { - - $submission_form_fields = get_term_meta( $term_id , 'submission_form_fields', true ); - // custom field assign to category migration - if ( empty( $submission_form_fields['fields'] ) ) { - return; - } - - // Modify the 'assign_to' value based on your criteria (e.g., change 'category' to 1) - foreach ( $submission_form_fields['fields'] as $field_type => $options ) { - if( empty( $options['assign_to'] ) ) { - continue; - } - - if ( $options['assign_to'] === 'category' ) { - $submission_form_fields['fields'][ $field_type ]['assign_to'] = 1; - } else { - $submission_form_fields['fields'][ $field_type ]['assign_to'] = false; - } - } - - update_term_meta( $term_id, 'submission_form_fields', $submission_form_fields ); - } - - - public static function migrate_review_settings( $term_id ) { - $old_review_settings = get_term_meta( $term_id, 'review_config', true ); - $new_review_builder = get_term_meta( $term_id, 'single_listings_contents', true ); - - // If no value is found, initialize the new review builder structure - if ( empty( $new_review_builder ) ) { - $new_review_builder = [ - 'fields' => [], - 'groups' => [], - ]; - } - - // Update review_cookies_consent in the 'groups' array if the review widget exists - if ( ! empty( $old_review_settings['review_cookies_consent'] ) && is_array( $new_review_builder['groups'] ) ) { - foreach ( $new_review_builder['groups'] as &$group ) { - if ( isset( $group['widget_name'] ) && 'review' === $group['widget_name'] ) { - $group['review_cookies_consent'] = $old_review_settings['review_cookies_consent']; - } - } - } - - // Mapping for fields outside of groups - $fields_mapping = array( - 'review_comment' => array( - 'placeholder' => 'review_comment_placeholder', - 'widget_name' => 'review', - 'widget_child_name' => 'review_comment', - 'widget_key' => 'review_comment', - 'widget_group' => 'other_widgets', - ), - 'review_email' => array( - 'label' => 'review_email_label', - 'placeholder' => 'review_email_placeholder', - 'widget_name' => 'review', - 'widget_child_name' => 'review_email', - 'widget_key' => 'review_email', - 'widget_group' => 'other_widgets', - ), - 'review_name' => array( - 'label' => 'review_name_label', - 'placeholder' => 'review_name_placeholder', - 'widget_name' => 'review', - 'widget_child_name' => 'review_name', - 'widget_key' => 'review_name', - 'widget_group' => 'other_widgets', - ), - 'review_website' => array( - 'enable' => 'review_show_website_field', - 'label' => 'review_website_label', - 'placeholder' => 'review_website_placeholder', - 'widget_name' => 'review', - 'widget_child_name' => 'review_website', - 'widget_key' => 'review_website', - 'widget_group' => 'other_widgets', - ), - ); - - // Ensure the 'fields' key exists in the new_review_builder array - if ( ! isset( $new_review_builder['fields'] ) || ! is_array( $new_review_builder['fields'] ) ) { - $new_review_builder['fields'] = array(); // Initialize if not present - } - - // Add or update fields based on the mapping - foreach ( $fields_mapping as $field_key => $mapping ) { - if ( ! isset( $new_review_builder['fields'][ $field_key ] ) ) { - $new_review_builder['fields'][ $field_key ] = array(); // Initialize the field if it doesn't exist - } - - // Add or update the mapped values - foreach ( $mapping as $new_key => $old_key ) { - if ( $new_key === 'widget_name' || $new_key === 'widget_child_name' || $new_key === 'widget_key' || $new_key === 'widget_group' ) { - // Directly assign widget-related keys - $new_review_builder['fields'][ $field_key ][ $new_key ] = $old_key; - } else { - // Assign other keys if they exist in old_review_settings - if ( ! empty( $old_review_settings[ $old_key ] ) ) { - $new_review_builder['fields'][ $field_key ][ $new_key ] = $old_review_settings[ $old_key ]; - } - } - } - } - - // Ensure the 'groups' key exists in the new_review_builder array - if ( ! isset( $new_review_builder['groups'] ) || ! is_array( $new_review_builder['groups'] ) ) { - $new_review_builder['groups'] = array(); // Initialize if not present - } - - // Add or update groups with the 'review' widget - foreach ( $new_review_builder['groups'] as &$group ) { - if ( isset( $group['widget_name'] ) && 'review' === $group['widget_name'] ) { - foreach ( array_keys( $fields_mapping ) as $field_key ) { - // Add the field to the group if it doesn't already exist - if ( ! in_array( $field_key, $group['fields'] ) ) { - $group['fields'][] = $field_key; - } - } - } - } - - // Update the term meta with the modified new_review_builder array - update_term_meta( $term_id, 'single_listings_contents', $new_review_builder ); - } - - public static function migrate_contact_owner_settings( $term_id ) { - // Get the current settings - $single_listings_contents = get_term_meta( $term_id, 'single_listings_contents', true ); - - // Check if necessary fields exist - if ( empty( $single_listings_contents['fields'] ) || empty( $single_listings_contents['groups'] ) || ! is_array( $single_listings_contents['groups'] ) ) { - return; - } - - // Define the fields mapping - $fields_mapping = array( - 'contact_name' => array( - 'enable' => 1, - 'placeholder' => __( 'Name', 'directorist' ), - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'widget_child_name' => 'contact_name', - 'widget_key' => 'contact_name', - ), - 'contact_email' => array( - 'placeholder' => __( 'Email', 'directorist' ), - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'widget_child_name' => 'contact_email', - 'widget_key' => 'contact_email', - ), - 'contact_message' => array( - 'placeholder' => __( 'Message...', 'directorist' ), - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'widget_child_name' => 'contact_message', - 'widget_key' => 'contact_message', - ), - ); - - // Iterate over groups and update the contact listings owner group - foreach ( $single_listings_contents['groups'] as &$group ) { - if ( isset( $group['widget_name'] ) && 'contact_listings_owner' === $group['widget_name'] ) { - foreach ( $fields_mapping as $field_key => $mapping ) { - // Add or update fields - $single_listings_contents['fields'][ $field_key ] = $mapping; - - // Ensure the field is added to the group's fields - if ( ! in_array( $field_key, $group['fields'], true ) ) { - $group['fields'][] = $field_key; - } - } - } - } - - // Update the term meta with the modified contents - update_term_meta( $term_id, 'single_listings_contents', $single_listings_contents ); - } - - public static function migrate_related_listing_settings( $term_id ) { - $number = get_term_meta( $term_id, 'similar_listings_number_of_listings_to_show', true ); - $same_author = get_term_meta( $term_id, 'listing_from_same_author', true ); - $logic = get_term_meta( $term_id, 'similar_listings_logics', true ); - $column = get_term_meta( $term_id, 'similar_listings_number_of_columns', true ); - $new_related_listing = get_term_meta( $term_id, 'single_listings_contents', true ); - - if ( ! empty( $new_related_listing['groups'] ) && is_array( $new_related_listing['groups'] ) ) { - foreach ( $new_related_listing['groups'] as &$group ) { - if ( isset( $group['widget_name'] ) && 'related_listings' === $group['widget_name'] ) { - $group['similar_listings_logics'] = $logic ?? 'OR'; - $group['listing_from_same_author'] = $same_author ?? false; - $group['similar_listings_number_of_listings_to_show'] = absint( $number ?? 3 ); - $group['similar_listings_number_of_columns'] = absint( $column ?? 3 ); - } - } - } - - update_term_meta( $term_id, 'single_listings_contents', $new_related_listing ); - } - - public static function migrate_privacy_policy( $term_id ) { - $display_privacy = (bool) get_directorist_type_option( $term_id, 'listing_privacy' ); - $privacy_is_required = (bool) get_directorist_type_option( $term_id, 'privacy_is_required' ); - $display_terms = (bool) get_directorist_type_option( $term_id, 'listing_terms_condition' ); - $terms_is_required = (bool) get_directorist_type_option( $term_id, 'require_terms_conditions' ); - $submission_form = get_term_meta( $term_id, 'submission_form_fields', true ); - - // Generate the label with links to Privacy Policy and Terms of Service - $terms_privacy_label = sprintf( - __( 'I agree to the <a href="%s" target="_blank">Privacy Policy</a> and <a href="%s" target="_blank">Terms of Service</a>', 'directorist' ), - \ATBDP_Permalink::get_privacy_policy_page_url(), - \ATBDP_Permalink::get_terms_and_conditions_page_url() - ); - - // Determine if the field should be required - $is_required = ( $privacy_is_required || $terms_is_required ) ? 1 : ''; - - // Define the new field for terms and privacy - $terms_privacy_field = [ - 'type' => 'text', - 'field_key' => 'privacy_policy', - 'text' => $terms_privacy_label, // Use the generated label - 'required' => $is_required, // Dynamically set required status - 'widget_group' => 'preset', - 'widget_name' => 'terms_privacy', - 'widget_key' => 'terms_privacy', - ]; - - // Check if either privacy or terms should be displayed - if ( $display_privacy || $display_terms ) { - // Add the new field to the fields array - $submission_form['fields']['terms_privacy'] = $terms_privacy_field; - // Add the 'terms_privacy' field to the last group in the 'groups' array - $last_group_key = array_key_last( $submission_form['groups'] ); // Get the last group key - $submission_form['groups'][ $last_group_key ]['fields'][] = 'terms_privacy'; // Add to the last group's fields - } - - // Update the term meta with the modified submission_form array - update_term_meta( $term_id, 'submission_form_fields', $submission_form ); - } - - // add_missing_single_listing_section_id - public function add_missing_single_listing_section_id() { - $directory_types = directorist_get_directories(); - - if ( is_wp_error( $directory_types ) || empty( $directory_types ) ) { - return; - } - - foreach ( $directory_types as $directory_type ) { - $single_listings_contents = get_term_meta( $directory_type->term_id, 'single_listings_contents', true ); - $need_to_update = false; - - if ( empty( $single_listings_contents ) ) { - continue; - } - - if ( empty( $single_listings_contents['groups'] ) ) { - continue; - } - - foreach ( $single_listings_contents['groups'] as $group_index => $group ) { - $has_section_id = ( ! empty( $group['section_id'] ) ) ? true : false; - $renew = ( $has_section_id ) ? false : true; - $renew = apply_filters( 'directorist_renew_single_listing_section_id', $renew ); - - if ( ! $renew ) { - continue; - } - - $group['section_id'] = $group_index + 1; - $single_listings_contents['groups'][ $group_index ] = $group; - $need_to_update = true; - } - - if ( $need_to_update ) { - update_term_meta( $directory_type->term_id, 'single_listings_contents', $single_listings_contents ); - } - } - - } - - // update_default_directory_type_option - public function update_default_directory_type_option() { - $args = array( - 'meta_query' => array( - array( - 'key' => '_default', - 'value' => true, - ) - ), - ); - - $default_directory = get_directorist_option( 'atbdp_default_derectory', '' ); - $terms = directorist_get_directories( $args ); - - if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) { - $default_directory = $terms[0]->term_id; - } - - update_directorist_option( 'atbdp_default_derectory', $default_directory ); - } - - // setup_migration - public function setup_migration() { - $migrated = get_option( 'atbdp_migrated', false ); - $need_migration = ( empty( $migrated ) && ! self::has_multidirectory() && self::has_old_listings_data() ) ? true : false; - - if ( $need_migration ) { - $this->prepare_settings(); - self::$migration->migrate(); - return; - } - - $need_import_default = ( ! self::has_multidirectory() ) ? true : false; - - if ( apply_filters( 'atbdp_import_default_directory', $need_import_default ) ) { - $this->prepare_settings(); - $this->import_default_directory(); - } - } - - // has_multidirectory - public static function has_multidirectory() { - $directory_types = directorist_get_directories(); - - return ( ! is_wp_error( $directory_types ) && ! empty( $directory_types ) ) ? true : false; - } - - // has_old_listings_data - public static function has_old_listings_data() { - $get_listings = new \WP_Query([ - 'post_type' => ATBDP_POST_TYPE, - 'posts_per_page' => 1, - 'fields' => 'ids', - ]); - - $get_custom_fields = new \WP_Query([ - 'post_type' => ATBDP_CUSTOM_FIELD_POST_TYPE, - 'posts_per_page' => 1, - 'fields' => 'ids', - ]); - - $has_listings = $get_listings->post_count; - $has_custom_fields = $get_custom_fields->post_count; - - return ( $has_listings || $has_custom_fields ) ? true : false; - } - - // handle_force_migration - public function handle_force_migration() { - if ( ! directorist_verify_nonce() ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ), - ], - ], 200); - } - - if ( ! current_user_can( 'manage_options' ) ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'message' => __( 'You are not allowed to access this resource', 'directorist' ), - ], - ], 200); - } - - wp_send_json( $this->run_force_migration() ); - } - - public function directorist_directory_type_library() { - - if ( ! directorist_verify_nonce() ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'message' => __( 'Something is wrong! Please refresh and retryyy.', 'directorist' ), - ], - ], 200); - } - - if ( ! current_user_can( 'install_plugins' ) || ! current_user_can( 'activate_plugins' ) ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'message' => __( 'You are not allowed to add/activate new plugin', 'directorist' ), - ], - ], 200); - } - - $installed = directorist_download_plugin( [ 'url' => 'https://downloads.wordpress.org/plugin/templatiq.zip' ] ); - $path = WP_PLUGIN_DIR . '/templatiq/templatiq.php'; - - if( ! is_plugin_active( $path ) ){ - activate_plugin( $path ); - } - - $installed['redirect'] = admin_url( 'admin.php?page=templatiq' ); - wp_send_json( $installed ); - } - - // run_force_migration - public function run_force_migration() { - $general_directory = term_exists( 'General', 'atbdp_listing_types' ); - $args = []; - - if ( $general_directory ) { - $args[ 'term_id' ] = $general_directory['term_id']; - } - - $this->prepare_settings(); - $migration_status = self::$migration->migrate( $args ); - - $status = [ - 'success' => $migration_status['success'], - 'message' => ( $migration_status ) ? __( 'Migration Successful', 'directorist' ) : __( 'Migration Failed', 'directorist' ), - ]; - - return $status; - } - - // import_default_directory - public function import_default_directory( array $args = [] ) { - $file = DIRECTORIST_ASSETS_DIR . 'sample-data/directory/directory.json'; - if ( ! file_exists( $file ) ) { return; } - $file_contents = file_get_contents( $file ); - - $add_directory = self::add_directory([ - 'directory_name' => 'General', - 'fields_value' => $file_contents, - 'is_json' => true - ]); - - if ( $add_directory['status']['success'] ) { - update_option( 'atbdp_has_multidirectory', true ); - update_term_meta( $add_directory['term_id'], '_default', true ); - - // Add directory type to all listings - $listings = new \WP_Query([ - 'post_type' => ATBDP_POST_TYPE, - 'status' => 'publish', - 'per_page' => -1, - ]); - - if ( $listings->have_posts() ) { - while ( $listings->have_posts() ) { - $listings->the_post(); - - wp_set_object_terms( get_the_id(), $add_directory['term_id'], 'atbdp_listing_types' ); - } - wp_reset_postdata(); - } - } - } - - public function save_imported_post_type_data() { - - if ( ! directorist_verify_nonce() ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'status_log' => [ - 'nonce_is_missing' => [ - 'type' => 'error', - 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ), - ], - ], - ], - ], 200); - } - - if ( ! current_user_can( 'manage_options' ) ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'status_log' => [ - 'access_denied' => [ - 'type' => 'error', - 'message' => __( 'You are not allowed to access this resource', 'directorist' ), - ], - ], - ], - ], 200); - } - - $term_id = ( ! empty( $_POST[ 'term_id' ] ) ) ? absint( $_POST[ 'term_id' ] ) : 0; - $directory_name = ( ! empty( $_POST[ 'directory-name' ] ) ) ? sanitize_text_field( wp_unslash( $_POST[ 'directory-name' ] ) ) : ''; - $json_file = ( ! empty( $_FILES[ 'directory-import-file' ] ) ) ? directorist_clean( wp_unslash( $_FILES[ 'directory-import-file' ] ) ) : ''; - - // Validation - $response = [ - 'status' => [ - 'success' => true, - 'status_log' => [], - 'error_count' => 0, - ] - ]; - - // Validate file - if ( empty( $json_file ) ) { - $response['status']['status_log']['file_is_missing'] = [ - 'type' => 'error', - 'message' => __( 'File is missing', 'directorist' ), - ]; - - $response['status']['error_count']++; - } - - // Validate file data - $file_contents = file_get_contents( $json_file['tmp_name'] ); - if ( empty( $file_contents ) ) { - $response['status']['status_log']['invalid_data'] = [ - 'type' => 'error', - 'message' => __( 'The data is invalid', 'directorist' ), - ]; - - $response['status']['error_count']++; - } - - // Send respone if has error - if ( $response['status']['error_count'] ) { - $response['status']['success'] = false; - wp_send_json( $response , 200 ); - } - - // If dierctory name is numeric update the term instead of creating - if ( is_numeric( $directory_name ) ) { - $term_id = (int) $directory_name; - $directory_name = ''; - } - - $this->prepare_settings(); - - $add_directory = self::add_directory([ - 'term_id' => $term_id, - 'directory_name' => $directory_name, - 'fields_value' => $file_contents, - 'is_json' => true - ]); - - wp_send_json( $add_directory, 200 ); - } - - - // cptm_fields_before_update - public function cptm_fields_before_update( $fields ) { - $new_fields = $fields; - $fields_group = self::$config['fields_group']; - - foreach ( $fields_group as $group_name => $group_fields ) { - $grouped_fields_value = []; - - foreach ( $group_fields as $field_index => $field_key ) { - if ( is_string( $field_key ) && array_key_exists($field_key, self::$fields)) { - $grouped_fields_value[ $field_key ] = ( isset( $new_fields[ $field_key ] ) ) ? $new_fields[ $field_key ] : ''; - unset( $new_fields[ $field_key ] ); - } - - if ( is_array( $field_key ) ) { - $grouped_fields_value[ $field_index ] = []; - - foreach ( $field_key as $sub_field_key ) { - if ( array_key_exists( $sub_field_key, self::$fields ) ) { - $grouped_fields_value[ $field_index ][ $sub_field_key ] = ( isset( $new_fields[ $sub_field_key ] ) ) ? $new_fields[ $sub_field_key ] : ''; - unset( $new_fields[ $sub_field_key ] ); - } - } - } - } - - $new_fields[ $group_name ] = $grouped_fields_value; - } - - return $new_fields; - } - - // save_post_type_data - public function save_post_type_data() - { - if ( ! directorist_verify_nonce() ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'status_log' => [ - 'nonce_is_missing' => [ - 'type' => 'error', - 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ), - ], - ], - ], - ], 200); - } - - if ( ! current_user_can( 'manage_options' ) ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'status_log' => [ - 'access_denied' => [ - 'type' => 'error', - 'message' => __( 'You are not allowed to access this resource', 'directorist' ), - ], - ], - ], - ], 200); - } - - if ( empty( $_POST['name'] ) ) { - wp_send_json([ - 'status' => [ - 'success' => false, - 'status_log' => [ - 'name_is_missing' => [ - 'type' => 'error', - 'message' => __( 'Name is missing', 'directorist' ), - ], - ], - ], - ], 200); - } - - $term_id = ( ! empty( $_POST['listing_type_id'] ) ) ? absint( $_POST['listing_type_id'] ) : 0; - $directory_name = sanitize_text_field( wp_unslash( $_POST['name'] ) ); - - $fields = []; - $field_list = ! empty( $_POST['field_list'] ) ? directorist_maybe_json( wp_unslash( $_POST['field_list'] ) ) : []; - - foreach ( $field_list as $field_key ) { - if ( isset( $_POST[$field_key] ) && 'name' !== $field_key ) { - $fields[ $field_key ] = directorist_maybe_json( - wp_unslash( $_POST[ $field_key ] ), - true, - 'directorist_clean_post' - ); - } - } - - /** - * @since 7.7.0 - * It fires before directory data updated - */ - - do_action( 'directorist_before_directory_type_updated' ); - - $this->prepare_settings(); - - $add_directory = self::add_directory([ - 'term_id' => $term_id, - 'directory_name' => $directory_name, - 'fields_value' => $fields, - ]); - - if ( ! $add_directory['status']['success'] ) { - wp_send_json( $add_directory ); - } - - if ( directorist_is_multi_directory_enabled() && empty( $term_id ) ) { - $redirect_url = admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types&action=edit&listing_type_id=' . $add_directory['term_id'] ); - $add_directory['redirect_url'] = $redirect_url; - } - - wp_send_json( $add_directory ); - } - - // update_validated_term_meta - public static function update_validated_term_meta( $term_id, $field_key, $value ) { - if ( ! isset( self::$fields[$field_key] ) && ! array_key_exists( $field_key, self::$config['fields_group'] ) ) { - return; - } - - if ( ! empty( self::$fields[$field_key]['type'] ) && 'toggle' === self::$fields[$field_key]['type'] ) { - $value = ('true' === $value || true === $value || '1' === $value || 1 === $value) ? true : 0; - } - - $value = directorist_maybe_json( $value, false, 'directorist_clean_post' ); - - update_term_meta( $term_id, $field_key, $value ); - } - - public function prepare_settings() { - static::load_builder_data(); - } + use Multi_Directory_Helper; + + public static $fields = array(); + public static $layouts = array(); + public static $config = array(); + public static $options = array(); + + public static $migration = null; + + + public function __construct() { + self::$migration = new Multi_Directory_Migration( array( 'multi_directory_manager' => $this ) ); + } + + // run + public function run() { + add_action( 'init', array( $this, 'register_directory_taxonomy' ) ); + add_action( 'init', array( $this, 'setup_migration' ) ); + + if ( ! is_admin() ) { + return; + } + + add_filter( 'cptm_fields_before_update', array( $this, 'cptm_fields_before_update' ), 20, 1 ); + + add_action( 'admin_menu', array( $this, 'add_menu_pages' ) ); + add_action( 'admin_post_delete_listing_type', array( $this, 'handle_delete_listing_type_request' ) ); + + // Ajax + add_action( 'wp_ajax_save_post_type_data', array( $this, 'save_post_type_data' ) ); + add_action( 'wp_ajax_save_imported_post_type_data', array( $this, 'save_imported_post_type_data' ) ); + add_action( 'wp_ajax_directorist_force_migrate', array( $this, 'handle_force_migration' ) ); + add_action( 'wp_ajax_directorist_directory_type_library', array( $this, 'directorist_directory_type_library' ) ); + } + + public static function builder_data_backup( $term_id ) { + $submission_form_fields = get_term_meta( $term_id, 'submission_form_fields', true ); + $single_listings_contents = get_term_meta( $term_id, 'single_listings_contents', true ); + $single_listing_header = get_term_meta( $term_id, 'single_listing_header', true ); + + // Fetch existing backup data from the option + $existing_backup_data = get_option( 'directorist_builder_backup_data', array() ); + + // Decode the JSON data if it exists + $existing_backup_data = ! empty( $existing_backup_data ) ? json_decode( $existing_backup_data, true ) : array(); + + if ( ! empty( $submission_form_fields ) && ! empty( $single_listings_contents ) && ! empty( $single_listing_header ) ) { + $existing_backup_data[ $term_id ] = array( + 'submission_form_fields' => $submission_form_fields, + 'single_listings_contents' => $single_listings_contents, + 'single_listing_header' => $single_listing_header, + ); + // Convert the backup data to JSON format + $json_backup_data = wp_json_encode( $existing_backup_data ); + + // Save the JSON backup data in options + update_option( 'directorist_builder_backup_data', $json_backup_data ); + } + } + + // custom field assign to category migration + public static function migrate_custom_field( $term_id ) { + + $submission_form_fields = get_term_meta( $term_id, 'submission_form_fields', true ); + // custom field assign to category migration + if ( empty( $submission_form_fields['fields'] ) ) { + return; + } + + // Modify the 'assign_to' value based on your criteria (e.g., change 'category' to 1) + foreach ( $submission_form_fields['fields'] as $field_type => $options ) { + if ( empty( $options['assign_to'] ) ) { + continue; + } + + if ( $options['assign_to'] === 'category' ) { + $submission_form_fields['fields'][ $field_type ]['assign_to'] = 1; + } else { + $submission_form_fields['fields'][ $field_type ]['assign_to'] = false; + } + } + + update_term_meta( $term_id, 'submission_form_fields', $submission_form_fields ); + } + + + public static function migrate_review_settings( $term_id ) { + $old_review_settings = get_term_meta( $term_id, 'review_config', true ); + $new_review_builder = get_term_meta( $term_id, 'single_listings_contents', true ); + + // If no value is found, initialize the new review builder structure + if ( empty( $new_review_builder ) ) { + $new_review_builder = array( + 'fields' => array(), + 'groups' => array(), + ); + } + + // Update review_cookies_consent in the 'groups' array if the review widget exists + if ( ! empty( $old_review_settings['review_cookies_consent'] ) && is_array( $new_review_builder['groups'] ) ) { + foreach ( $new_review_builder['groups'] as &$group ) { + if ( isset( $group['widget_name'] ) && 'review' === $group['widget_name'] ) { + $group['review_cookies_consent'] = $old_review_settings['review_cookies_consent']; + } + } + } + + // Mapping for fields outside of groups + $fields_mapping = array( + 'review_comment' => array( + 'placeholder' => 'review_comment_placeholder', + 'widget_name' => 'review', + 'widget_child_name' => 'review_comment', + 'widget_key' => 'review_comment', + 'widget_group' => 'other_widgets', + ), + 'review_email' => array( + 'label' => 'review_email_label', + 'placeholder' => 'review_email_placeholder', + 'widget_name' => 'review', + 'widget_child_name' => 'review_email', + 'widget_key' => 'review_email', + 'widget_group' => 'other_widgets', + ), + 'review_name' => array( + 'label' => 'review_name_label', + 'placeholder' => 'review_name_placeholder', + 'widget_name' => 'review', + 'widget_child_name' => 'review_name', + 'widget_key' => 'review_name', + 'widget_group' => 'other_widgets', + ), + 'review_website' => array( + 'enable' => 'review_show_website_field', + 'label' => 'review_website_label', + 'placeholder' => 'review_website_placeholder', + 'widget_name' => 'review', + 'widget_child_name' => 'review_website', + 'widget_key' => 'review_website', + 'widget_group' => 'other_widgets', + ), + ); + + // Ensure the 'fields' key exists in the new_review_builder array + if ( ! isset( $new_review_builder['fields'] ) || ! is_array( $new_review_builder['fields'] ) ) { + $new_review_builder['fields'] = array(); // Initialize if not present + } + + // Add or update fields based on the mapping + foreach ( $fields_mapping as $field_key => $mapping ) { + if ( ! isset( $new_review_builder['fields'][ $field_key ] ) ) { + $new_review_builder['fields'][ $field_key ] = array(); // Initialize the field if it doesn't exist + } + + // Add or update the mapped values + foreach ( $mapping as $new_key => $old_key ) { + if ( $new_key === 'widget_name' || $new_key === 'widget_child_name' || $new_key === 'widget_key' || $new_key === 'widget_group' ) { + // Directly assign widget-related keys + $new_review_builder['fields'][ $field_key ][ $new_key ] = $old_key; + } else { + // Assign other keys if they exist in old_review_settings + if ( ! empty( $old_review_settings[ $old_key ] ) ) { + $new_review_builder['fields'][ $field_key ][ $new_key ] = $old_review_settings[ $old_key ]; + } + } + } + } + + // Ensure the 'groups' key exists in the new_review_builder array + if ( ! isset( $new_review_builder['groups'] ) || ! is_array( $new_review_builder['groups'] ) ) { + $new_review_builder['groups'] = array(); // Initialize if not present + } + + // Add or update groups with the 'review' widget + foreach ( $new_review_builder['groups'] as &$group ) { + if ( isset( $group['widget_name'] ) && 'review' === $group['widget_name'] ) { + foreach ( array_keys( $fields_mapping ) as $field_key ) { + // Add the field to the group if it doesn't already exist + if ( ! in_array( $field_key, $group['fields'] ) ) { + $group['fields'][] = $field_key; + } + } + } + } + + // Update the term meta with the modified new_review_builder array + update_term_meta( $term_id, 'single_listings_contents', $new_review_builder ); + } + + public static function migrate_contact_owner_settings( $term_id ) { + // Get the current settings + $single_listings_contents = get_term_meta( $term_id, 'single_listings_contents', true ); + + // Check if necessary fields exist + if ( empty( $single_listings_contents['fields'] ) || empty( $single_listings_contents['groups'] ) || ! is_array( $single_listings_contents['groups'] ) ) { + return; + } + + // Define the fields mapping + $fields_mapping = array( + 'contact_name' => array( + 'enable' => 1, + 'placeholder' => __( 'Name', 'directorist' ), + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_name', + 'widget_key' => 'contact_name', + ), + 'contact_email' => array( + 'placeholder' => __( 'Email', 'directorist' ), + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_email', + 'widget_key' => 'contact_email', + ), + 'contact_message' => array( + 'placeholder' => __( 'Message...', 'directorist' ), + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'widget_child_name' => 'contact_message', + 'widget_key' => 'contact_message', + ), + ); + + // Iterate over groups and update the contact listings owner group + foreach ( $single_listings_contents['groups'] as &$group ) { + if ( isset( $group['widget_name'] ) && 'contact_listings_owner' === $group['widget_name'] ) { + foreach ( $fields_mapping as $field_key => $mapping ) { + // Add or update fields + $single_listings_contents['fields'][ $field_key ] = $mapping; + + // Ensure the field is added to the group's fields + if ( ! in_array( $field_key, $group['fields'], true ) ) { + $group['fields'][] = $field_key; + } + } + } + } + + // Update the term meta with the modified contents + update_term_meta( $term_id, 'single_listings_contents', $single_listings_contents ); + } + + public static function migrate_related_listing_settings( $term_id ) { + $number = get_term_meta( $term_id, 'similar_listings_number_of_listings_to_show', true ); + $same_author = get_term_meta( $term_id, 'listing_from_same_author', true ); + $logic = get_term_meta( $term_id, 'similar_listings_logics', true ); + $column = get_term_meta( $term_id, 'similar_listings_number_of_columns', true ); + $new_related_listing = get_term_meta( $term_id, 'single_listings_contents', true ); + + if ( ! empty( $new_related_listing['groups'] ) && is_array( $new_related_listing['groups'] ) ) { + foreach ( $new_related_listing['groups'] as &$group ) { + if ( isset( $group['widget_name'] ) && 'related_listings' === $group['widget_name'] ) { + $group['similar_listings_logics'] = $logic ?? 'OR'; + $group['listing_from_same_author'] = $same_author ?? false; + $group['similar_listings_number_of_listings_to_show'] = absint( $number ?? 3 ); + $group['similar_listings_number_of_columns'] = absint( $column ?? 3 ); + } + } + } + + update_term_meta( $term_id, 'single_listings_contents', $new_related_listing ); + } + + public static function migrate_privacy_policy( $term_id ) { + $display_privacy = (bool) get_directorist_type_option( $term_id, 'listing_privacy' ); + $privacy_is_required = (bool) get_directorist_type_option( $term_id, 'privacy_is_required' ); + $display_terms = (bool) get_directorist_type_option( $term_id, 'listing_terms_condition' ); + $terms_is_required = (bool) get_directorist_type_option( $term_id, 'require_terms_conditions' ); + $submission_form = get_term_meta( $term_id, 'submission_form_fields', true ); + + // Generate the label with links to Privacy Policy and Terms of Service + $terms_privacy_label = sprintf( + __( 'I agree to the <a href="%1$s" target="_blank">Privacy Policy</a> and <a href="%2$s" target="_blank">Terms of Service</a>', 'directorist' ), + \ATBDP_Permalink::get_privacy_policy_page_url(), + \ATBDP_Permalink::get_terms_and_conditions_page_url() + ); + + // Determine if the field should be required + $is_required = ( $privacy_is_required || $terms_is_required ) ? 1 : ''; + + // Define the new field for terms and privacy + $terms_privacy_field = array( + 'type' => 'text', + 'field_key' => 'privacy_policy', + 'text' => $terms_privacy_label, // Use the generated label + 'required' => $is_required, // Dynamically set required status + 'widget_group' => 'preset', + 'widget_name' => 'terms_privacy', + 'widget_key' => 'terms_privacy', + ); + + // Check if either privacy or terms should be displayed + if ( $display_privacy || $display_terms ) { + // Add the new field to the fields array + $submission_form['fields']['terms_privacy'] = $terms_privacy_field; + // Add the 'terms_privacy' field to the last group in the 'groups' array + $last_group_key = array_key_last( $submission_form['groups'] ); // Get the last group key + $submission_form['groups'][ $last_group_key ]['fields'][] = 'terms_privacy'; // Add to the last group's fields + } + + // Update the term meta with the modified submission_form array + update_term_meta( $term_id, 'submission_form_fields', $submission_form ); + } + + // add_missing_single_listing_section_id + public function add_missing_single_listing_section_id() { + $directory_types = directorist_get_directories(); + + if ( is_wp_error( $directory_types ) || empty( $directory_types ) ) { + return; + } + + foreach ( $directory_types as $directory_type ) { + $single_listings_contents = get_term_meta( $directory_type->term_id, 'single_listings_contents', true ); + $need_to_update = false; + + if ( empty( $single_listings_contents ) ) { + continue; + } + + if ( empty( $single_listings_contents['groups'] ) ) { + continue; + } + + foreach ( $single_listings_contents['groups'] as $group_index => $group ) { + $has_section_id = ( ! empty( $group['section_id'] ) ) ? true : false; + $renew = ( $has_section_id ) ? false : true; + $renew = apply_filters( 'directorist_renew_single_listing_section_id', $renew ); + + if ( ! $renew ) { + continue; + } + + $group['section_id'] = $group_index + 1; + $single_listings_contents['groups'][ $group_index ] = $group; + $need_to_update = true; + } + + if ( $need_to_update ) { + update_term_meta( $directory_type->term_id, 'single_listings_contents', $single_listings_contents ); + } + } + } + + // update_default_directory_type_option + public function update_default_directory_type_option() { + $args = array( + 'meta_query' => array( + array( + 'key' => '_default', + 'value' => true, + ), + ), + ); + + $default_directory = get_directorist_option( 'atbdp_default_derectory', '' ); + $terms = directorist_get_directories( $args ); + + if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) { + $default_directory = $terms[0]->term_id; + } + + update_directorist_option( 'atbdp_default_derectory', $default_directory ); + } + + // setup_migration + public function setup_migration() { + $migrated = get_option( 'atbdp_migrated', false ); + $need_migration = ( empty( $migrated ) && ! self::has_multidirectory() && self::has_old_listings_data() ) ? true : false; + + if ( $need_migration ) { + $this->prepare_settings(); + self::$migration->migrate(); + return; + } + + $need_import_default = ( ! self::has_multidirectory() ) ? true : false; + + if ( apply_filters( 'atbdp_import_default_directory', $need_import_default ) ) { + $this->prepare_settings(); + $this->import_default_directory(); + } + } + + // has_multidirectory + public static function has_multidirectory() { + $directory_types = directorist_get_directories(); + + return ( ! is_wp_error( $directory_types ) && ! empty( $directory_types ) ) ? true : false; + } + + // has_old_listings_data + public static function has_old_listings_data() { + $get_listings = new \WP_Query( + array( + 'post_type' => ATBDP_POST_TYPE, + 'posts_per_page' => 1, + 'fields' => 'ids', + ) + ); + + $get_custom_fields = new \WP_Query( + array( + 'post_type' => ATBDP_CUSTOM_FIELD_POST_TYPE, + 'posts_per_page' => 1, + 'fields' => 'ids', + ) + ); + + $has_listings = $get_listings->post_count; + $has_custom_fields = $get_custom_fields->post_count; + + return ( $has_listings || $has_custom_fields ) ? true : false; + } + + // handle_force_migration + public function handle_force_migration() { + if ( ! directorist_verify_nonce() ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ), + ), + ), + 200 + ); + } + + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'message' => __( 'You are not allowed to access this resource', 'directorist' ), + ), + ), + 200 + ); + } + + wp_send_json( $this->run_force_migration() ); + } + + public function directorist_directory_type_library() { + + if ( ! directorist_verify_nonce() ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'message' => __( 'Something is wrong! Please refresh and retryyy.', 'directorist' ), + ), + ), + 200 + ); + } + + if ( ! current_user_can( 'install_plugins' ) || ! current_user_can( 'activate_plugins' ) ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'message' => __( 'You are not allowed to add/activate new plugin', 'directorist' ), + ), + ), + 200 + ); + } + + $installed = directorist_download_plugin( array( 'url' => 'https://downloads.wordpress.org/plugin/templatiq.zip' ) ); + $path = WP_PLUGIN_DIR . '/templatiq/templatiq.php'; + + if ( ! is_plugin_active( $path ) ) { + activate_plugin( $path ); + } + + $installed['redirect'] = admin_url( 'admin.php?page=templatiq' ); + wp_send_json( $installed ); + } + + // run_force_migration + public function run_force_migration() { + $general_directory = term_exists( 'General', 'atbdp_listing_types' ); + $args = array(); + + if ( $general_directory ) { + $args['term_id'] = $general_directory['term_id']; + } + + $this->prepare_settings(); + $migration_status = self::$migration->migrate( $args ); + + $status = array( + 'success' => $migration_status['success'], + 'message' => ( $migration_status ) ? __( 'Migration Successful', 'directorist' ) : __( 'Migration Failed', 'directorist' ), + ); + + return $status; + } + + // import_default_directory + public function import_default_directory( array $args = array() ) { + $file = DIRECTORIST_ASSETS_DIR . 'sample-data/directory/directory.json'; + if ( ! file_exists( $file ) ) { + return; } + $file_contents = file_get_contents( $file ); + + $add_directory = self::add_directory( + array( + 'directory_name' => 'General', + 'fields_value' => $file_contents, + 'is_json' => true, + ) + ); + + if ( $add_directory['status']['success'] ) { + update_option( 'atbdp_has_multidirectory', true ); + update_term_meta( $add_directory['term_id'], '_default', true ); + + // Add directory type to all listings + $listings = new \WP_Query( + array( + 'post_type' => ATBDP_POST_TYPE, + 'status' => 'publish', + 'per_page' => -1, + ) + ); + + if ( $listings->have_posts() ) { + while ( $listings->have_posts() ) { + $listings->the_post(); + + wp_set_object_terms( get_the_id(), $add_directory['term_id'], 'atbdp_listing_types' ); + } + wp_reset_postdata(); + } + } + } + + public function save_imported_post_type_data() { + + if ( ! directorist_verify_nonce() ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'status_log' => array( + 'nonce_is_missing' => array( + 'type' => 'error', + 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ), + ), + ), + ), + ), + 200 + ); + } + + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'status_log' => array( + 'access_denied' => array( + 'type' => 'error', + 'message' => __( 'You are not allowed to access this resource', 'directorist' ), + ), + ), + ), + ), + 200 + ); + } + + $term_id = ( ! empty( $_POST['term_id'] ) ) ? absint( $_POST['term_id'] ) : 0; + $directory_name = ( ! empty( $_POST['directory-name'] ) ) ? sanitize_text_field( wp_unslash( $_POST['directory-name'] ) ) : ''; + $json_file = ( ! empty( $_FILES['directory-import-file'] ) ) ? directorist_clean( wp_unslash( $_FILES['directory-import-file'] ) ) : ''; + + // Validation + $response = array( + 'status' => array( + 'success' => true, + 'status_log' => array(), + 'error_count' => 0, + ), + ); + + // Validate file + if ( empty( $json_file ) ) { + $response['status']['status_log']['file_is_missing'] = array( + 'type' => 'error', + 'message' => __( 'File is missing', 'directorist' ), + ); + + ++$response['status']['error_count']; + } + + // Validate file data + $file_contents = file_get_contents( $json_file['tmp_name'] ); + if ( empty( $file_contents ) ) { + $response['status']['status_log']['invalid_data'] = array( + 'type' => 'error', + 'message' => __( 'The data is invalid', 'directorist' ), + ); + + ++$response['status']['error_count']; + } + + // Send respone if has error + if ( $response['status']['error_count'] ) { + $response['status']['success'] = false; + wp_send_json( $response, 200 ); + } + + // If dierctory name is numeric update the term instead of creating + if ( is_numeric( $directory_name ) ) { + $term_id = (int) $directory_name; + $directory_name = ''; + } + + $this->prepare_settings(); + + $add_directory = self::add_directory( + array( + 'term_id' => $term_id, + 'directory_name' => $directory_name, + 'fields_value' => $file_contents, + 'is_json' => true, + ) + ); + + wp_send_json( $add_directory, 200 ); + } + + + // cptm_fields_before_update + public function cptm_fields_before_update( $fields ) { + $new_fields = $fields; + $fields_group = self::$config['fields_group']; + + foreach ( $fields_group as $group_name => $group_fields ) { + $grouped_fields_value = array(); + + foreach ( $group_fields as $field_index => $field_key ) { + if ( is_string( $field_key ) && array_key_exists( $field_key, self::$fields ) ) { + $grouped_fields_value[ $field_key ] = ( isset( $new_fields[ $field_key ] ) ) ? $new_fields[ $field_key ] : ''; + unset( $new_fields[ $field_key ] ); + } + + if ( is_array( $field_key ) ) { + $grouped_fields_value[ $field_index ] = array(); + + foreach ( $field_key as $sub_field_key ) { + if ( array_key_exists( $sub_field_key, self::$fields ) ) { + $grouped_fields_value[ $field_index ][ $sub_field_key ] = ( isset( $new_fields[ $sub_field_key ] ) ) ? $new_fields[ $sub_field_key ] : ''; + unset( $new_fields[ $sub_field_key ] ); + } + } + } + } + + $new_fields[ $group_name ] = $grouped_fields_value; + } + + return $new_fields; + } + + // save_post_type_data + public function save_post_type_data() { + if ( ! directorist_verify_nonce() ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'status_log' => array( + 'nonce_is_missing' => array( + 'type' => 'error', + 'message' => __( 'Something is wrong! Please refresh and retry.', 'directorist' ), + ), + ), + ), + ), + 200 + ); + } + + if ( ! current_user_can( 'manage_options' ) ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'status_log' => array( + 'access_denied' => array( + 'type' => 'error', + 'message' => __( 'You are not allowed to access this resource', 'directorist' ), + ), + ), + ), + ), + 200 + ); + } + + if ( empty( $_POST['name'] ) ) { + wp_send_json( + array( + 'status' => array( + 'success' => false, + 'status_log' => array( + 'name_is_missing' => array( + 'type' => 'error', + 'message' => __( 'Name is missing', 'directorist' ), + ), + ), + ), + ), + 200 + ); + } + + $term_id = ( ! empty( $_POST['listing_type_id'] ) ) ? absint( $_POST['listing_type_id'] ) : 0; + $directory_name = sanitize_text_field( wp_unslash( $_POST['name'] ) ); + + $fields = array(); + $field_list = ! empty( $_POST['field_list'] ) ? directorist_maybe_json( wp_unslash( $_POST['field_list'] ) ) : array(); + + foreach ( $field_list as $field_key ) { + if ( isset( $_POST[ $field_key ] ) && 'name' !== $field_key ) { + $fields[ $field_key ] = directorist_maybe_json( + wp_unslash( $_POST[ $field_key ] ), + true, + 'directorist_clean_post' + ); + } + } + + /** + * @since 7.7.0 + * It fires before directory data updated + */ + + do_action( 'directorist_before_directory_type_updated' ); + + $this->prepare_settings(); + + $add_directory = self::add_directory( + array( + 'term_id' => $term_id, + 'directory_name' => $directory_name, + 'fields_value' => $fields, + ) + ); + + if ( ! $add_directory['status']['success'] ) { + wp_send_json( $add_directory ); + } + + if ( directorist_is_multi_directory_enabled() && empty( $term_id ) ) { + $redirect_url = admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types&action=edit&listing_type_id=' . $add_directory['term_id'] ); + $add_directory['redirect_url'] = $redirect_url; + } + + wp_send_json( $add_directory ); + } + + // update_validated_term_meta + public static function update_validated_term_meta( $term_id, $field_key, $value ) { + if ( ! isset( self::$fields[ $field_key ] ) && ! array_key_exists( $field_key, self::$config['fields_group'] ) ) { + return; + } + + if ( ! empty( self::$fields[ $field_key ]['type'] ) && 'toggle' === self::$fields[ $field_key ]['type'] ) { + $value = ( 'true' === $value || true === $value || '1' === $value || 1 === $value ) ? true : 0; + } + + $value = directorist_maybe_json( $value, false, 'directorist_clean_post' ); + + update_term_meta( $term_id, $field_key, $value ); + } + + public function prepare_settings() { + static::load_builder_data(); + } public static function load_builder_data() { - if ( empty( self::$fields ) ) { - $builder_data = new Builder_Data(); - - self::$fields = $builder_data->get_fields(); - self::$layouts = $builder_data->get_layouts(); - self::$config = $builder_data->get_config(); - self::$options = $builder_data->get_options(); - } - } - - // add_menu_pages - public function add_menu_pages() - { - $page_title = __( 'Directory Builder', 'directorist' ); - $page_slug = 'atbdp-layout-builder'; - - if ( directorist_is_multi_directory_enabled() ) { - $page_title = __( 'Directory Builder', 'directorist' ); - $page_slug = 'atbdp-directory-types'; - } - - add_submenu_page( - 'edit.php?post_type=at_biz_dir', - $page_title, - $page_title, - 'manage_options', - $page_slug, - [$this, 'menu_page_callback__directory_types'], - 5 - ); - } - - // get_default_directory_id - public function get_default_directory_id() { - $default_directory = get_directorist_option( 'atbdp_default_derectory', '' ); - - if ( ! empty( $default_directory ) ) { - return $default_directory; - } - - return 0; - } - - // menu_page_callback__directory_types - public function menu_page_callback__directory_types() - { - $enable_multi_directory = directorist_is_multi_directory_enabled(); - - $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; - $listing_type_id = 0; - - $data = [ - 'add_new_link' => admin_url('edit.php?post_type=at_biz_dir&page=atbdp-directory-types&action=add_new'), - ]; - - if ( ! $enable_multi_directory || ( ! empty( $action ) && ('edit' === $action || 'add_new' === $action ) ) ) { - $this->prepare_settings(); - $this->add_missing_single_listing_section_id(); - - $listing_type_id = ( ! empty( $_REQUEST['listing_type_id'] ) ) ? absint( $_REQUEST['listing_type_id'] ) : 0; - $listing_type_id = ( ! $enable_multi_directory ) ? default_directory_type() : $listing_type_id; - - $this->update_fields_with_old_data( $listing_type_id ); - - $directory_builder_data = [ - 'fields' => self::$fields, - 'layouts' => self::$layouts, - 'config' => self::$config, - 'options' => self::$options, - 'id' => $listing_type_id, - ]; + if ( empty( self::$fields ) ) { + $builder_data = new Builder_Data(); + + self::$fields = $builder_data->get_fields(); + self::$layouts = $builder_data->get_layouts(); + self::$config = $builder_data->get_config(); + self::$options = $builder_data->get_options(); + } + } + + // add_menu_pages + public function add_menu_pages() { + $page_title = __( 'Directory Builder', 'directorist' ); + $page_slug = 'atbdp-layout-builder'; + + if ( directorist_is_multi_directory_enabled() ) { + $page_title = __( 'Directory Builder', 'directorist' ); + $page_slug = 'atbdp-directory-types'; + } + + add_submenu_page( + 'edit.php?post_type=at_biz_dir', + $page_title, + $page_title, + 'manage_options', + $page_slug, + array( $this, 'menu_page_callback__directory_types' ), + 5 + ); + } + + // get_default_directory_id + public function get_default_directory_id() { + $default_directory = get_directorist_option( 'atbdp_default_derectory', '' ); + + if ( ! empty( $default_directory ) ) { + return $default_directory; + } + + return 0; + } + + // menu_page_callback__directory_types + public function menu_page_callback__directory_types() { + $enable_multi_directory = directorist_is_multi_directory_enabled(); + + $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; + $listing_type_id = 0; + + $data = array( + 'add_new_link' => admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types&action=add_new' ), + ); + + if ( ! $enable_multi_directory || ( ! empty( $action ) && ( 'edit' === $action || 'add_new' === $action ) ) ) { + $this->prepare_settings(); + $this->add_missing_single_listing_section_id(); + + $listing_type_id = ( ! empty( $_REQUEST['listing_type_id'] ) ) ? absint( $_REQUEST['listing_type_id'] ) : 0; + $listing_type_id = ( ! $enable_multi_directory ) ? default_directory_type() : $listing_type_id; + + $this->update_fields_with_old_data( $listing_type_id ); + + $directory_builder_data = array( + 'fields' => self::$fields, + 'layouts' => self::$layouts, + 'config' => self::$config, + 'options' => self::$options, + 'id' => $listing_type_id, + ); /** * Filter directory builder's all configuration data. @@ -833,145 +869,154 @@ public function menu_page_callback__directory_types() */ $directory_builder_data = apply_filters( 'directorist_builder_localize_data', $directory_builder_data ); - $data[ 'directory_builder_data' ] = $directory_builder_data; + $data['directory_builder_data'] = $directory_builder_data; - atbdp_load_admin_template('post-types-manager/edit-listing-type', $data); - return; - } + atbdp_load_admin_template( 'post-types-manager/edit-listing-type', $data ); + return; + } - atbdp_load_admin_template('post-types-manager/all-listing-types', $data); - } + atbdp_load_admin_template( 'post-types-manager/all-listing-types', $data ); + } - public function update_fields_with_old_data( $listing_type_id = 0 ) { - $term = get_term($listing_type_id, 'atbdp_listing_types'); + public function update_fields_with_old_data( $listing_type_id = 0 ) { + $term = get_term( $listing_type_id, 'atbdp_listing_types' ); - if ( is_wp_error( $term ) || empty( $term ) ) { - return; - } + if ( is_wp_error( $term ) || empty( $term ) ) { + return; + } - $term_name = ( $term ) ? $term->name : ''; - $term_id = ( $term ) ? $term->term_id : 0; + $term_name = ( $term ) ? $term->name : ''; + $term_id = ( $term ) ? $term->term_id : 0; - self::$options['name']['value'] = $term_name; + self::$options['name']['value'] = $term_name; - $all_term_meta = get_term_meta( $term_id ); - $test_migration = apply_filters( 'atbdp_test_migration', false ); + $all_term_meta = get_term_meta( $term_id ); + $test_migration = apply_filters( 'atbdp_test_migration', false ); - if ( $test_migration ) { - $all_term_meta = self::$migration->get_fields_data(); - } + if ( $test_migration ) { + $all_term_meta = self::$migration->get_fields_data(); + } - if ( ! is_array( $all_term_meta ) ) { + if ( ! is_array( $all_term_meta ) ) { return; } - foreach ( $all_term_meta as $meta_key => $meta_value ) { - if ( isset( self::$fields[$meta_key] ) ) { - $_meta_value = ( ! $test_migration ) ? $meta_value[0] : $meta_value; - $value = maybe_unserialize( maybe_unserialize( $_meta_value ) ); - - self::$fields[ $meta_key ]['value'] = $value; - } - } - - foreach (self::$config['fields_group'] as $group_key => $group_fields) { - if (array_key_exists($group_key, $all_term_meta)) { - $_group_meta_value = ( ! $test_migration ) ? $all_term_meta[$group_key][0] : $all_term_meta[$group_key]; - $group_value = maybe_unserialize( maybe_unserialize( $_group_meta_value ) ); - - foreach ($group_fields as $field_index => $field_key) { - - if ( ! key_exists( $field_key, $group_value ) ) { continue; } - - if ( is_string( $field_key ) && array_key_exists($field_key, self::$fields)) { - self::$fields[$field_key]['value'] = $group_value[$field_key]; - } - - if ( is_array( $field_key ) ) { - foreach ($field_key as $sub_field_key) { - if (array_key_exists($sub_field_key, self::$fields)) { - self::$fields[$sub_field_key]['value'] = $group_value[$field_index][$sub_field_key]; - } - } - } - } - } - } - } - - // handle_delete_listing_type_request - public function handle_delete_listing_type_request() - { - if ( ! directorist_verify_nonce( '_wpnonce', 'delete_listing_type' ) ) { - wp_die( esc_html__( 'Invalid request', 'directorist' ) ); - } - - if ( ! current_user_can( 'manage_options' ) ) { - wp_die( esc_html__( 'You are not allowed to delete directory type', 'directorist' ) ); - } - - $term_id = isset( $_REQUEST['listing_type_id'] ) ? absint( $_REQUEST['listing_type_id'] ) : 0; - - $this->delete_listing_type($term_id); - - wp_redirect(admin_url('edit.php?post_type=at_biz_dir&page=atbdp-directory-types')); - exit; - } - - // delete_listing_type - public function delete_listing_type($term_id = 0) - { - if (wp_delete_term($term_id, 'atbdp_listing_types')) { - atbdp_add_flush_alert([ - 'id' => 'deleting_listing_type_status', - 'page' => 'all-listing-type', - 'message' => __( 'Successfully Deleted the listing type', 'directorist' ), - ]); - } else { - atbdp_add_flush_alert([ - 'id' => 'deleting_listing_type_status', - 'page' => 'all-listing-type', - 'type' => 'error', - 'message' => __( 'Failed to delete the listing type', 'directorist' ) - ]); - } - } - - // register_directory_taxonomy - public function register_directory_taxonomy() - { - register_taxonomy( ATBDP_DIRECTORY_TYPE, [ ATBDP_POST_TYPE ], [ - 'hierarchical' => false, - 'labels' => [ - 'name' => _x( 'Listing Directory', 'taxonomy general name', 'directorist' ), - 'singular_name' => _x( 'Listing Directory', 'taxonomy singular name', 'directorist' ), - 'search_items' => __( 'Search listing directory', 'directorist' ), - 'menu_name' => __( 'Listing Directory', 'directorist' ), - ], - 'show_ui' => false, - ] ); - } - - /** - * Get all the pages in an array where each page is an array of key:value:id and key:label:name - * - * Example : array( - * array('value'=> 1, 'label'=> 'page_name'), - * array('value'=> 50, 'label'=> 'page_name'), - * ) - * @return array page names with key value pairs in a multi-dimensional array - * @since 3.0.0 - */ - public function get_pages_vl_arrays() - { - $pages = get_pages(); - $pages_options = array(); - if ($pages) { - foreach ($pages as $page) { - $pages_options[] = array('value' => $page->ID, 'label' => $page->post_title); - } - } - - return $pages_options; - } + foreach ( $all_term_meta as $meta_key => $meta_value ) { + if ( isset( self::$fields[ $meta_key ] ) ) { + $_meta_value = ( ! $test_migration ) ? $meta_value[0] : $meta_value; + $value = maybe_unserialize( maybe_unserialize( $_meta_value ) ); + + self::$fields[ $meta_key ]['value'] = $value; + } + } + + foreach ( self::$config['fields_group'] as $group_key => $group_fields ) { + if ( array_key_exists( $group_key, $all_term_meta ) ) { + $_group_meta_value = ( ! $test_migration ) ? $all_term_meta[ $group_key ][0] : $all_term_meta[ $group_key ]; + $group_value = maybe_unserialize( maybe_unserialize( $_group_meta_value ) ); + + foreach ( $group_fields as $field_index => $field_key ) { + + if ( ! key_exists( $field_key, $group_value ) ) { + continue; } + + if ( is_string( $field_key ) && array_key_exists( $field_key, self::$fields ) ) { + self::$fields[ $field_key ]['value'] = $group_value[ $field_key ]; + } + + if ( is_array( $field_key ) ) { + foreach ( $field_key as $sub_field_key ) { + if ( array_key_exists( $sub_field_key, self::$fields ) ) { + self::$fields[ $sub_field_key ]['value'] = $group_value[ $field_index ][ $sub_field_key ]; + } + } + } + } + } + } + } + + // handle_delete_listing_type_request + public function handle_delete_listing_type_request() { + if ( ! directorist_verify_nonce( '_wpnonce', 'delete_listing_type' ) ) { + wp_die( esc_html__( 'Invalid request', 'directorist' ) ); + } + + if ( ! current_user_can( 'manage_options' ) ) { + wp_die( esc_html__( 'You are not allowed to delete directory type', 'directorist' ) ); + } + + $term_id = isset( $_REQUEST['listing_type_id'] ) ? absint( $_REQUEST['listing_type_id'] ) : 0; + + $this->delete_listing_type( $term_id ); + + wp_redirect( admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types' ) ); + exit; + } + + // delete_listing_type + public function delete_listing_type( $term_id = 0 ) { + if ( wp_delete_term( $term_id, 'atbdp_listing_types' ) ) { + atbdp_add_flush_alert( + array( + 'id' => 'deleting_listing_type_status', + 'page' => 'all-listing-type', + 'message' => __( 'Successfully Deleted the listing type', 'directorist' ), + ) + ); + } else { + atbdp_add_flush_alert( + array( + 'id' => 'deleting_listing_type_status', + 'page' => 'all-listing-type', + 'type' => 'error', + 'message' => __( 'Failed to delete the listing type', 'directorist' ), + ) + ); + } + } + + // register_directory_taxonomy + public function register_directory_taxonomy() { + register_taxonomy( + ATBDP_DIRECTORY_TYPE, + array( ATBDP_POST_TYPE ), + array( + 'hierarchical' => false, + 'labels' => array( + 'name' => _x( 'Listing Directory', 'taxonomy general name', 'directorist' ), + 'singular_name' => _x( 'Listing Directory', 'taxonomy singular name', 'directorist' ), + 'search_items' => __( 'Search listing directory', 'directorist' ), + 'menu_name' => __( 'Listing Directory', 'directorist' ), + ), + 'show_ui' => false, + ) + ); + } + + /** + * Get all the pages in an array where each page is an array of key:value:id and key:label:name + * + * Example : array( + * array('value'=> 1, 'label'=> 'page_name'), + * array('value'=> 50, 'label'=> 'page_name'), + * ) + * + * @return array page names with key value pairs in a multi-dimensional array + * @since 3.0.0 + */ + public function get_pages_vl_arrays() { + $pages = get_pages(); + $pages_options = array(); + if ( $pages ) { + foreach ( $pages as $page ) { + $pages_options[] = array( + 'value' => $page->ID, + 'label' => $page->post_title, + ); + } + } + + return $pages_options; + } } diff --git a/includes/modules/multi-directory-setup/class-multi-directory-migration.php b/includes/modules/multi-directory-setup/class-multi-directory-migration.php index 57521ad6c4..b366aea978 100644 --- a/includes/modules/multi-directory-setup/class-multi-directory-migration.php +++ b/includes/modules/multi-directory-setup/class-multi-directory-migration.php @@ -4,1851 +4,1874 @@ class Multi_Directory_Migration { - public $multi_directory_manager = null; - - public function __construct( array $args = [] ) { - if ( isset( $args['multi_directory_manager'] ) ) { - $this->multi_directory_manager = $args['multi_directory_manager']; - } - } - - public function migrate( array $args = [] ) { - $default = []; - $args = array_merge( $default, $args ); - - $fields = $this->get_fields_data(); - $add_directory_args = [ - 'directory_name' => 'General', - 'fields_value' => $fields, - ]; - - $add_directory_args = array_merge( $add_directory_args, $args ); - $add_directory = $this->multi_directory_manager->add_directory( $add_directory_args ); - - if ( $add_directory['status']['success'] ) { - $directory_types = directorist_get_directories(); - - if ( ! empty( $directory_types ) ) { - foreach ( $directory_types as $directory_type ) { - update_term_meta( $directory_type->term_id, '_default', false ); - } - } - - update_term_meta( $add_directory['term_id'], '_default', true ); - update_option( 'atbdp_migrated', true ); - - // Add directory type to all locations and categories - $terms = [ ATBDP_CATEGORY, ATBDP_LOCATION ]; - foreach( $terms as $term ) { - $term_data = get_terms([ - 'taxonomy' => $term, - 'hide_empty' => false, - 'orderby' => 'date', - 'order' => 'DSCE', - ]); - if( !empty( $term_data ) ) { - foreach( $term_data as $data ) { - update_term_meta( $data->term_id, '_directory_type', [ $add_directory['term_id']] ); - } - } - } - - // Add directory type to all listings - $listings = new \WP_Query([ - 'post_type' => ATBDP_POST_TYPE, - 'status' => 'publish', - 'posts_per_page' => -1, - 'fields' => 'ids', - ]); - - $listings_ids = ( ! is_wp_error( $listings ) )? wp_parse_id_list( $listings->posts ) : []; - - if ( ! empty( $listings_ids ) ) { - foreach( $listings_ids as $listings_id ) { - // Set Directory Type - wp_set_object_terms( $listings_id, $add_directory['term_id'], 'atbdp_listing_types' ); - update_post_meta( $listings_id, '_directory_type', $add_directory['term_id'] ); - } - } - - return [ 'success' => true ]; - } - - return [ 'success' => false ]; - - } - - // get_fields_data - public function get_fields_data() { - $old_custom_fields = $this->get_old_custom_fields(); - $form_fields_common_data = [ 'old_custom_fields' => $old_custom_fields ]; - - $submission_form_fields_data = $this->get_submission_form_fields_data( $form_fields_common_data ); - $form_fields_common_data['submission_form_fields_data'] = $submission_form_fields_data; - - $listings_card_wedgets = $this->get_listings_card_wedgets_data(); - $listings_card_common_data = [ 'listings_card_wedgets' => $listings_card_wedgets ]; - - $fields = apply_filters( 'atbdp_multidirectory_migration_fields', [ - "icon" => "las la-home", - "singular_name" => "listing", - "plural_name" => "listings", - "permalink" => "listing", - "preview_mode" => get_directorist_option( 'preview_enable', true ), - "preview_image" => get_directorist_option( 'default_preview_image', true ), - - "default_expiration" => get_directorist_option( 'listing_expire_in_days', 365 ), - "new_listing_status" => get_directorist_option( 'new_listing_status', 'pending' ), - "edit_listing_status" => get_directorist_option( 'edit_listing_status', 'pending' ), - "submit_button_label" => get_directorist_option( 'submit_label', 'Save & Preview' ), - "listing_terms_condition" => get_directorist_option( 'listing_terms_condition', true ), - "require_terms_conditions" => get_directorist_option( 'require_terms_conditions', true ), - "terms_label" => $this->get_terms_label(), - "listing_privacy" => get_directorist_option( 'listing_privacy', true ), - "require_privacy" => get_directorist_option( 'require_privacy', true ), - "privacy_label" => $this->get_privacy_label(), - "submission_form_fields" => $submission_form_fields_data, - "single_listings_contents" => $this->get_single_listings_contents_data( $form_fields_common_data ), - "similar_listings_title" => get_directorist_option( 'rel_listing_title', true ), - "enable_similar_listings" => get_directorist_option( 'enable_rel_listing', true ), - "similar_listings_logics" => get_directorist_option( 'rel_listings_logic', 'OR' ), - "search_form_fields" => $this->get_search_form_fields( $form_fields_common_data ), - "single_listing_header" => $this->get_single_listing_header_data(), - "listings_card_grid_view" => $this->get_listings_card_grid_view_data( $listings_card_common_data ), - "listings_card_list_view" => $this->get_listings_card_list_view_data( $listings_card_common_data ), - - "similar_listings_number_of_listings_to_show" => get_directorist_option( 'rel_listing_num', 10 ), - "similar_listings_number_of_columns" => get_directorist_option( 'rel_listing_column', 3 ), - ]); - - return $fields; - } - - // get_submission_form_fields_data - public function get_submission_form_fields_data( array $args = [] ) { - $default = [ 'old_custom_fields' => [] ]; - $args = array_merge( $default, $args ); - - // Submission Form Fields - $preset_fields = []; - - // Group Keys - $general_group_field_keys = []; - $contact_group_info_field_keys = []; - $map_group_field_keys = []; - $gallery_group_field_keys = []; - - // General Group - // ------------------------------ - // Title - $general_group_field_keys[] = 'title'; - $preset_fields[ "title" ] = [ - "field_key" => "listing_title", - "type" => "text", - "required" => get_directorist_option( 'require_title', true ), - "label" => get_directorist_option( 'title_label', "Title" ), - "placeholder" => get_directorist_option( 'title_placeholder', "Enter a title" ), - "widget_group" => "preset", - "widget_name" => "title", - "widget_key" => "title", - ]; - - // Description - $general_group_field_keys[] = 'description'; - $preset_fields[ "description" ] = [ - "field_key" => "listing_content", - "type" => "wp_editor", - "label" => get_directorist_option( 'long_details_label', 'Long Details' ), - "placeholder" => "", - "required" => get_directorist_option( 'require_long_details', false ), - "only_for_admin" => get_directorist_option( 'display_desc_for', false ), - "widget_group" => "preset", - "widget_name" => "description", - "widget_key" => "description", - ]; - - // Excerpt - if ( ! empty( get_directorist_option( 'display_excerpt_field', true ) ) ) { - $general_group_field_keys[] = 'excerpt'; - $preset_fields[ "excerpt" ] = [ - "field_key" => "excerpt", - "label" => get_directorist_option( 'excerpt_label', 'Short Description/Excerpt' ), - "words_limit" => '', - "placeholder" => get_directorist_option( 'excerpt_placeholder', false ), - "required" => get_directorist_option( 'require_excerpt', false ), - "only_for_admin" => get_directorist_option( 'display_short_desc_for', false ), - "widget_group" => "preset", - "widget_name" => "excerpt", - "widget_key" => "excerpt", - ]; - } - - if ( ! empty( get_directorist_option( 'display_views_count', true ) ) ) { - $general_group_field_keys[] = 'view_count'; - $preset_fields[ "view_count" ] = [ - "type" => "number", - "field_key" => "atbdp_post_views_count", - "label" => get_directorist_option( 'views_count_label', 'Views Count' ), - "placeholder" => "", - "required" => false, - "only_for_admin" => true, - "widget_group" => "preset", - "widget_name" => "view_count", - "widget_key" => "view_count", - ]; - } - - if ( ! empty( get_directorist_option( 'display_tagline_field', true ) ) ) { - $general_group_field_keys[] = 'tagline'; - $preset_fields[ "tagline" ] = [ - "field_key" => "tagline", - "type" => "text", - "label" => get_directorist_option( 'tagline_label', 'Tagline' ), - "placeholder" => get_directorist_option( 'tagline_placeholder', "Your Listing's motto or tag-line" ), - "widget_group" => "preset", - "widget_name" => "tagline", - "widget_key" => "tagline", - ]; - } - - if ( ! empty( get_directorist_option( 'display_pricing_field', true ) ) ) { - $general_group_field_keys[] = 'pricing'; - $preset_fields[ "pricing" ] = [ - "field_key" => "pricing", - "pricing_type" => "both", - "label" => get_directorist_option( 'pricing_label', 'Pricing' ), - "price_range_label" => get_directorist_option( 'price_range_label', 'Select Price Range' ), - "price_range_options" => "cheap", - "price_unit_field_type" => "number", - "price_unit_field_label" => get_directorist_option( 'price_label', 'Price' ), - "widget_group" => "preset", - "widget_name" => "pricing", - "widget_key" => "pricing", - ]; - } - - if( !empty( $this->get_old_custom_fields() ) ){ - foreach( $this->get_old_custom_fields() as $key => $value ){ - $general_group_field_keys[] = $key; - $preset_fields[ $key ] = $value; - } - } - - $general_group_field_keys[] = 'location'; - $preset_fields[ "location" ] = [ - "type" => "multiple", - "field_key" => "tax_input[at_biz_dir-location][]", - "label" => get_directorist_option( 'location_label', 'Location' ), - "required" => get_directorist_option( 'require_location', false ), - "only_for_admin" => get_directorist_option( 'display_loc_for', false ), - "widget_group" => "preset", - "widget_name" => "location", - "widget_key" => "location" - ]; - - $general_group_field_keys[] = 'tag'; - $preset_fields[ "tag" ] = [ - "type" => "multiple", - "field_key" => "tax_input[at_biz_dir-tags][]", - "label" => get_directorist_option( 'tag_label', 'Tag' ), - "required" => get_directorist_option( 'require_tags', false ), - "allow_new" => get_directorist_option( 'create_new_tag', true ), - "only_for_admin" => get_directorist_option( 'display_tag_for', false ), - "widget_group" => "preset", - "widget_name" => "tag", - "widget_key" => "tag" - ]; - - $general_group_field_keys[] = 'category'; - $preset_fields[ "category" ] = [ - "type" => "multiple", - "field_key" => "admin_category_select[]", - "label" => get_directorist_option( 'category_label', 'Select Category' ), - "required" => get_directorist_option( 'require_category', false ), - "only_for_admin" => false, - "widget_group" => "preset", - "widget_name" => "category", - "widget_key" => "category", - ]; - - // Contact Group - // ------------------------------ - $contact_group_info_field_keys[] = 'hide_contact_owner'; - $preset_fields[ "hide_contact_owner" ] = [ - "type" => "checkbox", - "field_key" => "hide_contact_owner", - "label" => 'Hide contact owner form for single listing page', - "placeholder" => get_directorist_option( 'zip_placeholder', 'Enter Zip/Post Code' ), - "required" => get_directorist_option( 'require_zip', false ), - "widget_group" => "preset", - "widget_name" => "hide_contact_owner", - "widget_key" => "hide_contact_owner", - ]; - - if ( ! empty( get_directorist_option( 'display_zip_field', true ) ) ) { - $contact_group_info_field_keys[] = 'zip'; - $preset_fields[ "zip" ] = [ - "type" => "text", - "field_key" => "zip", - "label" => get_directorist_option( 'zip_label', 'Zip/Post Code' ), - "placeholder" => get_directorist_option( 'zip_placeholder', 'Enter Zip/Post Code' ), - "required" => get_directorist_option( 'require_zip', false ), - "only_for_admin" => get_directorist_option( 'display_zip_for', false ), - "widget_group" => "preset", - "widget_name" => "zip", - "widget_key" => "zip", - ]; - } - - if ( ! empty( get_directorist_option( 'display_phone_field', true ) ) ) { - $contact_group_info_field_keys[] = 'phone'; - $preset_fields[ "phone" ] = [ - "type" => "tel", - "field_key" => "phone", - "label" => get_directorist_option( 'phone_label', 'Phone' ), - "placeholder" => get_directorist_option( 'phone_placeholder', 'Phone Number' ), - "required" => get_directorist_option( 'require_phone_number', false ), - "only_for_admin" => get_directorist_option( 'display_phone_for', false ), - "widget_group" => "preset", - "widget_name" => "phone", - "widget_key" => "phone" - ]; - } - - if ( ! empty( get_directorist_option( 'display_phone_field2', true ) ) ) { - $contact_group_info_field_keys[] = 'phone2'; - $preset_fields[ "phone2" ] = [ - "type" => "tel", - "field_key" => "phone2", - "label" => get_directorist_option( 'phone_label2', 'Phone 2' ), - "placeholder" => get_directorist_option( 'phone2_placeholder', 'Phone Number' ), - "required" => get_directorist_option( 'require_phone2_number', false ), - "only_for_admin" => get_directorist_option( 'display_phone2_for', false ), - "widget_group" => "preset", - "widget_name" => "phone2", - "widget_key" => "phone2", - ]; - } - - if ( ! empty( get_directorist_option( 'display_fax', true ) ) ) { - $contact_group_info_field_keys[] = 'fax'; - $preset_fields[ "fax" ] = [ - "type" => "number", - "field_key" => "fax", - "label" => get_directorist_option( 'fax_label', 'Fax' ), - "placeholder" => get_directorist_option( 'fax_placeholder', 'Enter Fax' ), - "required" => get_directorist_option( 'require_fax', false ), - "only_for_admin" => get_directorist_option( 'display_fax_for', false ), - "widget_group" => "preset", - "widget_name" => "fax", - "widget_key" => "fax", - ]; - } - - if ( ! empty( get_directorist_option( 'display_email_field', true ) ) ) { - $contact_group_info_field_keys[] = 'email'; - $preset_fields[ "email" ] = [ - "type" => "email", - "field_key" => "email", - "label" => get_directorist_option( 'email_label', 'Email' ), - "placeholder" => get_directorist_option( 'email_placeholder', 'Enter Email' ), - "required" => get_directorist_option( 'require_email', false ), - "only_for_admin" => get_directorist_option( 'display_email_for', false ), - "widget_group" => "preset", - "widget_name" => "email", - "widget_key" => "email", - ]; - } - - if ( ! empty( get_directorist_option( 'display_website_field', true ) ) ) { - $contact_group_info_field_keys[] = 'website'; - $preset_fields[ "website" ] = [ - "type" => "text", - "field_key" => "website", - "label" => get_directorist_option( 'website_label', 'Website' ), - "placeholder" => get_directorist_option( 'website_placeholder', 'Listing Website eg. http://example.com' ), - "required" => get_directorist_option( 'require_website', false ), - "only_for_admin" => get_directorist_option( 'display_website_for', false ), - "plans" => [], - "widget_group" => "preset", - "widget_name" => "website", - "widget_key" => "website", - ]; - } - - if ( ! empty( get_directorist_option( 'display_social_info_field', true ) ) ) { - $contact_group_info_field_keys[] = 'social_info'; - $preset_fields[ "social_info" ] = [ - "type" => "add_new", - "field_key" => "social", - "label" => get_directorist_option( 'social_label', 'Social Information' ), - "required" => get_directorist_option( 'require_social_info', false ), - "only_for_admin" => get_directorist_option( 'display_social_info_for', false ), - "widget_group" => "preset", - "widget_name" => "social_info", - "widget_key" => "social_info", - ]; - } - - if ( ! empty( get_directorist_option( 'display_address_field', true ) ) ) { - $map_group_field_keys[] = 'address'; - $preset_fields[ "address" ] = [ - "type" => "text", - "field_key" => "address", - "label" => get_directorist_option( 'address_label', 'Address' ), - "placeholder" => get_directorist_option( 'address_placeholder', 'Listing address eg. New York, USA' ), - "required" => get_directorist_option( 'require_address', false ), - "only_for_admin" => get_directorist_option( 'display_address_for', false ), - "widget_group" => "preset", - "widget_name" => "address", - "widget_key" => "address", - ]; - } - - if ( ! empty( get_directorist_option( 'display_map_field', true ) ) ) { - $map_group_field_keys[] = 'map'; - $preset_fields[ "map" ] = [ - "type" => "map", - "field_key" => "map", - "label" => "Map", - "only_for_admin" => get_directorist_option( 'display_map_for', false ), - "lat_long" => "Or Enter Coordinates (latitude and longitude) Manually", - "required" => false, - "widget_group" => "preset", - "widget_name" => "map", - "widget_key" => "map", - ]; - } - - if ( ! empty( get_directorist_option( 'display_gallery_field', true ) ) ) { - $gallery_group_field_keys[] = 'image_upload'; - $preset_fields[ "image_upload" ] = [ - "type" => "media", - "field_key" => "listing_img", - "label" => "Images", - "select_files_label" => get_directorist_option( 'gallery_label', 'Select Files' ), - "required" => get_directorist_option( 'require_gallery_img', false ), - "max_image_limit" => get_directorist_option( 'require_gallery_img', 5 ), - "max_per_image_limit" => get_directorist_option( 'max_gallery_upload_size_per_file', 0 ), - "max_total_image_limit" => get_directorist_option( 'max_gallery_upload_size', 2 ), - "only_for_admin" => get_directorist_option( 'display_glr_img_for', false ), - "widget_group" => "preset", - "widget_name" => "image_upload", - "widget_key" => "image_upload", - ]; - } - - if ( ! empty( get_directorist_option( 'display_gallery_field', true ) ) ) { - $gallery_group_field_keys[] = 'video'; - $preset_fields[ "video" ] = [ - "type" => "text", - "field_key" => "videourl", - "label" => get_directorist_option( 'video_label', 'Video Url' ), - "placeholder" => get_directorist_option( 'video_placeholder', 'Only YouTube & Vimeo URLs.' ), - "required" => get_directorist_option( 'require_video', false ), - "only_for_admin" => get_directorist_option( 'display_video_for', false ), - "widget_group" => "preset", - "widget_name" => "video", - "widget_key" => "video", - ]; - } - - $custom_fields = $args[ 'old_custom_fields' ]; - $all_form_fields = array_merge( $preset_fields, $custom_fields ); - - $form_groups = []; - - // General Group - $form_groups[] = [ - "label" => "General Information", - "lock" => true, - "fields" => $general_group_field_keys, - ]; - - // Contact Info - $form_groups[] = [ - "label" => "Contact Information", - "fields" => $contact_group_info_field_keys, - ]; - - // Map - $form_groups[] = [ - "label" => "Map", - "fields" => $map_group_field_keys, - ]; - - // Gallery - $form_groups[] = [ - "label" => "Images & Video", - "fields" => $gallery_group_field_keys, - ]; - - $submission_form_fields = [ - "fields" => $all_form_fields, - "groups" => $form_groups - ]; - - return $submission_form_fields; - } - - // get_single_listings_contents_data - public function get_single_listings_contents_data( array $args = [] ) { - - $default = [ 'old_custom_fields' => [] ]; - $args = array_merge( $default, $args ); - - // Single Listing Contents - $single_listings_preset_fields = []; - $map_group_field_keys = []; - $contact_info_group_field_keys = []; - $video_group_field_keys = []; - - $single_listings_preset_fields["tag"] = [ - 'icon' => 'las la-tag', - "widget_name" => "tag", - "widget_group" => "preset_widgets", - ]; - - if ( ! empty( get_directorist_option( 'display_map_field', true ) ) ) { - $map_group_field_keys[] = 'map'; - $single_listings_preset_fields["map"] = [ - 'icon' => 'las la-map', - "widget_name" => "map", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_map_field', true ) ) ) { - $contact_info_group_field_keys[] = 'address'; - $single_listings_preset_fields["address"] = [ - "icon" => "las la-map", - 'address_link_with_map' => false, - "widget_name" => "address", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_phone_field', true ) ) ) { - $contact_info_group_field_keys[] = 'phone'; - $single_listings_preset_fields["phone"] = [ - "icon" => "las la-phone", - "widget_name" => "phone", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_phone_field2', true ) ) ) { - $contact_info_group_field_keys[] = 'phone2'; - $single_listings_preset_fields["phone2"] = [ - "icon" => "las la-phone", - "widget_name" => "phone2", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_zip_field', true ) ) ) { - $contact_info_group_field_keys[] = 'zip'; - $single_listings_preset_fields["zip"] = [ - "icon" => "las la-street-view", - "widget_name" => "zip", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_email_field', true ) ) ) { - $contact_info_group_field_keys[] = 'email'; - $single_listings_preset_fields["email"] = [ - "icon" => "las la-envelope", - "widget_name" => "email", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_website_field', true ) ) ) { - $contact_info_group_field_keys[] = 'website'; - $single_listings_preset_fields["website"] = [ - "icon" => "las la-globe", - "widget_name" => "website", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_fax', true ) ) ) { - $contact_info_group_field_keys[] = 'fax'; - $single_listings_preset_fields["fax"] = [ - "icon" => "las la-fax", - "widget_name" => "fax", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_social_info_field', true ) ) ) { - $contact_info_group_field_keys[] = 'social_info'; - $single_listings_preset_fields["social_info"] = [ - "icon" => "las la-share-alt", - "widget_name" => "social_info", - "widget_group" => "preset_widgets", - ]; - } - - if ( ! empty( get_directorist_option( 'display_video_field', true ) ) ) { - $video_group_field_keys[] = 'video'; - $single_listings_preset_fields["video"] = [ - "icon" => "las la-video", - "widget_name" => "video", - "widget_group" => "preset_widgets", - ]; - } - - $this->multi_directory_manager->prepare_settings(); - $single_listings_widgets = []; - if ( - isset( $this->multi_directory_manager::$fields ) && - isset( $this->multi_directory_manager::$fields['single_listings_contents'] ) && - isset( $this->multi_directory_manager::$fields['single_listings_contents']['widgets'] ) && - isset( $this->multi_directory_manager::$fields['single_listings_contents']['widgets']['preset_widgets'] ) && - isset( $this->multi_directory_manager::$fields['single_listings_contents']['widgets']['preset_widgets']['widgets'] ) && - is_array( $this->multi_directory_manager::$fields['single_listings_contents']['widgets']['preset_widgets']['widgets'] ) - ) { - $single_listings_widgets = $this->multi_directory_manager::$fields['single_listings_contents']['widgets']['preset_widgets']['widgets']; - } - - $single_listings_widgets_keys = is_array( $single_listings_widgets ) ? array_keys( $single_listings_widgets ) : []; - $single_listings_custom_fields = []; - $custom_fields = $args[ 'old_custom_fields' ]; - foreach ( $custom_fields as $field_key => $args ) { - $widget_args = [ - "label" => $args['label'], - "widget_group" => "preset_widgets", - "widget_name" => $field_key - ]; - - if ( ! in_array( $args['widget_name'], $single_listings_widgets_keys ) ) { - continue; - } - - if ( ! isset( $single_listings_widgets[ $args['widget_name'] ]['options'] ) ) { - continue; - } - - foreach ( $single_listings_widgets[ $args['widget_name'] ]['options'] as $option_key => $option_args ) { - $widget_args[ $option_key ] = $option_args['value']; - } - - $single_listings_custom_fields[ $field_key ] = $widget_args; - } - - $single_listings_fields = array_merge( $single_listings_preset_fields, $single_listings_custom_fields ); - $single_listings_groups = []; - - if ( ! empty( get_directorist_option( 'enable_single_tag', true ) ) ) { - $single_listings_groups[] = [ - "label" => get_directorist_option( 'tags_section_lable', __( 'Tags', 'directorist' ) ), - "fields" => [ "tag" ], - 'type' => 'general_group', - 'icon' => 'las la-tags', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - } - - if ( ! empty( $single_listings_custom_fields ) && is_array( $single_listings_custom_fields ) ) { - $single_listings_groups[] = [ - "label" => get_directorist_option( 'custom_section_lable', __( 'Features', 'directorist' ) ), - "fields" => array_keys( $single_listings_custom_fields ), - 'type' => 'general_group', - 'icon' => 'las la-bars', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - } - - if ( empty( get_directorist_option( 'disable_map', false ) ) && ! empty( $map_group_field_keys ) ) { - $single_listings_groups[] = [ - "label" => get_directorist_option( 'listing_location_text', __( 'Location', 'directorist' ) ), - "fields" => $map_group_field_keys, - 'type' => 'general_group', - 'icon' => 'las la-map', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - } - - if ( empty( get_directorist_option( 'disable_contact_info', false ) ) && ! empty( $contact_info_group_field_keys ) ) { - $single_listings_groups[] = [ - "label" => get_directorist_option( 'contact_info_text', __( 'Contact Information', 'directorist' ) ), - "fields" => $contact_info_group_field_keys, - 'type' => 'general_group', - 'icon' => 'las la-envelope-open', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - } - - if ( ! empty( get_directorist_option( 'atbd_video_url', true ) ) && ! empty( $video_group_field_keys ) ) { - $single_listings_groups[] = [ - "label" => get_directorist_option( 'atbd_video_title', __( 'Video', 'directorist' ) ), - "fields" => $video_group_field_keys, - 'type' => 'general_group', - 'icon' => 'las la-video', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - } - - $single_listings_groups[] = [ - "label" => get_directorist_option( 'atbd_author_info_title', __( 'Author Info', 'directorist' ) ), - "fields" => [], - 'type' => 'widget_group', - 'widget_group' => 'other_widgets', - 'widget_name' => 'author_info', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - - if ( empty( get_directorist_option( 'disable_contact_owner', false ) ) ) { - $single_listings_groups[] = [ - "label" => get_directorist_option( 'contact_listing_owner', __( 'Contact Listings Owner', 'directorist' ) ), - "fields" => [], - 'type' => 'widget_group', - 'widget_group' => 'other_widgets', - 'widget_name' => 'contact_listings_owner', - 'icon' => 'las la-phone', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - } - - if ( ! empty( get_directorist_option( 'enable_review', true ) ) ) { - $single_listings_groups[] = [ - "label" => "Review", - "fields" => [], - 'type' => 'widget_group', - 'widget_group' => 'other_widgets', - 'widget_name' => 'review', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - } - - if ( ! empty( get_directorist_option( 'enable_rel_listing', true ) ) ) { - $single_listings_groups[] = [ - "label" => get_directorist_option( 'rel_listing_title', __( 'Related Listings', 'directorist' ) ), - "fields" => [], - 'type' => 'widget_group', - 'widget_group' => 'other_widgets', - 'widget_name' => 'related_listings', - 'custom_block_id' => '', - 'custom_block_classes' => '', - ]; - } - - $single_listings_contents = [ - "fields" => $single_listings_fields, - "groups" => $single_listings_groups - ]; - - // directorist_console_log( $single_listings_contents ); - - return $single_listings_contents; - } - - // get_search_form_fields - public function get_search_form_fields( array $args = [] ) { - $default = [ 'old_custom_fields' => [] ]; - $args = array_merge( $default, $args ); - - // Search Form - $search_fields_map = [ - // Basic - 'search_text' => [ - 'field_key' => 'title', - 'options' => [ - "required" => get_directorist_option( 'require_search_text', false ), - "label" => "", - "placeholder" => get_directorist_option( 'listings_search_text_placeholder', "What are you looking for?" ), - "widget_name" => "title", - "widget_group" => "available_widgets", - ], - ], - 'search_category' => [ - 'field_key' => 'category', - 'options' => [ - "required" => get_directorist_option( 'require_search_category', false ), - "label" => "", - "placeholder" => get_directorist_option( 'search_category_placeholder', "Select a category" ), - "widget_name" => "category", - "widget_group" => "available_widgets", - ], - ], - 'search_location' => [ - 'field_key' => 'location', - "options" => [ - "required" => get_directorist_option( 'require_search_location', false ), - "placeholder" => get_directorist_option( 'search_location_placeholder', "Select a category" ), - "widget_group" => "available_widgets", - "label" => "", - "widget_name" => "location", - ], - ], - - // Advanced - 'search_rating' => [ - 'field_key' => 'review', - "options" => [ - "required" => false, - "widget_group" => "available_widgets", - "widget_name" => "", - "placeholder" => "" - ], - ], - 'search_tag' => [ - 'field_key' => 'tag', - "options" => [ - 'label' => 'Tag', - 'widget_name' => 'tag', - 'widget_group' => 'available_widgets', - ], - ], - // 'search_open_now' => [ - // 'field_key' => 'open_now', - // "options" => [ - // 'label' => 'Open Now', - // 'widget_name' => 'open_now', - // 'widget_group' => 'available_widgets', - // ], - // ], - 'search_website' => [ - 'field_key' => 'website', - "options" => [ - 'label' => 'Website', - "widget_group" => "available_widgets", - "widget_name" => "", - "placeholder" => "" - ], - ], - 'search_email' => [ - 'field_key' => 'email', - "options" => [ - 'label' => 'Email', - "widget_group" => "available_widgets", - "widget_name" => "", - "placeholder" => "" - ], - ], - 'search_phone' => [ - 'field_key' => 'phone', - "options" => [ - 'label' => 'Phone', - "widget_group" => "available_widgets", - "widget_name" => "", - "placeholder" => "" - ], - ], - 'search_fax' => [ - 'field_key' => 'fax', - "options" => [ - 'label' => 'Fax', - "widget_group" => "available_widgets", - "widget_name" => "fax", - "placeholder" => "" - ], - ], - 'search_zip_code' => [ - 'field_key' => 'zip', - "options" => [ - 'label' => 'Zip/Post Code', - 'placeholder' => 'Zip', - 'required' => false, - 'widget_name' => 'zip', - 'widget_group' => 'available_widgets', - ], - ], - 'phone' => [ - 'field_key' => 'phone', - "options" => [ - 'label' => 'Phone', - 'placeholder' => 'Phone', - 'required' => false, - 'widget_name' => 'phone', - 'widget_group' => 'available_widgets', - ], - ], - 'phone2' => [ - 'field_key' => 'phone', - "options" => [ - 'label' => 'Phone 2', - 'placeholder' => 'Phone 2', - 'required' => false, - 'widget_name' => 'phone2', - 'widget_group' => 'available_widgets', - ], - ], - 'radius_search' => [ - 'field_key' => 'radius_search', - "options" => [ - 'label' => 'Radius Search', - 'default_radius_distance' => 0, - 'radius_search_unit' => 'miles', - 'widget_name' => 'radius_search', - 'widget_group' => 'other_widgets', - ], - ], - 'search_rating' => [ - 'field_key' => 'review', - "options" => [ - 'label' => 'Review', - 'widget_name' => 'review', - 'widget_group' => 'other_widgets', - ], - ], - ]; - - // Get Basic Search Fields - $old_basic_search_fields = get_directorist_option( 'search_tsc_fields', [] ); - - $search_form_fields_basic_items = []; - - foreach ( $old_basic_search_fields as $field_key ) { - if ( empty( $search_fields_map[ $field_key ] ) ) { continue; } - - $new_field_key = $search_fields_map[ $field_key ][ 'field_key' ]; - $search_form_fields_basic_items[ $new_field_key ] = $search_fields_map[ $field_key ][ 'options' ]; - } - - // Get Advanced Fields - $old_advanced_search_fields = get_directorist_option( 'search_more_filters_fields', [] ); - $search_form_fields_advanced_items = []; - - // var_dump( $old_advanced_search_fields ); - - foreach ( $old_advanced_search_fields as $field_key ) { - if ( empty( $search_fields_map[ $field_key ] ) ) { continue; } - - $new_field_key = $search_fields_map[ $field_key ][ 'field_key' ]; - $search_form_fields_advanced_items[ $new_field_key ] = $search_fields_map[ $field_key ][ 'options' ]; - } - - // Get Other Fields - // Price Field - if ( in_array( 'search_price', $old_advanced_search_fields ) || in_array( 'search_price_range', $old_advanced_search_fields ) ) { - $search_form_fields_advanced_items[ 'pricing' ] = [ - 'label' => 'Pricing', - 'price_range_min_placeholder' => 'Min', - 'price_range_max_placeholder' => 'Max', - "widget_name" => "pricing", - "widget_group" => "available_widgets", - ]; - } - - // Custom Fields - if ( in_array( 'search_custom_fields', $old_advanced_search_fields ) && ! empty( $args[ 'old_custom_fields' ] ) ) { - // submission_form_fields_data - $custom_fields = $args[ 'old_custom_fields' ]; - $submission_form_field_keys = []; - - if ( ! empty( $args[ 'submission_form_fields_data' ] ) && ! empty( $args[ 'submission_form_fields_data' ]['fields'] ) && is_array( $args[ 'submission_form_fields_data' ]['fields'] ) ) { - $submission_form_field_keys = array_keys( $args[ 'submission_form_fields_data' ]['fields'] ); - } - - foreach ( $custom_fields as $field_key => $field_args ) { - if ( empty( $field_args['searchable'] ) || ! in_array( $field_key, $submission_form_field_keys ) ) { continue; } - - $search_form_fields_advanced_items[ $field_key ] = [ - "label" => $field_args['label'], - "widget_group" => "available_widgets", - "widget_name" => $field_args['type'] - ]; - } - } - - - $search_form_all_fields = array_merge( $search_form_fields_basic_items, $search_form_fields_advanced_items ); - $search_form_fields = [ - "fields" => $search_form_all_fields, - "groups" => [ - [ - "label" => "Basic", - "lock" => true, - "draggable" => false, - "fields" => array_keys( $search_form_fields_basic_items ) - ], - [ - "label" => "Advanced", - "lock" => true, - "draggable" => false, - "fields" => array_keys( $search_form_fields_advanced_items ) - ] - ] - ]; - - return $search_form_fields; - } - - // get_single_listing_header_data - public function get_single_listing_header_data() { - // Single Listing - // Quick Actions Items - $quick_actions = []; - if ( '1' == get_directorist_option( 'enable_favourite', true ) ) { - $quick_actions[] = [ - "type" => "button", - "label" => "Bookmark", - "widget_name" => "bookmark", - "widget_key" => "bookmark", - 'icon' => 'las la-heart', - ]; - } - if ( '1' == get_directorist_option( 'enable_report_abuse', true ) ) { - $quick_actions[] = [ - "type" => "badge", - "label" => "Share", - "hook" => "atbdp_single_listings_title", - "widget_name" => "share", - "widget_key" => "share", - "icon" => "las la-share" - ]; - } - if ( '1' == get_directorist_option( 'enable_social_share', true ) ) { - $quick_actions[] = [ - "type" => "badge", - "label" => "Report", - "hook" => "atbdp_single_listings_title", - "widget_name" => "report", - "widget_key" => "report", - "icon" => "las la-flag" - ]; - } - - // Thumbnail Items - $thumbnail = []; - if ( '1' == get_directorist_option( 'dsiplay_slider_single_page', true ) ) { - $thumbnail[] = [ - "type" => "thumbnail", - "label" => "Select Files", - "hook" => "atbdp_single_listings_slider", - "widget_name" => "listing_slider", - "widget_key" => "listing_slider", - "footer_thumbail" => get_directorist_option( 'dsiplay_thumbnail_img', true ) - ]; - } - - // Quick Info Items - $quick_info = []; - if ( '0' == get_directorist_option( 'disable_list_price', true ) ) { - $quick_info[] = [ - "type" => "badge", - "label" => "Pricing", - "hook" => "atbdp_single_listings_price", - "widget_name" => "price", - "widget_key" => "price" - ]; - } - - $quick_info[] = [ - "type" => "ratings-count", - "label" => "Listings Ratings", - "widget_name" => "ratings_count", - "widget_key" => "ratings_count" - ]; - - $quick_info[] = [ - "type" => "reviews", - "label" => "Listings Reviews", - "widget_name" => "reviews", - "widget_key" => "reviews" - ]; - - $quick_info[] = [ - "type" => "badge", - "label" => "Badges", - "widget_name" => "badges", - "widget_key" => "badges", - "new_badge" => get_directorist_option( 'display_new_badge_cart', true ), - "popular_badge" => get_directorist_option( 'display_popular_badge_cart', true ) - ]; - - $quick_info[] = [ - "type" => "badge", - "label" => "Category", - "widget_name" => "category", - "widget_key" => "category" - ]; - - $quick_info[] = [ - "type" => "badge", - "label" => "Location", - "widget_name" => "location", - "widget_key" => "location" - ]; - - - $single_listing_header = [ - "listings_header" => [ - "quick_actions" => $quick_actions, - "thumbnail" => $thumbnail, - "quick_info" => $quick_info - ], - - "options" => [ - "general" => [ - "back" => [ - "label" => get_directorist_option( 'display_back_link', true ) - ], - "section_title" => [ - "label" => get_directorist_option( 'listing_details_text', 'Listing Details' ) - ] - ], - "content_settings" => [ - "listing_title" => [ - "enable_title" => true, - "enable_tagline" => true - ], - "listing_description" => [ - "enable" => true - ] - ] - ] - ]; - - return $single_listing_header; - } - - // get_listings_card_grid_view_data - public function get_listings_card_grid_view_data( array $args = [] ) { - $active_template = ( ! empty( get_directorist_option( 'display_preview_image' ) ) ) ? 'grid_view_with_thumbnail' : 'grid_view_without_thumbnail'; - $grid_view['active_template'] = $active_template; - - $grid_view['template_data'] = []; - $grid_view['template_data']['grid_view_with_thumbnail'] = $this->get_listings_card_grid_view_with_thumbnail_data( $args ); - $grid_view['template_data']['grid_view_without_thumbnail'] = $this->get_listings_card_grid_view_without_thumbnail_data( $args ); - - return $grid_view; - } - - // get_listings_card_grid_view_data - public function get_listings_card_grid_view_with_thumbnail_data( array $args = [] ) { - - $default = [ 'listings_card_wedgets' => $this->get_listings_card_wedgets_data() ]; - $args = array_merge( $default, $args ); - $listings_card_wedgets = $args[ 'listings_card_wedgets' ]; - - $card_layouts = [ - 'thumbnail_top_right' => [], - 'thumbnail_top_left' => [], - 'thumbnail_bottom_right' => [], - 'thumbnail_bottom_left' => [], - 'thumbnail_avatar' => [], - 'body_top' => [], - 'body_bottom' => [], - 'body_excerpt' => [], - 'footer_right' => [], - 'footer_left' => [], - ]; - - $widget_layout_map = [ - 'favorite_badge' => [ - 'enable' => get_directorist_option( 'display_mark_as_fav', true ), - 'layout' => [ 'default' => 'thumbnail_top_right' ], - ], - 'featured_badge' => [ - 'enable' => get_directorist_option( 'display_feature_badge_cart', true ), - 'layout' => [ 'default' => 'thumbnail_top_left' ], - ], - 'new_badge' => [ - 'enable' => get_directorist_option( 'display_new_badge_cart', true ), - 'layout' => [ - 'default' => 'thumbnail_bottom_left', - 'direo' => 'thumbnail_top_left', - 'dlist' => 'thumbnail_top_left', - 'dservice' => 'thumbnail_top_left', - ], - ], - 'popular_badge' => [ - 'enable' => get_directorist_option( 'display_popular_badge_cart', true ), - 'layout' => [ - 'default' => 'thumbnail_bottom_left', - 'direo' => 'thumbnail_top_left', - 'dlist' => 'thumbnail_top_left', - 'dservice' => 'thumbnail_top_left', - ], - ], - 'user_avatar' => [ - 'enable' => get_directorist_option( 'display_author_image', true ), - 'layout' => [ 'default' => 'thumbnail_avatar' ], - ], - 'listing_title' => [ - 'enable' => get_directorist_option( 'display_title', true ), - 'layout' => [ 'default' => 'body_top' ], - ], - 'rating' => [ - 'enable' => get_directorist_option( 'enable_review', true ), - 'layout' => [ 'default' => 'body_top' ], - ], - 'pricing' => [ - 'enable' => get_directorist_option( 'display_pricing_field', true ), - 'layout' => [ - 'default' => 'body_top', - 'dservice' => 'thumbnail_bottom_right', - ], - ], - 'listings_location' => [ - 'enable' => get_directorist_option( 'display_contact_info', true ), - 'layout' => [ 'default' => 'body_bottom' ], - ], - 'posted_date' => [ - 'enable' => get_directorist_option( 'display_publish_date', true ), - 'layout' => [ 'default' => 'body_bottom' ], - ], - 'phone' => [ - 'enable' => get_directorist_option( 'display_contact_info', true ), - 'layout' => [ 'default' => 'body_bottom' ], - ], - 'website' => [ - 'enable' => get_directorist_option( 'display_web_link', true ), - 'layout' => [ 'default' => 'body_bottom' ], - ], - 'excerpt' => [ - 'enable' => get_directorist_option( 'enable_excerpt', true ), - 'layout' => [ 'default' => 'body_excerpt' ], - ], - 'view_count' => [ - 'enable' => get_directorist_option( 'display_view_count', true ), - 'layout' => [ 'default' => 'footer_right' ], - ], - 'contact_button' => [ - 'layout' => [ - 'default' => '', - 'dservice' => 'footer_right', - ], - ], - 'category' => [ - 'enable' => get_directorist_option( 'display_category', true ), - 'layout' => [ 'default' => 'footer_left' ], - ], - ]; - - $current_theme = wp_get_theme(); - $current_theme = $current_theme->stylesheet; - - // Fill layout with widgets - foreach ( $widget_layout_map as $widget_key => $args ) { - if ( isset( $args['enable'] ) && empty( $args['enable'] ) ) { continue; } - - $layout = ( in_array( $current_theme, array_keys( $args['layout'] ) ) ) ? $args['layout'][ $current_theme ] : $args['layout']['default']; - - if ( ! empty( $layout ) ) { - $card_layouts[ $layout ][] = $listings_card_wedgets[ $widget_key ]; - } - } - - $listings_card_grid_view = apply_filters( 'listings_card_grid_view_with_thumbnail', [ - "thumbnail"=> [ - "top_right" => $card_layouts['thumbnail_top_right'], - "top_left" => $card_layouts['thumbnail_top_left'], - "bottom_right" => $card_layouts['thumbnail_bottom_right'], - "bottom_left" => $card_layouts['thumbnail_bottom_left'], - "avatar" => $card_layouts['thumbnail_avatar'], - ], - "body" => [ - "top" => $card_layouts['body_top'], - "bottom" => $card_layouts['body_bottom'], - "excerpt" => $card_layouts['body_excerpt'] - ], - "footer"=> [ - "right" => $card_layouts['footer_right'], - "left" => $card_layouts['footer_left'], - ] - ]); - - return $listings_card_grid_view; - } - // get_listings_card_grid_view_without_thumbnail_data - public function get_listings_card_grid_view_without_thumbnail_data( array $args = [] ) { - $default = [ 'listings_card_wedgets' => $this->get_listings_card_wedgets_data() ]; - $args = array_merge( $default, $args ); - - $listings_card_wedgets = $args[ 'listings_card_wedgets' ]; - - // Listings Card Grid View - thumbnail_top_left - $listings_card_grid_view_body_quick_info = []; - if ( get_directorist_option( 'enable_review', true ) ) { - $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['rating']; - } - - if ( get_directorist_option( 'display_pricing_field', true ) && get_directorist_option( 'display_price', true ) ) { - $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['pricing']; - } - - if ( get_directorist_option( 'display_feature_badge_cart', true ) ) { - $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['featured_badge']; - } - - if ( get_directorist_option( 'display_popular_badge_cart', true ) ) { - $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['popular_badge']; - } - - if ( get_directorist_option( 'display_new_badge_cart', true ) ) { - $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['new_badge']; - } - - // listings_card_grid_view_body_avatar - $listings_card_grid_view_body_avatar = []; - if ( get_directorist_option( 'display_author_image', true ) ) { - $user_avatar = $listings_card_wedgets['user_avatar']; - $listings_card_grid_view_body_avatar[] = $user_avatar; - } - - // listings_card_grid_view_body_title - $listings_card_grid_view_body_title = []; - if ( get_directorist_option( 'display_title', true ) ) { - $listings_card_grid_view_body_title[] = $listings_card_wedgets['listing_title']; - } - - // listings_card_grid_view_body_quick_actions - $listings_card_grid_view_body_quick_actions = []; - if ( get_directorist_option( 'display_mark_as_fav', true ) ) { - $listings_card_grid_view_body_quick_actions[] = $listings_card_wedgets['favorite_badge']; - } - - // listings_card_grid_view_body_quick_info - $listings_card_grid_view_body_quick_info = []; - if ( get_directorist_option( 'display_mark_as_fav', true ) ) { - $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['favorite_badge']; - } - - // listings_card_grid_view_body_bottom - $listings_card_grid_view_body_bottom = []; - if ( get_directorist_option( 'display_contact_info', true ) ) { - $listings_card_grid_view_body_bottom[] = $listings_card_wedgets['listings_location']; - } - - if ( get_directorist_option( 'display_publish_date', true ) ) { - $listings_card_grid_view_body_bottom[] = $listings_card_wedgets['posted_date']; - } - - if ( get_directorist_option( 'display_contact_info', true ) ) { - $listings_card_grid_view_body_bottom[] = $listings_card_wedgets['phone']; - } - - if ( get_directorist_option( 'display_web_link', true ) ) { - $listings_card_grid_view_body_bottom[] = $listings_card_wedgets['website']; - } - - $listings_card_grid_view_body_excerpt = []; - if ( get_directorist_option( 'enable_excerpt', true ) ) { - $listings_card_grid_view_body_excerpt[] = $listings_card_wedgets['excerpt']; - } - - // listings_card_grid_view_footer_right - $listings_card_grid_view_footer_right = []; - if ( get_directorist_option( 'display_view_count', true ) ) { - $listings_card_grid_view_footer_right[] = $listings_card_wedgets['view_count']; - } - - // listings_card_grid_view_footer_left - $listings_card_grid_view_footer_left = []; - if ( get_directorist_option( 'display_category', true ) ) { - $listings_card_grid_view_footer_left[] = $listings_card_wedgets['category']; - } - - $listings_card_grid_view = apply_filters( 'listings_card_grid_view_without_thumbnail', [ - "body" => [ - "avatar" => $listings_card_grid_view_body_avatar, - "title" => $listings_card_grid_view_body_title, - "quick_actions" => $listings_card_grid_view_body_quick_actions, - "quick_info" => $listings_card_grid_view_body_quick_info, - "bottom" => $listings_card_grid_view_body_bottom, - "excerpt" => $listings_card_grid_view_body_excerpt - ], - "footer" => [ - "right" => $listings_card_grid_view_footer_right, - "left" => $listings_card_grid_view_footer_left, - ] - ]); - - return $listings_card_grid_view; - } - - // get_listings_card_list_view_data - public function get_listings_card_list_view_data( array $args = [] ) { - $active_template = ( ! empty( get_directorist_option( 'display_preview_image' ) ) ) ? 'list_view_with_thumbnail' : 'list_view_without_thumbnail'; - $list_view['active_template'] = $active_template; - - $list_view['template_data'] = []; - $list_view['template_data']['list_view_with_thumbnail'] = $this->get_listings_card_list_view_with_thumbnail_data( $args ); - $list_view['template_data']['list_view_without_thumbnail'] = $this->get_listings_card_list_view_without_thumbnail_data( $args ); - - return $list_view; - } - - // get_listings_card_list_view_with_thumbnail_data - public function get_listings_card_list_view_with_thumbnail_data( array $args = [] ) { - $default = [ 'listings_card_wedgets' => [] ]; - $args = array_merge( $default, $args ); - - $listings_card_wedgets = $args[ 'listings_card_wedgets' ]; - - // $listings_card_list_view_thumbnail_top_right - $listings_card_list_view_thumbnail_top_right = []; - if ( get_directorist_option( 'display_feature_badge_cart', true ) ) { - $listings_card_list_view_thumbnail_top_right[] = $listings_card_wedgets['featured_badge']; - } - - if ( get_directorist_option( 'display_popular_badge_cart', true ) ) { - $listings_card_list_view_thumbnail_top_right[] = $listings_card_wedgets['popular_badge']; - } - - // $listings_card_list_view_body_top - $listings_card_list_view_body_top = []; - if ( get_directorist_option( 'display_title', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['listing_title']; - } - - if ( get_directorist_option( 'enable_review', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['rating']; - } - - if ( get_directorist_option( 'display_pricing_field', true ) && get_directorist_option( 'display_price', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['pricing']; - } - - if ( get_directorist_option( 'display_new_badge_cart', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['new_badge']; - } - - // listings_card_list_view_body_right - $listings_card_list_view_body_right = []; - if ( get_directorist_option( 'display_mark_as_fav', true ) ) { - $listings_card_list_view_body_right[] = $listings_card_wedgets['favorite_badge']; - } - - // $listings_card_list_view_body_bottom - $listings_card_list_view_body_bottom = []; - if ( get_directorist_option( 'display_contact_info', true ) ) { - $listings_card_list_view_body_bottom[] = $listings_card_wedgets['listings_location']; - } - - if ( get_directorist_option( 'display_publish_date', true ) ) { - $listings_card_list_view_body_bottom[] = $listings_card_wedgets['posted_date']; - } - - if ( get_directorist_option( 'display_contact_info', true ) ) { - $listings_card_list_view_body_bottom[] = $listings_card_wedgets['phone']; - } - - if ( get_directorist_option( 'display_web_link', true ) ) { - $listings_card_list_view_body_bottom[] = $listings_card_wedgets['website']; - } - - // listings_card_list_view_body_excerpt - $listings_card_list_view_body_excerpt = []; - if ( get_directorist_option( 'enable_excerpt', true ) ) { - $listings_card_list_view_body_excerpt[] = $listings_card_wedgets['excerpt']; - } - - // listings_card_list_view_footer_right - $listings_card_list_view_footer_right = []; - if ( get_directorist_option( 'display_view_count', true ) ) { - $listings_card_list_view_footer_right[] = $listings_card_wedgets['view_count']; - } - - if ( get_directorist_option( 'display_author_image', true ) ) { - $listings_card_list_view_footer_right[] = $listings_card_wedgets['user_avatar']; - } - - $listings_card_list_view_footer_left = []; - if ( get_directorist_option( 'display_category', true ) ) { - $listings_card_list_view_footer_left[] = $listings_card_wedgets['category']; - } - - $listings_card_list_view = apply_filters( 'listings_card_list_view_with_thumbnail', [ - "thumbnail"=> [ - "top_right" => $listings_card_list_view_thumbnail_top_right - ], - "body"=> [ - "top" => $listings_card_list_view_body_top, - "right" => $listings_card_list_view_body_right, - "bottom" => $listings_card_list_view_body_bottom, - "excerpt" => $listings_card_list_view_body_excerpt, - ], - "footer" => [ - "right" => $listings_card_list_view_footer_right, - "left" => $listings_card_list_view_footer_left - ] - ]); - - return $listings_card_list_view; - } - - // get_listings_card_list_view_without_thumbnail_data - public function get_listings_card_list_view_without_thumbnail_data( array $args = [] ) { - $default = [ 'listings_card_wedgets' => [] ]; - $args = array_merge( $default, $args ); - - $listings_card_wedgets = $args[ 'listings_card_wedgets' ]; - - // $listings_card_list_view_body_top - $listings_card_list_view_body_top = []; - if ( get_directorist_option( 'display_title', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['listing_title']; - } - - if ( get_directorist_option( 'enable_review', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['rating']; - } - - if ( get_directorist_option( 'display_pricing_field', true ) && get_directorist_option( 'display_price', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['pricing']; - } - - if ( get_directorist_option( 'display_feature_badge_cart', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['featured_badge']; - } - - if ( get_directorist_option( 'display_popular_badge_cart', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['popular_badge']; - } - - if ( get_directorist_option( 'display_new_badge_cart', true ) ) { - $listings_card_list_view_body_top[] = $listings_card_wedgets['new_badge']; - } - - $listings_card_list_view_body_excerpt = []; - if ( get_directorist_option( 'enable_excerpt', true ) ) { - $listings_card_list_view_body_excerpt[] = $listings_card_wedgets['excerpt']; - } - - $listings_card_list_view_body_right = []; - if ( get_directorist_option( 'display_mark_as_fav', true ) ) { - $listings_card_list_view_body_right[] = $listings_card_wedgets['favorite_badge']; - } - - // $listings_card_list_view_body_bottom - $listings_card_list_view_body_bottom = []; - if ( get_directorist_option( 'display_contact_info', true ) ) { - $listings_card_list_view_body_bottom[] = $listings_card_wedgets['listings_location']; - } - - if ( get_directorist_option( 'display_publish_date', true ) ) { - $listings_card_list_view_body_bottom[] = $listings_card_wedgets['posted_date']; - } - - if ( get_directorist_option( 'display_contact_info', true ) ) { - $listings_card_list_view_body_bottom[] = $listings_card_wedgets['phone']; - } - - if ( get_directorist_option( 'display_web_link', true ) ) { - $listings_card_list_view_body_bottom[] = $listings_card_wedgets['website']; - } - - // listings_card_list_view_footer_right - $listings_card_list_view_footer_right = []; - if ( get_directorist_option( 'display_view_count', true ) ) { - $listings_card_list_view_footer_right[] = $listings_card_wedgets['view_count']; - } - - if ( get_directorist_option( 'display_author_image', true ) ) { - $listings_card_list_view_footer_right[] = $listings_card_wedgets['user_avatar']; - } - - $listings_card_list_view_footer_left = []; - if ( get_directorist_option( 'display_category', true ) ) { - $listings_card_list_view_footer_left[] = $listings_card_wedgets['category']; - } - - $listings_card_list_view = apply_filters( 'listings_card_list_view_with_thumbnail', [ - "body" => [ - "top" => $listings_card_list_view_body_top, - "right" => $listings_card_list_view_body_right, - "bottom" => $listings_card_list_view_body_bottom, - "excerpt" => $listings_card_list_view_body_excerpt, - ], - "footer" => [ - "right" => $listings_card_list_view_footer_right, - "left" => $listings_card_list_view_footer_left - ] - ]); - - return $listings_card_list_view; - } - - // get_listings_card_wedgets_data - public function get_listings_card_wedgets_data() { - $listings_card_wedgets = [ - 'favorite_badge' => [ - "type" => "icon", - "label" => "Favorite", - "hook" => "atbdp_favorite_badge", - "widget_name" => "favorite_badge", - "widget_key" => "favorite_badge", - ], - 'featured_badge' => [ - "type" => "badge", - "label" => get_directorist_option( 'feature_badge_text', __('Fetured', 'directorist') ), - "hook" => "atbdp_featured_badge", - "widget_name" => "featured_badge", - "widget_key" => "featured_badge", - ], - 'new_badge' => [ - "type" => "badge", - "label" => get_directorist_option( 'new_badge_text', __('New', 'directorist') ), - "hook" => "atbdp_new_badge", - "widget_name" => "new_badge", - "widget_key" => "new_badge", - ], - 'popular_badge' => [ - "type" => "badge", - "label" => get_directorist_option( 'popular_badge_text', __('Popular', 'directorist') ), - "hook" => "atbdp_popular_badge", - "widget_name" => "popular_badge", - "widget_key" => "popular_badge", - ], - 'user_avatar' => [ - "type" => "avatar", - "label" => "User Avatar", - "hook" => "atbdp_user_avatar", - 'can_move' => false, - "widget_name" => "user_avatar", - "widget_key" => "user_avatar", - "align" => "right", - ], - 'listing_title' => [ - "type" => "title", - "label" => "Title", - "hook" => "atbdp_listing_title", - "widget_name" => "listing_title", - "widget_key" => "listing_title", - 'show_tagline' => false, - ], - 'rating' => [ - "type" => "rating", - "label" => "Rating", - "hook" => "atbdp_listings_rating", - "widget_name" => "rating", - "widget_key" => "rating", - ], - 'pricing' => [ - "type" => "price", - "label" => "Pricing", - "hook" => "pricing", - "widget_name" => "pricing", - "widget_key" => "pricing", - ], - 'excerpt' => [ - "type" => "excerpt", - "label" => "Excerpt", - "hook" => "atbdp_listing_excerpt", - "words_limit" => get_directorist_option( 'excerpt_limit', 30 ), - "show_readmore" => get_directorist_option( 'display_readmore', false ), - "show_readmore_text" => get_directorist_option( 'readmore_text', 'Read More' ), - "widget_key" => "excerpt", - "widget_name" => "excerpt", - ], - 'listings_location' => [ - "type" => "list-item", - "label" => "Location", - "hook" => "atbdp_listings_location", - "widget_name" => "listings_location", - "widget_key" => "listings_location", - "icon" => "las la-map-marker" - ], - 'phone' => [ - "type" => "list-item", - "hook" => "atbdp_listings_phone", - "label" => "Phone", - "widget_name" => "phone", - "widget_key" => "phone", - "icon" => "las la-phone" - - ], - 'website' => [ - "type" => "list-item", - "hook" => "atbdp_listings_website", - "label" => "Listings Website", - "widget_name" => "website", - "widget_key" => "website", - "icon" => "las la-globe" - - ], - 'posted_date' => [ - "type" => "list-item", - "label" => "Posted Date", - "hook" => "atbdp_listings_posted_date", - "widget_name" => "posted_date", - "widget_key" => "posted_date", - "icon" => "las la-clock", - "date_type" => "days_ago" - ], - 'view_count' => [ - "type" => "view-count", - "label" => "View Count", - "hook" => "atbdp_view_count", - "widget_name" => "view_count", - "widget_key" => "view_count", - "icon" => "las la-heart" - ], - 'category' => [ - "type" => "category", - "label" => "Category", - "hook" => "atbdp_category", - "widget_name" => "category", - "widget_key" => "category", - "icon" => "las la-folder" - ], - 'contact_button' => [ - "type" => "button", - "label" => "Contact Label", - "hook" => "atbdp_open_close_badge", - "widget_name" => "contact_button", - "widget_key" => "contact_button", - "icon" => "las la-phone" - ], - - ]; - - $current_theme = wp_get_theme(); - $current_theme = $current_theme->stylesheet; - - $theme_user_avatar = [ - 'direo' => [ 'align' => 'left' ], - 'dlist' => [ 'align' => 'left' ], - 'dservice' => [ 'align' => 'left' ], - ]; - - if ( in_array( $current_theme, array_keys( $theme_user_avatar ) ) ) { - $listings_card_wedgets['user_avatar'] = array_merge( $listings_card_wedgets['user_avatar'], $theme_user_avatar[ $current_theme ] ); - } - - return $listings_card_wedgets; - } - - // get_terms_label - public function get_terms_label() { - $terms_label_a = get_directorist_option( 'terms_label', true ); - $terms_label_b = get_directorist_option( 'terms_label_link', true ); - $terms_label = "{$terms_label_a} %{$terms_label_b}%"; - - return $terms_label; - } - - // get_privacy_label - public function get_privacy_label() { - $privacy_label_a = get_directorist_option( 'privacy_label', true ); - $privacy_label_b = get_directorist_option( 'privacy_label_link', true ); - $privacy_label = "{$privacy_label_a} %{$privacy_label_b}%"; - - return $privacy_label; - } - - // get_preview_image - public function get_preview_image() { - $preview_image_url = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); - $preview_image = [ 'id' => null, 'url' => $preview_image_url ]; - - return $preview_image; - } - - - - // get_old_custom_fields - public function get_old_custom_fields() - { - $fields = []; - $old_fields = atbdp_get_custom_field_ids( '', true ); - - foreach ($old_fields as $old_field_id) { - $field_type = get_post_meta($old_field_id, 'type', true); - $accepted_types = [ 'text', 'number', 'date', 'color', 'time', 'radio', 'checkbox', 'select', 'textarea', 'url', 'file' ]; - - if ( ! in_array( $field_type, $accepted_types ) ) { continue; } - // $get_post_meta = get_post_meta($old_field_id); - - $required = get_post_meta($old_field_id, 'required', true); - $admin_use = get_post_meta($old_field_id, 'admin_use', true); - $category_pass = get_post_meta($old_field_id, 'category_pass', true); - $searchable = get_post_meta($old_field_id, 'searchable', true); - $field_data = []; - - $field_type = ( 'color' === $field_type ) ? 'color_picker' : $field_type; - - // Common Data - $field_data['type'] = $field_type; - $field_data['label'] = get_the_title($old_field_id); - $field_data['field_key'] = $old_field_id; - $field_data['placeholder'] = ''; - $field_data['description'] = get_post_meta($old_field_id, 'instructions', true); - $field_data['required'] = ( $required == 1 ) ? true : false; - - $field_data['only_for_admin'] = ( $admin_use == 1 ) ? true : false; - - $assign_to = get_post_meta($old_field_id, 'associate', true); - $assign_to = ( 'categories' === $assign_to ) ? 'category' : $assign_to; - $field_data['assign_to'] = $assign_to; - $field_data['category'] = ( is_numeric( $category_pass ) ) ? ( int ) $category_pass : ''; - $field_data['searchable'] = ( $searchable == 1 ) ? true : false; - - $field_data['widget_group'] = 'custom'; - $field_data['widget_name'] = $field_type; - $field_data['widget_key'] = $field_type . '_' . $old_field_id; - - // field group - $field_group = [ 'radio', 'checkbox', 'select' ]; - if ( in_array( $field_type, $field_group ) ) { - $choices = get_post_meta($old_field_id, 'choices', true); - $field_data['options'] = $this->decode_custom_field_option_string( $choices ); - } - - if ( ('textarea' === $field_type) ) { - $field_data['rows'] = get_post_meta($old_field_id, 'rows', true); - } - - if ( ('url' === $field_type) ) { - $field_data['target'] = get_post_meta($old_field_id, 'target', true); - } - - if ( ('file' === $field_type) ) { - $file_type = get_post_meta($old_field_id, 'file_type', true); - $file_type = ( 'all_types' === $file_type ) ? 'all' : $file_type; - $field_data['file_type'] = $file_type; - $field_data['file_size'] = get_post_meta($old_field_id, 'file_size', true); - } - - $fields[ $field_type . '_' . $old_field_id ] = $field_data; - } - - return $fields; - } - - // decode_custom_field_option_string - public function decode_custom_field_option_string( string $string = '' ) { - $choices = ( ! empty( $string ) ) ? explode( "\n", $string ) : []; - $options = []; - - if ( count( $choices ) ) { - foreach ( $choices as $option) { - $value_match = []; - $label_match = []; - - preg_match( '/(.+):/', $option, $value_match ); - preg_match( '/:(.+)/', $option, $label_match ); - - if ( empty( $value_match[1] ) && empty( $label_match[1] ) ) { - $options[] = [ - 'option_value' => $option, - 'option_label' => $option, - ]; - - continue; - } - - $options[] = [ - 'option_value' => trim( $value_match[1] ), - 'option_label' => trim( $label_match[1] ), - ]; - } - } - - return $options; - } -} \ No newline at end of file + public $multi_directory_manager = null; + + public function __construct( array $args = array() ) { + if ( isset( $args['multi_directory_manager'] ) ) { + $this->multi_directory_manager = $args['multi_directory_manager']; + } + } + + public function migrate( array $args = array() ) { + $default = array(); + $args = array_merge( $default, $args ); + + $fields = $this->get_fields_data(); + $add_directory_args = array( + 'directory_name' => 'General', + 'fields_value' => $fields, + ); + + $add_directory_args = array_merge( $add_directory_args, $args ); + $add_directory = $this->multi_directory_manager->add_directory( $add_directory_args ); + + if ( $add_directory['status']['success'] ) { + $directory_types = directorist_get_directories(); + + if ( ! empty( $directory_types ) ) { + foreach ( $directory_types as $directory_type ) { + update_term_meta( $directory_type->term_id, '_default', false ); + } + } + + update_term_meta( $add_directory['term_id'], '_default', true ); + update_option( 'atbdp_migrated', true ); + + // Add directory type to all locations and categories + $terms = array( ATBDP_CATEGORY, ATBDP_LOCATION ); + foreach ( $terms as $term ) { + $term_data = get_terms( + array( + 'taxonomy' => $term, + 'hide_empty' => false, + 'orderby' => 'date', + 'order' => 'DSCE', + ) + ); + if ( ! empty( $term_data ) ) { + foreach ( $term_data as $data ) { + update_term_meta( $data->term_id, '_directory_type', array( $add_directory['term_id'] ) ); + } + } + } + + // Add directory type to all listings + $listings = new \WP_Query( + array( + 'post_type' => ATBDP_POST_TYPE, + 'status' => 'publish', + 'posts_per_page' => -1, + 'fields' => 'ids', + ) + ); + + $listings_ids = ( ! is_wp_error( $listings ) ) ? wp_parse_id_list( $listings->posts ) : array(); + + if ( ! empty( $listings_ids ) ) { + foreach ( $listings_ids as $listings_id ) { + // Set Directory Type + wp_set_object_terms( $listings_id, $add_directory['term_id'], 'atbdp_listing_types' ); + update_post_meta( $listings_id, '_directory_type', $add_directory['term_id'] ); + } + } + + return array( 'success' => true ); + } + + return array( 'success' => false ); + } + + // get_fields_data + public function get_fields_data() { + $old_custom_fields = $this->get_old_custom_fields(); + $form_fields_common_data = array( 'old_custom_fields' => $old_custom_fields ); + + $submission_form_fields_data = $this->get_submission_form_fields_data( $form_fields_common_data ); + $form_fields_common_data['submission_form_fields_data'] = $submission_form_fields_data; + + $listings_card_wedgets = $this->get_listings_card_wedgets_data(); + $listings_card_common_data = array( 'listings_card_wedgets' => $listings_card_wedgets ); + + $fields = apply_filters( + 'atbdp_multidirectory_migration_fields', + array( + 'icon' => 'las la-home', + 'singular_name' => 'listing', + 'plural_name' => 'listings', + 'permalink' => 'listing', + 'preview_mode' => get_directorist_option( 'preview_enable', true ), + 'preview_image' => get_directorist_option( 'default_preview_image', true ), + + 'default_expiration' => get_directorist_option( 'listing_expire_in_days', 365 ), + 'new_listing_status' => get_directorist_option( 'new_listing_status', 'pending' ), + 'edit_listing_status' => get_directorist_option( 'edit_listing_status', 'pending' ), + 'submit_button_label' => get_directorist_option( 'submit_label', 'Save & Preview' ), + 'listing_terms_condition' => get_directorist_option( 'listing_terms_condition', true ), + 'require_terms_conditions' => get_directorist_option( 'require_terms_conditions', true ), + 'terms_label' => $this->get_terms_label(), + 'listing_privacy' => get_directorist_option( 'listing_privacy', true ), + 'require_privacy' => get_directorist_option( 'require_privacy', true ), + 'privacy_label' => $this->get_privacy_label(), + 'submission_form_fields' => $submission_form_fields_data, + 'single_listings_contents' => $this->get_single_listings_contents_data( $form_fields_common_data ), + 'similar_listings_title' => get_directorist_option( 'rel_listing_title', true ), + 'enable_similar_listings' => get_directorist_option( 'enable_rel_listing', true ), + 'similar_listings_logics' => get_directorist_option( 'rel_listings_logic', 'OR' ), + 'search_form_fields' => $this->get_search_form_fields( $form_fields_common_data ), + 'single_listing_header' => $this->get_single_listing_header_data(), + 'listings_card_grid_view' => $this->get_listings_card_grid_view_data( $listings_card_common_data ), + 'listings_card_list_view' => $this->get_listings_card_list_view_data( $listings_card_common_data ), + + 'similar_listings_number_of_listings_to_show' => get_directorist_option( 'rel_listing_num', 10 ), + 'similar_listings_number_of_columns' => get_directorist_option( 'rel_listing_column', 3 ), + ) + ); + + return $fields; + } + + // get_submission_form_fields_data + public function get_submission_form_fields_data( array $args = array() ) { + $default = array( 'old_custom_fields' => array() ); + $args = array_merge( $default, $args ); + + // Submission Form Fields + $preset_fields = array(); + + // Group Keys + $general_group_field_keys = array(); + $contact_group_info_field_keys = array(); + $map_group_field_keys = array(); + $gallery_group_field_keys = array(); + + // General Group + // ------------------------------ + // Title + $general_group_field_keys[] = 'title'; + $preset_fields['title'] = array( + 'field_key' => 'listing_title', + 'type' => 'text', + 'required' => get_directorist_option( 'require_title', true ), + 'label' => get_directorist_option( 'title_label', 'Title' ), + 'placeholder' => get_directorist_option( 'title_placeholder', 'Enter a title' ), + 'widget_group' => 'preset', + 'widget_name' => 'title', + 'widget_key' => 'title', + ); + + // Description + $general_group_field_keys[] = 'description'; + $preset_fields['description'] = array( + 'field_key' => 'listing_content', + 'type' => 'wp_editor', + 'label' => get_directorist_option( 'long_details_label', 'Long Details' ), + 'placeholder' => '', + 'required' => get_directorist_option( 'require_long_details', false ), + 'only_for_admin' => get_directorist_option( 'display_desc_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'description', + 'widget_key' => 'description', + ); + + // Excerpt + if ( ! empty( get_directorist_option( 'display_excerpt_field', true ) ) ) { + $general_group_field_keys[] = 'excerpt'; + $preset_fields['excerpt'] = array( + 'field_key' => 'excerpt', + 'label' => get_directorist_option( 'excerpt_label', 'Short Description/Excerpt' ), + 'words_limit' => '', + 'placeholder' => get_directorist_option( 'excerpt_placeholder', false ), + 'required' => get_directorist_option( 'require_excerpt', false ), + 'only_for_admin' => get_directorist_option( 'display_short_desc_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'excerpt', + 'widget_key' => 'excerpt', + ); + } + + if ( ! empty( get_directorist_option( 'display_views_count', true ) ) ) { + $general_group_field_keys[] = 'view_count'; + $preset_fields['view_count'] = array( + 'type' => 'number', + 'field_key' => 'atbdp_post_views_count', + 'label' => get_directorist_option( 'views_count_label', 'Views Count' ), + 'placeholder' => '', + 'required' => false, + 'only_for_admin' => true, + 'widget_group' => 'preset', + 'widget_name' => 'view_count', + 'widget_key' => 'view_count', + ); + } + + if ( ! empty( get_directorist_option( 'display_tagline_field', true ) ) ) { + $general_group_field_keys[] = 'tagline'; + $preset_fields['tagline'] = array( + 'field_key' => 'tagline', + 'type' => 'text', + 'label' => get_directorist_option( 'tagline_label', 'Tagline' ), + 'placeholder' => get_directorist_option( 'tagline_placeholder', "Your Listing's motto or tag-line" ), + 'widget_group' => 'preset', + 'widget_name' => 'tagline', + 'widget_key' => 'tagline', + ); + } + + if ( ! empty( get_directorist_option( 'display_pricing_field', true ) ) ) { + $general_group_field_keys[] = 'pricing'; + $preset_fields['pricing'] = array( + 'field_key' => 'pricing', + 'pricing_type' => 'both', + 'label' => get_directorist_option( 'pricing_label', 'Pricing' ), + 'price_range_label' => get_directorist_option( 'price_range_label', 'Select Price Range' ), + 'price_range_options' => 'cheap', + 'price_unit_field_type' => 'number', + 'price_unit_field_label' => get_directorist_option( 'price_label', 'Price' ), + 'widget_group' => 'preset', + 'widget_name' => 'pricing', + 'widget_key' => 'pricing', + ); + } + + if ( ! empty( $this->get_old_custom_fields() ) ) { + foreach ( $this->get_old_custom_fields() as $key => $value ) { + $general_group_field_keys[] = $key; + $preset_fields[ $key ] = $value; + } + } + + $general_group_field_keys[] = 'location'; + $preset_fields['location'] = array( + 'type' => 'multiple', + 'field_key' => 'tax_input[at_biz_dir-location][]', + 'label' => get_directorist_option( 'location_label', 'Location' ), + 'required' => get_directorist_option( 'require_location', false ), + 'only_for_admin' => get_directorist_option( 'display_loc_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'location', + 'widget_key' => 'location', + ); + + $general_group_field_keys[] = 'tag'; + $preset_fields['tag'] = array( + 'type' => 'multiple', + 'field_key' => 'tax_input[at_biz_dir-tags][]', + 'label' => get_directorist_option( 'tag_label', 'Tag' ), + 'required' => get_directorist_option( 'require_tags', false ), + 'allow_new' => get_directorist_option( 'create_new_tag', true ), + 'only_for_admin' => get_directorist_option( 'display_tag_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'tag', + 'widget_key' => 'tag', + ); + + $general_group_field_keys[] = 'category'; + $preset_fields['category'] = array( + 'type' => 'multiple', + 'field_key' => 'admin_category_select[]', + 'label' => get_directorist_option( 'category_label', 'Select Category' ), + 'required' => get_directorist_option( 'require_category', false ), + 'only_for_admin' => false, + 'widget_group' => 'preset', + 'widget_name' => 'category', + 'widget_key' => 'category', + ); + + // Contact Group + // ------------------------------ + $contact_group_info_field_keys[] = 'hide_contact_owner'; + $preset_fields['hide_contact_owner'] = array( + 'type' => 'checkbox', + 'field_key' => 'hide_contact_owner', + 'label' => 'Hide contact owner form for single listing page', + 'placeholder' => get_directorist_option( 'zip_placeholder', 'Enter Zip/Post Code' ), + 'required' => get_directorist_option( 'require_zip', false ), + 'widget_group' => 'preset', + 'widget_name' => 'hide_contact_owner', + 'widget_key' => 'hide_contact_owner', + ); + + if ( ! empty( get_directorist_option( 'display_zip_field', true ) ) ) { + $contact_group_info_field_keys[] = 'zip'; + $preset_fields['zip'] = array( + 'type' => 'text', + 'field_key' => 'zip', + 'label' => get_directorist_option( 'zip_label', 'Zip/Post Code' ), + 'placeholder' => get_directorist_option( 'zip_placeholder', 'Enter Zip/Post Code' ), + 'required' => get_directorist_option( 'require_zip', false ), + 'only_for_admin' => get_directorist_option( 'display_zip_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'zip', + 'widget_key' => 'zip', + ); + } + + if ( ! empty( get_directorist_option( 'display_phone_field', true ) ) ) { + $contact_group_info_field_keys[] = 'phone'; + $preset_fields['phone'] = array( + 'type' => 'tel', + 'field_key' => 'phone', + 'label' => get_directorist_option( 'phone_label', 'Phone' ), + 'placeholder' => get_directorist_option( 'phone_placeholder', 'Phone Number' ), + 'required' => get_directorist_option( 'require_phone_number', false ), + 'only_for_admin' => get_directorist_option( 'display_phone_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'phone', + 'widget_key' => 'phone', + ); + } + + if ( ! empty( get_directorist_option( 'display_phone_field2', true ) ) ) { + $contact_group_info_field_keys[] = 'phone2'; + $preset_fields['phone2'] = array( + 'type' => 'tel', + 'field_key' => 'phone2', + 'label' => get_directorist_option( 'phone_label2', 'Phone 2' ), + 'placeholder' => get_directorist_option( 'phone2_placeholder', 'Phone Number' ), + 'required' => get_directorist_option( 'require_phone2_number', false ), + 'only_for_admin' => get_directorist_option( 'display_phone2_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'phone2', + 'widget_key' => 'phone2', + ); + } + + if ( ! empty( get_directorist_option( 'display_fax', true ) ) ) { + $contact_group_info_field_keys[] = 'fax'; + $preset_fields['fax'] = array( + 'type' => 'number', + 'field_key' => 'fax', + 'label' => get_directorist_option( 'fax_label', 'Fax' ), + 'placeholder' => get_directorist_option( 'fax_placeholder', 'Enter Fax' ), + 'required' => get_directorist_option( 'require_fax', false ), + 'only_for_admin' => get_directorist_option( 'display_fax_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'fax', + 'widget_key' => 'fax', + ); + } + + if ( ! empty( get_directorist_option( 'display_email_field', true ) ) ) { + $contact_group_info_field_keys[] = 'email'; + $preset_fields['email'] = array( + 'type' => 'email', + 'field_key' => 'email', + 'label' => get_directorist_option( 'email_label', 'Email' ), + 'placeholder' => get_directorist_option( 'email_placeholder', 'Enter Email' ), + 'required' => get_directorist_option( 'require_email', false ), + 'only_for_admin' => get_directorist_option( 'display_email_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'email', + 'widget_key' => 'email', + ); + } + + if ( ! empty( get_directorist_option( 'display_website_field', true ) ) ) { + $contact_group_info_field_keys[] = 'website'; + $preset_fields['website'] = array( + 'type' => 'text', + 'field_key' => 'website', + 'label' => get_directorist_option( 'website_label', 'Website' ), + 'placeholder' => get_directorist_option( 'website_placeholder', 'Listing Website eg. http://example.com' ), + 'required' => get_directorist_option( 'require_website', false ), + 'only_for_admin' => get_directorist_option( 'display_website_for', false ), + 'plans' => array(), + 'widget_group' => 'preset', + 'widget_name' => 'website', + 'widget_key' => 'website', + ); + } + + if ( ! empty( get_directorist_option( 'display_social_info_field', true ) ) ) { + $contact_group_info_field_keys[] = 'social_info'; + $preset_fields['social_info'] = array( + 'type' => 'add_new', + 'field_key' => 'social', + 'label' => get_directorist_option( 'social_label', 'Social Information' ), + 'required' => get_directorist_option( 'require_social_info', false ), + 'only_for_admin' => get_directorist_option( 'display_social_info_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'social_info', + 'widget_key' => 'social_info', + ); + } + + if ( ! empty( get_directorist_option( 'display_address_field', true ) ) ) { + $map_group_field_keys[] = 'address'; + $preset_fields['address'] = array( + 'type' => 'text', + 'field_key' => 'address', + 'label' => get_directorist_option( 'address_label', 'Address' ), + 'placeholder' => get_directorist_option( 'address_placeholder', 'Listing address eg. New York, USA' ), + 'required' => get_directorist_option( 'require_address', false ), + 'only_for_admin' => get_directorist_option( 'display_address_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'address', + 'widget_key' => 'address', + ); + } + + if ( ! empty( get_directorist_option( 'display_map_field', true ) ) ) { + $map_group_field_keys[] = 'map'; + $preset_fields['map'] = array( + 'type' => 'map', + 'field_key' => 'map', + 'label' => 'Map', + 'only_for_admin' => get_directorist_option( 'display_map_for', false ), + 'lat_long' => 'Or Enter Coordinates (latitude and longitude) Manually', + 'required' => false, + 'widget_group' => 'preset', + 'widget_name' => 'map', + 'widget_key' => 'map', + ); + } + + if ( ! empty( get_directorist_option( 'display_gallery_field', true ) ) ) { + $gallery_group_field_keys[] = 'image_upload'; + $preset_fields['image_upload'] = array( + 'type' => 'media', + 'field_key' => 'listing_img', + 'label' => 'Images', + 'select_files_label' => get_directorist_option( 'gallery_label', 'Select Files' ), + 'required' => get_directorist_option( 'require_gallery_img', false ), + 'max_image_limit' => get_directorist_option( 'require_gallery_img', 5 ), + 'max_per_image_limit' => get_directorist_option( 'max_gallery_upload_size_per_file', 0 ), + 'max_total_image_limit' => get_directorist_option( 'max_gallery_upload_size', 2 ), + 'only_for_admin' => get_directorist_option( 'display_glr_img_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'image_upload', + 'widget_key' => 'image_upload', + ); + } + + if ( ! empty( get_directorist_option( 'display_gallery_field', true ) ) ) { + $gallery_group_field_keys[] = 'video'; + $preset_fields['video'] = array( + 'type' => 'text', + 'field_key' => 'videourl', + 'label' => get_directorist_option( 'video_label', 'Video Url' ), + 'placeholder' => get_directorist_option( 'video_placeholder', 'Only YouTube & Vimeo URLs.' ), + 'required' => get_directorist_option( 'require_video', false ), + 'only_for_admin' => get_directorist_option( 'display_video_for', false ), + 'widget_group' => 'preset', + 'widget_name' => 'video', + 'widget_key' => 'video', + ); + } + + $custom_fields = $args['old_custom_fields']; + $all_form_fields = array_merge( $preset_fields, $custom_fields ); + + $form_groups = array(); + + // General Group + $form_groups[] = array( + 'label' => 'General Information', + 'lock' => true, + 'fields' => $general_group_field_keys, + ); + + // Contact Info + $form_groups[] = array( + 'label' => 'Contact Information', + 'fields' => $contact_group_info_field_keys, + ); + + // Map + $form_groups[] = array( + 'label' => 'Map', + 'fields' => $map_group_field_keys, + ); + + // Gallery + $form_groups[] = array( + 'label' => 'Images & Video', + 'fields' => $gallery_group_field_keys, + ); + + $submission_form_fields = array( + 'fields' => $all_form_fields, + 'groups' => $form_groups, + ); + + return $submission_form_fields; + } + + // get_single_listings_contents_data + public function get_single_listings_contents_data( array $args = array() ) { + + $default = array( 'old_custom_fields' => array() ); + $args = array_merge( $default, $args ); + + // Single Listing Contents + $single_listings_preset_fields = array(); + $map_group_field_keys = array(); + $contact_info_group_field_keys = array(); + $video_group_field_keys = array(); + + $single_listings_preset_fields['tag'] = array( + 'icon' => 'las la-tag', + 'widget_name' => 'tag', + 'widget_group' => 'preset_widgets', + ); + + if ( ! empty( get_directorist_option( 'display_map_field', true ) ) ) { + $map_group_field_keys[] = 'map'; + $single_listings_preset_fields['map'] = array( + 'icon' => 'las la-map', + 'widget_name' => 'map', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_map_field', true ) ) ) { + $contact_info_group_field_keys[] = 'address'; + $single_listings_preset_fields['address'] = array( + 'icon' => 'las la-map', + 'address_link_with_map' => false, + 'widget_name' => 'address', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_phone_field', true ) ) ) { + $contact_info_group_field_keys[] = 'phone'; + $single_listings_preset_fields['phone'] = array( + 'icon' => 'las la-phone', + 'widget_name' => 'phone', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_phone_field2', true ) ) ) { + $contact_info_group_field_keys[] = 'phone2'; + $single_listings_preset_fields['phone2'] = array( + 'icon' => 'las la-phone', + 'widget_name' => 'phone2', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_zip_field', true ) ) ) { + $contact_info_group_field_keys[] = 'zip'; + $single_listings_preset_fields['zip'] = array( + 'icon' => 'las la-street-view', + 'widget_name' => 'zip', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_email_field', true ) ) ) { + $contact_info_group_field_keys[] = 'email'; + $single_listings_preset_fields['email'] = array( + 'icon' => 'las la-envelope', + 'widget_name' => 'email', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_website_field', true ) ) ) { + $contact_info_group_field_keys[] = 'website'; + $single_listings_preset_fields['website'] = array( + 'icon' => 'las la-globe', + 'widget_name' => 'website', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_fax', true ) ) ) { + $contact_info_group_field_keys[] = 'fax'; + $single_listings_preset_fields['fax'] = array( + 'icon' => 'las la-fax', + 'widget_name' => 'fax', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_social_info_field', true ) ) ) { + $contact_info_group_field_keys[] = 'social_info'; + $single_listings_preset_fields['social_info'] = array( + 'icon' => 'las la-share-alt', + 'widget_name' => 'social_info', + 'widget_group' => 'preset_widgets', + ); + } + + if ( ! empty( get_directorist_option( 'display_video_field', true ) ) ) { + $video_group_field_keys[] = 'video'; + $single_listings_preset_fields['video'] = array( + 'icon' => 'las la-video', + 'widget_name' => 'video', + 'widget_group' => 'preset_widgets', + ); + } + + $this->multi_directory_manager->prepare_settings(); + $single_listings_widgets = array(); + if ( + isset( $this->multi_directory_manager::$fields ) && + isset( $this->multi_directory_manager::$fields['single_listings_contents'] ) && + isset( $this->multi_directory_manager::$fields['single_listings_contents']['widgets'] ) && + isset( $this->multi_directory_manager::$fields['single_listings_contents']['widgets']['preset_widgets'] ) && + isset( $this->multi_directory_manager::$fields['single_listings_contents']['widgets']['preset_widgets']['widgets'] ) && + is_array( $this->multi_directory_manager::$fields['single_listings_contents']['widgets']['preset_widgets']['widgets'] ) + ) { + $single_listings_widgets = $this->multi_directory_manager::$fields['single_listings_contents']['widgets']['preset_widgets']['widgets']; + } + + $single_listings_widgets_keys = is_array( $single_listings_widgets ) ? array_keys( $single_listings_widgets ) : array(); + $single_listings_custom_fields = array(); + $custom_fields = $args['old_custom_fields']; + foreach ( $custom_fields as $field_key => $args ) { + $widget_args = array( + 'label' => $args['label'], + 'widget_group' => 'preset_widgets', + 'widget_name' => $field_key, + ); + + if ( ! in_array( $args['widget_name'], $single_listings_widgets_keys ) ) { + continue; + } + + if ( ! isset( $single_listings_widgets[ $args['widget_name'] ]['options'] ) ) { + continue; + } + + foreach ( $single_listings_widgets[ $args['widget_name'] ]['options'] as $option_key => $option_args ) { + $widget_args[ $option_key ] = $option_args['value']; + } + + $single_listings_custom_fields[ $field_key ] = $widget_args; + } + + $single_listings_fields = array_merge( $single_listings_preset_fields, $single_listings_custom_fields ); + $single_listings_groups = array(); + + if ( ! empty( get_directorist_option( 'enable_single_tag', true ) ) ) { + $single_listings_groups[] = array( + 'label' => get_directorist_option( 'tags_section_lable', __( 'Tags', 'directorist' ) ), + 'fields' => array( 'tag' ), + 'type' => 'general_group', + 'icon' => 'las la-tags', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + } + + if ( ! empty( $single_listings_custom_fields ) && is_array( $single_listings_custom_fields ) ) { + $single_listings_groups[] = array( + 'label' => get_directorist_option( 'custom_section_lable', __( 'Features', 'directorist' ) ), + 'fields' => array_keys( $single_listings_custom_fields ), + 'type' => 'general_group', + 'icon' => 'las la-bars', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + } + + if ( empty( get_directorist_option( 'disable_map', false ) ) && ! empty( $map_group_field_keys ) ) { + $single_listings_groups[] = array( + 'label' => get_directorist_option( 'listing_location_text', __( 'Location', 'directorist' ) ), + 'fields' => $map_group_field_keys, + 'type' => 'general_group', + 'icon' => 'las la-map', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + } + + if ( empty( get_directorist_option( 'disable_contact_info', false ) ) && ! empty( $contact_info_group_field_keys ) ) { + $single_listings_groups[] = array( + 'label' => get_directorist_option( 'contact_info_text', __( 'Contact Information', 'directorist' ) ), + 'fields' => $contact_info_group_field_keys, + 'type' => 'general_group', + 'icon' => 'las la-envelope-open', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + } + + if ( ! empty( get_directorist_option( 'atbd_video_url', true ) ) && ! empty( $video_group_field_keys ) ) { + $single_listings_groups[] = array( + 'label' => get_directorist_option( 'atbd_video_title', __( 'Video', 'directorist' ) ), + 'fields' => $video_group_field_keys, + 'type' => 'general_group', + 'icon' => 'las la-video', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + } + + $single_listings_groups[] = array( + 'label' => get_directorist_option( 'atbd_author_info_title', __( 'Author Info', 'directorist' ) ), + 'fields' => array(), + 'type' => 'widget_group', + 'widget_group' => 'other_widgets', + 'widget_name' => 'author_info', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + + if ( empty( get_directorist_option( 'disable_contact_owner', false ) ) ) { + $single_listings_groups[] = array( + 'label' => get_directorist_option( 'contact_listing_owner', __( 'Contact Listings Owner', 'directorist' ) ), + 'fields' => array(), + 'type' => 'widget_group', + 'widget_group' => 'other_widgets', + 'widget_name' => 'contact_listings_owner', + 'icon' => 'las la-phone', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + } + + if ( ! empty( get_directorist_option( 'enable_review', true ) ) ) { + $single_listings_groups[] = array( + 'label' => 'Review', + 'fields' => array(), + 'type' => 'widget_group', + 'widget_group' => 'other_widgets', + 'widget_name' => 'review', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + } + + if ( ! empty( get_directorist_option( 'enable_rel_listing', true ) ) ) { + $single_listings_groups[] = array( + 'label' => get_directorist_option( 'rel_listing_title', __( 'Related Listings', 'directorist' ) ), + 'fields' => array(), + 'type' => 'widget_group', + 'widget_group' => 'other_widgets', + 'widget_name' => 'related_listings', + 'custom_block_id' => '', + 'custom_block_classes' => '', + ); + } + + $single_listings_contents = array( + 'fields' => $single_listings_fields, + 'groups' => $single_listings_groups, + ); + + // directorist_console_log( $single_listings_contents ); + + return $single_listings_contents; + } + + // get_search_form_fields + public function get_search_form_fields( array $args = array() ) { + $default = array( 'old_custom_fields' => array() ); + $args = array_merge( $default, $args ); + + // Search Form + $search_fields_map = array( + // Basic + 'search_text' => array( + 'field_key' => 'title', + 'options' => array( + 'required' => get_directorist_option( 'require_search_text', false ), + 'label' => '', + 'placeholder' => get_directorist_option( 'listings_search_text_placeholder', 'What are you looking for?' ), + 'widget_name' => 'title', + 'widget_group' => 'available_widgets', + ), + ), + 'search_category' => array( + 'field_key' => 'category', + 'options' => array( + 'required' => get_directorist_option( 'require_search_category', false ), + 'label' => '', + 'placeholder' => get_directorist_option( 'search_category_placeholder', 'Select a category' ), + 'widget_name' => 'category', + 'widget_group' => 'available_widgets', + ), + ), + 'search_location' => array( + 'field_key' => 'location', + 'options' => array( + 'required' => get_directorist_option( 'require_search_location', false ), + 'placeholder' => get_directorist_option( 'search_location_placeholder', 'Select a category' ), + 'widget_group' => 'available_widgets', + 'label' => '', + 'widget_name' => 'location', + ), + ), + + // Advanced + 'search_rating' => array( + 'field_key' => 'review', + 'options' => array( + 'required' => false, + 'widget_group' => 'available_widgets', + 'widget_name' => '', + 'placeholder' => '', + ), + ), + 'search_tag' => array( + 'field_key' => 'tag', + 'options' => array( + 'label' => 'Tag', + 'widget_name' => 'tag', + 'widget_group' => 'available_widgets', + ), + ), + // 'search_open_now' => [ + // 'field_key' => 'open_now', + // "options" => [ + // 'label' => 'Open Now', + // 'widget_name' => 'open_now', + // 'widget_group' => 'available_widgets', + // ], + // ], + 'search_website' => array( + 'field_key' => 'website', + 'options' => array( + 'label' => 'Website', + 'widget_group' => 'available_widgets', + 'widget_name' => '', + 'placeholder' => '', + ), + ), + 'search_email' => array( + 'field_key' => 'email', + 'options' => array( + 'label' => 'Email', + 'widget_group' => 'available_widgets', + 'widget_name' => '', + 'placeholder' => '', + ), + ), + 'search_phone' => array( + 'field_key' => 'phone', + 'options' => array( + 'label' => 'Phone', + 'widget_group' => 'available_widgets', + 'widget_name' => '', + 'placeholder' => '', + ), + ), + 'search_fax' => array( + 'field_key' => 'fax', + 'options' => array( + 'label' => 'Fax', + 'widget_group' => 'available_widgets', + 'widget_name' => 'fax', + 'placeholder' => '', + ), + ), + 'search_zip_code' => array( + 'field_key' => 'zip', + 'options' => array( + 'label' => 'Zip/Post Code', + 'placeholder' => 'Zip', + 'required' => false, + 'widget_name' => 'zip', + 'widget_group' => 'available_widgets', + ), + ), + 'phone' => array( + 'field_key' => 'phone', + 'options' => array( + 'label' => 'Phone', + 'placeholder' => 'Phone', + 'required' => false, + 'widget_name' => 'phone', + 'widget_group' => 'available_widgets', + ), + ), + 'phone2' => array( + 'field_key' => 'phone', + 'options' => array( + 'label' => 'Phone 2', + 'placeholder' => 'Phone 2', + 'required' => false, + 'widget_name' => 'phone2', + 'widget_group' => 'available_widgets', + ), + ), + 'radius_search' => array( + 'field_key' => 'radius_search', + 'options' => array( + 'label' => 'Radius Search', + 'default_radius_distance' => 0, + 'radius_search_unit' => 'miles', + 'widget_name' => 'radius_search', + 'widget_group' => 'other_widgets', + ), + ), + 'search_rating' => array( + 'field_key' => 'review', + 'options' => array( + 'label' => 'Review', + 'widget_name' => 'review', + 'widget_group' => 'other_widgets', + ), + ), + ); + + // Get Basic Search Fields + $old_basic_search_fields = get_directorist_option( 'search_tsc_fields', array() ); + + $search_form_fields_basic_items = array(); + + foreach ( $old_basic_search_fields as $field_key ) { + if ( empty( $search_fields_map[ $field_key ] ) ) { + continue; } + + $new_field_key = $search_fields_map[ $field_key ]['field_key']; + $search_form_fields_basic_items[ $new_field_key ] = $search_fields_map[ $field_key ]['options']; + } + + // Get Advanced Fields + $old_advanced_search_fields = get_directorist_option( 'search_more_filters_fields', array() ); + $search_form_fields_advanced_items = array(); + + // var_dump( $old_advanced_search_fields ); + + foreach ( $old_advanced_search_fields as $field_key ) { + if ( empty( $search_fields_map[ $field_key ] ) ) { + continue; } + + $new_field_key = $search_fields_map[ $field_key ]['field_key']; + $search_form_fields_advanced_items[ $new_field_key ] = $search_fields_map[ $field_key ]['options']; + } + + // Get Other Fields + // Price Field + if ( in_array( 'search_price', $old_advanced_search_fields ) || in_array( 'search_price_range', $old_advanced_search_fields ) ) { + $search_form_fields_advanced_items['pricing'] = array( + 'label' => 'Pricing', + 'price_range_min_placeholder' => 'Min', + 'price_range_max_placeholder' => 'Max', + 'widget_name' => 'pricing', + 'widget_group' => 'available_widgets', + ); + } + + // Custom Fields + if ( in_array( 'search_custom_fields', $old_advanced_search_fields ) && ! empty( $args['old_custom_fields'] ) ) { + // submission_form_fields_data + $custom_fields = $args['old_custom_fields']; + $submission_form_field_keys = array(); + + if ( ! empty( $args['submission_form_fields_data'] ) && ! empty( $args['submission_form_fields_data']['fields'] ) && is_array( $args['submission_form_fields_data']['fields'] ) ) { + $submission_form_field_keys = array_keys( $args['submission_form_fields_data']['fields'] ); + } + + foreach ( $custom_fields as $field_key => $field_args ) { + if ( empty( $field_args['searchable'] ) || ! in_array( $field_key, $submission_form_field_keys ) ) { + continue; } + + $search_form_fields_advanced_items[ $field_key ] = array( + 'label' => $field_args['label'], + 'widget_group' => 'available_widgets', + 'widget_name' => $field_args['type'], + ); + } + } + + $search_form_all_fields = array_merge( $search_form_fields_basic_items, $search_form_fields_advanced_items ); + $search_form_fields = array( + 'fields' => $search_form_all_fields, + 'groups' => array( + array( + 'label' => 'Basic', + 'lock' => true, + 'draggable' => false, + 'fields' => array_keys( $search_form_fields_basic_items ), + ), + array( + 'label' => 'Advanced', + 'lock' => true, + 'draggable' => false, + 'fields' => array_keys( $search_form_fields_advanced_items ), + ), + ), + ); + + return $search_form_fields; + } + + // get_single_listing_header_data + public function get_single_listing_header_data() { + // Single Listing + // Quick Actions Items + $quick_actions = array(); + if ( '1' == get_directorist_option( 'enable_favourite', true ) ) { + $quick_actions[] = array( + 'type' => 'button', + 'label' => 'Bookmark', + 'widget_name' => 'bookmark', + 'widget_key' => 'bookmark', + 'icon' => 'las la-heart', + ); + } + if ( '1' == get_directorist_option( 'enable_report_abuse', true ) ) { + $quick_actions[] = array( + 'type' => 'badge', + 'label' => 'Share', + 'hook' => 'atbdp_single_listings_title', + 'widget_name' => 'share', + 'widget_key' => 'share', + 'icon' => 'las la-share', + ); + } + if ( '1' == get_directorist_option( 'enable_social_share', true ) ) { + $quick_actions[] = array( + 'type' => 'badge', + 'label' => 'Report', + 'hook' => 'atbdp_single_listings_title', + 'widget_name' => 'report', + 'widget_key' => 'report', + 'icon' => 'las la-flag', + ); + } + + // Thumbnail Items + $thumbnail = array(); + if ( '1' == get_directorist_option( 'dsiplay_slider_single_page', true ) ) { + $thumbnail[] = array( + 'type' => 'thumbnail', + 'label' => 'Select Files', + 'hook' => 'atbdp_single_listings_slider', + 'widget_name' => 'listing_slider', + 'widget_key' => 'listing_slider', + 'footer_thumbail' => get_directorist_option( 'dsiplay_thumbnail_img', true ), + ); + } + + // Quick Info Items + $quick_info = array(); + if ( '0' == get_directorist_option( 'disable_list_price', true ) ) { + $quick_info[] = array( + 'type' => 'badge', + 'label' => 'Pricing', + 'hook' => 'atbdp_single_listings_price', + 'widget_name' => 'price', + 'widget_key' => 'price', + ); + } + + $quick_info[] = array( + 'type' => 'ratings-count', + 'label' => 'Listings Ratings', + 'widget_name' => 'ratings_count', + 'widget_key' => 'ratings_count', + ); + + $quick_info[] = array( + 'type' => 'reviews', + 'label' => 'Listings Reviews', + 'widget_name' => 'reviews', + 'widget_key' => 'reviews', + ); + + $quick_info[] = array( + 'type' => 'badge', + 'label' => 'Badges', + 'widget_name' => 'badges', + 'widget_key' => 'badges', + 'new_badge' => get_directorist_option( 'display_new_badge_cart', true ), + 'popular_badge' => get_directorist_option( 'display_popular_badge_cart', true ), + ); + + $quick_info[] = array( + 'type' => 'badge', + 'label' => 'Category', + 'widget_name' => 'category', + 'widget_key' => 'category', + ); + + $quick_info[] = array( + 'type' => 'badge', + 'label' => 'Location', + 'widget_name' => 'location', + 'widget_key' => 'location', + ); + + $single_listing_header = array( + 'listings_header' => array( + 'quick_actions' => $quick_actions, + 'thumbnail' => $thumbnail, + 'quick_info' => $quick_info, + ), + + 'options' => array( + 'general' => array( + 'back' => array( + 'label' => get_directorist_option( 'display_back_link', true ), + ), + 'section_title' => array( + 'label' => get_directorist_option( 'listing_details_text', 'Listing Details' ), + ), + ), + 'content_settings' => array( + 'listing_title' => array( + 'enable_title' => true, + 'enable_tagline' => true, + ), + 'listing_description' => array( + 'enable' => true, + ), + ), + ), + ); + + return $single_listing_header; + } + + // get_listings_card_grid_view_data + public function get_listings_card_grid_view_data( array $args = array() ) { + $active_template = ( ! empty( get_directorist_option( 'display_preview_image' ) ) ) ? 'grid_view_with_thumbnail' : 'grid_view_without_thumbnail'; + $grid_view['active_template'] = $active_template; + + $grid_view['template_data'] = array(); + $grid_view['template_data']['grid_view_with_thumbnail'] = $this->get_listings_card_grid_view_with_thumbnail_data( $args ); + $grid_view['template_data']['grid_view_without_thumbnail'] = $this->get_listings_card_grid_view_without_thumbnail_data( $args ); + + return $grid_view; + } + + // get_listings_card_grid_view_data + public function get_listings_card_grid_view_with_thumbnail_data( array $args = array() ) { + + $default = array( 'listings_card_wedgets' => $this->get_listings_card_wedgets_data() ); + $args = array_merge( $default, $args ); + $listings_card_wedgets = $args['listings_card_wedgets']; + + $card_layouts = array( + 'thumbnail_top_right' => array(), + 'thumbnail_top_left' => array(), + 'thumbnail_bottom_right' => array(), + 'thumbnail_bottom_left' => array(), + 'thumbnail_avatar' => array(), + 'body_top' => array(), + 'body_bottom' => array(), + 'body_excerpt' => array(), + 'footer_right' => array(), + 'footer_left' => array(), + ); + + $widget_layout_map = array( + 'favorite_badge' => array( + 'enable' => get_directorist_option( 'display_mark_as_fav', true ), + 'layout' => array( 'default' => 'thumbnail_top_right' ), + ), + 'featured_badge' => array( + 'enable' => get_directorist_option( 'display_feature_badge_cart', true ), + 'layout' => array( 'default' => 'thumbnail_top_left' ), + ), + 'new_badge' => array( + 'enable' => get_directorist_option( 'display_new_badge_cart', true ), + 'layout' => array( + 'default' => 'thumbnail_bottom_left', + 'direo' => 'thumbnail_top_left', + 'dlist' => 'thumbnail_top_left', + 'dservice' => 'thumbnail_top_left', + ), + ), + 'popular_badge' => array( + 'enable' => get_directorist_option( 'display_popular_badge_cart', true ), + 'layout' => array( + 'default' => 'thumbnail_bottom_left', + 'direo' => 'thumbnail_top_left', + 'dlist' => 'thumbnail_top_left', + 'dservice' => 'thumbnail_top_left', + ), + ), + 'user_avatar' => array( + 'enable' => get_directorist_option( 'display_author_image', true ), + 'layout' => array( 'default' => 'thumbnail_avatar' ), + ), + 'listing_title' => array( + 'enable' => get_directorist_option( 'display_title', true ), + 'layout' => array( 'default' => 'body_top' ), + ), + 'rating' => array( + 'enable' => get_directorist_option( 'enable_review', true ), + 'layout' => array( 'default' => 'body_top' ), + ), + 'pricing' => array( + 'enable' => get_directorist_option( 'display_pricing_field', true ), + 'layout' => array( + 'default' => 'body_top', + 'dservice' => 'thumbnail_bottom_right', + ), + ), + 'listings_location' => array( + 'enable' => get_directorist_option( 'display_contact_info', true ), + 'layout' => array( 'default' => 'body_bottom' ), + ), + 'posted_date' => array( + 'enable' => get_directorist_option( 'display_publish_date', true ), + 'layout' => array( 'default' => 'body_bottom' ), + ), + 'phone' => array( + 'enable' => get_directorist_option( 'display_contact_info', true ), + 'layout' => array( 'default' => 'body_bottom' ), + ), + 'website' => array( + 'enable' => get_directorist_option( 'display_web_link', true ), + 'layout' => array( 'default' => 'body_bottom' ), + ), + 'excerpt' => array( + 'enable' => get_directorist_option( 'enable_excerpt', true ), + 'layout' => array( 'default' => 'body_excerpt' ), + ), + 'view_count' => array( + 'enable' => get_directorist_option( 'display_view_count', true ), + 'layout' => array( 'default' => 'footer_right' ), + ), + 'contact_button' => array( + 'layout' => array( + 'default' => '', + 'dservice' => 'footer_right', + ), + ), + 'category' => array( + 'enable' => get_directorist_option( 'display_category', true ), + 'layout' => array( 'default' => 'footer_left' ), + ), + ); + + $current_theme = wp_get_theme(); + $current_theme = $current_theme->stylesheet; + + // Fill layout with widgets + foreach ( $widget_layout_map as $widget_key => $args ) { + if ( isset( $args['enable'] ) && empty( $args['enable'] ) ) { + continue; } + + $layout = ( in_array( $current_theme, array_keys( $args['layout'] ) ) ) ? $args['layout'][ $current_theme ] : $args['layout']['default']; + + if ( ! empty( $layout ) ) { + $card_layouts[ $layout ][] = $listings_card_wedgets[ $widget_key ]; + } + } + + $listings_card_grid_view = apply_filters( + 'listings_card_grid_view_with_thumbnail', + array( + 'thumbnail' => array( + 'top_right' => $card_layouts['thumbnail_top_right'], + 'top_left' => $card_layouts['thumbnail_top_left'], + 'bottom_right' => $card_layouts['thumbnail_bottom_right'], + 'bottom_left' => $card_layouts['thumbnail_bottom_left'], + 'avatar' => $card_layouts['thumbnail_avatar'], + ), + 'body' => array( + 'top' => $card_layouts['body_top'], + 'bottom' => $card_layouts['body_bottom'], + 'excerpt' => $card_layouts['body_excerpt'], + ), + 'footer' => array( + 'right' => $card_layouts['footer_right'], + 'left' => $card_layouts['footer_left'], + ), + ) + ); + + return $listings_card_grid_view; + } + // get_listings_card_grid_view_without_thumbnail_data + public function get_listings_card_grid_view_without_thumbnail_data( array $args = array() ) { + $default = array( 'listings_card_wedgets' => $this->get_listings_card_wedgets_data() ); + $args = array_merge( $default, $args ); + + $listings_card_wedgets = $args['listings_card_wedgets']; + + // Listings Card Grid View - thumbnail_top_left + $listings_card_grid_view_body_quick_info = array(); + if ( get_directorist_option( 'enable_review', true ) ) { + $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['rating']; + } + + if ( get_directorist_option( 'display_pricing_field', true ) && get_directorist_option( 'display_price', true ) ) { + $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['pricing']; + } + + if ( get_directorist_option( 'display_feature_badge_cart', true ) ) { + $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['featured_badge']; + } + + if ( get_directorist_option( 'display_popular_badge_cart', true ) ) { + $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['popular_badge']; + } + + if ( get_directorist_option( 'display_new_badge_cart', true ) ) { + $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['new_badge']; + } + + // listings_card_grid_view_body_avatar + $listings_card_grid_view_body_avatar = array(); + if ( get_directorist_option( 'display_author_image', true ) ) { + $user_avatar = $listings_card_wedgets['user_avatar']; + $listings_card_grid_view_body_avatar[] = $user_avatar; + } + + // listings_card_grid_view_body_title + $listings_card_grid_view_body_title = array(); + if ( get_directorist_option( 'display_title', true ) ) { + $listings_card_grid_view_body_title[] = $listings_card_wedgets['listing_title']; + } + + // listings_card_grid_view_body_quick_actions + $listings_card_grid_view_body_quick_actions = array(); + if ( get_directorist_option( 'display_mark_as_fav', true ) ) { + $listings_card_grid_view_body_quick_actions[] = $listings_card_wedgets['favorite_badge']; + } + + // listings_card_grid_view_body_quick_info + $listings_card_grid_view_body_quick_info = array(); + if ( get_directorist_option( 'display_mark_as_fav', true ) ) { + $listings_card_grid_view_body_quick_info[] = $listings_card_wedgets['favorite_badge']; + } + + // listings_card_grid_view_body_bottom + $listings_card_grid_view_body_bottom = array(); + if ( get_directorist_option( 'display_contact_info', true ) ) { + $listings_card_grid_view_body_bottom[] = $listings_card_wedgets['listings_location']; + } + + if ( get_directorist_option( 'display_publish_date', true ) ) { + $listings_card_grid_view_body_bottom[] = $listings_card_wedgets['posted_date']; + } + + if ( get_directorist_option( 'display_contact_info', true ) ) { + $listings_card_grid_view_body_bottom[] = $listings_card_wedgets['phone']; + } + + if ( get_directorist_option( 'display_web_link', true ) ) { + $listings_card_grid_view_body_bottom[] = $listings_card_wedgets['website']; + } + + $listings_card_grid_view_body_excerpt = array(); + if ( get_directorist_option( 'enable_excerpt', true ) ) { + $listings_card_grid_view_body_excerpt[] = $listings_card_wedgets['excerpt']; + } + + // listings_card_grid_view_footer_right + $listings_card_grid_view_footer_right = array(); + if ( get_directorist_option( 'display_view_count', true ) ) { + $listings_card_grid_view_footer_right[] = $listings_card_wedgets['view_count']; + } + + // listings_card_grid_view_footer_left + $listings_card_grid_view_footer_left = array(); + if ( get_directorist_option( 'display_category', true ) ) { + $listings_card_grid_view_footer_left[] = $listings_card_wedgets['category']; + } + + $listings_card_grid_view = apply_filters( + 'listings_card_grid_view_without_thumbnail', + array( + 'body' => array( + 'avatar' => $listings_card_grid_view_body_avatar, + 'title' => $listings_card_grid_view_body_title, + 'quick_actions' => $listings_card_grid_view_body_quick_actions, + 'quick_info' => $listings_card_grid_view_body_quick_info, + 'bottom' => $listings_card_grid_view_body_bottom, + 'excerpt' => $listings_card_grid_view_body_excerpt, + ), + 'footer' => array( + 'right' => $listings_card_grid_view_footer_right, + 'left' => $listings_card_grid_view_footer_left, + ), + ) + ); + + return $listings_card_grid_view; + } + + // get_listings_card_list_view_data + public function get_listings_card_list_view_data( array $args = array() ) { + $active_template = ( ! empty( get_directorist_option( 'display_preview_image' ) ) ) ? 'list_view_with_thumbnail' : 'list_view_without_thumbnail'; + $list_view['active_template'] = $active_template; + + $list_view['template_data'] = array(); + $list_view['template_data']['list_view_with_thumbnail'] = $this->get_listings_card_list_view_with_thumbnail_data( $args ); + $list_view['template_data']['list_view_without_thumbnail'] = $this->get_listings_card_list_view_without_thumbnail_data( $args ); + + return $list_view; + } + + // get_listings_card_list_view_with_thumbnail_data + public function get_listings_card_list_view_with_thumbnail_data( array $args = array() ) { + $default = array( 'listings_card_wedgets' => array() ); + $args = array_merge( $default, $args ); + + $listings_card_wedgets = $args['listings_card_wedgets']; + + // $listings_card_list_view_thumbnail_top_right + $listings_card_list_view_thumbnail_top_right = array(); + if ( get_directorist_option( 'display_feature_badge_cart', true ) ) { + $listings_card_list_view_thumbnail_top_right[] = $listings_card_wedgets['featured_badge']; + } + + if ( get_directorist_option( 'display_popular_badge_cart', true ) ) { + $listings_card_list_view_thumbnail_top_right[] = $listings_card_wedgets['popular_badge']; + } + + // $listings_card_list_view_body_top + $listings_card_list_view_body_top = array(); + if ( get_directorist_option( 'display_title', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['listing_title']; + } + + if ( get_directorist_option( 'enable_review', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['rating']; + } + + if ( get_directorist_option( 'display_pricing_field', true ) && get_directorist_option( 'display_price', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['pricing']; + } + + if ( get_directorist_option( 'display_new_badge_cart', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['new_badge']; + } + + // listings_card_list_view_body_right + $listings_card_list_view_body_right = array(); + if ( get_directorist_option( 'display_mark_as_fav', true ) ) { + $listings_card_list_view_body_right[] = $listings_card_wedgets['favorite_badge']; + } + + // $listings_card_list_view_body_bottom + $listings_card_list_view_body_bottom = array(); + if ( get_directorist_option( 'display_contact_info', true ) ) { + $listings_card_list_view_body_bottom[] = $listings_card_wedgets['listings_location']; + } + + if ( get_directorist_option( 'display_publish_date', true ) ) { + $listings_card_list_view_body_bottom[] = $listings_card_wedgets['posted_date']; + } + + if ( get_directorist_option( 'display_contact_info', true ) ) { + $listings_card_list_view_body_bottom[] = $listings_card_wedgets['phone']; + } + + if ( get_directorist_option( 'display_web_link', true ) ) { + $listings_card_list_view_body_bottom[] = $listings_card_wedgets['website']; + } + + // listings_card_list_view_body_excerpt + $listings_card_list_view_body_excerpt = array(); + if ( get_directorist_option( 'enable_excerpt', true ) ) { + $listings_card_list_view_body_excerpt[] = $listings_card_wedgets['excerpt']; + } + + // listings_card_list_view_footer_right + $listings_card_list_view_footer_right = array(); + if ( get_directorist_option( 'display_view_count', true ) ) { + $listings_card_list_view_footer_right[] = $listings_card_wedgets['view_count']; + } + + if ( get_directorist_option( 'display_author_image', true ) ) { + $listings_card_list_view_footer_right[] = $listings_card_wedgets['user_avatar']; + } + + $listings_card_list_view_footer_left = array(); + if ( get_directorist_option( 'display_category', true ) ) { + $listings_card_list_view_footer_left[] = $listings_card_wedgets['category']; + } + + $listings_card_list_view = apply_filters( + 'listings_card_list_view_with_thumbnail', + array( + 'thumbnail' => array( + 'top_right' => $listings_card_list_view_thumbnail_top_right, + ), + 'body' => array( + 'top' => $listings_card_list_view_body_top, + 'right' => $listings_card_list_view_body_right, + 'bottom' => $listings_card_list_view_body_bottom, + 'excerpt' => $listings_card_list_view_body_excerpt, + ), + 'footer' => array( + 'right' => $listings_card_list_view_footer_right, + 'left' => $listings_card_list_view_footer_left, + ), + ) + ); + + return $listings_card_list_view; + } + + // get_listings_card_list_view_without_thumbnail_data + public function get_listings_card_list_view_without_thumbnail_data( array $args = array() ) { + $default = array( 'listings_card_wedgets' => array() ); + $args = array_merge( $default, $args ); + + $listings_card_wedgets = $args['listings_card_wedgets']; + + // $listings_card_list_view_body_top + $listings_card_list_view_body_top = array(); + if ( get_directorist_option( 'display_title', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['listing_title']; + } + + if ( get_directorist_option( 'enable_review', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['rating']; + } + + if ( get_directorist_option( 'display_pricing_field', true ) && get_directorist_option( 'display_price', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['pricing']; + } + + if ( get_directorist_option( 'display_feature_badge_cart', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['featured_badge']; + } + + if ( get_directorist_option( 'display_popular_badge_cart', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['popular_badge']; + } + + if ( get_directorist_option( 'display_new_badge_cart', true ) ) { + $listings_card_list_view_body_top[] = $listings_card_wedgets['new_badge']; + } + + $listings_card_list_view_body_excerpt = array(); + if ( get_directorist_option( 'enable_excerpt', true ) ) { + $listings_card_list_view_body_excerpt[] = $listings_card_wedgets['excerpt']; + } + + $listings_card_list_view_body_right = array(); + if ( get_directorist_option( 'display_mark_as_fav', true ) ) { + $listings_card_list_view_body_right[] = $listings_card_wedgets['favorite_badge']; + } + + // $listings_card_list_view_body_bottom + $listings_card_list_view_body_bottom = array(); + if ( get_directorist_option( 'display_contact_info', true ) ) { + $listings_card_list_view_body_bottom[] = $listings_card_wedgets['listings_location']; + } + + if ( get_directorist_option( 'display_publish_date', true ) ) { + $listings_card_list_view_body_bottom[] = $listings_card_wedgets['posted_date']; + } + + if ( get_directorist_option( 'display_contact_info', true ) ) { + $listings_card_list_view_body_bottom[] = $listings_card_wedgets['phone']; + } + + if ( get_directorist_option( 'display_web_link', true ) ) { + $listings_card_list_view_body_bottom[] = $listings_card_wedgets['website']; + } + + // listings_card_list_view_footer_right + $listings_card_list_view_footer_right = array(); + if ( get_directorist_option( 'display_view_count', true ) ) { + $listings_card_list_view_footer_right[] = $listings_card_wedgets['view_count']; + } + + if ( get_directorist_option( 'display_author_image', true ) ) { + $listings_card_list_view_footer_right[] = $listings_card_wedgets['user_avatar']; + } + + $listings_card_list_view_footer_left = array(); + if ( get_directorist_option( 'display_category', true ) ) { + $listings_card_list_view_footer_left[] = $listings_card_wedgets['category']; + } + + $listings_card_list_view = apply_filters( + 'listings_card_list_view_with_thumbnail', + array( + 'body' => array( + 'top' => $listings_card_list_view_body_top, + 'right' => $listings_card_list_view_body_right, + 'bottom' => $listings_card_list_view_body_bottom, + 'excerpt' => $listings_card_list_view_body_excerpt, + ), + 'footer' => array( + 'right' => $listings_card_list_view_footer_right, + 'left' => $listings_card_list_view_footer_left, + ), + ) + ); + + return $listings_card_list_view; + } + + // get_listings_card_wedgets_data + public function get_listings_card_wedgets_data() { + $listings_card_wedgets = array( + 'favorite_badge' => array( + 'type' => 'icon', + 'label' => 'Favorite', + 'hook' => 'atbdp_favorite_badge', + 'widget_name' => 'favorite_badge', + 'widget_key' => 'favorite_badge', + ), + 'featured_badge' => array( + 'type' => 'badge', + 'label' => get_directorist_option( 'feature_badge_text', __( 'Fetured', 'directorist' ) ), + 'hook' => 'atbdp_featured_badge', + 'widget_name' => 'featured_badge', + 'widget_key' => 'featured_badge', + ), + 'new_badge' => array( + 'type' => 'badge', + 'label' => get_directorist_option( 'new_badge_text', __( 'New', 'directorist' ) ), + 'hook' => 'atbdp_new_badge', + 'widget_name' => 'new_badge', + 'widget_key' => 'new_badge', + ), + 'popular_badge' => array( + 'type' => 'badge', + 'label' => get_directorist_option( 'popular_badge_text', __( 'Popular', 'directorist' ) ), + 'hook' => 'atbdp_popular_badge', + 'widget_name' => 'popular_badge', + 'widget_key' => 'popular_badge', + ), + 'user_avatar' => array( + 'type' => 'avatar', + 'label' => 'User Avatar', + 'hook' => 'atbdp_user_avatar', + 'can_move' => false, + 'widget_name' => 'user_avatar', + 'widget_key' => 'user_avatar', + 'align' => 'right', + ), + 'listing_title' => array( + 'type' => 'title', + 'label' => 'Title', + 'hook' => 'atbdp_listing_title', + 'widget_name' => 'listing_title', + 'widget_key' => 'listing_title', + 'show_tagline' => false, + ), + 'rating' => array( + 'type' => 'rating', + 'label' => 'Rating', + 'hook' => 'atbdp_listings_rating', + 'widget_name' => 'rating', + 'widget_key' => 'rating', + ), + 'pricing' => array( + 'type' => 'price', + 'label' => 'Pricing', + 'hook' => 'pricing', + 'widget_name' => 'pricing', + 'widget_key' => 'pricing', + ), + 'excerpt' => array( + 'type' => 'excerpt', + 'label' => 'Excerpt', + 'hook' => 'atbdp_listing_excerpt', + 'words_limit' => get_directorist_option( 'excerpt_limit', 30 ), + 'show_readmore' => get_directorist_option( 'display_readmore', false ), + 'show_readmore_text' => get_directorist_option( 'readmore_text', 'Read More' ), + 'widget_key' => 'excerpt', + 'widget_name' => 'excerpt', + ), + 'listings_location' => array( + 'type' => 'list-item', + 'label' => 'Location', + 'hook' => 'atbdp_listings_location', + 'widget_name' => 'listings_location', + 'widget_key' => 'listings_location', + 'icon' => 'las la-map-marker', + ), + 'phone' => array( + 'type' => 'list-item', + 'hook' => 'atbdp_listings_phone', + 'label' => 'Phone', + 'widget_name' => 'phone', + 'widget_key' => 'phone', + 'icon' => 'las la-phone', + + ), + 'website' => array( + 'type' => 'list-item', + 'hook' => 'atbdp_listings_website', + 'label' => 'Listings Website', + 'widget_name' => 'website', + 'widget_key' => 'website', + 'icon' => 'las la-globe', + + ), + 'posted_date' => array( + 'type' => 'list-item', + 'label' => 'Posted Date', + 'hook' => 'atbdp_listings_posted_date', + 'widget_name' => 'posted_date', + 'widget_key' => 'posted_date', + 'icon' => 'las la-clock', + 'date_type' => 'days_ago', + ), + 'view_count' => array( + 'type' => 'view-count', + 'label' => 'View Count', + 'hook' => 'atbdp_view_count', + 'widget_name' => 'view_count', + 'widget_key' => 'view_count', + 'icon' => 'las la-heart', + ), + 'category' => array( + 'type' => 'category', + 'label' => 'Category', + 'hook' => 'atbdp_category', + 'widget_name' => 'category', + 'widget_key' => 'category', + 'icon' => 'las la-folder', + ), + 'contact_button' => array( + 'type' => 'button', + 'label' => 'Contact Label', + 'hook' => 'atbdp_open_close_badge', + 'widget_name' => 'contact_button', + 'widget_key' => 'contact_button', + 'icon' => 'las la-phone', + ), + + ); + + $current_theme = wp_get_theme(); + $current_theme = $current_theme->stylesheet; + + $theme_user_avatar = array( + 'direo' => array( 'align' => 'left' ), + 'dlist' => array( 'align' => 'left' ), + 'dservice' => array( 'align' => 'left' ), + ); + + if ( in_array( $current_theme, array_keys( $theme_user_avatar ) ) ) { + $listings_card_wedgets['user_avatar'] = array_merge( $listings_card_wedgets['user_avatar'], $theme_user_avatar[ $current_theme ] ); + } + + return $listings_card_wedgets; + } + + // get_terms_label + public function get_terms_label() { + $terms_label_a = get_directorist_option( 'terms_label', true ); + $terms_label_b = get_directorist_option( 'terms_label_link', true ); + $terms_label = "{$terms_label_a} %{$terms_label_b}%"; + + return $terms_label; + } + + // get_privacy_label + public function get_privacy_label() { + $privacy_label_a = get_directorist_option( 'privacy_label', true ); + $privacy_label_b = get_directorist_option( 'privacy_label_link', true ); + $privacy_label = "{$privacy_label_a} %{$privacy_label_b}%"; + + return $privacy_label; + } + + // get_preview_image + public function get_preview_image() { + $preview_image_url = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); + $preview_image = array( + 'id' => null, + 'url' => $preview_image_url, + ); + + return $preview_image; + } + + + + // get_old_custom_fields + public function get_old_custom_fields() { + $fields = array(); + $old_fields = atbdp_get_custom_field_ids( '', true ); + + foreach ( $old_fields as $old_field_id ) { + $field_type = get_post_meta( $old_field_id, 'type', true ); + $accepted_types = array( 'text', 'number', 'date', 'color', 'time', 'radio', 'checkbox', 'select', 'textarea', 'url', 'file' ); + + if ( ! in_array( $field_type, $accepted_types ) ) { + continue; } + // $get_post_meta = get_post_meta($old_field_id); + + $required = get_post_meta( $old_field_id, 'required', true ); + $admin_use = get_post_meta( $old_field_id, 'admin_use', true ); + $category_pass = get_post_meta( $old_field_id, 'category_pass', true ); + $searchable = get_post_meta( $old_field_id, 'searchable', true ); + $field_data = array(); + + $field_type = ( 'color' === $field_type ) ? 'color_picker' : $field_type; + + // Common Data + $field_data['type'] = $field_type; + $field_data['label'] = get_the_title( $old_field_id ); + $field_data['field_key'] = $old_field_id; + $field_data['placeholder'] = ''; + $field_data['description'] = get_post_meta( $old_field_id, 'instructions', true ); + $field_data['required'] = ( $required == 1 ) ? true : false; + + $field_data['only_for_admin'] = ( $admin_use == 1 ) ? true : false; + + $assign_to = get_post_meta( $old_field_id, 'associate', true ); + $assign_to = ( 'categories' === $assign_to ) ? 'category' : $assign_to; + $field_data['assign_to'] = $assign_to; + $field_data['category'] = ( is_numeric( $category_pass ) ) ? (int) $category_pass : ''; + $field_data['searchable'] = ( $searchable == 1 ) ? true : false; + + $field_data['widget_group'] = 'custom'; + $field_data['widget_name'] = $field_type; + $field_data['widget_key'] = $field_type . '_' . $old_field_id; + + // field group + $field_group = array( 'radio', 'checkbox', 'select' ); + if ( in_array( $field_type, $field_group ) ) { + $choices = get_post_meta( $old_field_id, 'choices', true ); + $field_data['options'] = $this->decode_custom_field_option_string( $choices ); + } + + if ( ( 'textarea' === $field_type ) ) { + $field_data['rows'] = get_post_meta( $old_field_id, 'rows', true ); + } + + if ( ( 'url' === $field_type ) ) { + $field_data['target'] = get_post_meta( $old_field_id, 'target', true ); + } + + if ( ( 'file' === $field_type ) ) { + $file_type = get_post_meta( $old_field_id, 'file_type', true ); + $file_type = ( 'all_types' === $file_type ) ? 'all' : $file_type; + $field_data['file_type'] = $file_type; + $field_data['file_size'] = get_post_meta( $old_field_id, 'file_size', true ); + } + + $fields[ $field_type . '_' . $old_field_id ] = $field_data; + } + + return $fields; + } + + // decode_custom_field_option_string + public function decode_custom_field_option_string( string $string = '' ) { + $choices = ( ! empty( $string ) ) ? explode( "\n", $string ) : array(); + $options = array(); + + if ( count( $choices ) ) { + foreach ( $choices as $option ) { + $value_match = array(); + $label_match = array(); + + preg_match( '/(.+):/', $option, $value_match ); + preg_match( '/:(.+)/', $option, $label_match ); + + if ( empty( $value_match[1] ) && empty( $label_match[1] ) ) { + $options[] = array( + 'option_value' => $option, + 'option_label' => $option, + ); + + continue; + } + + $options[] = array( + 'option_value' => trim( $value_match[1] ), + 'option_label' => trim( $label_match[1] ), + ); + } + } + + return $options; + } +} diff --git a/includes/modules/multi-directory-setup/trait-multi-directory-helper.php b/includes/modules/multi-directory-setup/trait-multi-directory-helper.php index 2b53269819..7e18f15828 100644 --- a/includes/modules/multi-directory-setup/trait-multi-directory-helper.php +++ b/includes/modules/multi-directory-setup/trait-multi-directory-helper.php @@ -6,273 +6,275 @@ trait Multi_Directory_Helper { - public static function add_directory( array $args = [] ) { - $default = [ - 'term_id' => 0, - 'directory_name' => '', - 'fields_value' => [], - 'is_json' => false - ]; - $args = array_merge( $default, $args ); - - $has_term_id = false; - if ( ! empty( $args['term_id'] ) ) { - $has_term_id = true; - } - - if ( $has_term_id && ! is_numeric( $args['term_id'] ) ) { - $has_term_id = false; - } + public static function add_directory( array $args = array() ) { + $default = array( + 'term_id' => 0, + 'directory_name' => '', + 'fields_value' => array(), + 'is_json' => false, + ); + $args = array_merge( $default, $args ); + + $has_term_id = false; + if ( ! empty( $args['term_id'] ) ) { + $has_term_id = true; + } + + if ( $has_term_id && ! is_numeric( $args['term_id'] ) ) { + $has_term_id = false; + } + + if ( $has_term_id && $args['term_id'] < 1 ) { + $has_term_id = false; + } + + $create_directory = array( 'term_id' => 0 ); + + if ( ! $has_term_id ) { + $create_directory = self::create_directory( + array( + 'directory_name' => $args['directory_name'], + ) + ); + + if ( ! $create_directory['status']['success'] ) { + return $create_directory; + } + } + + $update_directory = self::update_directory( + array( + 'term_id' => ( ! $has_term_id ) ? (int) $create_directory['term_id'] : (int) $args['term_id'], + 'directory_name' => $args['directory_name'], + 'fields_value' => $args['fields_value'], + 'is_json' => $args['is_json'], + ) + ); + + if ( ! empty( $update_directory['status']['status_log']['term_updated'] ) && ! empty( $create_directory['status']['status_log']['term_created'] ) ) { + $update_directory['status']['status_log']['term_created'] = $create_directory['status']['status_log']['term_created']; + + unset( $update_directory['status']['status_log']['term_updated'] ); + } + + return $update_directory; + } + + // create_directory + public static function create_directory( array $args = array() ) { + $default = array( 'directory_name' => '' ); + $args = array_merge( $default, $args ); + + $response = array( + 'status' => array( + 'success' => true, + 'status_log' => array(), + 'error_count' => 0, + ), + ); + + $directory_name = esc_attr( $args['directory_name'] ); + + // Validate name + if ( empty( $directory_name ) ) { + $response['status']['status_log']['name_is_missing'] = array( + 'type' => 'error', + 'message' => __( 'Name is missing', 'directorist' ), + ); + + ++$response['status']['error_count']; + } + + // Validate term name + if ( ! empty( $directory_name ) && $term = term_exists( $directory_name, 'atbdp_listing_types' ) ) { + $response['status']['status_log']['term_exists'] = array( + 'type' => 'error', + 'message' => __( 'The name already exists', 'directorist' ), + ); + + $response['status']['term_id'] = $term['term_id']; + + ++$response['status']['error_count']; + } + + // Return status + if ( $response['status']['error_count'] ) { + $response['status']['success'] = false; + return $response; + } + + do_action( 'directorist_before_create_directory_type', $directory_name ); + + // Create the directory + $term = wp_insert_term( $directory_name, 'atbdp_listing_types' ); + + if ( is_wp_error( $term ) ) { + $response['status']['status_log']['term_exists'] = array( + 'type' => 'error', + 'message' => __( 'The name already exists', 'directorist' ), + ); + + ++$response['status']['error_count']; + } + + if ( $response['status']['error_count'] ) { + $response['status']['success'] = false; + return $response; + } + + do_action( 'directorist_after_create_directory_type', $term ); + + $response['term_id'] = (int) $term['term_id']; + + $response['status']['status_log']['term_created'] = array( + 'type' => 'success', + 'message' => __( 'The directory has been created successfully', 'directorist' ), + ); + update_term_meta( $response['term_id'], '_created_date', time() ); + return $response; + } + + // update_directory + public static function update_directory( array $args = array() ) { + $default = array( + 'directory_name' => '', + 'term_id' => 0, + 'fields_value' => array(), + 'is_json' => false, + ); + $args = array_merge( $default, $args ); + + $response = array( + 'status' => array( + 'success' => true, + 'status_log' => array(), + 'error_count' => 0, + ), + ); + + $response['term_id'] = $args['term_id']; + + // Validation + if ( $args['is_json'] ) { + $args['fields_value'] = json_decode( $args['fields_value'], true ); + } + + // Validate data + $has_invalid_data = false; + + if ( is_null( $args['fields_value'] ) ) { + $has_invalid_data = true; + } + + if ( ! is_array( $args['fields_value'] ) ) { + $has_invalid_data = true; + } + + if ( $has_invalid_data ) { + $response['status']['status_log']['invalid_data'] = array( + 'type' => 'error', + 'message' => __( 'The data is invalid', 'directorist' ), + ); + + ++$response['status']['error_count']; + } + + // Validate term id + $has_invalid_term_id = false; + + if ( empty( $args['term_id'] ) ) { + $has_invalid_term_id = true; + } + + if ( ! is_numeric( $args['term_id'] ) ) { + $has_invalid_term_id = true; + } + + $term_id = $args['term_id']; + if ( is_numeric( $term_id ) ) { + $args['term_id'] = (int) $term_id; + } + + // Validate term id + if ( ! term_exists( $args['term_id'], 'atbdp_listing_types' ) ) { + $has_invalid_term_id = true; + } + + if ( $has_invalid_term_id ) { + $response['status']['status_log']['invalid_term_id'] = array( + 'type' => 'error', + 'message' => __( 'Invalid term ID', 'directorist' ), + ); + + ++$response['status']['error_count']; + $response['status']['success'] = false; + + return $response; + } + + do_action( 'directorist_before_update_directory_type', (int) $term_id ); + + $fields = $args['fields_value']; + + if ( is_array( $fields ) ) { + foreach ( $fields as $_field_key => $_field_value ) { + $fields[ $_field_key ] = Helper::maybe_json( $_field_value ); + } + } + + $fields = apply_filters( 'cptm_fields_before_update', $fields ); + + $directory_name = ( ! empty( $fields['name'] ) ) ? $fields['name'] : ''; + $directory_name = ( ! empty( $args['directory_name'] ) ) ? $args['directory_name'] : $directory_name; + $directory_name = esc_attr( $directory_name ); + + $response['fields_value'] = $fields; + $response['directory_name'] = $args['directory_name']; + + unset( $fields['name'] ); + + $term = get_term( $args['term_id'], ATBDP_DIRECTORY_TYPE ); + $old_name = $term->name; + + $has_diffrent_name = $old_name !== $directory_name; + + if ( $has_diffrent_name && term_exists( $directory_name, 'atbdp_listing_types' ) ) { + $response['status']['status_log']['name_exists'] = array( + 'type' => 'error', + 'message' => __( 'The name already exists', 'directorist' ), + ); - if ( $has_term_id && $args['term_id'] < 1 ) { - $has_term_id = false; - } - - $create_directory = [ 'term_id' => 0 ]; - - if ( ! $has_term_id ) { - $create_directory = self::create_directory([ - 'directory_name' => $args['directory_name'] - ]); - - if ( ! $create_directory['status']['success'] ) { - return $create_directory; - } - } - - $update_directory = self::update_directory([ - 'term_id' => ( ! $has_term_id ) ? ( int ) $create_directory['term_id'] : ( int ) $args['term_id'], - 'directory_name' => $args['directory_name'], - 'fields_value' => $args['fields_value'], - 'is_json' => $args['is_json'], - ]); - - - if ( ! empty( $update_directory['status']['status_log']['term_updated'] ) && ! empty( $create_directory['status']['status_log']['term_created'] ) ) { - $update_directory['status']['status_log']['term_created'] = $create_directory['status']['status_log']['term_created']; - - unset( $update_directory['status']['status_log']['term_updated'] ); - } - - return $update_directory; - } - - // create_directory - public static function create_directory( array $args = [] ) { - $default = [ 'directory_name' => '' ]; - $args = array_merge( $default, $args ); - - $response = [ - 'status' => [ - 'success' => true, - 'status_log' => [], - 'error_count' => 0, - ] - ]; - - $directory_name = esc_attr( $args['directory_name'] ); - - // Validate name - if ( empty( $directory_name ) ) { - $response['status']['status_log']['name_is_missing'] = [ - 'type' => 'error', - 'message' => __( 'Name is missing', 'directorist' ), - ]; - - $response['status']['error_count']++; - } - - // Validate term name - if ( ! empty( $directory_name ) && $term = term_exists( $directory_name, 'atbdp_listing_types' ) ) { - $response['status']['status_log']['term_exists'] = [ - 'type' => 'error', - 'message' => __( 'The name already exists', 'directorist' ), - ]; - - $response['status']['term_id'] = $term['term_id']; - - $response['status']['error_count']++; - } - - // Return status - if ( $response['status']['error_count'] ) { - $response['status']['success'] = false; - return $response; - } - - do_action( 'directorist_before_create_directory_type', $directory_name ); - - // Create the directory - $term = wp_insert_term( $directory_name, 'atbdp_listing_types'); - - if ( is_wp_error( $term ) ) { - $response['status']['status_log']['term_exists'] = [ - 'type' => 'error', - 'message' => __( 'The name already exists', 'directorist' ), - ]; - - $response['status']['error_count']++; - } - - - if ( $response['status']['error_count'] ) { - $response['status']['success'] = false; - return $response; - } - - do_action( 'directorist_after_create_directory_type', $term ); - - $response['term_id'] = ( int ) $term['term_id']; - - $response['status']['status_log']['term_created'] = [ - 'type' => 'success', - 'message' => __( 'The directory has been created successfully', 'directorist' ), - ]; - update_term_meta( $response['term_id'], '_created_date', time() ); - return $response; - } - - // update_directory - public static function update_directory( array $args = [] ) { - $default = [ - 'directory_name' => '', - 'term_id' => 0, - 'fields_value' => [], - 'is_json' => false - ]; - $args = array_merge( $default, $args ); + ++$response['status']['error_count']; + } - $response = [ - 'status' => [ - 'success' => true, - 'status_log' => [], - 'error_count' => 0, - ] - ]; - - $response['term_id'] = $args['term_id']; - - // Validation - if ( $args['is_json'] ) { - $args['fields_value'] = json_decode( $args['fields_value'], true ); - } - - // Validate data - $has_invalid_data = false; - - if ( is_null( $args['fields_value'] ) ) { - $has_invalid_data = true; - } - - if ( ! is_array( $args['fields_value'] ) ) { - $has_invalid_data = true; - } + // Return status + if ( $response['status']['error_count'] ) { + $response['status']['success'] = false; + return $response; + } - if ( $has_invalid_data ) { - $response['status']['status_log']['invalid_data'] = [ - 'type' => 'error', - 'message' => __( 'The data is invalid', 'directorist' ), - ]; - - $response['status']['error_count']++; - } - - // Validate term id - $has_invalid_term_id = false; - - if ( empty( $args['term_id'] ) ) { - $has_invalid_term_id = true; - } - - if ( ! is_numeric( $args['term_id'] ) ) { - $has_invalid_term_id = true; - } + // Update name if exist + if ( ! empty( $directory_name ) ) { + wp_update_term( $args['term_id'], 'atbdp_listing_types', array( 'name' => $directory_name ) ); + } - $term_id = $args['term_id']; - if ( is_numeric( $term_id ) ) { - $args['term_id'] = ( int ) $term_id; - } - - // Validate term id - if ( ! term_exists( $args['term_id'], 'atbdp_listing_types' ) ) { - $has_invalid_term_id = true; - } + // Update the value + foreach ( $fields as $key => $value ) { + self::update_validated_term_meta( $args['term_id'], $key, $value ); + } - if ( $has_invalid_term_id ) { - $response['status']['status_log']['invalid_term_id'] = [ - 'type' => 'error', - 'message' => __( 'Invalid term ID', 'directorist' ), - ]; - - $response['status']['error_count']++; - $response['status']['success'] = false; - - return $response; - } + $response['status']['status_log']['term_updated'] = array( + 'type' => 'success', + 'message' => __( 'The directory has been updated successfully', 'directorist' ), + ); - do_action( 'directorist_before_update_directory_type', (int) $term_id ); - - $fields = $args['fields_value']; + do_action( 'directorist_after_update_directory_type', (int) $term_id ); - if ( is_array( $fields ) ) { - foreach ( $fields as $_field_key => $_field_value ) { - $fields[ $_field_key ] = Helper::maybe_json( $_field_value ); - } - } - - $fields = apply_filters( 'cptm_fields_before_update', $fields ); - - $directory_name = ( ! empty( $fields['name'] ) ) ? $fields['name'] : ''; - $directory_name = ( ! empty( $args['directory_name'] ) ) ? $args['directory_name'] : $directory_name; - $directory_name = esc_attr( $directory_name ); - - $response['fields_value'] = $fields; - $response['directory_name'] = $args['directory_name']; - - unset( $fields['name'] ); - - $term = get_term( $args['term_id'], ATBDP_DIRECTORY_TYPE ); - $old_name = $term->name; - - $has_diffrent_name = $old_name !== $directory_name; - - if ( $has_diffrent_name && term_exists( $directory_name, 'atbdp_listing_types' ) ) { - $response['status']['status_log']['name_exists'] = [ - 'type' => 'error', - 'message' => __( 'The name already exists', 'directorist' ), - ]; + return $response; + } - $response['status']['error_count']++; - } - - // Return status - if ( $response['status']['error_count'] ) { - $response['status']['success'] = false; - return $response; - } - - // Update name if exist - if ( ! empty( $directory_name ) ) { - wp_update_term( $args['term_id'], 'atbdp_listing_types', ['name' => $directory_name] ); - } - - // Update the value - foreach ( $fields as $key => $value ) { - self::update_validated_term_meta( $args['term_id'], $key, $value ); - } - - $response['status']['status_log']['term_updated'] = [ - 'type' => 'success', - 'message' => __( 'The directory has been updated successfully', 'directorist' ), - ]; - - do_action( 'directorist_after_update_directory_type', (int) $term_id ); - - return $response; - } - - // maybe_serialize - public function maybe_serialize( $value = '' ) { - return maybe_serialize( Helper::maybe_json( $value ) ); - } -} \ No newline at end of file + // maybe_serialize + public function maybe_serialize( $value = '' ) { + return maybe_serialize( Helper::maybe_json( $value ) ); + } +} diff --git a/includes/modules/updater/EDD_SL_Plugin_Updater.php b/includes/modules/updater/EDD_SL_Plugin_Updater.php index bc6300365d..71068b989c 100644 --- a/includes/modules/updater/EDD_SL_Plugin_Updater.php +++ b/includes/modules/updater/EDD_SL_Plugin_Updater.php @@ -1,6 +1,8 @@ <?php // Exit if accessed directly -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** * Allows plugins to use their own update API. @@ -16,7 +18,7 @@ class EDD_SL_Plugin_Updater { private $slug = ''; private $version = ''; private $wp_override = false; - private $beta = false; + private $beta = false; private $cache_key = ''; private $health_check_timeout = 5; @@ -27,9 +29,9 @@ class EDD_SL_Plugin_Updater { * @uses plugin_basename() * @uses hook() * - * @param string $_api_url The URL pointing to the custom API endpoint. - * @param string $_plugin_file Path to the plugin file. - * @param array $_api_data Optional data to send with API calls. + * @param string $_api_url The URL pointing to the custom API endpoint. + * @param string $_plugin_file Path to the plugin file. + * @param array $_api_data Optional data to send with API calls. */ public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { @@ -57,7 +59,6 @@ public function __construct( $_api_url, $_plugin_file, $_api_data = null ) { // Set up hooks. $this->init(); - } /** @@ -74,7 +75,6 @@ public function init() { remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 ); add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 ); add_action( 'admin_init', array( $this, 'show_changelog' ) ); - } /** @@ -87,7 +87,7 @@ public function init() { * * @uses api_request() * - * @param array $_transient_data Update array build by WordPress. + * @param array $_transient_data Update array build by WordPress. * @return array Modified update array with custom plugin data. */ public function check_update( $_transient_data ) { @@ -95,7 +95,7 @@ public function check_update( $_transient_data ) { global $pagenow; if ( ! is_object( $_transient_data ) ) { - $_transient_data = new stdClass; + $_transient_data = new stdClass(); } if ( 'plugins.php' == $pagenow && is_multisite() ) { @@ -109,7 +109,13 @@ public function check_update( $_transient_data ) { $version_info = $this->get_cached_version_info(); if ( false === $version_info ) { - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); + $version_info = $this->api_request( + 'plugin_latest_version', + array( + 'slug' => $this->slug, + 'beta' => $this->beta, + ) + ); $this->set_version_info_cache( $version_info ); @@ -137,8 +143,8 @@ public function check_update( $_transient_data ) { /** * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise! * - * @param string $file - * @param array $plugin + * @param string $file + * @param array $plugin */ public function show_update_notification( $file, $plugin ) { @@ -146,11 +152,11 @@ public function show_update_notification( $file, $plugin ) { return; } - if( ! current_user_can( 'update_plugins' ) ) { + if ( ! current_user_can( 'update_plugins' ) ) { return; } - if( ! is_multisite() ) { + if ( ! is_multisite() ) { return; } @@ -170,7 +176,13 @@ public function show_update_notification( $file, $plugin ) { $version_info = $this->get_cached_version_info(); if ( false === $version_info ) { - $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) ); + $version_info = $this->api_request( + 'plugin_latest_version', + array( + 'slug' => $this->slug, + 'beta' => $this->beta, + ) + ); // Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now: if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) { @@ -198,7 +210,7 @@ public function show_update_notification( $file, $plugin ) { } - $update_cache->last_checked = time(); + $update_cache->last_checked = time(); $update_cache->checked[ $this->name ] = $this->version; set_site_transient( 'update_plugins', $update_cache ); @@ -216,7 +228,7 @@ public function show_update_notification( $file, $plugin ) { // build a plugin list row, with update notification $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); - # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> + // <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"> echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">'; echo '<td colspan="3" class="plugin-update colspanchange">'; echo '<div class="update-message notice inline notice-warning notice-alt">'; @@ -238,7 +250,7 @@ public function show_update_notification( $file, $plugin ) { '<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">', esc_html( $version_info->new_version ), '</a>', - '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">', + '<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) . '">', '</a>' ); } @@ -254,9 +266,9 @@ public function show_update_notification( $file, $plugin ) { * * @uses api_request() * - * @param mixed $_data - * @param string $_action - * @param object $_args + * @param mixed $_data + * @param string $_action + * @param object $_args * @return object $_data */ public function plugins_api_filter( $_data, $_action = '', $_args = null ) { @@ -280,7 +292,7 @@ public function plugins_api_filter( $_data, $_action = '', $_args = null ) { 'banners' => array(), 'reviews' => false, 'icons' => array(), - ) + ), ); $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ); @@ -288,7 +300,7 @@ public function plugins_api_filter( $_data, $_action = '', $_args = null ) { // Get the transient where we store the api request for this plugin for 24 hours $edd_api_request_transient = $this->get_cached_version_info( $cache_key ); - //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now. + // If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now. if ( empty( $edd_api_request_transient ) ) { $api_response = $this->api_request( 'plugin_information', $to_send ); @@ -299,7 +311,6 @@ public function plugins_api_filter( $_data, $_action = '', $_args = null ) { if ( false !== $api_response ) { $_data = $api_response; } - } else { $_data = $edd_api_request_transient; } @@ -319,7 +330,7 @@ public function plugins_api_filter( $_data, $_action = '', $_args = null ) { $_data->icons = $this->convert_object_to_array( $_data->icons ); } - if( ! isset( $_data->plugin ) ) { + if ( ! isset( $_data->plugin ) ) { $_data->plugin = $this->name; } @@ -350,8 +361,8 @@ private function convert_object_to_array( $data ) { /** * Disable SSL verification in order to prevent download update failures * - * @param array $args - * @param string $url + * @param array $args + * @param string $url * @return object $array */ public function http_request_args( $args, $url ) { @@ -361,7 +372,6 @@ public function http_request_args( $args, $url ) { $args['sslverify'] = $verify_ssl; } return $args; - } /** @@ -371,8 +381,8 @@ public function http_request_args( $args, $url ) { * @uses wp_remote_post() * @uses is_wp_error() * - * @param string $_action The requested action. - * @param array $_data Parameters for the API action. + * @param string $_action The requested action. + * @param array $_data Parameters for the API action. * @return false|object */ private function api_request( $_action, $_data ) { @@ -386,15 +396,21 @@ private function api_request( $_action, $_data ) { if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) { $test_url_parts = parse_url( $this->api_url ); - $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http'; - $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; - $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : ''; + $scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http'; + $host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : ''; + $port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : ''; if ( empty( $host ) ) { $edd_plugin_url_available[ $store_hash ] = false; } else { - $test_url = $scheme . '://' . $host . $port; - $response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) ); + $test_url = $scheme . '://' . $host . $port; + $response = wp_remote_get( + $test_url, + array( + 'timeout' => $this->health_check_timeout, + 'sslverify' => $verify_ssl, + ) + ); $edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true; } } @@ -409,7 +425,7 @@ private function api_request( $_action, $_data ) { return; } - if( $this->api_url == trailingslashit ( home_url() ) ) { + if ( $this->api_url == trailingslashit( home_url() ) ) { return false; // Don't allow a plugin to ping itself } @@ -425,7 +441,14 @@ private function api_request( $_action, $_data ) { 'beta' => ! empty( $data['beta'] ), ); - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); + $request = wp_remote_post( + $this->api_url, + array( + 'timeout' => 15, + 'sslverify' => $verify_ssl, + 'body' => $api_params, + ) + ); if ( ! is_wp_error( $request ) ) { $request = json_decode( wp_remote_retrieve_body( $request ) ); @@ -445,8 +468,8 @@ private function api_request( $_action, $_data ) { $request->icons = maybe_unserialize( $request->icons ); } - if( ! empty( $request->sections ) ) { - foreach( $request->sections as $key => $section ) { + if ( ! empty( $request->sections ) ) { + foreach ( $request->sections as $key => $section ) { $request->$key = (array) $section; } } @@ -458,19 +481,19 @@ public function show_changelog() { global $edd_plugin_data; - if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { + if ( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) { return; } - if( empty( $_REQUEST['plugin'] ) ) { + if ( empty( $_REQUEST['plugin'] ) ) { return; } - if( empty( $_REQUEST['slug'] ) ) { + if ( empty( $_REQUEST['slug'] ) ) { return; } - if( ! current_user_can( 'update_plugins' ) ) { + if ( ! current_user_can( 'update_plugins' ) ) { wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) ); } @@ -479,7 +502,7 @@ public function show_changelog() { $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' ); $version_info = $this->get_cached_version_info( $cache_key ); - if( false === $version_info ) { + if ( false === $version_info ) { $api_params = array( 'edd_action' => 'get_version', @@ -488,25 +511,31 @@ public function show_changelog() { 'slug' => $_REQUEST['slug'], 'author' => $data['author'], 'url' => home_url(), - 'beta' => ! empty( $data['beta'] ) + 'beta' => ! empty( $data['beta'] ), ); $verify_ssl = $this->verify_ssl(); - $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) ); + $request = wp_remote_post( + $this->api_url, + array( + 'timeout' => 15, + 'sslverify' => $verify_ssl, + 'body' => $api_params, + ) + ); if ( ! is_wp_error( $request ) ) { $version_info = json_decode( wp_remote_retrieve_body( $request ) ); } - if ( ! empty( $version_info ) && isset( $version_info->sections ) ) { $version_info->sections = maybe_unserialize( $version_info->sections ); } else { $version_info = false; } - if( ! empty( $version_info ) ) { - foreach( $version_info->sections as $key => $section ) { + if ( ! empty( $version_info ) ) { + foreach ( $version_info->sections as $key => $section ) { $version_info->$key = (array) $section; } } @@ -515,7 +544,7 @@ public function show_changelog() { } - if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { + if ( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) { echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>'; } @@ -524,13 +553,13 @@ public function show_changelog() { public function get_cached_version_info( $cache_key = '' ) { - if( empty( $cache_key ) ) { + if ( empty( $cache_key ) ) { $cache_key = $this->cache_key; } $cache = get_option( $cache_key ); - if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { + if ( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) { return false; // Cache is expired } @@ -541,22 +570,20 @@ public function get_cached_version_info( $cache_key = '' ) { } return $cache['value']; - } public function set_version_info_cache( $value = '', $cache_key = '' ) { - if( empty( $cache_key ) ) { + if ( empty( $cache_key ) ) { $cache_key = $this->cache_key; } $data = array( 'timeout' => strtotime( '+3 hours', time() ), - 'value' => json_encode( $value ) + 'value' => json_encode( $value ), ); update_option( $cache_key, $data, 'no' ); - } /** @@ -568,5 +595,4 @@ public function set_version_info_cache( $value = '', $cache_key = '' ) { private function verify_ssl() { return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this ); } - } diff --git a/includes/payments/class-order.php b/includes/payments/class-order.php index 2e39f92c69..e69e9955a9 100644 --- a/includes/payments/class-order.php +++ b/includes/payments/class-order.php @@ -10,7 +10,9 @@ */ // Exit if accessed directly -if (!defined('ABSPATH')) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} /** * ATBDP_Order Class @@ -18,591 +20,595 @@ * @since 3.1.0 * @access public */ -class ATBDP_Order -{ - - - public function __construct() - { - add_action('init', array($this, 'register_custom_post_type')); - - add_action('admin_footer-edit.php', array($this, 'admin_footer_edit')); - add_action('restrict_manage_posts', array($this, 'restrict_manage_posts')); - add_action('load-edit.php', array($this, 'load_edit')); - add_action('admin_notices', array($this, 'admin_notices')); - - add_filter('parse_query', array($this, 'parse_query')); - add_filter('manage_atbdp_orders_posts_columns', array($this, 'add_new_order_columns')); - add_action('manage_atbdp_orders_posts_custom_column', array($this, 'manage_order_columns'), 10, 2); - - add_filter('manage_edit-atbdp_orders_sortable_columns', array($this, 'get_sortable_columns')); - - add_filter('post_row_actions', array($this, 'set_payment_receipt_link'), 10, 2); - - } - - /** - * It returns order details in html format - * @param int $order_id The order ID - * @return string - */ - public static function get_order_details($order_id) - { - if (empty($order_id)) return __('No Order ID Provided', 'directorist'); - $c_position = get_directorist_option('payment_currency_position'); - $currency = atbdp_get_payment_currency(); - $symbol = atbdp_currency_symbol($currency); - $order_items = apply_filters('atbdp_order_items_data', array(), $order_id); // this is the hook that an extension can hook to, to add new items on checkout page.eg. plan - - $featured = get_post_meta($order_id, '_featured', true); - $listing_id = get_post_meta($order_id, '_listing_id', true); - if ($featured) { - $order_items[] = atbdp_get_featured_settings_array(); - } - - // fix currency symbol position - $before = ''; - $after = ''; - ('after' == $c_position) ? $after = $symbol : $before = $symbol; - - ob_start(); - ?> - <table border="0" cellspacing="0" cellpadding="7" style="border:1px solid #CCC;"> - <tr style="background-color:#F0F0F0;"> - <th style="border-right:1px solid #CCC; border-bottom:1px solid #CCC; text-align:left;"><?php esc_html_e('Item(s)', 'directorist'); ?></th> - <th style="border-bottom:1px solid #CCC;"><?php printf( esc_html__('Price [%s]', 'directorist'), esc_html( $currency )); ?></th> - </tr> - <?php if (!empty($order_items)) { - foreach ($order_items as $order) : ?> - <tr> - <td style="border-right:1px solid #CCC; border-bottom:1px solid #CCC;"> - <h3><?php echo ! empty( $order['label'] ) ? esc_html( $order['label'] ) : ''; ?></h3> - <?php echo ! empty( $order['desc'] ) ? esc_html( $order['desc'] ) : ''; ?> - </td> - <td style="border-bottom:1px solid #CCC;"> - <?php echo esc_html( $before . $order['price'] . $after ); ?> - </td> - </tr> - <?php endforeach; - } ?> - <tr> - <td style="border-right:1px solid #CCC; text-align:right; vertical-align:middle;"> - <?php printf( esc_html__('Total amount [%s]', 'directorist'), esc_html( $currency )); ?> - </td> - <td> - <?php - $amount = get_post_meta( $order_id, '_amount', true ); - - /** - * Filter the order amount for email receipt. - * - * Allows developers to modify the order amount before it is used in email receipts. - * - * @since 7.8.0 - * - * @param float $amount The order amount. - * @param int $order_id The order ID. - * - * @return float The filtered order amount. - */ - $total_amount = apply_filters( 'directorist_email_receipt_order_amount', $amount, $order_id ); - - echo esc_html( $before . $total_amount . $after ); - do_action( 'atbdp_email_receipt_after_total_price', $listing_id ); - ?> - </td> - </tr> - </table> - <?php - return ob_get_clean(); - } - - /** - * Register a custom post type "atbdp_orders". - * - * @since 3.1.0 - * @access public - */ - public function register_custom_post_type() - { - - $mitization_active = directorist_is_monetization_enabled(); - $labels = array( - 'name' => _x('Order History', 'Post Type General Name', 'directorist'), - 'singular_name' => _x('Order', 'Post Type Singular Name', 'directorist'), - 'menu_name' => __('Order History', 'directorist'), - 'name_admin_bar' => __('Order', 'directorist'), - 'all_items' => __('Order History', 'directorist'), - 'add_new_item' => __('Add New Order', 'directorist'), - 'add_new' => __('Add New', 'directorist'), - 'new_item' => __('New Order', 'directorist'), - 'edit_item' => __('Edit Order', 'directorist'), - 'update_item' => __('Update Order', 'directorist'), - 'view_item' => __('View Order', 'directorist'), - 'search_items' => __('Search Order', 'directorist'), - 'not_found' => __('No orders found', 'directorist'), - 'not_found_in_trash' => __('No orders found in Trash', 'directorist'), - ); - - $args = array( - 'labels' => $labels, - 'description' => __('This order post type will keep track of user\'s order and payment status', 'directorist'), - 'supports' => array('title', 'author',), - 'taxonomies' => array(''), - 'hierarchical' => false, - 'public' => true, - 'show_ui' => current_user_can('manage_atbdp_options') ? (!empty($mitization_active) ? true : false) : false, // show the menu only to the admin - 'show_in_menu' => current_user_can('manage_atbdp_options') ? 'edit.php?post_type=' . ATBDP_POST_TYPE : false, - 'show_in_admin_bar' => true, - 'capabilities' => array( - 'create_posts' => false, - ), - 'show_in_nav_menus' => true, - 'can_export' => true, - 'has_archive' => true, - 'exclude_from_search' => true, - 'publicly_queryable' => true, - 'capability_type' => 'at_biz_dir', - 'map_meta_cap' => true, - ); - - register_post_type('atbdp_orders', $args); - - } - - /** - * Add/Remove custom bulk actions to the select menus. - * @todo; In future we may use add_action('bulk_actions-{screen_id}', 'my_bulk_action') when we will stop supporting WP < 4.7. - * @see http://wpengineer.com/2803/create-your-own-bulk-actions/ - * @since 3.1.0 - * @access public - */ - public function admin_footer_edit() - { - - global $post_type; - if ('atbdp_orders' == $post_type) { - - ?> - <script type="text/javascript"> - var atbdp_bulk_actions = <?php echo json_encode(atbdp_get_payment_bulk_actions()); ?>; - /*$actions = array( - 'set_to_created' => __( "Set Status to Created", 'directorist' ), - 'set_to_pending' => __( "Set Status to Pending", 'directorist' ), - 'set_to_completed' => __( "Set Status to Completed", 'directorist' ), - 'set_to_failed' => __( "Set Status to Failed", 'directorist' ), - 'set_to_cancelled' => __( "Set Status to Cancelled", 'directorist' ), - 'set_to_refunded' => __( "Set Status to Refunded", 'directorist' ) - );*/ - jQuery(document).ready(function () { - for (var key in atbdp_bulk_actions) { - if (atbdp_bulk_actions.hasOwnProperty(key)) { - var $option = jQuery('<option>').val(key).text(atbdp_bulk_actions[key]); - $option.appendTo('#bulk-action-selector-top', '#bulk-action-selector-bottom'); - //$option.appendTo('#bulk-action-selector-bottom'); - } - } - - jQuery('select[name="action"]').find('option[value="edit"]').remove(); - jQuery('select[name="action2"]').find('option[value="edit"]').remove(); - }); - </script> - <?php - } - } - - /** - * Add custom filter options. - * - * @since 3.1.0 - * @access public - */ - public function restrict_manage_posts() - { - - global $typenow, $wp_query; - - if ('atbdp_orders' == $typenow) { - - // Restrict by payment status - $statuses = atbdp_get_payment_statuses(); - /* - * @todo; remove all helper comments once work is done.. - * $statuses = array( - 'created' => __( "Created", 'directorist' ), - 'pending' => __( "Pending", 'directorist' ), - 'completed' => __( "Completed", 'directorist' ), - 'failed' => __( "Failed", 'directorist' ), - 'cancelled' => __( "Cancelled", 'directorist' ), - 'refunded' => __( "Refunded", 'directorist' ) - ); - */ - $current_status = isset($_GET['payment_status']) ? sanitize_text_field( wp_unslash( $_GET['payment_status'] ) ) : ''; - - echo '<select name="payment_status">'; - echo '<option value="all">' . esc_html__("All orders", 'directorist') . '</option>'; - foreach ($statuses as $value => $title) { - printf('<option value="%s" %s>%s</option>', esc_attr( $value ), selected($value, $current_status), esc_html( $title ) ); - } - echo '</select>'; - - - } - - } - - /** - * Parse a query string and enable filter by post meta "payment_status" - * - * @since 3.1.0 - * @access public - * - * @param WP_Query $query WordPress Query object - */ - public function parse_query($query) - { - global $pagenow, $post_type; - $st = isset($_GET['payment_status']) ? sanitize_text_field( wp_unslash( $_GET['payment_status'] ) ) : ''; - if ('edit.php' == $pagenow && 'atbdp_orders' == $post_type && !empty($st)) { - // Filter by post meta "payment_status" - if ('' != $st && 'all' != $st) { - $query->query_vars['meta_key'] = '_payment_status'; - $query->query_vars['meta_value'] = sanitize_key($st); - } - - } - - } - - /** - * Retrieve the table columns. - * - * @since 3.1.0 - * @access public - * @param array $columns - * - * @return array $columns Array of all the list table columns. - */ - public function add_new_order_columns($columns) - { - - $columns = array( - 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text - 'ID' => __('Order ID', 'directorist'), - 'details' => __('Details', 'directorist'), - 'amount' => __('Amount', 'directorist'), - 'type' => __('Payment Type', 'directorist'), - 'transaction_id' => __('Transaction ID', 'directorist'), - 'customer' => __('Customer', 'directorist'), - 'date' => __('Date', 'directorist'), - 'status' => __('Order Status', 'directorist'), - ); - - return $columns = apply_filters('atbdp_add_new_order_column', $columns); - - } - - /** - * This function renders the custom columns in the list table. - * - * @since 3.1.0 - * @access public - * - * @param string $column The name of the column. - * @param string $post_id Post ID. - */ - public function manage_order_columns($column, $post_id) - { - - global $post; - $listing_id = get_post_meta($post_id, '_listing_id', true); - switch ($column) { - case 'ID' : - ?> - <a href="<?php echo esc_url( ATBDP_Permalink::get_payment_receipt_page_link($post_id) ); ?>"><?php echo esc_html__( 'Order #', 'directorist' ) . esc_html( $post_id ); ?></a> - <?php - break; - case 'details' : - $listing_id = get_post_meta($post_id, '_listing_id', true); - ?> - <p> - <a href="<?php echo esc_url( get_edit_post_link( $listing_id ) ); ?>"><?php echo esc_html( get_the_title( $listing_id ) ) ; ?></a> - </p> - <?php - $order_details = apply_filters( 'atbdp_order_details', array(), $post_id, $listing_id ); - foreach ( array( $order_details ) as $order_detail ) { - $title = !empty($order_detail['label']) ? $order_detail['label'] : ""; - ?> - <div> - <?php echo esc_html__( '#Order for: ', 'directorist' ) . esc_html( $title ); - $featured = apply_filters( 'atbdp_order_for', get_post_meta( $post_id, '_featured', true), $post_id ); // is this listing featured ? - if ($featured) { - $f_title = apply_filters( 'atbdp_order_for', get_directorist_option( 'featured_listing_title', __( 'Featured', 'directorist' ) ), $post_id ); - echo esc_html( $f_title ); - }else{ - echo esc_html_e( 'Others', 'directorist' ); - } - ?> - </div> - <?php - } - break; - case 'amount' : - $amount = get_post_meta($post_id, '_amount', true); - $value = atbdp_format_payment_amount($amount); // add a currency sign before the price - $before = ''; $after = ''; - $c_position = get_directorist_option('payment_currency_position'); - $currency = atbdp_get_payment_currency(); - $symbol = atbdp_currency_symbol($currency); - ('after' == $c_position) ? $after = $symbol : $before = $symbol; - echo esc_html( $before . $value . $after ); - break; - case 'type' : - $gateway = get_post_meta($post_id, '_payment_gateway', true); - if ('free' == $gateway) { - esc_html_e('Free Submission', 'directorist'); - } else { - $label = apply_filters('atbdp_' . $gateway . 'gateway_label', ''); - echo ! empty( $label ) ? esc_html( $label ) : esc_html( $gateway ); - } - break; - case 'transaction_id' : - echo esc_html( get_post_meta($post_id, '_transaction_id', true) ); - break; - case 'customer' : - $user_info = get_userdata($post->post_author); - - ?> - <p> - <a href="<?php echo esc_url( get_edit_user_link($user_info->ID) ); ?>"><?php echo esc_html( $user_info->display_name ); ?></a> - </p> - <?php - echo esc_html( $user_info->user_email ); - break; - case 'date' : - $date = strtotime($post->post_date); - $value = date_i18n(get_option('date_format'), $date); - - echo esc_attr( $value ); - break; - case 'status' : - $value = get_post_meta($post_id, '_payment_status', true); - echo esc_attr( atbdp_get_payment_status_i18n( $value ) ); - break; - - } - /* - * since 4.0 - * - */ - do_action('atbdp_custom_order_column_content', $column, $post_id, $listing_id); - - } - - /** - * Retrieve the table's sortable columns. - * - * @since 3.1.0 - * @access public - * - * @return array Array of all the sortable columns - */ - public function get_sortable_columns() - { - $columns = array( - 'ID' => 'ID', - 'amount' => 'amount', - 'type' => 'type', - 'customer' => 'customer', - 'date' => 'date', - 'status' => 'status', - ); - return $columns = apply_filters('atbdp_order_table_shortable_colums', $columns); - - } - - /** - * Called only in /wp-admin/edit.php* pages. - * - * @since 3.1.0 - * @access public - */ - public function load_edit() - { - - // Handle the custom bulk action - global $typenow; - $post_type = $typenow; - - if ('atbdp_orders' == $typenow) { - - // Get the action - $wp_list_table = _get_list_table('WP_Posts_List_Table'); - $action = $wp_list_table->current_action(); - - $allowed_actions = array_keys(atbdp_get_payment_bulk_actions()); - if (!in_array($action, $allowed_actions)) return; - - // Security check - check_admin_referer('bulk-posts'); - - // Make sure ids are submitted - if (isset($_REQUEST['post'])) { - $post_ids = array_map('intval', $_REQUEST['post']); - } - - if (empty($post_ids)) return; - - // This is based on wp-admin/edit.php - $sendback = remove_query_arg(array_merge($allowed_actions, array('untrashed', 'deleted', 'ids')), wp_get_referer()); - if (!$sendback) $sendback = admin_url("edit.php?post_type=$post_type"); - - $pagenum = $wp_list_table->get_pagenum(); - $sendback = add_query_arg('paged', $pagenum, $sendback); - - $modified = 0; - foreach ($post_ids as $post_id) { - if (!$this->update_payment_status($action, $post_id)) wp_die( esc_html__('Error updating post.', 'directorist')); - $modified++; - } - - $sendback = add_query_arg(array($action => $modified, 'ids' => join(',', $post_ids)), $sendback); - $sendback = remove_query_arg(array('action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback); - - } - - // Add filter to sort columns - add_filter('request', array($this, 'sort_columns')); - - } - - /** - * Update payment status. - * - * @since 3.1.0 - * @access public - * - * @param string $action Action to be performed. - * @param int $post_id Post ID. - * @return boolean If the save was successful or not. - */ - public function update_payment_status($action, $post_id) - { - $old_status = get_post_meta( $post_id, '_payment_status', true); - $listing_id = get_post_meta( $post_id, '_listing_id', true); - $directory_type = directorist_get_listing_directory( $listing_id ); - $new_l_status = get_term_meta( $directory_type, 'new_listing_status', true ); - $new_status = str_replace('set_to_', '', $action); - $new_status = sanitize_key($new_status); - if ($new_status == $old_status) return true; - do_action('atbdp_order_status_changed', $new_status, $old_status, $post_id); - $non_complete_statuses = array('created', 'pending', 'failed', 'cancelled', 'refunded'); - // If the order has featured - $featured = get_post_meta($post_id, '_featured', true); - if (!empty($featured)) { - if ('completed' == $old_status && in_array($new_status, $non_complete_statuses)) { - update_post_meta($listing_id, '_featured', 0); - } else if (in_array($old_status, $non_complete_statuses) && 'completed' == $new_status) { - update_post_meta($listing_id, '_featured', 1); - $my_post = array(); - $my_post['ID'] = $listing_id; - $my_post['post_status'] = $new_l_status; - if (!is_fee_manager_active()){ - wp_update_post( $my_post ); - $token_refresh = get_post_meta( $listing_id, '_refresh_renewal_token', true ); - if( $token_refresh ){ - update_post_meta( $listing_id, '_refresh_renewal_token', 0 ); - update_post_meta( $listing_id, '_renewal_token', 0 ); - } - } - } - } - // Update new status - update_post_meta($post_id, '_payment_status', $new_status); - // Email listing owner when his/her set to completed - if (in_array($old_status, $non_complete_statuses) && 'completed' == $new_status) { - ATBDP()->email->notify_owner_order_completed($post_id, $listing_id); - ATBDP()->email->notify_admin_order_completed($post_id, $listing_id); - } - return true; - } - - /** - * Display an admin notice on the payment history page after performing - * a bulk action. - * - * @since 3.1.0 - * @access public - */ - public function admin_notices() - { - - global $pagenow, $post_type; - - if ('edit.php' == $pagenow && 'atbdp_orders' == $post_type) { - - $message = ''; - $allowed_actions = array_keys(atbdp_get_payment_bulk_actions()); - - foreach ($allowed_actions as $action) { - $_action = str_replace('set_to_', '', $action); - if (isset($_REQUEST[$action]) && (int)$_REQUEST[$action]) { - $message = esc_html__( 'Order(s) set to ', 'directorist') . $_action ; - break; - } - } - - if( $message ) { ?> - <div class="updated"> - <p><?php echo esc_html( $message ); ?></p> - </div> - <?php } - } - - } - - /** - * Sort custom columns. - * - * @since 3.1.0 - * @access public - * - * @param array $vars Array of query variables. - * @return array - */ - public function sort_columns($vars) - { - // Check if we're viewing the 'atbdp_orders' post type - if (isset($vars['post_type']) && 'atbdp_orders' == $vars['post_type']) { - // Check if 'orderby' is set to 'amount' - if (isset($vars['orderby']) && 'amount' == $vars['orderby']) { - // Merge the query vars with our custom variables. - $vars = array_merge( - $vars, - array( - 'meta_key' => 'amount', - 'orderby' => 'meta_value_num' - ) - ); - } - } - return $vars; - } - - /** - * It sets the view link of the order to the payment receipt page on the front end where the shortcode of payment receipt has been used. - * - * @param array $actions The array of post actions - * @param WP_Post $post The current post post - * @return array $actions It returns the array of post actions after modifying the order view link - */ - public function set_payment_receipt_link($actions, WP_Post $post) - { - if ($post->post_type != 'atbdp_orders') return $actions; - $actions['view'] = sprintf("<a href='%s'>%s</a>", esc_url( ATBDP_Permalink::get_payment_receipt_page_link( $post->ID ) ), __('View', 'directorist')); - unset($actions['edit']); - unset($actions['inline hide-if-no-js']); - return $actions; - } - +class ATBDP_Order { + + + + public function __construct() { + add_action( 'init', array( $this, 'register_custom_post_type' ) ); + + add_action( 'admin_footer-edit.php', array( $this, 'admin_footer_edit' ) ); + add_action( 'restrict_manage_posts', array( $this, 'restrict_manage_posts' ) ); + add_action( 'load-edit.php', array( $this, 'load_edit' ) ); + add_action( 'admin_notices', array( $this, 'admin_notices' ) ); + + add_filter( 'parse_query', array( $this, 'parse_query' ) ); + add_filter( 'manage_atbdp_orders_posts_columns', array( $this, 'add_new_order_columns' ) ); + add_action( 'manage_atbdp_orders_posts_custom_column', array( $this, 'manage_order_columns' ), 10, 2 ); + + add_filter( 'manage_edit-atbdp_orders_sortable_columns', array( $this, 'get_sortable_columns' ) ); + + add_filter( 'post_row_actions', array( $this, 'set_payment_receipt_link' ), 10, 2 ); + } + + /** + * It returns order details in html format + * + * @param int $order_id The order ID + * @return string + */ + public static function get_order_details( $order_id ) { + if ( empty( $order_id ) ) { + return __( 'No Order ID Provided', 'directorist' ); + } + $c_position = get_directorist_option( 'payment_currency_position' ); + $currency = atbdp_get_payment_currency(); + $symbol = atbdp_currency_symbol( $currency ); + $order_items = apply_filters( 'atbdp_order_items_data', array(), $order_id ); // this is the hook that an extension can hook to, to add new items on checkout page.eg. plan + + $featured = get_post_meta( $order_id, '_featured', true ); + $listing_id = get_post_meta( $order_id, '_listing_id', true ); + if ( $featured ) { + $order_items[] = atbdp_get_featured_settings_array(); + } + + // fix currency symbol position + $before = ''; + $after = ''; + ( 'after' == $c_position ) ? $after = $symbol : $before = $symbol; + + ob_start(); + ?> + <table border="0" cellspacing="0" cellpadding="7" style="border:1px solid #CCC;"> + <tr style="background-color:#F0F0F0;"> + <th style="border-right:1px solid #CCC; border-bottom:1px solid #CCC; text-align:left;"><?php esc_html_e( 'Item(s)', 'directorist' ); ?></th> + <th style="border-bottom:1px solid #CCC;"><?php printf( esc_html__( 'Price [%s]', 'directorist' ), esc_html( $currency ) ); ?></th> + </tr> + <?php + if ( ! empty( $order_items ) ) { + foreach ( $order_items as $order ) : + ?> + <tr> + <td style="border-right:1px solid #CCC; border-bottom:1px solid #CCC;"> + <h3><?php echo ! empty( $order['label'] ) ? esc_html( $order['label'] ) : ''; ?></h3> + <?php echo ! empty( $order['desc'] ) ? esc_html( $order['desc'] ) : ''; ?> + </td> + <td style="border-bottom:1px solid #CCC;"> + <?php echo esc_html( $before . $order['price'] . $after ); ?> + </td> + </tr> + <?php + endforeach; + } + ?> + <tr> + <td style="border-right:1px solid #CCC; text-align:right; vertical-align:middle;"> + <?php printf( esc_html__( 'Total amount [%s]', 'directorist' ), esc_html( $currency ) ); ?> + </td> + <td> + <?php + $amount = get_post_meta( $order_id, '_amount', true ); + + /** + * Filter the order amount for email receipt. + * + * Allows developers to modify the order amount before it is used in email receipts. + * + * @since 7.8.0 + * + * @param float $amount The order amount. + * @param int $order_id The order ID. + * + * @return float The filtered order amount. + */ + $total_amount = apply_filters( 'directorist_email_receipt_order_amount', $amount, $order_id ); + + echo esc_html( $before . $total_amount . $after ); + do_action( 'atbdp_email_receipt_after_total_price', $listing_id ); + ?> + </td> + </tr> + </table> + <?php + return ob_get_clean(); + } + + /** + * Register a custom post type "atbdp_orders". + * + * @since 3.1.0 + * @access public + */ + public function register_custom_post_type() { + + $mitization_active = directorist_is_monetization_enabled(); + $labels = array( + 'name' => _x( 'Order History', 'Post Type General Name', 'directorist' ), + 'singular_name' => _x( 'Order', 'Post Type Singular Name', 'directorist' ), + 'menu_name' => __( 'Order History', 'directorist' ), + 'name_admin_bar' => __( 'Order', 'directorist' ), + 'all_items' => __( 'Order History', 'directorist' ), + 'add_new_item' => __( 'Add New Order', 'directorist' ), + 'add_new' => __( 'Add New', 'directorist' ), + 'new_item' => __( 'New Order', 'directorist' ), + 'edit_item' => __( 'Edit Order', 'directorist' ), + 'update_item' => __( 'Update Order', 'directorist' ), + 'view_item' => __( 'View Order', 'directorist' ), + 'search_items' => __( 'Search Order', 'directorist' ), + 'not_found' => __( 'No orders found', 'directorist' ), + 'not_found_in_trash' => __( 'No orders found in Trash', 'directorist' ), + ); + + $args = array( + 'labels' => $labels, + 'description' => __( 'This order post type will keep track of user\'s order and payment status', 'directorist' ), + 'supports' => array( 'title', 'author' ), + 'taxonomies' => array( '' ), + 'hierarchical' => false, + 'public' => true, + 'show_ui' => current_user_can( 'manage_atbdp_options' ) ? ( ! empty( $mitization_active ) ? true : false ) : false, // show the menu only to the admin + 'show_in_menu' => current_user_can( 'manage_atbdp_options' ) ? 'edit.php?post_type=' . ATBDP_POST_TYPE : false, + 'show_in_admin_bar' => true, + 'capabilities' => array( + 'create_posts' => false, + ), + 'show_in_nav_menus' => true, + 'can_export' => true, + 'has_archive' => true, + 'exclude_from_search' => true, + 'publicly_queryable' => true, + 'capability_type' => 'at_biz_dir', + 'map_meta_cap' => true, + ); + + register_post_type( 'atbdp_orders', $args ); + } + + /** + * Add/Remove custom bulk actions to the select menus. + * + * @todo; In future we may use add_action('bulk_actions-{screen_id}', 'my_bulk_action') when we will stop supporting WP < 4.7. + * @see http://wpengineer.com/2803/create-your-own-bulk-actions/ + * @since 3.1.0 + * @access public + */ + public function admin_footer_edit() { + + global $post_type; + if ( 'atbdp_orders' == $post_type ) { + + ?> + <script type="text/javascript"> + var atbdp_bulk_actions = <?php echo json_encode( atbdp_get_payment_bulk_actions() ); ?>; + /*$actions = array( + 'set_to_created' => __( "Set Status to Created", 'directorist' ), + 'set_to_pending' => __( "Set Status to Pending", 'directorist' ), + 'set_to_completed' => __( "Set Status to Completed", 'directorist' ), + 'set_to_failed' => __( "Set Status to Failed", 'directorist' ), + 'set_to_cancelled' => __( "Set Status to Cancelled", 'directorist' ), + 'set_to_refunded' => __( "Set Status to Refunded", 'directorist' ) + );*/ + jQuery(document).ready(function () { + for (var key in atbdp_bulk_actions) { + if (atbdp_bulk_actions.hasOwnProperty(key)) { + var $option = jQuery('<option>').val(key).text(atbdp_bulk_actions[key]); + $option.appendTo('#bulk-action-selector-top', '#bulk-action-selector-bottom'); + //$option.appendTo('#bulk-action-selector-bottom'); + } + } + + jQuery('select[name="action"]').find('option[value="edit"]').remove(); + jQuery('select[name="action2"]').find('option[value="edit"]').remove(); + }); + </script> + <?php + } + } + + /** + * Add custom filter options. + * + * @since 3.1.0 + * @access public + */ + public function restrict_manage_posts() { + + global $typenow, $wp_query; + + if ( 'atbdp_orders' == $typenow ) { + + // Restrict by payment status + $statuses = atbdp_get_payment_statuses(); + /* + * @todo; remove all helper comments once work is done.. + * $statuses = array( + 'created' => __( "Created", 'directorist' ), + 'pending' => __( "Pending", 'directorist' ), + 'completed' => __( "Completed", 'directorist' ), + 'failed' => __( "Failed", 'directorist' ), + 'cancelled' => __( "Cancelled", 'directorist' ), + 'refunded' => __( "Refunded", 'directorist' ) + ); + */ + $current_status = isset( $_GET['payment_status'] ) ? sanitize_text_field( wp_unslash( $_GET['payment_status'] ) ) : ''; + + echo '<select name="payment_status">'; + echo '<option value="all">' . esc_html__( 'All orders', 'directorist' ) . '</option>'; + foreach ( $statuses as $value => $title ) { + printf( '<option value="%s" %s>%s</option>', esc_attr( $value ), selected( $value, $current_status ), esc_html( $title ) ); + } + echo '</select>'; + + } + } + + /** + * Parse a query string and enable filter by post meta "payment_status" + * + * @since 3.1.0 + * @access public + * + * @param WP_Query $query WordPress Query object + */ + public function parse_query( $query ) { + global $pagenow, $post_type; + $st = isset( $_GET['payment_status'] ) ? sanitize_text_field( wp_unslash( $_GET['payment_status'] ) ) : ''; + if ( 'edit.php' == $pagenow && 'atbdp_orders' == $post_type && ! empty( $st ) ) { + // Filter by post meta "payment_status" + if ( '' != $st && 'all' != $st ) { + $query->query_vars['meta_key'] = '_payment_status'; + $query->query_vars['meta_value'] = sanitize_key( $st ); + } + } + } + + /** + * Retrieve the table columns. + * + * @since 3.1.0 + * @access public + * @param array $columns + * + * @return array $columns Array of all the list table columns. + */ + public function add_new_order_columns( $columns ) { + + $columns = array( + 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text + 'ID' => __( 'Order ID', 'directorist' ), + 'details' => __( 'Details', 'directorist' ), + 'amount' => __( 'Amount', 'directorist' ), + 'type' => __( 'Payment Type', 'directorist' ), + 'transaction_id' => __( 'Transaction ID', 'directorist' ), + 'customer' => __( 'Customer', 'directorist' ), + 'date' => __( 'Date', 'directorist' ), + 'status' => __( 'Order Status', 'directorist' ), + ); + + return $columns = apply_filters( 'atbdp_add_new_order_column', $columns ); + } + + /** + * This function renders the custom columns in the list table. + * + * @since 3.1.0 + * @access public + * + * @param string $column The name of the column. + * @param string $post_id Post ID. + */ + public function manage_order_columns( $column, $post_id ) { + + global $post; + $listing_id = get_post_meta( $post_id, '_listing_id', true ); + switch ( $column ) { + case 'ID': + ?> + <a href="<?php echo esc_url( ATBDP_Permalink::get_payment_receipt_page_link( $post_id ) ); ?>"><?php echo esc_html__( 'Order #', 'directorist' ) . esc_html( $post_id ); ?></a> + <?php + break; + case 'details': + $listing_id = get_post_meta( $post_id, '_listing_id', true ); + ?> + <p> + <a href="<?php echo esc_url( get_edit_post_link( $listing_id ) ); ?>"><?php echo esc_html( get_the_title( $listing_id ) ); ?></a> + </p> + <?php + $order_details = apply_filters( 'atbdp_order_details', array(), $post_id, $listing_id ); + foreach ( array( $order_details ) as $order_detail ) { + $title = ! empty( $order_detail['label'] ) ? $order_detail['label'] : ''; + ?> + <div> + <?php + echo esc_html__( '#Order for: ', 'directorist' ) . esc_html( $title ); + $featured = apply_filters( 'atbdp_order_for', get_post_meta( $post_id, '_featured', true ), $post_id ); // is this listing featured ? + if ( $featured ) { + $f_title = apply_filters( 'atbdp_order_for', get_directorist_option( 'featured_listing_title', __( 'Featured', 'directorist' ) ), $post_id ); + echo esc_html( $f_title ); + } else { + echo esc_html_e( 'Others', 'directorist' ); + } + ?> + </div> + <?php + } + break; + case 'amount': + $amount = get_post_meta( $post_id, '_amount', true ); + $value = atbdp_format_payment_amount( $amount ); // add a currency sign before the price + $before = ''; + $after = ''; + $c_position = get_directorist_option( 'payment_currency_position' ); + $currency = atbdp_get_payment_currency(); + $symbol = atbdp_currency_symbol( $currency ); + ( 'after' == $c_position ) ? $after = $symbol : $before = $symbol; + echo esc_html( $before . $value . $after ); + break; + case 'type': + $gateway = get_post_meta( $post_id, '_payment_gateway', true ); + if ( 'free' == $gateway ) { + esc_html_e( 'Free Submission', 'directorist' ); + } else { + $label = apply_filters( 'atbdp_' . $gateway . 'gateway_label', '' ); + echo ! empty( $label ) ? esc_html( $label ) : esc_html( $gateway ); + } + break; + case 'transaction_id': + echo esc_html( get_post_meta( $post_id, '_transaction_id', true ) ); + break; + case 'customer': + $user_info = get_userdata( $post->post_author ); + + ?> + <p> + <a href="<?php echo esc_url( get_edit_user_link( $user_info->ID ) ); ?>"><?php echo esc_html( $user_info->display_name ); ?></a> + </p> + <?php + echo esc_html( $user_info->user_email ); + break; + case 'date': + $date = strtotime( $post->post_date ); + $value = date_i18n( get_option( 'date_format' ), $date ); + + echo esc_attr( $value ); + break; + case 'status': + $value = get_post_meta( $post_id, '_payment_status', true ); + echo esc_attr( atbdp_get_payment_status_i18n( $value ) ); + break; + + } + /* + * since 4.0 + * + */ + do_action( 'atbdp_custom_order_column_content', $column, $post_id, $listing_id ); + } + + /** + * Retrieve the table's sortable columns. + * + * @since 3.1.0 + * @access public + * + * @return array Array of all the sortable columns + */ + public function get_sortable_columns() { + $columns = array( + 'ID' => 'ID', + 'amount' => 'amount', + 'type' => 'type', + 'customer' => 'customer', + 'date' => 'date', + 'status' => 'status', + ); + return $columns = apply_filters( 'atbdp_order_table_shortable_colums', $columns ); + } + + /** + * Called only in /wp-admin/edit.php* pages. + * + * @since 3.1.0 + * @access public + */ + public function load_edit() { + + // Handle the custom bulk action + global $typenow; + $post_type = $typenow; + + if ( 'atbdp_orders' == $typenow ) { + + // Get the action + $wp_list_table = _get_list_table( 'WP_Posts_List_Table' ); + $action = $wp_list_table->current_action(); + + $allowed_actions = array_keys( atbdp_get_payment_bulk_actions() ); + if ( ! in_array( $action, $allowed_actions ) ) { + return; + } + + // Security check + check_admin_referer( 'bulk-posts' ); + + // Make sure ids are submitted + if ( isset( $_REQUEST['post'] ) ) { + $post_ids = array_map( 'intval', $_REQUEST['post'] ); + } + + if ( empty( $post_ids ) ) { + return; + } + + // This is based on wp-admin/edit.php + $sendback = remove_query_arg( array_merge( $allowed_actions, array( 'untrashed', 'deleted', 'ids' ) ), wp_get_referer() ); + if ( ! $sendback ) { + $sendback = admin_url( "edit.php?post_type=$post_type" ); + } + + $pagenum = $wp_list_table->get_pagenum(); + $sendback = add_query_arg( 'paged', $pagenum, $sendback ); + + $modified = 0; + foreach ( $post_ids as $post_id ) { + if ( ! $this->update_payment_status( $action, $post_id ) ) { + wp_die( esc_html__( 'Error updating post.', 'directorist' ) ); + } + ++$modified; + } + + $sendback = add_query_arg( + array( + $action => $modified, + 'ids' => join( ',', $post_ids ), + ), + $sendback + ); + $sendback = remove_query_arg( array( 'action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ), $sendback ); + + } + + // Add filter to sort columns + add_filter( 'request', array( $this, 'sort_columns' ) ); + } + + /** + * Update payment status. + * + * @since 3.1.0 + * @access public + * + * @param string $action Action to be performed. + * @param int $post_id Post ID. + * @return boolean If the save was successful or not. + */ + public function update_payment_status( $action, $post_id ) { + $old_status = get_post_meta( $post_id, '_payment_status', true ); + $listing_id = get_post_meta( $post_id, '_listing_id', true ); + $directory_type = directorist_get_listing_directory( $listing_id ); + $new_l_status = get_term_meta( $directory_type, 'new_listing_status', true ); + $new_status = str_replace( 'set_to_', '', $action ); + $new_status = sanitize_key( $new_status ); + if ( $new_status == $old_status ) { + return true; + } + do_action( 'atbdp_order_status_changed', $new_status, $old_status, $post_id ); + $non_complete_statuses = array( 'created', 'pending', 'failed', 'cancelled', 'refunded' ); + // If the order has featured + $featured = get_post_meta( $post_id, '_featured', true ); + if ( ! empty( $featured ) ) { + if ( 'completed' == $old_status && in_array( $new_status, $non_complete_statuses ) ) { + update_post_meta( $listing_id, '_featured', 0 ); + } elseif ( in_array( $old_status, $non_complete_statuses ) && 'completed' == $new_status ) { + update_post_meta( $listing_id, '_featured', 1 ); + $my_post = array(); + $my_post['ID'] = $listing_id; + $my_post['post_status'] = $new_l_status; + if ( ! is_fee_manager_active() ) { + wp_update_post( $my_post ); + $token_refresh = get_post_meta( $listing_id, '_refresh_renewal_token', true ); + if ( $token_refresh ) { + update_post_meta( $listing_id, '_refresh_renewal_token', 0 ); + update_post_meta( $listing_id, '_renewal_token', 0 ); + } + } + } + } + // Update new status + update_post_meta( $post_id, '_payment_status', $new_status ); + // Email listing owner when his/her set to completed + if ( in_array( $old_status, $non_complete_statuses ) && 'completed' == $new_status ) { + ATBDP()->email->notify_owner_order_completed( $post_id, $listing_id ); + ATBDP()->email->notify_admin_order_completed( $post_id, $listing_id ); + } + return true; + } + + /** + * Display an admin notice on the payment history page after performing + * a bulk action. + * + * @since 3.1.0 + * @access public + */ + public function admin_notices() { + + global $pagenow, $post_type; + + if ( 'edit.php' == $pagenow && 'atbdp_orders' == $post_type ) { + + $message = ''; + $allowed_actions = array_keys( atbdp_get_payment_bulk_actions() ); + + foreach ( $allowed_actions as $action ) { + $_action = str_replace( 'set_to_', '', $action ); + if ( isset( $_REQUEST[ $action ] ) && (int) $_REQUEST[ $action ] ) { + $message = esc_html__( 'Order(s) set to ', 'directorist' ) . $_action; + break; + } + } + + if ( $message ) { + ?> + <div class="updated"> + <p><?php echo esc_html( $message ); ?></p> + </div> + <?php + } + } + } + + /** + * Sort custom columns. + * + * @since 3.1.0 + * @access public + * + * @param array $vars Array of query variables. + * @return array + */ + public function sort_columns( $vars ) { + // Check if we're viewing the 'atbdp_orders' post type + if ( isset( $vars['post_type'] ) && 'atbdp_orders' == $vars['post_type'] ) { + // Check if 'orderby' is set to 'amount' + if ( isset( $vars['orderby'] ) && 'amount' == $vars['orderby'] ) { + // Merge the query vars with our custom variables. + $vars = array_merge( + $vars, + array( + 'meta_key' => 'amount', + 'orderby' => 'meta_value_num', + ) + ); + } + } + return $vars; + } + + /** + * It sets the view link of the order to the payment receipt page on the front end where the shortcode of payment receipt has been used. + * + * @param array $actions The array of post actions + * @param WP_Post $post The current post post + * @return array $actions It returns the array of post actions after modifying the order view link + */ + public function set_payment_receipt_link( $actions, WP_Post $post ) { + if ( $post->post_type != 'atbdp_orders' ) { + return $actions; + } + $actions['view'] = sprintf( "<a href='%s'>%s</a>", esc_url( ATBDP_Permalink::get_payment_receipt_page_link( $post->ID ) ), __( 'View', 'directorist' ) ); + unset( $actions['edit'] ); + unset( $actions['inline hide-if-no-js'] ); + return $actions; + } } \ No newline at end of file diff --git a/includes/payments/functions.php b/includes/payments/functions.php index 6ac8b6e0dd..ac4b72c8f6 100644 --- a/includes/payments/functions.php +++ b/includes/payments/functions.php @@ -18,23 +18,19 @@ * @param string $status * @return string */ -function atbdp_get_payment_status($status = '') -{ - return $status; +function atbdp_get_payment_status( $status = '' ) { + return $status; } /** * @param $payment_id * @param $status */ -function atbdp_update_payment_status($payment_id, $status) -{ - +function atbdp_update_payment_status( $payment_id, $status ) { } -function atbdp_purchase_form_required_fields() -{ - return array(); +function atbdp_purchase_form_required_fields() { + return array(); } /** @@ -44,20 +40,18 @@ function atbdp_purchase_form_required_fields() * * @return array $statuses A list of available payment status. */ -function atbdp_get_payment_statuses() -{ - - $statuses = array( - 'created' => __("Created", 'directorist'), - 'pending' => __("Pending", 'directorist'), - 'completed' => __("Completed", 'directorist'), - 'failed' => __("Failed", 'directorist'), - 'cancelled' => __("Cancelled", 'directorist'), - 'refunded' => __("Refunded", 'directorist'), - ); - - return apply_filters('atbdp_payment_statuses', $statuses); - +function atbdp_get_payment_statuses() { + + $statuses = array( + 'created' => __( 'Created', 'directorist' ), + 'pending' => __( 'Pending', 'directorist' ), + 'completed' => __( 'Completed', 'directorist' ), + 'failed' => __( 'Failed', 'directorist' ), + 'cancelled' => __( 'Cancelled', 'directorist' ), + 'refunded' => __( 'Refunded', 'directorist' ), + ); + + return apply_filters( 'atbdp_payment_statuses', $statuses ); } /** @@ -67,20 +61,18 @@ function atbdp_get_payment_statuses() * * @return array $actions An array of bulk list of order history status. */ -function atbdp_get_payment_bulk_actions() -{ - - $actions = array( - 'set_to_created' => __("Set Status to Created", 'directorist'), - 'set_to_pending' => __("Set Status to Pending", 'directorist'), - 'set_to_completed' => __("Set Status to Completed", 'directorist'), - 'set_to_failed' => __("Set Status to Failed", 'directorist'), - 'set_to_cancelled' => __("Set Status to Cancelled", 'directorist'), - 'set_to_refunded' => __("Set Status to Refunded", 'directorist'), - ); - - return apply_filters('atbdp_order_bulk_actions', $actions); - +function atbdp_get_payment_bulk_actions() { + + $actions = array( + 'set_to_created' => __( 'Set Status to Created', 'directorist' ), + 'set_to_pending' => __( 'Set Status to Pending', 'directorist' ), + 'set_to_completed' => __( 'Set Status to Completed', 'directorist' ), + 'set_to_failed' => __( 'Set Status to Failed', 'directorist' ), + 'set_to_cancelled' => __( 'Set Status to Cancelled', 'directorist' ), + 'set_to_refunded' => __( 'Set Status to Refunded', 'directorist' ), + ); + + return apply_filters( 'atbdp_order_bulk_actions', $actions ); } @@ -90,19 +82,18 @@ function atbdp_get_payment_bulk_actions() * @since 3.1.0 * * @param string $amount Price amount to format - * @param bool $decimals Whether to use decimals or not. Useful when set to false for non-currency numbers. - * @param array $currency_settings Currency Settings. If we do not provide currency settings - * then it uses the general currency settings used to display formatted pricing - * on the front end. However, we can provide new currency settings array - * with 4 items currency name, thousand and decimal separators and - * the position of the currency symbol. + * @param bool $decimals Whether to use decimals or not. Useful when set to false for non-currency numbers. + * @param array $currency_settings Currency Settings. If we do not provide currency settings + * then it uses the general currency settings used to display formatted pricing + * on the front end. However, we can provide new currency settings array + * with 4 items currency name, thousand and decimal separators and + * the position of the currency symbol. * * @return string $amount Newly formatted amount or Price Not Available */ function atbdp_format_amount( $amount, $decimals = true, $currency_settings = array() ) { - return apply_filters( 'atbdp_format_amount', number_format_i18n( ( float ) $amount, 2 ), $amount, $decimals, $currency_settings ); - + return apply_filters( 'atbdp_format_amount', number_format_i18n( (float) $amount, 2 ), $amount, $decimals, $currency_settings ); } /** @@ -111,15 +102,12 @@ function atbdp_format_amount( $amount, $decimals = true, $currency_settings = ar * @since 3.1.0 * * @param string $amount Price amount to format - * @param bool $decimals Whether or not to use decimals. Useful when set to false for non-currency numbers. + * @param bool $decimals Whether or not to use decimals. Useful when set to false for non-currency numbers. * @return string Newly formatted amount or Price Not Available */ - -function atbdp_format_payment_amount($amount, $decimals = true) -{ - $decimals = get_directorist_option('allow_decimal', 1); - return atbdp_format_amount($amount, $decimals, atbdp_get_payment_currency_settings()); - +function atbdp_format_payment_amount( $amount, $decimals = true ) { + $decimals = get_directorist_option( 'allow_decimal', 1 ); + return atbdp_format_amount( $amount, $decimals, atbdp_get_payment_currency_settings() ); } @@ -129,20 +117,18 @@ function atbdp_format_payment_amount($amount, $decimals = true) * @since 3.1.0 * @return array $currency_settings Currency settings array that contains currency name, thousand and decimal separators */ -function atbdp_get_payment_currency_settings() -{ +function atbdp_get_payment_currency_settings() { - // Get the payment currency settings, and use the general currency settings if the payment currency setting is empty. - $currency_settings = array( - 'currency' => get_directorist_option('payment_currency', directorist_get_currency() ), - 'thousands_separator' => get_directorist_option('payment_thousand_separator', get_directorist_option('g_thousand_separator', ',')), - 'decimal_separator' => get_directorist_option('payment_decimal_separator', get_directorist_option('g_decimal_separator', '.')), - 'position' => get_directorist_option('payment_currency_position', directorist_get_currency_position() ), + // Get the payment currency settings, and use the general currency settings if the payment currency setting is empty. + $currency_settings = array( + 'currency' => get_directorist_option( 'payment_currency', directorist_get_currency() ), + 'thousands_separator' => get_directorist_option( 'payment_thousand_separator', get_directorist_option( 'g_thousand_separator', ',' ) ), + 'decimal_separator' => get_directorist_option( 'payment_decimal_separator', get_directorist_option( 'g_decimal_separator', '.' ) ), + 'position' => get_directorist_option( 'payment_currency_position', directorist_get_currency_position() ), - ); - - return apply_filters('atbdp_payment_currency_settings', $currency_settings); // return the currency settings array + ); + return apply_filters( 'atbdp_payment_currency_settings', $currency_settings ); // return the currency settings array } @@ -152,25 +138,23 @@ function atbdp_get_payment_currency_settings() * @see https://developer.paypal.com/docs/classic/mass-pay/integration-guide/currency_codes/ * @since 3.1.0 * - * @param int $decimals Number of decimal places. + * @param int $decimals Number of decimal places. * @param string $currency Payment currency. * @return int It returns the number of decimal place */ -function atbdp_currency_decimal_count($decimals = 2, $currency = 'USD') -{ - /*Remove Decimal from the following currency as they do not support decimal*/ - switch ($currency) { - case 'RIAL' : - case 'SAR' : - case 'JPY' : - case 'TWD' : - case 'HUF' : - $decimals = 0; - break; - } - - return apply_filters('atbdp_currency_decimal_count', $decimals, $currency); - +function atbdp_currency_decimal_count( $decimals = 2, $currency = 'USD' ) { + /*Remove Decimal from the following currency as they do not support decimal*/ + switch ( $currency ) { + case 'RIAL': + case 'SAR': + case 'JPY': + case 'TWD': + case 'HUF': + $decimals = 0; + break; + } + + return apply_filters( 'atbdp_currency_decimal_count', $decimals, $currency ); } @@ -182,11 +166,9 @@ function atbdp_currency_decimal_count($decimals = 2, $currency = 'USD') * @param string|int|float $price Paid Amount. * @return string Formatted amount with currency. */ -function atbdp_payment_currency_filter($price = '') -{ - - return atbdp_currency_filter($price, atbdp_get_payment_currency_settings()); +function atbdp_payment_currency_filter( $price = '' ) { + return atbdp_currency_filter( $price, atbdp_get_payment_currency_settings() ); } @@ -196,78 +178,76 @@ function atbdp_payment_currency_filter($price = '') * @since 3.1.0 * * @param string|int|float $price Paid Amount. - * @param array $currency_settings Currency Settings. + * @param array $currency_settings Currency Settings. * @return string $formatted Formatted amount with currency. */ -function atbdp_currency_filter($price = '', $currency_settings = array()) -{ +function atbdp_currency_filter( $price = '', $currency_settings = array() ) { !is_array($currency_settings) || extract($currency_settings); // @codingStandardsIgnoreLine. if it is an array then extract it. Using the magic of OR CONDITION's FLOW - $currency = !empty($currency) ? $currency : directorist_get_currency(); - $position = !empty($position) ? $position : directorist_get_currency_position(); - - $negative = $price < 0; - - if ($negative) { - $price = substr($price, 1); // Remove proceeding "-" - - } - - $symbol = atbdp_currency_symbol($currency); - - if ($position == 'before') { - - switch ($currency) { - case "GBP" : - case "BRL" : - case "EUR" : - case "USD" : - case "AUD" : - case "CAD" : - case "HKD" : - case "MXN" : - case "NZD" : - case "SGD" : - case "JPY" : - $formatted = $symbol . $price; - break; - default : - $formatted = $currency . ' ' . $price; - break; - } - - $formatted = apply_filters('atbdp_' . strtolower($currency) . '_currency_filter_before', $formatted, $currency, $price); - - } else { - - switch ($currency) { - case "GBP" : - case "BRL" : - case "EUR" : - case "USD" : - case "AUD" : - case "CAD" : - case "HKD" : - case "MXN" : - case "SGD" : - case "JPY" : - $formatted = $price . $symbol; - break; - default : - $formatted = $price . ' ' . $currency; - break; - } - - $formatted = apply_filters('atbdp_' . strtolower($currency) . '_currency_filter_after', $formatted, $currency, $price); - - } - - if ($negative) { - // Prepend the mins sign before the currency sign - $formatted = '-' . $formatted; - } - - return $formatted; - + $currency = ! empty( $currency ) ? $currency : directorist_get_currency(); + $position = ! empty( $position ) ? $position : directorist_get_currency_position(); + + $negative = $price < 0; + + if ( $negative ) { + $price = substr( $price, 1 ); // Remove proceeding "-" - + } + + $symbol = atbdp_currency_symbol( $currency ); + + if ( $position == 'before' ) { + + switch ( $currency ) { + case 'GBP': + case 'BRL': + case 'EUR': + case 'USD': + case 'AUD': + case 'CAD': + case 'HKD': + case 'MXN': + case 'NZD': + case 'SGD': + case 'JPY': + $formatted = $symbol . $price; + break; + default: + $formatted = $currency . ' ' . $price; + break; + } + + $formatted = apply_filters( 'atbdp_' . strtolower( $currency ) . '_currency_filter_before', $formatted, $currency, $price ); + + } else { + + switch ( $currency ) { + case 'GBP': + case 'BRL': + case 'EUR': + case 'USD': + case 'AUD': + case 'CAD': + case 'HKD': + case 'MXN': + case 'SGD': + case 'JPY': + $formatted = $price . $symbol; + break; + default: + $formatted = $price . ' ' . $currency; + break; + } + + $formatted = apply_filters( 'atbdp_' . strtolower( $currency ) . '_currency_filter_after', $formatted, $currency, $price ); + + } + + if ( $negative ) { + // Prepend the mins sign before the currency sign + $formatted = '-' . $formatted; + } + + return $formatted; } /** @@ -279,433 +259,431 @@ function atbdp_currency_filter($price = '', $currency_settings = array()) * @param string $currency The currency string. * @return string The symbol to use for the currency. */ -function atbdp_currency_symbol($currency = '') -{ - - switch ($currency) { - case "GBP" : - case "POUND" : - case "pound" : - $symbol = '£'; - break; - case "BRL" : - $symbol = 'R$'; - break; - case "EUR" : - $symbol = '€'; - break; - case "JPY" : - $symbol = '¥'; - break; - case "RUPEE" : - case "INR" : - $symbol = '₹'; - break; - case "PHP" : - $symbol = '₱'; // Mexican and Philippine Peso Sign - break; - case "BDT" : - $symbol = '৳'; - break; - case "ALL" : - $symbol = 'Lek'; - break; - case "AFN" : - $symbol = '؋'; - break; - case "USD" : - case "AUD" : - case "NZD" : - case "CAD" : - case "ARP" : - case "HKD" : - case "SGD" : - case "ARS" : - case "BSD" : - case "BBD" : - case "BMD" : - case "BND" : - case "KYD" : - case "CLP" : - case "COP" : - case "XCD" : - case "SVC" : - case "FJD" : - case "GYD" : - case "LRD" : - case "MXN" : - case "NAD" : - case "SBD" : - case "SRD" : - case "TVD" : - case "CUC" : - case "CVE" : - $symbol = '$'; - break; - case "AWG" : - $symbol = 'ƒ'; - break; - case "AZN" : - $symbol = 'ман'; - break; - case "BYN" : - $symbol = 'Br'; - break; - case "BZD" : - $symbol = 'BZ$'; - break; - case "BOB" : - $symbol = 'Bs.'; - break; - case "BAM" : - $symbol = 'KM'; - break; - case "BWP" : - $symbol = 'P'; - break; - case "BGN" : - $symbol = 'лв'; - break; - case "KHR" : - $symbol = '៛'; - break; - case "CNY" : - $symbol = '¥'; - break; - case "CRC" : - $symbol = '₡'; - break; - case "HRK" : - $symbol = 'kn'; - break; - case "CUP" : - $symbol = '₱'; - break; - case "CZK" : - $symbol = 'Kč'; - break; - case "DKK" : - $symbol = 'kr'; - break; - case "DOP" : - $symbol = 'RD$'; - break; - case "FKP" : - case "GIP" : - case "GGP" : - case "IMP" : - case "JEP" : - case "SHP" : - case "SSP" : - $symbol = '£'; - break; - case "EGP" : - $symbol = 'E£'; - break; - case "GHS" : - $symbol = '₵'; - break; - case "GTQ" : - $symbol = 'Q'; - break; - case "HNL" : - $symbol = 'L'; - break; - case "HUF" : - $symbol = 'Ft'; - break; - case "ISK" : - $symbol = 'kr'; - break; - case "IDR" : - $symbol = 'Rp'; - break; - case "IRR" : - case "SAR" : - case "YER" : - $symbol = '﷼'; - break; - case "ILS" : - $symbol = '₪'; - break; - case "JMD" : - $symbol = 'J$'; - break; - case "KZT" : - $symbol = '₸'; - break; - case "KPW" : - case "KRW" : - $symbol = '₩'; - break; - case "KGS" : - $symbol = 'лв'; - break; - case "LAK" : - $symbol = '₭'; - break; - case "MKD" : - $symbol = 'ден'; - break; - case "MYR" : - $symbol = 'RM'; - break; - case "MNT" : - $symbol = '₮'; - break; - case "MZN" : - $symbol = 'MT'; - break; - case "NPR" : - case "PKR" : - case "SCR" : - case "LKR" : - case "MUR" : - $symbol = '₨'; - break; - case "ANG" : - $symbol = 'ƒ'; - break; - case "NIO" : - $symbol = 'C$'; - break; - case "NGN" : - $symbol = '₦'; - break; - case "NOK" : - $symbol = 'kr'; - break; - case "PAB" : - $symbol = 'B/.'; - break; - case "PYG" : - $symbol = '₲'; - break; - case "PEN" : - $symbol = 'S/.'; - break; - case "PLN" : - $symbol = 'zł'; - break; - case "RON" : - $symbol = 'lei'; - break; - case "RUB" : - $symbol = '₽'; - break; - case "RSD" : - $symbol = 'дин.'; - break; - case "SOS" : - $symbol = 'Sh'; - break; - case "ZAR" : - $symbol = 'R'; - break; - case "SEK" : - $symbol = 'kr'; - break; - case "CHF" : - $symbol = 'CHF'; - break; - case "TWD" : - $symbol = 'NT$'; - break; - case "THB" : - $symbol = '฿'; - break; - case "TTD" : - $symbol = 'TT$'; - break; - case "UAH" : - $symbol = '₴'; - break; - case "UYU" : - $symbol = '$U'; - break; - case "VEF" : - $symbol = 'Bs'; - break; - case "VND" : - $symbol = '₫'; - break; - case "ZWD" : - $symbol = 'Z$'; - break; - case "UZS" : - $symbol = 'UZS'; - break; - case "TRY" : - $symbol = '₺'; - break; - case "AED" : - $symbol = 'د.إ'; - break; - case "AMD" : - $symbol = 'AMD'; - break; - case "AOA" : - $symbol = 'Kz'; - break; - case "BHD" : - $symbol = '.د.ب'; - break; - case "BIF" : - case "CDF" : - case "DJF" : - case "GNF" : - case "KMF" : - case "RWF" : - $symbol = 'Fr'; - break; - case "BTC" : - $symbol = '฿'; - break; - case "BTN" : - $symbol = 'Nu.'; - break; - case "BWP" : - $symbol = 'P'; - break; - case "BYR" : - case "ETB" : - $symbol = 'Br'; - break; - case "DZD" : - $symbol = 'د.ج'; - break; - case "ERN" : - $symbol = 'Nfk'; - break; - case "GEL" : - $symbol = '₾'; - break; - case "GMD" : - $symbol = 'D'; - break; - case "HTG" : - $symbol = 'G'; - break; - case "IQD" : - $symbol = 'ع.د'; - break; - case "IRT" : - $symbol = 'تومان'; - break; - case "JOD" : - $symbol = 'د.ا'; - break; - case "KES" : - $symbol = 'KSh'; - break; - case "KWD" : - $symbol = 'د.ك'; - break; - case "LBP" : - $symbol = 'ل.ل'; - break; - case "LSL" : - case "MDL" : - case "SZL" : - $symbol = 'L'; - break; - case "LYD" : - $symbol = 'ل.د'; - break; - case "MAD" : - $symbol = 'د.م.'; - break; - case "MGA" : - $symbol = 'Ar'; - break; - case "MMK" : - $symbol = 'K'; - break; - case "MOP" : - $symbol = 'MOP$'; - break; - case "MRU" : - $symbol = 'UM'; - break; - case "MVR" : - $symbol = '.ރ'; - break; - case "MWK" : - $symbol = 'MK'; - break; - case "OMR" : - $symbol = 'ر.ع.'; - break; - case "PGK" : - $symbol = 'K'; - break; - case "PRB" : - $symbol = 'р.'; - break; - case "QAR" : - $symbol = 'ر.ق'; - break; - case "RMB" : - $symbol = '¥'; - break; - case "SDG" : - $symbol = 'ج.س.'; - break; - case "SLL" : - $symbol = 'Le'; - break; - case "STN" : - $symbol = 'Db'; - break; - case "SYP" : - $symbol = 'ل.س'; - break; - case "TJS" : - $symbol = 'ЅМ'; - break; - case "TMT" : - $symbol = 'm'; - break; - case "TND" : - $symbol = 'د.ت'; - break; - case "TOP" : - $symbol = 'T$'; - break; - case "TZS" : - $symbol = 'TSh'; - break; - case "UGX" : - $symbol = 'USh'; - break; - case "VES" : - $symbol = 'Bs.S'; - break; - case "VUV" : - $symbol = 'VT'; - break; - case "WST" : - $symbol = 'T'; - break; - case "XAF" : - $symbol = 'FCFA'; - break; - case "XOF" : - $symbol = 'CFA'; - break; - case "XPF" : - $symbol = '₣'; - break; - case "ZMW" : - $symbol = 'ZK'; - break; - default : - $symbol = $currency; - break; - } - - return apply_filters('atbdp_currency_symbol', $symbol, $currency); - +function atbdp_currency_symbol( $currency = '' ) { + + switch ( $currency ) { + case 'GBP': + case 'POUND': + case 'pound': + $symbol = '£'; + break; + case 'BRL': + $symbol = 'R$'; + break; + case 'EUR': + $symbol = '€'; + break; + case 'JPY': + $symbol = '¥'; + break; + case 'RUPEE': + case 'INR': + $symbol = '₹'; + break; + case 'PHP': + $symbol = '₱'; // Mexican and Philippine Peso Sign + break; + case 'BDT': + $symbol = '৳'; + break; + case 'ALL': + $symbol = 'Lek'; + break; + case 'AFN': + $symbol = '؋'; + break; + case 'USD': + case 'AUD': + case 'NZD': + case 'CAD': + case 'ARP': + case 'HKD': + case 'SGD': + case 'ARS': + case 'BSD': + case 'BBD': + case 'BMD': + case 'BND': + case 'KYD': + case 'CLP': + case 'COP': + case 'XCD': + case 'SVC': + case 'FJD': + case 'GYD': + case 'LRD': + case 'MXN': + case 'NAD': + case 'SBD': + case 'SRD': + case 'TVD': + case 'CUC': + case 'CVE': + $symbol = '$'; + break; + case 'AWG': + $symbol = 'ƒ'; + break; + case 'AZN': + $symbol = 'ман'; + break; + case 'BYN': + $symbol = 'Br'; + break; + case 'BZD': + $symbol = 'BZ$'; + break; + case 'BOB': + $symbol = 'Bs.'; + break; + case 'BAM': + $symbol = 'KM'; + break; + case 'BWP': + $symbol = 'P'; + break; + case 'BGN': + $symbol = 'лв'; + break; + case 'KHR': + $symbol = '៛'; + break; + case 'CNY': + $symbol = '¥'; + break; + case 'CRC': + $symbol = '₡'; + break; + case 'HRK': + $symbol = 'kn'; + break; + case 'CUP': + $symbol = '₱'; + break; + case 'CZK': + $symbol = 'Kč'; + break; + case 'DKK': + $symbol = 'kr'; + break; + case 'DOP': + $symbol = 'RD$'; + break; + case 'FKP': + case 'GIP': + case 'GGP': + case 'IMP': + case 'JEP': + case 'SHP': + case 'SSP': + $symbol = '£'; + break; + case 'EGP': + $symbol = 'E£'; + break; + case 'GHS': + $symbol = '₵'; + break; + case 'GTQ': + $symbol = 'Q'; + break; + case 'HNL': + $symbol = 'L'; + break; + case 'HUF': + $symbol = 'Ft'; + break; + case 'ISK': + $symbol = 'kr'; + break; + case 'IDR': + $symbol = 'Rp'; + break; + case 'IRR': + case 'SAR': + case 'YER': + $symbol = '﷼'; + break; + case 'ILS': + $symbol = '₪'; + break; + case 'JMD': + $symbol = 'J$'; + break; + case 'KZT': + $symbol = '₸'; + break; + case 'KPW': + case 'KRW': + $symbol = '₩'; + break; + case 'KGS': + $symbol = 'лв'; + break; + case 'LAK': + $symbol = '₭'; + break; + case 'MKD': + $symbol = 'ден'; + break; + case 'MYR': + $symbol = 'RM'; + break; + case 'MNT': + $symbol = '₮'; + break; + case 'MZN': + $symbol = 'MT'; + break; + case 'NPR': + case 'PKR': + case 'SCR': + case 'LKR': + case 'MUR': + $symbol = '₨'; + break; + case 'ANG': + $symbol = 'ƒ'; + break; + case 'NIO': + $symbol = 'C$'; + break; + case 'NGN': + $symbol = '₦'; + break; + case 'NOK': + $symbol = 'kr'; + break; + case 'PAB': + $symbol = 'B/.'; + break; + case 'PYG': + $symbol = '₲'; + break; + case 'PEN': + $symbol = 'S/.'; + break; + case 'PLN': + $symbol = 'zł'; + break; + case 'RON': + $symbol = 'lei'; + break; + case 'RUB': + $symbol = '₽'; + break; + case 'RSD': + $symbol = 'дин.'; + break; + case 'SOS': + $symbol = 'Sh'; + break; + case 'ZAR': + $symbol = 'R'; + break; + case 'SEK': + $symbol = 'kr'; + break; + case 'CHF': + $symbol = 'CHF'; + break; + case 'TWD': + $symbol = 'NT$'; + break; + case 'THB': + $symbol = '฿'; + break; + case 'TTD': + $symbol = 'TT$'; + break; + case 'UAH': + $symbol = '₴'; + break; + case 'UYU': + $symbol = '$U'; + break; + case 'VEF': + $symbol = 'Bs'; + break; + case 'VND': + $symbol = '₫'; + break; + case 'ZWD': + $symbol = 'Z$'; + break; + case 'UZS': + $symbol = 'UZS'; + break; + case 'TRY': + $symbol = '₺'; + break; + case 'AED': + $symbol = 'د.إ'; + break; + case 'AMD': + $symbol = 'AMD'; + break; + case 'AOA': + $symbol = 'Kz'; + break; + case 'BHD': + $symbol = '.د.ب'; + break; + case 'BIF': + case 'CDF': + case 'DJF': + case 'GNF': + case 'KMF': + case 'RWF': + $symbol = 'Fr'; + break; + case 'BTC': + $symbol = '฿'; + break; + case 'BTN': + $symbol = 'Nu.'; + break; + case 'BWP': + $symbol = 'P'; + break; + case 'BYR': + case 'ETB': + $symbol = 'Br'; + break; + case 'DZD': + $symbol = 'د.ج'; + break; + case 'ERN': + $symbol = 'Nfk'; + break; + case 'GEL': + $symbol = '₾'; + break; + case 'GMD': + $symbol = 'D'; + break; + case 'HTG': + $symbol = 'G'; + break; + case 'IQD': + $symbol = 'ع.د'; + break; + case 'IRT': + $symbol = 'تومان'; + break; + case 'JOD': + $symbol = 'د.ا'; + break; + case 'KES': + $symbol = 'KSh'; + break; + case 'KWD': + $symbol = 'د.ك'; + break; + case 'LBP': + $symbol = 'ل.ل'; + break; + case 'LSL': + case 'MDL': + case 'SZL': + $symbol = 'L'; + break; + case 'LYD': + $symbol = 'ل.د'; + break; + case 'MAD': + $symbol = 'د.م.'; + break; + case 'MGA': + $symbol = 'Ar'; + break; + case 'MMK': + $symbol = 'K'; + break; + case 'MOP': + $symbol = 'MOP$'; + break; + case 'MRU': + $symbol = 'UM'; + break; + case 'MVR': + $symbol = '.ރ'; + break; + case 'MWK': + $symbol = 'MK'; + break; + case 'OMR': + $symbol = 'ر.ع.'; + break; + case 'PGK': + $symbol = 'K'; + break; + case 'PRB': + $symbol = 'р.'; + break; + case 'QAR': + $symbol = 'ر.ق'; + break; + case 'RMB': + $symbol = '¥'; + break; + case 'SDG': + $symbol = 'ج.س.'; + break; + case 'SLL': + $symbol = 'Le'; + break; + case 'STN': + $symbol = 'Db'; + break; + case 'SYP': + $symbol = 'ل.س'; + break; + case 'TJS': + $symbol = 'ЅМ'; + break; + case 'TMT': + $symbol = 'm'; + break; + case 'TND': + $symbol = 'د.ت'; + break; + case 'TOP': + $symbol = 'T$'; + break; + case 'TZS': + $symbol = 'TSh'; + break; + case 'UGX': + $symbol = 'USh'; + break; + case 'VES': + $symbol = 'Bs.S'; + break; + case 'VUV': + $symbol = 'VT'; + break; + case 'WST': + $symbol = 'T'; + break; + case 'XAF': + $symbol = 'FCFA'; + break; + case 'XOF': + $symbol = 'CFA'; + break; + case 'XPF': + $symbol = '₣'; + break; + case 'ZMW': + $symbol = 'ZK'; + break; + default: + $symbol = $currency; + break; + } + + return apply_filters( 'atbdp_currency_symbol', $symbol, $currency ); } @@ -717,12 +695,10 @@ function atbdp_currency_symbol($currency = '') * @param string $status Payment status. * @return string $status Localized payment status. */ -function atbdp_get_payment_status_i18n($status) -{ - - $statuses = atbdp_get_payment_statuses(); - return array_key_exists($status, $statuses) ? $statuses[$status] : esc_html__('Invalid', 'directorist'); +function atbdp_get_payment_status_i18n( $status ) { + $statuses = atbdp_get_payment_statuses(); + return array_key_exists( $status, $statuses ) ? $statuses[ $status ] : esc_html__( 'Invalid', 'directorist' ); } /** @@ -731,8 +707,7 @@ function atbdp_get_payment_status_i18n($status) * @since 3.1.0 * @return string The currency code. */ -function atbdp_get_payment_currency() -{ - $cs = atbdp_get_payment_currency_settings(); - return !empty($cs['currency']) ? strtoupper($cs['currency']) : 'USD'; +function atbdp_get_payment_currency() { + $cs = atbdp_get_payment_currency_settings(); + return ! empty( $cs['currency'] ) ? strtoupper( $cs['currency'] ) : 'USD'; } diff --git a/includes/rest-api/Version1/class-abstract-controller.php b/includes/rest-api/Version1/class-abstract-controller.php index 345f4964c2..de4753bb9b 100644 --- a/includes/rest-api/Version1/class-abstract-controller.php +++ b/includes/rest-api/Version1/class-abstract-controller.php @@ -494,7 +494,7 @@ public function get_public_batch_schema() { 'type' => 'array', 'context' => array( 'view', 'edit' ), 'items' => array( - 'type' => 'object', + 'type' => 'object', ), ), 'update' => array( @@ -502,7 +502,7 @@ public function get_public_batch_schema() { 'type' => 'array', 'context' => array( 'view', 'edit' ), 'items' => array( - 'type' => 'object', + 'type' => 'object', ), ), 'delete' => array( @@ -510,7 +510,7 @@ public function get_public_batch_schema() { 'type' => 'array', 'context' => array( 'view', 'edit' ), 'items' => array( - 'type' => 'integer', + 'type' => 'integer', ), ), ), @@ -581,7 +581,7 @@ public function get_fields_for_response( $request ) { // Return the list of all requested fields which appear in the schema. $this->_fields = array_reduce( $requested_fields, - function( $response_fields, $field ) use ( $fields ) { + function ( $response_fields, $field ) use ( $fields ) { if ( in_array( $field, $fields, true ) ) { $response_fields[] = $field; return $response_fields; diff --git a/includes/rest-api/Version1/class-abstract-posts-controller.php b/includes/rest-api/Version1/class-abstract-posts-controller.php index 8340a28b1a..e3278121eb 100644 --- a/includes/rest-api/Version1/class-abstract-posts-controller.php +++ b/includes/rest-api/Version1/class-abstract-posts-controller.php @@ -46,9 +46,8 @@ protected function get_allowed_query_vars() { * `add_filter( 'directorist_rest_private_query_vars', '__return_empty_array' );` * * @param array $private_query_vars Array of allowed query vars for authorized users. - * */ - $private = apply_filters( 'directorist_rest_private_query_vars', $wp->private_query_vars ); + $private = apply_filters( 'directorist_rest_private_query_vars', $wp->private_query_vars ); $valid_vars = array_merge( $valid_vars, $private ); } // Define our own in addition to WP's normal vars. diff --git a/includes/rest-api/Version1/class-abstract-terms-controller.php b/includes/rest-api/Version1/class-abstract-terms-controller.php index 75dfe8d318..0e884d2809 100644 --- a/includes/rest-api/Version1/class-abstract-terms-controller.php +++ b/includes/rest-api/Version1/class-abstract-terms-controller.php @@ -266,52 +266,53 @@ public function get_items( $request ) { if ( ! empty( $prepared_args['listing'] ) ) { $query_result = $this->get_terms_for_listing( $prepared_args, $request ); $total_terms = $this->total_terms; - } else { - if ( ! empty( $request['directory'] ) ) { + } elseif ( ! empty( $request['directory'] ) ) { $_prepared_args = $prepared_args; unset( $_prepared_args['number'] ); unset( $_prepared_args['offset'] ); $terms = get_terms( $taxonomy, $_prepared_args ); - $queried_directories = ( is_array( $request['directory'] ) ) ? $request['directory'] : [ $request['directory'] ]; + $queried_directories = ( is_array( $request['directory'] ) ) ? $request['directory'] : array( $request['directory'] ); - $terms = array_filter( $terms, function( $term ) use( $queried_directories ) { - $directories = get_term_meta( $term->term_id, '_directory_type', true ); + $terms = array_filter( + $terms, + function ( $term ) use ( $queried_directories ) { + $directories = get_term_meta( $term->term_id, '_directory_type', true ); - if ( empty( $directories ) || ! is_array( $directories ) ) { - return false; - } + if ( empty( $directories ) || ! is_array( $directories ) ) { + return false; + } - $exists = array_intersect( $queried_directories, $directories ); - return ( count( $exists ) > 0 ); - } ); + $exists = array_intersect( $queried_directories, $directories ); + return ( count( $exists ) > 0 ); + } + ); $offset = $prepared_args['offset'] ? $prepared_args['offset'] : 0; $query_result = array_slice( $terms, $offset, $prepared_args['number'] ); $total_terms = count( $terms ); - if ( $offset >= $total_terms ) { - $query_result = array(); - } - } else { - $query_result = get_terms( $taxonomy, $prepared_args ); - - $count_args = $prepared_args; - unset( $count_args['number'] ); - unset( $count_args['offset'] ); - $total_terms = wp_count_terms( $taxonomy, $count_args ); - - // Ensure we don't return results when offset is out of bounds. - // See https://core.trac.wordpress.org/ticket/35935. - if ( $prepared_args['offset'] && $prepared_args['offset'] >= $total_terms ) { - $query_result = array(); - } - - // wp_count_terms can return a falsy value when the term has no children. - if ( ! $total_terms ) { - $total_terms = 0; - } + if ( $offset >= $total_terms ) { + $query_result = array(); + } + } else { + $query_result = get_terms( $taxonomy, $prepared_args ); + + $count_args = $prepared_args; + unset( $count_args['number'] ); + unset( $count_args['offset'] ); + $total_terms = wp_count_terms( $taxonomy, $count_args ); + + // Ensure we don't return results when offset is out of bounds. + // See https://core.trac.wordpress.org/ticket/35935. + if ( $prepared_args['offset'] && $prepared_args['offset'] >= $total_terms ) { + $query_result = array(); + } + + // wp_count_terms can return a falsy value when the term has no children. + if ( ! $total_terms ) { + $total_terms = 0; } } @@ -386,10 +387,8 @@ public function prepare_query_args( $request ) { if ( 0 === $request['parent'] ) { // Only query top-level terms. $prepared_args['parent'] = 0; - } else { - if ( $request['parent'] ) { + } elseif ( $request['parent'] ) { $prepared_args['parent'] = $request['parent']; - } } } @@ -511,8 +510,8 @@ public function get_item( $request ) { * @return WP_REST_Request|WP_Error */ public function update_item( $request ) { - $taxonomy = $this->taxonomy; - $id = (int) $request['id']; + $taxonomy = $this->taxonomy; + $id = (int) $request['id']; do_action( 'directorist_rest_before_query', 'update_term_item', $request, $id, $taxonomy ); diff --git a/includes/rest-api/Version1/class-builder-controller.php b/includes/rest-api/Version1/class-builder-controller.php index 23896a4702..3b2544f668 100644 --- a/includes/rest-api/Version1/class-builder-controller.php +++ b/includes/rest-api/Version1/class-builder-controller.php @@ -153,13 +153,13 @@ public function get_item_schema() { 'title' => $this->taxonomy, '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' => __( 'Category name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -167,7 +167,7 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_text_field', ), ), - 'slug' => array( + 'slug' => array( 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -175,12 +175,12 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_title', ), ), - 'image_url' => array( + 'image_url' => array( 'description' => __( 'Preview image url.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'icon' => array( + 'icon' => array( 'description' => __( 'Icon class.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -188,19 +188,19 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_text_field', ), ), - 'count' => array( + 'count' => array( 'description' => __( 'Number of published listings for the resource.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'is_default' => array( + 'is_default' => array( 'description' => __( 'Default directory status.', 'directorist' ), 'type' => 'boolean', 'default' => false, 'context' => array( 'view', 'edit' ), ), - 'new_status' => array( + 'new_status' => array( 'description' => __( 'Newly created listing status under this directory.', 'directorist' ), 'type' => 'string', 'default' => 'pending', @@ -210,7 +210,7 @@ public function get_item_schema() { ), 'context' => array( 'view', 'edit' ), ), - 'edit_status' => array( + 'edit_status' => array( 'description' => __( 'Edited listing status under this directory.', 'directorist' ), 'type' => 'string', 'default' => 'pending', @@ -225,7 +225,7 @@ public function get_item_schema() { 'type' => 'integer', 'context' => array( 'view', 'edit' ), ), - 'date_created' => array( + 'date_created' => array( 'description' => __( "The date the directory was created, in the site's timezone.", 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), @@ -243,7 +243,6 @@ public function get_item_schema() { * @param WP_Term $term Term object. * @param WP_REST_Request $request Request instance. * @return bool|WP_Error - * */ protected function update_term_meta_fields( $term, $request ) { return true; diff --git a/includes/rest-api/Version1/class-categories-controller.php b/includes/rest-api/Version1/class-categories-controller.php index 4f7ce1d267..fa6e09fb05 100644 --- a/includes/rest-api/Version1/class-categories-controller.php +++ b/includes/rest-api/Version1/class-categories-controller.php @@ -197,7 +197,7 @@ public function get_item_schema() { ), ), ), - 'icon' => array( + 'icon' => array( 'description' => __( 'Icon class.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -205,18 +205,18 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_text_field', ), ), - 'directory' => array( + 'directory' => array( 'description' => __( 'Directory type ids for this resource.', 'directorist' ), 'type' => 'array', - 'items' => array( - 'type' => 'integer', + 'items' => array( + 'type' => 'integer', ), 'context' => array( 'view', 'edit' ), 'arg_options' => array( 'sanitize_callback' => 'wp_parse_id_list', ), ), - 'count' => array( + 'count' => array( 'description' => __( 'Number of published listings for the resource.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), @@ -256,12 +256,14 @@ protected function update_term_meta_fields( $term, $request ) { } $directory_ids = $request['directory']; - $directory = get_terms( array( - 'include' => $directory_ids, - 'taxonomy' => ATBDP_TYPE, - 'update_term_meta_cache' => false, - 'hide_empty' => false, - ) ); + $directory = get_terms( + array( + 'include' => $directory_ids, + 'taxonomy' => ATBDP_TYPE, + 'update_term_meta_cache' => false, + 'hide_empty' => false, + ) + ); if ( is_wp_error( $directory ) || empty( $directory ) ) { return new WP_Error( @@ -335,9 +337,9 @@ public function get_collection_params() { if ( directorist_is_multi_directory_enabled() ) { $params['directory'] = array( - 'description' => __( 'Limit result set to specific directory type ids.', 'directorist' ), - 'type' => 'array', - 'items' => array( + 'description' => __( 'Limit result set to specific directory type ids.', 'directorist' ), + 'type' => 'array', + 'items' => array( 'type' => 'integer', ), 'validate_callback' => 'rest_validate_request_arg', diff --git a/includes/rest-api/Version1/class-directories-controller.php b/includes/rest-api/Version1/class-directories-controller.php index 1fe6dadf4c..aaab4f4e9a 100644 --- a/includes/rest-api/Version1/class-directories-controller.php +++ b/includes/rest-api/Version1/class-directories-controller.php @@ -101,13 +101,13 @@ public function get_item_schema() { 'title' => $this->taxonomy, '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' => __( 'Category name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -115,7 +115,7 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_text_field', ), ), - 'slug' => array( + 'slug' => array( 'description' => __( 'An alphanumeric identifier for the resource unique to its type.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -123,12 +123,12 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_title', ), ), - 'image_url' => array( + 'image_url' => array( 'description' => __( 'Preview image url.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'icon' => array( + 'icon' => array( 'description' => __( 'Icon class.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -136,19 +136,19 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_text_field', ), ), - 'count' => array( + 'count' => array( 'description' => __( 'Number of published listings for the resource.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'is_default' => array( + 'is_default' => array( 'description' => __( 'Default directory status.', 'directorist' ), 'type' => 'boolean', 'default' => false, 'context' => array( 'view', 'edit' ), ), - 'new_status' => array( + 'new_status' => array( 'description' => __( 'Newly created listing status under this directory.', 'directorist' ), 'type' => 'string', 'default' => 'pending', @@ -158,7 +158,7 @@ public function get_item_schema() { ), 'context' => array( 'view', 'edit' ), ), - 'edit_status' => array( + 'edit_status' => array( 'description' => __( 'Edited listing status under this directory.', 'directorist' ), 'type' => 'string', 'default' => 'pending', @@ -173,7 +173,7 @@ public function get_item_schema() { 'type' => 'integer', 'context' => array( 'view', 'edit' ), ), - 'date_created' => array( + 'date_created' => array( 'description' => __( "The date the directory was created, in the site's timezone.", 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), @@ -191,7 +191,6 @@ public function get_item_schema() { * @param WP_Term $term Term object. * @param WP_REST_Request $request Request instance. * @return bool|WP_Error - * */ protected function update_term_meta_fields( $term, $request ) { return true; diff --git a/includes/rest-api/Version1/class-listing-reviews-controller.php b/includes/rest-api/Version1/class-listing-reviews-controller.php index 7a79eea4ac..a5bcb925f3 100644 --- a/includes/rest-api/Version1/class-listing-reviews-controller.php +++ b/includes/rest-api/Version1/class-listing-reviews-controller.php @@ -36,7 +36,9 @@ class Listing_Reviews_Controller extends Abstract_Controller { */ public function register_routes() { register_rest_route( - $this->namespace, '/' . $this->rest_base, array( + $this->namespace, + '/' . $this->rest_base, + array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), @@ -48,7 +50,9 @@ public function register_routes() { ); register_rest_route( - $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( + $this->namespace, + '/' . $this->rest_base . '/(?P<id>[\d]+)', + array( 'args' => array( 'id' => array( 'description' => __( 'Unique identifier for the resource.', 'directorist' ), @@ -460,15 +464,15 @@ public function get_item_schema() { $avatar_properties = array(); $avatar_sizes = rest_get_avatar_sizes(); - foreach ( $avatar_sizes as $size ) { - $avatar_properties[ $size ] = array( - /* translators: %d: avatar image size in pixels */ - 'description' => sprintf( __( 'Avatar URL with image size of %d pixels.', 'directorist' ), $size ), - 'type' => 'string', - 'format' => 'uri', - 'context' => array( 'embed', 'view', 'edit' ), - ); - } + foreach ( $avatar_sizes as $size ) { + $avatar_properties[ $size ] = array( + /* translators: %d: avatar image size in pixels */ + 'description' => sprintf( __( 'Avatar URL with image size of %d pixels.', 'directorist' ), $size ), + 'type' => 'string', + 'format' => 'uri', + 'context' => array( 'embed', 'view', 'edit' ), + ); + } $schema['properties']['reviewer_avatar_urls'] = array( 'description' => __( 'Avatar URLs for the object reviewer.', 'directorist' ), 'type' => 'object', @@ -476,9 +480,9 @@ public function get_item_schema() { 'readonly' => true, 'properties' => $avatar_properties, ); - // } + // } - return $this->add_additional_fields_schema( $schema ); + return $this->add_additional_fields_schema( $schema ); } /** diff --git a/includes/rest-api/Version1/class-listings-actions-controller.php b/includes/rest-api/Version1/class-listings-actions-controller.php index 9f2b711f67..7d103d0be6 100644 --- a/includes/rest-api/Version1/class-listings-actions-controller.php +++ b/includes/rest-api/Version1/class-listings-actions-controller.php @@ -145,14 +145,14 @@ public function create_item( $request ) { /** * Prepare a single listings output for response. * - * @param array $data Listings data. + * @param array $data Listings data. * @param WP_REST_Request $request Request object. * * @return WP_REST_Response */ public function prepare_item_for_response( $data, $request ) { $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; - $schema = $this->get_item_schema(); + $schema = $this->get_item_schema(); $data = array_intersect_key( $request->get_params(), $schema['properties'] ); $data = $this->add_additional_fields_to_object( $data, $request ); @@ -170,7 +170,7 @@ public function prepare_item_for_response( $data, $request ) { * @param array $data Data. * @param WP_REST_Request $request Request object. */ - return apply_filters( "directorist_rest_prepare_listings_actions", $response, $data, $request ); + return apply_filters( 'directorist_rest_prepare_listings_actions', $response, $data, $request ); } /** @@ -184,17 +184,17 @@ public function get_item_schema() { 'title' => 'listings-actions', 'type' => 'object', 'properties' => array( - 'id' => array( + 'id' => array( 'description' => __( 'Action name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'name' => array( + 'name' => array( 'description' => __( 'Action initiator name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'email' => array( + 'email' => array( 'description' => __( 'Action email.', 'directorist' ), 'type' => 'string', 'format' => 'email', @@ -205,7 +205,7 @@ public function get_item_schema() { 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - ) + ), ); return $this->add_additional_fields_schema( $schema ); @@ -232,20 +232,20 @@ public function send_listing_report( $listing_id, $message ) { '{listing_url}' => sprintf( '<a href="%s">%s</a>', $listing_url, $listing_url ), '{sender_name}' => $user->display_name, '{sender_email}' => $user->user_email, - '{message}' => $message + '{message}' => $message, ); - $send_email = get_directorist_option( 'admin_email_lists' ); + $send_email = get_directorist_option( 'admin_email_lists' ); - $to = !empty($send_email) ? $send_email : get_bloginfo('admin_email'); + $to = ! empty( $send_email ) ? $send_email : get_bloginfo( 'admin_email' ); - $subject = __('{site_name} Report Abuse via "{listing_title}"', 'directorist'); - $subject = strtr($subject, $placeholders); + $subject = __( '{site_name} Report Abuse via "{listing_title}"', 'directorist' ); + $subject = strtr( $subject, $placeholders ); - $message = __("Dear Administrator,<br /><br />This is an email abuse report for a listing at {listing_url}.<br /><br />Name: {sender_name}<br />Email: {sender_email}<br />Message: {message}", 'directorist'); - $message = strtr($message, $placeholders); + $message = __( 'Dear Administrator,<br /><br />This is an email abuse report for a listing at {listing_url}.<br /><br />Name: {sender_name}<br />Email: {sender_email}<br />Message: {message}', 'directorist' ); + $message = strtr( $message, $placeholders ); - $message = atbdp_email_html($subject, $message); - $headers = "From: {$user->display_name} <{$user->user_email}>\r\n"; + $message = atbdp_email_html( $subject, $message ); + $headers = "From: {$user->display_name} <{$user->user_email}>\r\n"; $headers .= "Reply-To: {$user->user_email}\r\n"; // return true or false, based on the result @@ -260,47 +260,47 @@ public function contact_listing_owner( $listing_id, $name, $email, $message ) { $listing_email = get_post_meta( $post_id, '_email', true ); $message = stripslashes( esc_textarea( $message ) ); // vars - $post_author_id = get_post_field('post_author', $post_id); - $user = get_userdata($post_author_id); - $site_name = get_bloginfo('name'); - $site_url = get_bloginfo('url'); - $site_email = get_bloginfo('admin_email'); - $listing_title = get_the_title($post_id); - $listing_url = get_permalink($post_id); - $date_format = get_option('date_format'); - $time_format = get_option('time_format'); - $current_time = current_time('timestamp'); - $contact_email_subject = get_directorist_option('email_sub_listing_contact_email'); - $contact_email_body = get_directorist_option('email_tmpl_listing_contact_email'); - $contact_recipient = get_user_meta( $post_author_id, 'directorist_contact_owner_recipient', true ); + $post_author_id = get_post_field( 'post_author', $post_id ); + $user = get_userdata( $post_author_id ); + $site_name = get_bloginfo( 'name' ); + $site_url = get_bloginfo( 'url' ); + $site_email = get_bloginfo( 'admin_email' ); + $listing_title = get_the_title( $post_id ); + $listing_url = get_permalink( $post_id ); + $date_format = get_option( 'date_format' ); + $time_format = get_option( 'time_format' ); + $current_time = current_time( 'timestamp' ); + $contact_email_subject = get_directorist_option( 'email_sub_listing_contact_email' ); + $contact_email_body = get_directorist_option( 'email_tmpl_listing_contact_email' ); + $contact_recipient = get_user_meta( $post_author_id, 'directorist_contact_owner_recipient', true ); $user_email = ! empty( $contact_recipient ) ? $contact_recipient : 'author'; $placeholders = array( '==NAME==' => $user->display_name, '==USERNAME==' => $user->user_login, '==SITE_NAME==' => $site_name, - '==SITE_LINK==' => sprintf('<a href="%s">%s</a>', $site_url, $site_name), - '==SITE_URL==' => sprintf('<a href="%s">%s</a>', $site_url, $site_url), + '==SITE_LINK==' => sprintf( '<a href="%s">%s</a>', $site_url, $site_name ), + '==SITE_URL==' => sprintf( '<a href="%s">%s</a>', $site_url, $site_url ), '==LISTING_TITLE==' => $listing_title, - '==LISTING_LINK==' => sprintf('<a href="%s">%s</a>', $listing_url, $listing_title), - '==LISTING_URL==' => sprintf('<a href="%s">%s</a>', $listing_url, $listing_url), + '==LISTING_LINK==' => sprintf( '<a href="%s">%s</a>', $listing_url, $listing_title ), + '==LISTING_URL==' => sprintf( '<a href="%s">%s</a>', $listing_url, $listing_url ), '==SENDER_NAME==' => $name, '==SENDER_EMAIL==' => $email, '==MESSAGE==' => $message, - '==TODAY==' => date_i18n($date_format, $current_time), - '==NOW==' => date_i18n($date_format . ' ' . $time_format, $current_time) + '==TODAY==' => date_i18n( $date_format, $current_time ), + '==NOW==' => date_i18n( $date_format . ' ' . $time_format, $current_time ), ); - if ('listing_email' == $user_email) { + if ( 'listing_email' == $user_email ) { $to = $listing_email; } else { $to = $user->user_email; } - $subject = strtr($contact_email_subject, $placeholders); - $message = strtr($contact_email_body, $placeholders); - $message = nl2br($message); - $headers = "From: {$name} <{$site_email}>\r\n"; + $subject = strtr( $contact_email_subject, $placeholders ); + $message = strtr( $contact_email_body, $placeholders ); + $message = nl2br( $message ); + $headers = "From: {$name} <{$site_email}>\r\n"; $headers .= "Reply-To: {$email}\r\n"; - $message = atbdp_email_html( $subject, $message ); + $message = atbdp_email_html( $subject, $message ); // return true or false, based on the result return (bool) ATBDP()->email->send_mail( $to, $subject, $message, $headers ); diff --git a/includes/rest-api/Version1/class-listings-controller.php b/includes/rest-api/Version1/class-listings-controller.php index 959fb2eaaa..322e93c86b 100644 --- a/includes/rest-api/Version1/class-listings-controller.php +++ b/includes/rest-api/Version1/class-listings-controller.php @@ -104,7 +104,7 @@ public function get_items( $request ) { continue; } - $data = $this->prepare_item_for_response( $object, $request ); + $data = $this->prepare_item_for_response( $object, $request ); $objects[] = $this->prepare_response_for_collection( $data ); } @@ -165,7 +165,7 @@ protected function get_listings( $query_args ) { * @return array */ protected function prepare_objects_query( $request ) { - $args = []; + $args = array(); $args['offset'] = $request['offset']; $args['order'] = $request['order']; $args['orderby'] = $request['orderby']; @@ -179,11 +179,11 @@ protected function prepare_objects_query( $request ) { $args['fields'] = $this->get_fields_for_response( $request ); // Taxonomy query. - $tax_query = []; + $tax_query = array(); // Meta query. - $meta_query = []; + $meta_query = array(); // Date query. - $args['date_query'] = []; + $args['date_query'] = array(); // Set before into date query. Date query must be specified as an array of an array. if ( isset( $request['before'] ) ) { @@ -210,51 +210,51 @@ protected function prepare_objects_query( $request ) { // Set featured query. $is_featured = false; if ( isset( $request['featured'] ) && $request['featured'] ) { - $is_featured = true; - $meta_query['_featured'] = [ + $is_featured = true; + $meta_query['_featured'] = array( 'key' => '_featured', 'value' => 1, 'compare' => '=', - ]; + ); } // Set directory type query. if ( isset( $request['directory'] ) ) { - $meta_query['_directory_type'] = [ + $meta_query['_directory_type'] = array( 'key' => '_directory_type', 'value' => $request['directory'], 'compare' => '=', - ]; + ); } // Set categories query. if ( isset( $request['categories'] ) ) { - $tax_query['tax_query'][] = [ + $tax_query['tax_query'][] = array( 'taxonomy' => ATBDP_CATEGORY, 'field' => 'term_id', 'terms' => $request['categories'], 'include_children' => true, /*@todo; Add option to include children or exclude it*/ - ]; + ); } // Set locations query. if ( isset( $request['locations'] ) ) { - $tax_query['tax_query'][] = [ + $tax_query['tax_query'][] = array( 'taxonomy' => ATBDP_LOCATION, 'field' => 'term_id', 'terms' => $request['locations'], 'include_children' => true, /*@todo; Add option to include children or exclude it*/ - ]; + ); } // Set locations query. if ( isset( $request['tags'] ) ) { - $tax_query['tax_query'][] = [ + $tax_query['tax_query'][] = array( 'taxonomy' => ATBDP_TAGS, 'field' => 'term_id', 'terms' => $request['tags'], 'include_children' => true, /*@todo; Add option to include children or exclude it*/ - ]; + ); } switch ( $args['orderby'] ) { @@ -269,35 +269,35 @@ protected function prepare_objects_query( $request ) { case 'title': if ( $is_featured ) { $args['meta_key'] = '_featured'; - $args['orderby'] = [ + $args['orderby'] = array( 'meta_value_num' => 'DESC', 'title' => $args['order'], - ]; + ); } break; case 'date': if ( $is_featured ) { $args['meta_key'] = '_featured'; - $args['orderby'] = [ + $args['orderby'] = array( 'meta_value_num' => 'DESC', 'date' => $args['order'], - ]; + ); } break; case 'price': if ( $is_featured ) { - $meta_query['price'] = [ + $meta_query['price'] = array( 'key' => '_price', 'type' => 'NUMERIC', 'compare' => 'EXISTS', - ]; + ); - $args['orderby'] = [ + $args['orderby'] = array( '_featured' => 'DESC', 'price' => $args['orderby'], - ]; + ); } else { $args['meta_key'] = '_price'; $args['orderby'] = 'meta_value_num'; @@ -306,43 +306,43 @@ protected function prepare_objects_query( $request ) { break; case 'popular': - $meta_query['views'] = [ + $meta_query['views'] = array( 'key' => directorist_get_listing_views_count_meta_key(), 'value' => get_directorist_option( 'views_for_popular', 4 ), 'type' => 'NUMERIC', 'compare' => '>=', - ]; + ); if ( $is_featured ) { - $args['orderby'] = [ + $args['orderby'] = array( '_featured' => $args['order'], 'views' => $args['order'], - ]; + ); } else { - $args['orderby'] = [ + $args['orderby'] = array( 'views' => $args['order'], - ]; + ); } } // TODO: Status has been migrated, remove related code. // // Expired listings query. // $meta_query['expired'] = array( - // 'key' => '_listing_status', - // 'value' => 'expired', - // 'compare' => '!=' + // 'key' => '_listing_status', + // 'value' => 'expired', + // 'compare' => '!=' // ); // if ( $args['post_status'] === 'expired' ) { - // // Get only expired listings - // $meta_query['expired'] = array( - // 'key' => '_listing_status', - // 'value' => 'expired', - // 'compare' => '==', - // ); - - // // Expired listings have post_status => private hence we need to set any. - // $args['post_status'] = 'any'; + // Get only expired listings + // $meta_query['expired'] = array( + // 'key' => '_listing_status', + // 'value' => 'expired', + // 'compare' => '==', + // ); + + // Expired listings have post_status => private hence we need to set any. + // $args['post_status'] = 'any'; // } // TODO: Remove the above lines due to listing status migration. @@ -353,21 +353,21 @@ protected function prepare_objects_query( $request ) { 'key' => '_price', 'value' => array( $request['min_price'], $request['max_price'] ), 'type' => 'NUMERIC', - 'compare' => 'BETWEEN' + 'compare' => 'BETWEEN', ); } elseif ( $request['min_price'] ) { $meta_query['price'] = array( 'key' => '_price', 'value' => $request['min_price'], 'type' => 'NUMERIC', - 'compare' => '>=' + 'compare' => '>=', ); } elseif ( $request['max_price'] ) { $meta_query['price'] = array( 'key' => '_price', 'value' => $request['max_price'], 'type' => 'NUMERIC', - 'compare' => '<=' + 'compare' => '<=', ); } } @@ -377,7 +377,7 @@ protected function prepare_objects_query( $request ) { $meta_query['price_range'] = array( 'key' => '_price_range', 'value' => $request['price_range'], - 'compare' => '=' + 'compare' => '=', ); } @@ -385,7 +385,7 @@ protected function prepare_objects_query( $request ) { $meta_query['website'] = array( 'key' => '_website', 'value' => $request['website'], - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } @@ -393,7 +393,7 @@ protected function prepare_objects_query( $request ) { $meta_query['email'] = array( 'key' => '_email', 'value' => $request['email'], - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } @@ -401,15 +401,15 @@ protected function prepare_objects_query( $request ) { $meta_query['phone'] = array( 'relation' => 'OR', array( - 'key' => '_phone2', - 'value' => $request['phone'], - 'compare' => 'LIKE' + 'key' => '_phone2', + 'value' => $request['phone'], + 'compare' => 'LIKE', ), array( - 'key' => '_phone', - 'value' => $request['phone'], - 'compare' => 'LIKE' - ) + 'key' => '_phone', + 'value' => $request['phone'], + 'compare' => 'LIKE', + ), ); } @@ -417,7 +417,7 @@ protected function prepare_objects_query( $request ) { $meta_query['fax'] = array( 'key' => '_fax', 'value' => $request['fax'], - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } @@ -425,7 +425,7 @@ protected function prepare_objects_query( $request ) { $meta_query['zip'] = array( 'key' => '_zip', 'value' => $request['zip'], - 'compare' => 'LIKE' + 'compare' => 'LIKE', ); } @@ -447,13 +447,13 @@ protected function prepare_objects_query( $request ) { 'latitude' => $request['radius']['latitude'], 'longitude' => $request['radius']['longitude'], 'distance' => $request['radius']['distance'], - 'units' => get_directorist_option( 'radius_search_unit', 'miles' ) + 'units' => get_directorist_option( 'radius_search_unit', 'miles' ), ); } if ( ! empty( $meta_query ) ) { $meta_query[]['relation'] = 'AND'; - $args['meta_query'] = $meta_query; + $args['meta_query'] = $meta_query; } if ( ! empty( $tax_query ) ) { @@ -506,7 +506,7 @@ public function get_item( $request ) { return new WP_Error( "directorist_rest_invalid_{$this->post_type}_id", __( 'Invalid ID.', 'directorist' ), array( 'status' => 404 ) ); } - $data = $this->prepare_item_for_response( $post, $request ); + $data = $this->prepare_item_for_response( $post, $request ); $response = rest_ensure_response( $data ); if ( $this->public ) { @@ -533,8 +533,8 @@ public function prepare_item_for_response( $object, $request ) { $this->request = $request; $data = $this->get_listing_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 ) ); @@ -555,8 +555,8 @@ public function prepare_item_for_response( $object, $request ) { /** * Get taxonomy terms. * - * @param int $post_id Listing id. - * @param string $taxonomy Taxonomy slug. + * @param int $post_id Listing id. + * @param string $taxonomy Taxonomy slug. * * @return array */ @@ -635,15 +635,15 @@ protected function get_images( $listing ) { // Set a placeholder image if the listing has no images set. if ( empty( $images ) ) { // $images[] = array( - // 'id' => 0, - // 'date_created' => directorist_rest_prepare_date_response( current_time( 'mysql' ), false ), // Default to now. - // 'date_created_gmt' => directorist_rest_prepare_date_response( time() ), // Default to now. - // 'date_modified' => directorist_rest_prepare_date_response( current_time( 'mysql' ), false ), - // 'date_modified_gmt' => directorist_rest_prepare_date_response( time() ), - // 'src' => directorist_placeholder_img_src(), - // 'name' => __( 'Placeholder', 'directorist' ), - // 'alt' => __( 'Placeholder', 'directorist' ), - // 'position' => 0, + // 'id' => 0, + // 'date_created' => directorist_rest_prepare_date_response( current_time( 'mysql' ), false ), // Default to now. + // 'date_created_gmt' => directorist_rest_prepare_date_response( time() ), // Default to now. + // 'date_modified' => directorist_rest_prepare_date_response( current_time( 'mysql' ), false ), + // 'date_modified_gmt' => directorist_rest_prepare_date_response( time() ), + // 'src' => directorist_placeholder_img_src(), + // 'name' => __( 'Placeholder', 'directorist' ), + // 'alt' => __( 'Placeholder', 'directorist' ), + // 'position' => 0, // ); $images = null; @@ -655,14 +655,14 @@ protected function get_images( $listing ) { /** * Get listing data. * - * @param WP_Post $listing WP_Post instance. + * @param WP_Post $listing WP_Post instance. * @param WP_REST_Request $request Request object. - * @param string $context Request context. Options: 'view' and 'edit'. + * @param string $context Request context. Options: 'view' and 'edit'. * * @return array */ protected function get_listing_data( $listing, $request, $context = 'view' ) { - $fields = $this->get_fields_for_response( $request ); + $fields = $this->get_fields_for_response( $request ); $base_data = array(); foreach ( $fields as $field ) { @@ -692,7 +692,7 @@ protected function get_listing_data( $listing, $request, $context = 'view' ) { $base_data['date_modified_gmt'] = directorist_rest_prepare_date_response( $listing->post_date_modified_gmt ); break; case 'description': - $base_data['description'] = 'view' === $context ? wpautop( do_shortcode( $listing->post_content ) ): $listing->post_content; + $base_data['description'] = 'view' === $context ? wpautop( do_shortcode( $listing->post_content ) ) : $listing->post_content; break; case 'short_description': $base_data['short_description'] = 'view' === $context ? $listing->post_excerpt : $listing->post_excerpt; @@ -773,9 +773,9 @@ protected function get_listing_data( $listing, $request, $context = 'view' ) { // TODO: Status has been migrated, remove related code. // $listing_status = get_post_meta( $listing->ID, '_listing_status', true ); // if ( $listing_status && $listing_status === 'expired' ) { - // $base_data['status'] = 'expired'; + // $base_data['status'] = 'expired'; // } else { - // $base_data['status'] = $listing->post_status; + // $base_data['status'] = $listing->post_status; // } $base_data['status'] = $listing->post_status; break; @@ -818,7 +818,7 @@ protected function get_listing_data( $listing, $request, $context = 'view' ) { protected function get_listing_social_links( $id ) { $links = get_post_meta( $id, '_social', true ); - if ( empty( $links ) || ! is_array( $links )) { + if ( empty( $links ) || ! is_array( $links ) ) { return null; } @@ -828,8 +828,8 @@ protected function get_listing_social_links( $id ) { continue; } $data[] = array( - 'id' => $link['id'], - 'url' => $link['url'] + 'id' => $link['id'], + 'url' => $link['url'], ); } @@ -843,8 +843,8 @@ protected function get_related_listings_ids( $listing_id ) { $logic = get_directorist_type_option( $directory_type, 'similar_listings_logics', 'OR' ); $relationship = ( in_array( $logic, array( 'AND', 'OR' ) ) ? $logic : 'OR' ); - $categories = directorist_get_object_terms( $listing_id, ATBDP_CATEGORY, 'term_id' ); - $tags = directorist_get_object_terms( $listing_id, ATBDP_TAGS, 'term_id' ); + $categories = directorist_get_object_terms( $listing_id, ATBDP_CATEGORY, 'term_id' ); + $tags = directorist_get_object_terms( $listing_id, ATBDP_TAGS, 'term_id' ); $args = array( 'post_type' => ATBDP_POST_TYPE, @@ -865,16 +865,16 @@ protected function get_related_listings_ids( $listing_id ) { ), ); - if ( ! empty( $same_author ) ){ - $args['author'] = get_post_field( 'post_author', $listing_id ); + if ( ! empty( $same_author ) ) { + $args['author'] = get_post_field( 'post_author', $listing_id ); } $meta_queries = array(); // TODO: Status has been migrated, remove related code. // $meta_queries['expired'] = array( - // 'key' => '_listing_status', - // 'value' => 'expired', - // 'compare' => '!=', + // 'key' => '_listing_status', + // 'value' => 'expired', + // 'compare' => '!=', // ); $meta_queries['directory_type'] = array( 'key' => '_directory_type', @@ -882,14 +882,14 @@ protected function get_related_listings_ids( $listing_id ) { 'compare' => '=', ); - $meta_queries = apply_filters('atbdp_related_listings_meta_queries', $meta_queries); - $count_meta_queries = count($meta_queries); - if ($count_meta_queries) { - $args['meta_query'] = ($count_meta_queries > 1) ? array_merge(array('relation' => 'AND'), $meta_queries) : $meta_queries; + $meta_queries = apply_filters( 'atbdp_related_listings_meta_queries', $meta_queries ); + $count_meta_queries = count( $meta_queries ); + if ( $count_meta_queries ) { + $args['meta_query'] = ( $count_meta_queries > 1 ) ? array_merge( array( 'relation' => 'AND' ), $meta_queries ) : $meta_queries; } $args = apply_filters( 'directorist_related_listing_args', $args ); - $related = new \Directorist\Directorist_Listings( [], 'related', $args, ['cache' => false] ); + $related = new \Directorist\Directorist_Listings( array(), 'related', $args, array( 'cache' => false ) ); return $related->post_ids(); } @@ -927,64 +927,64 @@ 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' => __( 'Listing name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'slug' => array( + 'slug' => array( 'description' => __( 'Listing slug.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'permalink' => array( + 'permalink' => array( 'description' => __( 'Listing URL.', 'directorist' ), 'type' => 'string', 'format' => 'uri', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'date_created' => array( + 'date_created' => array( 'description' => __( "The date the listing was created, in the site's timezone.", 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'date_created_gmt' => array( + 'date_created_gmt' => array( 'description' => __( 'The date the listing was created, as GMT.', 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'date_modified' => array( + 'date_modified' => array( 'description' => __( "The date the listing was last modified, in the site's timezone.", 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'date_modified_gmt' => array( + 'date_modified_gmt' => array( 'description' => __( 'The date the listing was last modified, as GMT.', 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'description' => array( + 'description' => array( 'description' => __( 'Listing description.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'short_description' => array( + 'short_description' => array( 'description' => __( 'Listing short description.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -994,12 +994,12 @@ public function get_item_schema() { 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'phone' => array( + 'phone' => array( 'description' => __( 'Phone number 1.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'phone_2' => array( + 'phone_2' => array( 'description' => __( 'Phone number 2.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -1009,25 +1009,25 @@ public function get_item_schema() { 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'email' => array( + 'email' => array( 'description' => __( 'Email address.', 'directorist' ), 'type' => 'string', 'format' => 'email', 'context' => array( 'view', 'edit' ), ), - 'website' => array( + 'website' => array( 'description' => __( 'Website url.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'social_links' => array( + 'social_links' => array( 'description' => __( 'List of social media links.', 'directorist' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), 'items' => array( 'type' => 'object', 'properties' => array( - 'id' => array( + 'id' => array( 'description' => __( 'Social media name', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -1040,13 +1040,13 @@ public function get_item_schema() { ), ), ), - 'views_count' => array( + 'views_count' => array( 'description' => __( 'Visitors view count.', 'directorist' ), 'type' => 'integer', 'default' => 0, 'context' => array( 'view', 'edit' ), ), - 'map_hidden' => array( + 'map_hidden' => array( 'description' => __( 'Map visibility status status.', 'directorist' ), 'type' => 'boolean', 'default' => false, @@ -1057,40 +1057,40 @@ public function get_item_schema() { 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'latitude' => array( + 'latitude' => array( 'description' => __( 'Address location latitude.', 'directorist' ), 'type' => 'number', 'context' => array( 'view', 'edit' ), ), - 'longitude' => array( + 'longitude' => array( 'description' => __( 'Address location longitude.', 'directorist' ), 'type' => 'number', 'context' => array( 'view', 'edit' ), ), - 'pricing_type' => array( + 'pricing_type' => array( 'description' => __( 'Pricing type.', 'directorist' ), 'type' => 'string', // 'enum' => array( 'price', 'range' ), 'context' => array( 'view', 'edit' ), ), - 'price' => array( + 'price' => array( 'description' => __( 'Listing price.', 'directorist' ), 'type' => 'number', 'context' => array( 'view', 'edit' ), ), - 'price_range' => array( + 'price_range' => array( 'description' => __( 'Listing price range.', 'directorist' ), 'type' => 'string', 'enum' => array( 'skimming', 'moderate', 'economy', 'bellow_economy' ), 'context' => array( 'view', 'edit' ), ), - 'owner_contact_hidden' => array( + 'owner_contact_hidden' => array( 'description' => __( 'Listing owner contact form visibility status.', 'directorist' ), 'type' => 'boolean', 'default' => false, 'context' => array( 'view', 'edit' ), ), - 'video_url' => array( + 'video_url' => array( 'description' => __( 'Video url.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -1100,29 +1100,29 @@ public function get_item_schema() { 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'directory' => array( + 'directory' => array( 'description' => __( 'Multi directory type id.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), ), - 'date_expired' => array( + 'date_expired' => array( 'description' => __( 'Expiration date.', 'directorist' ), 'type' => 'date-time', 'context' => array( 'view', 'edit' ), ), - 'never_expired' => array( + 'never_expired' => array( 'description' => __( 'Never expired status.', 'directorist' ), 'type' => 'boolen', 'default' => false, 'context' => array( 'view', 'edit' ), ), - 'featured' => array( + 'featured' => array( 'description' => __( 'Featured listing.', 'directorist' ), 'type' => 'boolean', 'default' => false, 'context' => array( 'view', 'edit' ), ), - 'new' => array( + 'new' => array( 'description' => __( 'New listing.', 'directorist' ), 'type' => 'boolean', 'default' => false, @@ -1136,39 +1136,39 @@ public function get_item_schema() { 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'status' => array( + 'status' => array( 'description' => __( 'Listing status.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'reviews_allowed' => array( + 'reviews_allowed' => array( 'description' => __( 'Allow reviews.', 'directorist' ), 'type' => 'boolean', 'default' => true, 'context' => array( 'view', 'edit' ), ), - 'average_rating' => array( + 'average_rating' => array( 'description' => __( 'Reviews average rating.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'rating_count' => array( + 'rating_count' => array( 'description' => __( 'Amount of reviews that the listing have.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'related_ids' => array( + 'related_ids' => array( 'description' => __( 'List of related listings IDs.', 'directorist' ), 'type' => 'array', 'items' => array( 'type' => 'integer', ), - 'context' => array( 'view', 'edit' ), - 'readonly' => true, + 'context' => array( 'view', 'edit' ), + 'readonly' => true, ), - 'categories' => array( + 'categories' => array( 'description' => __( 'List of categories.', 'directorist' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), @@ -1201,7 +1201,7 @@ public function get_item_schema() { ), ), ), - 'tags' => array( + 'tags' => array( 'description' => __( 'List of tags.', 'directorist' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), @@ -1228,7 +1228,7 @@ public function get_item_schema() { ), ), ), - 'locations' => array( + 'locations' => array( 'description' => __( 'List of locations.', 'directorist' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), @@ -1255,7 +1255,7 @@ public function get_item_schema() { ), ), ), - 'images' => array( + 'images' => array( 'description' => __( 'List of images.', 'directorist' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), @@ -1315,17 +1315,17 @@ public function get_item_schema() { ), ), ), - 'menu_order' => array( + 'menu_order' => array( 'description' => __( 'Menu order, used to custom sort listings.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), ), - 'author' => array( + 'author' => array( 'description' => __( 'Listing author id.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), ), - 'meta_data' => array( + 'meta_data' => array( 'description' => __( 'Meta data.', 'directorist' ), 'type' => 'array', 'context' => array( 'view', 'edit' ), @@ -1367,45 +1367,45 @@ public function get_collection_params() { $params['context']['default'] = 'view'; - $params['exclude'] = array( + $params['exclude'] = array( 'description' => __( 'Ensure result set excludes specific IDs.', 'directorist' ), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', - 'validate_callback' => 'rest_validate_request_arg', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['include'] = array( + $params['include'] = array( 'description' => __( 'Limit result set to specific IDs.', 'directorist' ), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', - 'validate_callback' => 'rest_validate_request_arg', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['offset'] = array( - 'description' => __( 'Offset the result set by a specific number of items.', 'directorist' ), - 'type' => 'integer', - 'sanitize_callback' => 'absint', - 'validate_callback' => 'rest_validate_request_arg', + $params['offset'] = array( + 'description' => __( 'Offset the result set by a specific number of items.', 'directorist' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['order'] = array( - 'default' => 'desc', - 'description' => __( 'Order sort attribute ascending or descending.', 'directorist' ), - 'enum' => array( 'asc', 'desc' ), - 'sanitize_callback' => 'sanitize_key', - 'type' => 'string', - 'validate_callback' => 'rest_validate_request_arg', + $params['order'] = array( + 'default' => 'desc', + 'description' => __( 'Order sort attribute ascending or descending.', 'directorist' ), + 'enum' => array( 'asc', 'desc' ), + 'sanitize_callback' => 'sanitize_key', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['orderby'] = array( - 'description' => __( 'Sort collection by object attribute.', 'directorist' ), - 'enum' => array_keys( $this->get_orderby_possibles() ), - 'sanitize_callback' => 'sanitize_key', - 'type' => 'string', - 'validate_callback' => 'rest_validate_request_arg', + $params['orderby'] = array( + 'description' => __( 'Sort collection by object attribute.', 'directorist' ), + 'enum' => array_keys( $this->get_orderby_possibles() ), + 'sanitize_callback' => 'sanitize_key', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['slug'] = array( + $params['slug'] = array( 'description' => __( 'Limit result set to listings with a specific slug.', 'directorist' ), 'type' => 'string', 'validate_callback' => 'rest_validate_request_arg', ); - $params['status'] = array( + $params['status'] = array( 'default' => 'publish', 'description' => __( 'Limit result set to listings assigned a specific status.', 'directorist' ), 'type' => 'string', @@ -1413,35 +1413,35 @@ public function get_collection_params() { 'sanitize_callback' => 'sanitize_key', 'validate_callback' => 'rest_validate_request_arg', ); - $params['featured'] = array( + $params['featured'] = array( 'description' => __( 'Limit result set to featured listings.', 'directorist' ), 'type' => 'boolean', 'validate_callback' => 'rest_validate_request_arg', ); - $params['categories'] = array( + $params['categories'] = array( 'description' => __( 'Limit result set to listings assigned a specific category ID.', 'directorist' ), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', 'validate_callback' => 'rest_validate_request_arg', ); - $params['tags'] = array( + $params['tags'] = array( 'description' => __( 'Limit result set to listings assigned a specific tag ID.', 'directorist' ), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', 'validate_callback' => 'rest_validate_request_arg', ); - $params['locations'] = array( + $params['locations'] = array( 'description' => __( 'Limit result set to listings assigned a specific location ID.', 'directorist' ), 'type' => 'string', 'sanitize_callback' => 'wp_parse_id_list', 'validate_callback' => 'rest_validate_request_arg', ); - $params['min_price'] = array( + $params['min_price'] = array( 'description' => __( 'Limit result set to listings based on a minimum price.', 'directorist' ), 'type' => 'integer', 'validate_callback' => 'rest_validate_request_arg', ); - $params['max_price'] = array( + $params['max_price'] = array( 'description' => __( 'Limit result set to listings based on maximum price.', 'directorist' ), 'type' => 'integer', 'validate_callback' => 'rest_validate_request_arg', @@ -1452,12 +1452,12 @@ public function get_collection_params() { 'enum' => array( 'skimming', 'moderate', 'economy', 'bellow_economy' ), 'validate_callback' => 'rest_validate_request_arg', ); - $params['rating'] = array( + $params['rating'] = array( 'description' => __( 'Limit result set to specified rating.', 'directorist' ), 'type' => 'integer', 'validate_callback' => 'rest_validate_request_arg', ); - $params['radius'] = array( + $params['radius'] = array( 'description' => __( 'Limit result set to listings based on radius search.', 'directorist' ), 'type' => 'object', 'properties' => array( @@ -1469,20 +1469,20 @@ public function get_collection_params() { 'type' => 'string', 'required' => true, ), - 'distance' => array( + 'distance' => array( 'type' => 'string', 'required' => true, - ) + ), ), 'validate_callback' => 'rest_validate_request_arg', ); - $params['directory'] = array( + $params['directory'] = array( 'description' => __( 'Limit result set to listings to sepecific directory type.', 'directorist' ), 'type' => 'integar', 'sanitize_callback' => 'absint', 'validate_callback' => 'rest_validate_request_arg', ); - $params['author'] = array( + $params['author'] = array( 'description' => __( 'Limit result set to listings specific to author ID.', 'directorist' ), 'type' => 'integer', 'sanitize_callback' => 'absint', diff --git a/includes/rest-api/Version1/class-locations-controller.php b/includes/rest-api/Version1/class-locations-controller.php index 09e8ec1cca..529acb5a78 100644 --- a/includes/rest-api/Version1/class-locations-controller.php +++ b/includes/rest-api/Version1/class-locations-controller.php @@ -194,11 +194,11 @@ public function get_item_schema() { ), ), ), - 'directory' => array( + 'directory' => array( 'description' => __( 'Directory type ids for this resource.', 'directorist' ), 'type' => 'array', - 'items' => array( - 'type' => 'integer', + 'items' => array( + 'type' => 'integer', ), 'context' => array( 'view', 'edit' ), 'arg_options' => array( @@ -240,12 +240,14 @@ protected function update_term_meta_fields( $term, $request ) { } $directory_ids = $request['directory']; - $directory = get_terms( array( - 'include' => $directory_ids, - 'taxonomy' => ATBDP_TYPE, - 'update_term_meta_cache' => false, - 'hide_empty' => false, - ) ); + $directory = get_terms( + array( + 'include' => $directory_ids, + 'taxonomy' => ATBDP_TYPE, + 'update_term_meta_cache' => false, + 'hide_empty' => false, + ) + ); if ( is_wp_error( $directory ) || empty( $directory ) ) { return new WP_Error( @@ -319,9 +321,9 @@ public function get_collection_params() { if ( directorist_is_multi_directory_enabled() ) { $params['directory'] = array( - 'description' => __( 'Limit result set to specific directory type ids.', 'directorist' ), - 'type' => 'array', - 'items' => array( + 'description' => __( 'Limit result set to specific directory type ids.', 'directorist' ), + 'type' => 'array', + 'items' => array( 'type' => 'integer', ), 'validate_callback' => 'rest_validate_request_arg', diff --git a/includes/rest-api/Version1/class-users-account-controller.php b/includes/rest-api/Version1/class-users-account-controller.php index f577443a1c..a5749d39d2 100644 --- a/includes/rest-api/Version1/class-users-account-controller.php +++ b/includes/rest-api/Version1/class-users-account-controller.php @@ -30,90 +30,106 @@ class Users_Account_Controller extends Abstract_Controller { */ public function register_routes() { // Send Password Reset PIN - register_rest_route( $this->namespace, '/' . $this->rest_base . '/send-password-reset-pin', array( - 'methods' => WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'send_password_reset_pin' ), - 'permission_callback' => array( $this, 'check_send_password_permission' ), - 'args' => array( - 'email' => array( - 'required' => true, - 'type' => 'string', - 'format' => 'email', - 'description' => __( 'User email address.', 'directorist' ), + register_rest_route( + $this->namespace, + '/' . $this->rest_base . '/send-password-reset-pin', + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'send_password_reset_pin' ), + 'permission_callback' => array( $this, 'check_send_password_permission' ), + 'args' => array( + 'email' => array( + 'required' => true, + 'type' => 'string', + 'format' => 'email', + 'description' => __( 'User email address.', 'directorist' ), + ), ), ) - ) ); + ); // Verify Password Reset PIN - register_rest_route( $this->namespace, '/' . $this->rest_base . '/verify-password-reset-pin', array( - 'methods' => WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'verify_password_reset_pin' ), - 'permission_callback' => array( $this, 'check_verify_reset_pin_permission' ), - 'args' => array( - 'email' => array( - 'required' => true, - 'type' => 'string', - 'format' => 'email', - 'description' => __( 'User email address.', 'directorist' ), - ), - 'pin' => array( - 'required' => true, - 'type' => 'string', - 'description' => __( 'Password rest pin.', 'directorist' ), + register_rest_route( + $this->namespace, + '/' . $this->rest_base . '/verify-password-reset-pin', + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'verify_password_reset_pin' ), + 'permission_callback' => array( $this, 'check_verify_reset_pin_permission' ), + 'args' => array( + 'email' => array( + 'required' => true, + 'type' => 'string', + 'format' => 'email', + 'description' => __( 'User email address.', 'directorist' ), + ), + 'pin' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Password rest pin.', 'directorist' ), + ), ), ) - ) ); + ); // Rest user password. - register_rest_route( $this->namespace, '/' . $this->rest_base . '/reset-user-password', array( - 'methods' => WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'reset_user_password' ), - 'permission_callback' => array( $this, 'check_reset_password_permission' ), - 'args' => array( - 'email' => array( - 'required' => true, - 'type' => 'string', - 'format' => 'email', - 'description' => __( 'User email address.', 'directorist' ), - ), - 'password' => array( - 'required' => true, - 'type' => 'string', - 'minLength' => 6, - 'description' => __( 'User new password.', 'directorist' ), - ), - 'pin' => array( - 'required' => true, - 'type' => 'string', - 'description' => __( 'Password rest pin.', 'directorist' ), + register_rest_route( + $this->namespace, + '/' . $this->rest_base . '/reset-user-password', + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'reset_user_password' ), + 'permission_callback' => array( $this, 'check_reset_password_permission' ), + 'args' => array( + 'email' => array( + 'required' => true, + 'type' => 'string', + 'format' => 'email', + 'description' => __( 'User email address.', 'directorist' ), + ), + 'password' => array( + 'required' => true, + 'type' => 'string', + 'minLength' => 6, + 'description' => __( 'User new password.', 'directorist' ), + ), + 'pin' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'Password rest pin.', 'directorist' ), + ), ), ) - ) ); + ); // Change password. - register_rest_route( $this->namespace, '/' . $this->rest_base . '/change-password', array( - 'methods' => WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'change_password' ), - 'permission_callback' => array( $this, 'check_change_password_permission' ), - 'args' => array( - 'user_id' => array( - 'required' => true, - 'type' => 'integer', - 'description' => __( 'User id.', 'directorist' ), - ), - 'old_password' => array( - 'required' => true, - 'type' => 'string', - 'description' => __( 'User old password.', 'directorist' ), - ), - 'new_password' => array( - 'required' => true, - 'type' => 'string', - 'minLength' => 6, - 'description' => __( 'User new password.', 'directorist' ), + register_rest_route( + $this->namespace, + '/' . $this->rest_base . '/change-password', + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'change_password' ), + 'permission_callback' => array( $this, 'check_change_password_permission' ), + 'args' => array( + 'user_id' => array( + 'required' => true, + 'type' => 'integer', + 'description' => __( 'User id.', 'directorist' ), + ), + 'old_password' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'User old password.', 'directorist' ), + ), + 'new_password' => array( + 'required' => true, + 'type' => 'string', + 'minLength' => 6, + 'description' => __( 'User new password.', 'directorist' ), + ), ), ) - ) ); + ); } protected function get_user_by_email( $email ) { @@ -171,11 +187,11 @@ public function send_password_reset_pin( $request ) { ATBDP()->email->send_password_reset_pin_email( $user ); - $data = [ + $data = array( 'success' => true, 'message' => __( 'Password reset code has been sent to your email.', 'directorist' ), 'email' => $request['email'], - ]; + ); $response = rest_ensure_response( $data ); @@ -189,10 +205,10 @@ public function verify_password_reset_pin( $request ) { return $is_valid; } - $data = [ + $data = array( 'success' => true, 'message' => __( 'Password reset pin has been verified.', 'directorist' ), - ]; + ); $response = rest_ensure_response( $data ); @@ -213,11 +229,11 @@ public function reset_user_password( $request ) { directorist_delete_password_reset_code_transient( $user ); delete_user_meta( $user->ID, 'directorist_pasword_reset_key' ); - $data = [ + $data = array( 'success' => true, 'message' => __( 'Password has been reset successfully.', 'directorist' ), 'user_id' => $user->ID, - ]; + ); $response = rest_ensure_response( $data ); @@ -234,10 +250,10 @@ public function change_password( $request ) { // Change Password wp_set_password( $request['new_password'], $user->ID ); - $data = [ + $data = array( 'success' => true, 'message' => __( 'Password has been changed successfully.', 'directorist' ), - ]; + ); $response = rest_ensure_response( $data ); @@ -257,4 +273,4 @@ protected function validate_reset_pin_code( $request ) { return true; } -} \ No newline at end of file +} diff --git a/includes/rest-api/Version1/class-users-controller.php b/includes/rest-api/Version1/class-users-controller.php index 5a1ed3aba5..bb30bb0793 100644 --- a/includes/rest-api/Version1/class-users-controller.php +++ b/includes/rest-api/Version1/class-users-controller.php @@ -30,78 +30,89 @@ class Users_Controller extends Abstract_Controller { * Register the routes for terms. */ public function register_routes() { - register_rest_route( $this->namespace, '/' . $this->rest_base, array( + register_rest_route( + $this->namespace, + '/' . $this->rest_base, array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_items' ), - 'permission_callback' => array( $this, 'get_items_permissions_check' ), - 'args' => $this->get_collection_params(), - ), - array( - 'methods' => WP_REST_Server::CREATABLE, - 'callback' => array( $this, 'create_item' ), - 'permission_callback' => array( $this, 'create_item_permissions_check' ), - 'args' => array_merge( $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), array( - 'email' => array( - 'required' => true, - 'type' => 'string', - 'description' => __( 'New user email address.', 'directorist' ), - ), - 'username' => array( - 'required' => false, - 'description' => __( 'New user username.', 'directorist' ), - 'type' => 'string', - ), - 'password' => array( - 'required' => true, - 'description' => __( 'New user password.', 'directorist' ), - 'type' => 'string', + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_items' ), + 'permission_callback' => array( $this, 'get_items_permissions_check' ), + 'args' => $this->get_collection_params(), + ), + array( + 'methods' => WP_REST_Server::CREATABLE, + 'callback' => array( $this, 'create_item' ), + 'permission_callback' => array( $this, 'create_item_permissions_check' ), + 'args' => array_merge( + $this->get_endpoint_args_for_item_schema( WP_REST_Server::CREATABLE ), + array( + 'email' => array( + 'required' => true, + 'type' => 'string', + 'description' => __( 'New user email address.', 'directorist' ), + ), + 'username' => array( + 'required' => false, + 'description' => __( 'New user username.', 'directorist' ), + 'type' => 'string', + ), + 'password' => array( + 'required' => true, + 'description' => __( 'New user password.', 'directorist' ), + 'type' => 'string', + ), + ) ), - ) ), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) ); - - register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( - 'args' => array( - 'id' => array( - 'description' => __( 'Unique identifier for the resource.', 'directorist' ), - 'type' => 'integer', ), - ), + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); + + register_rest_route( + $this->namespace, + '/' . $this->rest_base . '/(?P<id>[\d]+)', array( - 'methods' => WP_REST_Server::READABLE, - 'callback' => array( $this, 'get_item' ), - 'permission_callback' => array( $this, 'get_item_permissions_check' ), - 'args' => array( - 'context' => $this->get_context_param( array( 'default' => 'view' ) ), + 'args' => array( + 'id' => array( + 'description' => __( 'Unique identifier for the resource.', 'directorist' ), + 'type' => 'integer', + ), ), - ), - array( - 'methods' => WP_REST_Server::EDITABLE, - 'callback' => array( $this, 'update_item' ), - 'permission_callback' => array( $this, 'update_item_permissions_check' ), - 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), - ), - array( - 'methods' => WP_REST_Server::DELETABLE, - 'callback' => array( $this, 'delete_item' ), - 'permission_callback' => array( $this, 'delete_item_permissions_check' ), - 'args' => array( - 'force' => array( - 'default' => false, - 'type' => 'boolean', - 'description' => __( 'Required to be true, as resource does not support trashing.', 'directorist' ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_item' ), + 'permission_callback' => array( $this, 'get_item_permissions_check' ), + 'args' => array( + 'context' => $this->get_context_param( array( 'default' => 'view' ) ), ), - 'reassign' => array( - 'default' => 0, - 'type' => 'integer', - 'description' => __( 'ID to reassign posts to.', 'directorist' ), + ), + array( + 'methods' => WP_REST_Server::EDITABLE, + 'callback' => array( $this, 'update_item' ), + 'permission_callback' => array( $this, 'update_item_permissions_check' ), + 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), + ), + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array( + 'force' => array( + 'default' => false, + 'type' => 'boolean', + 'description' => __( 'Required to be true, as resource does not support trashing.', 'directorist' ), + ), + 'reassign' => array( + 'default' => 0, + 'type' => 'integer', + 'description' => __( 'ID to reassign posts to.', 'directorist' ), + ), ), ), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) ); + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); } /** @@ -229,7 +240,7 @@ protected function check_permissions( $request, $context = 'read' ) { * @return WP_Error|WP_REST_Response */ public function get_items( $request ) { - $prepared_args = array(); + $prepared_args = array(); $prepared_args['exclude'] = $request['exclude']; $prepared_args['include'] = $request['include']; $prepared_args['order'] = $request['order']; @@ -239,7 +250,7 @@ public function get_items( $request ) { } else { $prepared_args['offset'] = ( $request['page'] - 1 ) * $prepared_args['number']; } - $orderby_possibles = $this->get_orderby_possibles(); + $orderby_possibles = $this->get_orderby_possibles(); $prepared_args['orderby'] = $orderby_possibles[ $request['orderby'] ]; $prepared_args['search'] = $request['search']; @@ -259,7 +270,7 @@ public function get_items( $request ) { } // Limit users to having published listings only - $prepared_args['has_published_posts'] = [ ATBDP_POST_TYPE ]; + $prepared_args['has_published_posts'] = array( ATBDP_POST_TYPE ); /** * Filter arguments, before passing to WP_User_Query, when querying users via the REST API. @@ -277,7 +288,7 @@ public function get_items( $request ) { $users = array(); foreach ( $query->results as $user ) { - $data = $this->prepare_item_for_response( $user, $request ); + $data = $this->prepare_item_for_response( $user, $request ); $users[] = $this->prepare_response_for_collection( $data ); } @@ -285,7 +296,7 @@ public function get_items( $request ) { // Store pagination values for headers then unset for count query. $per_page = (int) $prepared_args['number']; - $page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 ); + $page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 ); $prepared_args['fields'] = 'ID'; @@ -350,12 +361,12 @@ public function create_item( $request ) { $username = sanitize_user( current( explode( '@', $request['email'] ) ), true ); // Ensure username is unique. - $append = 1; + $append = 1; $o_username = $username; while ( username_exists( $username ) ) { $username = $o_username . $append; - $append++; + ++$append; } $user_data['user_login'] = $username; @@ -447,7 +458,7 @@ public function update_item( $request ) { } $updated_user_data = array( - 'ID' => $user_data->ID + 'ID' => $user_data->ID, ); // User email. @@ -570,8 +581,8 @@ public function prepare_item_for_response( $user, $request ) { 'id' => $id, 'date_created' => directorist_rest_prepare_date_response( $user->user_registered ), 'name' => $user->display_name, - 'username' => null, //$user->user_login, - 'nickname' => null, //$user->nickname, + 'username' => null, // $user->user_login, + 'nickname' => null, // $user->nickname, 'first_name' => $user->first_name, 'last_name' => $user->last_name, 'description' => $user->description, @@ -583,12 +594,12 @@ public function prepare_item_for_response( $user, $request ) { 'avatar' => null, 'social_links' => null, 'favorite' => null, - 'roles' => null, //array_values( $user->roles ), + 'roles' => null, // array_values( $user->roles ), 'listings_count' => (int) count_user_posts( $id, ATBDP_POST_TYPE, true ), ); foreach ( array_keys( $schema['properties']['social_links']['properties'] ) as $field ) { - $value = get_user_meta( $id, 'atbdp_' . $field, true ); + $value = get_user_meta( $id, 'atbdp_' . $field, true ); $data['social_links'][ $field ] = ( ! empty( $value ) ? $value : null ); } @@ -633,7 +644,7 @@ public function prepare_item_for_response( $user, $request ) { /** * Update user meta fields. * - * @param WP_User $user + * @param WP_User $user * @param WP_REST_Request $request */ protected function update_user_meta_fields( $user, $request ) { @@ -705,7 +716,7 @@ protected function update_user_meta_fields( $user, $request ) { */ protected function prepare_links( $user ) { $links = array( - 'self' => array( + 'self' => array( 'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $user->ID ) ), ), 'collection' => array( @@ -727,13 +738,13 @@ public function get_item_schema() { 'title' => 'user', 'type' => 'object', 'properties' => array( - 'id' => array( + 'id' => array( 'description' => __( 'Unique identifier for the resource.', 'directorist' ), 'type' => 'integer', 'context' => array( 'view', 'edit' ), 'readonly' => true, ), - 'date_created' => array( + 'date_created' => array( 'description' => __( 'The date the user was created, as GMT.', 'directorist' ), 'type' => 'string', 'format' => 'date-time', @@ -745,7 +756,7 @@ public function get_item_schema() { 'type' => 'string', 'context' => array( 'view' ), ), - 'username' => array( + 'username' => array( 'description' => __( 'User login name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -753,12 +764,12 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_user', ), ), - 'nickname' => array( + 'nickname' => array( 'description' => __( 'The nickname for the user.', 'directorist' ), 'type' => 'string', 'context' => array( 'view' ), ), - 'first_name' => array( + 'first_name' => array( 'description' => __( 'User first name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -766,7 +777,7 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_text_field', ), ), - 'last_name' => array( + 'last_name' => array( 'description' => __( 'User last name.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), @@ -774,24 +785,24 @@ public function get_item_schema() { 'sanitize_callback' => 'sanitize_text_field', ), ), - 'description' => array( + 'description' => array( 'description' => __( 'Description of the user.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'email' => array( + 'email' => array( 'description' => __( 'The email address for the user.', 'directorist' ), 'type' => 'string', 'format' => 'email', 'context' => array( 'view', 'edit' ), ), - 'url' => array( + 'url' => array( 'description' => __( 'The website url for the user.', 'directorist' ), 'type' => 'string', 'format' => 'url', 'context' => array( 'view', 'edit' ), ), - 'password' => array( + 'password' => array( 'description' => __( 'User password.', 'directorist' ), 'type' => 'string', 'context' => array( 'edit' ), @@ -801,12 +812,12 @@ public function get_item_schema() { 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'phone' => array( + 'phone' => array( 'description' => __( 'Phone number of the user.', 'directorist' ), 'type' => 'string', 'context' => array( 'view', 'edit' ), ), - 'avatar' => array( + 'avatar' => array( 'description' => __( 'User avatar image data.', 'directorist' ), 'type' => 'object', 'context' => array( 'view', 'edit' ), @@ -848,7 +859,7 @@ public function get_item_schema() { ), ), ), - 'avater' => array( + 'avater' => array( 'description' => __( 'User avatar image data.', 'directorist' ), 'type' => 'object', 'context' => array( 'view', 'edit' ), @@ -890,7 +901,7 @@ public function get_item_schema() { ), ), ), - 'social_links' => array( + 'social_links' => array( 'description' => __( 'User social links.', 'directorist' ), 'type' => 'object', 'context' => array( 'view', 'edit' ), @@ -901,7 +912,7 @@ public function get_item_schema() { 'format' => 'uri', 'context' => array( 'view', 'edit' ), ), - 'twitter' => array( + 'twitter' => array( 'description' => __( 'Twitter profile link.', 'directorist' ), 'type' => 'string', 'format' => 'uri', @@ -913,7 +924,7 @@ public function get_item_schema() { 'format' => 'uri', 'context' => array( 'view', 'edit' ), ), - 'youtube' => array( + 'youtube' => array( 'description' => __( 'Youtube profile link.', 'directorist' ), 'type' => 'string', 'format' => 'uri', @@ -921,7 +932,7 @@ public function get_item_schema() { ), ), ), - 'favorite' => array( + 'favorite' => array( 'description' => __( 'User favorite listing ids.', 'directorist' ), 'type' => 'array', 'items' => array( @@ -968,7 +979,7 @@ public function get_collection_params() { 'description' => __( 'Ensure result set excludes specific IDs.', 'directorist' ), 'type' => 'array', 'items' => array( - 'type' => 'integer', + 'type' => 'integer', ), 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list', @@ -977,45 +988,45 @@ public function get_collection_params() { 'description' => __( 'Limit result set to specific IDs.', 'directorist' ), 'type' => 'array', 'items' => array( - 'type' => 'integer', + 'type' => 'integer', ), 'default' => array(), 'sanitize_callback' => 'wp_parse_id_list', ); - $params['offset'] = array( - 'description' => __( 'Offset the result set by a specific number of items.', 'directorist' ), - 'type' => 'integer', - 'sanitize_callback' => 'absint', - 'validate_callback' => 'rest_validate_request_arg', + $params['offset'] = array( + 'description' => __( 'Offset the result set by a specific number of items.', 'directorist' ), + 'type' => 'integer', + 'sanitize_callback' => 'absint', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['order'] = array( - 'default' => 'asc', - 'description' => __( 'Order sort attribute ascending or descending.', 'directorist' ), - 'enum' => array( 'asc', 'desc' ), - 'sanitize_callback' => 'sanitize_key', - 'type' => 'string', - 'validate_callback' => 'rest_validate_request_arg', + $params['order'] = array( + 'default' => 'asc', + 'description' => __( 'Order sort attribute ascending or descending.', 'directorist' ), + 'enum' => array( 'asc', 'desc' ), + 'sanitize_callback' => 'sanitize_key', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', ); $params['orderby'] = array( - 'default' => 'name', - 'description' => __( 'Sort collection by object attribute.', 'directorist' ), - 'enum' => array_keys( $this->get_orderby_possibles() ), - 'sanitize_callback' => 'sanitize_key', - 'type' => 'string', - 'validate_callback' => 'rest_validate_request_arg', + 'default' => 'name', + 'description' => __( 'Sort collection by object attribute.', 'directorist' ), + 'enum' => array_keys( $this->get_orderby_possibles() ), + 'sanitize_callback' => 'sanitize_key', + 'type' => 'string', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['email'] = array( - 'description' => __( 'Limit result set to resources with a specific email.', 'directorist' ), - 'type' => 'string', - 'format' => 'email', - 'validate_callback' => 'rest_validate_request_arg', + $params['email'] = array( + 'description' => __( 'Limit result set to resources with a specific email.', 'directorist' ), + 'type' => 'string', + 'format' => 'email', + 'validate_callback' => 'rest_validate_request_arg', ); - $params['role'] = array( - 'description' => __( 'Limit result set to resources with a specific role.', 'directorist' ), - 'type' => 'string', - 'default' => 'all', - 'enum' => array_merge( array( 'all' ), $this->get_role_names() ), - 'validate_callback' => 'rest_validate_request_arg', + $params['role'] = array( + 'description' => __( 'Limit result set to resources with a specific role.', 'directorist' ), + 'type' => 'string', + 'default' => 'all', + 'enum' => array_merge( array( 'all' ), $this->get_role_names() ), + 'validate_callback' => 'rest_validate_request_arg', ); return $params; } diff --git a/includes/rest-api/Version1/class-users-favorites-controller.php b/includes/rest-api/Version1/class-users-favorites-controller.php index 610607d742..10653dbb77 100644 --- a/includes/rest-api/Version1/class-users-favorites-controller.php +++ b/includes/rest-api/Version1/class-users-favorites-controller.php @@ -29,7 +29,9 @@ class User_Favorites_Controller extends Abstract_Controller { * Register the routes for terms. */ public function register_routes() { - register_rest_route( $this->namespace, '/' . $this->rest_base, + register_rest_route( + $this->namespace, + '/' . $this->rest_base, array( array( 'methods' => WP_REST_Server::CREATABLE, @@ -50,25 +52,29 @@ public function register_routes() { ) ); - register_rest_route( $this->namespace, '/' . $this->rest_base . '/(?P<id>[\d]+)', array( - 'args' => array( - 'user_id' => array( - 'description' => __( 'User id.', 'directorist' ), - 'type' => 'integer', + register_rest_route( + $this->namespace, + '/' . $this->rest_base . '/(?P<id>[\d]+)', + array( + 'args' => array( + 'user_id' => array( + 'description' => __( 'User id.', 'directorist' ), + 'type' => 'integer', + ), + 'id' => array( + 'description' => __( 'Listing id.', 'directorist' ), + 'type' => 'integer', + ), ), - 'id' => array( - 'description' => __( 'Listing id.', 'directorist' ), - 'type' => 'integer', + array( + 'methods' => WP_REST_Server::DELETABLE, + 'callback' => array( $this, 'delete_item' ), + 'permission_callback' => array( $this, 'delete_item_permissions_check' ), + 'args' => array(), ), - ), - array( - 'methods' => WP_REST_Server::DELETABLE, - 'callback' => array( $this, 'delete_item' ), - 'permission_callback' => array( $this, 'delete_item_permissions_check' ), - 'args' => array(), - ), - 'schema' => array( $this, 'get_public_item_schema' ), - ) ); + 'schema' => array( $this, 'get_public_item_schema' ), + ) + ); } /** @@ -286,5 +292,6 @@ public function get_item_schema() { return $this->add_additional_fields_schema( $schema ); } } -/* This code is retrieving the user meta data for the user ID of the user that is logged +/* +This code is retrieving the user meta data for the user ID of the user that is logged in. */ diff --git a/includes/rest-api/class-datetime.php b/includes/rest-api/class-datetime.php index 67f59d4ccf..b22c60caa1 100644 --- a/includes/rest-api/class-datetime.php +++ b/includes/rest-api/class-datetime.php @@ -48,7 +48,7 @@ public function set_utc_offset( $offset ) { * @return int */ #[\ReturnTypeWillChange] - public function getOffset() : int { + public function getOffset(): int { return $this->utc_offset ? $this->utc_offset : parent::getOffset(); } @@ -58,8 +58,8 @@ public function getOffset() : int { * @param DateTimeZone $timezone DateTimeZone instance. * @return DateTime */ - #[\ReturnTypeWillChange] - public function setTimezone( $timezone ) : DateTime { + #[\ReturnTypeWillChange] + public function setTimezone( $timezone ): DateTime { $this->utc_offset = 0; return parent::setTimezone( $timezone ); } diff --git a/includes/rest-api/filter-functions.php b/includes/rest-api/filter-functions.php index 14c44d5059..dfc91626bf 100644 --- a/includes/rest-api/filter-functions.php +++ b/includes/rest-api/filter-functions.php @@ -7,9 +7,9 @@ /** * Allow rest api endpoint permission to all read context requests. * - * @param boolen $permission - * @param string $context - * @param integer $object_id + * @param boolen $permission + * @param string $context + * @param integer $object_id * @param string @object_type * * @return boolen diff --git a/includes/rest-api/functions.php b/includes/rest-api/functions.php index bfa01d1bf2..2107be43f3 100644 --- a/includes/rest-api/functions.php +++ b/includes/rest-api/functions.php @@ -9,10 +9,11 @@ * * Required WP 4.4 or later. * See https://developer.wordpress.org/reference/functions/mysql_to_rfc3339/ + * * @see wc_rest_prepare_date_response * * @param string|null|Directorist_DateTime $date Date. - * @param bool $utc Send false to get local/offset time. + * @param bool $utc Send false to get local/offset time. * @return string|null ISO8601/RFC3339 formatted datetime. */ function directorist_rest_prepare_date_response( $date, $utc = true ) { @@ -131,10 +132,10 @@ function directorist_rest_upload_image_from_url( $image_url ) { // Add extension to the name when downloaded from extension less url if ( strrpos( $file_array['name'], '.' ) === false ) { - $mime_type = mime_content_type( $file_array['tmp_name'] ); - $_mime_types = array_flip( $allowed_mime_types ); - $extensions = $_mime_types[ $mime_type ] ?? ''; - $extensions = explode( '|', $extensions, 2 ); + $mime_type = mime_content_type( $file_array['tmp_name'] ); + $_mime_types = array_flip( $allowed_mime_types ); + $extensions = $_mime_types[ $mime_type ] ?? ''; + $extensions = explode( '|', $extensions, 2 ); $file_array['name'] .= '.' . $extensions[0]; } @@ -366,4 +367,4 @@ function directorist_rest_check_user_favorite_permissions( $context = 'read', $o $permission = current_user_can( $contexts[ $context ], $object_id ); return apply_filters( 'directorist_rest_check_permissions', $permission, $context, $object_id, 'user_favorite' ); -} \ No newline at end of file +} diff --git a/includes/review/class-admin.php b/includes/review/class-admin.php index 265d88baac..6996f62d7c 100644 --- a/includes/review/class-admin.php +++ b/includes/review/class-admin.php @@ -7,6 +7,7 @@ * @since 7.1.0 */ namespace Directorist\Review; + use Directorist\Directorist_Single_Listing; if ( ! defined( 'ABSPATH' ) ) { @@ -16,16 +17,16 @@ class Metabox { public static function init() { - add_action( 'admin_menu', [ __CLASS__, 'add_menu' ] ); - add_action( 'add_meta_boxes_comment', [ __CLASS__, 'register' ] ); - add_action( 'edit_comment', [ __CLASS__, 'on_edit_comment' ], 10, 2 ); - add_action( 'add_meta_boxes', [ __CLASS__, 'update_meta_boxes' ], 20 ); - add_filter( 'admin_comment_types_dropdown', [ __CLASS__, 'add_comment_types_in_dropdown' ] ); + add_action( 'admin_menu', array( __CLASS__, 'add_menu' ) ); + add_action( 'add_meta_boxes_comment', array( __CLASS__, 'register' ) ); + add_action( 'edit_comment', array( __CLASS__, 'on_edit_comment' ), 10, 2 ); + add_action( 'add_meta_boxes', array( __CLASS__, 'update_meta_boxes' ), 20 ); + add_filter( 'admin_comment_types_dropdown', array( __CLASS__, 'add_comment_types_in_dropdown' ) ); - add_action( 'directorist/admin/review/meta_fields', [ __CLASS__, 'render_rating_meta_field' ] ); + add_action( 'directorist/admin/review/meta_fields', array( __CLASS__, 'render_rating_meta_field' ) ); - add_filter( 'comment_edit_redirect', [ __CLASS__, 'comment_edit_redirect' ], 10, 2 ); - add_filter( 'wp_update_comment_data', [ __CLASS__, 'update_comment_data' ], 10, 2 ); + add_filter( 'comment_edit_redirect', array( __CLASS__, 'comment_edit_redirect' ), 10, 2 ); + add_filter( 'wp_update_comment_data', array( __CLASS__, 'update_comment_data' ), 10, 2 ); } public static function update_comment_data( $data, $comment ) { @@ -40,10 +41,12 @@ public static function update_comment_data( $data, $comment ) { public static function comment_edit_redirect( $location, $comment_id ) { if ( ! current_user_can( 'moderate_comments' ) ) { - return add_query_arg( array( - 'action' => 'editcomment', - 'c' => $comment_id, - ) ); + return add_query_arg( + array( + 'action' => 'editcomment', + 'c' => $comment_id, + ) + ); } return $location; @@ -73,7 +76,7 @@ public static function add_menu() { return; } - $menu_slug = 'edit.php?post_type='. ATBDP_POST_TYPE; + $menu_slug = 'edit.php?post_type=' . ATBDP_POST_TYPE; $submenu_slug = 'edit-comments.php?post_type=' . ATBDP_POST_TYPE; add_submenu_page( @@ -82,7 +85,7 @@ public static function add_menu() { __( 'Reviews', 'directorist' ), 'edit_posts', $submenu_slug - ); + ); // Make sure "Reviews" menu is active global $submenu, $pagenow; @@ -154,12 +157,14 @@ public static function render_meta_fields( $comment ) { } public static function render_rating_meta_field( $comment ) { - $listing = Directorist_Single_Listing::instance( $comment->comment_post_ID ); - $section_data = $listing->get_review_section_data(); - $builder = Builder::get( $section_data['section_data'] ); - $rating = Comment_Meta::get_rating( $comment->comment_ID, 0 ); - - if ( $builder->is_rating_type_single() ) : $r = floor( $rating ); ?> + $listing = Directorist_Single_Listing::instance( $comment->comment_post_ID ); + $section_data = $listing->get_review_section_data(); + $builder = Builder::get( $section_data['section_data'] ); + $rating = Comment_Meta::get_rating( $comment->comment_ID, 0 ); + + if ( $builder->is_rating_type_single() ) : + $r = floor( $rating ); + ?> <tr> <th><?php esc_html_e( 'Rating', 'directorist' ); ?></th> <td> @@ -173,7 +178,8 @@ public static function render_rating_meta_field( $comment ) { </select> </td> </tr> - <?php endif; + <?php + endif; } } diff --git a/includes/review/class-bc-review-rating.php b/includes/review/class-bc-review-rating.php index d225f8c77e..7043968a35 100644 --- a/includes/review/class-bc-review-rating.php +++ b/includes/review/class-bc-review-rating.php @@ -36,12 +36,12 @@ public function __construct() { * @return string */ public function print_static_rating( $star_number = 1 ) { - $v ='<ul>'; - for ( $i=1; $i<=5; $i++ ) { - $v .= ( $i <= $star_number ) - ? "<li><span class='directorist-rate-active'></span></li>" - : "<li><span class='directorist-rate-disable'></span></li>"; - } + $v = '<ul>'; + for ( $i = 1; $i <= 5; $i++ ) { + $v .= ( $i <= $star_number ) + ? "<li><span class='directorist-rate-active'></span></li>" + : "<li><span class='directorist-rate-disable'></span></li>"; + } $v .= '</ul>'; return $v; @@ -142,7 +142,7 @@ public function get_ratings_by( $field = 'id', $value = 0, $limit = PHP_INT_MAX } $comments_query = new WP_Comment_Query( $args ); - $comments = $comments_query->comments; + $comments = $comments_query->comments; if ( empty( $comments ) ) { return false; @@ -151,7 +151,7 @@ public function get_ratings_by( $field = 'id', $value = 0, $limit = PHP_INT_MAX $data = array(); foreach ( $comments as $comment_id ) { $data[] = (object) array( - 'rating' => (int) \Directorist\Review\Comment_Meta::get_rating( $comment_id ) + 'rating' => (int) \Directorist\Review\Comment_Meta::get_rating( $comment_id ), ); } unset( $comments, $comments_query ); diff --git a/includes/review/class-builder-screen.php b/includes/review/class-builder-screen.php index 718e795cfc..443c995cf8 100644 --- a/includes/review/class-builder-screen.php +++ b/includes/review/class-builder-screen.php @@ -14,9 +14,9 @@ class Builder_Screen { public static function init() { - add_filter( 'directorist/builder/config', [ __CLASS__, 'register_config' ] ); - add_filter( 'directorist/builder/fields', [ __CLASS__, 'register_fields' ] ); - add_filter( 'directorist/builder/layouts', [ __CLASS__, 'register_layout' ] ); + add_filter( 'directorist/builder/config', array( __CLASS__, 'register_config' ) ); + add_filter( 'directorist/builder/fields', array( __CLASS__, 'register_fields' ) ); + add_filter( 'directorist/builder/layouts', array( __CLASS__, 'register_layout' ) ); } public static function register_config( $config ) { @@ -28,7 +28,7 @@ public static function register_layout( $layouts ) { } public static function get_fields() { - $fields = []; + $fields = array(); return $fields; } diff --git a/includes/review/class-builder.php b/includes/review/class-builder.php index 0a8cada2ff..1dfd8af962 100644 --- a/includes/review/class-builder.php +++ b/includes/review/class-builder.php @@ -6,6 +6,7 @@ * @since 8.0 */ namespace Directorist\Review; + use ATBDP_Permalink; if ( ! defined( 'ABSPATH' ) ) { @@ -14,12 +15,12 @@ class Builder { - protected $fields = array(); + protected $fields = array(); protected $cookies_consent; protected $gdpr_consent; protected $gdpr_consent_label; protected $rating_type; - private static $instance = null; + private static $instance = null; public static function get( $data ) { if ( is_null( self::$instance ) ) { @@ -31,17 +32,17 @@ public static function get( $data ) { private function __construct( $data ) { $this->load_data( $data ); - $this->cookies_consent = ! empty( $data['review_cookies_consent'] ) ? true : false; - $this->gdpr_consent = ! empty( $data['review_enable_gdpr_consent'] ) ? true : false; - $this->rating_type = ! empty( $data['rating_type'] ) ? $data['rating_type'] : 'single'; - $this->gdpr_consent_label = ! empty( $data['review_gdpr_consent_label'] ) ? $data['review_gdpr_consent_label'] : sprintf( - __( 'I have read and agree to the <a href="%s" target="_blank">Privacy Policy</a> and <a href="%s" target="_blank">Terms of Service</a>', 'directorist' ), + $this->cookies_consent = ! empty( $data['review_cookies_consent'] ) ? true : false; + $this->gdpr_consent = ! empty( $data['review_enable_gdpr_consent'] ) ? true : false; + $this->rating_type = ! empty( $data['rating_type'] ) ? $data['rating_type'] : 'single'; + $this->gdpr_consent_label = ! empty( $data['review_gdpr_consent_label'] ) ? $data['review_gdpr_consent_label'] : sprintf( + __( 'I have read and agree to the <a href="%1$s" target="_blank">Privacy Policy</a> and <a href="%2$s" target="_blank">Terms of Service</a>', 'directorist' ), esc_url( ATBDP_Permalink::get_privacy_policy_page_url() ), esc_url( ATBDP_Permalink::get_terms_and_conditions_page_url() ) - );; + ); } - public function load_data( $data ) { + public function load_data( $data ) { $this->fields = $data['fields'] ?? array(); } diff --git a/includes/review/class-comment-form-processor.php b/includes/review/class-comment-form-processor.php index 38fbe261cd..a5cdbf7c5a 100644 --- a/includes/review/class-comment-form-processor.php +++ b/includes/review/class-comment-form-processor.php @@ -18,7 +18,7 @@ class Comment_Form_Processor { const AJAX_ACTION = 'directorist_process_comment_form'; public static function init() { - add_action( 'wp_ajax_' . self::AJAX_ACTION , array( __CLASS__, 'process' ) ); + add_action( 'wp_ajax_' . self::AJAX_ACTION, array( __CLASS__, 'process' ) ); add_action( 'wp_ajax_nopriv_' . self::AJAX_ACTION, array( __CLASS__, 'process' ) ); } @@ -49,10 +49,12 @@ public static function process() { $comment_type_label = $is_review ? __( 'review', 'directorist' ) : __( 'comment', 'directorist' ); if ( ! is_user_logged_in() ) { - throw new Exception( sprintf( - __( 'Please login to update your %s.', 'directorist' ), - $comment_type_label - ) ); + throw new Exception( + sprintf( + __( 'Please login to update your %s.', 'directorist' ), + $comment_type_label + ) + ); } if ( ! current_user_can( 'edit_comment', $comment_id ) ) { @@ -82,7 +84,7 @@ public static function process() { 'comment_ID' => $comment->comment_ID, 'comment_post_ID' => $comment->comment_post_ID, 'comment_type' => $comment->comment_type, - 'comment_content' => $comment_content + 'comment_content' => $comment_content, ); $updated_comment = wp_update_comment( $comment_data, true ); @@ -97,7 +99,7 @@ public static function process() { Comment::post_rating( $comment_id, $comment_data, $_POST ); Comment::clear_transients( $comment->comment_post_ID ); - $cpage = isset( $_POST['cpage'] ) ? absint( $_POST['cpage'] ) : 0; + $cpage = isset( $_POST['cpage'] ) ? absint( $_POST['cpage'] ) : 0; $redirect_to = get_permalink( $comment->comment_post_ID ); if ( $cpage ) { $redirect_to = add_query_arg( 'cpage', $cpage, $redirect_to ); @@ -106,21 +108,21 @@ public static function process() { /** * @since 7.7.0 - * */ do_action( 'directorist_review_updated', $comment_id, $comment_data ); - wp_safe_redirect( $redirect_to ); exit; } catch ( Exception $e ) { $html = sprintf( '<div class="directorist-alert directorist-alert-danger">%s</div>', $e->getMessage() ); - wp_send_json_error( array( - 'error' => $e->getMessage(), - 'html' => $html, - ) ); + wp_send_json_error( + array( + 'error' => $e->getMessage(), + 'html' => $html, + ) + ); } } } diff --git a/includes/review/class-comment-form-renderer.php b/includes/review/class-comment-form-renderer.php index 41f4949f70..f579101e23 100644 --- a/includes/review/class-comment-form-renderer.php +++ b/includes/review/class-comment-form-renderer.php @@ -28,7 +28,7 @@ public static function get_ajax_url() { array( 'action' => self::AJAX_ACTION, 'nonce' => wp_create_nonce( self::AJAX_ACTION ), - 'cpage' => get_query_var( 'cpage' ) + 'cpage' => get_query_var( 'cpage' ), ), admin_url( 'admin-ajax.php', 'relative' ) ); @@ -67,10 +67,12 @@ public static function render() { $comment_type_label = $is_review ? __( 'review', 'directorist' ) : __( 'comment', 'directorist' ); if ( ! is_user_logged_in() ) { - throw new Exception( sprintf( - __( 'Please login to update your %s.', 'directorist' ), - $comment_type_label - ) ); + throw new Exception( + sprintf( + __( 'Please login to update your %s.', 'directorist' ), + $comment_type_label + ) + ); } if ( ! current_user_can( 'edit_comment', $comment_id ) ) { @@ -79,17 +81,21 @@ public static function render() { $form = self::get_form_markup( $comment ); - wp_send_json_success( array( - 'error' => '', - 'html' => $form, - ) ); + wp_send_json_success( + array( + 'error' => '', + 'html' => $form, + ) + ); } catch ( Exception $e ) { $html = sprintf( '<div class="directorist-alert directorist-alert-danger">%s</div>', $e->getMessage() ); - wp_send_json_error( array( - 'error' => $e->getMessage(), - 'html' => $html, - ) ); + wp_send_json_error( + array( + 'error' => $e->getMessage(), + 'html' => $html, + ) + ); } } @@ -135,16 +141,16 @@ public static function get_form_markup( $comment ) { } public static function get_fields( $comment ) { - $fields = array(); - + $fields = array(); + $comment_type = __( 'comment', 'directorist' ); if ( $comment->comment_type === 'review' ) { - $rating = Comment::get_rating( $comment->comment_ID ); + $rating = Comment::get_rating( $comment->comment_ID ); $fields['rating'] = '<div class="directorist-review-criteria directorist-adv-criteria">' . Markup::get_rating( $rating, $comment ) . '</div>'; - $comment_type = __( 'review', 'directorist' ); + $comment_type = __( 'review', 'directorist' ); } - - $fields['content'] = sprintf( + + $fields['content'] = sprintf( '<div class="directorist-form-group form-group-comment">%s</div>', sprintf( '<textarea id="comment" class="directorist-form-element" placeholder="%s" name="comment" cols="30" rows="10" maxlength="65525" required="required">%s</textarea>', @@ -152,15 +158,15 @@ public static function get_fields( $comment ) { esc_textarea( $comment->comment_content ) ) ); - + // Add custom action hook after textarea ob_start(); - do_action('directorist_after_comment_textarea', $comment); + do_action( 'directorist_after_comment_textarea', $comment ); $fields['after_textarea'] = ob_get_clean(); - + return $fields; } - + public static function get_action_url() { return admin_url( 'admin-ajax.php', 'relative' ); @@ -172,7 +178,7 @@ public static function get_action_url() { * @see comment_form() wp core function. Directly copied from there and renamed filters. * * @param array $args - * @param int $post_id + * @param int $post_id * * @return void */ @@ -250,7 +256,7 @@ public static function comment_form( $args = array(), $post_id = null ) { ), ); - if ( $builder->is_gdpr_consent() ) { + if ( $builder->is_gdpr_consent() ) { $args['fields']['gdpr_consent'] = sprintf( '<p class="comment-form-gdpr-consent comment-form-cookies-consent"> <input id="directorist-gdpr-consent" name="directorist-gdpr-consent" type="checkbox" value="yes" required /> @@ -396,8 +402,6 @@ public static function comment_form( $args = array(), $post_id = null ) { // echo $args['cancel_reply_before']; - - // echo $args['cancel_reply_after']; echo wp_kses_post( $args['title_reply_after'] ); diff --git a/includes/review/class-comment-meta.php b/includes/review/class-comment-meta.php index b2d45d6d29..8292abf64f 100644 --- a/includes/review/class-comment-meta.php +++ b/includes/review/class-comment-meta.php @@ -17,10 +17,10 @@ class Comment_Meta { const FIELD_REPORT = 'reported'; - public static $valid_fields = [ + public static $valid_fields = array( self::FIELD_RATING, self::FIELD_REPORT, - ]; + ); protected static function is_valid_field( $field_key ) { return in_array( $field_key, self::$valid_fields, true ); diff --git a/includes/review/class-comment.php b/includes/review/class-comment.php index 7aed2f4413..c5d54cfe39 100644 --- a/includes/review/class-comment.php +++ b/includes/review/class-comment.php @@ -17,28 +17,28 @@ class Comment { public static function init() { // Rating posts. - add_filter( 'comments_open', [ __CLASS__, 'comments_open' ], 10, 2 ); - add_filter( 'preprocess_comment', [ __CLASS__, 'validate_data' ], 0 ); - add_action( 'comment_post', [ __CLASS__, 'on_comment_post' ], 10, 3 ); + add_filter( 'comments_open', array( __CLASS__, 'comments_open' ), 10, 2 ); + add_filter( 'preprocess_comment', array( __CLASS__, 'validate_data' ), 0 ); + add_action( 'comment_post', array( __CLASS__, 'on_comment_post' ), 10, 3 ); // Support avatars for `review` comment type. - add_filter( 'get_avatar_comment_types', [ __CLASS__, 'set_avater_comment_types' ] ); + add_filter( 'get_avatar_comment_types', array( __CLASS__, 'set_avater_comment_types' ) ); // Clear transients. - add_action( 'wp_update_comment_count', [ __CLASS__, 'clear_transients'] ); + add_action( 'wp_update_comment_count', array( __CLASS__, 'clear_transients' ) ); // Set comment type. - add_filter( 'preprocess_comment', [ __CLASS__, 'preprocess_comment_data' ], 1 ); + add_filter( 'preprocess_comment', array( __CLASS__, 'preprocess_comment_data' ), 1 ); // Set comment approval - add_filter( 'pre_comment_approved', [ __CLASS__, 'set_comment_status' ], 10, 2 ); + add_filter( 'pre_comment_approved', array( __CLASS__, 'set_comment_status' ), 10, 2 ); // Count comments. - add_filter( 'wp_count_comments', [ __CLASS__, 'wp_count_comments' ], 10, 2 ); + add_filter( 'wp_count_comments', array( __CLASS__, 'wp_count_comments' ), 10, 2 ); // Delete comments count cache whenever there is a new comment or a comment status changes. - add_action( 'wp_insert_comment', [ __CLASS__, 'delete_comments_count_cache' ] ); - add_action( 'wp_set_comment_status', [ __CLASS__, 'delete_comments_count_cache' ] ); + add_action( 'wp_insert_comment', array( __CLASS__, 'delete_comments_count_cache' ) ); + add_action( 'wp_set_comment_status', array( __CLASS__, 'delete_comments_count_cache' ) ); } /** @@ -78,21 +78,24 @@ public static function validate_data( $comment_data ) { throw new Exception( __( '<strong>Error</strong>: You must login to share review.', 'directorist' ), 401 ); } $post_id = absint( $_POST['comment_post_ID'] ); // @codingStandardsIgnoreLine. - $listing = Directorist_Single_Listing::instance( $post_id ); - $section_data = $listing->get_review_section_data(); - $builder = Builder::get( $section_data['section_data'] ); + $listing = Directorist_Single_Listing::instance( $post_id ); + $section_data = $listing->get_review_section_data(); + $builder = Builder::get( $section_data['section_data'] ); if ( $builder->is_gdpr_consent() && ! isset( $_POST['directorist-gdpr-consent'] ) ) { - throw new Exception( sprintf( + throw new Exception( + sprintf( /** translators: %1$s gdpr consent label */ - __( '<strong>Error</strong>: Please agree to - %1$s', 'directorist' ), - $builder->gdpr_consent_label() - ), 400 ); + __( '<strong>Error</strong>: Please agree to - %1$s', 'directorist' ), + $builder->gdpr_consent_label() + ), + 400 + ); } - $user_id = $comment_data['user_ID']; - $author_email = $comment_data['comment_author_email']; - $errors = array(); + $user_id = $comment_data['user_ID']; + $author_email = $comment_data['comment_author_email']; + $errors = array(); if ( isset( $_POST['comment_parent'], $_POST['rating'], $comment_data['comment_type'] ) && // @codingStandardsIgnoreLine. $comment_data['comment_parent'] === 0 && self::is_default_comment_type( $comment_data['comment_type'] ) ) { @@ -122,7 +125,7 @@ public static function validate_data( $comment_data ) { } do_action( 'directorist_review_validate_data', $comment_data ); - } catch( Exception $e ) { + } catch ( Exception $e ) { wp_die( wp_kses_post( $e->getMessage() ) ); exit; } @@ -220,10 +223,10 @@ public static function preprocess_comment_data( $comment_data ) { return $comment_data; } - $listing = Directorist_Single_Listing::instance( absint( $_POST['comment_post_ID'] ) ); - $section_data = $listing->get_review_section_data(); - $builder = Builder::get( $section_data['section_data'] ); - + $listing = Directorist_Single_Listing::instance( absint( $_POST['comment_post_ID'] ) ); + $section_data = $listing->get_review_section_data(); + $builder = Builder::get( $section_data['section_data'] ); + if ( isset( $_POST['comment_parent'], $_POST['rating'], $comment_data['comment_type'] ) && // @codingStandardsIgnoreLine. $comment_data['comment_parent'] === 0 && self::is_default_comment_type( $comment_data['comment_type'] ) && ( $builder->is_rating_type_single() && ! empty( $_POST['rating'] ) ) ) { // @codingStandardsIgnoreLine. @@ -251,8 +254,8 @@ public static function set_comment_status( $approved, $comment_data ) { return $approved; } - $pending = 0; - $approve = 1; + $pending = 0; + $approve = 1; $is_review = ( $comment_data['comment_type'] === 'review' ); if ( directorist_is_guest_review_enabled() && ! is_user_logged_in() && $is_review ) { @@ -438,10 +441,10 @@ public static function post_rating( $comment_id, $comment_data, $posted_data ) { return; } - $listing = Directorist_Single_Listing::instance( absint( $comment_data['comment_post_ID'] ) ); - $section_data = $listing->get_review_section_data(); - $builder = Builder::get( $section_data['section_data'] ); - $rating = 0; + $listing = Directorist_Single_Listing::instance( absint( $comment_data['comment_post_ID'] ) ); + $section_data = $listing->get_review_section_data(); + $builder = Builder::get( $section_data['section_data'] ); + $rating = 0; if ( $builder->is_rating_type_single() ) { $rating = is_array( $posted_data['rating'] ) ? current( $posted_data['rating'] ) : $posted_data['rating']; diff --git a/includes/review/class-email.php b/includes/review/class-email.php index 1595920dc1..c410521743 100644 --- a/includes/review/class-email.php +++ b/includes/review/class-email.php @@ -14,10 +14,10 @@ class Email { public static function init() { - add_action( 'comment_post', [ __CLASS__, 'notify_owner' ] ); - add_action( 'comment_post', [ __CLASS__, 'notify_admin' ] ); + add_action( 'comment_post', array( __CLASS__, 'notify_owner' ) ); + add_action( 'comment_post', array( __CLASS__, 'notify_admin' ) ); - add_action( 'comment_post', [ __CLASS__, 'maybe_disable_default_email' ], 0 ); + add_action( 'comment_post', array( __CLASS__, 'maybe_disable_default_email' ), 0 ); } public static function maybe_disable_default_email() { @@ -77,17 +77,17 @@ public static function notify_owner( $comment_id ) { $subject = __( '[{site_name}] New review at "{listing_title}"', 'directorist' ); $subject = strtr( $subject, $placeholders ); - $message = __( "Dear User,<br /><br />A new review at {listing_url}.<br /><br />Name: {sender_name}<br />Email: {sender_email}<br />Review: {message}", 'directorist' ); + $message = __( 'Dear User,<br /><br />A new review at {listing_url}.<br /><br />Name: {sender_name}<br />Email: {sender_email}<br />Review: {message}', 'directorist' ); $message = strtr( $message, $placeholders ); - $headers = "From: {$review->comment_author_email} <{$review->comment_author_email}>\r\n"; + $headers = "From: {$review->comment_author_email} <{$review->comment_author_email}>\r\n"; $headers .= "Reply-To: {$review->comment_author_email}\r\n"; return ATBDP()->email->send_mail( $user->user_email, $subject, $message, $headers ); } public static function notify_admin( $comment_id ) { - if ( ! directorist_admin_notifiable_for( 'listing_review' ) ) { + if ( ! directorist_admin_notifiable_for( 'listing_review' ) ) { return false; } @@ -96,12 +96,12 @@ public static function notify_admin( $comment_id ) { return false; } - $post = get_post( $review->comment_post_ID ); - $site_name = get_bloginfo( 'name' ); - $site_url = get_bloginfo( 'url' ); - $listing_title = get_the_title( $post->ID ); - $listing_url = get_the_permalink( $post->ID ); - $listing_url = sprintf( '<a href="%s">%s</a>', $listing_url, $listing_url ); + $post = get_post( $review->comment_post_ID ); + $site_name = get_bloginfo( 'name' ); + $site_url = get_bloginfo( 'url' ); + $listing_title = get_the_title( $post->ID ); + $listing_url = get_the_permalink( $post->ID ); + $listing_url = sprintf( '<a href="%s">%s</a>', $listing_url, $listing_url ); $comment_author = empty( $review->comment_author ) ? $review->comment_author_email : $review->comment_author; $to = get_directorist_option( 'admin_email_lists' ); @@ -110,10 +110,10 @@ public static function notify_admin( $comment_id ) { $to = get_bloginfo( 'admin_email' ); } - $subject = "[$site_name] New review at $listing_title"; - $message = __( "Dear Admin,<br /><br />A new review at $listing_url.<br /><br />Name: $comment_author<br />Email: $review->comment_author_email<br />Review: $review->comment_content", 'directorist' ); - $message = atbdp_email_html( $subject, $message ); - $headers = "From: {$review->comment_author_email} <{$review->comment_author_email}>\r\n"; + $subject = "[$site_name] New review at $listing_title"; + $message = __( "Dear Admin,<br /><br />A new review at $listing_url.<br /><br />Name: $comment_author<br />Email: $review->comment_author_email<br />Review: $review->comment_content", 'directorist' ); + $message = atbdp_email_html( $subject, $message ); + $headers = "From: {$review->comment_author_email} <{$review->comment_author_email}>\r\n"; $headers .= "Reply-To: {$review->comment_author_email}\r\n"; return ATBDP()->email->send_mail( $to, $subject, $message, $headers ); diff --git a/includes/review/class-markup.php b/includes/review/class-markup.php index fa76f55130..905a915c87 100644 --- a/includes/review/class-markup.php +++ b/includes/review/class-markup.php @@ -34,7 +34,7 @@ public static function get_rating( $selected = 0, $comment = null ) { } private static function convert_to_num( $input ) { - + $numericValue = 0; if ( strpos( $input, '.' ) !== false ) { $numericValue = floatval( $input ); @@ -47,19 +47,19 @@ private static function convert_to_num( $input ) { public static function get_rating_stars( $rating = 0, $base_rating = 5 ) { $rating = max( 0, min( $base_rating, $rating ) ); - $empty_star = ''; - $full_star = ''; - $counter = 0; - $rating = self::convert_to_num( $rating ); + $empty_star = ''; + $full_star = ''; + $counter = 0; + $rating = self::convert_to_num( $rating ); $rounded_rating = floor( $rating ); $full_star = str_repeat( directorist_icon( 'fas fa-star', false, 'star-full' ), $rounded_rating ); - while( $counter <= $base_rating - ( $rounded_rating + 1 ) ) { - $empty_star .= directorist_icon( 'far fa-star', false, ( ( $counter === 0 ) && ( is_float( $rating ) ) ) ? 'star-empty directorist_fraction_star' : 'star-empty' ); - $counter++; + while ( $counter <= $base_rating - ( $rounded_rating + 1 ) ) { + $empty_star .= directorist_icon( 'far fa-star', false, ( ( $counter === 0 ) && ( is_float( $rating ) ) ) ? 'star-empty directorist_fraction_star' : 'star-empty' ); + ++$counter; } - + return $full_star . $empty_star; } diff --git a/includes/review/class-review-walker.php b/includes/review/class-review-walker.php index 41706c8329..e8b55ecd78 100644 --- a/includes/review/class-review-walker.php +++ b/includes/review/class-review-walker.php @@ -171,8 +171,8 @@ protected function html5_comment( $comment, $depth, $args ) { $args, array( 'edit_text' => sprintf( __( '%s Edit', 'directorist' ), directorist_icon( 'fas fa-pencil-alt', false ) ), - 'depth' => $depth, - 'max_depth' => $args['max_depth'] + 'depth' => $depth, + 'max_depth' => $args['max_depth'], ) ) ); @@ -180,7 +180,7 @@ protected function html5_comment( $comment, $depth, $args ) { if ( $edit_link ) { echo wp_kses_post( $edit_link ); - + } ?> </div> diff --git a/includes/review/class-settings-screen.php b/includes/review/class-settings-screen.php index 5e0098f6cd..205e848719 100644 --- a/includes/review/class-settings-screen.php +++ b/includes/review/class-settings-screen.php @@ -14,176 +14,182 @@ class Settings_Screen { public static function init() { - add_filter( 'atbdp_listing_type_settings_layout', [ __CLASS__, 'register_layout' ] ); - add_filter( 'atbdp_listing_type_settings_field_list', [ __CLASS__, 'register_fields' ] ); + add_filter( 'atbdp_listing_type_settings_layout', array( __CLASS__, 'register_layout' ) ); + add_filter( 'atbdp_listing_type_settings_field_list', array( __CLASS__, 'register_fields' ) ); } public static function register_layout( $layout ) { if ( ! isset( $layout['listing_settings']['submenu']['review'] ) ) { - $layout['listing_settings']['submenu']['review'] = [ - 'label' => __( 'Review', 'directorist' ), - 'icon' => '<i class="fa fa-star"></i>', - 'sections' => apply_filters( 'atbdp_listing_settings_review_sections', [ - 'review_options' => [ - 'title' => __( 'Review Options', 'directorist' ), - 'fields' => [ - 'enable_review', 'enable_owner_review', 'guest_review', 'review_enable_reply' - ], - ], - 'moderation_options' => [ - 'title' => __( 'Moderation Option', 'directorist' ), - 'fields' => [ - 'approve_immediately' - ], - ], - 'display_settings' => [ - 'title' => __( 'Display Setting', 'directorist' ), - 'fields' => [ - 'review_num' - ], - ], - ] ), - ]; + $layout['listing_settings']['submenu']['review'] = array( + 'label' => __( 'Review', 'directorist' ), + 'icon' => '<i class="fa fa-star"></i>', + 'sections' => apply_filters( + 'atbdp_listing_settings_review_sections', + array( + 'review_options' => array( + 'title' => __( 'Review Options', 'directorist' ), + 'fields' => array( + 'enable_review', + 'enable_owner_review', + 'guest_review', + 'review_enable_reply', + ), + ), + 'moderation_options' => array( + 'title' => __( 'Moderation Option', 'directorist' ), + 'fields' => array( + 'approve_immediately', + ), + ), + 'display_settings' => array( + 'title' => __( 'Display Setting', 'directorist' ), + 'fields' => array( + 'review_num', + ), + ), + ) + ), + ); } return $layout; } public static function get_fields() { - return [ - 'enable_review' => [ + return array( + 'enable_review' => array( 'type' => 'toggle', 'label' => __( 'Enable User Reviews', 'directorist' ), 'description' => __( 'Let customers and listing owners leave reviews on listings.', 'directorist' ), 'value' => true, - ], - 'enable_owner_review' => [ + ), + 'enable_owner_review' => array( 'type' => 'toggle', - 'label' => __( 'Enable Owner Reviews', 'directorist'), + 'label' => __( 'Enable Owner Reviews', 'directorist' ), 'description' => __( 'Allow listing owners to review their own listings.', 'directorist' ), 'value' => true, - 'show-if' => [ + 'show-if' => array( 'where' => 'enable_review', - 'conditions' => [ - [ + 'conditions' => array( + array( 'key' => 'value', 'compare' => '=', - 'value' => true - ], - ], - ], - ], - 'guest_review' => [ + 'value' => true, + ), + ), + ), + ), + 'guest_review' => array( 'type' => 'toggle', 'label' => __( 'Enable Guest Reviews', 'directorist' ), 'description' => __( 'Allow non-logged-in users to leave reviews (subject to moderation).', 'directorist' ), 'value' => false, - 'show-if' => [ + 'show-if' => array( 'where' => 'enable_review', - 'conditions' => [ - [ + 'conditions' => array( + array( 'key' => 'value', 'compare' => '=', - 'value' => true - ], - ], - ], - ], - 'approve_immediately' => [ - 'type' => 'toggle', - 'label' => __( 'Auto-Approve Reviews', 'directorist' ), + 'value' => true, + ), + ), + ), + ), + 'approve_immediately' => array( + 'type' => 'toggle', + 'label' => __( 'Auto-Approve Reviews', 'directorist' ), 'description' => __( 'Automatically approve all submitted reviews without moderation.', 'directorist' ), - 'value' => true, - 'show-if' => [ + 'value' => true, + 'show-if' => array( 'where' => 'enable_review', - 'conditions' => [ - [ + 'conditions' => array( + array( 'key' => 'value', 'compare' => '=', - 'value' => true - ], - ], - ], - ], - 'review_enable_reply' => [ + 'value' => true, + ), + ), + ), + ), + 'review_enable_reply' => array( 'type' => 'toggle', 'label' => __( 'Allow Review Replies', 'directorist' ), 'description' => __( 'Let users reply to reviews or comments.', 'directorist' ), 'value' => false, - 'show-if' => [ + 'show-if' => array( 'where' => 'enable_review', - 'conditions' => [ - [ + 'conditions' => array( + array( 'key' => 'value', 'compare' => '=', - 'value' => true - ], - ], - ], - ], + 'value' => true, + ), + ), + ), + ), // 'review_approval_text' => [ - // 'type' => 'textarea', - // 'label' => __( 'Approval Notification Text', 'directorist'), - // 'value' => __( 'We have received your review. It requires approval.', 'directorist' ), - // 'show-if' => [ - // 'where' => 'enable_review', - // 'conditions' => [ - // [ - // 'key' => 'value', - // 'compare' => '=', - // 'value' => true - // ], - // ], - // ], + // 'type' => 'textarea', + // 'label' => __( 'Approval Notification Text', 'directorist'), + // 'value' => __( 'We have received your review. It requires approval.', 'directorist' ), + // 'show-if' => [ + // 'where' => 'enable_review', + // 'conditions' => [ + // [ + // 'key' => 'value', + // 'compare' => '=', + // 'value' => true + // ], + // ], + // ], // ], // 'enable_reviewer_img' => [ - // 'type' => 'toggle', - // 'label' => __( 'Enable Reviewer Image', 'directorist' ), - // 'value' => true, - // 'show-if' => [ - // 'where' => 'enable_review', - // 'conditions' => [ - // [ - // 'key' => 'value', - // 'compare' => '=', - // 'value' => true - // ], - // ], - // ], + // 'type' => 'toggle', + // 'label' => __( 'Enable Reviewer Image', 'directorist' ), + // 'value' => true, + // 'show-if' => [ + // 'where' => 'enable_review', + // 'conditions' => [ + // [ + // 'key' => 'value', + // 'compare' => '=', + // 'value' => true + // ], + // ], + // ], // ], // 'enable_reviewer_content' => [ - // 'type' => 'toggle', - // 'label' => __('Enable Reviewer content', 'directorist'), - // 'value' => true, - // 'description' => __('Allow to display content of reviewer on single listing page.', 'directorist'), - // 'show-if' => [ - // 'where' => 'enable_review', - // 'conditions' => [ - // [ - // 'key' => 'value', - // 'compare' => '=', - // 'value' => true - // ], - // ], - // ], + // 'type' => 'toggle', + // 'label' => __('Enable Reviewer content', 'directorist'), + // 'value' => true, + // 'description' => __('Allow to display content of reviewer on single listing page.', 'directorist'), + // 'show-if' => [ + // 'where' => 'enable_review', + // 'conditions' => [ + // [ + // 'key' => 'value', + // 'compare' => '=', + // 'value' => true + // ], + // ], + // ], // ], // 'required_reviewer_content' => [ - // 'type' => 'toggle', - // 'label' => __('Required Reviewer content', 'directorist'), - // 'value' => true, - // 'description' => __('Allow to Require the content of reviewer on single listing page.', 'directorist'), - // 'show-if' => [ - // 'where' => 'enable_review', - // 'conditions' => [ - // [ - // 'key' => 'value', - // 'compare' => '=', - // 'value' => true - // ], - // ], - // ], - // ], - 'review_num' => [ + // 'type' => 'toggle', + // 'label' => __('Required Reviewer content', 'directorist'), + // 'value' => true, + // 'description' => __('Allow to Require the content of reviewer on single listing page.', 'directorist'), + // 'show-if' => [ + // 'where' => 'enable_review', + // 'conditions' => [ + // [ + // 'key' => 'value', + // 'compare' => '=', + // 'value' => true + // ], + // ], + // ], + // ], + 'review_num' => array( 'label' => __( 'Reviews Per Page', 'directorist' ), 'description' => __( 'Set how many reviews to display per page (For the best performance, we suggest keeping it under 10)', 'directorist' ), 'type' => 'number', @@ -191,19 +197,19 @@ public static function get_fields() { 'min' => 1, 'max' => 20, 'step' => 1, - 'show-if' => [ + 'show-if' => array( 'where' => 'enable_review', - 'conditions' => [ - [ + 'conditions' => array( + array( 'key' => 'value', 'compare' => '=', - 'value' => true - ], - ], - ], - ], - - ]; + 'value' => true, + ), + ), + ), + ), + + ); } public static function register_fields( $fields ) { diff --git a/includes/review/directorist-review-functions.php b/includes/review/directorist-review-functions.php index 12cb51c722..d17a7e912b 100644 --- a/includes/review/directorist-review-functions.php +++ b/includes/review/directorist-review-functions.php @@ -90,43 +90,43 @@ function directorist_get_rating_field_meta_key() { /** * Get comment edit link. * - * @param array $args + * @param array $args * @param WP_Comment|string|int $comment - * @param WP_Post|int $post + * @param WP_Post|int $post * * @return void */ function directorist_get_comment_edit_link( $args = array(), $comment = null, $post = null ) { - $defaults = array( - 'edit_text' => __( 'Edit', 'directorist' ), - 'edit_of_text' => __( 'Edit %s', 'directorist' ), - 'max_depth' => 0, - 'depth' => 0, - ); + $defaults = array( + 'edit_text' => __( 'Edit', 'directorist' ), + 'edit_of_text' => __( 'Edit %s', 'directorist' ), + 'max_depth' => 0, + 'depth' => 0, + ); - $args = wp_parse_args( $args, $defaults ); + $args = wp_parse_args( $args, $defaults ); - $comment = get_comment( $comment ); + $comment = get_comment( $comment ); - if ( empty( $comment ) ) { - return; - } + if ( empty( $comment ) ) { + return; + } if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) { return; } - if ( empty( $post ) ) { - $post = $comment->comment_post_ID; - } + if ( empty( $post ) ) { + $post = $comment->comment_post_ID; + } - $post = get_post( $post ); + $post = get_post( $post ); - if ( ! comments_open( $post->ID ) ) { - return false; - } + if ( ! comments_open( $post->ID ) ) { + return false; + } - $comment_type = ( $comment->comment_type === 'review' ? __( 'review', 'directorist' ) : __( 'comment', 'directorist' ) ); + $comment_type = ( $comment->comment_type === 'review' ? __( 'review', 'directorist' ) : __( 'comment', 'directorist' ) ); $data_attributes = array( 'commentid' => $comment->comment_ID, 'postid' => $post->ID, @@ -149,7 +149,7 @@ function directorist_get_comment_edit_link( $args = array(), $comment = null, $p $args['edit_text'] ); - return apply_filters( 'directorist_comment_edit_link', $link, $args, $comment, $post ); + return apply_filters( 'directorist_comment_edit_link', $link, $args, $comment, $post ); } /** @@ -167,7 +167,7 @@ function directorist_get_comment_form_ajax_url( $type = 'add' ) { * Check if user already shared a review. * * @param string $user_email - * @param int $post_id. + * @param int $post_id. * @return bool */ function directorist_user_review_exists( $user_email, $post_id ) { @@ -290,7 +290,7 @@ function directorist_get_review_gdpr_consent_label() { '<a target="_blank" href="' . esc_url( ATBDP_Permalink::get_privacy_policy_page_url() ) . '">', '</a>', '<a target="_blank" href="' . esc_url( ATBDP_Permalink::get_terms_and_conditions_page_url() ) . '">', - '</a>' + '</a>', ), $label ); diff --git a/includes/review/init.php b/includes/review/init.php index c157ca6c72..248400a2e8 100644 --- a/includes/review/init.php +++ b/includes/review/init.php @@ -177,10 +177,10 @@ public static function override_comment_order_option() { * * Since subscriber cannot edit their own comment so meta cap remapping is necessary. * - * @param array $caps + * @param array $caps * @param string $cap - * @param int $user_id - * @param mixed $args + * @param int $user_id + * @param mixed $args * * @return array */ @@ -213,7 +213,7 @@ public static function add_comment_support( $args, $post_type ) { return $args; } - $args['supports'] = array_merge( $args['supports'], [ 'comments' ] ); + $args['supports'] = array_merge( $args['supports'], array( 'comments' ) ); return $args; } diff --git a/includes/system-status/class-system-status.php b/includes/system-status/class-system-status.php index d93bcb4eb6..68d31881d9 100644 --- a/includes/system-status/class-system-status.php +++ b/includes/system-status/class-system-status.php @@ -2,59 +2,59 @@ /** * @author AazzTech */ -class ATBDP_Status -{ - - public $custom_url; - - public function __construct() { - add_action( 'admin_menu', array( $this, 'status_menu' ), 60 ); - - $this->include(); - $this->custom_url = new ATBDP_Custom_Url(); - } - - public function include() { - include ATBDP_INC_DIR . '/system-status/system-information/system-information.php'; - include ATBDP_INC_DIR . '/system-status/custom-url.php'; - } - - /** - * Add system status menu page - * - * @return void - */ - public function status_menu() { - add_submenu_page( 'edit.php?post_type=at_biz_dir', __( 'Help & Support', 'directorist' ), __( 'Help & Support', 'directorist' ) , 'manage_options', 'directorist-status', array( $this, 'tools_page' ) ); - } - - public function tools_page() { - include ATBDP_INC_DIR . '/system-status/template.php'; - } - - public function status_page() { ?> - - <div class='postbox'> - <?php - esc_html_e( 'Help & Support', 'directorist' ); - new ATBDP_System_Info(); - ?> - </div> - - <div class='postbox'> - <?php - $this->custom_url->custom_link(); - ?> - </div> - - <div class='postbox'> - <?php - include ATBDP_INC_DIR . '/system-status/warning.php'; - ?> - </div> - <?php - } - +class ATBDP_Status { + + + public $custom_url; + + public function __construct() { + add_action( 'admin_menu', array( $this, 'status_menu' ), 60 ); + + $this->include(); + $this->custom_url = new ATBDP_Custom_Url(); + } + + public function include() { + include ATBDP_INC_DIR . '/system-status/system-information/system-information.php'; + include ATBDP_INC_DIR . '/system-status/custom-url.php'; + } + + /** + * Add system status menu page + * + * @return void + */ + public function status_menu() { + add_submenu_page( 'edit.php?post_type=at_biz_dir', __( 'Help & Support', 'directorist' ), __( 'Help & Support', 'directorist' ), 'manage_options', 'directorist-status', array( $this, 'tools_page' ) ); + } + + public function tools_page() { + include ATBDP_INC_DIR . '/system-status/template.php'; + } + + public function status_page() { + ?> + + <div class='postbox'> + <?php + esc_html_e( 'Help & Support', 'directorist' ); + new ATBDP_System_Info(); + ?> + </div> + + <div class='postbox'> + <?php + $this->custom_url->custom_link(); + ?> + </div> + + <div class='postbox'> + <?php + include ATBDP_INC_DIR . '/system-status/warning.php'; + ?> + </div> + <?php + } } new ATBDP_Status(); diff --git a/includes/system-status/custom-url.php b/includes/system-status/custom-url.php index a4f73f8455..2db9e7e316 100644 --- a/includes/system-status/custom-url.php +++ b/includes/system-status/custom-url.php @@ -2,21 +2,21 @@ /** * @author AazzTech */ -class ATBDP_Custom_Url -{ - public function __construct() { +class ATBDP_Custom_Url { + + public function __construct() { add_action( 'wp_ajax_generate_url', array( $this, 'generate_url' ) ); add_action( 'wp_ajax_revoke_url', array( $this, 'revoke_url' ) ); add_action( 'template_redirect', array( $this, 'view_debug_info' ), 1 ); - } + } - public function generate_url() { + public function generate_url() { if ( ! directorist_verify_nonce( '_nonce', '_generate_custom_url' ) ) { - wp_send_json_error( __( 'Invalid request', 'directorist' ), 400 ); + wp_send_json_error( __( 'Invalid request', 'directorist' ), 400 ); } if ( ! current_user_can( 'manage_options' ) ) { - wp_send_json_error( __( 'You are not allowed to create secret url', 'directorist' ), 403 ); + wp_send_json_error( __( 'You are not allowed to create secret url', 'directorist' ), 403 ); } $token = wp_rand(); @@ -29,33 +29,36 @@ public function generate_url() { 'message' => __( 'Secret URL has been created.', 'directorist' ), ) ); - } + } public function get_token_url( $token ) { - return add_query_arg( array( - 'directorist_debug_token' => wp_hash( $token, 'nonce' ), - ), home_url( '/' ) ); + return add_query_arg( + array( + 'directorist_debug_token' => wp_hash( $token, 'nonce' ), + ), + home_url( '/' ) + ); } - public function revoke_url() { + public function revoke_url() { if ( ! directorist_verify_nonce( '_nonce', '_revoke_custom_url' ) ) { - wp_send_json_error( __( 'Invalid request', 'directorist' ), 400 ); + wp_send_json_error( __( 'Invalid request', 'directorist' ), 400 ); } if ( ! current_user_can( 'manage_options' ) ) { - wp_send_json_error( __( 'You are not allowed to revoke secret url', 'directorist' ), 403 ); + wp_send_json_error( __( 'You are not allowed to revoke secret url', 'directorist' ), 403 ); } delete_transient( 'system_info_remote_token' ); wp_send_json_success( __( 'Secret URL has been revoked.', 'directorist' ) ); - } + } - public function view_debug_info() { + public function view_debug_info() { if ( empty( $_GET['directorist_debug_token'] ) ) { return; } - $debug_token = sanitize_text_field( wp_unslash( $_GET['directorist_debug_token'] ) ); + $debug_token = sanitize_text_field( wp_unslash( $_GET['directorist_debug_token'] ) ); $stored_debug_token = get_transient( 'system_info_remote_token' ); if ( wp_hash( $stored_debug_token, 'nonce' ) !== $debug_token ) { @@ -73,14 +76,14 @@ public function view_debug_info() { exit; } - public function system_info() { + public function system_info() { include ATBDP_INC_DIR . '/system-status/system-info.php'; ob_start(); new ATBDP_System_Info_Email_Link(); return ob_get_clean(); } - public function custom_link() { + public function custom_link() { $url = ''; if ( get_transient( 'system_info_remote_token' ) ) { $url = $this->get_token_url( get_transient( 'system_info_remote_token' ) ); @@ -115,5 +118,4 @@ public function custom_link() { </div> <?php } - } \ No newline at end of file diff --git a/includes/system-status/system-info-template.php b/includes/system-status/system-info-template.php index d0c7dd26e4..bce31ebfb9 100644 --- a/includes/system-status/system-info-template.php +++ b/includes/system-status/system-info-template.php @@ -1,107 +1,109 @@ -<?php +<?php global $wpdb; - $environment = $this->get_environment_info(); - $database = $this->get_database_info(); - $post_type_counts = $this->get_post_type_counts(); - $security = $this->get_security_info(); - $active_plugins = $this->get_active_plugins(); - $theme = $this->get_Theme_info(); - $php_information = $this->php_information(); - - $atbdp_option = get_option( 'atbdp_option' ); +$environment = $this->get_environment_info(); +$database = $this->get_database_info(); +$post_type_counts = $this->get_post_type_counts(); +$security = $this->get_security_info(); +$active_plugins = $this->get_active_plugins(); +$theme = $this->get_Theme_info(); +$php_information = $this->php_information(); + +$atbdp_option = get_option( 'atbdp_option' ); ?> <!-- WordPress environment --> <table class="atbdp_status_table widefat" cellspacing="0" id="status"> - <thead> - <tr> - <th colspan="3" data-export-label="WordPress Environment"><h2><?php esc_html_e( 'WordPress environment', 'directorist' ); ?></h2></th> - </tr> - </thead> - <tbody> - <tr> - <td data-export-label="Home URL"><?php esc_html_e( 'Home URL', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The homepage URL of your site.', 'directorist' ) ) ); ?></td> - <td><?php echo wp_kses_post( $environment['home_url'] ) ?></td> - </tr> - <tr> - <td data-export-label="Site URL"><?php esc_html_e( 'Site URL', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The root URL of your site.', 'directorist' ) ) ); ?></td> - <td><?php echo esc_html( $environment['site_url'] ) ?></td> - </tr> - <tr> - <td data-export-label="Directorist Version"><?php esc_html_e( 'Directorist version', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The version of GeoDirectory installed on your site.', 'directorist' ) ) ); ?></td> - <td><?php echo esc_html( $environment['version'] ) ?></td> - </tr> - <tr> - <td data-export-label="WP Version"><?php esc_html_e( 'WP version', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The version of WordPress installed on your site.', 'directorist' ) ) ); ?></td> - <td><?php echo esc_html( $environment['wp_version'] ) ?></td> - </tr> - <tr> - <td data-export-label="WP Multisite"><?php esc_html_e( 'WP multisite', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Whether or not you have WordPress Multisite enabled.', 'directorist' ) ) ); ?></td> - <td><?php echo ( $environment['wp_multisite'] ) ? '<span class="dashicons dashicons-yes"></span>' : '–'; ?></td> - </tr> - <tr> - <td data-export-label="WP Memory Limit"><?php esc_html_e( 'WP memory limit', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The maximum amount of memory (RAM) that your site can use at one time.', 'directorist' ) ) ); ?></td> - <td><?php - if ( $environment['wp_memory_limit'] < 67108864 ) { - $_memory_limit = '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'directorist' ), esc_html( size_format( $environment['wp_memory_limit'] ) ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . esc_html__( 'Increasing memory allocated to PHP', 'directorist' ) . '</a>' ) . '</mark>'; - } else { - $_memory_limit = '<mark class="yes">' . esc_html( size_format( $environment['wp_memory_limit'] ) ) . '</mark>'; - } + <thead> + <tr> + <th colspan="3" data-export-label="WordPress Environment"><h2><?php esc_html_e( 'WordPress environment', 'directorist' ); ?></h2></th> + </tr> + </thead> + <tbody> + <tr> + <td data-export-label="Home URL"><?php esc_html_e( 'Home URL', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The homepage URL of your site.', 'directorist' ) ) ); ?></td> + <td><?php echo wp_kses_post( $environment['home_url'] ); ?></td> + </tr> + <tr> + <td data-export-label="Site URL"><?php esc_html_e( 'Site URL', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The root URL of your site.', 'directorist' ) ) ); ?></td> + <td><?php echo esc_html( $environment['site_url'] ); ?></td> + </tr> + <tr> + <td data-export-label="Directorist Version"><?php esc_html_e( 'Directorist version', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The version of GeoDirectory installed on your site.', 'directorist' ) ) ); ?></td> + <td><?php echo esc_html( $environment['version'] ); ?></td> + </tr> + <tr> + <td data-export-label="WP Version"><?php esc_html_e( 'WP version', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The version of WordPress installed on your site.', 'directorist' ) ) ); ?></td> + <td><?php echo esc_html( $environment['wp_version'] ); ?></td> + </tr> + <tr> + <td data-export-label="WP Multisite"><?php esc_html_e( 'WP multisite', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Whether or not you have WordPress Multisite enabled.', 'directorist' ) ) ); ?></td> + <td><?php echo ( $environment['wp_multisite'] ) ? '<span class="dashicons dashicons-yes"></span>' : '–'; ?></td> + </tr> + <tr> + <td data-export-label="WP Memory Limit"><?php esc_html_e( 'WP memory limit', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The maximum amount of memory (RAM) that your site can use at one time.', 'directorist' ) ) ); ?></td> + <td> + <?php + if ( $environment['wp_memory_limit'] < 67108864 ) { + $_memory_limit = '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'directorist' ), esc_html( size_format( $environment['wp_memory_limit'] ) ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . esc_html__( 'Increasing memory allocated to PHP', 'directorist' ) . '</a>' ) . '</mark>'; + } else { + $_memory_limit = '<mark class="yes">' . esc_html( size_format( $environment['wp_memory_limit'] ) ) . '</mark>'; + } echo wp_kses_post( $_memory_limit ); - ?></td> - </tr> - <tr> - <td data-export-label="WP Debug Mode"><?php esc_html_e( 'WP debug mode', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Displays whether or not WordPress is in Debug Mode.', 'directorist' ) ) ); ?></td> - <td> - <?php if ( $environment['wp_debug_mode'] ) : ?> + ?> + </td> + </tr> + <tr> + <td data-export-label="WP Debug Mode"><?php esc_html_e( 'WP debug mode', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Displays whether or not WordPress is in Debug Mode.', 'directorist' ) ) ); ?></td> + <td> + <?php if ( $environment['wp_debug_mode'] ) : ?> <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> <?php else : ?> <mark class="no">–</mark> <?php endif; ?> - </td> - </tr> - <tr> - <td data-export-label="WP Cron"><?php esc_html_e( 'WP cron', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Displays whether or not WP Cron Jobs are enabled.', 'directorist' ) ) ); ?></td> - <td> - <?php if ( $environment['wp_cron'] ) : ?> + </td> + </tr> + <tr> + <td data-export-label="WP Cron"><?php esc_html_e( 'WP cron', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Displays whether or not WP Cron Jobs are enabled.', 'directorist' ) ) ); ?></td> + <td> + <?php if ( $environment['wp_cron'] ) : ?> <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> <?php else : ?> <mark class="no">–</mark> <?php endif; ?> - </td> - </tr> - <tr> - <td data-export-label="Language"><?php esc_html_e( 'Language', 'directorist' ); ?>:</td> - <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The current language used by WordPress. Default = English', 'directorist' ) ) ); ?></td> - <td><?php echo esc_html( $environment['language'] ) ?></td> - </tr> - </tbody> + </td> + </tr> + <tr> + <td data-export-label="Language"><?php esc_html_e( 'Language', 'directorist' ); ?>:</td> + <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The current language used by WordPress. Default = English', 'directorist' ) ) ); ?></td> + <td><?php echo esc_html( $environment['language'] ); ?></td> + </tr> + </tbody> </table> <!-- PHP --> <table class="atbdp_status_table widefat" cellspacing="0" id="status"> - <thead> - <tr> - <th colspan="3" data-export-label="PHP"><h2><?php esc_html_e( 'PHP', 'directorist' ); ?></h2></th> - </tr> - </thead> - <tbody> - <?php foreach( $php_information as $item => $value) { ?> - <tr> - <td data-export-label="<?php echo esc_attr( $item ); ?>"><?php echo wp_kses_post( $item ); ?>:</td> - <td><?php echo wp_kses_post( $value ); ?></td> + <thead> + <tr> + <th colspan="3" data-export-label="PHP"><h2><?php esc_html_e( 'PHP', 'directorist' ); ?></h2></th> + </tr> + </thead> + <tbody> + <?php foreach ( $php_information as $item => $value ) { ?> + <tr> + <td data-export-label="<?php echo esc_attr( $item ); ?>"><?php echo wp_kses_post( $item ); ?>:</td> + <td><?php echo wp_kses_post( $value ); ?></td> </tr> <?php } ?> - </tbody> + </tbody> </table> - <!-- Server environment --> +<!-- Server environment --> <table class="atbdp_status_table widefat" cellspacing="0"> <thead> <tr> @@ -116,7 +118,8 @@ </tr> <?php $ver = $wpdb->db_server_info(); - if ( ! empty( $wpdb->is_mysql ) && ! stristr( $ver, 'MariaDB' ) ) : ?> + if ( ! empty( $wpdb->is_mysql ) && ! stristr( $ver, 'MariaDB' ) ) : + ?> <tr> <td data-export-label="MySQL Version"><?php esc_html_e( 'MySQL version', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The version of MySQL installed on your hosting server.', 'directorist' ) ) ); ?></td> @@ -139,91 +142,107 @@ <tr> <td data-export-label="Default Timezone is UTC"><?php esc_html_e( 'Default timezone is UTC', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The default timezone for your server.', 'directorist' ) ) ); ?></td> - <td><?php - if ( 'UTC' !== $environment['default_timezone'] ) { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'directorist' ), esc_html( $environment['default_timezone'] ) ) . '</mark>'; - } else { - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; - } ?> + <td> + <?php + if ( 'UTC' !== $environment['default_timezone'] ) { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'directorist' ), esc_html( $environment['default_timezone'] ) ) . '</mark>'; + } else { + echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; + } + ?> </td> </tr> <tr> <td data-export-label="fsockopen/cURL"><?php esc_html_e( 'fsockopen/cURL', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'directorist' ) ) ); ?></td> - <td><?php - if ( $environment['fsockopen_or_curl_enabled'] ) { - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'directorist' ) . '</mark>'; - } ?> + <td> + <?php + if ( $environment['fsockopen_or_curl_enabled'] ) { + echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'directorist' ) . '</mark>'; + } + ?> </td> </tr> <tr> <td data-export-label="SoapClient"><?php esc_html_e( 'SoapClient', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Some webservices like shipping use SOAP to get information from remote servers, for example, live shipping quotes from FedEx require SOAP to be installed.', 'directorist' ) ) ); ?></td> - <td><?php - if ( $environment['soapclient_enabled'] ) { - $_soapclient_enabled = '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; - } else { - $_soapclient_enabled = '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'directorist' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' ) . '</mark>'; - } - - echo wp_kses_post( $_soapclient_enabled ); ?> + <td> + <?php + if ( $environment['soapclient_enabled'] ) { + $_soapclient_enabled = '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; + } else { + $_soapclient_enabled = '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( __( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'directorist' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' ) . '</mark>'; + } + + echo wp_kses_post( $_soapclient_enabled ); + ?> </td> </tr> <tr> <td data-export-label="DOMDocument"><?php esc_html_e( 'DOMDocument', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'directorist' ) ) ); ?></td> - <td><?php - if ( $environment['domdocument_enabled'] ) { - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'directorist' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' ) . '</mark>'; - } ?> + <td> + <?php + if ( $environment['domdocument_enabled'] ) { + echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'directorist' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' ) . '</mark>'; + } + ?> </td> </tr> <tr> <td data-export-label="GZip"><?php esc_html_e( 'GZip', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'directorist' ) ) ); ?></td> - <td><?php - if ( $environment['gzip_enabled'] ) { - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'directorist' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' ) . '</mark>'; - } ?> + <td> + <?php + if ( $environment['gzip_enabled'] ) { + echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'directorist' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' ) . '</mark>'; + } + ?> </td> </tr> <tr> <td data-export-label="Multibyte String"><?php esc_html_e( 'Multibyte string', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'directorist' ) ) ); ?></td> - <td><?php - if ( $environment['mbstring_enabled'] ) { - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'directorist' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>'; - } ?> + <td> + <?php + if ( $environment['mbstring_enabled'] ) { + echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'directorist' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>'; + } + ?> </td> </tr> <tr> <td data-export-label="Remote Post"><?php esc_html_e( 'Remote post', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'PayPal uses this method of communicating when sending back transaction information.', 'directorist' ) ) ); ?></td> - <td><?php - if ( $environment['remote_post_successful'] ) { - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'directorist' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>'; - } ?> + <td> + <?php + if ( $environment['remote_post_successful'] ) { + echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'directorist' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>'; + } + ?> </td> </tr> <tr> <td data-export-label="Remote Get"><?php esc_html_e( 'Remote get', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'GeoDirectory plugins may use this method of communication when checking for plugin updates.', 'directorist' ) ) ); ?></td> - <td><?php - if ( $environment['remote_get_successful'] ) { - echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'directorist' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>'; - } ?> + <td> + <?php + if ( $environment['remote_get_successful'] ) { + echo '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'directorist' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>'; + } + ?> </td> </tr> <?php @@ -231,10 +250,10 @@ foreach ( $rows as $row ) { if ( ! empty( $row['success'] ) ) { $css_class = 'yes'; - $icon = '<span class="dashicons dashicons-yes"></span>'; + $icon = '<span class="dashicons dashicons-yes"></span>'; } else { $css_class = 'error'; - $icon = '<span class="dashicons dashicons-no-alt"></span>'; + $icon = '<span class="dashicons dashicons-no-alt"></span>'; } ?> <tr> @@ -245,8 +264,10 @@ <?php echo wp_kses_data( $icon ); ?> <?php echo wp_kses_data( ! empty( $row['note'] ) ? $row['note'] : '' ); ?> </mark> </td> - </tr><?php - } ?> + </tr> + <?php + } + ?> </tbody> </table> <!-- User platform --> @@ -281,110 +302,113 @@ </table> <!-- Settings --> <table class="atbdp_status_table widefat" cellspacing="0"> - <thead> - <tr> - <th colspan="3" data-export-label="User platform"><h2><?php esc_html_e( 'Settings', 'directorist' ); ?></h2></th> - </th> - </tr> - </thead> - <tbody> - <?php - if ( ! empty( $atbdp_option ) ) : - foreach ($atbdp_option as $name => $value) { - ?> - <tr> - <td data-export-label="<?php echo esc_attr( ! empty( $name ) ? $name: '' ); ?>"> <?php echo esc_attr( ! empty( $name ) ? $name : '' ); ?> </td> - <td> <?php print_r( $value ) ?> </td> - </tr> - <?php - } - endif; - ?> - </tbody> + <thead> + <tr> + <th colspan="3" data-export-label="User platform"><h2><?php esc_html_e( 'Settings', 'directorist' ); ?></h2></th> + </th> + </tr> + </thead> + <tbody> + <?php + if ( ! empty( $atbdp_option ) ) : + foreach ( $atbdp_option as $name => $value ) { + ?> + <tr> + <td data-export-label="<?php echo esc_attr( ! empty( $name ) ? $name : '' ); ?>"> <?php echo esc_attr( ! empty( $name ) ? $name : '' ); ?> </td> + <td> <?php print_r( $value ); ?> </td> + </tr> + <?php + } + endif; + ?> + </tbody> </table> <!-- Database --> <table class="atbdp_status_table widefat" cellspacing="0"> - <thead> - <tr> - <th colspan="3" data-export-label="Database"><h2><?php esc_html_e( 'Database', 'directorist' ); ?></h2></th> - </tr> - </thead> - <tbody> - <tr> - <td data-export-label="Directorist Database Prefix"><?php esc_html_e( 'Database prefix', 'directorist' ); ?></td> - <td class="help"> </td> - <td><?php - if ( strlen( $database['database_prefix'] ) > 20 ) { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend using a prefix with less than 20 characters.', 'directorist' ), esc_html( $database['database_prefix'] ) ) . '</mark>'; - } else { - echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>'; - } - ?> - </td> - </tr> - <tr> - <td><?php esc_html_e( 'Total Database Size', 'directorist' ); ?></td> - <td class="help"> </td> - <td><?php printf( '%.2fMB', esc_html( $database['database_size']['data'] ) + $database['database_size']['index'] ); ?></td> - </tr> + <thead> + <tr> + <th colspan="3" data-export-label="Database"><h2><?php esc_html_e( 'Database', 'directorist' ); ?></h2></th> + </tr> + </thead> + <tbody> + <tr> + <td data-export-label="Directorist Database Prefix"><?php esc_html_e( 'Database prefix', 'directorist' ); ?></td> + <td class="help"> </td> + <td> + <?php + if ( strlen( $database['database_prefix'] ) > 20 ) { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend using a prefix with less than 20 characters.', 'directorist' ), esc_html( $database['database_prefix'] ) ) . '</mark>'; + } else { + echo '<mark class="yes">' . esc_html( $database['database_prefix'] ) . '</mark>'; + } + ?> + </td> + </tr> + <tr> + <td><?php esc_html_e( 'Total Database Size', 'directorist' ); ?></td> + <td class="help"> </td> + <td><?php printf( '%.2fMB', esc_html( $database['database_size']['data'] ) + $database['database_size']['index'] ); ?></td> + </tr> - <tr> - <td><?php esc_html_e( 'Database Data Size', 'directorist' ); ?></td> - <td class="help"> </td> - <td><?php printf( '%.2fMB', esc_html( $database['database_size']['data'] ) ); ?></td> - </tr> + <tr> + <td><?php esc_html_e( 'Database Data Size', 'directorist' ); ?></td> + <td class="help"> </td> + <td><?php printf( '%.2fMB', esc_html( $database['database_size']['data'] ) ); ?></td> + </tr> - <tr> - <td><?php esc_html_e( 'Database Index Size', 'directorist' ); ?></td> - <td class="help"> </td> - <td><?php printf( '%.2fMB', esc_html( $database['database_size']['index'] ) ); ?></td> - </tr> + <tr> + <td><?php esc_html_e( 'Database Index Size', 'directorist' ); ?></td> + <td class="help"> </td> + <td><?php printf( '%.2fMB', esc_html( $database['database_size']['index'] ) ); ?></td> + </tr> <?php foreach ( $database['database_tables']['directorist'] as $table => $table_data ) { ?> - <tr> - <td><?php echo esc_html( $table ); ?></td> - <td class="help"> </td> - <td> - <?php if ( ! $table_data ) { + <tr> + <td><?php echo esc_html( $table ); ?></td> + <td class="help"> </td> + <td> + <?php + if ( ! $table_data ) { echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Table does not exist', 'directorist' ) . '</mark>'; } else { - printf( esc_html__( 'Data: %.2fMB + Index: %.2fMB', 'directorist' ), wp_kses_post( $this->directorist_help_tip( $table_data['data'], 2 ) ), wp_kses_post( $this->directorist_help_tip( $table_data['index'], 2 ) ) ); - } ?> - </td> - </tr> - <?php } ?> + printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'directorist' ), wp_kses_post( $this->directorist_help_tip( $table_data['data'], 2 ) ), wp_kses_post( $this->directorist_help_tip( $table_data['index'], 2 ) ) ); + } + ?> + </td> + </tr> + <?php } ?> - <?php foreach ( $database['database_tables']['other'] as $table => $table_data ) { ?> - <tr> - <td><?php echo esc_html( $table ); ?></td> - <td class="help"> </td> - <td> - <?php printf( esc_html__( 'Data: %.2fMB + Index: %.2fMB', 'directorist' ), wp_kses_post( $this->directorist_help_tip( $table_data['data'], 2 ) ), wp_kses_post( $this->directorist_help_tip( $table_data['index'], 2 ) ) ); ?> - </td> - </tr> - <?php } ?> - </tbody> + <?php foreach ( $database['database_tables']['other'] as $table => $table_data ) { ?> + <tr> + <td><?php echo esc_html( $table ); ?></td> + <td class="help"> </td> + <td> + <?php printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'directorist' ), wp_kses_post( $this->directorist_help_tip( $table_data['data'], 2 ) ), wp_kses_post( $this->directorist_help_tip( $table_data['index'], 2 ) ) ); ?> + </td> + </tr> + <?php } ?> + </tbody> </table> <!-- Post type counts --> <table class="atbdp_status_table widefat" cellspacing="0"> - <thead> - <tr> - <th colspan="3" data-export-label="Post Type Counts"><h2><?php esc_html_e( 'Post Type Counts', 'directorist' ); ?></h2></th> - </tr> - </thead> - <tbody> + <thead> + <tr> + <th colspan="3" data-export-label="Post Type Counts"><h2><?php esc_html_e( 'Post Type Counts', 'directorist' ); ?></h2></th> + </tr> + </thead> + <tbody> <?php foreach ( $post_type_counts as $post_type ) { ?> - <tr> - <td><?php echo esc_html( $post_type->type ); ?></td> - <td class="help"> </td> - <td><?php echo absint( $post_type->count ); ?></td> - </tr> + <tr> + <td><?php echo esc_html( $post_type->type ); ?></td> + <td class="help"> </td> + <td><?php echo absint( $post_type->count ); ?></td> + </tr> <?php } ?> - </tbody> + </tbody> </table> <!-- Security --> <table class="atbdp_status_table widefat" cellspacing="0"> @@ -451,11 +475,13 @@ <tr> <td><?php echo wp_kses_post( $plugin_name ); ?></td> <td class="help"> </td> - <td><?php + <td> + <?php /* translators: %s: plugin author */ printf( esc_html__( 'by %s', 'directorist' ), esc_html( $plugin['author_name'] ) ); echo ' – ' . esc_html( $plugin['version'] ) . esc_html( $version_string ) . esc_html( $network_string ); - ?></td> + ?> + </td> </tr> <?php } @@ -479,31 +505,35 @@ <tr> <td data-export-label="Version"><?php esc_html_e( 'Version', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The installed version of the current active theme.', 'directorist' ) ) ); ?></td> - <td><?php + <td> + <?php echo esc_html( $theme['version'] ); - if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) { - /* translators: %s: theme latest version */ - echo ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), esc_html( $theme['version_latest'] ) ) . '</strong>'; - } - ?></td> + if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) { + /* translators: %s: theme latest version */ + echo ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), esc_html( $theme['version_latest'] ) ) . '</strong>'; + } + ?> + </td> </tr> <tr> <td data-export-label="Author URL"><?php esc_html_e( 'Author URL', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The theme developers URL.', 'directorist' ) ) ); ?></td> - <td><?php echo esc_html( $theme['author_url'] ) ?></td> + <td><?php echo esc_html( $theme['author_url'] ); ?></td> </tr> <tr> <td data-export-label="Child Theme"><?php esc_html_e( 'Child theme', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'Displays whether or not the current theme is a child theme.', 'directorist' ) ) ); ?></td> - <td><?php - $_child_theme = $theme['is_child_theme'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> – ' . sprintf( __( 'If you are modifying Directorist on a parent theme that you did not build personally we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', 'directorist' ), 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ); + <td> + <?php + $_child_theme = $theme['is_child_theme'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> – ' . sprintf( __( 'If you are modifying Directorist on a parent theme that you did not build personally we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', 'directorist' ), 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ); - echo wp_kses_post( $_child_theme ); - ?></td> + echo wp_kses_post( $_child_theme ); + ?> + </td> </tr> <?php if ( $theme['is_child_theme'] ) : - ?> + ?> <tr> <td data-export-label="Parent Theme Name"><?php esc_html_e( 'Parent theme name', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The name of the parent theme.', 'directorist' ) ) ); ?></td> @@ -512,13 +542,15 @@ <tr> <td data-export-label="Parent Theme Version"><?php esc_html_e( 'Parent theme version', 'directorist' ); ?>:</td> <td class="help"><?php echo wp_kses_post( $this->directorist_help_tip( __( 'The installed version of the parent theme.', 'directorist' ) ) ); ?></td> - <td><?php + <td> + <?php echo esc_html( $theme['parent_version'] ); - if ( version_compare( $theme['parent_version'], $theme['parent_version_latest'], '<' ) ) { - /* translators: %s: parant theme latest version */ - echo ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), esc_html( $theme['parent_version_latest'] ) ) . '</strong>'; - } - ?></td> + if ( version_compare( $theme['parent_version'], $theme['parent_version_latest'], '<' ) ) { + /* translators: %s: parant theme latest version */ + echo ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), esc_html( $theme['parent_version_latest'] ) ) . '</strong>'; + } + ?> + </td> </tr> <tr> <td data-export-label="Parent Theme Author URL"><?php esc_html_e( 'Parent theme author URL', 'directorist' ); ?>:</td> @@ -536,8 +568,9 @@ </tr> </thead> <tbody> - <?php - if ( ! empty( $theme['overrides'] ) ) { ?> + <?php + if ( ! empty( $theme['overrides'] ) ) { + ?> <tr> <td data-export-label="Overrides"><?php esc_html_e( 'Overrides', 'directorist' ); ?></td> <td class="help"> </td> @@ -566,25 +599,25 @@ </td> </tr> <?php - } else { - ?> + } else { + ?> <tr> <td data-export-label="Overrides"><?php esc_html_e( 'Overrides', 'directorist' ); ?>:</td> <td class="help"> </td> <td>–</td> </tr> <?php - } + } - if ( true === $theme['has_outdated_templates'] ) { - ?> + if ( true === $theme['has_outdated_templates'] ) { + ?> <tr> <td data-export-label="Outdated Templates"><?php esc_html_e( 'Outdated templates', 'directorist' ); ?>:</td> <td class="help"> </td> <td><mark class="error"><span class="dashicons dashicons-warning"></span></mark></td> </tr> <?php - } + } ?> </tbody> </table> \ No newline at end of file diff --git a/includes/system-status/system-info.php b/includes/system-status/system-info.php index 8462790535..32be1b7213 100644 --- a/includes/system-status/system-info.php +++ b/includes/system-status/system-info.php @@ -5,13 +5,13 @@ use Directorist\Helper; -class ATBDP_System_Info_Email_Link -{ - public function __construct() { - include_once ATBDP_INC_DIR . '/system-status/system-info-template.php'; - } +class ATBDP_System_Info_Email_Link { - public function get_environment_info() { + public function __construct() { + include_once ATBDP_INC_DIR . '/system-status/system-info-template.php'; + } + + public function get_environment_info() { global $wpdb; // Figure out cURL version, if installed. @@ -28,31 +28,37 @@ public function get_environment_info() { } // User agent - $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : ''; - $default_role = get_option( 'default_role' ); + $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : ''; + $default_role = get_option( 'default_role' ); // Test POST requests - $post_response = wp_safe_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', array( - 'timeout' => 10, - 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url(), - 'httpversion' => '1.1', - 'body' => array( - 'useragent' => sanitize_text_field( $user_agent ), - ), - ) ); - - $post_response_body = NULL; + $post_response = wp_safe_remote_post( + 'http://api.wordpress.org/core/browse-happy/1.1/', + array( + 'timeout' => 10, + 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url(), + 'httpversion' => '1.1', + 'body' => array( + 'useragent' => sanitize_text_field( $user_agent ), + ), + ) + ); + + $post_response_body = null; $post_response_successful = false; if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { $post_response_successful = true; - $post_response_body = json_decode( wp_remote_retrieve_body( $post_response ), true ); + $post_response_body = json_decode( wp_remote_retrieve_body( $post_response ), true ); } // Test GET requests - $get_response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/directorist/trunk/readme.txt', array( - 'timeout' => 10, - 'user-agent' => 'Directorist/' . ATBDP_VERSION, - 'httpversion' => '1.1', - ) ); + $get_response = wp_safe_remote_get( + 'https://plugins.svn.wordpress.org/directorist/trunk/readme.txt', + array( + 'timeout' => 10, + 'user-agent' => 'Directorist/' . ATBDP_VERSION, + 'httpversion' => '1.1', + ) + ); $get_response_successful = false; if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { $get_response_successful = true; @@ -88,15 +94,15 @@ public function get_environment_info() { 'remote_post_response' => ( is_wp_error( $post_response ) ? $post_response->get_error_message() : $post_response['response']['code'] ), 'remote_get_successful' => $get_response_successful, 'remote_get_response' => ( is_wp_error( $get_response ) ? $get_response->get_error_message() : $get_response['response']['code'] ), - 'platform' => ! empty( $post_response_body['platform'] ) ? $post_response_body['platform'] : '-', - 'browser_name' => ! empty( $post_response_body['name'] ) ? $post_response_body['name'] : '-', - 'browser_version' => ! empty( $post_response_body['version'] ) ? $post_response_body['version'] : '-', - 'user_agent' => $user_agent, - 'default_role' => $default_role, + 'platform' => ! empty( $post_response_body['platform'] ) ? $post_response_body['platform'] : '-', + 'browser_name' => ! empty( $post_response_body['name'] ) ? $post_response_body['name'] : '-', + 'browser_version' => ! empty( $post_response_body['version'] ) ? $post_response_body['version'] : '-', + 'user_agent' => $user_agent, + 'default_role' => $default_role, ); - } + } - /** + /** * Get array of database information. Version, prefix, and table existence. * * @return array @@ -181,9 +187,9 @@ public function get_database_info() { 'database_tables' => $tables, 'database_size' => $database_size, ); - } + } - /** + /** * Add prefix to table. * * @param string $table table name @@ -192,9 +198,9 @@ public function get_database_info() { protected function add_db_table_prefix( $table ) { global $wpdb; return $wpdb->prefix . $table; - } + } - /** + /** * Get array of counts of objects. Orders, products, etc. * * @return array @@ -205,9 +211,9 @@ public function get_post_type_counts() { $post_type_counts = $wpdb->get_results( "SELECT post_type AS 'type', count(1) AS 'count' FROM {$wpdb->posts} GROUP BY post_type;" ); return is_array( $post_type_counts ) ? $post_type_counts : array(); - } + } - /** + /** * Returns security tips. * * @return array @@ -218,16 +224,16 @@ public function get_security_info() { 'secure_connection' => 'https' === substr( $check_page, 0, 5 ), 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), ); - } + } - /** + /** * Get a list of plugins active on the site. * * @return array */ public function get_active_plugins() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); - require_once( ABSPATH . 'wp-admin/includes/update.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + require_once ABSPATH . 'wp-admin/includes/update.php'; if ( ! function_exists( 'get_plugin_updates' ) ) { return array(); @@ -266,9 +272,9 @@ public function get_active_plugins() { } return $active_plugins_data; - } + } - /** + /** * Get info on the current active theme, info on parent theme (if present) * and a list of template overrides. * @@ -333,36 +339,39 @@ public function get_theme_info() { } $active_theme_info = array( - 'name' => $active_theme->name, - 'version' => $active_theme->version, - 'version_latest' => self::get_latest_theme_version( $active_theme ), - 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), - 'is_child_theme' => is_child_theme(), - 'has_outdated_templates' => $outdated_templates, - 'overrides' => $override_files, + 'name' => $active_theme->name, + 'version' => $active_theme->version, + 'version_latest' => self::get_latest_theme_version( $active_theme ), + 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), + 'is_child_theme' => is_child_theme(), + 'has_outdated_templates' => $outdated_templates, + 'overrides' => $override_files, ); return array_merge( $active_theme_info, $parent_theme_info ); - } + } - /** + /** * Get latest version of a theme by slug. - * - * @since 2.0.0 - * + * + * @since 2.0.0 + * * @param object $theme WP_Theme object. * @return string Version number if found. */ public static function get_latest_theme_version( $theme ) { - include_once( ABSPATH . 'wp-admin/includes/theme.php' ); - - $api = themes_api( 'theme_information', array( - 'slug' => $theme->get_stylesheet(), - 'fields' => array( - 'sections' => false, - 'tags' => false, - ), - ) ); + include_once ABSPATH . 'wp-admin/includes/theme.php'; + + $api = themes_api( + 'theme_information', + array( + 'slug' => $theme->get_stylesheet(), + 'fields' => array( + 'sections' => false, + 'tags' => false, + ), + ) + ); $update_theme_version = 0; @@ -370,25 +379,30 @@ public static function get_latest_theme_version( $theme ) { if ( is_object( $api ) && ! is_wp_error( $api ) ) { if ( isset( $api->version ) ) { $update_theme_version = $api->version; - } else if ( isset( $api->stable_version ) ) { + } elseif ( isset( $api->stable_version ) ) { $update_theme_version = $api->stable_version; } - // Check GeoDirectory Theme Version. + // Check GeoDirectory Theme Version. } elseif ( strstr( $theme->{'Author URI'}, 'aazztech' ) ) { - $theme_dir = substr( strtolower( str_replace( ' ', '', $theme->name ) ), 0, 45 ); + $theme_dir = substr( strtolower( str_replace( ' ', '', $theme->name ) ), 0, 45 ); $theme_version_data = get_transient( $theme_dir . '_version_data' ); if ( false === $theme_version_data ) { $theme_changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' ); - $cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) ); + $cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) ); if ( ! empty( $cl_lines ) ) { foreach ( $cl_lines as $line_num => $cl_line ) { if ( preg_match( '/^[0-9]/', $cl_line ) ) { $theme_date = str_replace( '.', '-', trim( substr( $cl_line, 0, strpos( $cl_line, '-' ) ) ) ); - $theme_version = preg_replace( '~[^0-9,.]~', '',stristr( $cl_line, "version" ) ); + $theme_version = preg_replace( '~[^0-9,.]~', '', stristr( $cl_line, 'version' ) ); $theme_update = trim( str_replace( '*', '', $cl_lines[ $line_num + 1 ] ) ); - $theme_version_data = array( 'date' => $theme_date, 'version' => $theme_version, 'update' => $theme_update, 'changelog' => $theme_changelog ); + $theme_version_data = array( + 'date' => $theme_date, + 'version' => $theme_version, + 'update' => $theme_update, + 'changelog' => $theme_changelog, + ); set_transient( $theme_dir . '_version_data', $theme_version_data, DAY_IN_SECONDS ); break; } @@ -404,7 +418,7 @@ public static function get_latest_theme_version( $theme ) { return $update_theme_version; } - public function php_information() { + public function php_information() { $dump_php = array(); $php_vars = array( 'max_execution_time', @@ -478,9 +492,9 @@ public function _error_reporting() { } return $levels; - } + } - /** + /** * Scan the template files. * * @param string $template_path Path to the template directory. @@ -510,7 +524,7 @@ public static function scan_template_files( $template_path ) { return $result; } - /** + /** * Retrieve metadata from a file. Based on WP Core's get_file_data function. * * @since 2.1.1 @@ -544,37 +558,37 @@ public static function get_file_version( $file ) { return $version; } - /** - * let_to_num function. - * - * This function transforms the php.ini notation for numbers (like '2M') to an integer. - * - * @since 2.0.0 - * @param $size - * @return int - */ - public function directorist_let_to_num( $size ) { - $l = substr( $size, -1 ); - $ret = substr( $size, 0, -1 ); - switch ( strtoupper( $l ) ) { - case 'P': - $ret *= 1024; - case 'T': - $ret *= 1024; - case 'G': - $ret *= 1024; - case 'M': - $ret *= 1024; - case 'K': - $ret *= 1024; - } - return $ret; - } - - function directorist_help_tip( $tip ) { - - $tip = esc_attr( $tip ); - - return '<span class="atbdp-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; - } -} \ No newline at end of file + /** + * let_to_num function. + * + * This function transforms the php.ini notation for numbers (like '2M') to an integer. + * + * @since 2.0.0 + * @param $size + * @return int + */ + public function directorist_let_to_num( $size ) { + $l = substr( $size, -1 ); + $ret = substr( $size, 0, -1 ); + switch ( strtoupper( $l ) ) { + case 'P': + $ret *= 1024; + case 'T': + $ret *= 1024; + case 'G': + $ret *= 1024; + case 'M': + $ret *= 1024; + case 'K': + $ret *= 1024; + } + return $ret; + } + + function directorist_help_tip( $tip ) { + + $tip = esc_attr( $tip ); + + return '<span class="atbdp-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; + } +} diff --git a/includes/system-status/system-information/system-information-template.php b/includes/system-status/system-information/system-information-template.php index 0516c42bda..f52d803aa6 100644 --- a/includes/system-status/system-information/system-information-template.php +++ b/includes/system-status/system-information/system-information-template.php @@ -1,819 +1,840 @@ <?php global $wpdb; -$environment = $this->get_environment_info(); -$database = $this->get_database_info(); -$post_type_counts = $this->get_post_type_counts(); -$security = $this->get_security_info(); -$active_plugins = $this->get_active_plugins(); -$theme = $this->get_Theme_info(); -$php_information = $this->php_information(); +$environment = $this->get_environment_info(); +$database = $this->get_database_info(); +$post_type_counts = $this->get_post_type_counts(); +$security = $this->get_security_info(); +$active_plugins = $this->get_active_plugins(); +$theme = $this->get_Theme_info(); +$php_information = $this->php_information(); -$atbdp_option = get_option( 'atbdp_option' ); +$atbdp_option = get_option( 'atbdp_option' ); ?> <div class="tab-pane active show" id="atbds_system-info"> - <div class="card atbds_card"> - <div class="card-head"> - <h4><?php esc_html_e( 'System Information', 'directorist' ); ?></h4> - </div> - <div class="card-body"> - <div class="atbds_content__tab"> - <div class="atbds_c-t-menu"> - <ul class="nav" id="atbds_ststus-tab" role="tablist"> - <li class="nav-item"> - <a href="#atbds_system-wp" class="nav-link active" id="atbds_system-info-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Wordpress Environment', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_php" class="nav-link" id="atbds_php-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'PHP', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_server" class="nav-link" id="atbds_server-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Server Environment', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_platform" class="nav-link" id="atbds_platform-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'User Platform', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_setting" class="nav-link" id="atbds_setting-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Settings', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_database" class="nav-link" id="atbds_database-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Database', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_p-count" class="nav-link" id="atbds_p-count-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Post Type Counts', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_sequrity" class="nav-link" id="atbds_sequrity-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Security', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_plugins" class="nav-link" id="atbds_plugins-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Active Plugins', 'directorist' ); ?> <span class="atbds__pl-count">(<?php echo count( $active_plugins ); ?>)</span></a> - </li> - <li class="nav-item"> - <a href="#atbds_theme" class="nav-link" id="atbds_theme-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Theme', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_template" class="nav-link" id="atbds_theme-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Templates', 'directorist' ); ?></a> - </li> - </ul> - </div><!-- ends: .atbds_c-t-menu --> - <div class="atbds_c-t__details"> - <div class="tab-content" data-tabArea="atbds_system-info-tab"> - <div class="tab-pane active show" id="atbds_system-wp"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Home URL', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The homepage URL of your site.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span class="atbds_url"><?php echo esc_html( $environment['home_url'] ); ?></span></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Site URL', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The root URL of your site.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span class="atbds_url"><?php echo esc_html( $environment['site_url'] ); ?></span></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Directorist version', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The version of GeoDirectory installed on your site.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span><?php echo esc_html( $environment['version'] ); ?></span></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'WP version', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The version of WordPress installed on your site.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span><?php echo esc_html( $environment['wp_version'] ); ?></span></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'WP Multisite', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Whether or not you have WordPress Multisite enabled.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo ( $environment['wp_multisite'] ) ? '<span class="dashicons dashicons-yes"></span>' : '–'; ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'WP Memory Limit', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The maximum amount of memory (RAM) that your site can use at one time.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php - if ( $environment['wp_memory_limit'] < 67108864 ) { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'directorist' ), esc_html( size_format( $environment['wp_memory_limit'] ) ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . esc_html__( 'Increasing memory allocated to PHP', 'directorist' ) . '</a>' ) . '</mark>'; - } else { - echo '<span class="atbds_color-success">' . esc_html( size_format( $environment['wp_memory_limit'] ) ) . '</span>'; - } - ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'WP debug mode', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Displays whether or not WordPress is in Debug Mode.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php if ( $environment['wp_debug_mode'] ) : ?> - <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> - <?php else : ?> - <span class="no">-</span> - <?php endif; ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'WP cron', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Displays whether or not WP Cron Jobs are enabled.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php if ( $environment['wp_cron'] ) : ?> - <span class="atbds_color-success"><i class="fa fa-check"></i></span> - <?php else : ?> - <mark class="no">–</mark> - <?php endif; ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'New User Default Role', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The default role of new user.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo esc_html( $environment['default_role'] ) ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Language', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The current language used by WordPress. Default = English', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo esc_html( $environment['language'] ) ?></td> - </tr> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_php"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <?php foreach ( $php_information as $item => $value ) { ?> - <tr> - <td class="atbds_table-title"><?php echo esc_html( $item ); ?>:</td> - <td><?php echo wp_kses_post( $value ); ?></td> - </tr> - <?php } ?> - </tbody> - </table> - </div> - </div> - <div class="tab-pane" id="atbds_server"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Server environment', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Information about the web server that is currently hosting your site.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo esc_html( $environment['server_info'] ); ?></td> - </tr> - <?php - $ver = $wpdb->db_server_info(); - if ( ! empty( $wpdb->is_mysql ) && ! stristr( $ver, 'MariaDB' ) ) : ?> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'MySQL version', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The version of MySQL installed on your hosting server.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - if ( version_compare( $environment['mysql_version'], '5.6', '<' ) ) { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( - /* translators: %s: version */ - esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'directorist' ), - esc_html( $environment['mysql_version'] ), - '<a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress requirements', 'directorist' ) . '</a>' - ) . '</mark>'; - } else { - echo '<span>' . esc_html( $environment['mysql_version'] ) . '</span>'; - } - ?> - </td> - </tr> - <?php endif; ?> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Max upload size', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The largest filesize that can be uploaded to your WordPress installation.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span><?php echo esc_html( size_format( $environment['max_upload_size'] ) ); ?></span></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Default timezone is UTC', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The default timezone for your server.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - if ( 'UTC' !== $environment['default_timezone'] ) { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'directorist' ), esc_html( $environment['default_timezone'] ) ) . '</mark>'; - } else { - echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; - } ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'fsockopen/cURL', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php - if ( $environment['fsockopen_or_curl_enabled'] ) { - echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'directorist' ) . '</mark>'; - } ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'SoapClient', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php - if ( $environment['soapclient_enabled'] ) { - echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'directorist' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' ) . '</mark>'; - } ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'DOMDocument', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - if ( $environment['domdocument_enabled'] ) { - echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'directorist' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' ) . '</mark>'; - } ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'GZip', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php - if ( $environment['gzip_enabled'] ) { - echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'directorist' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' ) . '</mark>'; - } ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Multibyte string', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - if ( $environment['mbstring_enabled'] ) { - echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'directorist' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>'; - } ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Remote post', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'PayPal uses this method of communicating when sending back transaction information.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - if ( $environment['remote_post_successful'] ) { - echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'directorist' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>'; - } ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Remote get', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Directorist plugin may use this method of communication when checking for plugin updates.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - if ( $environment['remote_get_successful'] ) { - echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; - } else { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'directorist' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>'; - } ?> - </td> - </tr> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_platform"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Platform', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo esc_html__( $environment['platform'] ); ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Browser name', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php echo esc_html( $environment['browser_name'] ); ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Browser version', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span><?php echo esc_html( $environment['browser_version'] ); ?></span></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'User agent', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span><?php echo esc_html( $environment['user_agent'] ); ?></span></td> - </tr> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_setting"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <?php - if ( ! empty( $atbdp_option ) ) : - foreach ( $atbdp_option as $name => $value ) { - ?> - <tr> - <td class="atbds_table-title"><?php echo esc_html( ! empty( $name ) ? $name : '' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php print_r( $value ); ?></td> - </tr> - <?php - } - endif; - ?> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_database"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Database prefix', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php - if ( strlen( $database['database_prefix'] ) > 20 ) { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend using a prefix with less than 20 characters.', 'directorist' ), esc_html( $database['database_prefix'] ) ) . '</mark>'; - } else { - echo '<span class="atbds_color-success">' . esc_html( $database['database_prefix'] ) . '</span>'; - } - ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Total Database Size', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php printf( '%.2fMB', esc_attr( $database['database_size']['data'] ) + esc_attr( $database['database_size']['index'] ) ); ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Database Data Size', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span><?php printf( '%.2fMB', esc_attr( $database['database_size']['data'] ) ); ?></span></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e('Database Index Size', 'directorist'); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span><?php printf( '%.2fMB', esc_attr( $database['database_size']['index'] ) ); ?></span></td> - </tr> - <?php foreach ( $database['database_tables']['directorist'] as $table => $table_data ) { ?> - <tr> - <td class="atbds_table-title"><?php echo esc_html( $table ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php if ( ! $table_data ) { - echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Table does not exist', 'directorist' ) . '</mark>'; - } else { - printf( esc_html__( 'Data: %.2fMB + Index: %.2fMB', 'directorist' ), wp_kses_post( $this->directorist_help_tip( $table_data['data'], 2 ) ), wp_kses_post( $this->directorist_help_tip( $table_data['index'], 2 ) ) ); - } ?> - </td> - </tr> - <?php } ?> - <?php foreach ( $database['database_tables']['other'] as $table => $table_data ) { ?> - <tr> - <td class="atbds_table-title"><?php echo esc_html( $table ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php printf( esc_html__( 'Data: %.2fMB + Index: %.2fMB', 'directorist' ), wp_kses_post( $this->directorist_help_tip( $table_data['data'], 2 ) ), wp_kses_post( $this->directorist_help_tip( $table_data['index'], 2 ) ) ); ?></td> - </tr> - <?php } ?> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_p-count"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <?php - foreach ( $post_type_counts as $post_type ) { - ?> - <tr> - <td class="atbds_table-title"><?php echo esc_html( $post_type->type ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo esc_html( absint( $post_type->count ) ); ?></td> - </tr> - <?php - } - ?> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_sequrity"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <tr> - <td class="atbds_table-title"><?php esc_html_e('Secure connection (HTTPS)', 'directorist'); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Is the connection to your site secure?', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php if ( $security['secure_connection'] ) : ?> - <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> - <?php else : ?> - <mark class="error"><span class="dashicons dashicons-warning"></span><?php echo esc_html__( 'HTTPS is not enabled on your site.', 'directorist' ); ?></mark> - <?php endif; ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Hide errors from visitors', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Error messages can contain sensitive information about your site environment. These should be hidden from untrusted visitors.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php if ( $security['hide_errors'] ) : ?> - <span class="atbds_color-success"><i class="fa fa-check"></i></span> - <?php else : ?> - <mark class="error"><span class="dashicons dashicons-warning"></span><?php esc_html_e( 'Error messages should not be shown to visitors.', 'directorist' ); ?></mark> - <?php endif; ?> - </td> - </tr> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_plugins"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <?php - foreach ( $active_plugins as $plugin ) { - if ( ! empty( $plugin['name'] ) ) { - $dirname = dirname( $plugin['plugin'] ); + <div class="card atbds_card"> + <div class="card-head"> + <h4><?php esc_html_e( 'System Information', 'directorist' ); ?></h4> + </div> + <div class="card-body"> + <div class="atbds_content__tab"> + <div class="atbds_c-t-menu"> + <ul class="nav" id="atbds_ststus-tab" role="tablist"> + <li class="nav-item"> + <a href="#atbds_system-wp" class="nav-link active" id="atbds_system-info-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'WordPress Environment', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_php" class="nav-link" id="atbds_php-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'PHP', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_server" class="nav-link" id="atbds_server-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Server Environment', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_platform" class="nav-link" id="atbds_platform-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'User Platform', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_setting" class="nav-link" id="atbds_setting-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Settings', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_database" class="nav-link" id="atbds_database-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Database', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_p-count" class="nav-link" id="atbds_p-count-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Post Type Counts', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_sequrity" class="nav-link" id="atbds_sequrity-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Security', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_plugins" class="nav-link" id="atbds_plugins-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Active Plugins', 'directorist' ); ?> <span class="atbds__pl-count">(<?php echo count( $active_plugins ); ?>)</span></a> + </li> + <li class="nav-item"> + <a href="#atbds_theme" class="nav-link" id="atbds_theme-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Theme', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_template" class="nav-link" id="atbds_theme-tab" data-tabArea="atbds_system-info-tab"><?php esc_html_e( 'Templates', 'directorist' ); ?></a> + </li> + </ul> + </div><!-- ends: .atbds_c-t-menu --> + <div class="atbds_c-t__details"> + <div class="tab-content" data-tabArea="atbds_system-info-tab"> + <div class="tab-pane active show" id="atbds_system-wp"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Home URL', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The homepage URL of your site.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span class="atbds_url"><?php echo esc_html( $environment['home_url'] ); ?></span></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Site URL', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The root URL of your site.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span class="atbds_url"><?php echo esc_html( $environment['site_url'] ); ?></span></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Directorist version', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The version of GeoDirectory installed on your site.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span><?php echo esc_html( $environment['version'] ); ?></span></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'WP version', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The version of WordPress installed on your site.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span><?php echo esc_html( $environment['wp_version'] ); ?></span></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'WP Multisite', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Whether or not you have WordPress Multisite enabled.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo ( $environment['wp_multisite'] ) ? '<span class="dashicons dashicons-yes"></span>' : '–'; ?></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'WP Memory Limit', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The maximum amount of memory (RAM) that your site can use at one time.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( $environment['wp_memory_limit'] < 67108864 ) { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend setting memory to at least 64MB. See: %2$s', 'directorist' ), esc_html( size_format( $environment['wp_memory_limit'] ) ), '<a href="https://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP" target="_blank">' . esc_html__( 'Increasing memory allocated to PHP', 'directorist' ) . '</a>' ) . '</mark>'; + } else { + echo '<span class="atbds_color-success">' . esc_html( size_format( $environment['wp_memory_limit'] ) ) . '</span>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'WP debug mode', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Displays whether or not WordPress is in Debug Mode.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php if ( $environment['wp_debug_mode'] ) : ?> + <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> + <?php else : ?> + <span class="no">-</span> + <?php endif; ?></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'WP cron', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Displays whether or not WP Cron Jobs are enabled.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php if ( $environment['wp_cron'] ) : ?> + <span class="atbds_color-success"><i class="fa fa-check"></i></span> + <?php else : ?> + <mark class="no">–</mark> + <?php endif; ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'New User Default Role', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The default role of new user.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo esc_html( $environment['default_role'] ); ?></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Language', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The current language used by WordPress. Default = English', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo esc_html( $environment['language'] ); ?></td> + </tr> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_php"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <?php foreach ( $php_information as $item => $value ) { ?> + <tr> + <td class="atbds_table-title"><?php echo esc_html( $item ); ?>:</td> + <td><?php echo wp_kses_post( $value ); ?></td> + </tr> + <?php } ?> + </tbody> + </table> + </div> + </div> + <div class="tab-pane" id="atbds_server"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Server environment', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Information about the web server that is currently hosting your site.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo esc_html( $environment['server_info'] ); ?></td> + </tr> + <?php + $ver = $wpdb->db_server_info(); + if ( ! empty( $wpdb->is_mysql ) && ! stristr( $ver, 'MariaDB' ) ) : + ?> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'MySQL version', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The version of MySQL installed on your hosting server.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( version_compare( $environment['mysql_version'], '5.6', '<' ) ) { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( + /* translators: %s: version */ + esc_html__( '%1$s - We recommend a minimum MySQL version of 5.6. See: %2$s', 'directorist' ), + esc_html( $environment['mysql_version'] ), + '<a href="https://wordpress.org/about/requirements/" target="_blank">' . esc_html__( 'WordPress requirements', 'directorist' ) . '</a>' + ) . '</mark>'; + } else { + echo '<span>' . esc_html( $environment['mysql_version'] ) . '</span>'; + } + ?> + </td> + </tr> + <?php endif; ?> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Max upload size', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The largest filesize that can be uploaded to your WordPress installation.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span><?php echo esc_html( size_format( $environment['max_upload_size'] ) ); ?></span></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Default timezone is UTC', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The default timezone for your server.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( 'UTC' !== $environment['default_timezone'] ) { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Default timezone is %s - it should be UTC', 'directorist' ), esc_html( $environment['default_timezone'] ) ) . '</mark>'; + } else { + echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'fsockopen/cURL', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( $environment['fsockopen_or_curl_enabled'] ) { + echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'directorist' ) . '</mark>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'SoapClient', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Payment gateways can use cURL to communicate with remote servers to authorize payments, other plugins may also use it when communicating with remote services.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( $environment['soapclient_enabled'] ) { + echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not have the %s class enabled - some gateway plugins which use SOAP may not work as expected.', 'directorist' ), '<a href="https://php.net/manual/en/class.soapclient.php">SoapClient</a>' ) . '</mark>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'DOMDocument', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'HTML/Multipart emails use DOMDocument to generate inline CSS in templates.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( $environment['domdocument_enabled'] ) { + echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not have the %s class enabled - HTML/Multipart emails, and also some extensions, will not work without DOMDocument.', 'directorist' ), '<a href="https://php.net/manual/en/class.domdocument.php">DOMDocument</a>' ) . '</mark>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'GZip', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'GZip (gzopen) is used to open the GEOIP database from MaxMind.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( $environment['gzip_enabled'] ) { + echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s function - this is required to use the GeoIP database from MaxMind.', 'directorist' ), '<a href="https://php.net/manual/en/zlib.installation.php">gzopen</a>' ) . '</mark>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Multibyte string', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Multibyte String (mbstring) is used to convert character encoding, like for emails or converting characters to lowercase.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( $environment['mbstring_enabled'] ) { + echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( 'Your server does not support the %s functions - this is required for better character encoding. Some fallbacks will be used instead for it.', 'directorist' ), '<a href="https://php.net/manual/en/mbstring.installation.php">mbstring</a>' ) . '</mark>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Remote post', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'PayPal uses this method of communicating when sending back transaction information.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( $environment['remote_post_successful'] ) { + echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'directorist' ), 'wp_remote_post()' ) . ' ' . esc_html( $environment['remote_post_response'] ) . '</mark>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Remote get', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Directorist plugin may use this method of communication when checking for plugin updates.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( $environment['remote_get_successful'] ) { + echo '<span class="atbds_color-success"><i class="fa fa-check"></i></span>'; + } else { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%s failed. Contact your hosting provider.', 'directorist' ), 'wp_remote_get()' ) . ' ' . esc_html( $environment['remote_get_response'] ) . '</mark>'; + } + ?> + </td> + </tr> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_platform"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Platform', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo esc_html__( $environment['platform'] ); ?></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Browser name', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php echo esc_html( $environment['browser_name'] ); ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Browser version', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span><?php echo esc_html( $environment['browser_version'] ); ?></span></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'User agent', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span><?php echo esc_html( $environment['user_agent'] ); ?></span></td> + </tr> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_setting"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <?php + if ( ! empty( $atbdp_option ) ) : + foreach ( $atbdp_option as $name => $value ) { + ?> + <tr> + <td class="atbds_table-title"><?php echo esc_html( ! empty( $name ) ? $name : '' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php print_r( $value ); ?></td> + </tr> + <?php + } + endif; + ?> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_database"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Database prefix', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( strlen( $database['database_prefix'] ) > 20 ) { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . sprintf( esc_html__( '%1$s - We recommend using a prefix with less than 20 characters.', 'directorist' ), esc_html( $database['database_prefix'] ) ) . '</mark>'; + } else { + echo '<span class="atbds_color-success">' . esc_html( $database['database_prefix'] ) . '</span>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Total Database Size', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php printf( '%.2fMB', esc_attr( $database['database_size']['data'] ) + esc_attr( $database['database_size']['index'] ) ); ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Database Data Size', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span><?php printf( '%.2fMB', esc_attr( $database['database_size']['data'] ) ); ?></span></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Database Index Size', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span><?php printf( '%.2fMB', esc_attr( $database['database_size']['index'] ) ); ?></span></td> + </tr> + <?php foreach ( $database['database_tables']['directorist'] as $table => $table_data ) { ?> + <tr> + <td class="atbds_table-title"><?php echo esc_html( $table ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + if ( ! $table_data ) { + echo '<mark class="error"><span class="dashicons dashicons-warning"></span> ' . esc_html__( 'Table does not exist', 'directorist' ) . '</mark>'; + } else { + printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'directorist' ), wp_kses_post( $this->directorist_help_tip( $table_data['data'], 2 ) ), wp_kses_post( $this->directorist_help_tip( $table_data['index'], 2 ) ) ); + } + ?> + </td> + </tr> + <?php } ?> + <?php foreach ( $database['database_tables']['other'] as $table => $table_data ) { ?> + <tr> + <td class="atbds_table-title"><?php echo esc_html( $table ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php printf( esc_html__( 'Data: %1$.2fMB + Index: %2$.2fMB', 'directorist' ), wp_kses_post( $this->directorist_help_tip( $table_data['data'], 2 ) ), wp_kses_post( $this->directorist_help_tip( $table_data['index'], 2 ) ) ); ?></td> + </tr> + <?php } ?> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_p-count"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <?php + foreach ( $post_type_counts as $post_type ) { + ?> + <tr> + <td class="atbds_table-title"><?php echo esc_html( $post_type->type ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo esc_html( absint( $post_type->count ) ); ?></td> + </tr> + <?php + } + ?> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_sequrity"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Secure connection (HTTPS)', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Is the connection to your site secure?', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php if ( $security['secure_connection'] ) : ?> + <mark class="yes"><span class="dashicons dashicons-yes"></span></mark> + <?php else : ?> + <mark class="error"><span class="dashicons dashicons-warning"></span><?php echo esc_html__( 'HTTPS is not enabled on your site.', 'directorist' ); ?></mark> + <?php endif; ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Hide errors from visitors', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Error messages can contain sensitive information about your site environment. These should be hidden from untrusted visitors.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php if ( $security['hide_errors'] ) : ?> + <span class="atbds_color-success"><i class="fa fa-check"></i></span> + <?php else : ?> + <mark class="error"><span class="dashicons dashicons-warning"></span><?php esc_html_e( 'Error messages should not be shown to visitors.', 'directorist' ); ?></mark> + <?php endif; ?> + </td> + </tr> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_plugins"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <?php + foreach ( $active_plugins as $plugin ) { + if ( ! empty( $plugin['name'] ) ) { + $dirname = dirname( $plugin['plugin'] ); - // Link the plugin name to the plugin url if available. - $plugin_name = esc_html( $plugin['name'] ); - if ( ! empty( $plugin['url'] ) ) { - $plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage', 'directorist' ) . '" target="_blank">' . $plugin_name . '</a>'; - } + // Link the plugin name to the plugin url if available. + $plugin_name = esc_html( $plugin['name'] ); + if ( ! empty( $plugin['url'] ) ) { + $plugin_name = '<a href="' . esc_url( $plugin['url'] ) . '" aria-label="' . esc_attr__( 'Visit plugin homepage', 'directorist' ) . '" target="_blank">' . $plugin_name . '</a>'; + } - $version_string = ''; - $network_string = ''; - if ( ! empty( $plugin['latest_verison'] ) && version_compare( $plugin['latest_verison'], $plugin['version'], '>' ) ) { - /* translators: %s: plugin latest version */ - $version_string = ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), $plugin['latest_verison'] ) . '</strong>'; - } + $version_string = ''; + $network_string = ''; + if ( ! empty( $plugin['latest_verison'] ) && version_compare( $plugin['latest_verison'], $plugin['version'], '>' ) ) { + /* translators: %s: plugin latest version */ + $version_string = ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), $plugin['latest_verison'] ) . '</strong>'; + } - if ( false != $plugin['network_activated'] ) { - $network_string = ' – <strong style="color:black;">' . esc_html_e( 'Network enabled', 'directorist' ) . '</strong>'; - } - ?> - <tr> - <td class="atbds_table-title"><?php echo wp_kses_post( $plugin_name ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip"> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - /* translators: %s: plugin author */ - printf( esc_html__('by %s', 'directorist'), wp_kses_post( $plugin['author_name'] ) ); - echo ' – ' . wp_kses_post( $plugin['version'] ) . wp_kses_post( $version_string ) . wp_kses_post( $network_string ); - ?> - </td> - </tr> - <?php - } - } - ?> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_theme"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Name', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The name of the current active theme.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo esc_html( $theme['name'] ) ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Version', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The installed version of the current active theme.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - echo esc_html( $theme['version'] ); - if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) { - /* translators: %s: theme latest version */ - echo ' – <strong style="color:red;">' . sprintf( esc_html__('%s is available', 'directorist'), esc_html( $theme['version_latest'] ) ) . '</strong>'; - } - ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e('Author URL', 'directorist'); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e('The theme developers URL.', 'directorist'); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><span><?php echo esc_html( $theme['author_url'] ) ?></span></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Child theme', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Displays whether or not the current theme is a child theme.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - $_child_theme = $theme['is_child_theme'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> – ' . sprintf( __( 'If you are modifying Directorist on a parent theme that you did not build personally we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', 'directorist' ), 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ); + if ( false != $plugin['network_activated'] ) { + $network_string = ' – <strong style="color:black;">' . esc_html_e( 'Network enabled', 'directorist' ) . '</strong>'; + } + ?> + <tr> + <td class="atbds_table-title"><?php echo wp_kses_post( $plugin_name ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip"> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + /* translators: %s: plugin author */ + printf( esc_html__( 'by %s', 'directorist' ), wp_kses_post( $plugin['author_name'] ) ); + echo ' – ' . wp_kses_post( $plugin['version'] ) . wp_kses_post( $version_string ) . wp_kses_post( $network_string ); + ?> + </td> + </tr> + <?php + } + } + ?> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_theme"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Name', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The name of the current active theme.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo esc_html( $theme['name'] ); ?></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Version', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The installed version of the current active theme.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + echo esc_html( $theme['version'] ); + if ( version_compare( $theme['version'], $theme['version_latest'], '<' ) ) { + /* translators: %s: theme latest version */ + echo ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), esc_html( $theme['version_latest'] ) ) . '</strong>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Author URL', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The theme developers URL.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><span><?php echo esc_html( $theme['author_url'] ); ?></span></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Child theme', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'Displays whether or not the current theme is a child theme.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + $_child_theme = $theme['is_child_theme'] ? '<mark class="yes"><span class="dashicons dashicons-yes"></span></mark>' : '<span class="dashicons dashicons-no-alt"></span> – ' . sprintf( __( 'If you are modifying Directorist on a parent theme that you did not build personally we recommend using a child theme. See: <a href="%s" target="_blank">How to create a child theme</a>', 'directorist' ), 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ); - echo wp_kses_post( $_child_theme ); - ?> - </td> - </tr> - <?php - if ($theme['is_child_theme']) : - ?> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Parent theme name', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The name of the parent theme.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo esc_html( $theme['parent_name'] ); ?></td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Parent theme version', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The installed version of the parent theme.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td> - <?php - echo esc_html( $theme['parent_version'] ); - if ( version_compare( $theme['parent_version'], $theme['parent_latest_verison'], '<' ) ) { - /* translators: %s: parant theme latest version */ - echo ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), esc_html( $theme['parent_latest_verison'] ) ) . '</strong>'; - } - ?> - </td> - </tr> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Parent theme author URL', 'directorist' ); ?>:</td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The parent theme developers URL.', 'directorist' ); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td><?php echo esc_html( $theme['parent_author_url'] ) ?></td> - </tr> - <?php endif ?> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> + echo wp_kses_post( $_child_theme ); + ?> + </td> + </tr> + <?php + if ( $theme['is_child_theme'] ) : + ?> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Parent theme name', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The name of the parent theme.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo esc_html( $theme['parent_name'] ); ?></td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Parent theme version', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The installed version of the parent theme.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td> + <?php + echo esc_html( $theme['parent_version'] ); + if ( version_compare( $theme['parent_version'], $theme['parent_latest_verison'], '<' ) ) { + /* translators: %s: parant theme latest version */ + echo ' – <strong style="color:red;">' . sprintf( esc_html__( '%s is available', 'directorist' ), esc_html( $theme['parent_latest_verison'] ) ) . '</strong>'; + } + ?> + </td> + </tr> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Parent theme author URL', 'directorist' ); ?>:</td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'The parent theme developers URL.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td><?php echo esc_html( $theme['parent_author_url'] ); ?></td> + </tr> + <?php endif ?> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_template"> - <div class="atbds_system-table-wrap"> - <table class="atbds_system-table table-responsive"> - <tbody> - <?php - if ( ! empty( $theme['overrides'] ) ) { ?> - <tr> - <td class="atbds_table-title"><?php esc_html_e( 'Overrides', 'directorist' ); ?></td> - <td class="atbds_table-pointer"> - <span class="atbd_tooltip" aria-label="<?php esc_attr_e('This section shows any files that are overriding the default Directorist template pages.', 'directorist'); ?>"> - <i class="fa fa-question-circle"></i> - <span class="atbd_tooltip__text"></span> - </span> - </td> - <td class="diretorist-table-text"> - <?php - $total_overrides = count( $theme['overrides'] ); - - for ( $i = 0; $i < $total_overrides; $i++ ) { ?> - <p> - <?php - $override = $theme['overrides'][ $i ]; - if ( $override['core_version'] && ( empty( $override['version'] ) || version_compare( $override['version'], $override['core_version'], '<' ) ) ) { - $current_version = $override['version'] ? $override['version'] : '-'; - $_core_version = sprintf( - __( '%1$s version %2$s is out of date. The core version is %3$s', 'directorist' ), - '<code>' . esc_html( $override['file'] ) . '</code>', - '<strong style="color:red">' . esc_html( $current_version ) . '</strong>', - esc_attr( $override['core_version'] ) - ); - echo wp_kses_post( $_core_version ); - } else { - echo esc_html( $override['file'] ); - } - if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) { - echo ', '; - } - } - ?> - </p> - </td> - </tr> - <?php - } else { - ?> - <tr> - <td data-export-label="Overrides"><?php esc_html_e( 'Overrides', 'directorist' ); ?>:</td> - <td class="help"> </td> - <td>–</td> - </tr> - <?php - } - ?> - </tbody> - </table> - </div> - </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_template"> + <div class="atbds_system-table-wrap"> + <table class="atbds_system-table table-responsive"> + <tbody> + <?php + if ( ! empty( $theme['overrides'] ) ) { + ?> + <tr> + <td class="atbds_table-title"><?php esc_html_e( 'Overrides', 'directorist' ); ?></td> + <td class="atbds_table-pointer"> + <span class="atbd_tooltip" aria-label="<?php esc_attr_e( 'This section shows any files that are overriding the default Directorist template pages.', 'directorist' ); ?>"> + <i class="fa fa-question-circle"></i> + <span class="atbd_tooltip__text"></span> + </span> + </td> + <td class="diretorist-table-text"> + <?php + $total_overrides = count( $theme['overrides'] ); + for ( $i = 0; $i < $total_overrides; $i++ ) { + ?> + <p> + <?php + $override = $theme['overrides'][ $i ]; + if ( $override['core_version'] && ( empty( $override['version'] ) || version_compare( $override['version'], $override['core_version'], '<' ) ) ) { + $current_version = $override['version'] ? $override['version'] : '-'; + $_core_version = sprintf( + __( '%1$s version %2$s is out of date. The core version is %3$s', 'directorist' ), + '<code>' . esc_html( $override['file'] ) . '</code>', + '<strong style="color:red">' . esc_html( $current_version ) . '</strong>', + esc_attr( $override['core_version'] ) + ); + echo wp_kses_post( $_core_version ); + } else { + echo esc_html( $override['file'] ); + } + if ( ( count( $theme['overrides'] ) - 1 ) !== $i ) { + echo ', '; + } + } + ?> + </p> + </td> + </tr> + <?php + } else { + ?> + <tr> + <td data-export-label="Overrides"><?php esc_html_e( 'Overrides', 'directorist' ); ?>:</td> + <td class="help"> </td> + <td>–</td> + </tr> + <?php + } + ?> + </tbody> + </table> + </div> + </div><!-- ends: .tab-pane --> - </div> - </div><!-- ends: .atbds_c-t__details --> - </div> - </div> - </div> + + </div> + </div><!-- ends: .atbds_c-t__details --> + </div> + </div> + </div> </div> \ No newline at end of file diff --git a/includes/system-status/system-information/system-information.php b/includes/system-status/system-information/system-information.php index 032a7b4dd3..b4c7cc90a1 100644 --- a/includes/system-status/system-information/system-information.php +++ b/includes/system-status/system-information/system-information.php @@ -5,13 +5,13 @@ use Directorist\Helper; -class ATBDP_System_Info -{ - public function __construct() { - include ATBDP_INC_DIR . '/system-status/system-information/system-information-template.php'; - } +class ATBDP_System_Info { - public function get_environment_info() { + public function __construct() { + include ATBDP_INC_DIR . '/system-status/system-information/system-information-template.php'; + } + + public function get_environment_info() { global $wpdb; // Figure out cURL version, if installed. @@ -28,31 +28,37 @@ public function get_environment_info() { } // User agent - $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : ''; - $default_role = get_option( 'default_role' ); + $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : ''; + $default_role = get_option( 'default_role' ); // Test POST requests - $post_response = wp_safe_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', array( - 'timeout' => 10, - 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url(), - 'httpversion' => '1.1', - 'body' => array( - 'useragent' => $user_agent, - ), - ) ); - - $post_response_body = NULL; + $post_response = wp_safe_remote_post( + 'http://api.wordpress.org/core/browse-happy/1.1/', + array( + 'timeout' => 10, + 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url(), + 'httpversion' => '1.1', + 'body' => array( + 'useragent' => $user_agent, + ), + ) + ); + + $post_response_body = null; $post_response_successful = false; if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { $post_response_successful = true; - $post_response_body = json_decode( wp_remote_retrieve_body( $post_response ), true ); + $post_response_body = json_decode( wp_remote_retrieve_body( $post_response ), true ); } // Test GET requests - $get_response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/directorist/trunk/readme.txt', array( - 'timeout' => 10, - 'user-agent' => 'Directorist/' . ATBDP_VERSION, - 'httpversion' => '1.1', - ) ); + $get_response = wp_safe_remote_get( + 'https://plugins.svn.wordpress.org/directorist/trunk/readme.txt', + array( + 'timeout' => 10, + 'user-agent' => 'Directorist/' . ATBDP_VERSION, + 'httpversion' => '1.1', + ) + ); $get_response_successful = false; if ( ! is_wp_error( $post_response ) && $post_response['response']['code'] >= 200 && $post_response['response']['code'] < 300 ) { $get_response_successful = true; @@ -88,15 +94,15 @@ public function get_environment_info() { 'remote_post_response' => ( is_wp_error( $post_response ) ? $post_response->get_error_message() : $post_response['response']['code'] ), 'remote_get_successful' => $get_response_successful, 'remote_get_response' => ( is_wp_error( $get_response ) ? $get_response->get_error_message() : $get_response['response']['code'] ), - 'platform' => ! empty( $post_response_body['platform'] ) ? $post_response_body['platform'] : '-', - 'browser_name' => ! empty( $post_response_body['name'] ) ? $post_response_body['name'] : '-', - 'browser_version' => ! empty( $post_response_body['version'] ) ? $post_response_body['version'] : '-', - 'user_agent' => $user_agent, - 'default_role' => $default_role, + 'platform' => ! empty( $post_response_body['platform'] ) ? $post_response_body['platform'] : '-', + 'browser_name' => ! empty( $post_response_body['name'] ) ? $post_response_body['name'] : '-', + 'browser_version' => ! empty( $post_response_body['version'] ) ? $post_response_body['version'] : '-', + 'user_agent' => $user_agent, + 'default_role' => $default_role, ); - } + } - /** + /** * Get array of database information. Version, prefix, and table existence. * * @return array @@ -181,9 +187,9 @@ public function get_database_info() { 'database_tables' => $tables, 'database_size' => $database_size, ); - } + } - /** + /** * Add prefix to table. * * @param string $table table name @@ -192,9 +198,9 @@ public function get_database_info() { protected function add_db_table_prefix( $table ) { global $wpdb; return $wpdb->prefix . $table; - } + } - /** + /** * Get array of counts of objects. Orders, products, etc. * * @return array @@ -205,9 +211,9 @@ public function get_post_type_counts() { $post_type_counts = $wpdb->get_results( "SELECT post_type AS 'type', count(1) AS 'count' FROM {$wpdb->posts} GROUP BY post_type;" ); return is_array( $post_type_counts ) ? $post_type_counts : array(); - } + } - /** + /** * Returns security tips. * * @return array @@ -218,16 +224,16 @@ public function get_security_info() { 'secure_connection' => 'https' === substr( $check_page, 0, 5 ), 'hide_errors' => ! ( defined( 'WP_DEBUG' ) && defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG && WP_DEBUG_DISPLAY ) || 0 === intval( ini_get( 'display_errors' ) ), ); - } + } - /** + /** * Get a list of plugins active on the site. * * @return array */ public function get_active_plugins() { - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); - require_once( ABSPATH . 'wp-admin/includes/update.php' ); + require_once ABSPATH . 'wp-admin/includes/plugin.php'; + require_once ABSPATH . 'wp-admin/includes/update.php'; if ( ! function_exists( 'get_plugin_updates' ) ) { return array(); @@ -266,9 +272,9 @@ public function get_active_plugins() { } return $active_plugins_data; - } + } - /** + /** * Get info on the current active theme, info on parent theme (if present) * and a list of template overrides. * @@ -333,36 +339,39 @@ public function get_theme_info() { } $active_theme_info = array( - 'name' => $active_theme->name, - 'version' => $active_theme->version, - 'version_latest' => self::get_latest_theme_version( $active_theme ), - 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), - 'is_child_theme' => is_child_theme(), - 'has_outdated_templates' => $outdated_templates, - 'overrides' => $override_files, + 'name' => $active_theme->name, + 'version' => $active_theme->version, + 'version_latest' => self::get_latest_theme_version( $active_theme ), + 'author_url' => esc_url_raw( $active_theme->{'Author URI'} ), + 'is_child_theme' => is_child_theme(), + 'has_outdated_templates' => $outdated_templates, + 'overrides' => $override_files, ); return array_merge( $active_theme_info, $parent_theme_info ); - } + } - /** + /** * Get latest version of a theme by slug. - * - * @since 2.0.0 - * + * + * @since 2.0.0 + * * @param object $theme WP_Theme object. * @return string Version number if found. */ public static function get_latest_theme_version( $theme ) { - include_once( ABSPATH . 'wp-admin/includes/theme.php' ); - - $api = themes_api( 'theme_information', array( - 'slug' => $theme->get_stylesheet(), - 'fields' => array( - 'sections' => false, - 'tags' => false, - ), - ) ); + include_once ABSPATH . 'wp-admin/includes/theme.php'; + + $api = themes_api( + 'theme_information', + array( + 'slug' => $theme->get_stylesheet(), + 'fields' => array( + 'sections' => false, + 'tags' => false, + ), + ) + ); $update_theme_version = 0; @@ -370,25 +379,30 @@ public static function get_latest_theme_version( $theme ) { if ( is_object( $api ) && ! is_wp_error( $api ) ) { if ( isset( $api->version ) ) { $update_theme_version = $api->version; - } else if ( isset( $api->stable_version ) ) { + } elseif ( isset( $api->stable_version ) ) { $update_theme_version = $api->stable_version; } - // Check GeoDirectory Theme Version. + // Check GeoDirectory Theme Version. } elseif ( strstr( $theme->{'Author URI'}, 'aazztech' ) ) { - $theme_dir = substr( strtolower( str_replace( ' ', '', $theme->name ) ), 0, 45 ); + $theme_dir = substr( strtolower( str_replace( ' ', '', $theme->name ) ), 0, 45 ); $theme_version_data = get_transient( $theme_dir . '_version_data' ); if ( false === $theme_version_data ) { $theme_changelog = wp_safe_remote_get( 'http://dzv365zjfbd8v.cloudfront.net/changelogs/' . $theme_dir . '/changelog.txt' ); - $cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) ); + $cl_lines = explode( "\n", wp_remote_retrieve_body( $theme_changelog ) ); if ( ! empty( $cl_lines ) ) { foreach ( $cl_lines as $line_num => $cl_line ) { if ( preg_match( '/^[0-9]/', $cl_line ) ) { $theme_date = str_replace( '.', '-', trim( substr( $cl_line, 0, strpos( $cl_line, '-' ) ) ) ); - $theme_version = preg_replace( '~[^0-9,.]~', '',stristr( $cl_line, "version" ) ); + $theme_version = preg_replace( '~[^0-9,.]~', '', stristr( $cl_line, 'version' ) ); $theme_update = trim( str_replace( '*', '', $cl_lines[ $line_num + 1 ] ) ); - $theme_version_data = array( 'date' => $theme_date, 'version' => $theme_version, 'update' => $theme_update, 'changelog' => $theme_changelog ); + $theme_version_data = array( + 'date' => $theme_date, + 'version' => $theme_version, + 'update' => $theme_update, + 'changelog' => $theme_changelog, + ); set_transient( $theme_dir . '_version_data', $theme_version_data, DAY_IN_SECONDS ); break; } @@ -404,7 +418,7 @@ public static function get_latest_theme_version( $theme ) { return $update_theme_version; } - public function php_information() { + public function php_information() { $dump_php = array(); $php_vars = array( 'max_execution_time', @@ -478,9 +492,9 @@ public function _error_reporting() { } return $levels; - } + } - /** + /** * Scan the template files. * * @param string $template_path Path to the template directory. @@ -510,7 +524,7 @@ public static function scan_template_files( $template_path ) { return $result; } - /** + /** * Retrieve metadata from a file. Based on WP Core's get_file_data function. * * @since 2.1.1 @@ -544,37 +558,37 @@ public static function get_file_version( $file ) { return $version; } - /** - * let_to_num function. - * - * This function transforms the php.ini notation for numbers (like '2M') to an integer. - * - * @since 2.0.0 - * @param $size - * @return int - */ - public function directorist_let_to_num( $size ) { - $l = substr( $size, -1 ); - $ret = substr( $size, 0, -1 ); - switch ( strtoupper( $l ) ) { - case 'P': - $ret *= 1024; - case 'T': - $ret *= 1024; - case 'G': - $ret *= 1024; - case 'M': - $ret *= 1024; - case 'K': - $ret *= 1024; - } - return $ret; - } - - function directorist_help_tip( $tip ) { - - $tip = esc_attr( $tip ); - - return '<span class="atbdp-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; - } -} \ No newline at end of file + /** + * let_to_num function. + * + * This function transforms the php.ini notation for numbers (like '2M') to an integer. + * + * @since 2.0.0 + * @param $size + * @return int + */ + public function directorist_let_to_num( $size ) { + $l = substr( $size, -1 ); + $ret = substr( $size, 0, -1 ); + switch ( strtoupper( $l ) ) { + case 'P': + $ret *= 1024; + case 'T': + $ret *= 1024; + case 'G': + $ret *= 1024; + case 'M': + $ret *= 1024; + case 'K': + $ret *= 1024; + } + return $ret; + } + + function directorist_help_tip( $tip ) { + + $tip = esc_attr( $tip ); + + return '<span class="atbdp-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; + } +} diff --git a/includes/system-status/template.php b/includes/system-status/template.php index 6231262969..8aed68074d 100644 --- a/includes/system-status/template.php +++ b/includes/system-status/template.php @@ -1,50 +1,50 @@ <?php - $warnings = directorist_warnings(); - $_count = count( $warnings ); - $warning_count = ! empty( $_count ) ? '<span class="directorist-badge directorist-badge-warning">' . $_count . '</span>' : ''; + $warnings = directorist_warnings(); + $_count = count( $warnings ); + $warning_count = ! empty( $_count ) ? '<span class="directorist-badge directorist-badge-warning">' . $_count . '</span>' : ''; ?> <section class="atbds_wrapper"> - <div class="row"> - <div class="col-12"> - <h2 class="atbds_title"><?php esc_html_e( 'System Status', 'directorist' ); ?></h2> - </div> - </div> - <div class="atbds_row"> - <div class="atbds_col-left"> - <aside class="atbds_sidebar pl-30"> - <ul class="nav" class="atbds_status-nav" id="atbds_status-tab" role="tablist"> - <li class="nav-item"> - <a href="#atbds_system-info" class="nav-link active" data-action="atbds_tab" data-tabArea="atbds_system-status-tab"><?php esc_html_e( 'System Information', 'directorist' ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_warning" class="nav-link" data-action="atbds_tab" data-tabArea="atbds_system-status-tab"><?php esc_html_e( 'Warning ', 'directorist' ); ?><?php echo wp_kses_post( $warning_count ); ?></a> - </li> - <li class="nav-item"> - <a href="#atbds_r-viewing" class="nav-link" data-action="atbds_tab" data-tabArea="atbds_system-status-tab"><?php esc_html_e( 'Remote Viewing', 'directorist' ); ?></a> - </li> - </ul> - <a href="https://directorist.com/contact/" target="_blank"><?php esc_html_e( 'Contact Support', 'directorist' ); ?></a> - </aside> - </div><!-- ends: .atbds_col-left --> - <div class="atbds_col-right"> - <div class="atbds_content"> - <div class="tab-content" id="myTabContent" data-tabArea="atbds_system-status-tab"> - <?php - new ATBDP_System_Info(); - ?> - <div class="tab-pane" id="atbds_warning"> - <?php - include_once ATBDP_INC_DIR . 'system-status/warning.php'; - ?> - </div><!-- ends: .tab-pane --> - <div class="tab-pane" id="atbds_r-viewing"> - <?php - $custom_url = new ATBDP_Custom_Url(); - $custom_url->custom_link(); - ?> - </div><!-- ends: .tab-pane --> - </div> - </div> - </div><!-- ends: .atbds_col-right --> - </div> + <div class="row"> + <div class="col-12"> + <h2 class="atbds_title"><?php esc_html_e( 'System Status', 'directorist' ); ?></h2> + </div> + </div> + <div class="atbds_row"> + <div class="atbds_col-left"> + <aside class="atbds_sidebar pl-30"> + <ul class="nav" class="atbds_status-nav" id="atbds_status-tab" role="tablist"> + <li class="nav-item"> + <a href="#atbds_system-info" class="nav-link active" data-action="atbds_tab" data-tabArea="atbds_system-status-tab"><?php esc_html_e( 'System Information', 'directorist' ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_warning" class="nav-link" data-action="atbds_tab" data-tabArea="atbds_system-status-tab"><?php esc_html_e( 'Warning ', 'directorist' ); ?><?php echo wp_kses_post( $warning_count ); ?></a> + </li> + <li class="nav-item"> + <a href="#atbds_r-viewing" class="nav-link" data-action="atbds_tab" data-tabArea="atbds_system-status-tab"><?php esc_html_e( 'Remote Viewing', 'directorist' ); ?></a> + </li> + </ul> + <a href="https://directorist.com/contact/" target="_blank"><?php esc_html_e( 'Contact Support', 'directorist' ); ?></a> + </aside> + </div><!-- ends: .atbds_col-left --> + <div class="atbds_col-right"> + <div class="atbds_content"> + <div class="tab-content" id="myTabContent" data-tabArea="atbds_system-status-tab"> + <?php + new ATBDP_System_Info(); + ?> + <div class="tab-pane" id="atbds_warning"> + <?php + require_once ATBDP_INC_DIR . 'system-status/warning.php'; + ?> + </div><!-- ends: .tab-pane --> + <div class="tab-pane" id="atbds_r-viewing"> + <?php + $custom_url = new ATBDP_Custom_Url(); + $custom_url->custom_link(); + ?> + </div><!-- ends: .tab-pane --> + </div> + </div> + </div><!-- ends: .atbds_col-right --> + </div> </section> \ No newline at end of file diff --git a/includes/system-status/warning.php b/includes/system-status/warning.php index 07f3e8c100..128b3acb9f 100644 --- a/includes/system-status/warning.php +++ b/includes/system-status/warning.php @@ -1,41 +1,48 @@ <?php -$warnings = directorist_warnings(); -$_count = count( $warnings ); +$warnings = directorist_warnings(); +$_count = count( $warnings ); $warning_count = ! empty( $_count ) ? '( ' . $_count . ' )' : ''; ?> <div class="card atbds_card"> - <div class="card-head"> - <h4><?php esc_html_e( "Warning ", 'directorist' ); echo wp_kses_post( $warning_count ); ?></h4> - </div> - <div class="card-body"> - <div class="atbds_content__tab"> - <div class="atbds_warnings"> - <div class="atbds_row"> - <?php if( ! empty( $warnings) ) { - foreach ( $warnings as $warning ) : - ?> - <div class="atbds_col-4"> - <div class="atbds_warnings__single atbds_text-center"> - <div class="atbds_warnings__icon"> - <i class="fa fa-exclamation-triangle"></i> - </div> - <div class="atbds_warnigns__content"> - <h4><?php echo esc_html( $warning['title'] ); ?></h4> - <p><?php echo wp_kses_post( $warning['desc'] ); ?></p> - <?php if ( ! empty( $warning['link'] ) ) { ?> - <a href="<?php echo esc_url( $warning['link'] ); ?>" class="atbds_btnLink"><?php echo esc_html( $warning['link_text'] ); ?> <i class="la la-angle-right"></i></a> - <?php } ?> - </div> - </div><!-- ends: .atbds_warnings__single --> - </div> - <?php - endforeach; - } else { ?> - <p><?php esc_html_e( 'No warning found!', 'directorist' ); ?></p> - <?php } ?> + <div class="card-head"> + <h4> + <?php + esc_html_e( 'Warning ', 'directorist' ); + echo wp_kses_post( $warning_count ); + ?> + </h4> + </div> + <div class="card-body"> + <div class="atbds_content__tab"> + <div class="atbds_warnings"> + <div class="atbds_row"> + <?php + if ( ! empty( $warnings ) ) { + foreach ( $warnings as $warning ) : + ?> + <div class="atbds_col-4"> + <div class="atbds_warnings__single atbds_text-center"> + <div class="atbds_warnings__icon"> + <i class="fa fa-exclamation-triangle"></i> + </div> + <div class="atbds_warnigns__content"> + <h4><?php echo esc_html( $warning['title'] ); ?></h4> + <p><?php echo wp_kses_post( $warning['desc'] ); ?></p> + <?php if ( ! empty( $warning['link'] ) ) { ?> + <a href="<?php echo esc_url( $warning['link'] ); ?>" class="atbds_btnLink"><?php echo esc_html( $warning['link_text'] ); ?> <i class="la la-angle-right"></i></a> + <?php } ?> + </div> + </div><!-- ends: .atbds_warnings__single --> + </div> + <?php + endforeach; + } else { + ?> + <p><?php esc_html_e( 'No warning found!', 'directorist' ); ?></p> + <?php } ?> - </div> - </div> - </div> - </div> + </div> + </div> + </div> + </div> </div> \ No newline at end of file diff --git a/includes/template-functions.php b/includes/template-functions.php index a919160ca8..0413ba3d24 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -1,110 +1,110 @@ <?php if ( ! defined( 'ABSPATH' ) ) { - exit; + exit; } // atbdp_get_extension_template_path function atbdp_get_extension_template_path( string $base_path = '', string $file_path = '', string $base_dirrectory = '' ) { - $ext_dir_path = trailingslashit( $base_path ); - $ext_file_path = $file_path; - $base_dirrectory = preg_replace( '/(\/.+)?(\/)?/', '', $base_dirrectory ); + $ext_dir_path = trailingslashit( $base_path ); + $ext_file_path = $file_path; + $base_dirrectory = preg_replace( '/(\/.+)?(\/)?/', '', $base_dirrectory ); - $template_file = ""; - $extension_template = "{$ext_dir_path}{$ext_file_path}.php"; - $theme_template = get_template_directory() . "/directorist/extensions/{$base_dirrectory}/{$ext_file_path}.php"; + $template_file = ''; + $extension_template = "{$ext_dir_path}{$ext_file_path}.php"; + $theme_template = get_template_directory() . "/directorist/extensions/{$base_dirrectory}/{$ext_file_path}.php"; - if ( ! empty( $ext_dir_path ) && ! empty( $ext_file_path ) && file_exists( $extension_template ) ) { - $template_file = $extension_template; - } + if ( ! empty( $ext_dir_path ) && ! empty( $ext_file_path ) && file_exists( $extension_template ) ) { + $template_file = $extension_template; + } - if ( file_exists( $theme_template ) ) { - $template_file = $theme_template; - } + if ( file_exists( $theme_template ) ) { + $template_file = $theme_template; + } - return $template_file; + return $template_file; } // atbdp_get_extension_template -function atbdp_get_extension_template( string $base_path = '', string $file_path = '', string $theme_dir = '', $data = [] ) { - $template = atbdp_get_extension_template_path( $base_path, $file_path, $theme_dir ); +function atbdp_get_extension_template( string $base_path = '', string $file_path = '', string $theme_dir = '', $data = array() ) { + $template = atbdp_get_extension_template_path( $base_path, $file_path, $theme_dir ); - if ( file_exists( $template ) ) { - include $template; - } + if ( file_exists( $template ) ) { + include $template; + } } function atbdp_has_admin_template( $template ) { - $file = ATBDP_VIEWS_DIR . 'admin-templates/' . $template . '.php'; + $file = ATBDP_VIEWS_DIR . 'admin-templates/' . $template . '.php'; - return file_exists( $file ) ? true : false; + return file_exists( $file ) ? true : false; } -function atbdp_get_admin_template( $template, $args = [] ) { - if ( ! atbdp_has_admin_template( $template ) ) { - return; - } +function atbdp_get_admin_template( $template, $args = array() ) { + if ( ! atbdp_has_admin_template( $template ) ) { + return; + } - if ( is_array( $args ) ) { - extract( $args ); - } + if ( is_array( $args ) ) { + extract( $args ); + } - $file = ATBDP_VIEWS_DIR . 'admin-templates/' . $template . '.php'; + $file = ATBDP_VIEWS_DIR . 'admin-templates/' . $template . '.php'; - include $file; + include $file; } function atbdp_search_result_page_link() { - echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); + echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); } -function atbdp_get_template( $template_file, $args = [] ) { - if ( is_array( $args ) ) { - extract( $args ); - } - - $theme_template = '/directorist/' . $template_file . '.php'; - $plugin_template = ATBDP_VIEWS_DIR . $template_file . '.php'; - - if ( file_exists( get_stylesheet_directory() . $theme_template ) ) { - $file = get_stylesheet_directory() . $theme_template; - } elseif ( file_exists( get_template_directory() . $theme_template ) ) { - $file = get_template_directory() . $theme_template; - } else { - $file = $plugin_template; - } - - if ( file_exists( $file ) ) { - include $file; - } +function atbdp_get_template( $template_file, $args = array() ) { + if ( is_array( $args ) ) { + extract( $args ); + } + + $theme_template = '/directorist/' . $template_file . '.php'; + $plugin_template = ATBDP_VIEWS_DIR . $template_file . '.php'; + + if ( file_exists( get_stylesheet_directory() . $theme_template ) ) { + $file = get_stylesheet_directory() . $theme_template; + } elseif ( file_exists( get_template_directory() . $theme_template ) ) { + $file = get_template_directory() . $theme_template; + } else { + $file = $plugin_template; + } + + if ( file_exists( $file ) ) { + include $file; + } } function atbdp_get_template_path( $template_file ) { - $theme_template = '/directorist/' . $template_file . '.php'; - $plugin_template = ATBDP_VIEWS_DIR . $template_file . '.php'; + $theme_template = '/directorist/' . $template_file . '.php'; + $plugin_template = ATBDP_VIEWS_DIR . $template_file . '.php'; - if ( file_exists( get_stylesheet_directory() . $theme_template ) ) { - $file = get_stylesheet_directory() . $theme_template; - } elseif ( file_exists( get_template_directory() . $theme_template ) ) { - $file = get_template_directory() . $theme_template; - } else { - $file = $plugin_template; - } + if ( file_exists( get_stylesheet_directory() . $theme_template ) ) { + $file = get_stylesheet_directory() . $theme_template; + } elseif ( file_exists( get_template_directory() . $theme_template ) ) { + $file = get_template_directory() . $theme_template; + } else { + $file = $plugin_template; + } - return $file; + return $file; } -function atbdp_get_widget_template( $template, $args = [] ) { - $args = apply_filters( 'atbdp_widget_template_args', $args, $template ); - $template = 'widgets/' . $template; - atbdp_get_template( $template, $args ); +function atbdp_get_widget_template( $template, $args = array() ) { + $args = apply_filters( 'atbdp_widget_template_args', $args, $template ); + $template = 'widgets/' . $template; + atbdp_get_template( $template, $args ); } function atbdp_get_widget_template_path( $template ) { - $template = 'widgets/' . $template; + $template = 'widgets/' . $template; - return atbdp_get_template_path( $template ); + return atbdp_get_template_path( $template ); } function directorist_get_listing_thumbnail_id( $listing = null ) { diff --git a/includes/update-functions.php b/includes/update-functions.php index 07357e2e3f..76894b472e 100644 --- a/includes/update-functions.php +++ b/includes/update-functions.php @@ -29,26 +29,28 @@ function directorist_710_migrate_reviews_table_to_comments_table() { if ( ! empty( $reviews ) ) { foreach ( $reviews as $review ) { - wp_insert_comment( array( - 'comment_type' => ( ( isset( $review->rating ) && $review->rating > 0 ) ? 'review' : 'comment' ), - 'comment_post_ID' => $review->post_id, - 'comment_author' => $review->name, - 'comment_author_email' => $review->email, - 'comment_content' => $review->content, - 'comment_date' => $review->date_created, - 'comment_date_gmt' => $review->date_created, - 'user_id' => ! empty( $review->by_user_id ) ? absint( $review->by_user_id ) : 0, - 'comment_approved' => 1, - 'comment_meta' => array( - 'rating' => $review->rating + wp_insert_comment( + array( + 'comment_type' => ( ( isset( $review->rating ) && $review->rating > 0 ) ? 'review' : 'comment' ), + 'comment_post_ID' => $review->post_id, + 'comment_author' => $review->name, + 'comment_author_email' => $review->email, + 'comment_content' => $review->content, + 'comment_date' => $review->date_created, + 'comment_date_gmt' => $review->date_created, + 'user_id' => ! empty( $review->by_user_id ) ? absint( $review->by_user_id ) : 0, + 'comment_approved' => 1, + 'comment_meta' => array( + 'rating' => $review->rating, + ), ) - ) ); + ); } } update_option( 'directorist_old_reviews_table_migrated', 1, false ); - //Delete review table + // Delete review table // TODO: Delete this table in future. // $wpdb->query( "DROP TABLE IF EXISTS {$review_table}" ); } @@ -79,26 +81,28 @@ function directorist_710_migrate_posts_table_to_comments_table() { if ( ! empty( $reviews ) ) { foreach ( $reviews as $review ) { - wp_insert_comment( array( - 'comment_type' => ( ( isset( $review->rating ) && $review->rating > 0 ) ? 'review' : 'comment' ), - 'comment_post_ID' => $review->post_id, - 'comment_author' => $review->author, - 'comment_author_email' => $review->author_email, - 'comment_content' => $review->comment, - 'comment_date' => $review->comment_date, - 'comment_date_gmt' => $review->comment_date, - 'user_id' => ! empty( $review->user_id ) ? absint( $review->user_id ) : 0, - 'comment_approved' => _directorist_get_comment_status_by_review_status( $review->status ), - 'comment_meta' => array( - 'rating' => $review->rating + wp_insert_comment( + array( + 'comment_type' => ( ( isset( $review->rating ) && $review->rating > 0 ) ? 'review' : 'comment' ), + 'comment_post_ID' => $review->post_id, + 'comment_author' => $review->author, + 'comment_author_email' => $review->author_email, + 'comment_content' => $review->comment, + 'comment_date' => $review->comment_date, + 'comment_date_gmt' => $review->comment_date, + 'user_id' => ! empty( $review->user_id ) ? absint( $review->user_id ) : 0, + 'comment_approved' => _directorist_get_comment_status_by_review_status( $review->status ), + 'comment_meta' => array( + 'rating' => $review->rating, + ), ) - ) ); + ); } // Delete review type posts // TODO: Delete this in the future // foreach ( $reviews as $review ) { - // wp_delete_post( $review->post_id, true ); + // wp_delete_post( $review->post_id, true ); // } } @@ -155,23 +159,27 @@ function directorist_7100_clean_falsy_never_expire_meta() { } function directorist_7100_migrate_expired_meta_to_expired_status( $updater ) { - $listings = new \WP_Query( array( - 'post_status' => 'private', - 'post_type' => ATBDP_POST_TYPE, - 'posts_per_page' => 10, - 'cache_results' => false, - 'nopaging' => true, - 'meta_key' => '_listing_status', - 'meta_value' => 'expired', - ) ); + $listings = new \WP_Query( + array( + 'post_status' => 'private', + 'post_type' => ATBDP_POST_TYPE, + 'posts_per_page' => 10, + 'cache_results' => false, + 'nopaging' => true, + 'meta_key' => '_listing_status', + 'meta_value' => 'expired', + ) + ); while ( $listings->have_posts() ) { $listings->the_post(); - wp_update_post( array( - 'ID' => get_the_ID(), - 'post_status' => 'expired', - ) ); + wp_update_post( + array( + 'ID' => get_the_ID(), + 'post_status' => 'expired', + ) + ); } wp_reset_postdata(); @@ -182,7 +190,7 @@ function directorist_7100_clean_listing_status_expired_meta() { global $wpdb; $table_name = $wpdb->prefix . 'postmeta'; - $meta_key = '_listing_status'; + $meta_key = '_listing_status'; $meta_value = 'expired'; $wpdb->query( @@ -237,5 +245,5 @@ function directorist_7123_update_db_version() { } function directorist_800_update_db_version() { - \ATBDP_Installation::update_db_version( '8.0.0' ); -} \ No newline at end of file + \ATBDP_Installation::update_db_version( '8.0.0' ); +} diff --git a/includes/widgets/all-categories.php b/includes/widgets/all-categories.php index 7ad66b24c3..8e8967dd42 100644 --- a/includes/widgets/all-categories.php +++ b/includes/widgets/all-categories.php @@ -7,353 +7,359 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class All_Categories extends \WP_Widget { public function __construct() { $id_base = 'bdcw_widget'; - $name = esc_html__( 'Directorist - Categories', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show Categories by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Categories', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show Categories by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Directorist Categories', 'directorist' ), - 'display_as' => 'list', - 'order_by' => 'id', - 'order' => 'asc', - 'max_number' => '', - 'immediate_category' => 1, - 'hide_empty' => 1, - 'show_count' => 1, - 'single_only' => 1, - ]; + $defaults = array( + 'title' => esc_html__( 'Directorist Categories', 'directorist' ), + 'display_as' => 'list', + 'order_by' => 'id', + 'order' => 'asc', + 'max_number' => '', + 'immediate_category' => 1, + 'hide_empty' => 1, + 'show_count' => 1, + 'single_only' => 1, + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'display_as' => [ + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'display_as' => array( 'label' => esc_html__( 'View as:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'list' => esc_html__( 'List', 'directorist' ), - 'dropdown' => esc_html__( 'Dropdown', 'directorist' ) - ] - ], - 'order_by' => [ + 'options' => array( + 'list' => esc_html__( 'List', 'directorist' ), + 'dropdown' => esc_html__( 'Dropdown', 'directorist' ), + ), + ), + 'order_by' => array( 'label' => esc_html__( 'Order By:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'id' => esc_html__( 'Id', 'directorist' ), - 'count' => esc_html__( 'Count', 'directorist' ), - 'name' => esc_html__( 'Name', 'directorist' ), - 'slug' => esc_html__( 'Slug', 'directorist' ) - ] - ], - 'order' => [ + 'options' => array( + 'id' => esc_html__( 'Id', 'directorist' ), + 'count' => esc_html__( 'Count', 'directorist' ), + 'name' => esc_html__( 'Name', 'directorist' ), + 'slug' => esc_html__( 'Slug', 'directorist' ), + ), + ), + 'order' => array( 'label' => esc_html__( 'Sort By:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'asc' => esc_html__( 'Ascending', 'directorist' ), - 'desc' => esc_html__( 'Descending', 'directorist' ), - ] - ], - 'max_number' => [ - 'label' => esc_html__( 'Maximum Number:', 'directorist' ), - 'type' => 'text', - ], - 'immediate_category' => [ - 'label' => esc_html__( 'Show all the top-level categories only', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - 'hide_empty' => [ - 'label' => esc_html__( 'Hide empty categories', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - 'show_count' => [ - 'label' => esc_html__( 'Display listing counts', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - 'single_only' => [ - 'label' => esc_html__( 'Display only on single listing', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - ]; + 'options' => array( + 'asc' => esc_html__( 'Ascending', 'directorist' ), + 'desc' => esc_html__( 'Descending', 'directorist' ), + ), + ), + 'max_number' => array( + 'label' => esc_html__( 'Maximum Number:', 'directorist' ), + 'type' => 'text', + ), + 'immediate_category' => array( + 'label' => esc_html__( 'Show all the top-level categories only', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + 'hide_empty' => array( + 'label' => esc_html__( 'Hide empty categories', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + 'show_count' => array( + 'label' => esc_html__( 'Display listing counts', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + 'single_only' => array( + 'label' => esc_html__( 'Display only on single listing', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; $instance['display_as'] = ! empty( $new_instance['display_as'] ) ? sanitize_text_field( $new_instance['display_as'] ) : 'list'; - $instance['order_by'] = ! empty( $new_instance['order_by'] ) ? sanitize_text_field( $new_instance['order_by'] ) : 'id'; - $instance['order'] = ! empty( $new_instance['order'] ) ? sanitize_text_field( $new_instance['order'] ) : 'asc'; - $instance['immediate_category'] = ! empty( $new_instance['immediate_category'] ) ? 1 : 0; - $instance['hide_empty'] = ! empty( $new_instance['hide_empty'] ) ? 1 : 0; - $instance['show_count'] = ! empty( $new_instance['show_count'] ) ? 1 : 0; - $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; - $instance['max_number'] = ! empty( $new_instance['max_number'] ) ? $new_instance['max_number'] : ''; + $instance['order_by'] = ! empty( $new_instance['order_by'] ) ? sanitize_text_field( $new_instance['order_by'] ) : 'id'; + $instance['order'] = ! empty( $new_instance['order'] ) ? sanitize_text_field( $new_instance['order'] ) : 'asc'; + $instance['immediate_category'] = ! empty( $new_instance['immediate_category'] ) ? 1 : 0; + $instance['hide_empty'] = ! empty( $new_instance['hide_empty'] ) ? 1 : 0; + $instance['show_count'] = ! empty( $new_instance['show_count'] ) ? 1 : 0; + $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; + $instance['max_number'] = ! empty( $new_instance['max_number'] ) ? $new_instance['max_number'] : ''; return $instance; } public function widget( $args, $instance ) { - $allowWidget = apply_filters('atbdp_allow_categories_widget', true); + $allowWidget = apply_filters( 'atbdp_allow_categories_widget', true ); - if( ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) || ! $allowWidget) - return; + if ( ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) || ! $allowWidget ) { + return; + } echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Directorist Categories', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Directorist Categories', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); + $query_args = array( + 'template' => ! empty( $instance['display_as'] ) ? sanitize_text_field( $instance['display_as'] ) : 'list', + 'parent' => ! empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, + 'term_id' => ! empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, + 'hide_empty' => ! empty( $instance['hide_empty'] ) ? 1 : 0, + 'orderby' => ! empty( $instance['order_by'] ) ? sanitize_text_field( $instance['order_by'] ) : 'id', + 'order' => ! empty( $instance['order'] ) ? sanitize_text_field( $instance['order'] ) : 'asc', + 'max_number' => ! empty( $instance['max_number'] ) ? $instance['max_number'] : '', + 'show_count' => ! empty( $instance['show_count'] ) ? 1 : 0, + 'single_only' => ! empty( $instance['single_only'] ) ? 1 : 0, + 'pad_counts' => true, + 'immediate_category' => ! empty( $instance['immediate_category'] ) ? 1 : 0, + 'active_term_id' => 0, + 'ancestors' => array(), + ); + + if ( $query_args['immediate_category'] ) { + + $term_slug = get_query_var( ATBDP_CATEGORY ); + + if ( '' != $term_slug ) { + $term = get_term_by( 'slug', $term_slug, ATBDP_CATEGORY ); + $query_args['active_term_id'] = $term->term_id; + + $query_args['ancestors'] = get_ancestors( $query_args['active_term_id'], 'atbdp_categories' ); + $query_args['ancestors'][] = $query_args['active_term_id']; + $query_args['ancestors'] = array_unique( $query_args['ancestors'] ); + } + } + + if ( 'dropdown' == $query_args['template'] ) { + $categories = $this->dropdown_categories( $query_args ); + } else { + $categories = $this->directorist_categories_list( $query_args ); + } + + Helper::get_template( 'widgets/all-categories', compact( 'args', 'instance', 'query_args', 'categories' ) ); + + echo wp_kses_post( $args['after_widget'] ); + } - $query_args = array( - 'template' => !empty( $instance['display_as'] ) ? sanitize_text_field( $instance['display_as'] ) : 'list', - 'parent' => !empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, - 'term_id' => !empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, - 'hide_empty' => !empty( $instance['hide_empty'] ) ? 1 : 0, - 'orderby' => !empty( $instance['order_by'] ) ? sanitize_text_field( $instance['order_by'] ) : 'id', - 'order' => !empty( $instance['order'] ) ? sanitize_text_field( $instance['order'] ) : 'asc', - 'max_number' => !empty( $instance['max_number'] ) ? $instance['max_number'] : '', - 'show_count' => !empty( $instance['show_count'] ) ? 1 : 0, - 'single_only' => !empty( $instance['single_only'] ) ? 1 : 0, - 'pad_counts' => true, - 'immediate_category' => ! empty( $instance['immediate_category'] ) ? 1 : 0, - 'active_term_id' => 0, - 'ancestors' => array() - ); + public function directorist_categories_list( $settings ) { + if ( $settings['immediate_category'] ) { - if( $query_args['immediate_category'] ) { + if ( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { + return; + } + } - $term_slug = get_query_var( ATBDP_CATEGORY ); + $args = array( + 'taxonomy' => ATBDP_CATEGORY, + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => $settings['term_id'], + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + 'child_of' => 0, + 'number' => ! empty( $settings['max_number'] ) ? $settings['max_number'] : '', + ); + + $terms = get_terms( $args ); + $parent = $args['parent']; + $child_class = ! empty( $parent ) ? 'directorist-taxonomy-list__sub-item' : 'directorist-widget-taxonomy directorist-widget-category'; + $html = ''; + if ( count( $terms ) > 0 ) { + $i = 1; + $html .= '<div class="' . $child_class . '">'; + foreach ( $terms as $term ) { + $settings['term_id'] = $term->term_id; + $child_category = get_term_children( $term->term_id, ATBDP_CATEGORY ); + $plus_icon = ( ! empty( $child_category ) && empty( $parent ) ) ? directorist_icon( 'las la-angle-down', false ) : ''; + $icon = get_term_meta( $term->term_id, 'category_icon', true ); + $child_icon = empty( $parent ) ? directorist_icon( $icon, false ) : ''; + $child_icon_class = $child_icon ? 'directorist-taxonomy-list__icon' : 'directorist-taxonomy-list__icon-default'; + $children = get_term_children( $term->term_id, ATBDP_CATEGORY ); + $has_icon = $parent ? '' : 'directorist-taxonomy-list__card--icon'; + $has_child_class = ''; + + if ( empty( $children ) ) { + $has_child_class = ''; + } else { + $has_child_class = 'directorist-taxonomy-list__toggle'; + } + + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_category( $term->term_id ); + + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } + + $html .= '<div class="directorist-taxonomy-list-one">'; + $html .= '<div class="directorist-taxonomy-list">'; + $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_category_page( $term ) . '" class="directorist-taxonomy-list__card ' . $has_child_class . ' ' . $has_icon . '">'; + $html .= '<span class="' . $child_icon_class . '">' . $child_icon . '</span>'; + $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; + if ( ! empty( $settings['show_count'] ) ) { + $expired_listings = atbdp_get_expired_listings( ATBDP_CATEGORY, $term->term_id ); + $number_of_expired = $expired_listings->post_count; + $number_of_expired = ! empty( $number_of_expired ) ? $number_of_expired : '0'; + $total = ( $count ) ? ( $count - $number_of_expired ) : $count; + $html .= '<span class="directorist-taxonomy-list__count"> (' . $total . ') </span>'; + } + if ( empty( $settings['immediate_category'] ) && empty( $settings['hide_empty'] ) ) { + $html .= $plus_icon ? '<span class="directorist-taxonomy-list__toggler">' . $plus_icon . '</span>' : ''; + } + $html .= '</a>'; + $html .= $this->sub_categories_list( $settings ); + $html .= '</div>'; + $html .= '</div>'; + if ( ! empty( $args['number'] ) ) { + if ( $i++ == $args['number'] ) { + break; + } + } + } + $html .= '</div>'; - if( '' != $term_slug ) { - $term = get_term_by( 'slug', $term_slug, ATBDP_CATEGORY ); - $query_args['active_term_id'] = $term->term_id; + } - $query_args['ancestors'] = get_ancestors( $query_args['active_term_id'], 'atbdp_categories' ); - $query_args['ancestors'][] = $query_args['active_term_id']; - $query_args['ancestors'] = array_unique( $query_args['ancestors'] ); - } + return $html; + } - } + public function sub_categories_list( $settings ) { + if ( $settings['immediate_category'] ) { + if ( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { + return; + } + } - if( 'dropdown' == $query_args['template'] ) { - $categories = $this->dropdown_categories( $query_args ); - } else { - $categories = $this->directorist_categories_list( $query_args ); - } + $args = array( + 'taxonomy' => ATBDP_CATEGORY, + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => $settings['term_id'], + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + 'child_of' => 0, + 'number' => ! empty( $settings['max_number'] ) ? $settings['max_number'] : '', + ); + + $terms = get_terms( $args ); + $parent = $args['parent']; + $child_class = ! empty( $parent ) ? 'directorist-taxonomy-list__sub-item' : ''; + $html = ''; + if ( count( $terms ) > 0 ) { + $i = 1; + $html .= '<ul class="' . $child_class . '">'; + foreach ( $terms as $term ) { + $settings['term_id'] = $term->term_id; + $child_category = get_term_children( $term->term_id, ATBDP_CATEGORY ); + $plus_icon = ( ! empty( $child_category ) ) ? directorist_icon( 'las la-plus', false ) : ''; + $icon = get_term_meta( $term->term_id, 'category_icon', true ); + $child_icon = empty( $parent ) ? directorist_icon( $icon, false ) : ''; + $has_icon = $parent ? '' : 'directorist-taxonomy-list__card--icon'; + + $has_child_class = ''; + if ( empty( $child_category ) ) { + $has_child_class = ''; + } else { + $has_child_class = 'directorist-taxonomy-list__sub-item-toggle'; + } + + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_category( $term->term_id ); + + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } + + $html .= '<li>'; + $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_category_page( $term ) . '" class="' . $has_child_class . ' ' . $child_icon . '">'; + $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; + if ( ! empty( $settings['show_count'] ) ) { + $expired_listings = atbdp_get_expired_listings( ATBDP_CATEGORY, $term->term_id ); + $number_of_expired = $expired_listings->post_count; + $number_of_expired = ! empty( $number_of_expired ) ? $number_of_expired : '0'; + $total = ( $count ) ? ( $count - $number_of_expired ) : $count; + $html .= '<span class="directorist-taxonomy-list__count"> (' . + $total . ') </span>'; + } + $html .= $plus_icon ? '<span class="directorist-taxonomy-list__sub-item-toggler"></span>' : ''; + $html .= '</a>'; + $html .= $this->sub_categories_list( $settings ); + $html .= '</li>'; + if ( ! empty( $args['number'] ) ) { + if ( $i++ == $args['number'] ) { + break; + } + } + } + $html .= '</ul>'; - Helper::get_template( 'widgets/all-categories', compact( 'args', 'instance', 'query_args', 'categories' ) ); + } - echo wp_kses_post( $args['after_widget'] ); + return $html; } - public function directorist_categories_list( $settings ) { - - if( $settings['immediate_category'] ) { - - if( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { - return; - } - - } - - $args = array( - 'taxonomy' => ATBDP_CATEGORY, - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => $settings['term_id'], - 'hierarchical' => !empty( $settings['hide_empty'] ) ? true : false, - 'child_of' => 0, - 'number' => !empty($settings['max_number']) ? $settings['max_number'] : '' - ); - - $terms = get_terms( $args ); - $parent = $args['parent']; - $child_class = !empty($parent) ? 'directorist-taxonomy-list__sub-item' : 'directorist-widget-taxonomy directorist-widget-category'; - $html = ''; - if( count( $terms ) > 0 ) { - $i = 1; - $html .= '<div class="' .$child_class. '">'; - foreach( $terms as $term ) { - $settings['term_id'] = $term->term_id; - $child_category = get_term_children( $term->term_id, ATBDP_CATEGORY ); - $plus_icon = (!empty($child_category) && empty($parent) )? directorist_icon( 'las la-angle-down', false ) : ''; - $icon = get_term_meta($term->term_id,'category_icon',true); - $child_icon = empty($parent) ? directorist_icon( $icon, false ) : ''; - $child_icon_class = $child_icon ? 'directorist-taxonomy-list__icon' : 'directorist-taxonomy-list__icon-default'; - $children = get_term_children( $term->term_id, ATBDP_CATEGORY ); - $has_icon = $parent ? '' : 'directorist-taxonomy-list__card--icon'; - $has_child_class = ''; - - if ( empty( $children ) ) { - $has_child_class = ''; - } else { - $has_child_class = 'directorist-taxonomy-list__toggle'; - } - - $count = 0; - if( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { - $count = atbdp_listings_count_by_category( $term->term_id ); - - if( ! empty( $settings['hide_empty'] ) && 0 == $count ) continue; - } - - $html .= '<div class="directorist-taxonomy-list-one">'; - $html .= '<div class="directorist-taxonomy-list">'; - $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_category_page( $term ) . '" class="directorist-taxonomy-list__card ' . $has_child_class . ' ' . $has_icon . '">'; - $html .= '<span class="' . $child_icon_class . '">' . $child_icon . '</span>'; - $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; - if( ! empty( $settings['show_count'] ) ) { - $expired_listings = atbdp_get_expired_listings(ATBDP_CATEGORY, $term->term_id); - $number_of_expired = $expired_listings->post_count; - $number_of_expired = !empty($number_of_expired)?$number_of_expired:'0'; - $total = ($count)?($count-$number_of_expired):$count; - $html .= '<span class="directorist-taxonomy-list__count"> (' . $total . ') </span>'; - } - if( empty( $settings['immediate_category'] ) && empty( $settings['hide_empty'] ) ) { - $html .= $plus_icon ? '<span class="directorist-taxonomy-list__toggler">'. $plus_icon . '</span>' : ''; - } - $html .= '</a>'; - $html .= $this->sub_categories_list( $settings ); - $html .= '</div>'; - $html .= '</div>'; - if(!empty($args['number'])) { - if( $i++ == $args['number'] ) break; - } - } - $html .= '</div>'; - - } - - return $html; - - } - - public function sub_categories_list( $settings ) { - if( $settings['immediate_category'] ) { - if( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { - return; - } - } - - $args = array( - 'taxonomy' => ATBDP_CATEGORY, - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => $settings['term_id'], - 'hierarchical' => !empty( $settings['hide_empty'] ) ? true : false, - 'child_of' => 0, - 'number' => !empty($settings['max_number']) ? $settings['max_number'] : '' - ); - - $terms = get_terms( $args ); - $parent = $args['parent']; - $child_class = !empty($parent) ? 'directorist-taxonomy-list__sub-item' : ''; - $html = ''; - if( count( $terms ) > 0 ) { - $i = 1; - $html .= '<ul class="' .$child_class. '">'; - foreach( $terms as $term ) { - $settings['term_id'] = $term->term_id; - $child_category = get_term_children( $term->term_id, ATBDP_CATEGORY ); - $plus_icon = (!empty($child_category) )? directorist_icon( 'las la-plus', false ) : ''; - $icon = get_term_meta($term->term_id,'category_icon',true); - $child_icon = empty($parent) ? directorist_icon( $icon, false ) : ''; - $has_icon = $parent ? '' : 'directorist-taxonomy-list__card--icon'; - - $has_child_class = ''; - if ( empty( $child_category ) ) { - $has_child_class = ''; - } else { - $has_child_class = 'directorist-taxonomy-list__sub-item-toggle'; - } - - $count = 0; - if( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { - $count = atbdp_listings_count_by_category( $term->term_id ); - - if( ! empty( $settings['hide_empty'] ) && 0 == $count ) continue; - } - - $html .= '<li>'; - $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_category_page( $term ) . '" class="' . $has_child_class . ' ' . $child_icon . '">'; - $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; - if( ! empty( $settings['show_count'] ) ) { - $expired_listings = atbdp_get_expired_listings(ATBDP_CATEGORY, $term->term_id); - $number_of_expired = $expired_listings->post_count; - $number_of_expired = !empty($number_of_expired)?$number_of_expired:'0'; - $total = ($count)?($count-$number_of_expired):$count; - $html .= '<span class="directorist-taxonomy-list__count"> (' . - $total . ') </span>'; - } - $html .= $plus_icon ? '<span class="directorist-taxonomy-list__sub-item-toggler"></span>' : ''; - $html .= '</a>'; - $html .= $this->sub_categories_list( $settings ); - $html .= '</li>'; - if(!empty($args['number'])) { - if( $i++ == $args['number'] ) break; - } - } - $html .= '</ul>'; - - } - - return $html; - } - - public function dropdown_categories( $settings, $prefix = '' ) { - if ( $settings['immediate_category'] && + public function dropdown_categories( $settings, $prefix = '' ) { + if ( $settings['immediate_category'] && ( $settings['term_id'] > $settings['parent'] ) && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { return; - } + } - $term_slug = get_query_var( ATBDP_CATEGORY ); + $term_slug = get_query_var( ATBDP_CATEGORY ); - $args = array( - 'taxonomy' => ATBDP_CATEGORY, - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => !empty($settings['term_id']) ? $settings['term_id'] : '', - 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, - 'number' => !empty($settings['max_number']) ? $settings['max_number'] : '' - ); + $args = array( + 'taxonomy' => ATBDP_CATEGORY, + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => ! empty( $settings['term_id'] ) ? $settings['term_id'] : '', + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + 'number' => ! empty( $settings['max_number'] ) ? $settings['max_number'] : '', + ); - $terms = get_terms( $args ); + $terms = get_terms( $args ); if ( is_wp_error( $terms ) ) { return; } - $html = ''; + $html = ''; - foreach( $terms as $term ) { + foreach ( $terms as $term ) { $settings['term_id'] = $term->term_id; $html .= sprintf( '<option value="%s" %s>', $term->term_id, selected( $term->term_id, $term_slug, false ) ); @@ -363,10 +369,10 @@ public function dropdown_categories( $settings, $prefix = '' ) { $html .= ' (' . $term->count . ')'; } - //$html .= $this->dropdown_locations( $settings, $prefix . ' ' ); + // $html .= $this->dropdown_locations( $settings, $prefix . ' ' ); $html .= '</option>'; } - return $html; - } -} \ No newline at end of file + return $html; + } +} diff --git a/includes/widgets/all-locations.php b/includes/widgets/all-locations.php index 846af170df..d4614a0503 100644 --- a/includes/widgets/all-locations.php +++ b/includes/widgets/all-locations.php @@ -7,357 +7,365 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class All_Locations extends \WP_Widget { public function __construct() { $id_base = 'bdlw_widget'; - $name = esc_html__( 'Directorist - Locations', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show Locations by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Locations', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show Locations by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Directorist Locations', 'directorist' ), - 'display_as' => 'list', - 'order_by' => 'id', - 'order' => 'asc', - 'max_number' => '', - 'immediate_category' => '', - 'hide_empty' => '', - 'show_count' => '', - 'single_only' => '', - ]; + $defaults = array( + 'title' => esc_html__( 'Directorist Locations', 'directorist' ), + 'display_as' => 'list', + 'order_by' => 'id', + 'order' => 'asc', + 'max_number' => '', + 'immediate_category' => '', + 'hide_empty' => '', + 'show_count' => '', + 'single_only' => '', + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'display_as' => [ + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'display_as' => array( 'label' => esc_html__( 'View as:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'list' => esc_html__( 'List', 'directorist' ), - 'dropdown' => esc_html__( 'Dropdown', 'directorist' ) - ] - ], - 'order_by' => [ + 'options' => array( + 'list' => esc_html__( 'List', 'directorist' ), + 'dropdown' => esc_html__( 'Dropdown', 'directorist' ), + ), + ), + 'order_by' => array( 'label' => esc_html__( 'Order By:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'id' => esc_html__( 'Id', 'directorist' ), - 'count' => esc_html__( 'Count', 'directorist' ), - 'name' => esc_html__( 'Name', 'directorist' ), - 'slug' => esc_html__( 'Slug', 'directorist' ) - ] - ], - 'order' => [ + 'options' => array( + 'id' => esc_html__( 'Id', 'directorist' ), + 'count' => esc_html__( 'Count', 'directorist' ), + 'name' => esc_html__( 'Name', 'directorist' ), + 'slug' => esc_html__( 'Slug', 'directorist' ), + ), + ), + 'order' => array( 'label' => esc_html__( 'Sort By:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'asc' => esc_html__( 'Ascending', 'directorist' ), - 'desc' => esc_html__( 'Descending', 'directorist' ), - ] - ], - 'max_number' => [ - 'label' => esc_html__( 'Maximum Number:', 'directorist' ), - 'type' => 'text', - ], - 'immediate_category' => [ - 'label' => esc_html__( 'Show all the top-level locations only', 'directorist' ), - 'type' => 'checkbox', - ], - 'hide_empty' => [ - 'label' => esc_html__( 'Hide empty locations', 'directorist' ), - 'type' => 'checkbox', - ], - 'show_count' => [ - 'label' => esc_html__( 'Display listing counts', 'directorist' ), - 'type' => 'checkbox', - ], - 'single_only' => [ - 'label' => esc_html__( 'Display only on single listing', 'directorist' ), - 'type' => 'checkbox', - ], - ]; + 'options' => array( + 'asc' => esc_html__( 'Ascending', 'directorist' ), + 'desc' => esc_html__( 'Descending', 'directorist' ), + ), + ), + 'max_number' => array( + 'label' => esc_html__( 'Maximum Number:', 'directorist' ), + 'type' => 'text', + ), + 'immediate_category' => array( + 'label' => esc_html__( 'Show all the top-level locations only', 'directorist' ), + 'type' => 'checkbox', + ), + 'hide_empty' => array( + 'label' => esc_html__( 'Hide empty locations', 'directorist' ), + 'type' => 'checkbox', + ), + 'show_count' => array( + 'label' => esc_html__( 'Display listing counts', 'directorist' ), + 'type' => 'checkbox', + ), + 'single_only' => array( + 'label' => esc_html__( 'Display only on single listing', 'directorist' ), + 'type' => 'checkbox', + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; $instance['display_as'] = ! empty( $new_instance['display_as'] ) ? sanitize_text_field( $new_instance['display_as'] ) : 'list'; - $instance['order_by'] = ! empty( $new_instance['order_by'] ) ? sanitize_text_field( $new_instance['order_by'] ) : 'id'; - $instance['order'] = ! empty( $new_instance['order'] ) ? sanitize_text_field( $new_instance['order'] ) : 'asc'; - $instance['immediate_category'] = ! empty( $new_instance['immediate_category'] ) ? 1 : 0; - $instance['hide_empty'] = ! empty( $new_instance['hide_empty'] ) ? 1 : 0; - $instance['show_count'] = ! empty( $new_instance['show_count'] ) ? 1 : 0; - $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; - $instance['max_number'] = ! empty( $new_instance['max_number'] ) ? $new_instance['max_number'] : ''; + $instance['order_by'] = ! empty( $new_instance['order_by'] ) ? sanitize_text_field( $new_instance['order_by'] ) : 'id'; + $instance['order'] = ! empty( $new_instance['order'] ) ? sanitize_text_field( $new_instance['order'] ) : 'asc'; + $instance['immediate_category'] = ! empty( $new_instance['immediate_category'] ) ? 1 : 0; + $instance['hide_empty'] = ! empty( $new_instance['hide_empty'] ) ? 1 : 0; + $instance['show_count'] = ! empty( $new_instance['show_count'] ) ? 1 : 0; + $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; + $instance['max_number'] = ! empty( $new_instance['max_number'] ) ? $new_instance['max_number'] : ''; return $instance; } public function widget( $args, $instance ) { - $allowWidget = apply_filters('atbdp_allow_locations_widget', true); + $allowWidget = apply_filters( 'atbdp_allow_locations_widget', true ); - if( ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) || ! $allowWidget) - return; + if ( ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) || ! $allowWidget ) { + return; + } echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Directorist Locations', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Directorist Locations', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); - $query_args = array( - 'template' => !empty( $instance['display_as'] ) ? sanitize_text_field( $instance['display_as'] ) : 'list', - 'parent' => !empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, - 'term_id' => !empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, - 'hide_empty' => !empty( $instance['hide_empty'] ) ? 1 : 0, - 'orderby' => !empty( $instance['order_by'] ) ? sanitize_text_field( $instance['order_by'] ) : 'id', - 'order' => !empty( $instance['order'] ) ? sanitize_text_field( $instance['order'] ) : 'asc', - 'max_number' => !empty( $instance['max_number'] ) ? $instance['max_number'] : '', - 'show_count' => !empty( $instance['show_count'] ) ? 1 : 0, - 'single_only' => !empty( $instance['single_only'] ) ? 1 : 0, - 'pad_counts' => true, - 'immediate_category' => ! empty( $instance['immediate_category'] ) ? 1 : 0, - 'active_term_id' => 0, - 'ancestors' => array() - ); - - - if( $query_args['immediate_category'] ) { - - $term_slug = get_query_var( ATBDP_LOCATION ); - - if( '' != $term_slug ) { - $term = get_term_by( 'slug', $term_slug, ATBDP_LOCATION ); + $query_args = array( + 'template' => ! empty( $instance['display_as'] ) ? sanitize_text_field( $instance['display_as'] ) : 'list', + 'parent' => ! empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, + 'term_id' => ! empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, + 'hide_empty' => ! empty( $instance['hide_empty'] ) ? 1 : 0, + 'orderby' => ! empty( $instance['order_by'] ) ? sanitize_text_field( $instance['order_by'] ) : 'id', + 'order' => ! empty( $instance['order'] ) ? sanitize_text_field( $instance['order'] ) : 'asc', + 'max_number' => ! empty( $instance['max_number'] ) ? $instance['max_number'] : '', + 'show_count' => ! empty( $instance['show_count'] ) ? 1 : 0, + 'single_only' => ! empty( $instance['single_only'] ) ? 1 : 0, + 'pad_counts' => true, + 'immediate_category' => ! empty( $instance['immediate_category'] ) ? 1 : 0, + 'active_term_id' => 0, + 'ancestors' => array(), + ); + + if ( $query_args['immediate_category'] ) { + + $term_slug = get_query_var( ATBDP_LOCATION ); + + if ( '' != $term_slug ) { + $term = get_term_by( 'slug', $term_slug, ATBDP_LOCATION ); $query_args['active_term_id'] = $term->term_id; - $query_args['ancestors'] = get_ancestors( $query_args['active_term_id'], 'atbdp_categories' ); + $query_args['ancestors'] = get_ancestors( $query_args['active_term_id'], 'atbdp_categories' ); $query_args['ancestors'][] = $query_args['active_term_id']; - $query_args['ancestors'] = array_unique( $query_args['ancestors'] ); - } - - } + $query_args['ancestors'] = array_unique( $query_args['ancestors'] ); + } + } - if( 'dropdown' == $query_args['template'] ) { - $categories = $this->dropdown_locations( $query_args ); - } else { - $categories = $this->list_locations( $query_args ); - } + if ( 'dropdown' == $query_args['template'] ) { + $categories = $this->dropdown_locations( $query_args ); + } else { + $categories = $this->list_locations( $query_args ); + } Helper::get_template( 'widgets/all-locations', compact( 'args', 'instance', 'query_args', 'categories' ) ); echo wp_kses_post( $args['after_widget'] ); } - public function list_locations( $settings ) { - - if( $settings['immediate_category'] ) { - - if( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { - return; - } - - } - - $args = array( - 'taxonomy' => ATBDP_LOCATION, - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => $settings['term_id'], - 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, - 'number' => !empty($settings['max_number']) ? $settings['max_number'] : '' - ); - - $terms = get_terms( $args ); - $parent = $args['parent']; - $child_class = !empty($parent) ? 'directorist-taxonomy-list__sub-item' : 'directorist-widget-taxonomy directorist-widget-location'; - $html = ''; - - if( count( $terms ) > 0 ) { - $i = 1; - $html .= '<div class="' .$child_class. '">'; - foreach( $terms as $term ) { - $child_category = get_term_children($term->term_id,ATBDP_LOCATION); - $plus_icon = (!empty($child_category) && empty($parent) ) ? directorist_icon( 'las la-angle-down', false ) : ''; - $settings['term_id'] = $term->term_id; - - $count = 0; - if( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { - $count = atbdp_listings_count_by_location( $term->term_id ); - - if( ! empty( $settings['hide_empty'] ) && 0 == $count ) continue; - } - - $html .= '<div class="directorist-taxonomy-list-one">'; - $html .= '<div class="directorist-taxonomy-list">'; - $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_location_page( $term ) . '" class="directorist-taxonomy-list__card directorist-taxonomy-list__toggle">'; - $html .= '<span class="directorist-taxonomy-list__name">'. $term->name .'</span>'; - if( ! empty( $settings['show_count'] ) ) { - $expired_listings = atbdp_get_expired_listings(ATBDP_LOCATION, $term->term_id); - $number_of_expired = $expired_listings->post_count; - $number_of_expired = !empty($number_of_expired)?$number_of_expired:'0'; - $total = ($count)?($count-$number_of_expired):$count; - $html .= '<span class="directorist-taxonomy-list__count">(' . $total . ')</span>'; - } - if( empty( $settings['immediate_category'] ) && empty( $settings['hide_empty'] ) ) { - $html .= $plus_icon ? '<span class="directorist-taxonomy-list__toggler">'. $plus_icon . '</span>' : ''; - } - $html .= '</a>'; - $html .= $this->sub_locations_list( $settings ); - $html .= '</div>'; - $html .= '</div>'; - if(!empty($args['number'])) { - if( $i++ == $args['number'] ) break; - } - } - $html .= '</div>'; - - } - - return $html; - - } - - public function sub_locations_list( $settings ) { - if( $settings['immediate_category'] ) { - if( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { - return; - } - } - - $args = array( - 'taxonomy' => ATBDP_LOCATION, - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => $settings['term_id'], - 'hierarchical' => !empty( $settings['hide_empty'] ) ? true : false, - 'child_of' => 0, - 'number' => !empty($settings['max_number']) ? $settings['max_number'] : '' - ); - - $terms = get_terms( $args ); - $parent = $args['parent']; - $child_class = !empty($parent) ? 'directorist-taxonomy-list__sub-item' : ''; - $html = ''; - if( count( $terms ) > 0 ) { - $i = 1; - $html .= '<ul class="' .$child_class. '">'; - foreach( $terms as $term ) { - $settings['term_id'] = $term->term_id; - $child_category = get_term_children( $term->term_id, ATBDP_LOCATION ); - $plus_icon = (!empty($child_category) )? directorist_icon( 'las la-plus', false ) : ''; - $icon = get_term_meta($term->term_id,'category_icon',true); - $child_icon = empty($parent) ? directorist_icon( $icon, false ) : ''; - - $has_child_class = ''; - if ( empty( $child_category ) ) { - $has_child_class = ''; - } else { - $has_child_class = 'directorist-taxonomy-list__sub-item-toggle'; - } - - $count = 0; - if( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { - $count = atbdp_listings_count_by_location( $term->term_id ); - - if( ! empty( $settings['hide_empty'] ) && 0 == $count ) continue; - } - - $html .= '<li>'; - $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_location_page( $term ) . '" class="' . $has_child_class . ' ' . $child_icon . '">'; - $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; - if( ! empty( $settings['show_count'] ) ) { - $expired_listings = atbdp_get_expired_listings(ATBDP_LOCATION, $term->term_id); - $number_of_expired = $expired_listings->post_count; - $number_of_expired = !empty($number_of_expired)?$number_of_expired:'0'; - $total = ($count)?($count-$number_of_expired):$count; - $html .= '<span class="directorist-taxonomy-list__count"> (' . - $total . ') </span>'; - } - $html .= $plus_icon ? '<span class="directorist-taxonomy-list__sub-item-toggler"></span>' : ''; - $html .= '</a>'; - $html .= $this->sub_locations_list( $settings ); - $html .= '</li>'; - if(!empty($args['number'])) { - if( $i++ == $args['number'] ) break; - } - } - $html .= '</ul>'; - - } - - return $html; - } - - public function dropdown_locations( $settings, $prefix = '' ) { - - if( $settings['immediate_category'] ) { - - if( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { - return; - } - - } - - $term_slug = get_query_var( ATBDP_LOCATION ); - - $args = array( - 'taxonomy' => ATBDP_LOCATION, - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => !empty($settings['term_id']) ? $settings['term_id'] : '', - 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, - 'number' => !empty($settings['max_number']) ? $settings['max_number'] : '' - ); - - $terms = get_terms( $args ); - - $html = ''; - - if( count( $terms ) > 0 ) { - $i = 1; - foreach( $terms as $term ) { - $settings['term_id'] = $term->term_id; - - $count = 0; - if( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { - $count = atbdp_listings_count_by_category( $term->term_id ); - - if( ! empty( $settings['hide_empty'] ) && 0 == $count ) continue; - } - - $html .= sprintf( '<option value="%s" %s>', $term->term_id, selected( $term->term_id, $term_slug, false ) ); - $html .= $prefix . $term->name; - if( ! empty( $settings['show_count'] ) ) { - $html .= ' (' . $count . ')'; - } - //$html .= $this->dropdown_locations( $settings, $prefix . ' ' ); - $html .= '</option>'; - if(!empty($args['number'])) { - if( $i++ == $args['number'] ) break; - } - } - - } - - return $html; - - } + public function list_locations( $settings ) { + + if ( $settings['immediate_category'] ) { + + if ( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { + return; + } + } + + $args = array( + 'taxonomy' => ATBDP_LOCATION, + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => $settings['term_id'], + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + 'number' => ! empty( $settings['max_number'] ) ? $settings['max_number'] : '', + ); + + $terms = get_terms( $args ); + $parent = $args['parent']; + $child_class = ! empty( $parent ) ? 'directorist-taxonomy-list__sub-item' : 'directorist-widget-taxonomy directorist-widget-location'; + $html = ''; + + if ( count( $terms ) > 0 ) { + $i = 1; + $html .= '<div class="' . $child_class . '">'; + foreach ( $terms as $term ) { + $child_category = get_term_children( $term->term_id, ATBDP_LOCATION ); + $plus_icon = ( ! empty( $child_category ) && empty( $parent ) ) ? directorist_icon( 'las la-angle-down', false ) : ''; + $settings['term_id'] = $term->term_id; + + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_location( $term->term_id ); + + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } + + $html .= '<div class="directorist-taxonomy-list-one">'; + $html .= '<div class="directorist-taxonomy-list">'; + $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_location_page( $term ) . '" class="directorist-taxonomy-list__card directorist-taxonomy-list__toggle">'; + $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; + if ( ! empty( $settings['show_count'] ) ) { + $expired_listings = atbdp_get_expired_listings( ATBDP_LOCATION, $term->term_id ); + $number_of_expired = $expired_listings->post_count; + $number_of_expired = ! empty( $number_of_expired ) ? $number_of_expired : '0'; + $total = ( $count ) ? ( $count - $number_of_expired ) : $count; + $html .= '<span class="directorist-taxonomy-list__count">(' . $total . ')</span>'; + } + if ( empty( $settings['immediate_category'] ) && empty( $settings['hide_empty'] ) ) { + $html .= $plus_icon ? '<span class="directorist-taxonomy-list__toggler">' . $plus_icon . '</span>' : ''; + } + $html .= '</a>'; + $html .= $this->sub_locations_list( $settings ); + $html .= '</div>'; + $html .= '</div>'; + if ( ! empty( $args['number'] ) ) { + if ( $i++ == $args['number'] ) { + break; + } + } + } + $html .= '</div>'; + + } + + return $html; + } + + public function sub_locations_list( $settings ) { + if ( $settings['immediate_category'] ) { + if ( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { + return; + } + } + + $args = array( + 'taxonomy' => ATBDP_LOCATION, + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => $settings['term_id'], + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + 'child_of' => 0, + 'number' => ! empty( $settings['max_number'] ) ? $settings['max_number'] : '', + ); + + $terms = get_terms( $args ); + $parent = $args['parent']; + $child_class = ! empty( $parent ) ? 'directorist-taxonomy-list__sub-item' : ''; + $html = ''; + if ( count( $terms ) > 0 ) { + $i = 1; + $html .= '<ul class="' . $child_class . '">'; + foreach ( $terms as $term ) { + $settings['term_id'] = $term->term_id; + $child_category = get_term_children( $term->term_id, ATBDP_LOCATION ); + $plus_icon = ( ! empty( $child_category ) ) ? directorist_icon( 'las la-plus', false ) : ''; + $icon = get_term_meta( $term->term_id, 'category_icon', true ); + $child_icon = empty( $parent ) ? directorist_icon( $icon, false ) : ''; + + $has_child_class = ''; + if ( empty( $child_category ) ) { + $has_child_class = ''; + } else { + $has_child_class = 'directorist-taxonomy-list__sub-item-toggle'; + } + + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_location( $term->term_id ); + + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } + + $html .= '<li>'; + $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_location_page( $term ) . '" class="' . $has_child_class . ' ' . $child_icon . '">'; + $html .= '<span class="directorist-taxonomy-list__name">' . $term->name . '</span>'; + if ( ! empty( $settings['show_count'] ) ) { + $expired_listings = atbdp_get_expired_listings( ATBDP_LOCATION, $term->term_id ); + $number_of_expired = $expired_listings->post_count; + $number_of_expired = ! empty( $number_of_expired ) ? $number_of_expired : '0'; + $total = ( $count ) ? ( $count - $number_of_expired ) : $count; + $html .= '<span class="directorist-taxonomy-list__count"> (' . + $total . ') </span>'; + } + $html .= $plus_icon ? '<span class="directorist-taxonomy-list__sub-item-toggler"></span>' : ''; + $html .= '</a>'; + $html .= $this->sub_locations_list( $settings ); + $html .= '</li>'; + if ( ! empty( $args['number'] ) ) { + if ( $i++ == $args['number'] ) { + break; + } + } + } + $html .= '</ul>'; + + } + + return $html; + } + + public function dropdown_locations( $settings, $prefix = '' ) { + + if ( $settings['immediate_category'] ) { + + if ( $settings['term_id'] > $settings['parent'] && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { + return; + } + } + + $term_slug = get_query_var( ATBDP_LOCATION ); + + $args = array( + 'taxonomy' => ATBDP_LOCATION, + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => ! empty( $settings['term_id'] ) ? $settings['term_id'] : '', + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + 'number' => ! empty( $settings['max_number'] ) ? $settings['max_number'] : '', + ); + + $terms = get_terms( $args ); + + $html = ''; + + if ( count( $terms ) > 0 ) { + $i = 1; + foreach ( $terms as $term ) { + $settings['term_id'] = $term->term_id; + + $count = 0; + if ( ! empty( $settings['hide_empty'] ) || ! empty( $settings['show_count'] ) ) { + $count = atbdp_listings_count_by_category( $term->term_id ); + + if ( ! empty( $settings['hide_empty'] ) && 0 == $count ) { + continue; + } + } + + $html .= sprintf( '<option value="%s" %s>', $term->term_id, selected( $term->term_id, $term_slug, false ) ); + $html .= $prefix . $term->name; + if ( ! empty( $settings['show_count'] ) ) { + $html .= ' (' . $count . ')'; + } + // $html .= $this->dropdown_locations( $settings, $prefix . ' ' ); + $html .= '</option>'; + if ( ! empty( $args['number'] ) ) { + if ( $i++ == $args['number'] ) { + break; + } + } + } + } + + return $html; + } } diff --git a/includes/widgets/all-tags.php b/includes/widgets/all-tags.php index 729a1cabcb..43b09e55ff 100644 --- a/includes/widgets/all-tags.php +++ b/includes/widgets/all-tags.php @@ -7,200 +7,202 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class All_Tags extends \WP_Widget { public function __construct() { $id_base = 'bdtw_widget'; - $name = esc_html__( 'Directorist - Tags', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show listing tags by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Tags', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show listing tags by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Tags', 'directorist' ), - 'display_as' => 'list', - 'order_by' => 'id', - 'order' => 'asc', - 'max_number' => '', - 'hide_empty' => 0, - 'show_count' => 0, - 'display_single_tag' => 0, - ]; + $defaults = array( + 'title' => esc_html__( 'Tags', 'directorist' ), + 'display_as' => 'list', + 'order_by' => 'id', + 'order' => 'asc', + 'max_number' => '', + 'hide_empty' => 0, + 'show_count' => 0, + 'display_single_tag' => 0, + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'display_as' => [ + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'display_as' => array( 'label' => esc_html__( 'View as:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'list' => esc_html__( 'List', 'directorist' ), - 'dropdown' => esc_html__( 'Dropdown', 'directorist' ) - ] - ], - 'order_by' => [ + 'options' => array( + 'list' => esc_html__( 'List', 'directorist' ), + 'dropdown' => esc_html__( 'Dropdown', 'directorist' ), + ), + ), + 'order_by' => array( 'label' => esc_html__( 'Order By:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'id' => esc_html__( 'Id', 'directorist' ), - 'count' => esc_html__( 'Count', 'directorist' ), - 'name' => esc_html__( 'Name', 'directorist' ), - 'slug' => esc_html__( 'Slug', 'directorist' ) - ] - ], - 'order' => [ + 'options' => array( + 'id' => esc_html__( 'Id', 'directorist' ), + 'count' => esc_html__( 'Count', 'directorist' ), + 'name' => esc_html__( 'Name', 'directorist' ), + 'slug' => esc_html__( 'Slug', 'directorist' ), + ), + ), + 'order' => array( 'label' => esc_html__( 'Sort By:', 'directorist' ), 'type' => 'select', - 'options' => [ - 'asc' => esc_html__( 'Ascending', 'directorist' ), - 'desc' => esc_html__( 'Descending', 'directorist' ), - ] - ], - 'max_number' => [ - 'label' => esc_html__( 'Maximum Number:', 'directorist' ), - 'type' => 'text', - ], - 'hide_empty' => [ - 'label' => esc_html__( 'Hide empty tags', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - 'show_count' => [ - 'label' => esc_html__( 'Display listing counts', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - 'display_single_tag' => [ - 'label' => esc_html__( 'Display single listing tags', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - ]; + 'options' => array( + 'asc' => esc_html__( 'Ascending', 'directorist' ), + 'desc' => esc_html__( 'Descending', 'directorist' ), + ), + ), + 'max_number' => array( + 'label' => esc_html__( 'Maximum Number:', 'directorist' ), + 'type' => 'text', + ), + 'hide_empty' => array( + 'label' => esc_html__( 'Hide empty tags', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + 'show_count' => array( + 'label' => esc_html__( 'Display listing counts', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + 'display_single_tag' => array( + 'label' => esc_html__( 'Display single listing tags', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; $instance['display_as'] = ! empty( $new_instance['display_as'] ) ? sanitize_text_field( $new_instance['display_as'] ) : 'list'; - $instance['order_by'] = ! empty( $new_instance['order_by'] ) ? sanitize_text_field( $new_instance['order_by'] ) : 'id'; - $instance['order'] = ! empty( $new_instance['order'] ) ? sanitize_text_field( $new_instance['order'] ) : 'asc'; - $instance['hide_empty'] = ! empty( $new_instance['hide_empty'] ) ? 1 : 0; - $instance['show_count'] = ! empty( $new_instance['show_count'] ) ? 1 : 0; - $instance['display_single_tag'] = ! empty( $new_instance['display_single_tag'] ) ? 1 : 0; - $instance['max_number'] = ! empty( $new_instance['max_number'] ) ? $new_instance['max_number'] : ''; + $instance['order_by'] = ! empty( $new_instance['order_by'] ) ? sanitize_text_field( $new_instance['order_by'] ) : 'id'; + $instance['order'] = ! empty( $new_instance['order'] ) ? sanitize_text_field( $new_instance['order'] ) : 'asc'; + $instance['hide_empty'] = ! empty( $new_instance['hide_empty'] ) ? 1 : 0; + $instance['show_count'] = ! empty( $new_instance['show_count'] ) ? 1 : 0; + $instance['display_single_tag'] = ! empty( $new_instance['display_single_tag'] ) ? 1 : 0; + $instance['max_number'] = ! empty( $new_instance['max_number'] ) ? $new_instance['max_number'] : ''; return $instance; } public function widget( $args, $instance ) { - $allowWidget = apply_filters('atbdp_allow_tags_widget', true); - $check_tag = get_the_terms(get_the_ID(), ATBDP_TAGS); + $allowWidget = apply_filters( 'atbdp_allow_tags_widget', true ); + $check_tag = get_the_terms( get_the_ID(), ATBDP_TAGS ); - if( ( ! empty( $instance['display_single_tag'] ) && ! is_singular( ATBDP_POST_TYPE ) && ! $check_tag ) || ! $allowWidget) - return; + if ( ( ! empty( $instance['display_single_tag'] ) && ! is_singular( ATBDP_POST_TYPE ) && ! $check_tag ) || ! $allowWidget ) { + return; + } echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Tags', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Tags', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); - $query_args = array( - 'template' => !empty( $instance['display_as'] ) ? sanitize_text_field( $instance['display_as'] ) : 'list', - 'parent' => !empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, - 'term_id' => !empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, - 'hide_empty' => !empty( $instance['hide_empty'] ) ? 1 : 0, - 'orderby' => !empty( $instance['order_by'] ) ? sanitize_text_field( $instance['order_by'] ) : 'id', - 'order' => !empty( $instance['order'] ) ? sanitize_text_field( $instance['order'] ) : 'asc', - 'show_count' => !empty( $instance['show_count'] ) ? 1 : 0, - 'display_single_tag' => !empty( $instance['display_single_tag'] ) ? 1 : 0, - 'pad_counts' => true, - 'immediate_category' => !empty( $instance['immediate_category'] ) ? 1 : 0, - 'max_number' => !empty( $instance['max_number'] ) ? $instance['max_number'] : '', - 'active_term_id' => 0, - 'ancestors' => array() - ); - - if( $query_args['immediate_category'] ) { - - $term_slug = get_query_var( ATBDP_TAGS ); - - if( '' != $term_slug ) { - $term = get_term_by( 'slug', $term_slug, ATBDP_TAGS ); - $query_args['active_term_id'] = $term->term_id; - - $query_args['ancestors'] = get_ancestors( $query_args['active_term_id'], 'atbdp_tags' ); - $query_args['ancestors'][] = $query_args['active_term_id']; - $query_args['ancestors'] = array_unique( $query_args['ancestors'] ); - } - - } - - if( 'dropdown' == $query_args['template'] ) { - $tags = $this->dropdown_tags( $query_args ); - } else { - $tags = $this->directorist_tags_list( $query_args ); - } + $query_args = array( + 'template' => ! empty( $instance['display_as'] ) ? sanitize_text_field( $instance['display_as'] ) : 'list', + 'parent' => ! empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, + 'term_id' => ! empty( $instance['parent'] ) ? (int) $instance['parent'] : 0, + 'hide_empty' => ! empty( $instance['hide_empty'] ) ? 1 : 0, + 'orderby' => ! empty( $instance['order_by'] ) ? sanitize_text_field( $instance['order_by'] ) : 'id', + 'order' => ! empty( $instance['order'] ) ? sanitize_text_field( $instance['order'] ) : 'asc', + 'show_count' => ! empty( $instance['show_count'] ) ? 1 : 0, + 'display_single_tag' => ! empty( $instance['display_single_tag'] ) ? 1 : 0, + 'pad_counts' => true, + 'immediate_category' => ! empty( $instance['immediate_category'] ) ? 1 : 0, + 'max_number' => ! empty( $instance['max_number'] ) ? $instance['max_number'] : '', + 'active_term_id' => 0, + 'ancestors' => array(), + ); + + if ( $query_args['immediate_category'] ) { + + $term_slug = get_query_var( ATBDP_TAGS ); + + if ( '' != $term_slug ) { + $term = get_term_by( 'slug', $term_slug, ATBDP_TAGS ); + $query_args['active_term_id'] = $term->term_id; + + $query_args['ancestors'] = get_ancestors( $query_args['active_term_id'], 'atbdp_tags' ); + $query_args['ancestors'][] = $query_args['active_term_id']; + $query_args['ancestors'] = array_unique( $query_args['ancestors'] ); + } + } + + if ( 'dropdown' == $query_args['template'] ) { + $tags = $this->dropdown_tags( $query_args ); + } else { + $tags = $this->directorist_tags_list( $query_args ); + } Helper::get_template( 'widgets/all-tags', compact( 'args', 'instance', 'query_args', 'tags' ) ); echo wp_kses_post( $args['after_widget'] ); } - public function directorist_tags_list( $settings ) { - if ( $settings['display_single_tag'] ) { - $terms = get_the_terms(get_the_ID(), ATBDP_TAGS); - $html = ''; - - if ( ! empty( $terms ) ) { - $html .= '<ul>'; - foreach ( $terms as $term ) { - $html .= '<li>'; - $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_tag_page($term) . '">'; - $html .= $term->name; - $html .= '</a>'; - $html .= '</li>'; - } - $html .= '</ul>'; - } - } else { - if ( $settings['immediate_category'] && + public function directorist_tags_list( $settings ) { + if ( $settings['display_single_tag'] ) { + $terms = get_the_terms( get_the_ID(), ATBDP_TAGS ); + $html = ''; + + if ( ! empty( $terms ) ) { + $html .= '<ul>'; + foreach ( $terms as $term ) { + $html .= '<li>'; + $html .= '<a href="' . \ATBDP_Permalink::atbdp_get_tag_page( $term ) . '">'; + $html .= $term->name; + $html .= '</a>'; + $html .= '</li>'; + } + $html .= '</ul>'; + } + } else { + if ( $settings['immediate_category'] && ( $settings['term_id'] > $settings['parent'] ) && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { return; - } + } - $args = array( - 'taxonomy' => ATBDP_TAGS, - 'orderby' => $settings['orderby'], - 'order' => $settings['order'], - 'hide_empty' => $settings['hide_empty'], - 'parent' => !empty($settings['term_id']) ? $settings['term_id'] : '', - 'hierarchical' => !empty($settings['hide_empty']) ? true : false, - 'number' => !empty($settings['max_number']) ? $settings['max_number'] : '' - ); + $args = array( + 'taxonomy' => ATBDP_TAGS, + 'orderby' => $settings['orderby'], + 'order' => $settings['order'], + 'hide_empty' => $settings['hide_empty'], + 'parent' => ! empty( $settings['term_id'] ) ? $settings['term_id'] : '', + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + 'number' => ! empty( $settings['max_number'] ) ? $settings['max_number'] : '', + ); - $terms = get_terms( $args ); + $terms = get_terms( $args ); if ( is_wp_error( $terms ) ) { return; } - $html = ''; + $html = ''; $html .= '<ul>'; foreach ( $terms as $term ) { @@ -220,66 +222,65 @@ public function directorist_tags_list( $settings ) { } $html .= '</ul>'; - } - - return $html; - } + } - public function dropdown_tags( $settings, $prefix = '' ) { - $term_slug = get_query_var(ATBDP_TAGS); - if( $settings['display_single_tag'] ) { - $terms = get_the_terms(get_the_ID(), ATBDP_TAGS); - $html = ''; - if (!empty($terms)) { - - foreach ($terms as $term) { - $html .= sprintf( '<option value="%s" %s>', $term->slug, selected( $term->slug, $term_slug, false ) ); - $html .= $prefix . $term->name; - $html .= '</option>'; - } + return $html; + } - } - } else { + public function dropdown_tags( $settings, $prefix = '' ) { + $term_slug = get_query_var( ATBDP_TAGS ); + if ( $settings['display_single_tag'] ) { + $terms = get_the_terms( get_the_ID(), ATBDP_TAGS ); + $html = ''; + if ( ! empty( $terms ) ) { + + foreach ( $terms as $term ) { + $html .= sprintf( '<option value="%s" %s>', $term->slug, selected( $term->slug, $term_slug, false ) ); + $html .= $prefix . $term->name; + $html .= '</option>'; + } + } + } else { - if ( $settings['immediate_category'] && + if ( $settings['immediate_category'] && ( $settings['term_id'] > $settings['parent'] ) && ! in_array( $settings['term_id'], $settings['ancestors'] ) ) { return; - } + } - $args = array( + $args = array( 'taxonomy' => ATBDP_TAGS, 'orderby' => $settings['orderby'], 'order' => $settings['order'], 'hide_empty' => $settings['hide_empty'], - 'parent' => !empty($settings['term_id']) ? $settings['term_id'] : '', - 'hierarchical' => !empty($settings['hide_empty']) ? true : false, - 'number' => !empty($settings['max_number']) ? $settings['max_number'] : '' + 'parent' => ! empty( $settings['term_id'] ) ? $settings['term_id'] : '', + 'hierarchical' => ! empty( $settings['hide_empty'] ) ? true : false, + 'number' => ! empty( $settings['max_number'] ) ? $settings['max_number'] : '', ); - $terms = get_terms( $args ); + $terms = get_terms( $args ); if ( is_wp_error( $terms ) ) { return; } - $html = ''; + $html = ''; foreach ( $terms as $term ) { $settings['term_id'] = $term->term_id; - $html .= sprintf('<option value="%s" %s>', $term->term_taxonomy_id, selected($term->slug, $term_slug, false)); + $html .= sprintf( '<option value="%s" %s>', $term->term_taxonomy_id, selected( $term->slug, $term_slug, false ) ); $html .= $prefix . $term->name; if ( ! empty( $settings['show_count'] ) ) { $html .= ' (' . $term->count . ')'; } - //$html .= $this->dropdown_tags($settings, $prefix . ' '); + // $html .= $this->dropdown_tags($settings, $prefix . ' '); $html .= '</option>'; } - } + } - return $html; - } -} \ No newline at end of file + return $html; + } +} diff --git a/includes/widgets/author-info.php b/includes/widgets/author-info.php index 6eb8cec731..eb660274af 100644 --- a/includes/widgets/author-info.php +++ b/includes/widgets/author-info.php @@ -7,42 +7,44 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Author_Info extends \WP_Widget { public function __construct() { $id_base = 'bdsi_widget'; - $name = esc_html__( 'Directorist - Author Info', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show author info by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Author Info', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show author info by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Author Info', 'directorist' ), - ]; + $defaults = array( + 'title' => esc_html__( 'Author Info', 'directorist' ), + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; return $instance; } @@ -51,7 +53,7 @@ public function widget( $args, $instance ) { if ( is_singular( ATBDP_POST_TYPE ) ) { echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Author Info', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Author Info', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); @@ -60,4 +62,4 @@ public function widget( $args, $instance ) { echo wp_kses_post( $args['after_widget'] ); } } -} \ No newline at end of file +} diff --git a/includes/widgets/contact-form.php b/includes/widgets/contact-form.php index 8593ba1fb5..b6545ac66e 100644 --- a/includes/widgets/contact-form.php +++ b/includes/widgets/contact-form.php @@ -7,62 +7,64 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Contact_Form extends \WP_Widget { public function __construct() { $id_base = 'bdco_widget'; - $name = esc_html__( 'Directorist - Contact Listing Owner', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show a form to contact the listing owners by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Contact Listing Owner', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show a form to contact the listing owners by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__('Contact the listing owner', 'directorist'), - ]; + $defaults = array( + 'title' => esc_html__( 'Contact the listing owner', 'directorist' ), + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; return $instance; } public function widget( $args, $instance ) { - if( is_singular( ATBDP_POST_TYPE ) ) { + if ( is_singular( ATBDP_POST_TYPE ) ) { echo wp_kses_post( $args['before_widget'] ); $plan_permission = true; - $email = get_post_meta( get_the_ID(), '_email', true ); - $author_id = get_post_field( 'post_author', get_the_ID() ); - $hide_form = get_user_meta( $author_id, 'hide_contact_form', true ); + $email = get_post_meta( get_the_ID(), '_email', true ); + $author_id = get_post_field( 'post_author', get_the_ID() ); + $hide_form = get_user_meta( $author_id, 'hide_contact_form', true ); - if( is_fee_manager_active() ){ + if ( is_fee_manager_active() ) { $plan_permission = is_plan_allowed_owner_contact_widget( get_post_meta( get_the_ID(), '_fm_plans', true ) ); } if ( $plan_permission && ! $hide_form ) { - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Contact the listing owner', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Contact the listing owner', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); @@ -73,4 +75,4 @@ public function widget( $args, $instance ) { echo wp_kses_post( $args['after_widget'] ); } } -} \ No newline at end of file +} diff --git a/includes/widgets/featured-listing.php b/includes/widgets/featured-listing.php index bf0db5faa0..63a80f13c7 100644 --- a/includes/widgets/featured-listing.php +++ b/includes/widgets/featured-listing.php @@ -7,68 +7,71 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Featured_Listing extends \WP_Widget { public function __construct() { $id_base = 'bdfl_widget'; - $name = esc_html__( 'Directorist - Featured Listings', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show featured listings by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Featured Listings', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show featured listings by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Featured Listings', 'directorist' ), - 'f_listing_num' => 5, - 'single_only' => 1, - ]; + $defaults = array( + 'title' => esc_html__( 'Featured Listings', 'directorist' ), + 'f_listing_num' => 5, + 'single_only' => 1, + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'f_listing_num' => [ - 'label' => esc_html__( 'Number of Listings', 'directorist' ), - 'type' => 'text', - ], - 'single_only' => [ - 'label' => esc_html__( 'Display only on single listing', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'f_listing_num' => array( + 'label' => esc_html__( 'Number of Listings', 'directorist' ), + 'type' => 'text', + ), + 'single_only' => array( + 'label' => esc_html__( 'Display only on single listing', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; - $instance['f_listing_num'] = ! empty( $new_instance['f_listing_num'] ) ? sanitize_text_field( $new_instance['f_listing_num'] ) : 5; - $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['f_listing_num'] = ! empty( $new_instance['f_listing_num'] ) ? sanitize_text_field( $new_instance['f_listing_num'] ) : 5; + $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; return $instance; } public function widget( $args, $instance ) { - $allowWidget = apply_filters('atbdp_allow_featured_widget', true); + $allowWidget = apply_filters( 'atbdp_allow_featured_widget', true ); - if( ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) || ! $allowWidget) - return; + if ( ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) || ! $allowWidget ) { + return; + } echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Featured Listings', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Featured Listings', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); @@ -76,4 +79,4 @@ public function widget( $args, $instance ) { echo wp_kses_post( $args['after_widget'] ); } -} \ No newline at end of file +} diff --git a/includes/widgets/init.php b/includes/widgets/init.php index 1d6cf63867..640ada82e1 100644 --- a/includes/widgets/init.php +++ b/includes/widgets/init.php @@ -1,32 +1,34 @@ <?php /** * Singleton class for handling widgets. - * + * * @author wpWax */ namespace Directorist\Widgets; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Init { protected static $instance = null; private function __construct() { - add_action( 'widgets_init', [ $this , 'register_widgets' ] ); + add_action( 'widgets_init', array( $this, 'register_widgets' ) ); Widget_Fields::init(); } public static function instance() { if ( null == self::$instance ) { - self::$instance = new self; + self::$instance = new self(); } return self::$instance; } public function register_widgets() { - register_widget( 'Directorist\Widgets\Popular_Listings' ); + register_widget( 'Directorist\Widgets\Popular_Listings' ); register_widget( 'Directorist\Widgets\Listing_Video' ); register_widget( 'Directorist\Widgets\Contact_Form' ); register_widget( 'Directorist\Widgets\Submit_Listing' ); @@ -40,4 +42,4 @@ public function register_widgets() { register_widget( 'Directorist\Widgets\Author_Info' ); register_widget( 'Directorist\Widgets\Featured_Listing' ); } -} \ No newline at end of file +} diff --git a/includes/widgets/lib-widget-fields.php b/includes/widgets/lib-widget-fields.php index 1f6745a904..1bd6695438 100644 --- a/includes/widgets/lib-widget-fields.php +++ b/includes/widgets/lib-widget-fields.php @@ -7,22 +7,24 @@ namespace Directorist\Widgets; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Widget_Fields { public static function init() { - add_action( 'admin_footer', [ __CLASS__, 'load_scripts' ] ); + add_action( 'admin_footer', array( __CLASS__, 'load_scripts' ) ); } public static function create( $fields, $instance, $object ) { foreach ( $fields as $key => $field ) { $label = $field['label']; - $desc = !empty( $field['desc'] ) ? $field['desc'] : false; + $desc = ! empty( $field['desc'] ) ? $field['desc'] : false; $id = $object->get_field_id( $key ); $name = $object->get_field_name( $key ); - $value = $instance[$key]; - $options = !empty( $field['options'] ) ? $field['options'] : false; + $value = $instance[ $key ]; + $options = ! empty( $field['options'] ) ? $field['options'] : false; if ( method_exists( __CLASS__, $field['type'] ) ) { echo '<div class="directorist-widget-field">'; @@ -102,11 +104,11 @@ protected static function image( $id, $name, $value, $label, $options, $field ) echo ' <label for="' . esc_attr( $id ) . '">' . esc_html( $label ) . ':</label> <div class="directorist_widget_image_area"> - <input name="'. esc_attr( $name ) .'" type="hidden" class="directorist-widget-upload-img" value="'. esc_attr( $value ) .'" /> - <img src="'. esc_url( $image ) .'" class="directorist_widget_preview_image" style="'. esc_attr( $disstyle ) .'" alt="" /> - <input class="directorist_widget_upload_image upload_button_'. esc_attr( $id ) .' button-primary" type="button" value="' . esc_attr__( 'Choose Image', 'directorist' ). '" /> - <div class="directorist_widget_remove_image_wrap" style="'. esc_attr( $disstyle ) .'"> - <a href="#" class="directorist_widget_remove_image button" >' . esc_html__( 'Remove Image', 'directorist' ). '</a> + <input name="' . esc_attr( $name ) . '" type="hidden" class="directorist-widget-upload-img" value="' . esc_attr( $value ) . '" /> + <img src="' . esc_url( $image ) . '" class="directorist_widget_preview_image" style="' . esc_attr( $disstyle ) . '" alt="" /> + <input class="directorist_widget_upload_image upload_button_' . esc_attr( $id ) . ' button-primary" type="button" value="' . esc_attr__( 'Choose Image', 'directorist' ) . '" /> + <div class="directorist_widget_remove_image_wrap" style="' . esc_attr( $disstyle ) . '"> + <a href="#" class="directorist_widget_remove_image button" >' . esc_html__( 'Remove Image', 'directorist' ) . '</a> </div> </div> '; diff --git a/includes/widgets/listing-video.php b/includes/widgets/listing-video.php index 9867deebe9..11ed3eef30 100644 --- a/includes/widgets/listing-video.php +++ b/includes/widgets/listing-video.php @@ -7,53 +7,55 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Listing_Video extends \WP_Widget { public function __construct() { $id_base = 'bdvd_widget'; - $name = esc_html__( 'Directorist - Video', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show listing video by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Video', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show listing video by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Listing Video', 'directorist' ), - ]; + $defaults = array( + 'title' => esc_html__( 'Listing Video', 'directorist' ), + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; return $instance; } public function widget( $args, $instance ) { - $videourl = get_post_meta( get_the_ID(), '_videourl', true ); + $videourl = get_post_meta( get_the_ID(), '_videourl', true ); - if( is_singular( ATBDP_POST_TYPE ) && ! empty( $videourl ) ) { + if ( is_singular( ATBDP_POST_TYPE ) && ! empty( $videourl ) ) { echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Listing Video', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Listing Video', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); @@ -62,4 +64,4 @@ public function widget( $args, $instance ) { echo wp_kses_post( $args['after_widget'] ); } } -} \ No newline at end of file +} diff --git a/includes/widgets/login-form.php b/includes/widgets/login-form.php index e872b35dd2..e044ae41dc 100644 --- a/includes/widgets/login-form.php +++ b/includes/widgets/login-form.php @@ -7,60 +7,63 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Login_Form extends \WP_Widget { public function __construct() { $id_base = 'bdlf_widget'; - $name = esc_html__( 'Directorist - Login Form', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show login form for logged out users by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Login Form', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show login form for logged out users by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Login Form', 'directorist' ), - 'single_only' => 1, - ]; + $defaults = array( + 'title' => esc_html__( 'Login Form', 'directorist' ), + 'single_only' => 1, + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'single_only' => [ - 'label' => esc_html__( 'Display only on single listing', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'single_only' => array( + 'label' => esc_html__( 'Display only on single listing', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; - $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; return $instance; } public function widget( $args, $instance ) { - if( ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) || is_user_logged_in() ) - return; + if ( ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) || is_user_logged_in() ) { + return; + } echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Login Form', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Login Form', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); @@ -68,4 +71,4 @@ public function widget( $args, $instance ) { echo wp_kses_post( $args['after_widget'] ); } -} \ No newline at end of file +} diff --git a/includes/widgets/popular-listings.php b/includes/widgets/popular-listings.php index d96858398c..3e61d590a3 100644 --- a/includes/widgets/popular-listings.php +++ b/includes/widgets/popular-listings.php @@ -7,55 +7,57 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Popular_Listings extends \WP_Widget { public function __construct() { $id_base = 'bdpl_widget'; - $name = esc_html__( 'Directorist - Popular Listings', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show popular listing by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Popular Listings', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show popular listing by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ + $defaults = array( 'title' => esc_html__( 'Popular Listings', 'directorist' ), 'pop_listing_num' => 5, 'single_only' => 1, - ]; + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'pop_listing_num' => [ - 'label' => esc_html__( 'Number of Listings:', 'directorist' ), - 'type' => 'number', - ], - 'single_only' => [ - 'label' => esc_html__( 'Display only on single listing', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'pop_listing_num' => array( + 'label' => esc_html__( 'Number of Listings:', 'directorist' ), + 'type' => 'number', + ), + 'single_only' => array( + 'label' => esc_html__( 'Display only on single listing', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; - $instance['pop_listing_num'] = ! empty( $new_instance['pop_listing_num'] ) ? sanitize_text_field( $new_instance['pop_listing_num'] ) : ''; - $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['pop_listing_num'] = ! empty( $new_instance['pop_listing_num'] ) ? sanitize_text_field( $new_instance['pop_listing_num'] ) : ''; + $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; return $instance; } @@ -63,11 +65,11 @@ public function update( $new_instance, $old_instance ) { public function widget( $args, $instance ) { echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Popular Listings', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Popular Listings', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); - $count = !empty( $instance['pop_listing_num'] ) ? $instance['pop_listing_num'] : 5; + $count = ! empty( $instance['pop_listing_num'] ) ? $instance['pop_listing_num'] : 5; $query = $this->popular_listings_query( $count ); Helper::get_template( 'widgets/popular-listings', compact( 'args', 'instance', 'query' ) ); @@ -78,7 +80,7 @@ public function widget( $args, $instance ) { public function popular_listings_query( $count = 5 ) { $count = intval( $count > 0 ? $count : 5 ); $view_to_popular = get_directorist_option( 'views_for_popular' ); - $count = apply_filters( 'atbdp_popular_listing_number', $count ); + $count = apply_filters( 'atbdp_popular_listing_number', $count ); $args = array( 'post_type' => ATBDP_POST_TYPE, @@ -133,51 +135,49 @@ public function popular_listings_query( $count = 5 ) { 'views' => 'DESC', ); } - } else { - if ( 'average_rating' === $listing_popular_by ) { - $meta_queries['_rating'] = array( - 'key' => directorist_get_rating_field_meta_key(), - 'value' => $average_review_for_popular, - 'type' => 'NUMERIC', - 'compare' => '<=', - ); - } elseif ( 'view_count' === $listing_popular_by ) { - $meta_queries['views'] = array( - 'key' => '_atbdp_post_views_count', - 'value' => $view_to_popular, - 'type' => 'NUMERIC', - 'compare' => '>=', - ); - - $args['orderby'] = array( - 'views' => 'DESC', - ); - } else { - $meta_queries['views'] = array( - 'key' => '_atbdp_post_views_count', - 'value' => $view_to_popular, - 'type' => 'NUMERIC', - 'compare' => '>=', - ); - + } elseif ( 'average_rating' === $listing_popular_by ) { $meta_queries['_rating'] = array( 'key' => directorist_get_rating_field_meta_key(), 'value' => $average_review_for_popular, 'type' => 'NUMERIC', 'compare' => '<=', ); - - $args['orderby'] = array( - 'views' => 'DESC', - ); - } + } elseif ( 'view_count' === $listing_popular_by ) { + $meta_queries['views'] = array( + 'key' => '_atbdp_post_views_count', + 'value' => $view_to_popular, + 'type' => 'NUMERIC', + 'compare' => '>=', + ); + + $args['orderby'] = array( + 'views' => 'DESC', + ); + } else { + $meta_queries['views'] = array( + 'key' => '_atbdp_post_views_count', + 'value' => $view_to_popular, + 'type' => 'NUMERIC', + 'compare' => '>=', + ); + + $meta_queries['_rating'] = array( + 'key' => directorist_get_rating_field_meta_key(), + 'value' => $average_review_for_popular, + 'type' => 'NUMERIC', + 'compare' => '<=', + ); + + $args['orderby'] = array( + 'views' => 'DESC', + ); } if ( count( $meta_queries ) ) { $meta_queries['relation'] = 'AND'; - $args['meta_query'] = $meta_queries; + $args['meta_query'] = $meta_queries; } return new \WP_Query( apply_filters( 'atbdp_popular_listing_args', $args ) ); } -} \ No newline at end of file +} diff --git a/includes/widgets/search-form.php b/includes/widgets/search-form.php index cbc9751ef4..024f66f581 100644 --- a/includes/widgets/search-form.php +++ b/includes/widgets/search-form.php @@ -7,53 +7,57 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Search_Form extends \WP_Widget { public function __construct() { $id_base = 'bdsw_widget'; - $name = esc_html__( 'Directorist - Search Listings', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show search listing form by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Search Listings', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show search listing form by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Search', 'directorist' ), - ]; + $defaults = array( + 'title' => esc_html__( 'Search', 'directorist' ), + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; return $instance; } public function widget( $args, $instance ) { - $allowWidget = apply_filters('atbdp_allow_search_widget', true); - if ( ! $allowWidget ) return; + $allowWidget = apply_filters( 'atbdp_allow_search_widget', true ); + if ( ! $allowWidget ) { + return; + } echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Search', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Search', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); @@ -61,4 +65,4 @@ public function widget( $args, $instance ) { echo wp_kses_post( $args['after_widget'] ); } -} \ No newline at end of file +} diff --git a/includes/widgets/similar-listing.php b/includes/widgets/similar-listing.php index 2048c3bda5..9b623737b2 100644 --- a/includes/widgets/similar-listing.php +++ b/includes/widgets/similar-listing.php @@ -7,110 +7,114 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Similar_Listing extends \WP_Widget { public function __construct() { $id_base = 'bdsl_widget'; - $name = esc_html__( 'Directorist - Similar Listings', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show similar listing by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Similar Listings', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show similar listing by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Similar Listings', 'directorist' ), - 'sim_listing_num' => 5, - ]; + $defaults = array( + 'title' => esc_html__( 'Similar Listings', 'directorist' ), + 'sim_listing_num' => 5, + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'sim_listing_num' => [ - 'label' => esc_html__( 'Number of Listings', 'directorist' ), - 'type' => 'text', - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'sim_listing_num' => array( + 'label' => esc_html__( 'Number of Listings', 'directorist' ), + 'type' => 'text', + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; - $instance['sim_listing_num'] = ! empty( $new_instance['sim_listing_num'] ) ? sanitize_text_field( $new_instance['sim_listing_num'] ) : 5; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['sim_listing_num'] = ! empty( $new_instance['sim_listing_num'] ) ? sanitize_text_field( $new_instance['sim_listing_num'] ) : 5; return $instance; } public function directorist_related_listings_query( $count ) { global $post; - $directory_type = get_the_terms( get_the_ID(), ATBDP_TYPE ); - $type_id = ! empty( $directory_type ) ? $directory_type[0]->term_id : ''; - $same_author = get_directorist_type_option( $type_id, 'listing_from_same_author', false ); - $rel_listing_num = !empty($count) ? $count : 5; - $atbd_cats = get_the_terms($post, ATBDP_CATEGORY); - $atbd_tags = get_the_terms($post, ATBDP_TAGS); + $directory_type = get_the_terms( get_the_ID(), ATBDP_TYPE ); + $type_id = ! empty( $directory_type ) ? $directory_type[0]->term_id : ''; + $same_author = get_directorist_type_option( $type_id, 'listing_from_same_author', false ); + $rel_listing_num = ! empty( $count ) ? $count : 5; + $atbd_cats = get_the_terms( $post, ATBDP_CATEGORY ); + $atbd_tags = get_the_terms( $post, ATBDP_TAGS ); // get the tag ids of the listing post type $atbd_cats_ids = array(); $atbd_tags_ids = array(); - if (!empty($atbd_cats)) { - foreach ($atbd_cats as $atbd_cat) { + if ( ! empty( $atbd_cats ) ) { + foreach ( $atbd_cats as $atbd_cat ) { $atbd_cats_ids[] = $atbd_cat->term_id; } } - if (!empty($atbd_tags)) { - foreach ($atbd_tags as $atbd_tag) { + if ( ! empty( $atbd_tags ) ) { + foreach ( $atbd_tags as $atbd_tag ) { $atbd_tags_ids[] = $atbd_tag->term_id; } } $args = array( - 'post_type' => ATBDP_POST_TYPE, - 'tax_query' => array( + 'post_type' => ATBDP_POST_TYPE, + 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => ATBDP_CATEGORY, - 'field' => 'term_id', - 'terms' => $atbd_cats_ids, + 'field' => 'term_id', + 'terms' => $atbd_cats_ids, ), array( 'taxonomy' => ATBDP_TAGS, - 'field' => 'term_id', - 'terms' => $atbd_tags_ids, + 'field' => 'term_id', + 'terms' => $atbd_tags_ids, ), ), - 'posts_per_page' => (int)$rel_listing_num, - 'post__not_in' => array($post->ID), + 'posts_per_page' => (int) $rel_listing_num, + 'post__not_in' => array( $post->ID ), ); - if( ! empty( $same_author ) ){ - $args['author'] = get_post_field( 'post_author', get_the_ID() ); + if ( ! empty( $same_author ) ) { + $args['author'] = get_post_field( 'post_author', get_the_ID() ); } - return new \WP_Query(apply_filters('atbdp_related_listing_args', $args)); + return new \WP_Query( apply_filters( 'atbdp_related_listing_args', $args ) ); } public function widget( $args, $instance ) { - $allowWidget = apply_filters('atbdp_allow_similar_widget', true); + $allowWidget = apply_filters( 'atbdp_allow_similar_widget', true ); - if( ! is_singular( ATBDP_POST_TYPE ) || ! $allowWidget ) return; + if ( ! is_singular( ATBDP_POST_TYPE ) || ! $allowWidget ) { + return; + } - $number = !empty($instance['sim_listing_num']) ? $instance['sim_listing_num'] : 5; + $number = ! empty( $instance['sim_listing_num'] ) ? $instance['sim_listing_num'] : 5; $related_listings = $this->directorist_related_listings_query( $number ); echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Similar Listings', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Similar Listings', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); @@ -118,4 +122,4 @@ public function widget( $args, $instance ) { echo wp_kses_post( $args['after_widget'] ); } -} \ No newline at end of file +} diff --git a/includes/widgets/single-map.php b/includes/widgets/single-map.php index cd789091c2..547104f039 100644 --- a/includes/widgets/single-map.php +++ b/includes/widgets/single-map.php @@ -7,83 +7,86 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Single_Map extends \WP_Widget { public function __construct() { $id_base = 'bdmw_widget'; - $name = esc_html__( 'Directorist - Map (Single Listing)', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show single listing map by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Map (Single Listing)', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show single listing map by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Map', 'directorist' ), - 'zoom' => 16, - ]; + $defaults = array( + 'title' => esc_html__( 'Map', 'directorist' ), + 'zoom' => 16, + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'zoom' => [ - 'label' => esc_html__( 'Map Zoom Level', 'directorist' ), - 'type' => 'text', - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'zoom' => array( + 'label' => esc_html__( 'Map Zoom Level', 'directorist' ), + 'type' => 'text', + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; - $instance['zoom'] = ! empty( $new_instance['zoom'] ) ? sanitize_text_field( $new_instance['zoom'] ) : 16; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['zoom'] = ! empty( $new_instance['zoom'] ) ? sanitize_text_field( $new_instance['zoom'] ) : 16; return $instance; } public function widget( $args, $instance ) { - if( ! is_singular( ATBDP_POST_TYPE ) ) - return; + if ( ! is_singular( ATBDP_POST_TYPE ) ) { + return; + } echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Popular Listings', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Popular Listings', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); - $map_zoom_level = !empty( $instance['zoom'] ) ? (int) $instance['zoom'] : get_directorist_option('map_zoom_level', 16 ); - - $manual_lat = get_post_meta( get_the_ID(), '_manual_lat', true ); - $manual_lng = get_post_meta( get_the_ID(), '_manual_lng', true ); - $tagline = get_post_meta( get_the_ID(), '_tagline', true ); - $address = get_post_meta( get_the_ID(), '_address', true ); - $t = get_the_title(); - $t = !empty($t) ? $t : __('No Title', 'directorist'); - $info_content = "<div class='map_info_window'> <h3>{$t}</h3>"; - $info_content .= "<p> {$tagline} </p>"; - $info_content .= "<address>{$address}</address>"; - $info_content .= "<a href='http://www.google.com/maps/place/{$manual_lat},{$manual_lng}' target='_blank'> " . __('View On Google Maps', 'directorist') . "</a></div>"; - - $listing = \Directorist\Directorist_Single_Listing::instance(); - $map_data = json_decode( $listing->map_data() ); + $map_zoom_level = ! empty( $instance['zoom'] ) ? (int) $instance['zoom'] : get_directorist_option( 'map_zoom_level', 16 ); + + $manual_lat = get_post_meta( get_the_ID(), '_manual_lat', true ); + $manual_lng = get_post_meta( get_the_ID(), '_manual_lng', true ); + $tagline = get_post_meta( get_the_ID(), '_tagline', true ); + $address = get_post_meta( get_the_ID(), '_address', true ); + $t = get_the_title(); + $t = ! empty( $t ) ? $t : __( 'No Title', 'directorist' ); + $info_content = "<div class='map_info_window'> <h3>{$t}</h3>"; + $info_content .= "<p> {$tagline} </p>"; + $info_content .= "<address>{$address}</address>"; + $info_content .= "<a href='http://www.google.com/maps/place/{$manual_lat},{$manual_lng}' target='_blank'> " . __( 'View On Google Maps', 'directorist' ) . '</a></div>'; + + $listing = \Directorist\Directorist_Single_Listing::instance(); + $map_data = json_decode( $listing->map_data() ); $map_data->map_zoom_level = $map_zoom_level; - //$map_data->info_content = $info_content; + // $map_data->info_content = $info_content; $map_data = json_encode( $map_data ); Helper::get_template( 'widgets/single-map', compact( 'args', 'instance', 'map_data' ) ); echo wp_kses_post( $args['after_widget'] ); } -} \ No newline at end of file +} diff --git a/includes/widgets/submit-listing.php b/includes/widgets/submit-listing.php index c17f411a3f..b8aa8e44d8 100644 --- a/includes/widgets/submit-listing.php +++ b/includes/widgets/submit-listing.php @@ -7,60 +7,63 @@ use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} class Submit_Listing extends \WP_Widget { public function __construct() { $id_base = 'bdsb_widget'; - $name = esc_html__( 'Directorist - Submit Listing', 'directorist' ); - $widget_options = [ - 'classname' => 'directorist-widget', - 'description' => esc_html__( 'You can show submit listing button by this widget', 'directorist' ), - ]; + $name = esc_html__( 'Directorist - Submit Listing', 'directorist' ); + $widget_options = array( + 'classname' => 'directorist-widget', + 'description' => esc_html__( 'You can show submit listing button by this widget', 'directorist' ), + ); parent::__construct( $id_base, $name, $widget_options ); } public function form( $instance ) { - $defaults = [ - 'title' => esc_html__( 'Submit a Listing', 'directorist' ), - 'single_only' => 1, - ]; + $defaults = array( + 'title' => esc_html__( 'Submit a Listing', 'directorist' ), + 'single_only' => 1, + ); $instance = wp_parse_args( (array) $instance, $defaults ); - $fields = [ - 'title' => [ - 'label' => esc_html__( 'Title:', 'directorist' ), - 'type' => 'text', - ], - 'single_only' => [ - 'label' => esc_html__( 'Display only on single listing', 'directorist' ), - 'type' => 'checkbox', - 'value' => 1, - ], - ]; + $fields = array( + 'title' => array( + 'label' => esc_html__( 'Title:', 'directorist' ), + 'type' => 'text', + ), + 'single_only' => array( + 'label' => esc_html__( 'Display only on single listing', 'directorist' ), + 'type' => 'checkbox', + 'value' => 1, + ), + ); Widget_Fields::create( $fields, $instance, $this ); } public function update( $new_instance, $old_instance ) { - $instance = []; + $instance = array(); - $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; - $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; + $instance['title'] = ! empty( $new_instance['title'] ) ? sanitize_text_field( $new_instance['title'] ) : ''; + $instance['single_only'] = ! empty( $new_instance['single_only'] ) ? 1 : 0; return $instance; } public function widget( $args, $instance ) { - if( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) - return; + if ( ! empty( $instance['single_only'] ) && ! is_singular( ATBDP_POST_TYPE ) ) { + return; + } echo wp_kses_post( $args['before_widget'] ); - $title = !empty($instance['title']) ? esc_html($instance['title']) : esc_html__('Submit a Listing', 'directorist'); + $title = ! empty( $instance['title'] ) ? esc_html( $instance['title'] ) : esc_html__( 'Submit a Listing', 'directorist' ); $widget_title = $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title']; echo wp_kses_post( $widget_title ); @@ -68,4 +71,4 @@ public function widget( $args, $instance ) { echo wp_kses_post( $args['after_widget'] ); } -} \ No newline at end of file +} diff --git a/index.php b/index.php index d038ef5a98..be54149e04 100644 --- a/index.php +++ b/index.php @@ -1,2 +1,2 @@ <?php -// Be kind to everyone even if he is your enemy. \ No newline at end of file +// Be kind to everyone even if he is your enemy. diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 83112df4b8..2571eb26fc 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -9,7 +9,7 @@ For most standard PHP configurations, this means the memory limit will temporarily be raised. Ref: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#specifying-phpini-settings --> - <ini name="memory_limit" value="256M"/> + <ini name="memory_limit" value="1000M"/> <!-- Strip the filepaths in reports down to the relevant bit. --> <arg name="basepath" value="./" /> @@ -21,7 +21,7 @@ <arg value="ps" /> <!-- Exclude Warnings. --> - <arg value="n" /> + <!-- <arg value="n" /> --> <file>.</file> @@ -41,7 +41,7 @@ <exclude-pattern>/vendor/*</exclude-pattern> <!-- Rules --> - <rule ref="WordPress.Security"/> + <!-- <rule ref="WordPress"/> --> <rule ref="WordPress.Security.NonceVerification"> <properties> diff --git a/templates/account/login-registration-form.php b/templates/account/login-registration-form.php index a706026bfe..ba1ed47c0c 100644 --- a/templates/account/login-registration-form.php +++ b/templates/account/login-registration-form.php @@ -5,7 +5,7 @@ * @version 8.0.6 */ -use \Directorist\Helper; +use Directorist\Helper; $user_email = isset( $_GET['user'] ) ? sanitize_email( wp_unslash( base64_decode( $_GET['user'] ) ) ) : ''; $key = isset( $_GET['key'] ) ? sanitize_text_field( wp_unslash( $_GET['key'] ) ) : ''; @@ -17,27 +17,36 @@ } ?> <div class="directorist-w-100"> - <div class="<?php Helper::directorist_container_fluid(); ?>"> - <div class="<?php Helper::directorist_row(); ?>"> - <div class="directorist-col-md-6 directorist-offset-md-3 directorist-login-wrapper directorist-authentication <?php echo esc_attr( $active_form === 'signin' ? 'active' : '' ); ?>"> + <div class="<?php Helper::directorist_container_fluid(); ?>"> + <div class="<?php Helper::directorist_row(); ?>"> + <div class="directorist-col-md-6 directorist-offset-md-3 directorist-login-wrapper directorist-authentication <?php echo esc_attr( $active_form === 'signin' ? 'active' : '' ); ?>"> <div class="atbdp_login_form_shortcode directorist-authentication__form"> - <?php if ( $registration_success ): ?> + <?php if ( $registration_success ) : ?> <p style="padding: 20px" class="alert-success directorist-alert directorist-alert-success"> - <span><?php esc_html_e('Registration completed. Please check your email for confirmation. Or login here.', 'directorist');?></span> + <span><?php esc_html_e( 'Registration completed. Please check your email for confirmation. Or login here.', 'directorist' ); ?></span> </p> <?php endif; ?> <?php if ( directorist_is_email_verification_enabled() && ! empty( $_GET['verification'] ) && is_email( $user_email ) ) : ?> <p class="directorist-alert directorist-alert-success"><span> <?php - $send_confirm_mail_url = add_query_arg( array( - 'action' => 'directorist_send_confirmation_email', - 'user' => $user_email, - 'directorist_nonce' => wp_create_nonce( 'directorist_nonce' ), - ), admin_url( 'admin-ajax.php' ) ); - - echo wp_kses( sprintf( __( "Thank you for signing up! To complete the registration, please verify your email address by clicking on the link we have sent to your email.<br><br>If you didn't find the verification email, please check your spam folder. If you still can't find it, click on the <a href='%s'>Resend confirmation email</a> to have a new email sent to you.", 'directorist' ), esc_url( $send_confirm_mail_url ) ), array( 'a' => array( 'href' => array() ), 'br' => array() ) ); + $send_confirm_mail_url = add_query_arg( + array( + 'action' => 'directorist_send_confirmation_email', + 'user' => $user_email, + 'directorist_nonce' => wp_create_nonce( 'directorist_nonce' ), + ), + admin_url( 'admin-ajax.php' ) + ); + + echo wp_kses( + sprintf( __( "Thank you for signing up! To complete the registration, please verify your email address by clicking on the link we have sent to your email.<br><br>If you didn't find the verification email, please check your spam folder. If you still can't find it, click on the <a href='%s'>Resend confirmation email</a> to have a new email sent to you.", 'directorist' ), esc_url( $send_confirm_mail_url ) ), + array( + 'a' => array( 'href' => array() ), + 'br' => array(), + ) + ); ?> </span></p> <?php endif; ?> @@ -53,37 +62,51 @@ if ( is_email( $user_email ) && ! empty( $key ) ) { $user = get_user_by( 'email', $user_email ); - if ( ! $user ) { ?> + if ( ! $user ) { + ?> <p class="directorist-alert directorist-alert-danger"> <?php esc_html_e( 'Sorry! user not found', 'directorist' ); ?> </p> - <?php } else { + <?php + } else { $is_valid_password_reset_key = check_password_reset_key( $key, $user->user_login ); if ( is_wp_error( $is_valid_password_reset_key ) ) { - ?><p class="directorist-alert directorist-alert-danger"> + ?> + <p class="directorist-alert directorist-alert-danger"> <?php echo $is_valid_password_reset_key->get_error_message(); ?> - </p><?php + </p> + <?php } else { if ( ! empty( $_POST['directorist_reset_password'] ) && directorist_verify_nonce( 'directorist-reset-password-nonce', 'reset_password' ) ) : // Ignore password sanitization $password_1 = isset( $_POST['password_1'] ) ? $_POST['password_1'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $password_2 = isset( $_POST['password_2'] ) ? $_POST['password_2'] : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized - if ( empty( $password_1 ) || empty( $password_2 ) ) : ?> + if ( empty( $password_1 ) || empty( $password_2 ) ) : + ?> <p class="atbd_reset_warning directorist-alert directorist-alert-danger"><?php echo esc_html__( 'Passwords cannot be empty.', 'directorist' ); ?></p> <?php elseif ( $password_1 !== $password_2 ) : ?> <p class="atbd_reset_error directorist-alert directorist-alert-danger"><?php echo esc_html__( 'Passwords do not match!', 'directorist' ); ?></p> - <?php else : + <?php + else : wp_set_password( $password_2, $user->ID ); // Since password reset is handled through email, so we can consider it verified! delete_user_meta( $user->ID, 'directorist_user_email_unverified' ); ?> - <p class="atbd_reset_success directorist-alert directorist-alert-success"><?php echo wp_kses( sprintf( - __( 'Password changed successfully. Please <a href="%s">click here to login</a>.', 'directorist' ), - esc_url( ATBDP_Permalink::get_signin_signup_page_link() ) - ), array( 'a' => array( 'href' => array() ) ) ); ?></p> - <?php endif; + <p class="atbd_reset_success directorist-alert directorist-alert-success"> + <?php + echo wp_kses( + sprintf( + __( 'Password changed successfully. Please <a href="%s">click here to login</a>.', 'directorist' ), + esc_url( ATBDP_Permalink::get_signin_signup_page_link() ) + ), + array( 'a' => array( 'href' => array() ) ) + ); + ?> + </p> + <?php + endif; endif; if ( ! empty( $_GET['password_reset'] ) ) { @@ -98,16 +121,22 @@ ATBDP()->email->custom_wp_new_user_notification_email( $user->ID ); ?> <div class="directorist-alert directorist-alert-success"> - <?php echo wp_kses( sprintf( - __( 'Email verification successful. Please <a href="%s">click here to login</a>.', 'directorist' ), - esc_url( ATBDP_Permalink::get_signin_signup_page_link() ) - ), array( 'a' => array( 'href' => array() ) ) ); ?> + <?php + echo wp_kses( + sprintf( + __( 'Email verification successful. Please <a href="%s">click here to login</a>.', 'directorist' ), + esc_url( ATBDP_Permalink::get_signin_signup_page_link() ) + ), + array( 'a' => array( 'href' => array() ) ) + ); + ?> </div> <?php } } } - } else { ?> + } else { + ?> <form action="#" id="login" method="POST"> <p class="status"></p> <div class="directorist-form-group directorist-mb-15"> @@ -128,20 +157,22 @@ </label> </div> - <?php if ( ! empty( $display_recpass ) && 'yes' == $display_recpass ) : + <?php + if ( ! empty( $display_recpass ) && 'yes' == $display_recpass ) : $output = sprintf( "<a href='' class='atbdp_recovery_pass'> " . $recpass_text . '</a>' ); echo wp_kses_post( $output ); - endif; ?> + endif; + ?> </div> <div class="directorist-form-group atbd_login_btn_wrapper directorist-mb-15 directorist-authentication__form__btn-wrapper"> <button class="directorist-btn directorist-btn-block directorist-authentication__form__btn" type="submit" value="<?php echo esc_attr( $log_button ); ?>" name="submit" aria-label="Signin Button"><?php echo esc_html( $log_button ); ?></button> - <?php wp_nonce_field( 'ajax-login-nonce', 'security' );?> + <?php wp_nonce_field( 'ajax-login-nonce', 'security' ); ?> </div> </form> <div class="atbd_social_login"> - <?php do_action( 'atbdp_before_login_form_end' );?> + <?php do_action( 'atbdp_before_login_form_end' ); ?> </div> <?php if ( directorist_is_user_registration_enabled() ) : ?> @@ -152,8 +183,8 @@ <?php endif; ?> <?php - //stuff to recover password start - $error = ''; + // stuff to recover password start + $error = ''; $success = ''; // check if we're in reset form if ( isset( $_POST['action'] ) && 'reset' === $_POST['action'] && directorist_verify_nonce() ) : @@ -162,19 +193,21 @@ if ( empty( $email ) ) { $error = __( 'Email address cannot be empty.', 'directorist' ); - } else if ( ! is_email( $email ) ) { + } elseif ( ! is_email( $email ) ) { $error = __( 'Invalid e-mail address.', 'directorist' ); - } else if ( ! email_exists( $email ) ) { + } elseif ( ! email_exists( $email ) ) { $error = __( 'There is no user registered with that email address.', 'directorist' ); } else { - $user = get_user_by( 'email', $email ); + $user = get_user_by( 'email', $email ); /* translators: %s: site name */ - $subject = esc_html( sprintf( __( '[%s] Reset Your Password', 'directorist' ), get_option( 'blogname', 'display' ) )); + $subject = esc_html( sprintf( __( '[%s] Reset Your Password', 'directorist' ), get_option( 'blogname', 'display' ) ) ); $title = esc_html__( 'Password Reset Request', 'directorist' ); $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); /* translators: %1$s: site name, %1$s: user name, %3$s: password reset link */ - $message = sprintf( __( 'Someone has requested a password reset for the following account: + $message = sprintf( + __( + 'Someone has requested a password reset for the following account: <strong>Site name:</strong> %1$s <strong>User name:</strong> %2$s To reset your password, please click on the <a href="%3$s">Reset Password</a>.<br> @@ -185,13 +218,16 @@ esc_url( directorist_password_reset_url( $user, true ) ) ); - $message = wp_kses( $message, array( - 'br' => array(), - 'strong' => array(), - 'a' => array( - 'href' => array() + $message = wp_kses( + $message, + array( + 'br' => array(), + 'strong' => array(), + 'a' => array( + 'href' => array(), + ), ) - ) ); + ); $message = atbdp_email_html( $title, nl2br( $message ) ); @@ -202,7 +238,6 @@ } else { $error = __( 'Something went wrong, unable to send the password reset email. If the issue persists please contact with the site administrator.', 'directorist' ); } - } if ( ! empty( $error ) ) { @@ -213,7 +248,8 @@ echo '<div class="error_login"><p class="success directorist-alert directorist-alert-success">' . esc_html( $success ) . '</p></div>'; } - endif; ?> + endif; + ?> <div id="recover-pass-modal" class="directorist-mt-15 directorist-authentication__form__recover-pass-modal"> <form method="post"> @@ -229,7 +265,7 @@ </fieldset> </form> </div> - <?php }; ?> + <?php } ?> </div><!-- /.atbdp_login_form_shortcode --> </div> @@ -241,7 +277,7 @@ if ( ! empty( $_GET['registration_status'] ) && true == $_GET['registration_status'] ) { if ( empty( $display_password_reg ) || 'yes' != $display_password_reg ) { ?> - <p style="padding: 20px" class="alert-success directorist-alert directorist-alert-success"><span> <?php esc_html_e('Go to your inbox or spam/junk and get your password.', 'directorist'); ?> + <p style="padding: 20px" class="alert-success directorist-alert directorist-alert-success"><span> <?php esc_html_e( 'Go to your inbox or spam/junk and get your password.', 'directorist' ); ?> <?php $output = sprintf( __( 'Click %s to login.', 'directorist' ), '<a href="' . ATBDP_Permalink::get_login_page_link() . '"><i style="color: red">' . __( 'Here', 'directorist' ) . '</i></a>' ); echo wp_kses_post( $output ); @@ -249,13 +285,13 @@ </span></p> <?php } else { ?> <!--registration succeeded, so show notification --> - <p style="padding: 20px" class="alert-success directorist-alert directorist-alert-success"><span> <?php esc_html_e('Registration completed. Please check your email for confirmation.', 'directorist'); ?> + <p style="padding: 20px" class="alert-success directorist-alert directorist-alert-success"><span> <?php esc_html_e( 'Registration completed. Please check your email for confirmation.', 'directorist' ); ?> <?php - $output = sprintf( __('Or click %s to login.', 'directorist' ), '<button class="directorist-authentication__btn directorist-authentication__btn--signin"><span style="color: red">' . __( 'Here', 'directorist' ) . '</span></button>' ); + $output = sprintf( __( 'Or click %s to login.', 'directorist' ), '<button class="directorist-authentication__btn directorist-authentication__btn--signin"><span style="color: red">' . __( 'Here', 'directorist' ) . '</span></button>' ); echo wp_kses_post( $output ); ?> </span></p> - <?php + <?php } } ?> @@ -273,47 +309,57 @@ </div> <?php if ( ! empty( $display_password_reg ) && 'yes' == $display_password_reg ) { ?> <div class="directorist-form-group directorist-mb-35"> - <label for="directorist__authentication__signup__password"><?php + <label for="directorist__authentication__signup__password"> + <?php echo esc_html( $password ); echo '<strong class="directorist-form-required">*</strong>'; - ?></label> + ?> + </label> <input id="directorist__authentication__signup__password" class="directorist-form-element" type="password" name="password" value="" required> </div> <?php } ?> <?php if ( ! empty( $display_fname ) && 'yes' == $display_fname ) { ?> <div class="directorist-form-group directorist-mb-35"> - <label for="directorist__authentication__signup__fname"><?php + <label for="directorist__authentication__signup__fname"> + <?php echo esc_html( $first_name ); echo ( ! empty( $require_fname ) && 'yes' == $require_fname ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> - <input id="directorist__authentication__signup__fname" class="directorist-form-element" type="text" name="fname" value="<?php echo isset( $_REQUEST['fname']) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['fname'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_fname ) && 'yes' == $require_fname ? 'required' : '' ); ?>> + ?> + </label> + <input id="directorist__authentication__signup__fname" class="directorist-form-element" type="text" name="fname" value="<?php echo isset( $_REQUEST['fname'] ) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['fname'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_fname ) && 'yes' == $require_fname ? 'required' : '' ); ?>> </div> <?php } ?> <?php if ( ! empty( $display_lname ) && 'yes' == $display_lname ) { ?> <div class="directorist-form-group directorist-mb-35"> - <label for="directorist__authentication__signup__lname"><?php + <label for="directorist__authentication__signup__lname"> + <?php echo esc_html( $last_name ); echo ( ! empty( $require_lname ) && 'yes' == $require_lname ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> - <input class="directorist-form-element" id="directorist__authentication__signup__lname" type="text" name="lname" value="<?php echo isset( $_REQUEST['lname']) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['lname'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_lname ) && 'yes' == $require_lname ? 'required' : '' ); ?>> + ?> + </label> + <input class="directorist-form-element" id="directorist__authentication__signup__lname" type="text" name="lname" value="<?php echo isset( $_REQUEST['lname'] ) ? esc_attr( sanitize_text_field( wp_unslash( $_REQUEST['lname'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_lname ) && 'yes' == $require_lname ? 'required' : '' ); ?>> </div> <?php } ?> - <?php if ( ! empty( $display_website ) && 'yes' == $display_website ) { ?> + <?php if ( ! empty( $display_website ) && 'yes' == $display_website ) { ?> <div class="directorist-form-group directorist-mb-35"> - <label for="directorist__authentication__signup__website"><?php + <label for="directorist__authentication__signup__website"> + <?php echo esc_html( $website ); echo ( ! empty( $require_website ) && 'yes' == $require_website ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> - <input id="directorist__authentication__signup__website" class="directorist-form-element" type="text" name="website" value="<?php echo isset( $_REQUEST['website']) ? esc_url( sanitize_text_field( wp_unslash( $_REQUEST['website'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_website ) && 'yes' == $require_website ? 'required' : '' ); ?>> + ?> + </label> + <input id="directorist__authentication__signup__website" class="directorist-form-element" type="text" name="website" value="<?php echo isset( $_REQUEST['website'] ) ? esc_url( sanitize_text_field( wp_unslash( $_REQUEST['website'] ) ) ) : ''; ?>" <?php echo ( ! empty( $require_website ) && 'yes' == $require_website ? 'required' : '' ); ?>> </div> <?php } ?> <?php if ( ! empty( $display_bio ) && 'yes' == $display_bio ) { ?> <div class="directorist-form-group directorist-mb-35"> - <label for="directorist__authentication__signup__bio"><?php + <label for="directorist__authentication__signup__bio"> + <?php echo esc_html( $bio ); echo ( ! empty( $require_bio ) && 'yes' == $require_bio ? '<strong class="directorist-form-required">*</strong>' : '' ); - ?></label> - <textarea id="directorist__authentication__signup__bio" class="directorist-form-element" name="bio" rows="10" placeholder="<?php echo esc_html( $bio ); ?>" <?php echo ( ! empty( $require_bio ) ? 'required' : '' ); ?>><?php echo isset( $_REQUEST['bio']) ? esc_textarea( sanitize_text_field( wp_unslash( $_REQUEST['bio'] ) ) ) : ''; ?></textarea> + ?> + </label> + <textarea id="directorist__authentication__signup__bio" class="directorist-form-element" name="bio" rows="10" placeholder="<?php echo esc_html( $bio ); ?>" <?php echo ( ! empty( $require_bio ) ? 'required' : '' ); ?>><?php echo isset( $_REQUEST['bio'] ) ? esc_textarea( sanitize_text_field( wp_unslash( $_REQUEST['bio'] ) ) ) : ''; ?></textarea> </div> <?php } ?> @@ -338,8 +384,8 @@ <?php if ( ! empty( $enable_registration_terms ) && 'yes' == $enable_registration_terms ) { ?> <div class="atbd_term_and_condition_area directory_regi_btn directorist-checkbox directorist-mb-30"> <input id="directorist__authentication__signup__listing_t" type="checkbox" name="t_c_check" <?php echo( ( isset( $t_c_check ) && 'on' === $t_c_check ) ? 'checked="checked"' : '' ); ?>> - <label for="directorist__authentication__signup__listing_t" class="directorist-checkbox__label"><?php echo esc_attr($terms_label); ?> - <a style="color: red" target="_blank" href="<?php echo esc_url($t_C_page_link)?>"><?php echo esc_attr( $terms_label_link); ?></a> <span class="directorist-form-required">*</span></label> + <label for="directorist__authentication__signup__listing_t" class="directorist-checkbox__label"><?php echo esc_attr( $terms_label ); ?> + <a style="color: red" target="_blank" href="<?php echo esc_url( $t_C_page_link ); ?>"><?php echo esc_attr( $terms_label_link ); ?></a> <span class="directorist-form-required">*</span></label> </div> <?php } ?> diff --git a/templates/account/password-reset-form.php b/templates/account/password-reset-form.php index 0738d3eea8..1bf83d57b1 100644 --- a/templates/account/password-reset-form.php +++ b/templates/account/password-reset-form.php @@ -1,43 +1,43 @@ <?php -if (!defined('ABSPATH')) { +if ( ! defined( 'ABSPATH' ) ) { die(); } -do_action('directorist_before_reset_password_form'); +do_action( 'directorist_before_reset_password_form' ); ?> <form method="post" class="directorist-ResetPassword lost_reset_password"> <p class="directorist-alert directorist-alert-danger password-not-match" style="display:none"> - <?php esc_html_e('Password did not match', 'directorist')?> + <?php esc_html_e( 'Password did not match', 'directorist' ); ?> </p> <p> - <?php esc_html_e('Enter a new password below.', 'directorist'); ?> + <?php esc_html_e( 'Enter a new password below.', 'directorist' ); ?> </p> <div class="directorist-form-group directorist-mb-15"> <label for="password_1"> - <?php esc_html_e('New password', 'directorist'); ?> <span class="required">*</span> + <?php esc_html_e( 'New password', 'directorist' ); ?> <span class="required">*</span> </label> <input type="password" class="directorist-form-element" id="password_1" name="password_1" autocomplete="new-password" required> </div> <div class="directorist-form-group directorist-mb-15"> <label for="password_2"> - <?php esc_html_e('Re-enter new password', 'directorist'); ?> <span class="required">*</span> + <?php esc_html_e( 'Re-enter new password', 'directorist' ); ?> <span class="required">*</span> </label> <input type="password" class="directorist-form-element" id="password_2" name="password_2" autocomplete="new-password" required> </div> <div class="clear"></div> - <?php do_action('directorist_resetpassword_form'); ?> + <?php do_action( 'directorist_resetpassword_form' ); ?> <p class="directorist-form-row form-row"> <input type="hidden" name="directorist_reset_password" value="true" /> - <button type="submit" class="directorist-btn directorist-btn-block directorist-authentication__form__btn" value="<?php esc_attr_e('Save', 'directorist'); ?>"><?php esc_html_e('Save', 'directorist'); ?></button> + <button type="submit" class="directorist-btn directorist-btn-block directorist-authentication__form__btn" value="<?php esc_attr_e( 'Save', 'directorist' ); ?>"><?php esc_html_e( 'Save', 'directorist' ); ?></button> </p> - <?php wp_nonce_field('reset_password', 'directorist-reset-password-nonce'); ?> + <?php wp_nonce_field( 'reset_password', 'directorist-reset-password-nonce' ); ?> </form> <?php -do_action('directorist_after_reset_password_form'); +do_action( 'directorist_after_reset_password_form' ); diff --git a/templates/all-authors.php b/templates/all-authors.php index d68de2f06d..396750d889 100644 --- a/templates/all-authors.php +++ b/templates/all-authors.php @@ -5,10 +5,12 @@ * @version 7.4.0 */ -use \Directorist\Helper; -use \Directorist\Directorist_All_Authors as Authors; +use Directorist\Helper; +use Directorist\Directorist_All_Authors as Authors; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-w-100 directorist-authors-section" id="directorist-all-authors"> @@ -17,14 +19,14 @@ <div class="directorist-authors"> - <?php if( $authors->display_sorting() ): ?> + <?php if ( $authors->display_sorting() ) : ?> <div class="directorist-authors__nav"> <ul> <li> <a href="#" class="directorist-alphabet ALL" data-nonce="<?php echo esc_attr( wp_create_nonce( 'directorist_author_sorting' ) ); ?>" data-alphabet="ALL"><?php esc_html_e( 'All', 'directorist' ); ?></a> </li> - <?php foreach( range( 'A', 'Z' ) as $value ): ?> + <?php foreach ( range( 'A', 'Z' ) as $value ) : ?> <li> <a href="#" class="directorist-alphabet <?php echo esc_attr( $value ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'directorist_author_sorting' ) ); ?>" data-alphabet="<?php echo esc_attr( $value ); ?>"><?php echo esc_html( $value ); ?></a> @@ -41,15 +43,16 @@ <div class="directorist-row"> <?php - if( $authors->author_list() ): + if ( $authors->author_list() ) : - foreach( $authors->author_list() as $author ): ?> + foreach ( $authors->author_list() as $author ) : + ?> <div class="<?php Helper::directorist_column( $authors->get_columns() ); ?>"> <div class="directorist-authors__card"> - <?php if( ( $image = Authors::user_image_src( $author ) ) && $authors->display_image() ): ?> + <?php if ( ( $image = Authors::user_image_src( $author ) ) && $authors->display_image() ) : ?> <div class="directorist-authors__card__img"> <img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( Helper::user_info( $author, 'name' ) ); ?>"> @@ -60,28 +63,28 @@ <div class="directorist-authors__card__details"> <div class="directorist-authors__card__details__top"> - <?php if( $authors->display_name() ): ?> - <h2><?php echo esc_html( Helper::user_info( $author, 'name' ) ) ; ?></h2> + <?php if ( $authors->display_name() ) : ?> + <h2><?php echo esc_html( Helper::user_info( $author, 'name' ) ); ?></h2> <?php endif; ?> </div> - <?php if( $authors->contact_info() ) : ?> + <?php if ( $authors->contact_info() ) : ?> <ul class="directorist-authors__card__info-list"> - <?php if( in_array( 'phone', $authors->contact_info() ) && $phone = Helper::user_info( $author, 'phone' ) ): ?> + <?php if ( in_array( 'phone', $authors->contact_info() ) && $phone = Helper::user_info( $author, 'phone' ) ) : ?> <li><?php directorist_icon( 'las la-phone' ); ?> <a href="tel:<?php Helper::formatted_tel( $phone ); ?>"><?php echo esc_html( $phone ); ?></a></li> <?php endif; ?> - <?php if( is_user_logged_in() && in_array( 'email', $authors->contact_info() ) && $email = Helper::user_info( $author, 'email' ) ) : ?> + <?php if ( is_user_logged_in() && in_array( 'email', $authors->contact_info() ) && $email = Helper::user_info( $author, 'email' ) ) : ?> <li><?php directorist_icon( 'las la-envelope' ); ?> <a href="mailto:<?php echo esc_attr( $email ); ?>"><?php echo esc_html( $email ); ?></a></li> <?php endif; ?> - <?php if( in_array( 'address', $authors->contact_info() ) && $address = Helper::user_info( $author, 'address' ) ): ?> + <?php if ( in_array( 'address', $authors->contact_info() ) && $address = Helper::user_info( $author, 'address' ) ) : ?> <li><?php directorist_icon( 'las la-map-marker' ); ?> <?php echo esc_html( $address ); ?></li> <?php endif; ?> - <?php if( in_array( 'website', $authors->contact_info() ) && $website = Helper::user_info( $author, 'website' ) ): ?> + <?php if ( in_array( 'website', $authors->contact_info() ) && $website = Helper::user_info( $author, 'website' ) ) : ?> <li><?php directorist_icon( 'las la-globe' ); ?> <a href="<?php echo esc_url( $website ); ?>"><?php echo esc_html( $website ); ?></a></li> <?php endif; ?> @@ -89,33 +92,33 @@ <?php endif; ?> - <?php if( Helper::user_info( $author, 'description' ) && $authors->display_description() ): ?> + <?php if ( Helper::user_info( $author, 'description' ) && $authors->display_description() ) : ?> <p><?php echo esc_html( wp_trim_words( Helper::user_info( $author, 'description' ), $authors->description_limit() ) ); ?></p> <?php endif; ?> - <?php if( $authors->display_social_info() ): ?> + <?php if ( $authors->display_social_info() ) : ?> <ul class="directorist-author-social directorist-author-social--light"> - <?php if( $facebook = Helper::user_info( $author, 'facebook' ) ): ?> + <?php if ( $facebook = Helper::user_info( $author, 'facebook' ) ) : ?> <li class="directorist-author-social-item"> <a target="_blank" href="<?php echo esc_url( $facebook ); ?>"><?php directorist_icon( 'lab la-facebook' ); ?></a> </li> <?php endif; ?> - <?php if( $twitter = Helper::user_info( $author, 'twitter' ) ): ?> + <?php if ( $twitter = Helper::user_info( $author, 'twitter' ) ) : ?> <li class="directorist-author-social-item"> <a target="_blank" href="<?php echo esc_url( $twitter ); ?>"><?php directorist_icon( 'lab la-twitter' ); ?></a> </li> <?php endif; ?> - <?php if( $linkedin = Helper::user_info( $author, 'linkedin' ) ): ?> + <?php if ( $linkedin = Helper::user_info( $author, 'linkedin' ) ) : ?> <li class="directorist-author-social-item"> <a target="_blank" href="<?php echo esc_url( $linkedin ); ?>"><?php directorist_icon( 'lab la-linkedin' ); ?></a> </li> <?php endif; ?> - <?php if( $youtube = Helper::user_info( $author, 'youtube' ) ): ?> + <?php if ( $youtube = Helper::user_info( $author, 'youtube' ) ) : ?> <li class="directorist-author-social-item"> <a target="_blank" href="<?php echo esc_url( $youtube ); ?>"><?php directorist_icon( 'lab la-youtube' ); ?></span></a> </li> @@ -125,8 +128,8 @@ <?php endif; ?> - <?php if( $authors->display_btn() ): ?> - <a href="<?php echo esc_url( ATBDP_Permalink::get_user_profile_page_link( $author->data->ID ) );?>" class="directorist-btn directorist-btn-light directorist-btn-block"><?php echo esc_html( $authors->btn_text() ); ?></a> + <?php if ( $authors->display_btn() ) : ?> + <a href="<?php echo esc_url( ATBDP_Permalink::get_user_profile_page_link( $author->data->ID ) ); ?>" class="directorist-btn directorist-btn-light directorist-btn-block"><?php echo esc_html( $authors->btn_text() ); ?></a> <?php endif; ?> </div> @@ -134,10 +137,10 @@ </div> </div> - <?php + <?php endforeach; - else: + else : ?> <p><?php esc_html_e( 'No authors found', 'directorist' ); ?></p> diff --git a/templates/archive-contents.php b/templates/archive-contents.php index c045aceef2..f5ee168071 100644 --- a/templates/archive-contents.php +++ b/templates/archive-contents.php @@ -5,10 +5,17 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<div <?php $listings->wrapper_class(); $listings->data_atts(); ?>> +<div +<?php +$listings->wrapper_class(); +$listings->data_atts(); +?> +> <div class="directorist-archive-contents__top"> <?php $listings->mobile_view_filter_template(); diff --git a/templates/archive/advance-search-form.php b/templates/archive/advance-search-form.php index a515dbebdd..50d62a067f 100644 --- a/templates/archive/advance-search-form.php +++ b/templates/archive/advance-search-form.php @@ -5,9 +5,11 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <form action="<?php atbdp_search_result_page_link(); ?>" class="directorist-search-form directorist-advanced-search"> <div class="directorist-search-form__box"> @@ -20,7 +22,7 @@ <div class="directorist-advanced-filter__advanced"> <input type="hidden" name='directory_type' value='<?php echo esc_attr( $listings->get_directory_type_slug() ); ?>'> <?php foreach ( $searchform->form_data[1]['fields'] as $field ) : ?> - <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] ) ?>"><?php $searchform->field_template( $field ); ?></div> + <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] ); ?>"><?php $searchform->field_template( $field ); ?></div> <?php endforeach; ?> <div class="directorist-advanced-filter__action directorist-advanced-filter__action--ajax"> <button class="directorist-btn-reset-js directorist-btn-reset-ajax"><?php echo esc_html( $searchform->options['reset_sidebar_filters_text'] ?? esc_html__( 'Clear All', 'directorist' ) ); ?></button> diff --git a/templates/archive/basic-search-form.php b/templates/archive/basic-search-form.php index 68e4c952a9..f6343a1d78 100644 --- a/templates/archive/basic-search-form.php +++ b/templates/archive/basic-search-form.php @@ -5,37 +5,39 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <form action="<?php atbdp_search_result_page_link(); ?>" class="directorist-search-form directorist-basic-search"> - <div class="directorist-search-form__box"> - <div class="directorist-search-form-top directorist-flex directorist-align-center directorist-search-form-inline directorist-search-form__top"> - - <?php - foreach ( $searchform->form_data[0]['fields'] as $field ){ - $searchform->field_template( $field ); - } - ?> - - </div> - - <?php if ( ! empty( $listings->display_search_button() ) ) : ?> - <div class="directorist-search-form-action"> - <div class="directorist-search-form-action__submit"> - <button type="submit" class="directorist-btn directorist-btn-lg directorist-btn-primary directorist-btn-search"> - - <?php if ( $searchform->has_search_button_icon() ): ?> - <?php directorist_icon( 'las la-search' ); ?> - <?php endif;?> - - <?php echo esc_html( $searchform->search_button_text );?> - - </button> - </div> - </div> - <?php endif; ?> - </div> + <div class="directorist-search-form__box"> + <div class="directorist-search-form-top directorist-flex directorist-align-center directorist-search-form-inline directorist-search-form__top"> + + <?php + foreach ( $searchform->form_data[0]['fields'] as $field ) { + $searchform->field_template( $field ); + } + ?> + + </div> + + <?php if ( ! empty( $listings->display_search_button() ) ) : ?> + <div class="directorist-search-form-action"> + <div class="directorist-search-form-action__submit"> + <button type="submit" class="directorist-btn directorist-btn-lg directorist-btn-primary directorist-btn-search"> + + <?php if ( $searchform->has_search_button_icon() ) : ?> + <?php directorist_icon( 'las la-search' ); ?> + <?php endif; ?> + + <?php echo esc_html( $searchform->search_button_text ); ?> + + </button> + </div> + </div> + <?php endif; ?> + </div> </form> \ No newline at end of file diff --git a/templates/archive/custom-fields/checkbox.php b/templates/archive/custom-fields/checkbox.php index d386863ffb..74dc5d2229 100644 --- a/templates/archive/custom-fields/checkbox.php +++ b/templates/archive/custom-fields/checkbox.php @@ -6,15 +6,15 @@ */ if ( ! defined( 'ABSPATH' ) ) { - exit; + exit; } -$tag = tag_escape( $before ? $before : 'div' ); +$tag = tag_escape( $before ? $before : 'div' ); $closing_tag = tag_escape( $after ? $after : 'div' ); ?> <<?php echo $tag; ?> class="directorist-listing-card-checkbox"> - <?php directorist_icon( $icon ); ?> - <?php $listings->print_label( $label ); ?> - <?php echo esc_html( $value ); ?> + <?php directorist_icon( $icon ); ?> + <?php $listings->print_label( $label ); ?> + <?php echo esc_html( $value ); ?> </<?php echo $closing_tag; ?>> diff --git a/templates/archive/custom-fields/date.php b/templates/archive/custom-fields/date.php index bc28f601b6..77acb31ec3 100644 --- a/templates/archive/custom-fields/date.php +++ b/templates/archive/custom-fields/date.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<<?php echo tag_escape( $before ? $before : 'div' ); ?> class="directorist-listing-card-date"><?php directorist_icon( $icon );?><?php $listings->print_label( $label ); ?><?php echo esc_html( directorist_format_date( $value ) ); ?><<?php echo tag_escape( $after ? $after : 'div' ); ?>/> \ No newline at end of file +<<?php echo tag_escape( $before ? $before : 'div' ); ?> class="directorist-listing-card-date"><?php directorist_icon( $icon ); ?><?php $listings->print_label( $label ); ?><?php echo esc_html( directorist_format_date( $value ) ); ?><<?php echo tag_escape( $after ? $after : 'div' ); ?>/> \ No newline at end of file diff --git a/templates/archive/custom-fields/number.php b/templates/archive/custom-fields/number.php index 573ad34bda..777b1b2da5 100644 --- a/templates/archive/custom-fields/number.php +++ b/templates/archive/custom-fields/number.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <<?php echo tag_escape( $before ? $before : 'div' ); ?> class="directorist-listing-card-number"><?php directorist_icon( $icon ); ?><?php $listings->print_label( $label ); ?><?php echo esc_html( $value ); ?></<?php echo tag_escape( $after ? $after : 'div' ); ?>> \ No newline at end of file diff --git a/templates/archive/custom-fields/radio.php b/templates/archive/custom-fields/radio.php index c1ee0bfa12..5967568bbf 100644 --- a/templates/archive/custom-fields/radio.php +++ b/templates/archive/custom-fields/radio.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <<?php echo tag_escape( $before ? $before : 'div' ); ?> class="directorist-listing-card-radio"><?php directorist_icon( $icon ); ?><?php $listings->print_label( $label ); ?><?php echo esc_html( $value ); ?></<?php echo tag_escape( $after ? $after : 'div' ); ?>> \ No newline at end of file diff --git a/templates/archive/custom-fields/select.php b/templates/archive/custom-fields/select.php index 7770eb701c..485ab69393 100644 --- a/templates/archive/custom-fields/select.php +++ b/templates/archive/custom-fields/select.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <<?php echo tag_escape( $before ? $before : 'div' ); ?> class="directorist-listing-card-select"><?php directorist_icon( $icon ); ?><?php $listings->print_label( $label ); ?><?php echo esc_html( $value ); ?></<?php echo tag_escape( $after ? $after : 'div' ); ?>> \ No newline at end of file diff --git a/templates/archive/custom-fields/text.php b/templates/archive/custom-fields/text.php index bdef0af697..9752ad082a 100644 --- a/templates/archive/custom-fields/text.php +++ b/templates/archive/custom-fields/text.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <<?php echo tag_escape( $before ? $before : 'div' ); ?> class="directorist-listing-card-text"><?php directorist_icon( $icon ); ?><?php $listings->print_label( $label ); ?><?php echo esc_html( $value ); ?></<?php echo tag_escape( $after ? $after : 'div' ); ?>> \ No newline at end of file diff --git a/templates/archive/custom-fields/time.php b/templates/archive/custom-fields/time.php index bf22c0af52..2e4b3fe75e 100644 --- a/templates/archive/custom-fields/time.php +++ b/templates/archive/custom-fields/time.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <<?php echo tag_escape( $before ? $before : 'div' ); ?> class="directorist-listing-card-time"><?php directorist_icon( $icon ); ?><?php $listings->print_label( $label ); ?><?php echo esc_html( directorist_format_time( $value ) ); ?></<?php echo tag_escape( $after ? $after : 'div' ); ?>> \ No newline at end of file diff --git a/templates/archive/custom-fields/url.php b/templates/archive/custom-fields/url.php index a12dc4d7fe..dbf6131898 100644 --- a/templates/archive/custom-fields/url.php +++ b/templates/archive/custom-fields/url.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <<?php echo tag_escape( $before ? $before : 'div' ); ?> class="directorist-listing-card-url"><?php directorist_icon( $icon ); ?><?php $listings->print_label( $label ); ?><a target="_blank" rel="noopener" href="<?php echo esc_url( $value ); ?>"><?php echo esc_html( $value ); ?></a></<?php echo tag_escape( $after ? $after : 'div' ); ?>> \ No newline at end of file diff --git a/templates/archive/directory-type-nav.php b/templates/archive/directory-type-nav.php index 9b7e868d81..518884740e 100644 --- a/templates/archive/directory-type-nav.php +++ b/templates/archive/directory-type-nav.php @@ -8,9 +8,11 @@ * @version 7.4.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $current_directory_type = ( ! empty( $_GET['directory_type'] ) ? sanitize_text_field( wp_unslash( $_GET['directory_type'] ) ) : '' ); @@ -30,8 +32,8 @@ <?php foreach ( $listings->listing_types as $id => $value ) : ?> - <li class="<?php echo ( ( $listings->current_listing_type === $value['term']->term_id && 'all' !== $current_directory_type ) ? 'directorist-type-nav__list__current': '' ); ?>"> - <a class="directorist-type-nav__link" href="<?php echo esc_url( directorist_get_directory_type_nav_url( $value['term']->slug ) ); ?>" data-listing_type="<?php echo esc_attr( $value['term']->slug ); ?>" data-listing_type_id="<?php echo esc_attr( $value['term']->term_id ); ?>"><?php directorist_icon( $value['data']['icon'] );?> <?php echo esc_html( $value['name'] );?></a> + <li class="<?php echo ( ( $listings->current_listing_type === $value['term']->term_id && 'all' !== $current_directory_type ) ? 'directorist-type-nav__list__current' : '' ); ?>"> + <a class="directorist-type-nav__link" href="<?php echo esc_url( directorist_get_directory_type_nav_url( $value['term']->slug ) ); ?>" data-listing_type="<?php echo esc_attr( $value['term']->slug ); ?>" data-listing_type_id="<?php echo esc_attr( $value['term']->term_id ); ?>"><?php directorist_icon( $value['data']['icon'] ); ?> <?php echo esc_html( $value['name'] ); ?></a> </li> <?php endforeach; ?> diff --git a/templates/archive/fields/address.php b/templates/archive/fields/address.php index f3397daaad..835d07f95f 100644 --- a/templates/archive/fields/address.php +++ b/templates/archive/fields/address.php @@ -5,12 +5,14 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <li class="directorist-listing-card-address"><?php directorist_icon( $icon ); ?> - <?php if ( ! empty( $label ) ) : ?> - <?php $listings->print_label( $label ); ?> - <?php endif; ?> - <?php echo esc_html( $value ); ?> + <?php if ( ! empty( $label ) ) : ?> + <?php $listings->print_label( $label ); ?> + <?php endif; ?> + <?php echo esc_html( $value ); ?> </li> \ No newline at end of file diff --git a/templates/archive/fields/badge.php b/templates/archive/fields/badge.php index a5c4591a8b..2594381d3b 100644 --- a/templates/archive/fields/badge.php +++ b/templates/archive/fields/badge.php @@ -5,34 +5,36 @@ * @version 8.0.11 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<span class="directorist-badge directorist-info-item directorist-badge-<?php echo esc_attr( $class )?> <?php echo esc_attr( $class === 'featured' ? $featured_badge_class : '' ); ?>"> +<span class="directorist-badge directorist-info-item directorist-badge-<?php echo esc_attr( $class ); ?> <?php echo esc_attr( $class === 'featured' ? $featured_badge_class : '' ); ?>"> - <?php if ( $class == 'featured' ) : ?> + <?php if ( $class == 'featured' ) : ?> - <?php if ( $featured_badge_type == 'icon_badge' ) : ?> + <?php if ( $featured_badge_type == 'icon_badge' ) : ?> - <?php directorist_icon( 'fas fa-star' ); ?> - <span class="directorist-badge-tooltip directorist-badge-tooltip__featured"><?php echo esc_html( ! empty( $label ) ? $label : 'Featured' ); ?></span> + <?php directorist_icon( 'fas fa-star' ); ?> + <span class="directorist-badge-tooltip directorist-badge-tooltip__featured"><?php echo esc_html( ! empty( $label ) ? $label : 'Featured' ); ?></span> - <?php else: ?> + <?php else : ?> - <?php echo esc_html( ! empty( $label ) ? $label : 'Featured' ); ?> + <?php echo esc_html( ! empty( $label ) ? $label : 'Featured' ); ?> - <?php endif; ?> + <?php endif; ?> - <?php elseif ( $class == 'new' ) : ?> + <?php elseif ( $class == 'new' ) : ?> - <?php directorist_icon( 'fas fa-bolt' ); ?> - <span class="directorist-badge-tooltip directorist-badge-tooltip__new"><?php echo esc_html( ! empty( $label ) ? $label : 'New' ); ?></span> + <?php directorist_icon( 'fas fa-bolt' ); ?> + <span class="directorist-badge-tooltip directorist-badge-tooltip__new"><?php echo esc_html( ! empty( $label ) ? $label : 'New' ); ?></span> - <?php elseif ( $class == 'popular' ) : ?> + <?php elseif ( $class == 'popular' ) : ?> - <?php directorist_icon( 'fas fa-fire' ); ?> - <span class="directorist-badge-tooltip directorist-badge-tooltip__popular"><?php echo esc_html( ! empty( $label ) ? $label : 'Popular' ); ?></span> + <?php directorist_icon( 'fas fa-fire' ); ?> + <span class="directorist-badge-tooltip directorist-badge-tooltip__popular"><?php echo esc_html( ! empty( $label ) ? $label : 'Popular' ); ?></span> - <?php endif;?> + <?php endif; ?> </span> \ No newline at end of file diff --git a/templates/archive/fields/category.php b/templates/archive/fields/category.php index 842cedf246..7a417dc795 100644 --- a/templates/archive/fields/category.php +++ b/templates/archive/fields/category.php @@ -5,25 +5,30 @@ * @version 7.8.3 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-listing-category"> - <?php if ( ! empty( $listings->loop['cats'] ) ) { + <?php + if ( ! empty( $listings->loop['cats'] ) ) { $term_icon = get_term_meta( $listings->loop['cats'][0]->term_id, 'category_icon', true ); $term_icon = $term_icon ? $term_icon : $icon; $term_link = esc_url( get_term_link( $listings->loop['cats'][0]->term_id, ATBDP_CATEGORY ) ); $term_label = $listings->loop['cats'][0]->name; ?> - <a href="<?php echo esc_url( $term_link ); ?>"><?php directorist_icon( $term_icon );?><?php echo esc_html( $term_label ); ?></a> + <a href="<?php echo esc_url( $term_link ); ?>"><?php directorist_icon( $term_icon ); ?><?php echo esc_html( $term_label ); ?></a> <?php - $totalTerm = count($listings->loop['cats']); - if ( $totalTerm > 1 ) { $totalTerm = $totalTerm - 1; ?> + $totalTerm = count( $listings->loop['cats'] ); + if ( $totalTerm > 1 ) { + $totalTerm = $totalTerm - 1; + ?> <div class="directorist-listing-category__popup"> <span class="directorist-listing-category__extran-count">+<?php echo esc_html( $totalTerm ); ?></span> <div class="directorist-listing-category__popup__content"> <?php - foreach (array_slice($listings->loop['cats'], 1) as $cat) { + foreach ( array_slice( $listings->loop['cats'], 1 ) as $cat ) { $term_icon = get_term_meta( $cat->term_id, 'category_icon', true ); $term_icon = $term_icon ? $term_icon : $icon; $term_link = esc_url( ATBDP_Permalink::atbdp_get_category_page( $cat ) ); @@ -31,7 +36,7 @@ $term_label = $cat->name; ?> - <a href="<?php echo esc_url( $term_link );?>"><?php directorist_icon( $term_icon );?> <?php echo esc_html( $term_label ); ?></a> + <a href="<?php echo esc_url( $term_link ); ?>"><?php directorist_icon( $term_icon ); ?> <?php echo esc_html( $term_label ); ?></a> <?php } @@ -41,9 +46,9 @@ </div> <?php } - } - else { ?> - <a href="#"><?php directorist_icon( $icon );?><?php esc_html_e('Uncategorized', 'directorist'); ?></a> + } else { + ?> + <a href="#"><?php directorist_icon( $icon ); ?><?php esc_html_e( 'Uncategorized', 'directorist' ); ?></a> <?php } ?> diff --git a/templates/archive/fields/email.php b/templates/archive/fields/email.php index a0b6d4789c..2a13db6851 100644 --- a/templates/archive/fields/email.php +++ b/templates/archive/fields/email.php @@ -5,12 +5,14 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<li class="directorist-listing-card-email"><?php directorist_icon( $icon );?> - <?php $listings->print_label( $label ); ?> - <a target="_top" href="mailto:<?php echo esc_attr( $value );?>"> - <?php echo esc_html( $value ) ;?> - </a> +<li class="directorist-listing-card-email"><?php directorist_icon( $icon ); ?> + <?php $listings->print_label( $label ); ?> + <a target="_top" href="mailto:<?php echo esc_attr( $value ); ?>"> + <?php echo esc_html( $value ); ?> + </a> </li> \ No newline at end of file diff --git a/templates/archive/fields/excerpt.php b/templates/archive/fields/excerpt.php index 5ebbb53d60..77f00ff161 100644 --- a/templates/archive/fields/excerpt.php +++ b/templates/archive/fields/excerpt.php @@ -5,15 +5,17 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -if ( !$value ) { +if ( ! $value ) { return; } ?> <p class="directorist-listing-single__info__excerpt"> - <?php + <?php echo esc_html( wp_trim_words( $value, (int) $data['words_limit'] ) ); if ( $data['show_readmore'] ) { // Add the permalink with the 'read more' text as a link diff --git a/templates/archive/fields/favorite_badge.php b/templates/archive/fields/favorite_badge.php index ce0f005612..729f351e65 100644 --- a/templates/archive/fields/favorite_badge.php +++ b/templates/archive/fields/favorite_badge.php @@ -5,12 +5,14 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$fav_class = $listings->loop_is_favourite() ? 'directorist-added-to-favorite' : ''; +$fav_class = $listings->loop_is_favourite() ? 'directorist-added-to-favorite' : ''; ?> -<button class="directorist-mark-as-favorite__btn <?php echo esc_attr( $fav_class ); ?> directorist-fav_<?php echo esc_attr( $listings->loop['id'] ); ?>" data-listing_id="<?php echo esc_attr( $listings->loop['id'] ); ?>" aria-label="Add to Favorite Button"> +<button class="directorist-mark-as-favorite__btn <?php echo esc_attr( $fav_class ); ?> directorist-fav_<?php echo esc_attr( $listings->loop['id'] ); ?>" data-listing_id="<?php echo esc_attr( $listings->loop['id'] ); ?>" aria-label="Add to Favorite Button"> <span class="directorist-favorite-icon"></span> <span class="directorist-favorite-tooltip"></span> </button> \ No newline at end of file diff --git a/templates/archive/fields/fax.php b/templates/archive/fields/fax.php index cec59309fe..ecd741923c 100644 --- a/templates/archive/fields/fax.php +++ b/templates/archive/fields/fax.php @@ -5,13 +5,15 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <li class="directorist-listing-card-fax"> - <?php directorist_icon( $icon ); ?> - <?php $listings->print_label( $label ); ?> - <a href="tel:<?php Helper::formatted_tel( $value ); ?>"><?php echo esc_html( $value ); ?></a> + <?php directorist_icon( $icon ); ?> + <?php $listings->print_label( $label ); ?> + <a href="tel:<?php Helper::formatted_tel( $value ); ?>"><?php echo esc_html( $value ); ?></a> </li> \ No newline at end of file diff --git a/templates/archive/fields/google-map.php b/templates/archive/fields/google-map.php index cd3f86fe6a..1d4e0ad136 100644 --- a/templates/archive/fields/google-map.php +++ b/templates/archive/fields/google-map.php @@ -6,16 +6,16 @@ */ ?> -<div class="marker" data-latitude="<?php echo esc_attr( $ls_data['manual_lat'] ); ?>" data-longitude="<?php echo esc_attr($ls_data['manual_lng']); ?>" data-icon="<?php echo esc_attr($ls_data['cat_icon']); ?>"> +<div class="marker" data-latitude="<?php echo esc_attr( $ls_data['manual_lat'] ); ?>" data-longitude="<?php echo esc_attr( $ls_data['manual_lng'] ); ?>" data-icon="<?php echo esc_attr( $ls_data['cat_icon'] ); ?>"> <?php if ( ! $map_is_disabled ) { ?> <div class='map-info-wrapper map-listing-card-single' style="display:none";> - <?php - if( ! empty( $display_favorite_badge_map ) ) { - $ls_data['listings']->get_favorite_badge(); - } + <?php + if ( ! empty( $display_favorite_badge_map ) ) { + $ls_data['listings']->get_favorite_badge(); + } ?> <?php if ( ! empty( $display_image_map ) ) { ?> @@ -25,22 +25,26 @@ <?php } - if ( ! empty( $ls_data['listing_prv_img'] ) ) { ?> + if ( ! empty( $ls_data['listing_prv_img'] ) ) { + ?> <img src='<?php echo esc_url( $ls_data['prv_image'] ); ?>' alt='<?php echo esc_attr( get_the_title() ); ?>'> <?php } - if ( ! empty( $ls_data['listing_img'][0] ) && empty( $ls_data['listing_prv_img'] ) ) { ?> + if ( ! empty( $ls_data['listing_img'][0] ) && empty( $ls_data['listing_prv_img'] ) ) { + ?> <img src='<?php echo esc_url( $ls_data['gallery_img'] ); ?>' alt='<?php echo esc_attr( get_the_title() ); ?>'> <?php } - if ( empty( $ls_data['listing_img'][0] ) && empty( $ls_data['listing_prv_img'] ) ) {?> + if ( empty( $ls_data['listing_img'][0] ) && empty( $ls_data['listing_prv_img'] ) ) { + ?> <img src='<?php echo esc_url( $ls_data['default_image'] ); ?>' alt='<?php echo esc_attr( get_the_title() ); ?>'> <?php } - if ( ! $disable_single_listing ) { ?> + if ( ! $disable_single_listing ) { + ?> </figure></a> <?php } @@ -48,11 +52,12 @@ </div> <?php } ?> - <?php - if( ! empty( $display_user_avatar_map ) ) { ?> + <?php + if ( ! empty( $display_user_avatar_map ) ) { + ?> <div class='map-listing-card-single__author'> <?php - $ls_data['listings']->get_user_avatar(); + $ls_data['listings']->get_user_avatar(); ?> </div> <?php } ?> @@ -65,51 +70,52 @@ <a href='<?php echo esc_url( get_the_permalink() ); ?>'><?php the_title(); ?></a> </h3> <?php - } - else { ?> - <h3 class='map-listing-card-single__content__title'><?php the_title();?></h3> + } else { + ?> + <h3 class='map-listing-card-single__content__title'><?php the_title(); ?></h3> <?php } ?> <?php } ?> - <?php if ( ! empty( $display_review_map ) || ! empty( $display_price_map ) ) { ?> + <?php if ( ! empty( $display_review_map ) || ! empty( $display_price_map ) ) { ?> <div class="map-listing-card-single__content__meta"> - <?php - if( ! empty( $display_review_map ) ) { - $ls_data['listings']->get_listing_review(); - } + <?php + if ( ! empty( $display_review_map ) ) { + $ls_data['listings']->get_listing_review(); + } - if( ! empty( $display_price_map ) ) { - $ls_data['listings']->get_price(); - } + if ( ! empty( $display_price_map ) ) { + $ls_data['listings']->get_price(); + } ?> </div> <?php } ?> - <?php if ( ! empty( $ls_data['address'] ) || ! empty( $ls_data['phone'] ) ) { ?> + <?php if ( ! empty( $ls_data['address'] ) || ! empty( $ls_data['phone'] ) ) { ?> <div class="map-listing-card-single__content__info"> <?php - if ( ! empty( $ls_data['address'] ) ) { - if ( ! empty( $display_address_map ) ) { ?> + if ( ! empty( $ls_data['address'] ) ) { + if ( ! empty( $display_address_map ) ) { + ?> <div class='directorist-info-item map-listing-card-single__content__address'> <?php directorist_icon( 'fas fa-map-marker-alt' ); ?> <div class="map-listing-card-single__content__location"> - <?php echo $ls_data['listings']->get_the_location() ?> + <?php echo $ls_data['listings']->get_the_location(); ?> </div> </div> <?php - } - } + } - if ( ! empty( $ls_data['phone'] ) && ! empty( $display_phone_map ) ) { ?> + if ( ! empty( $ls_data['phone'] ) && ! empty( $display_phone_map ) ) { + ?> <div class='directorist-info-item map-listing-card-single__content__phone'> <?php directorist_icon( 'fas fa-phone-alt' ); ?> <a href='./' class='map-info-link'><?php echo esc_html( $ls_data['phone'] ); ?></a> </div> <?php - } + } ?> </div> <?php } ?> diff --git a/templates/archive/fields/listing_title.php b/templates/archive/fields/listing_title.php index 63ac713064..f5f918fa52 100644 --- a/templates/archive/fields/listing_title.php +++ b/templates/archive/fields/listing_title.php @@ -5,13 +5,15 @@ * @version 7.0.4 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<h2 class="directorist-listing-title"><?php echo wp_kses_post( $listings->loop_get_title() );?></h2> +<h2 class="directorist-listing-title"><?php echo wp_kses_post( $listings->loop_get_title() ); ?></h2> -<?php if( !empty( $data['show_tagline'] ) && !empty( $listings->loop_get_tagline() ) ){ ?> - -<p class="directorist-listing-tagline"><?php echo wp_kses_post( $listings->loop_get_tagline() );?></p> +<?php if ( ! empty( $data['show_tagline'] ) && ! empty( $listings->loop_get_tagline() ) ) { ?> + +<p class="directorist-listing-tagline"><?php echo wp_kses_post( $listings->loop_get_tagline() ); ?></p> -<?php }?> \ No newline at end of file +<?php } ?> \ No newline at end of file diff --git a/templates/archive/fields/listings_location.php b/templates/archive/fields/listings_location.php index 7a4dafe21f..270888101b 100644 --- a/templates/archive/fields/listings_location.php +++ b/templates/archive/fields/listings_location.php @@ -5,13 +5,15 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <li class="directorist-listing-card-location"> - <?php directorist_icon( $icon );?> - <?php $listings->print_label( $label ); ?> - <div class="directorist-listing-card-location-list"> - <?php directorist_the_locations(); ?> - </div> + <?php directorist_icon( $icon ); ?> + <?php $listings->print_label( $label ); ?> + <div class="directorist-listing-card-location-list"> + <?php directorist_the_locations(); ?> + </div> </li> \ No newline at end of file diff --git a/templates/archive/fields/openstreet-map.php b/templates/archive/fields/openstreet-map.php index fda31a6fb0..9f8787435e 100644 --- a/templates/archive/fields/openstreet-map.php +++ b/templates/archive/fields/openstreet-map.php @@ -7,10 +7,10 @@ ?> <div class='map-listing-card-single'> - <?php - if( ! empty( $display_favorite_badge_map ) ) { - $ls_data['listings']->get_favorite_badge(); - } + <?php + if ( ! empty( $display_favorite_badge_map ) ) { + $ls_data['listings']->get_favorite_badge(); + } ?> <?php if ( ! empty( $display_image_map ) ) { ?> @@ -20,22 +20,26 @@ <?php } - if ( ! empty( $ls_data['listing_prv_img'] ) ) { ?> + if ( ! empty( $ls_data['listing_prv_img'] ) ) { + ?> <img src='<?php echo esc_url( $ls_data['prv_image'] ); ?>' alt='<?php echo esc_attr( get_the_title() ); ?>'> <?php } - if ( ! empty( $ls_data['listing_img'][0] ) && empty( $ls_data['listing_prv_img'] ) ) { ?> + if ( ! empty( $ls_data['listing_img'][0] ) && empty( $ls_data['listing_prv_img'] ) ) { + ?> <img src='<?php echo esc_url( $ls_data['gallery_img'] ); ?>' alt='<?php echo esc_attr( get_the_title() ); ?>'> <?php } - if ( empty( $ls_data['listing_img'][0] ) && empty( $ls_data['listing_prv_img'] ) ) {?> + if ( empty( $ls_data['listing_img'][0] ) && empty( $ls_data['listing_prv_img'] ) ) { + ?> <img src='<?php echo esc_url( $ls_data['default_image'] ); ?>' alt='<?php echo esc_attr( get_the_title() ); ?>'> <?php } - if ( ! $disable_single_listing ) { ?> + if ( ! $disable_single_listing ) { + ?> </figure></a> <?php } @@ -43,11 +47,12 @@ </div> <?php } ?> - <?php - if( ! empty( $display_user_avatar_map ) ) { ?> + <?php + if ( ! empty( $display_user_avatar_map ) ) { + ?> <div class='map-listing-card-single__author'> <?php - $ls_data['listings']->get_user_avatar(); + $ls_data['listings']->get_user_avatar(); ?> </div> <?php } ?> @@ -60,51 +65,52 @@ <a href='<?php echo esc_url( get_the_permalink() ); ?>'><?php the_title(); ?></a> </h3> <?php - } - else { ?> - <h3 class='map-listing-card-single__content__title'><?php the_title();?></h3> + } else { + ?> + <h3 class='map-listing-card-single__content__title'><?php the_title(); ?></h3> <?php } ?> <?php } ?> - <?php if ( ! empty( $display_review_map ) || ! empty( $display_price_map ) ) { ?> + <?php if ( ! empty( $display_review_map ) || ! empty( $display_price_map ) ) { ?> <div class="map-listing-card-single__content__meta"> - <?php - if( ! empty( $display_review_map ) ) { - $ls_data['listings']->get_listing_review(); - } + <?php + if ( ! empty( $display_review_map ) ) { + $ls_data['listings']->get_listing_review(); + } - if( ! empty( $display_price_map ) ) { - $ls_data['listings']->get_price(); - } + if ( ! empty( $display_price_map ) ) { + $ls_data['listings']->get_price(); + } ?> </div> <?php } ?> - <?php if ( ! empty( $ls_data['address'] ) || ! empty( $ls_data['phone'] ) ) { ?> + <?php if ( ! empty( $ls_data['address'] ) || ! empty( $ls_data['phone'] ) ) { ?> <div class="map-listing-card-single__content__info"> <?php - if ( ! empty( $ls_data['address'] ) ) { - if ( ! empty( $display_address_map ) ) { ?> + if ( ! empty( $ls_data['address'] ) ) { + if ( ! empty( $display_address_map ) ) { + ?> <div class='directorist-info-item map-listing-card-single__content__address'> <?php directorist_icon( 'fas fa-map-marker-alt' ); ?> <div class="map-listing-card-single__content__location"> - <?php echo $ls_data['listings']->get_the_location() ?> + <?php echo $ls_data['listings']->get_the_location(); ?> </div> </div> <?php - } - } + } - if ( ! empty( $ls_data['phone'] ) && ! empty( $display_phone_map ) ) { ?> + if ( ! empty( $ls_data['phone'] ) && ! empty( $display_phone_map ) ) { + ?> <div class='directorist-info-item map-listing-card-single__content__phone'> <?php directorist_icon( 'fas fa-phone-alt' ); ?> <a href='./' class='map-info-link'><?php echo esc_html( $ls_data['phone'] ); ?></a> </div> <?php - } + } ?> </div> <?php } ?> diff --git a/templates/archive/fields/phone.php b/templates/archive/fields/phone.php index b77243695d..ea8e4c57bd 100644 --- a/templates/archive/fields/phone.php +++ b/templates/archive/fields/phone.php @@ -5,13 +5,15 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $phone_args = array( - 'number' => $value, - 'whatsapp' => $listings->has_whatsapp( $data ), + 'number' => $value, + 'whatsapp' => $listings->has_whatsapp( $data ), ); ?> diff --git a/templates/archive/fields/phone2.php b/templates/archive/fields/phone2.php index 2fa4e5206c..01a19d78e0 100644 --- a/templates/archive/fields/phone2.php +++ b/templates/archive/fields/phone2.php @@ -5,13 +5,15 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $phone_args = array( - 'number' => $value, - 'whatsapp' => $listings->has_whatsapp( $data ), + 'number' => $value, + 'whatsapp' => $listings->has_whatsapp( $data ), ); ?> diff --git a/templates/archive/fields/posted_date.php b/templates/archive/fields/posted_date.php index 22183afc26..ff08d882fb 100644 --- a/templates/archive/fields/posted_date.php +++ b/templates/archive/fields/posted_date.php @@ -5,12 +5,14 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <<?php echo $args['before'] ? $args['before'] : 'li'; ?> class="directorist-listing-card-posted-on"> - <?php directorist_icon( $icon );?> - <span> - <?php echo esc_html( $listings->loop_get_published_date( $data ) );?> - </span> + <?php directorist_icon( $icon ); ?> + <span> + <?php echo esc_html( $listings->loop_get_published_date( $data ) ); ?> + </span> </<?php echo $args['after'] ? $args['after'] : 'li'; ?>> \ No newline at end of file diff --git a/templates/archive/fields/pricing.php b/templates/archive/fields/pricing.php index 748bc72c30..5ed9b76dcf 100644 --- a/templates/archive/fields/pricing.php +++ b/templates/archive/fields/pricing.php @@ -5,13 +5,15 @@ * @version 6.7 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $id = get_the_ID(); -if ( !Helper::has_price_range( $id ) && !Helper::has_price( $id ) ) { +if ( ! Helper::has_price_range( $id ) && ! Helper::has_price( $id ) ) { return; } ?> @@ -20,8 +22,7 @@ <?php if ( 'range' === Helper::pricing_type( $id ) ) { Helper::price_range_template( $id ); - } - elseif ( !$listings->is_disable_price ) { + } elseif ( ! $listings->is_disable_price ) { Helper::price_template( $id ); } ?> diff --git a/templates/archive/fields/rating.php b/templates/archive/fields/rating.php index 9ea561ae5c..89b3a485ab 100644 --- a/templates/archive/fields/rating.php +++ b/templates/archive/fields/rating.php @@ -5,7 +5,9 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} // Return early when review is disabled. if ( ! directorist_is_review_enabled() ) { @@ -13,7 +15,7 @@ } ?> <span class="directorist-info-item directorist-rating-meta directorist-rating-transparent"> - <?php echo wp_kses_post( $listings->loop['review']['review_stars'] ); ?> - <span class="directorist-rating-avg"><?php echo esc_html( $listings->loop['review']['average_reviews'] ); ?></span> - <span class="directorist-total-review">(<?php echo esc_html( $listings->loop['review']['total_reviews'] ); ?>)</span> + <?php echo wp_kses_post( $listings->loop['review']['review_stars'] ); ?> + <span class="directorist-rating-avg"><?php echo esc_html( $listings->loop['review']['average_reviews'] ); ?></span> + <span class="directorist-total-review">(<?php echo esc_html( $listings->loop['review']['total_reviews'] ); ?>)</span> </span> diff --git a/templates/archive/fields/related-grid.php b/templates/archive/fields/related-grid.php index 6828943b19..8650c34277 100644 --- a/templates/archive/fields/related-grid.php +++ b/templates/archive/fields/related-grid.php @@ -5,9 +5,11 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="related_single_carousel"> - <?php $listings->card_template();?> + <?php $listings->card_template(); ?> </div> \ No newline at end of file diff --git a/templates/archive/fields/thumb-card.php b/templates/archive/fields/thumb-card.php index 6a11b0e7da..bddb523186 100644 --- a/templates/archive/fields/thumb-card.php +++ b/templates/archive/fields/thumb-card.php @@ -5,33 +5,35 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$is_blur = get_directorist_option('prv_background_type', 'blur'); -$is_blur = ('blur' === $is_blur ? true : false); -$container_size_by = get_directorist_option('prv_container_size_by', 'px'); +$is_blur = get_directorist_option( 'prv_background_type', 'blur' ); +$is_blur = ( 'blur' === $is_blur ? true : false ); +$container_size_by = get_directorist_option( 'prv_container_size_by', 'px' ); $by_ratio = ( 'px' === $container_size_by ) ? false : true; -$image_size = get_directorist_option('way_to_show_preview', 'cover'); -$ratio_width = get_directorist_option('crop_width', 360); -$ratio_height = get_directorist_option('crop_height', 300); +$image_size = get_directorist_option( 'way_to_show_preview', 'cover' ); +$ratio_width = get_directorist_option( 'crop_width', 360 ); +$ratio_height = get_directorist_option( 'crop_height', 300 ); $blur_background = $is_blur; -$background_color = get_directorist_option('prv_background_color', '#fff'); +$background_color = get_directorist_option( 'prv_background_color', '#fff' ); // Style -$style_component = []; +$style_component = array(); if ( $by_ratio ) { - $padding_top_value = (int) $ratio_height / (int) $ratio_width * 100; - $style_component[ 'padding-top' ] = "{$padding_top_value}%"; + $padding_top_value = (int) $ratio_height / (int) $ratio_width * 100; + $style_component['padding-top'] = "{$padding_top_value}%"; } else { - $height_value = (int) $ratio_height; - $style_component[ 'height' ] = "{$height_value}px"; + $height_value = (int) $ratio_height; + $style_component['height'] = "{$height_value}px"; } if ( $image_size !== 'full' && ! $blur_background ) { - $style_component[ 'background-color' ] = $background_color; + $style_component['background-color'] = $background_color; } if ( $image_size === 'full' ) { - unset( $style_component[ 'height' ] ); + unset( $style_component['height'] ); } $style = ''; @@ -39,39 +41,39 @@ $style .= "{$style_prop}: {$style_value};"; } -$front_wrap_html = "<div class='directorist-thumnail-card-front-wrap'>".$listings->loop_get_the_thumbnail('directorist-thumnail-card-front-img')."</div>"; -$back_wrap_html = "<div class='directorist-thumnail-card-back-wrap'>".$listings->loop_get_the_thumbnail('directorist-thumnail-card-back-img')."</div>"; +$front_wrap_html = "<div class='directorist-thumnail-card-front-wrap'>" . $listings->loop_get_the_thumbnail( 'directorist-thumnail-card-front-img' ) . '</div>'; +$back_wrap_html = "<div class='directorist-thumnail-card-back-wrap'>" . $listings->loop_get_the_thumbnail( 'directorist-thumnail-card-back-img' ) . '</div>'; $blur_bg = ( $blur_background ) ? $back_wrap_html : ''; // Card Contain -$card_contain_wrap = "<div class='directorist-thumnail-card directorist-card-contain' style='$style'>"; -$image_contain_html = $card_contain_wrap . $blur_bg . $front_wrap_html . "</div>"; +$card_contain_wrap = "<div class='directorist-thumnail-card directorist-card-contain' style='$style'>"; +$image_contain_html = $card_contain_wrap . $blur_bg . $front_wrap_html . '</div>'; // Card Cover -$card_cover_wrap = "<div class='directorist-thumnail-card directorist-card-cover' style='$style'>"; -$image_cover_html = $card_cover_wrap . $front_wrap_html . "</div>"; +$card_cover_wrap = "<div class='directorist-thumnail-card directorist-card-cover' style='$style'>"; +$image_cover_html = $card_cover_wrap . $front_wrap_html . '</div>'; // Card Full -$card_full_wrap = "<div class='directorist-thumnail-card directorist-card-full' style='$style'>"; -$image_full_html = $card_full_wrap . $front_wrap_html . "</div>"; +$card_full_wrap = "<div class='directorist-thumnail-card directorist-card-full' style='$style'>"; +$image_full_html = $card_full_wrap . $front_wrap_html . '</div>'; $the_html = $image_cover_html; -switch ($image_size) { +switch ( $image_size ) { case 'cover': - $the_html = $image_cover_html; - break; + $the_html = $image_cover_html; + break; case 'contain': - $the_html = $image_contain_html; - break; + $the_html = $image_contain_html; + break; case 'full': - $the_html = $image_full_html; - break; + $the_html = $image_full_html; + break; } -$link_start = '<a href="'.esc_url( apply_filters( 'directorist_archive_single_listing_url', $listings->loop['permalink'], $listings->loop['id'], 'thumbnail' ) ).'">'; +$link_start = '<a href="' . esc_url( apply_filters( 'directorist_archive_single_listing_url', $listings->loop['permalink'], $listings->loop['id'], 'thumbnail' ) ) . '">'; $link_end = '</a>'; echo wp_kses_post( $the_html ); diff --git a/templates/archive/fields/user_avatar.php b/templates/archive/fields/user_avatar.php index e9e150dc00..b214197f0b 100644 --- a/templates/archive/fields/user_avatar.php +++ b/templates/archive/fields/user_avatar.php @@ -5,17 +5,18 @@ * @version 7.3.1 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$alignment = !empty( $data['align'] ) ? $data['align'] : '' ; +$alignment = ! empty( $data['align'] ) ? $data['align'] : ''; ?> -<div class="directorist-thumb-listing-author directorist-alignment-<?php echo esc_attr( $alignment ) ?>"> +<div class="directorist-thumb-listing-author directorist-alignment-<?php echo esc_attr( $alignment ); ?>"> <a href="<?php echo esc_url( $listings->loop['author_link'] ); ?>" aria-label="Author Image" class="<?php echo esc_attr( $listings->loop['author_link_class'] ); ?>"> - <?php if ($listings->loop['u_pro_pic']) { ?> - <img src="<?php echo esc_url($listings->loop['u_pro_pic'][0]); ?>" alt="<?php esc_attr_e( 'Author Image', 'directorist' );?>"> + <?php if ( $listings->loop['u_pro_pic'] ) { ?> + <img src="<?php echo esc_url( $listings->loop['u_pro_pic'][0] ); ?>" alt="<?php esc_attr_e( 'Author Image', 'directorist' ); ?>"> <?php - } - else { + } else { echo wp_kses_post( $listings->loop['avatar_img'] ); } ?> diff --git a/templates/archive/fields/view_count.php b/templates/archive/fields/view_count.php index 6a93edae89..37f154aded 100644 --- a/templates/archive/fields/view_count.php +++ b/templates/archive/fields/view_count.php @@ -5,7 +5,9 @@ * @version 7.8.3 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<div class="directorist-view-count"><?php directorist_icon( $icon ); ?><?php echo ! empty($listings->loop['post_view']) ? esc_html( $listings->loop['post_view'] ) : 0;?></div> +<div class="directorist-view-count"><?php directorist_icon( $icon ); ?><?php echo ! empty( $listings->loop['post_view'] ) ? esc_html( $listings->loop['post_view'] ) : 0; ?></div> diff --git a/templates/archive/fields/website.php b/templates/archive/fields/website.php index 23f32b0174..afc8edd9ab 100644 --- a/templates/archive/fields/website.php +++ b/templates/archive/fields/website.php @@ -5,13 +5,15 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <li class="directorist-listing-card-website"> - <?php directorist_icon( $icon ); ?> - <?php $listings->print_label( $label ); ?> - <a target="_blank" rel="noopener" href="<?php echo esc_url( $value ); ?>"> - <?php echo esc_html( $value ); ?> - </a> + <?php directorist_icon( $icon ); ?> + <?php $listings->print_label( $label ); ?> + <a target="_blank" rel="noopener" href="<?php echo esc_url( $value ); ?>"> + <?php echo esc_html( $value ); ?> + </a> </li> \ No newline at end of file diff --git a/templates/archive/fields/zip.php b/templates/archive/fields/zip.php index a0b6dab081..c7cabb1fc8 100644 --- a/templates/archive/fields/zip.php +++ b/templates/archive/fields/zip.php @@ -7,7 +7,7 @@ ?> <li class="directorist-listing-card-zip"> - <?php directorist_icon( $icon ); ?> - <?php $listings->print_label( $label ); ?> - <?php echo esc_html( $value ); ?> + <?php directorist_icon( $icon ); ?> + <?php $listings->print_label( $label ); ?> + <?php echo esc_html( $value ); ?> </li> \ No newline at end of file diff --git a/templates/archive/grid-view.php b/templates/archive/grid-view.php index 8ad3a7e357..bcd617adb9 100644 --- a/templates/archive/grid-view.php +++ b/templates/archive/grid-view.php @@ -5,21 +5,23 @@ * @version 8.1 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<div class="directorist-archive-items directorist-archive-grid-view <?php echo esc_attr( $listings->pagination_infinite_scroll_class() ) ?>"> +<div class="directorist-archive-items directorist-archive-grid-view <?php echo esc_attr( $listings->pagination_infinite_scroll_class() ); ?>"> <div class="<?php Helper::directorist_container_fluid(); ?>"> <?php do_action( 'directorist_before_grid_listings_loop' ); ?> - <?php if ( $listings->have_posts() ): ?> + <?php if ( $listings->have_posts() ) : ?> <div class="<?php echo $listings->has_masonry() ? 'directorist-masonry' : ''; ?> <?php Helper::directorist_row(); ?>"> - <?php $listings->render_grid_view( $listings->post_ids() ) ?> + <?php $listings->render_grid_view( $listings->post_ids() ); ?> </div> @@ -34,9 +36,9 @@ } ?> - <?php do_action('directorist_after_grid_listings_loop'); ?> + <?php do_action( 'directorist_after_grid_listings_loop' ); ?> - <?php else: ?> + <?php else : ?> <div class="directorist-archive-notfound"><?php esc_html_e( 'No listings found.', 'directorist' ); ?></div> diff --git a/templates/archive/header-bar.php b/templates/archive/header-bar.php index 798ae7d666..62c4d2981d 100644 --- a/templates/archive/header-bar.php +++ b/templates/archive/header-bar.php @@ -5,33 +5,35 @@ * @version 8.0.1 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-header-bar"> <div class="<?php Helper::directorist_container_fluid(); ?>"> <div class="directorist-listings-header"> - <?php if ( $listings->has_listings_header() ): ?> + <?php if ( $listings->has_listings_header() ) : ?> <div class="directorist-listings-header__left"> - <?php if ( $listings->has_filters_button && 'no_sidebar' === $listings->sidebar ): ?> + <?php if ( $listings->has_filters_button && 'no_sidebar' === $listings->sidebar ) : ?> <button class="directorist-btn directorist-btn-sm directorist-filter-btn directorist-modal-btn directorist-modal-btn--full" aria-label="Modal Button"><?php echo wp_kses_post( $listings->filter_btn_html() ); ?></button> <?php endif; ?> - <?php - if ( $listings->header_title && ! empty( $listings->options['display_listings_count'] ) ) { - echo $listings->listings_header_title(); - } + <?php + if ( $listings->header_title && ! empty( $listings->options['display_listings_count'] ) ) { + echo $listings->listings_header_title(); + } ?> </div> <?php endif; ?> - <?php if ( $listings->has_header_toolbar() ): ?> + <?php if ( $listings->has_header_toolbar() ) : ?> <div class="directorist-listings-header__right"> <?php diff --git a/templates/archive/list-view.php b/templates/archive/list-view.php index 0e4e5ac1e8..0df119b1cf 100644 --- a/templates/archive/list-view.php +++ b/templates/archive/list-view.php @@ -5,20 +5,22 @@ * @version 8.1 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<div class="directorist-archive-items directorist-archive-list-view <?php echo esc_attr( $listings->pagination_infinite_scroll_class() ) ?>"> +<div class="directorist-archive-items directorist-archive-list-view <?php echo esc_attr( $listings->pagination_infinite_scroll_class() ); ?>"> <div class="<?php Helper::directorist_container_fluid(); ?>"> <?php do_action( 'directorist_before_list_listings_loop' ); ?> - <?php if ( $listings->have_posts() ): ?> + <?php if ( $listings->have_posts() ) : ?> <div class="<?php Helper::directorist_row(); ?>"> - <?php $listings->render_list_view( $listings->post_ids() ) ?> + <?php $listings->render_list_view( $listings->post_ids() ); ?> </div> <div/> @@ -33,9 +35,9 @@ } ?> - <?php do_action('directorist_after_grid_listings_loop'); ?> + <?php do_action( 'directorist_after_grid_listings_loop' ); ?> - <?php else: ?> + <?php else : ?> <div class="directorist-archive-notfound"><?php esc_html_e( 'No listings found.', 'directorist' ); ?></div> diff --git a/templates/archive/loop-grid-nothumb.php b/templates/archive/loop-grid-nothumb.php index 0144c99b8e..d2675476fa 100644 --- a/templates/archive/loop-grid-nothumb.php +++ b/templates/archive/loop-grid-nothumb.php @@ -5,28 +5,30 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $loop_fields = $listings->loop['card_fields']['template_data']['grid_view_without_thumbnail']; // Capture output for avatar ob_start(); -$listings->render_loop_fields($loop_fields['body']['avatar']); +$listings->render_loop_fields( $loop_fields['body']['avatar'] ); $listing_avatar = ob_get_clean(); // Capture output for title ob_start(); -$listings->render_loop_fields($loop_fields['body']['title']); +$listings->render_loop_fields( $loop_fields['body']['title'] ); $listing_title = ob_get_clean(); // Capture output for quick actions ob_start(); -$listings->render_loop_fields($loop_fields['body']['quick_actions']); +$listings->render_loop_fields( $loop_fields['body']['quick_actions'] ); $quick_actions_field = ob_get_clean(); // Capture output for quick_info ob_start(); -$listings->render_loop_fields($loop_fields['body']['quick_info']); +$listings->render_loop_fields( $loop_fields['body']['quick_info'] ); $quick_info_field = ob_get_clean(); ?> @@ -63,16 +65,16 @@ <?php endif; ?> <section class="directorist-listing-single__content"> - <ul class="directorist-listing-single__info__list"><?php $listings->render_loop_fields($loop_fields['body']['bottom'], '', ''); ?></ul> + <ul class="directorist-listing-single__info__list"><?php $listings->render_loop_fields( $loop_fields['body']['bottom'], '', '' ); ?></ul> <?php if ( ! empty( $loop_fields['body']['excerpt'] ) ) : ?> - <?php $listings->render_loop_fields( $loop_fields['body']['excerpt'] ) ?> + <?php $listings->render_loop_fields( $loop_fields['body']['excerpt'] ); ?> <?php endif; ?> </section> <footer class="directorist-listing-single__meta"> - <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields($loop_fields['footer']['left']); ?></div> - <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields($loop_fields['footer']['right']); ?></div> + <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields( $loop_fields['footer']['left'] ); ?></div> + <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields( $loop_fields['footer']['right'] ); ?></div> </footer> </article> \ No newline at end of file diff --git a/templates/archive/loop-grid.php b/templates/archive/loop-grid.php index 279d8ee5c8..663f1ba0b8 100644 --- a/templates/archive/loop-grid.php +++ b/templates/archive/loop-grid.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $loop_fields = $listings->loop['card_fields']['template_data']['grid_view_with_thumbnail']; ?> @@ -16,13 +18,13 @@ <?php $listings->loop_thumb_card_template(); - $listings->render_loop_fields($loop_fields['thumbnail']['avatar']); + $listings->render_loop_fields( $loop_fields['thumbnail']['avatar'] ); ?> - <div class="directorist-thumb-top-left"><?php $listings->render_loop_fields($loop_fields['thumbnail']['top_left']); ?></div> - <div class="directorist-thumb-top-right"><?php $listings->render_loop_fields($loop_fields['thumbnail']['top_right']); ?></div> - <div class="directorist-thumb-bottom-left"><?php $listings->render_loop_fields($loop_fields['thumbnail']['bottom_left']); ?></div> - <div class="directorist-thumb-bottom-right"><?php $listings->render_loop_fields($loop_fields['thumbnail']['bottom_right']); ?></div> + <div class="directorist-thumb-top-left"><?php $listings->render_loop_fields( $loop_fields['thumbnail']['top_left'] ); ?></div> + <div class="directorist-thumb-top-right"><?php $listings->render_loop_fields( $loop_fields['thumbnail']['top_right'] ); ?></div> + <div class="directorist-thumb-bottom-left"><?php $listings->render_loop_fields( $loop_fields['thumbnail']['bottom_left'] ); ?></div> + <div class="directorist-thumb-bottom-right"><?php $listings->render_loop_fields( $loop_fields['thumbnail']['bottom_right'] ); ?></div> </div> @@ -37,13 +39,13 @@ </ul> <?php if ( ! empty( $loop_fields['body']['excerpt'] ) ) : ?> - <?php $listings->render_loop_fields( $loop_fields['body']['excerpt'] ) ?> + <?php $listings->render_loop_fields( $loop_fields['body']['excerpt'] ); ?> <?php endif; ?> </section> <footer class="directorist-listing-single__meta"> - <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields($loop_fields['footer']['left']); ?></div> - <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields($loop_fields['footer']['right']); ?></div> + <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields( $loop_fields['footer']['left'] ); ?></div> + <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields( $loop_fields['footer']['right'] ); ?></div> </footer> </div> diff --git a/templates/archive/loop-list-nothumb.php b/templates/archive/loop-list-nothumb.php index 483c39749f..0959a1bb65 100644 --- a/templates/archive/loop-list-nothumb.php +++ b/templates/archive/loop-list-nothumb.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $loop_fields = $listings->loop['list_fields']['template_data']['list_view_without_thumbnail']; ?> @@ -17,35 +19,35 @@ <section class="directorist-listing-single__info"> <div class="directorist-listing-single__info__top-right"> <header class="directorist-listing-single__info__top"> - <?php $listings->render_loop_fields($loop_fields['body']['top']); ?> + <?php $listings->render_loop_fields( $loop_fields['body']['top'] ); ?> </header> <div class="directorist-listing-single__info__right"> <div class="directorist-listing-single__action"> - <?php $listings->render_loop_fields($loop_fields['body']['right']); ?> + <?php $listings->render_loop_fields( $loop_fields['body']['right'] ); ?> </div> </div> </div> <ul class="directorist-listing-single__info__list"> - <?php $listings->render_loop_fields($loop_fields['body']['bottom'], 'li', 'li'); ?> + <?php $listings->render_loop_fields( $loop_fields['body']['bottom'], 'li', 'li' ); ?> </ul> <?php if ( ! empty( $loop_fields['body']['excerpt'] ) ) : ?> - <?php $listings->render_loop_fields( $loop_fields['body']['excerpt'] ) ?> + <?php $listings->render_loop_fields( $loop_fields['body']['excerpt'] ); ?> <?php endif; ?> </section> <footer class="directorist-listing-single__meta"> - <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields($loop_fields['footer']['left']); ?></div> - <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields($loop_fields['footer']['right']); ?></div> + <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields( $loop_fields['footer']['left'] ); ?></div> + <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields( $loop_fields['footer']['right'] ); ?></div> </footer> </div> <footer class="directorist-listing-single__mobile-view-meta"> <div class="directorist-listing-single__meta"> - <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields($loop_fields['footer']['left']); ?></div> - <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields($loop_fields['footer']['right']); ?></div> + <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields( $loop_fields['footer']['left'] ); ?></div> + <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields( $loop_fields['footer']['right'] ); ?></div> </div> </footer> diff --git a/templates/archive/loop-list.php b/templates/archive/loop-list.php index b7aef7722c..950ac2385d 100644 --- a/templates/archive/loop-list.php +++ b/templates/archive/loop-list.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $loop_fields = $listings->loop['list_fields']['template_data']['list_view_with_thumbnail']; ?> @@ -14,7 +16,7 @@ <div class="directorist-listing-single__thumb"> <?php $listings->loop_thumb_card_template(); ?> - <div class="directorist-thumb-top-right"><?php $listings->render_loop_fields($loop_fields['thumbnail']['top_right']); ?></div> + <div class="directorist-thumb-top-right"><?php $listings->render_loop_fields( $loop_fields['thumbnail']['top_right'] ); ?></div> </div> <section class="directorist-listing-single__content"> @@ -26,29 +28,29 @@ </header> <div class="directorist-listing-single__info__right"> <div class="directorist-listing-single__action"> - <?php $listings->render_loop_fields($loop_fields['body']['right']); ?> + <?php $listings->render_loop_fields( $loop_fields['body']['right'] ); ?> </div> </div> </div> <ul class="directorist-listing-single__info__list"> - <?php $listings->render_loop_fields($loop_fields['body']['bottom'], '', ''); ?> + <?php $listings->render_loop_fields( $loop_fields['body']['bottom'], '', '' ); ?> </ul> <?php if ( ! empty( $loop_fields['body']['excerpt'] ) ) : ?> - <?php $listings->render_loop_fields( $loop_fields['body']['excerpt'] ) ?> + <?php $listings->render_loop_fields( $loop_fields['body']['excerpt'] ); ?> <?php endif; ?> </div> <footer class="directorist-listing-single__meta"> - <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields($loop_fields['footer']['left']); ?></div> - <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields($loop_fields['footer']['right']); ?></div> + <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields( $loop_fields['footer']['left'] ); ?></div> + <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields( $loop_fields['footer']['right'] ); ?></div> </footer> </section> <footer class="directorist-listing-single__mobile-view-meta"> <div class="directorist-listing-single__meta"> - <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields($loop_fields['footer']['left']); ?></div> - <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields($loop_fields['footer']['right']); ?></div> + <div class="directorist-listing-single__meta__left"><?php $listings->render_loop_fields( $loop_fields['footer']['left'] ); ?></div> + <div class="directorist-listing-single__meta__right"><?php $listings->render_loop_fields( $loop_fields['footer']['right'] ); ?></div> </div> </footer> diff --git a/templates/archive/map-view.php b/templates/archive/map-view.php index 7a51f2fb01..ff4624dbbd 100644 --- a/templates/archive/map-view.php +++ b/templates/archive/map-view.php @@ -5,7 +5,9 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-archive-items directorist-archive-map-view"> diff --git a/templates/archive/mobile-search-form.php b/templates/archive/mobile-search-form.php index 75817275fa..baec69c4ab 100644 --- a/templates/archive/mobile-search-form.php +++ b/templates/archive/mobile-search-form.php @@ -12,53 +12,53 @@ ?> <div class="directorist-all-listing-btn"> - <div class="directorist-all-listing-btn__back"> + <div class="directorist-all-listing-btn__back"> <a href="#" class="directorist-btn__back"><?php directorist_icon( 'las la-arrow-left' ); ?></a> </div> - <div class="directorist-all-listing-btn__basic"> + <div class="directorist-all-listing-btn__basic"> <a href="#" class="directorist-btn directorist-btn-light directorist-modal-btn directorist-modal-btn--basic"><?php directorist_icon( 'las la-search' ); ?> <?php esc_html_e( 'Search', 'directorist' ); ?></a> </div> - <div class="directorist-all-listing-btn__advanced"> - <a href="#" class="directorist-modal-btn directorist-modal-btn--advanced"><?php directorist_icon( 'fas fa-sliders-h' ); ?></a> - </div> + <div class="directorist-all-listing-btn__advanced"> + <a href="#" class="directorist-modal-btn directorist-modal-btn--advanced"><?php directorist_icon( 'fas fa-sliders-h' ); ?></a> + </div> </div> <div class="directorist-all-listing-modal"> - <form action="<?php echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); ?>" class="directorist-search-form" data-atts="<?php echo esc_attr( $searchform->get_atts_data() ); ?>"> - <div class="directorist-search-modal directorist-search-modal--advanced"> - <div class="directorist-search-modal__overlay"></div> - <div class="directorist-search-adv-filter directorist-advanced-filter directorist-search-modal__contents"> - <div class="directorist-search-modal__contents__header"> - <h3 class="directorist-search-modal__contents__title"><?php esc_html_e( 'More Filters', 'directorist' ); ?></h3> - <button class="directorist-search-modal__contents__btn directorist-search-modal__contents__btn--close"><?php directorist_icon( 'fas fa-times' ); ?></button> - <span class="directorist-search-modal__minimizer"></span> - </div> - <div class="directorist-search-modal__contents__body"> - <?php foreach ( $searchform->form_data[1]['fields'] as $field ): ?> - <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] )?>"> + <form action="<?php echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); ?>" class="directorist-search-form" data-atts="<?php echo esc_attr( $searchform->get_atts_data() ); ?>"> + <div class="directorist-search-modal directorist-search-modal--advanced"> + <div class="directorist-search-modal__overlay"></div> + <div class="directorist-search-adv-filter directorist-advanced-filter directorist-search-modal__contents"> + <div class="directorist-search-modal__contents__header"> + <h3 class="directorist-search-modal__contents__title"><?php esc_html_e( 'More Filters', 'directorist' ); ?></h3> + <button class="directorist-search-modal__contents__btn directorist-search-modal__contents__btn--close"><?php directorist_icon( 'fas fa-times' ); ?></button> + <span class="directorist-search-modal__minimizer"></span> + </div> + <div class="directorist-search-modal__contents__body"> + <?php foreach ( $searchform->form_data[1]['fields'] as $field ) : ?> + <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] ); ?>"> + <?php $searchform->field_template( $field ); ?> + </div> + <?php endforeach; ?> + </div> + <div class="directorist-search-modal__contents__footer"> + <?php $searchform->buttons_template(); ?> + </div> + </div> + </div> + <div class="directorist-search-modal directorist-search-modal--basic"> + <div class="directorist-search-modal__overlay"></div> + <div class="directorist-search-adv-filter directorist-advanced-filter directorist-search-modal__contents"> + <span class="directorist-search-modal__minimizer"></span> + <div class="directorist-search-modal__contents__body"> + <?php foreach ( $searchform->form_data[0]['fields'] as $field ) : ?> + <div class="directorist-search-modal__input"> <?php $searchform->field_template( $field ); ?> </div> <?php endforeach; ?> - </div> - <div class="directorist-search-modal__contents__footer"> - <?php $searchform->buttons_template(); ?> - </div> - </div> - </div> - <div class="directorist-search-modal directorist-search-modal--basic"> - <div class="directorist-search-modal__overlay"></div> - <div class="directorist-search-adv-filter directorist-advanced-filter directorist-search-modal__contents"> - <span class="directorist-search-modal__minimizer"></span> - <div class="directorist-search-modal__contents__body"> - <?php foreach ( $searchform->form_data[0]['fields'] as $field ) : ?> - <div class="directorist-search-modal__input"> - <?php $searchform->field_template( $field ); ?> - </div> - <?php endforeach; ?> - <button type="submit" class="directorist-btn directorist-btn-white directorist-search-form-action__modal__btn-search"><?php directorist_icon( 'las la-search' ); ?> <?php esc_html_e( 'Search', 'directorist' ); ?></button> - </div> - </div> - </div> - </form> + <button type="submit" class="directorist-btn directorist-btn-white directorist-search-form-action__modal__btn-search"><?php directorist_icon( 'las la-search' ); ?> <?php esc_html_e( 'Search', 'directorist' ); ?></button> + </div> + </div> + </div> + </form> </div> diff --git a/templates/archive/search-form.php b/templates/archive/search-form.php index 5adbbc781b..31d207b091 100644 --- a/templates/archive/search-form.php +++ b/templates/archive/search-form.php @@ -7,8 +7,8 @@ ?> <?php -if (is_numeric($searchform->listing_type)) { - $term = get_term_by('id', $searchform->listing_type, ATBDP_TYPE); +if ( is_numeric( $searchform->listing_type ) ) { + $term = get_term_by( 'id', $searchform->listing_type, ATBDP_TYPE ); $listing_type = $term->slug; } ?> @@ -25,16 +25,16 @@ </div> <div class="directorist-search-modal__contents__body"> - <input type="hidden" name='directory_type' value='<?php echo !empty($listing_type) ? esc_attr( $listing_type ) : esc_attr( $searchform->listing_type ); ?>'> + <input type="hidden" name='directory_type' value='<?php echo ! empty( $listing_type ) ? esc_attr( $listing_type ) : esc_attr( $searchform->listing_type ); ?>'> <div class="directorist-advanced-filter__basic"> - <?php foreach ($searchform->form_data[0]['fields'] as $field) : ?> - <div class="directorist-advanced-filter__basic__element"><?php $searchform->field_template($field); ?></div> + <?php foreach ( $searchform->form_data[0]['fields'] as $field ) : ?> + <div class="directorist-advanced-filter__basic__element"><?php $searchform->field_template( $field ); ?></div> <?php endforeach; ?> </div> <div class="directorist-advanced-filter__advanced"> - <?php foreach ($searchform->form_data[1]['fields'] as $field) : ?> - <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr($field['widget_name']) ?>"><?php $searchform->field_template($field); ?></div> + <?php foreach ( $searchform->form_data[1]['fields'] as $field ) : ?> + <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] ); ?>"><?php $searchform->field_template( $field ); ?></div> <?php endforeach; ?> </div> </div> diff --git a/templates/archive/sortby-dropdown.php b/templates/archive/sortby-dropdown.php index 8b386a70b2..4fa84df4f2 100644 --- a/templates/archive/sortby-dropdown.php +++ b/templates/archive/sortby-dropdown.php @@ -5,7 +5,9 @@ * @version 7.3.1 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-dropdown directorist-dropdown-js directorist-sortby-dropdown"> @@ -16,11 +18,11 @@ <form id="directorsit-listing-sort" method="post" action="#"> <?php - $current_order = !empty($_GET['sort']) ? sanitize_text_field( wp_unslash( $_GET['sort'] ) ) : ''; - foreach ($listings->get_sort_by_link_list() as $key => $value) { + $current_order = ! empty( $_GET['sort'] ) ? sanitize_text_field( wp_unslash( $_GET['sort'] ) ) : ''; + foreach ( $listings->get_sort_by_link_list() as $key => $value ) { $active_class = ( $value['key'] == $current_order ) ? ' active' : ''; ?> - <a href="#" class="directorist-dropdown__links__single directorist-dropdown__links__single-js <?php echo esc_attr( $active_class );?>" data-link="<?php echo esc_attr( $value['link'] ); ?>"><?php echo esc_html($value['label']);?></a> + <a href="#" class="directorist-dropdown__links__single directorist-dropdown__links__single-js <?php echo esc_attr( $active_class ); ?>" data-link="<?php echo esc_attr( $value['link'] ); ?>"><?php echo esc_html( $value['label'] ); ?></a> <?php } ?> diff --git a/templates/archive/viewas-dropdown.php b/templates/archive/viewas-dropdown.php index dcd498d0b9..5721155863 100644 --- a/templates/archive/viewas-dropdown.php +++ b/templates/archive/viewas-dropdown.php @@ -5,27 +5,29 @@ * @version 8.0.1 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-viewas"> <!-- Archive sidebar offcanvas toggle --> - <?php if( $listings->sidebar != 'no_sidebar' ) : ?> + <?php if ( $listings->sidebar != 'no_sidebar' ) : ?> <button class="directorist-archive-sidebar-toggle" aria-label="Sidebar Filter Toggle Button"> <?php directorist_icon( 'fas fa-filter' ); ?> Filter </button> <?php endif; ?> - <?php foreach ( array_unique($listings->get_view_as_link_list(), SORT_REGULAR) as $key => $value ): ?> + <?php foreach ( array_unique( $listings->get_view_as_link_list(), SORT_REGULAR ) as $key => $value ) : ?> - <a class="directorist-viewas__item directorist-viewas__item--<?php echo esc_attr( strtolower( $value['label'] ) ) ?> <?php echo esc_attr( $value['active_class'] ); ?>" href="<?php echo esc_attr( $value['link'] ); ?>" aria-label="<?php echo esc_attr( strtolower( $value['label'] ) ) ?> view"> - <?php if ( strpos( $value['link'], 'grid' ) ): ?> + <a class="directorist-viewas__item directorist-viewas__item--<?php echo esc_attr( strtolower( $value['label'] ) ); ?> <?php echo esc_attr( $value['active_class'] ); ?>" href="<?php echo esc_attr( $value['link'] ); ?>" aria-label="<?php echo esc_attr( strtolower( $value['label'] ) ); ?> view"> + <?php if ( strpos( $value['link'], 'grid' ) ) : ?> <?php directorist_icon( 'fas fa-grip-horizontal' ); ?> - <?php elseif ( strpos( $value['link'], 'map' ) ): ?> + <?php elseif ( strpos( $value['link'], 'map' ) ) : ?> <?php directorist_icon( 'far fa-map' ); ?> - <?php elseif ( strpos( $value['link'], 'list' ) ): ?> + <?php elseif ( strpos( $value['link'], 'list' ) ) : ?> <?php directorist_icon( 'fas fa-list' ); ?> - <?php endif;?> + <?php endif; ?> </a> <?php endforeach; ?> </div> \ No newline at end of file diff --git a/templates/author-contents.php b/templates/author-contents.php index cea0082729..5055a0cd90 100644 --- a/templates/author-contents.php +++ b/templates/author-contents.php @@ -5,9 +5,11 @@ * @version 7.7.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-wrapper directorist-author-profile-content directorist-w-100"> diff --git a/templates/author/about.php b/templates/author/about.php index 61bbd296d3..293a3faaf7 100644 --- a/templates/author/about.php +++ b/templates/author/about.php @@ -5,9 +5,11 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <?php do_action( 'directorist_before_author_about_section' ); ?> @@ -26,52 +28,52 @@ <ul class="directorist-author-info-list"> - <?php if ( $address ): ?> + <?php if ( $address ) : ?> <li class="directorist-author-info-list__item"> <?php directorist_icon( 'las la-map-marker' ); ?> <span class="directorist-info"><?php echo esc_html( $address ); ?></span> </li> <?php endif; ?> - <?php if ( $phone ): ?> + <?php if ( $phone ) : ?> <li class="directorist-author-info-list__item"> <?php directorist_icon( 'las la-phone' ); ?> <span class="directorist-info"><a href="tel:<?php ATBDP_Helper::sanitize_tel_attr( $phone ); ?>"><?php echo esc_html( $phone ); ?></a></span> </li> <?php endif; ?> - <?php if ( $email_endabled && $email ): ?> + <?php if ( $email_endabled && $email ) : ?> <li class="directorist-author-info-list__item"> <?php directorist_icon( 'las la-envelope' ); ?> <span class="directorist-info"><?php echo esc_html( $email ); ?></span> </li> <?php endif; ?> - <?php if ( $website ): ?> + <?php if ( $website ) : ?> <li class="directorist-author-info-list__item"> <?php directorist_icon( 'las la-globe' ); ?> - <span class="directorist-info"><a target="_blank" href="<?php echo esc_url( $website ); ?>"><?php echo esc_html( $website) ; ?></a></span> + <span class="directorist-info"><a target="_blank" href="<?php echo esc_url( $website ); ?>"><?php echo esc_html( $website ); ?></a></span> </li> <?php endif; ?> </ul> - <?php if ( $facebook || $twitter || $linkedin || $youtube ): ?> + <?php if ( $facebook || $twitter || $linkedin || $youtube ) : ?> <ul class="directorist-author-social"> - <?php if ( $facebook ): ?> + <?php if ( $facebook ) : ?> <li class="directorist-author-social-item directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $facebook ); ?>"><?php directorist_icon( 'lab la-facebook' ); ?></a></li> <?php endif; ?> - <?php if ( $twitter ): ?> + <?php if ( $twitter ) : ?> <li class="directorist-author-social-item directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $twitter ); ?>"><?php directorist_icon( 'lab la-twitter' ); ?></a></li> <?php endif; ?> - <?php if ( $linkedin ): ?> + <?php if ( $linkedin ) : ?> <li class="directorist-author-social-item directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $linkedin ); ?>"><?php directorist_icon( 'lab la-linkedin' ); ?></a></li> <?php endif; ?> - <?php if ( $youtube ): ?> + <?php if ( $youtube ) : ?> <li class="directorist-author-social-item directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $youtube ); ?>"><?php directorist_icon( 'lab la-youtube' ); ?></a></li> <?php endif; ?> @@ -93,7 +95,7 @@ <div class="directorist-card__body"> <div class="directorist-author-about__content"> - <p><?php echo $bio ? wp_kses_post( $bio ) : esc_html__( 'Nothing to show!', 'directorist' );?></p> + <p><?php echo $bio ? wp_kses_post( $bio ) : esc_html__( 'Nothing to show!', 'directorist' ); ?></p> </div> </div> diff --git a/templates/author/header.php b/templates/author/header.php index 32cdaa8214..cf335e72d8 100644 --- a/templates/author/header.php +++ b/templates/author/header.php @@ -5,9 +5,11 @@ * @version 7.7.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <section class="directorist-author-profile-area directorist-author-profile"> @@ -29,7 +31,7 @@ <ul class="directorist-author-meta-list directorist-author-profile__meta-list"> - <?php if ( $author->review_enabled() ): ?> + <?php if ( $author->review_enabled() ) : ?> <li class="directorist-author-meta-list__item directorist-info-meta directorist-author-profile__meta-list__item"> <?php directorist_icon( 'fas fa-star' ); ?> <span class="directorist-review-count"> diff --git a/templates/author/listings.php b/templates/author/listings.php index 48d94d5027..cc5fffb332 100644 --- a/templates/author/listings.php +++ b/templates/author/listings.php @@ -5,13 +5,15 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <header class="directorist-author-listing-top"> - <h2 class="directorist-author-listing-top__title"><?php esc_html_e( 'Author Listings' , 'directorist'); ?></h2> + <h2 class="directorist-author-listing-top__title"><?php esc_html_e( 'Author Listings', 'directorist' ); ?></h2> <div class="directorist-author-listing-top__filter"> <div class="directorist-author-listing-type"> <?php $author->archive_type( $author ); ?> @@ -19,14 +21,14 @@ <div class="directorist-dropdown directorist-dropdown-js directorist-author-listing-top__dropdown directorist-dropdown-update-js"> - <button class="directorist-dropdown__toggle directorist-dropdown__toggle-js directorist-toggle-has-icon directorist-btn" id="directorist-dropdown-menu-link"><?php esc_html_e( 'Filter by category', 'directorist'); ?> <span class="atbd_drop-caret"></span></button> + <button class="directorist-dropdown__toggle directorist-dropdown__toggle-js directorist-toggle-has-icon directorist-btn" id="directorist-dropdown-menu-link"><?php esc_html_e( 'Filter by category', 'directorist' ); ?> <span class="atbd_drop-caret"></span></button> <div class="directorist-dropdown__links directorist-dropdown__links-js"> <?php - foreach ($author->get_listing_categories() as $category) { - $active_class = ( isset($_GET['category']) && ($category->slug == $_GET['category']) ) ? 'active' : ''; - $link = directorist_add_query_args_with_no_pagination( [ 'category' => $category->slug ] ); + foreach ( $author->get_listing_categories() as $category ) { + $active_class = ( isset( $_GET['category'] ) && ( $category->slug == $_GET['category'] ) ) ? 'active' : ''; + $link = directorist_add_query_args_with_no_pagination( array( 'category' => $category->slug ) ); printf( '<a class="directorist-dropdown__links__single %s" href="%s">%s</a>', esc_attr( $active_class ), esc_url( $link ), esc_html( $category->name ) ); } ?> @@ -44,7 +46,7 @@ <div class="<?php Helper::directorist_row(); ?>"> - <?php foreach ( $listings->post_ids() as $listing_id ): ?> + <?php foreach ( $listings->post_ids() as $listing_id ) : ?> <div class="<?php Helper::directorist_column( $author->columns ); ?>"> <?php $listings->loop_template( 'grid', $listing_id ); ?> diff --git a/templates/dashboard-contents.php b/templates/dashboard-contents.php index bb04d99d94..51ee14a93c 100644 --- a/templates/dashboard-contents.php +++ b/templates/dashboard-contents.php @@ -5,9 +5,11 @@ * @version 7.4 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-user-dashboard"> @@ -16,7 +18,7 @@ <?php $dashboard->notice_template(); ?> - <?php if ( $dashboard->display_title() ): ?> + <?php if ( $dashboard->display_title() ) : ?> <h2><?php esc_html_e( 'My Dashboard', 'directorist' ); ?></h2> <?php endif; ?> diff --git a/templates/dashboard/listing-row.php b/templates/dashboard/listing-row.php index 2dca887ec3..08cd6bae88 100644 --- a/templates/dashboard/listing-row.php +++ b/templates/dashboard/listing-row.php @@ -5,9 +5,11 @@ * @version 7.4.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} if ( $query->have_posts() ) { @@ -39,7 +41,7 @@ <?php do_action( 'directorist_dashboard_listing_td_2', $dashboard ); ?> - <?php if ( directorist_is_multi_directory_enabled() ): ?> + <?php if ( directorist_is_multi_directory_enabled() ) : ?> <td><span class="directorist-listing-plan"><?php echo esc_html( $dashboard->get_listing_type() ); ?></span></td> <?php endif; ?> @@ -52,7 +54,7 @@ <td> <div class="directorist-actions"> - <a href="<?php echo esc_url(ATBDP_Permalink::get_edit_listing_page_link(get_the_ID())); ?>" class="directorist-link-btn"><?php directorist_icon( 'las la-edit' ); ?><?php esc_html_e( 'Edit', 'directorist' ); ?></a> + <a href="<?php echo esc_url( ATBDP_Permalink::get_edit_listing_page_link( get_the_ID() ) ); ?>" class="directorist-link-btn"><?php directorist_icon( 'las la-edit' ); ?><?php esc_html_e( 'Edit', 'directorist' ); ?></a> <div class="directorist-dropdown"> @@ -64,8 +66,8 @@ <?php $dropdown_items = $dashboard->get_action_dropdown_item(); - if( $dropdown_items ) { - foreach( $dropdown_items as $item ) { + if ( $dropdown_items ) { + foreach ( $dropdown_items as $item ) { ?> <a class="directorist-dropdown-item <?php echo esc_attr( $item['class'] ); ?>" <?php echo wp_kses_post( $item['data_attr'] ); ?> href="<?php echo esc_url( $item['link'] ); ?>"><?php echo wp_kses_post( $item['icon'] ); ?><?php echo wp_kses_post( $item['label'] ); ?></a> <?php @@ -87,8 +89,7 @@ <?php } wp_reset_postdata(); -} -else { +} else { ?> <tr><td colspan="5"><?php esc_html_e( 'No items found', 'directorist' ); ?></td></tr> <?php diff --git a/templates/dashboard/main-contents.php b/templates/dashboard/main-contents.php index fdb01e6cf5..c9d44bc5eb 100644 --- a/templates/dashboard/main-contents.php +++ b/templates/dashboard/main-contents.php @@ -5,14 +5,16 @@ * @version 7.3.1 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $counter = 1; ?> <div class="directorist-user-dashboard__tab-content directorist-tab__content"> - <?php foreach ( $dashboard->dashboard_tabs() as $key => $value ): ?> + <?php foreach ( $dashboard->dashboard_tabs() as $key => $value ) : ?> <div class="directorist-tab__pane <?php echo ( $counter == 1 ) ? 'directorist-tab__pane--active' : ''; ?>" id="<?php echo esc_attr( $key ); ?>"> <?php @@ -22,13 +24,13 @@ ?> </div> <?php - if (!empty($value['after_content_hook'])) { - do_action($value['after_content_hook']); - } - ?> + if ( ! empty( $value['after_content_hook'] ) ) { + do_action( $value['after_content_hook'] ); + } + ?> <?php do_action( 'directorist_dashboard_contents', $key, $dashboard ); ?> - <?php $counter++; ?> + <?php ++$counter; ?> <?php endforeach; ?> diff --git a/templates/dashboard/nav-buttons.php b/templates/dashboard/nav-buttons.php index 7b6678ca49..cb1cd96b34 100644 --- a/templates/dashboard/nav-buttons.php +++ b/templates/dashboard/nav-buttons.php @@ -5,30 +5,32 @@ * @version 7.3.1 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-tab__nav__action"> - <?php if ( $dashboard->user_can_submit() ): ?> - <a href="<?php echo esc_url(ATBDP_Permalink::get_add_listing_page_link()); ?>" class="directorist-btn directorist-btn--add-listing"><?php esc_html_e( 'Submit Listing', 'directorist' ); ?></a> + <?php if ( $dashboard->user_can_submit() ) : ?> + <a href="<?php echo esc_url( ATBDP_Permalink::get_add_listing_page_link() ); ?>" class="directorist-btn directorist-btn--add-listing"><?php esc_html_e( 'Submit Listing', 'directorist' ); ?></a> <?php endif; ?> - <?php if ( $dashboard->user_type == 'general' && ! empty( $dashboard->become_author_button)): ?> + <?php if ( $dashboard->user_type == 'general' && ! empty( $dashboard->become_author_button ) ) : ?> <a href="#" class="directorist-btn directorist-become-author"><?php echo esc_html( $dashboard->become_author_button_text ); ?></a> <p id="directorist-become-author-success"></p> <div class="directorist-become-author-modal"> - <div class="directorist-become-author-modal__content"> - <h3><?php esc_html_e( 'Are you sure you want to become an author?', 'directorist' ); ?> <br><?php esc_html_e( '(It is subject to approval by the admin)', 'directorist' ); ?> <span class="directorist-become-author__loader"></span></h3> - <p> - <a href="#" class="directorist-become-author-modal__cancel">Cancel</a> - <a href="#" class="directorist-become-author-modal__approve" data-nonce="<?php echo esc_attr( wp_create_nonce('atbdp_become_author' ) ); ?>" data-userId='<?php echo esc_attr( get_current_user_id() ); ?>'>Yes</a> - </p> - </div> - </div> + <div class="directorist-become-author-modal__content"> + <h3><?php esc_html_e( 'Are you sure you want to become an author?', 'directorist' ); ?> <br><?php esc_html_e( '(It is subject to approval by the admin)', 'directorist' ); ?> <span class="directorist-become-author__loader"></span></h3> + <p> + <a href="#" class="directorist-become-author-modal__cancel">Cancel</a> + <a href="#" class="directorist-become-author-modal__approve" data-nonce="<?php echo esc_attr( wp_create_nonce( 'atbdp_become_author' ) ); ?>" data-userId='<?php echo esc_attr( get_current_user_id() ); ?>'>Yes</a> + </p> + </div> + </div> <?php endif; ?> - <a href="<?php echo esc_url(wp_logout_url(home_url())); ?>" class="directorist-btn directorist-btn-secondary directorist-btn--logout"><?php esc_html_e( 'Sign Out', 'directorist' ); ?></a> + <a href="<?php echo esc_url( wp_logout_url( home_url() ) ); ?>" class="directorist-btn directorist-btn-secondary directorist-btn--logout"><?php esc_html_e( 'Sign Out', 'directorist' ); ?></a> </div> \ No newline at end of file diff --git a/templates/dashboard/navigation.php b/templates/dashboard/navigation.php index 62a26e0fd2..4b038888a9 100644 --- a/templates/dashboard/navigation.php +++ b/templates/dashboard/navigation.php @@ -5,7 +5,9 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $counter = 1; ?> @@ -16,7 +18,7 @@ <ul class="directorist-tab__nav__items"> - <?php foreach ( $dashboard->dashboard_tabs() as $key => $value ): ?> + <?php foreach ( $dashboard->dashboard_tabs() as $key => $value ) : ?> <li class="directorist-tab__nav__item"> <a href="#" class="directorist-booking-nav-link directorist-tab__nav__link <?php echo ( $counter == 1 ) ? 'directorist-tab__nav__active' : ''; ?>" target="<?php echo esc_attr( $key ); ?>"> @@ -30,7 +32,7 @@ </li> <?php do_action( 'directorist_dashboard_navigation', $key, $dashboard ); ?> - <?php $counter++; ?> + <?php ++$counter; ?> <?php endforeach; ?> diff --git a/templates/dashboard/notice.php b/templates/dashboard/notice.php index bd80d69a93..4e783d27e6 100644 --- a/templates/dashboard/notice.php +++ b/templates/dashboard/notice.php @@ -5,18 +5,20 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<?php if( $renew_token_expired ): ?> +<?php if ( $renew_token_expired ) : ?> <div class="directorist-alert directorist-alert-danger directorist-alert-dismissable"><?php directorist_icon( 'las la-info-circle' ); ?><?php esc_html_e( 'Link appears to be invalid.', 'directorist' ); ?></div> <?php endif; ?> -<?php if( $renew_succeed ): ?> +<?php if ( $renew_succeed ) : ?> <div class="directorist-alert directorist-alert-info directorist-alert-dismissable"><?php directorist_icon( 'las la-info-circle' ); ?><?php esc_html_e( 'Renewed successfully.', 'directorist' ); ?></div> <?php endif; ?> -<?php if( $dashboard->confirmation_text() ): ?> +<?php if ( $dashboard->confirmation_text() ) : ?> <div class="directorist-alert directorist-alert-info directorist-alert-dismissible"> <?php echo esc_html( $dashboard->confirmation_text() ); ?> <button type="button" class="directorist-alert__close"><span aria-hidden="true">×</span></button> diff --git a/templates/dashboard/profile-pic.php b/templates/dashboard/profile-pic.php index 53fd04f44d..4b68e9059e 100644 --- a/templates/dashboard/profile-pic.php +++ b/templates/dashboard/profile-pic.php @@ -5,7 +5,9 @@ * @version 7.3.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $uid = $dashboard->id; $u_pro_pic_id = get_user_meta( $uid, 'pro_pic', true ); @@ -28,8 +30,8 @@ <div class="ezmu__old-files"> - <?php if ($u_pro_pic) { ?> - <span class="ezmu__old-files-meta" data-attachment-id="<?php echo esc_attr($u_pro_pic_id); ?>" data-url="<?php echo esc_url($u_pro_pic[0]); ?>" data-type="image"></span> + <?php if ( $u_pro_pic ) { ?> + <span class="ezmu__old-files-meta" data-attachment-id="<?php echo esc_attr( $u_pro_pic_id ); ?>" data-url="<?php echo esc_url( $u_pro_pic[0] ); ?>" data-type="image"></span> <?php } ?> </div> @@ -37,23 +39,23 @@ <div class="ezmu-dictionary"> - <span class="ezmu-dictionary-label-select-files"><?php esc_html_e('Select', 'directorist'); ?></span> + <span class="ezmu-dictionary-label-select-files"><?php esc_html_e( 'Select', 'directorist' ); ?></span> - <span class="ezmu-dictionary-label-add-more"><?php esc_html_e('Select', 'directorist'); ?></span> + <span class="ezmu-dictionary-label-add-more"><?php esc_html_e( 'Select', 'directorist' ); ?></span> - <span class="ezmu-dictionary-label-change"><?php esc_html_e('Change', 'directorist'); ?></span> + <span class="ezmu-dictionary-label-change"><?php esc_html_e( 'Change', 'directorist' ); ?></span> - <span class="ezmu-dictionary-alert-max-total-file-size"><?php esc_html_e('Max limit for total file size is __DT__', 'directorist'); ?></span> + <span class="ezmu-dictionary-alert-max-total-file-size"><?php esc_html_e( 'Max limit for total file size is __DT__', 'directorist' ); ?></span> - <span class="ezmu-dictionary-alert-min-file-items"><?php esc_html_e('Min __DT__ file is required', 'directorist'); ?></span> + <span class="ezmu-dictionary-alert-min-file-items"><?php esc_html_e( 'Min __DT__ file is required', 'directorist' ); ?></span> - <span class="ezmu-dictionary-alert-max-file-items"><?php esc_html_e('Max limit for total file is __DT__', 'directorist'); ?></span> + <span class="ezmu-dictionary-alert-max-file-items"><?php esc_html_e( 'Max limit for total file is __DT__', 'directorist' ); ?></span> - <span class="ezmu-dictionary-info-max-total-file-size"><?php esc_html_e('Maximum allowed file size is __DT__', 'directorist'); ?></span> + <span class="ezmu-dictionary-info-max-total-file-size"><?php esc_html_e( 'Maximum allowed file size is __DT__', 'directorist' ); ?></span> <span class="ezmu-dictionary-info-type" data-show='0'></span> - <span class="ezmu-dictionary-info-min-file-items"><?php esc_html_e('Minimum __DT__ file is required', 'directorist'); ?></span> + <span class="ezmu-dictionary-info-min-file-items"><?php esc_html_e( 'Minimum __DT__ file is required', 'directorist' ); ?></span> </div> diff --git a/templates/dashboard/restrict-access.php b/templates/dashboard/restrict-access.php index abeee06976..b1f636f748 100644 --- a/templates/dashboard/restrict-access.php +++ b/templates/dashboard/restrict-access.php @@ -5,12 +5,14 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-user-dashboard-access-notice"> <div class="directorist-alert directorist-alert-warning"> <?php directorist_icon( 'las la-info-circle' ); ?> - <?php echo wp_kses_post( sprintf(__("You need to be logged in to view the content of this page. You can login <a href='%s'>Here</a>. Don't have an account? <a href='%s'>Sign Up</a>", 'directorist'), $login_link, $registration_link ) ); ?> + <?php echo wp_kses_post( sprintf( __( "You need to be logged in to view the content of this page. You can login <a href='%1\$s'>Here</a>. Don't have an account? <a href='%2\$s'>Sign Up</a>", 'directorist' ), $login_link, $registration_link ) ); ?> </div> </div> \ No newline at end of file diff --git a/templates/dashboard/tab-announcement.php b/templates/dashboard/tab-announcement.php index 122ddeb9d4..6cee3b02e5 100644 --- a/templates/dashboard/tab-announcement.php +++ b/templates/dashboard/tab-announcement.php @@ -5,23 +5,25 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $announcements = $dashboard->get_announcements(); ?> <div class="directorist-announcement-wrapper"> - <?php if ( !empty( $announcements ) ) : ?> + <?php if ( ! empty( $announcements ) ) : ?> - <?php foreach ( $announcements as $announcement_id => $announcement ): ?> + <?php foreach ( $announcements as $announcement_id => $announcement ) : ?> <div class="directorist-announcement" data-post-id="<?php echo esc_attr( $announcement_id ); ?>"> <div class="directorist-announcement__date"> - <span class="directorist-announcement__date__part-one"><?php echo get_the_date( 'd', $announcement_id ) ?></span> - <span class="directorist-announcement__date__part-two"><?php echo get_the_date( 'M', $announcement_id ) ?></span> - <span class="directorist-announcement__date__part-three"><?php echo get_the_date( 'Y', $announcement_id ) ?></span> + <span class="directorist-announcement__date__part-one"><?php echo get_the_date( 'd', $announcement_id ); ?></span> + <span class="directorist-announcement__date__part-two"><?php echo get_the_date( 'M', $announcement_id ); ?></span> + <span class="directorist-announcement__date__part-three"><?php echo get_the_date( 'Y', $announcement_id ); ?></span> </div> <div class="directorist-announcement__content"> @@ -37,9 +39,9 @@ <?php endforeach; ?> - <?php else: ?> + <?php else : ?> - <p class="directorist_not-found"><?php esc_html_e( 'No announcements found', 'directorist' ) ?></p> + <p class="directorist_not-found"><?php esc_html_e( 'No announcements found', 'directorist' ); ?></p> <?php endif; ?> diff --git a/templates/dashboard/tab-fav-listings.php b/templates/dashboard/tab-fav-listings.php index 19df0c01e2..e9dca98229 100644 --- a/templates/dashboard/tab-fav-listings.php +++ b/templates/dashboard/tab-fav-listings.php @@ -5,33 +5,35 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-favourite-items-wrap"> <div class="directorist-favourirte-items"> - <?php if ( $dashboard->fav_listing_items() ): ?> + <?php if ( $dashboard->fav_listing_items() ) : ?> <div class="directorist-dashboard-items-list"> - <?php foreach ( $dashboard->fav_listing_items() as $item ): ?> + <?php foreach ( $dashboard->fav_listing_items() as $item ) : ?> <div class="directorist-dashboard-items-list__single directorist_favourite_<?php echo esc_attr( $item['obj']->ID ); ?>"> <div class="directorist-dashboard-items-list__single__info"> <div class="directorist-listing-img"> - <a href="<?php echo esc_url( $item['permalink'] );?>"> - <img src="<?php echo esc_url( $item['img_src'] );?>" alt="<?php echo esc_attr( $item['title'] );?>"> + <a href="<?php echo esc_url( $item['permalink'] ); ?>"> + <img src="<?php echo esc_url( $item['img_src'] ); ?>" alt="<?php echo esc_attr( $item['title'] ); ?>"> </a> </div> <div class="directorist-listing-content"> - <h4 class="directorist-listing-title"><a href="<?php echo esc_url( $item['permalink'] );?>"><?php echo esc_html( $item['title'] );?></a></h4> + <h4 class="directorist-listing-title"><a href="<?php echo esc_url( $item['permalink'] ); ?>"><?php echo esc_html( $item['title'] ); ?></a></h4> - <a class="directorist-listing-category" href="<?php echo esc_url( $item['category_link'] );?>"><?php echo esc_html( $item['category_name'] );?></a> + <a class="directorist-listing-category" href="<?php echo esc_url( $item['category_link'] ); ?>"><?php echo esc_html( $item['category_name'] ); ?></a> </div> @@ -49,7 +51,7 @@ <?php endforeach; ?> </div> - <?php else: ?> + <?php else : ?> <div class="directorist-notfound"><?php esc_html_e( 'Nothing found!', 'directorist' ); ?></div> diff --git a/templates/dashboard/tab-my-listings.php b/templates/dashboard/tab-my-listings.php index fb6798d6ce..61cb4202fb 100644 --- a/templates/dashboard/tab-my-listings.php +++ b/templates/dashboard/tab-my-listings.php @@ -5,9 +5,11 @@ * @version 7.4.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-dashboard-mylistings" id="directorist-dashboard-mylistings-js" data-paged="1" data-search=""> @@ -68,7 +70,7 @@ <?php do_action( 'directorist_dashboard_listing_th_2', $dashboard ); ?> - <?php if ( directorist_is_multi_directory_enabled() ): ?> + <?php if ( directorist_is_multi_directory_enabled() ) : ?> <th class="directorist-table-listing-type"><?php esc_html_e( 'Type', 'directorist' ); ?></th> <?php endif; ?> diff --git a/templates/dashboard/tab-preferences.php b/templates/dashboard/tab-preferences.php index 4aaa3c4476..6ec02b8df1 100644 --- a/templates/dashboard/tab-preferences.php +++ b/templates/dashboard/tab-preferences.php @@ -5,12 +5,14 @@ * @version 7.4.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; -$hide_contact_form = $dashboard->user_info( 'hide_contact_form' ) ? $dashboard->user_info( 'hide_contact_form' ) : 'no'; -$display_author_email = $dashboard->user_info( 'display_author_email' ) ? $dashboard->user_info( 'display_author_email' ) : 'public'; -$contact_owner_recipient = $dashboard->user_info( 'contact_owner_recipient' ) ? $dashboard->user_info( 'contact_owner_recipient' ) : 'author'; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} +$hide_contact_form = $dashboard->user_info( 'hide_contact_form' ) ? $dashboard->user_info( 'hide_contact_form' ) : 'no'; +$display_author_email = $dashboard->user_info( 'display_author_email' ) ? $dashboard->user_info( 'display_author_email' ) : 'public'; +$contact_owner_recipient = $dashboard->user_info( 'contact_owner_recipient' ) ? $dashboard->user_info( 'contact_owner_recipient' ) : 'author'; ?> <form action="#" id="user_preferences" method="post"> @@ -37,15 +39,15 @@ <div class="directorist-flex directorist-flex-wrap directorist-radio-wrapper"> <div class="directorist-radio directorist-radio-circle"> <input type="radio" id="public" name="directorist_display_author_email" value="public" <?php checked( $display_author_email, 'public' ); ?>> - <label class="directorist-radio__label" for="public"><?php esc_html_e('Display to Everyone', 'directorist') ?></label> + <label class="directorist-radio__label" for="public"><?php esc_html_e( 'Display to Everyone', 'directorist' ); ?></label> </div> <div class="directorist-radio directorist-radio-circle"> <input type="radio" id="logged_in" name="directorist_display_author_email" value="logged_in" <?php checked( $display_author_email, 'logged_in' ); ?>> - <label class="directorist-radio__label" for="logged_in"><?php esc_html_e('Display to Logged in Users Only', 'directorist') ?></label> + <label class="directorist-radio__label" for="logged_in"><?php esc_html_e( 'Display to Logged in Users Only', 'directorist' ); ?></label> </div> <div class="directorist-radio directorist-radio-circle"> <input type="radio" id="none_to_display" name="directorist_display_author_email" value="none_to_display" <?php checked( $display_author_email, 'none_to_display' ); ?>> - <label class="directorist-radio__label" for="none_to_display"><?php esc_html_e('Don’t Display', 'directorist') ?></label> + <label class="directorist-radio__label" for="none_to_display"><?php esc_html_e( 'Don’t Display', 'directorist' ); ?></label> </div> </div> </div> @@ -58,11 +60,11 @@ <div class="directorist-flex directorist-flex-wrap directorist-radio-wrapper"> <div class="directorist-radio directorist-radio-circle"> <input type="radio" id="author" name="directorist_contact_owner_recipient" value="author" <?php checked( $contact_owner_recipient, 'author' ); ?>> - <label class="directorist-radio__label" for="author"><?php esc_html_e( 'Author Email', 'directorist' ) ?></label> + <label class="directorist-radio__label" for="author"><?php esc_html_e( 'Author Email', 'directorist' ); ?></label> </div> <div class="directorist-radio directorist-radio-circle"> <input type="radio" id="listing_email" name="directorist_contact_owner_recipient" value="listing_email" <?php checked( $contact_owner_recipient, 'listing_email' ); ?>> - <label class="directorist-radio__label" for="listing_email"><?php esc_html_e( "Listing's Email", 'directorist' ) ?></label> + <label class="directorist-radio__label" for="listing_email"><?php esc_html_e( "Listing's Email", 'directorist' ); ?></label> </div> </div> </div> diff --git a/templates/dashboard/tab-profile.php b/templates/dashboard/tab-profile.php index 6c3793f301..3e94b2f7b6 100644 --- a/templates/dashboard/tab-profile.php +++ b/templates/dashboard/tab-profile.php @@ -5,22 +5,24 @@ * @version 7.4.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <form action="#" id="user_profile_form" method="post"> <div class="<?php Helper::directorist_row(); ?>"> - <div class="<?php Helper::directorist_column('lg-3'); ?>"> + <div class="<?php Helper::directorist_column( 'lg-3' ); ?>"> <?php $dashboard->profile_pic_template(); ?> </div> - <div class="<?php Helper::directorist_column('lg-9'); ?>"> + <div class="<?php Helper::directorist_column( 'lg-9' ); ?>"> <div class="directorist-user-profile-edit"> @@ -50,7 +52,7 @@ <div class="directorist-form-group"> - <label for="user_name"><?php esc_html_e('User Name', 'directorist'); ?></label> + <label for="user_name"><?php esc_html_e( 'User Name', 'directorist' ); ?></label> <input class="directorist-form-element" id="user_name" type="text" disabled="disabled" name="user[user_name]" value="<?php echo esc_attr( $dashboard->user_info( 'username' ) ); ?>"> <span class="directorist-input-extra-info"><?php esc_html_e( '(username can not be changed)', 'directorist' ); ?></span> @@ -153,7 +155,7 @@ <input id="facebook" class="directorist-form-element" type="url" name="user[facebook]" value="<?php echo esc_attr( $dashboard->user_info( 'facebook' ) ); ?>" placeholder="<?php esc_attr_e( 'Enter your facebook url', 'directorist' ); ?>"> - <span class="directorist-input-extra-info"><?php esc_html_e( 'Leave it empty to hide', 'directorist' ) ?></span> + <span class="directorist-input-extra-info"><?php esc_html_e( 'Leave it empty to hide', 'directorist' ); ?></span> </div> @@ -163,7 +165,7 @@ <input id="twitter" class="directorist-form-element" type="url" name="user[twitter]" value="<?php echo esc_attr( $dashboard->user_info( 'twitter' ) ); ?>" placeholder="<?php esc_attr_e( 'Enter your twitter url', 'directorist' ); ?>"> - <span class="directorist-input-extra-info"><?php esc_html_e( 'Leave it empty to hide', 'directorist' ) ?></span> + <span class="directorist-input-extra-info"><?php esc_html_e( 'Leave it empty to hide', 'directorist' ); ?></span> </div> @@ -173,7 +175,7 @@ <input id="linkedIn" class="directorist-form-element" type="url" name="user[linkedIn]" value="<?php echo esc_attr( $dashboard->user_info( 'linkedin' ) ); ?>" placeholder="<?php esc_attr_e( 'Enter linkedIn url', 'directorist' ); ?>"> - <span class="directorist-input-extra-info"><?php esc_html_e( 'Leave it empty to hide', 'directorist' ) ?></span> + <span class="directorist-input-extra-info"><?php esc_html_e( 'Leave it empty to hide', 'directorist' ); ?></span> </div> @@ -183,7 +185,7 @@ <input id="youtube" class="directorist-form-element" type="url" name="user[youtube]" value="<?php echo esc_attr( $dashboard->user_info( 'youtube' ) ); ?>" placeholder="<?php esc_attr_e( 'Enter youtube url', 'directorist' ); ?>"> - <span class="directorist-input-extra-info"><?php esc_html_e( 'Leave it empty to hide', 'directorist' ) ?></span> + <span class="directorist-input-extra-info"><?php esc_html_e( 'Leave it empty to hide', 'directorist' ); ?></span> </div> diff --git a/templates/global/price-range.php b/templates/global/price-range.php index 2e6426f256..7cc048e241 100644 --- a/templates/global/price-range.php +++ b/templates/global/price-range.php @@ -5,12 +5,14 @@ * @version 7.3.1 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$html = str_repeat( '<span class="directorist-price-active">'.$currency.'</span>' , $active_items ); -$html .= str_repeat( '<span>'.$currency.'</span>' , ( 4-$active_items ) ); +$html = str_repeat( '<span class="directorist-price-active">' . $currency . '</span>', $active_items ); +$html .= str_repeat( '<span>' . $currency . '</span>', ( 4 - $active_items ) ); ?> -<span class="directorist-listing-price-range directorist-tooltip" data-label="<?php echo esc_attr( $price_range_text ); ?>"><?php echo wp_kses_post( $html );?></span> \ No newline at end of file +<span class="directorist-listing-price-range directorist-tooltip" data-label="<?php echo esc_attr( $price_range_text ); ?>"><?php echo wp_kses_post( $html ); ?></span> \ No newline at end of file diff --git a/templates/global/price.php b/templates/global/price.php index 184adcf161..e4b5b08cc9 100644 --- a/templates/global/price.php +++ b/templates/global/price.php @@ -5,9 +5,11 @@ * @version 7.3.1 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <span class="directorist-listing-price"><?php echo wp_kses_post( Helper::formatted_price( $price ) ); ?></span> \ No newline at end of file diff --git a/templates/listing-form/add-listing-notype.php b/templates/listing-form/add-listing-notype.php index 9250a4c6b0..96bfe64893 100644 --- a/templates/listing-form/add-listing-notype.php +++ b/templates/listing-form/add-listing-notype.php @@ -5,9 +5,11 @@ * @version 7.3.1 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-add-listing-types directorist-w-100"> diff --git a/templates/listing-form/add-listing-type.php b/templates/listing-form/add-listing-type.php index 231dad466a..ca0abdebbd 100644 --- a/templates/listing-form/add-listing-type.php +++ b/templates/listing-form/add-listing-type.php @@ -5,27 +5,29 @@ * @version 7.5 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-add-listing-types directorist-w-100"> <div class="<?php Helper::directorist_container_fluid(); ?>"> <div class="<?php Helper::directorist_row(); ?> directorist-justify-content-center"> - <?php foreach ( $listing_form->get_listing_types() as $id => $value ): ?> + <?php foreach ( $listing_form->get_listing_types() as $id => $value ) : ?> - <div class="<?php Helper::directorist_column(['lg-3', 'md-4', 'sm-6']); ?>"> - <a href="<?php echo esc_url( add_query_arg('directory_type', $value['term']->slug ) ); ?>" class="directorist-add-listing-types__single__link"> - <?php - if( ! empty( $value['data']['icon'] ) ) { - directorist_icon( $value['data']['icon'] ); - } else { - directorist_icon( 'las la-home' ); - } + <div class="<?php Helper::directorist_column( array( 'lg-3', 'md-4', 'sm-6' ) ); ?>"> + <a href="<?php echo esc_url( add_query_arg( 'directory_type', $value['term']->slug ) ); ?>" class="directorist-add-listing-types__single__link"> + <?php + if ( ! empty( $value['data']['icon'] ) ) { + directorist_icon( $value['data']['icon'] ); + } else { + directorist_icon( 'las la-home' ); + } ?> - <span><?php echo esc_html( $value['name'] );?></span> + <span><?php echo esc_html( $value['name'] ); ?></span> </a> </div> diff --git a/templates/listing-form/add-listing.php b/templates/listing-form/add-listing.php index d62216d21c..f0e67e66d1 100644 --- a/templates/listing-form/add-listing.php +++ b/templates/listing-form/add-listing.php @@ -5,100 +5,105 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$action_url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ): ''; +$action_url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : ''; ?> <div class="directorist-add-listing-wrapper directorist-w-100"> - <div class="<?php Helper::directorist_container_fluid(); ?>"> - <?php do_action('directorist_before_add_listing_from_frontend');?> - <form action="<?php echo esc_url( $action_url ); ?>" method="post" id="directorist-add-listing-form"> - <div class="directorist-add-listing-form"> - <input type="hidden" name="add_listing_form" value="1"> - <input type="hidden" name="listing_id" value="<?php echo !empty($p_id) ? esc_attr($p_id) : ''; ?>"> - <!-- MultiStep Wizard Start --> - <div class="multistep-wizard default-add-listing"> - - <?php if( ! empty( $enable_sidebar ) ) : ?> - - <div class="multistep-wizard__nav"> - <?php - foreach ( $form_data as $key => $section ) { - $label = $section['label'] ?? ''; - $id = str_replace(' ', '-', strtolower( $label ) ); - $listing_type = isset( $section['fields']['listing_type'] ) ? $section['fields']['listing_type']['widget_name'] : ''; - $section['fields'] = array_filter( $section['fields'], function( $field ) { - return empty( $field['only_for_admin'] ); - }); - - if ( empty( $listing_type ) && ! empty( $section['fields'] ) ) { - printf( '<a href="#add-listing-content-%s" id="add-listing-nav-%s" class="multistep-wizard__nav__btn">%s %s</a>', esc_attr( $id ), esc_attr( $id ), ( isset( $section['icon'] ) ? directorist_icon( $section['icon'], false ) : directorist_icon( 'fas fa-circle', false ) ), $section['label'] ); - } - } - ?> - <a href="#add-listing-last-content" id="add-listing-last-nav" class="multistep-wizard__nav__btn multistep-wizard__nav__btn--finish add-listing-nav-999"><?php directorist_icon( 'fas fa-check' ); ?><?php esc_html_e( 'Finish', 'directorist' ); ?></a> - </div> - - <?php endif; ?> - - <div class="multistep-wizard__content"> - <div class="multistep-wizard__wrapper"> - <?php - ATBDP()->listing->add_listing->show_nonce_field(); - if ( !empty( $is_edit_mode ) || !empty( $single_directory ) ) { - $listing_form->type_hidden_field(); - } - foreach ( $form_data as $section ) { - $listing_form->section_template( $section ); - } - ?> - <div id="add-listing-last-content" class="multistep-wizard__single add-listing-content-999"> - <?php - $listing_form->submit_template(); - ?> - </div> - </div> - - <div class="multistep-wizard__progressbar"> - <span class="multistep-wizard__progressbar__width"></span> - </div> - - <div class="multistep-wizard__bottom"> - <a class="directorist-btn multistep-wizard__btn multistep-wizard__btn--prev" disabled="true" aria-label="Return to Back"></a> - <?php - directorist_icon( 'fas fa-arrow-left' ); - esc_html_e( 'Back', 'directorist' ); - ?> - </a> - - <div class="multistep-wizard__count"> - <span class="multistep-wizard__count__current"></span> / <span class="multistep-wizard__count__total"></span> - </div> - - <a type="submit" class="directorist-btn multistep-wizard__btn multistep-wizard__btn--next" aria-label="Go to Next">Save & Next<?php directorist_icon( 'fas fa-arrow-right' ); ?></a> - - <button type="submit" class="directorist-btn directorist-form-submit__btn multistep-wizard__btn multistep-wizard__btn--save-preview"><?php echo esc_html( $listing_form->submit_label() ); ?></button> - - <button type="submit" class="directorist-btn directorist-btn-primary directorist-form-submit__btn multistep-wizard__btn multistep-wizard__btn--skip-preview"><?php esc_html_e( 'Skip preview and submit listing', 'directorist' ); ?></button> - </div> - - <?php do_action( 'directorist_before_submit_listing_frontend' ); ?> - - <div class="default-add-listing-bottom"> - <button type="submit" class="directorist-btn directorist-btn-primary directorist-form-submit__btn"><?php echo esc_html( $listing_form->submit_label() ); ?></button> - </div> - - <?php do_action( 'directorist_after_submit_listing_frontend' ); ?> - - </div> - </div> - <!-- MultiStep Wizard End --> - </div> - </form> - </div> + <div class="<?php Helper::directorist_container_fluid(); ?>"> + <?php do_action( 'directorist_before_add_listing_from_frontend' ); ?> + <form action="<?php echo esc_url( $action_url ); ?>" method="post" id="directorist-add-listing-form"> + <div class="directorist-add-listing-form"> + <input type="hidden" name="add_listing_form" value="1"> + <input type="hidden" name="listing_id" value="<?php echo ! empty( $p_id ) ? esc_attr( $p_id ) : ''; ?>"> + <!-- MultiStep Wizard Start --> + <div class="multistep-wizard default-add-listing"> + + <?php if ( ! empty( $enable_sidebar ) ) : ?> + + <div class="multistep-wizard__nav"> + <?php + foreach ( $form_data as $key => $section ) { + $label = $section['label'] ?? ''; + $id = str_replace( ' ', '-', strtolower( $label ) ); + $listing_type = isset( $section['fields']['listing_type'] ) ? $section['fields']['listing_type']['widget_name'] : ''; + $section['fields'] = array_filter( + $section['fields'], + function ( $field ) { + return empty( $field['only_for_admin'] ); + } + ); + + if ( empty( $listing_type ) && ! empty( $section['fields'] ) ) { + printf( '<a href="#add-listing-content-%s" id="add-listing-nav-%s" class="multistep-wizard__nav__btn">%s %s</a>', esc_attr( $id ), esc_attr( $id ), ( isset( $section['icon'] ) ? directorist_icon( $section['icon'], false ) : directorist_icon( 'fas fa-circle', false ) ), $section['label'] ); + } + } + ?> + <a href="#add-listing-last-content" id="add-listing-last-nav" class="multistep-wizard__nav__btn multistep-wizard__nav__btn--finish add-listing-nav-999"><?php directorist_icon( 'fas fa-check' ); ?><?php esc_html_e( 'Finish', 'directorist' ); ?></a> + </div> + + <?php endif; ?> + + <div class="multistep-wizard__content"> + <div class="multistep-wizard__wrapper"> + <?php + ATBDP()->listing->add_listing->show_nonce_field(); + if ( ! empty( $is_edit_mode ) || ! empty( $single_directory ) ) { + $listing_form->type_hidden_field(); + } + foreach ( $form_data as $section ) { + $listing_form->section_template( $section ); + } + ?> + <div id="add-listing-last-content" class="multistep-wizard__single add-listing-content-999"> + <?php + $listing_form->submit_template(); + ?> + </div> + </div> + + <div class="multistep-wizard__progressbar"> + <span class="multistep-wizard__progressbar__width"></span> + </div> + + <div class="multistep-wizard__bottom"> + <a class="directorist-btn multistep-wizard__btn multistep-wizard__btn--prev" disabled="true" aria-label="Return to Back"></a> + <?php + directorist_icon( 'fas fa-arrow-left' ); + esc_html_e( 'Back', 'directorist' ); + ?> + </a> + + <div class="multistep-wizard__count"> + <span class="multistep-wizard__count__current"></span> / <span class="multistep-wizard__count__total"></span> + </div> + + <a type="submit" class="directorist-btn multistep-wizard__btn multistep-wizard__btn--next" aria-label="Go to Next">Save & Next<?php directorist_icon( 'fas fa-arrow-right' ); ?></a> + + <button type="submit" class="directorist-btn directorist-form-submit__btn multistep-wizard__btn multistep-wizard__btn--save-preview"><?php echo esc_html( $listing_form->submit_label() ); ?></button> + + <button type="submit" class="directorist-btn directorist-btn-primary directorist-form-submit__btn multistep-wizard__btn multistep-wizard__btn--skip-preview"><?php esc_html_e( 'Skip preview and submit listing', 'directorist' ); ?></button> + </div> + + <?php do_action( 'directorist_before_submit_listing_frontend' ); ?> + + <div class="default-add-listing-bottom"> + <button type="submit" class="directorist-btn directorist-btn-primary directorist-form-submit__btn"><?php echo esc_html( $listing_form->submit_label() ); ?></button> + </div> + + <?php do_action( 'directorist_after_submit_listing_frontend' ); ?> + + </div> + </div> + <!-- MultiStep Wizard End --> + </div> + </form> + </div> </div> <?php Helper::get_template( 'listing-form/quick-login' ); ?> \ No newline at end of file diff --git a/templates/listing-form/custom-fields/checkbox.php b/templates/listing-form/custom-fields/checkbox.php index 8fc1794ce0..73f182a8ad 100644 --- a/templates/listing-form/custom-fields/checkbox.php +++ b/templates/listing-form/custom-fields/checkbox.php @@ -5,21 +5,23 @@ * @version 7.5.4 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-custom-field-checkbox"> - <?php $listing_form->field_label_template( $data );?> - <?php if( !empty( $data['options'] ) ) : ?> + <?php $listing_form->field_label_template( $data ); ?> + <?php if ( ! empty( $data['options'] ) ) : ?> - <?php foreach ( $data['options'] as $option ): ?> + <?php foreach ( $data['options'] as $option ) : ?> - <?php $uniqid = $option['option_value'] . '-' . wp_rand(); ?> + <?php $uniqid = $option['option_value'] . '-' . wp_rand(); ?> <div class="directorist-checkbox directorist-mb-10"> - <input type="checkbox" id="<?php echo esc_attr( $uniqid ); ?>" name="<?php echo esc_attr( $data['field_key'] ); ?>[]" value="<?php echo esc_attr( $option['option_value'] ); ?>" <?php echo in_array( $option['option_value'], (array) $data['value'], true ) ? 'checked="checked"' : '' ; ?>> + <input type="checkbox" id="<?php echo esc_attr( $uniqid ); ?>" name="<?php echo esc_attr( $data['field_key'] ); ?>[]" value="<?php echo esc_attr( $option['option_value'] ); ?>" <?php echo in_array( $option['option_value'], (array) $data['value'], true ) ? 'checked="checked"' : ''; ?>> <label for="<?php echo esc_attr( $uniqid ); ?>" class="directorist-checkbox__label"><?php echo esc_html( $option['option_label'] ); ?></label> </div> diff --git a/templates/listing-form/custom-fields/color_picker.php b/templates/listing-form/custom-fields/color_picker.php index a19a665d97..3605853b07 100644 --- a/templates/listing-form/custom-fields/color_picker.php +++ b/templates/listing-form/custom-fields/color_picker.php @@ -5,7 +5,9 @@ * @version 7.3.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-custom-field-color"> @@ -14,6 +16,6 @@ <input type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-color-field-js directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" <?php $listing_form->required( $data ); ?>> - <?php $listing_form->field_description_template( $data );?> + <?php $listing_form->field_description_template( $data ); ?> </div> \ No newline at end of file diff --git a/templates/listing-form/custom-fields/date.php b/templates/listing-form/custom-fields/date.php index 495a584a4b..b5a35dc07a 100644 --- a/templates/listing-form/custom-fields/date.php +++ b/templates/listing-form/custom-fields/date.php @@ -5,15 +5,17 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-custom-filed-date"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="date" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" <?php $listing_form->required( $data ); ?>> - <?php $listing_form->field_description_template( $data );?> + <?php $listing_form->field_description_template( $data ); ?> </div> \ No newline at end of file diff --git a/templates/listing-form/custom-fields/file.php b/templates/listing-form/custom-fields/file.php index d8a1f96b7c..310b3d4927 100644 --- a/templates/listing-form/custom-fields/file.php +++ b/templates/listing-form/custom-fields/file.php @@ -5,7 +5,9 @@ * @version 7.3.3 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $post_id = ! empty( $data['field_key'] ) ? $data['field_key'] : rand(); $file_types = 'all_types'; @@ -20,7 +22,7 @@ } } -$file_size = ! empty( $data['file_size'] ) ? $data['file_size'] : '2mb'; +$file_size = ! empty( $data['file_size'] ) ? $data['file_size'] : '2mb'; // place js config array for plupload $plupload_init = array( 'runtimes' => 'html5,silverlight,html4', @@ -95,25 +97,25 @@ ?> <div class="directorist-form-group directorist-custom-field-file-upload"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <div class="directorist-custom-field-file-upload__wrapper"> <div class="" id="<?php echo esc_attr( $id ); ?>dropbox"> - <input type="hidden" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $post_id ); ?>" value="<?php echo !empty( $data['value'] ) ? esc_attr( $data['value'] ) : '' ; ?>" + <input type="hidden" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $post_id ); ?>" value="<?php echo ! empty( $data['value'] ) ? esc_attr( $data['value'] ) : ''; ?>" /> <input type="hidden" name="<?php echo esc_attr( $id ); ?>image_limit" id="<?php echo esc_attr( $id ); ?>image_limit" - value="<?php echo esc_attr( $image_limit ); ?>"/> + value="<?php echo esc_attr( $image_limit ); ?>"/> <input type="hidden" name="<?php echo esc_attr( $id ); ?>totImg" id="<?php echo esc_attr( $id ); ?>totImg" - value="<?php echo esc_attr( $total_files ); ?>"/> + value="<?php echo esc_attr( $total_files ); ?>"/> <?php if ( $allowed_file_types != '' ) { ?> <input type="hidden" name="<?php echo esc_attr( $id ); ?>_allowed_types" id="<?php echo esc_attr( $id ); ?>_allowed_types" - value="<?php echo esc_attr( $allowed_file_types ); ?>" - data-exts="<?php echo esc_attr( $display_file_types ); ?>"/> + value="<?php echo esc_attr( $allowed_file_types ); ?>" + data-exts="<?php echo esc_attr( $display_file_types ); ?>"/> <?php } ?> <?php if ( ! empty( $file_size ) ) { ?> <input type="hidden" name="<?php echo esc_attr( $id ); ?>_file_size" id="<?php echo esc_attr( $id ); ?>_file_size" - value="<?php echo esc_attr( $file_size ); ?>"/> + value="<?php echo esc_attr( $file_size ); ?>"/> <?php } ?> <input type="hidden" name="<?php echo esc_attr( $id ); ?>_directory" id="<?php echo esc_attr( $id ); ?>_directory" value="general"/> @@ -126,7 +128,7 @@ ?> " id="<?php echo esc_attr( $id ); ?>plupload-upload-ui"> <input id="<?php echo esc_attr( $id ); ?>plupload-browse-button" type="button" - value="<?php esc_attr_e( 'Select Files', 'directorist' ); ?>" class="directorist-btn"/> + value="<?php esc_attr_e( 'Select Files', 'directorist' ); ?>" class="directorist-btn"/> <label for="<?php echo esc_attr( $id ); ?>plupload-browse-button" class="plupload-browse-button-label"><?php directorist_icon( 'far fa-image' ); ?></label> <span class="plupload-browse-img-size">1600×1200 or larger</span> </div> @@ -137,7 +139,7 @@ echo 'plupload-thumbs-multiple'; } ?> - clearfix" id="<?php echo esc_attr( $id ); ?>plupload-thumbs"></div> + clearfix" id="<?php echo esc_attr( $id ); ?>plupload-thumbs"></div> <span id="<?php echo esc_attr( $id ); ?>upload-error" style="display:none"></span> <span style="display: none" id="atbdp-image-meta-input" class="lity-hide lity-show"></span> </div> diff --git a/templates/listing-form/custom-fields/number.php b/templates/listing-form/custom-fields/number.php index 274402a8e1..955125f2f7 100644 --- a/templates/listing-form/custom-fields/number.php +++ b/templates/listing-form/custom-fields/number.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $data_min = $data['min_value'] ?? ''; $data_max = $data['max_value'] ?? ''; $data_step = absint( $data['step'] ?? 1 ); @@ -13,7 +15,7 @@ <div class="directorist-form-group directorist-custom-field-number"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <div class="directorist-form-group__with-prefix"> diff --git a/templates/listing-form/custom-fields/radio.php b/templates/listing-form/custom-fields/radio.php index 65c158e728..9def090fee 100644 --- a/templates/listing-form/custom-fields/radio.php +++ b/templates/listing-form/custom-fields/radio.php @@ -5,18 +5,20 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-custom-field-radio"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> - <?php if( !empty( $data['options'] ) ) : ?> + <?php if ( ! empty( $data['options'] ) ) : ?> - <?php foreach ( $data['options'] as $option ): ?> + <?php foreach ( $data['options'] as $option ) : ?> - <?php $uniqid = $option['option_value'] . '-' .wp_rand(); ?> + <?php $uniqid = $option['option_value'] . '-' . wp_rand(); ?> <div class="directorist-radio directorist-radio-circle directorist-mb-10"> <input type="radio" id="<?php echo esc_attr( $uniqid ); ?>" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $option['option_value'] ); ?>" <?php checked( $option['option_value'], $data['value'] ); ?>> diff --git a/templates/listing-form/custom-fields/select.php b/templates/listing-form/custom-fields/select.php index 2c7ca8007b..15bcd46bba 100644 --- a/templates/listing-form/custom-fields/select.php +++ b/templates/listing-form/custom-fields/select.php @@ -5,20 +5,22 @@ * @version 7.3.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-custom-field-select"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> - <?php if( !empty( $data['options'] ) ) : ?> + <?php if ( ! empty( $data['options'] ) ) : ?> <select name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" <?php $listing_form->required( $data ); ?>> - <?php foreach( $data['options'] as $key => $value ): ?> + <?php foreach ( $data['options'] as $key => $value ) : ?> - <option value="<?php echo esc_attr( $value['option_value'] )?>" <?php selected( $value['option_value'], $data['value'] ); ?>><?php echo esc_attr( $value['option_label'] )?></option> + <option value="<?php echo esc_attr( $value['option_value'] ); ?>" <?php selected( $value['option_value'], $data['value'] ); ?>><?php echo esc_attr( $value['option_label'] ); ?></option> <?php endforeach ?> diff --git a/templates/listing-form/custom-fields/text.php b/templates/listing-form/custom-fields/text.php index 58dac5c14d..3fedd7ef55 100644 --- a/templates/listing-form/custom-fields/text.php +++ b/templates/listing-form/custom-fields/text.php @@ -5,7 +5,9 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-custom-field-text"> diff --git a/templates/listing-form/custom-fields/textarea.php b/templates/listing-form/custom-fields/textarea.php index 24872c64ec..af4152d702 100644 --- a/templates/listing-form/custom-fields/textarea.php +++ b/templates/listing-form/custom-fields/textarea.php @@ -5,17 +5,19 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $maxlength = $data['max'] ?? ''; ?> <div class="directorist-form-group directorist-custom-field-textarea"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <textarea name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" rows="<?php echo (int) $data['rows']; ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" maxlength="<?php echo esc_attr( $maxlength ); ?>" <?php $listing_form->required( $data ); ?>><?php echo esc_textarea( $data['value'] ); ?></textarea> - <?php $listing_form->field_description_template( $data );?> + <?php $listing_form->field_description_template( $data ); ?> </div> \ No newline at end of file diff --git a/templates/listing-form/custom-fields/time.php b/templates/listing-form/custom-fields/time.php index 8f80c367fa..f3d55028ee 100644 --- a/templates/listing-form/custom-fields/time.php +++ b/templates/listing-form/custom-fields/time.php @@ -5,15 +5,17 @@ * @version 7.0.5.3 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-custom-filed-time"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="time" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" <?php $listing_form->required( $data ); ?>> - <?php $listing_form->field_description_template( $data );?> + <?php $listing_form->field_description_template( $data ); ?> </div> \ No newline at end of file diff --git a/templates/listing-form/custom-fields/url.php b/templates/listing-form/custom-fields/url.php index 47ec4ba125..a2c3ade61d 100644 --- a/templates/listing-form/custom-fields/url.php +++ b/templates/listing-form/custom-fields/url.php @@ -5,15 +5,17 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-custom-filed-url"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="url" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> - <?php $listing_form->field_description_template( $data );?> + <?php $listing_form->field_description_template( $data ); ?> </div> \ No newline at end of file diff --git a/templates/listing-form/field-description.php b/templates/listing-form/field-description.php index 7eb195912c..1ff7fc7628 100644 --- a/templates/listing-form/field-description.php +++ b/templates/listing-form/field-description.php @@ -5,7 +5,9 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} if ( empty( $data['description'] ) ) { return; diff --git a/templates/listing-form/field-label.php b/templates/listing-form/field-label.php index c58a8ff993..5671a7f3d1 100644 --- a/templates/listing-form/field-label.php +++ b/templates/listing-form/field-label.php @@ -5,13 +5,15 @@ * @version 7.0.5.3 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} if ( empty( $data['label'] ) ) { return; } ?> -<label class="directorist-form-label" for="<?php echo esc_html( $data['field_key']); ?>"> - <?php echo esc_html( $data['label'] ); ?>:<?php echo !empty( $data['required'] ) ? '<span class="directorist-form-required"> *</span>' : ''; ?> +<label class="directorist-form-label" for="<?php echo esc_html( $data['field_key'] ); ?>"> + <?php echo esc_html( $data['label'] ); ?>:<?php echo ! empty( $data['required'] ) ? '<span class="directorist-form-required"> *</span>' : ''; ?> </label> \ No newline at end of file diff --git a/templates/listing-form/fields/address.php b/templates/listing-form/fields/address.php index 2b21c88b8f..ef8018399f 100644 --- a/templates/listing-form/fields/address.php +++ b/templates/listing-form/fields/address.php @@ -5,12 +5,14 @@ * @version 7.0.5.6 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-address-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="text" autocomplete="off" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element directorist-location-js" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> diff --git a/templates/listing-form/fields/category.php b/templates/listing-form/fields/category.php index cbf7452425..914d541dfd 100644 --- a/templates/listing-form/fields/category.php +++ b/templates/listing-form/fields/category.php @@ -13,13 +13,19 @@ $current_terms = $listing_form->add_listing_terms( ATBDP_CATEGORY ); -$current_ids = array_map( function( $term ) { - return $term->term_id; -}, $current_terms ); - -$current_labels = array_map( function( $term ) { - return $term->name; -}, $current_terms ); +$current_ids = array_map( + function ( $term ) { + return $term->term_id; + }, + $current_terms +); + +$current_labels = array_map( + function ( $term ) { + return $term->name; + }, + $current_terms +); $current_ids_as_string = implode( ',', $current_ids ); $current_labels_as_string = implode( ',', $current_labels ); @@ -28,12 +34,12 @@ <div class="directorist-form-group directorist-form-categories-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> - <select name="admin_category_select[]" id="at_biz_dir-categories" class="directorist-form-element" data-selected-id="<?php echo esc_attr( $current_ids_as_string ) ?>" data-selected-label="<?php echo esc_attr( $current_labels_as_string ) ?>" data-placeholder="<?php echo esc_attr( $placeholder ); ?>" data-max="<?php echo esc_attr( $data_max ); ?>" data-allow_new="<?php echo esc_attr( $data_new ); ?>" <?php echo esc_attr( $multiple ); ?> <?php $listing_form->required( $data ); ?>> + <select name="admin_category_select[]" id="at_biz_dir-categories" class="directorist-form-element" data-selected-id="<?php echo esc_attr( $current_ids_as_string ); ?>" data-selected-label="<?php echo esc_attr( $current_labels_as_string ); ?>" data-placeholder="<?php echo esc_attr( $placeholder ); ?>" data-max="<?php echo esc_attr( $data_max ); ?>" data-allow_new="<?php echo esc_attr( $data_new ); ?>" <?php echo esc_attr( $multiple ); ?> <?php $listing_form->required( $data ); ?>> <?php - if ($data['type'] !== 'multiple') { + if ( $data['type'] !== 'multiple' ) { echo '<option value="">' . esc_attr( $placeholder ) . '</option>'; } diff --git a/templates/listing-form/fields/description.php b/templates/listing-form/fields/description.php index 0ba14a70f7..90e0ef1912 100644 --- a/templates/listing-form/fields/description.php +++ b/templates/listing-form/fields/description.php @@ -5,7 +5,9 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $maxlength = $data['max'] ?? ''; ?> @@ -19,8 +21,7 @@ ?> <textarea name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" rows="8" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" maxlength="<?php echo esc_attr( $maxlength ); ?>" <?php $listing_form->required( $data ); ?>><?php echo esc_html( $data['value'] ); ?></textarea> <?php - } - else { + } else { wp_editor( wp_kses_post( $data['value'] ), $data['field_key'], diff --git a/templates/listing-form/fields/email.php b/templates/listing-form/fields/email.php index 30b7869c53..0b77634af3 100644 --- a/templates/listing-form/fields/email.php +++ b/templates/listing-form/fields/email.php @@ -5,12 +5,14 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-email-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="email" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> diff --git a/templates/listing-form/fields/excerpt.php b/templates/listing-form/fields/excerpt.php index 21b9fd40ee..04c42a8c01 100644 --- a/templates/listing-form/fields/excerpt.php +++ b/templates/listing-form/fields/excerpt.php @@ -5,12 +5,14 @@ * @version 7.0.5.6 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-excerpt-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <textarea name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" cols="30" rows="5" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>><?php echo esc_textarea( $data['value'] ); ?></textarea> diff --git a/templates/listing-form/fields/fax.php b/templates/listing-form/fields/fax.php index 8c7294b329..3013faeb75 100644 --- a/templates/listing-form/fields/fax.php +++ b/templates/listing-form/fields/fax.php @@ -5,12 +5,14 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-fax-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="tel" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> diff --git a/templates/listing-form/fields/hide_contact_owner.php b/templates/listing-form/fields/hide_contact_owner.php index d32284203a..87685a7105 100644 --- a/templates/listing-form/fields/hide_contact_owner.php +++ b/templates/listing-form/fields/hide_contact_owner.php @@ -5,12 +5,14 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-checkbox directorist-form-hide-owner-field"> - <input type="checkbox" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" <?php checked($data['value'], 'on'); ?> > + <input type="checkbox" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" <?php checked( $data['value'], 'on' ); ?> > <label class="directorist-checkbox__label" for="<?php echo esc_attr( $data['field_key'] ); ?>"><?php echo esc_html( $data['label'] ); ?></label> diff --git a/templates/listing-form/fields/image_upload.php b/templates/listing-form/fields/image_upload.php index ee5974bd96..c1a4cd0239 100644 --- a/templates/listing-form/fields/image_upload.php +++ b/templates/listing-form/fields/image_upload.php @@ -5,30 +5,32 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $listing_img = atbdp_get_listing_attachment_ids( $listing_form->get_add_listing_id() ); $maximum = ! empty( $data['max'] ) ? $data['max'] : $data['max_image_limit']; $unlimited = ! empty( $data['unlimited'] ) ? $data['unlimited'] : ''; -$limit = $unlimited ? '0' : $maximum; +$limit = $unlimited ? '0' : $maximum; $max_file_size = (float) $data['max_per_image_limit']; $max_total_file_size = (float) $data['max_total_image_limit']; $max_file_size_kb = $max_file_size * 1024; $max_total_file_size_kb = $max_total_file_size * 1024; $required = (bool) $data['required']; -$select_files_label = ! empty( $data['select_files_label'] ) ? $data['select_files_label'] : __( 'Select Files', 'directorist' ); +$select_files_label = ! empty( $data['select_files_label'] ) ? $data['select_files_label'] : __( 'Select Files', 'directorist' ); $accepted_mime_types = directorist_get_mime_types( 'image', 'extension' ); -$accepted_mime_types_upper = array_map( 'strtoupper', $accepted_mime_types ) ; +$accepted_mime_types_upper = array_map( 'strtoupper', $accepted_mime_types ); $accepted_mime_types = array_merge( $accepted_mime_types, $accepted_mime_types_upper ); -$img_upload_data = [ +$img_upload_data = array( 'type' => join( ', ', $accepted_mime_types ), 'max_num_of_img' => $limit, 'max_total_img_size' => $max_total_file_size_kb, 'is_required' => $required, 'max_size_per_img' => $max_file_size_kb, -]; +); $img_upload_data = json_encode( $img_upload_data ); ?> @@ -68,7 +70,7 @@ <span class="ezmu-dictionary-info-type"></span> <span class="ezmu-dictionary-info-min-file-items"><?php esc_html_e( 'Minimum __DT__ file is required', 'directorist' ); ?></span> <span class="ezmu-dictionary-info-max-file-items"> - <?php echo !empty($unlimited) ? esc_html__( 'Unlimited images with this plan!', 'directorist' ) : ( ( $limit > 1 ) ? esc_html__('Maximum __DT__ files are allowed', 'directorist') : esc_html__( 'Maximum __DT__ file is allowed', 'directorist' ) ); ?> + <?php echo ! empty( $unlimited ) ? esc_html__( 'Unlimited images with this plan!', 'directorist' ) : ( ( $limit > 1 ) ? esc_html__( 'Maximum __DT__ files are allowed', 'directorist' ) : esc_html__( 'Maximum __DT__ file is allowed', 'directorist' ) ); ?> </span> </div> </div> diff --git a/templates/listing-form/fields/listing-type.php b/templates/listing-form/fields/listing-type.php index 68864f0a1e..6b272b71c0 100644 --- a/templates/listing-form/fields/listing-type.php +++ b/templates/listing-form/fields/listing-type.php @@ -5,16 +5,18 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -if( is_admin() || $data['value'] ) { +if ( is_admin() || $data['value'] ) { return; } ?> <div class="directorist-form-group directorist-form-listing-type"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <div class="directorist-form-listing-type__single directorist-radio directorist-radio-circle"> diff --git a/templates/listing-form/fields/location.php b/templates/listing-form/fields/location.php index d96730ec90..0c941cae2f 100644 --- a/templates/listing-form/fields/location.php +++ b/templates/listing-form/fields/location.php @@ -13,13 +13,19 @@ $current_terms = $listing_form->add_listing_terms( ATBDP_LOCATION ); -$current_ids = array_map( function( $term ) { - return $term->term_id; -}, $current_terms ); - -$current_labels = array_map( function( $term ) { - return $term->name; -}, $current_terms ); +$current_ids = array_map( + function ( $term ) { + return $term->term_id; + }, + $current_terms +); + +$current_labels = array_map( + function ( $term ) { + return $term->name; + }, + $current_terms +); $current_ids_as_string = implode( ',', $current_ids ); $current_labels_as_string = implode( ',', $current_labels ); @@ -29,10 +35,10 @@ <?php $listing_form->field_label_template( $data ); ?> - <select name="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" id="at_biz_dir-location" data-selected-id="<?php echo esc_attr( $current_ids_as_string ) ?>" data-selected-label="<?php echo esc_attr( $current_labels_as_string ) ?>" data-placeholder="<?php echo esc_attr( $placeholder ); ?>" data-max="<?php echo esc_attr( $data_max ); ?>" data-allow_new="<?php echo esc_attr( $data_new ); ?>" <?php echo esc_attr( $multiple ); ?> <?php $listing_form->required( $data ); ?>> + <select name="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" id="at_biz_dir-location" data-selected-id="<?php echo esc_attr( $current_ids_as_string ); ?>" data-selected-label="<?php echo esc_attr( $current_labels_as_string ); ?>" data-placeholder="<?php echo esc_attr( $placeholder ); ?>" data-max="<?php echo esc_attr( $data_max ); ?>" data-allow_new="<?php echo esc_attr( $data_new ); ?>" <?php echo esc_attr( $multiple ); ?> <?php $listing_form->required( $data ); ?>> <?php - if ($data['type'] !== 'multiple') { + if ( $data['type'] !== 'multiple' ) { echo '<option value="">' . esc_attr( $placeholder ) . '</option>'; } if ( ! $lazy_load ) { diff --git a/templates/listing-form/fields/map.php b/templates/listing-form/fields/map.php index cfd34b46a6..d2d2d7b233 100644 --- a/templates/listing-form/fields/map.php +++ b/templates/listing-form/fields/map.php @@ -5,7 +5,9 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $p_id = $listing_form->add_listing_id; $address = get_post_meta( $p_id, '_address', true ); @@ -14,9 +16,9 @@ $manual_lng = get_post_meta( $p_id, '_manual_lng', true ); $default_latitude = get_directorist_option( 'default_latitude', '40.7127753' ); $default_longitude = get_directorist_option( 'default_longitude', '-74.0059728' ); -$latitude = !empty( $manual_lat ) ? $manual_lat : $default_latitude; -$longitude = !empty( $manual_lng ) ? $manual_lng : $default_longitude; -$hide_map = !empty( get_post_meta( $p_id, '_hide_map', true ) ) ? true : false; +$latitude = ! empty( $manual_lat ) ? $manual_lat : $default_latitude; +$longitude = ! empty( $manual_lng ) ? $manual_lng : $default_longitude; +$hide_map = ! empty( get_post_meta( $p_id, '_hide_map', true ) ) ? true : false; $map_data = $listing_form->get_map_data(); Directorist\Helper::add_hidden_data_to_dom( 'map_data', $map_data ); @@ -33,9 +35,9 @@ </div> </div></div></div> - <?php if ('google' == $select_listing_map): ?> + <?php if ( 'google' == $select_listing_map ) : ?> - <small class="map_drag_info"><?php directorist_icon( 'las la-info-circle' ); ?> <?php esc_html_e('You can drag pinpoint to place the correct address manually.', 'directorist'); ?></small> + <small class="map_drag_info"><?php directorist_icon( 'las la-info-circle' ); ?> <?php esc_html_e( 'You can drag pinpoint to place the correct address manually.', 'directorist' ); ?></small> <?php endif; ?> @@ -43,7 +45,7 @@ <input type="checkbox" name="manual_coordinate" value="1" id="manual_coordinate"> - <label for="manual_coordinate" class="directorist-checkbox__label"><?php echo esc_attr( $data['lat_long'] );?></label> + <label for="manual_coordinate" class="directorist-checkbox__label"><?php echo esc_attr( $data['lat_long'] ); ?></label> </div> @@ -52,8 +54,8 @@ <div class="directorist-map-coordinates"> <div class="directorist-form-group"> - <label for="manual_lat"> <?php esc_html_e('Latitude', 'directorist'); ?></label> - <input type="text" name="manual_lat" id="manual_lat" value="<?php echo esc_attr( $latitude ); ?>" class="directorist-form-element directory_field" placeholder="<?php esc_attr_e('Enter Latitude eg. 24.89904', 'directorist'); ?>"/> + <label for="manual_lat"> <?php esc_html_e( 'Latitude', 'directorist' ); ?></label> + <input type="text" name="manual_lat" id="manual_lat" value="<?php echo esc_attr( $latitude ); ?>" class="directorist-form-element directory_field" placeholder="<?php esc_attr_e( 'Enter Latitude eg. 24.89904', 'directorist' ); ?>"/> </div> <div class="directorist-form-group"> @@ -69,7 +71,7 @@ <div class="directorist-checkbox directorist-hide-map-option"> <input type="checkbox" name="hide_map" value="1" id="hide_map"<?php checked( $hide_map ); ?>> - <label for="hide_map" class="directorist-checkbox__label"><?php esc_html_e(' Hide Map', 'directorist' ); ?> </label> + <label for="hide_map" class="directorist-checkbox__label"><?php esc_html_e( ' Hide Map', 'directorist' ); ?> </label> </div> </div> \ No newline at end of file diff --git a/templates/listing-form/fields/phone.php b/templates/listing-form/fields/phone.php index 6e65edc047..ef700241e4 100644 --- a/templates/listing-form/fields/phone.php +++ b/templates/listing-form/fields/phone.php @@ -5,12 +5,14 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-phone-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="tel" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> diff --git a/templates/listing-form/fields/phone2.php b/templates/listing-form/fields/phone2.php index aea1181af4..75227ef62f 100644 --- a/templates/listing-form/fields/phone2.php +++ b/templates/listing-form/fields/phone2.php @@ -5,12 +5,14 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-phone2-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="tel" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> diff --git a/templates/listing-form/fields/pricing.php b/templates/listing-form/fields/pricing.php index 9832b97705..8155f41600 100644 --- a/templates/listing-form/fields/pricing.php +++ b/templates/listing-form/fields/pricing.php @@ -5,14 +5,16 @@ * @version 7.4.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$listing_id = $listing_form->get_add_listing_id(); -$price = get_post_meta( $listing_id, '_price', true ); -$price_range = get_post_meta( $listing_id, '_price_range', true ); -$price_type = get_post_meta( $listing_id, '_atbd_listing_pricing', true ); -$allow_decimal = get_directorist_option( 'allow_decimal', 1 ); -$currency_symbol = atbdp_currency_symbol( directorist_get_currency() ); +$listing_id = $listing_form->get_add_listing_id(); +$price = get_post_meta( $listing_id, '_price', true ); +$price_range = get_post_meta( $listing_id, '_price_range', true ); +$price_type = get_post_meta( $listing_id, '_atbd_listing_pricing', true ); +$allow_decimal = get_directorist_option( 'allow_decimal', 1 ); +$currency_symbol = atbdp_currency_symbol( directorist_get_currency() ); ?> <div class="directorist-form-group directorist-form-pricing-field price-type-<?php echo esc_attr( $data['pricing_type'] ); ?>"> @@ -22,7 +24,7 @@ <div class="directorist-form-pricing-field__options"> <div class="directorist-checkbox directorist_pricing_options"> <input type="checkbox" id="price_selected" value="price" name="atbd_listing_pricing" <?php checked( $price_type, 'price' ); ?>> - <label for="price_selected" class="directorist-checkbox__label" data-option="price"><?php echo esc_html( $data['price_unit_field_label'] );?></label> + <label for="price_selected" class="directorist-checkbox__label" data-option="price"><?php echo esc_html( $data['price_unit_field_label'] ); ?></label> </div> <?php if ( ! empty( $price_unit_checkbox ) ) : ?> @@ -43,8 +45,8 @@ <?php if ( $data['pricing_type'] === 'both' || $data['pricing_type'] === 'price_range' ) { ?> <select class="directorist-form-element directory_field directory_pricing_field" id="price_range" name="price_range"> <option value=""><?php echo esc_html( ! empty( $data['price_range_placeholder'] ) ? $data['price_range_placeholder'] : '' ); ?></option> - <option value="skimming"<?php selected( $price_range, 'skimming' ); ?>><?php echo esc_html( sprintf( __( 'Ultra High (%s)', 'directorist' ), str_repeat( $currency_symbol, 4 ) ) );?></option> - <option value="moderate" <?php selected( $price_range, 'moderate' ); ?>><?php echo esc_html( sprintf( __( 'Expensive (%s)', 'directorist' ), str_repeat( $currency_symbol, 3 ) ) );?></option> + <option value="skimming"<?php selected( $price_range, 'skimming' ); ?>><?php echo esc_html( sprintf( __( 'Ultra High (%s)', 'directorist' ), str_repeat( $currency_symbol, 4 ) ) ); ?></option> + <option value="moderate" <?php selected( $price_range, 'moderate' ); ?>><?php echo esc_html( sprintf( __( 'Expensive (%s)', 'directorist' ), str_repeat( $currency_symbol, 3 ) ) ); ?></option> <option value="economy" <?php selected( $price_range, 'economy' ); ?>><?php echo esc_html( sprintf( __( 'Moderate (%s)', 'directorist' ), str_repeat( $currency_symbol, 2 ) ) ); ?></option> <option value="bellow_economy" <?php selected( $price_range, 'bellow_economy' ); ?>><?php echo esc_html( sprintf( __( 'Cheap (%s)', 'directorist' ), str_repeat( $currency_symbol, 1 ) ) ); ?></option> </select> diff --git a/templates/listing-form/fields/social_info.php b/templates/listing-form/fields/social_info.php index d61608adee..62fa069a1d 100644 --- a/templates/listing-form/fields/social_info.php +++ b/templates/listing-form/fields/social_info.php @@ -5,21 +5,23 @@ * @version 6.7 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-social-info-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <div id="social_info_sortable_container"> <input type="hidden" id="is_social_checked"> <?php - if ( !empty( $data['value'] ) ){ + if ( ! empty( $data['value'] ) ) { foreach ( $data['value'] as $index => $social_info ) { $listing_form->social_item_template( $index, $social_info ); } @@ -28,6 +30,6 @@ </div> - <button type="button" class="directorist-btn directorist-btn-light" id="addNewSocial"><?php directorist_icon( 'las la-plus' ); ?><?php esc_html_e('Add Social', 'directorist'); ?></button> + <button type="button" class="directorist-btn directorist-btn-light" id="addNewSocial"><?php directorist_icon( 'las la-plus' ); ?><?php esc_html_e( 'Add Social', 'directorist' ); ?></button> </div> \ No newline at end of file diff --git a/templates/listing-form/fields/tag.php b/templates/listing-form/fields/tag.php index 1bd602249e..c1453541dd 100644 --- a/templates/listing-form/fields/tag.php +++ b/templates/listing-form/fields/tag.php @@ -10,19 +10,25 @@ $data_new = $data['allow_new'] ?? ''; $multiple = $data['type'] === 'multiple' ? 'multiple' : ''; -$lazy_load = $data['lazy_load']; -$all_tags = ( ! $lazy_load ) ? get_terms( ATBDP_TAGS, array( 'hide_empty' => 0 ) ) : []; +$lazy_load = $data['lazy_load']; +$all_tags = ( ! $lazy_load ) ? get_terms( ATBDP_TAGS, array( 'hide_empty' => 0 ) ) : array(); $current_terms = $listing_form->add_listing_terms( ATBDP_TAGS ); -$current_ids = array_map( function( $term ) { - return $term->term_id; -}, $current_terms ); +$current_ids = array_map( + function ( $term ) { + return $term->term_id; + }, + $current_terms +); -$current_labels = array_map( function( $term ) { - return $term->name; -}, $current_terms ); +$current_labels = array_map( + function ( $term ) { + return $term->name; + }, + $current_terms +); $current_ids_as_string = implode( ',', $current_ids ); $current_labels_as_string = implode( ',', $current_labels ); @@ -33,18 +39,18 @@ <?php $listing_form->field_label_template( $data, 'at_biz_dir-tags' ); ?> - <select name="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" id="at_biz_dir-tags" data-selected-id="<?php echo esc_attr( $current_ids_as_string ) ?>" data-selected-label="<?php echo esc_attr( $current_labels_as_string ) ?>" data-placeholder="<?php echo esc_attr( $placeholder ); ?>" data-max="<?php echo esc_attr( $data_max ); ?>" data-allow_new="<?php echo esc_attr( $data_new ); ?>" <?php echo esc_attr( $multiple ); ?> <?php $listing_form->required( $data ); ?>> + <select name="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" id="at_biz_dir-tags" data-selected-id="<?php echo esc_attr( $current_ids_as_string ); ?>" data-selected-label="<?php echo esc_attr( $current_labels_as_string ); ?>" data-placeholder="<?php echo esc_attr( $placeholder ); ?>" data-max="<?php echo esc_attr( $data_max ); ?>" data-allow_new="<?php echo esc_attr( $data_new ); ?>" <?php echo esc_attr( $multiple ); ?> <?php $listing_form->required( $data ); ?>> <?php - if ($data['type'] !== 'multiple') { + if ( $data['type'] !== 'multiple' ) { echo '<option value="">' . esc_attr( $placeholder ) . '</option>'; } if ( ! $lazy_load ) { - foreach ($all_tags as $tag) { - $current = in_array($tag->term_id, $current_ids) ? true : false; + foreach ( $all_tags as $tag ) { + $current = in_array( $tag->term_id, $current_ids ) ? true : false; ?> - <option <?php selected( $current, true, true ); ?> value='<?php echo esc_attr($tag->name); ?>'><?php echo esc_html($tag->name) ?></option> + <option <?php selected( $current, true, true ); ?> value='<?php echo esc_attr( $tag->name ); ?>'><?php echo esc_html( $tag->name ); ?></option> <?php } } diff --git a/templates/listing-form/fields/tagline.php b/templates/listing-form/fields/tagline.php index 320de721c1..240a98b3cd 100644 --- a/templates/listing-form/fields/tagline.php +++ b/templates/listing-form/fields/tagline.php @@ -5,7 +5,9 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-tagline-field"> diff --git a/templates/listing-form/fields/terms_privacy.php b/templates/listing-form/fields/terms_privacy.php index 1cf2ff3ce3..dc79cfebe1 100644 --- a/templates/listing-form/fields/terms_privacy.php +++ b/templates/listing-form/fields/terms_privacy.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-add-listing-form__privacy"> <?php @@ -18,7 +20,7 @@ <label for="directorist_submit_privacy_policy" class="directorist-checkbox__label"><?php echo wp_kses_post( strip_tags( $data['text'], '<a><strong><em>' ) ); ?></label> - <?php if ( $data['required'] ): ?> + <?php if ( $data['required'] ) : ?> <span class="directorist-form-required"> *</span> <?php endif; ?> diff --git a/templates/listing-form/fields/title.php b/templates/listing-form/fields/title.php index 1342786e95..aceafc0a8a 100644 --- a/templates/listing-form/fields/title.php +++ b/templates/listing-form/fields/title.php @@ -5,7 +5,9 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-title-field"> diff --git a/templates/listing-form/fields/video.php b/templates/listing-form/fields/video.php index 8922a5d3fc..1dff3e040b 100644 --- a/templates/listing-form/fields/video.php +++ b/templates/listing-form/fields/video.php @@ -5,12 +5,14 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-video-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="url" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> diff --git a/templates/listing-form/fields/website.php b/templates/listing-form/fields/website.php index f22ecbae89..711de3caae 100644 --- a/templates/listing-form/fields/website.php +++ b/templates/listing-form/fields/website.php @@ -5,12 +5,14 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-website-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> diff --git a/templates/listing-form/fields/zip.php b/templates/listing-form/fields/zip.php index 5d4361f34f..be31280cf5 100644 --- a/templates/listing-form/fields/zip.php +++ b/templates/listing-form/fields/zip.php @@ -5,12 +5,14 @@ * @version 7.0.5.3 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-form-group directorist-form-zip-field"> - <?php $listing_form->field_label_template( $data );?> + <?php $listing_form->field_label_template( $data ); ?> <input type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" id="<?php echo esc_attr( $data['field_key'] ); ?>" class="directorist-form-element" value="<?php echo esc_attr( $data['value'] ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php $listing_form->required( $data ); ?>> diff --git a/templates/listing-form/quick-login.php b/templates/listing-form/quick-login.php index 34c918207b..b9f9bf0425 100644 --- a/templates/listing-form/quick-login.php +++ b/templates/listing-form/quick-login.php @@ -5,7 +5,9 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div id="directorist-quick-login" class="directorist-quick-login directorist-modal-container"> @@ -33,7 +35,7 @@ <input type="password" name="password" placeholder="Password" class="directorist-form-element"> </div> - <?php wp_nonce_field('directorist-quick-login-nonce', 'directorist-quick-login-security'); ?> + <?php wp_nonce_field( 'directorist-quick-login-nonce', 'directorist-quick-login-security' ); ?> <div class="directorist-form-feedback"></div> <div class="directorist-form-actions directorist-text-center"> diff --git a/templates/listing-form/restrict-access.php b/templates/listing-form/restrict-access.php index eb296d777e..4205b25175 100644 --- a/templates/listing-form/restrict-access.php +++ b/templates/listing-form/restrict-access.php @@ -5,7 +5,9 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-edit-listing-error"><?php esc_html_e( 'You do not have permission to edit this listing', 'directorist' ); ?></div> \ No newline at end of file diff --git a/templates/listing-form/section.php b/templates/listing-form/section.php index aff46df1c9..fcd5187fad 100644 --- a/templates/listing-form/section.php +++ b/templates/listing-form/section.php @@ -5,22 +5,24 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $label = $section_data['label'] ?? ''; -$id = str_replace(' ', '-', strtolower( $label ) ); +$id = str_replace( ' ', '-', strtolower( $label ) ); ?> <section class="directorist-form-section directorist-content-module multistep-wizard__single" id="add-listing-content-<?php echo esc_attr( $id ?? '' ); ?>"> <header class="directorist-content-module__title"> - <?php echo ! empty( $section_data['icon'] ) ? directorist_icon( $section_data['icon'] ) : ''; ?> - <h2><?php echo esc_html( $section_data['label'] );?></h2> + <?php echo ! empty( $section_data['icon'] ) ? directorist_icon( $section_data['icon'] ) : ''; ?> + <h2><?php echo esc_html( $section_data['label'] ); ?></h2> </header> <section class="directorist-content-module__contents"> - <?php - foreach ( $section_data['fields'] as $field ) { - $listing_form->field_template( $field ); - } + <?php + foreach ( $section_data['fields'] as $field ) { + $listing_form->field_template( $field ); + } ?> </section> diff --git a/templates/listing-form/social-item.php b/templates/listing-form/social-item.php index 5a5a487070..29e734d8a1 100644 --- a/templates/listing-form/social-item.php +++ b/templates/listing-form/social-item.php @@ -5,25 +5,27 @@ * @version 7.3.1 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$id = (array_key_exists('id', $args)) ? $args['id'] : $index; ?> +$id = ( array_key_exists( 'id', $args ) ) ? $args['id'] : $index; ?> <div class="directorist-form-social-fields" id="socialID-<?php echo esc_attr( $id ); ?>"> - <div class="directorist-form-social-fields__input"> - <div class="directorist-form-group"> - <select name="social[<?php echo esc_attr( $id ); ?>][id]" class="directorist-form-element placeholder-item"> - <option value=""><?php esc_html_e( 'Select Network', 'directorist' ); ?></option> - <?php foreach ( ATBDP()->helper->social_links() as $nameID => $socialName ) { ?> - <option value="<?php echo esc_attr($nameID); ?>" <?php selected($nameID, $social_info['id']); ?>><?php echo esc_html($socialName); ?></option> - <?php } ?> - </select> - </div> - <div class="directorist-form-group"> - <input type="url" name="social[<?php echo esc_attr( $id ); ?>][url]" class="directorist-form-element directory_field atbdp_social_input" value="<?php echo esc_url($social_info['url']); ?>" placeholder="<?php esc_attr_e('eg. http://example.com', 'directorist'); ?>" required> - </div> - </div> - <div class="directorist-form-social-fields__action"> - <span data-id="<?php echo esc_attr( $id ); ?>" class="directorist-form-social-fields__remove dashicons" title="<?php esc_html_e('Remove this item', 'directorist'); ?>"><?php directorist_icon( 'fas fa-trash-alt' ); ?></span> - </div> + <div class="directorist-form-social-fields__input"> + <div class="directorist-form-group"> + <select name="social[<?php echo esc_attr( $id ); ?>][id]" class="directorist-form-element placeholder-item"> + <option value=""><?php esc_html_e( 'Select Network', 'directorist' ); ?></option> + <?php foreach ( ATBDP()->helper->social_links() as $nameID => $socialName ) { ?> + <option value="<?php echo esc_attr( $nameID ); ?>" <?php selected( $nameID, $social_info['id'] ); ?>><?php echo esc_html( $socialName ); ?></option> + <?php } ?> + </select> + </div> + <div class="directorist-form-group"> + <input type="url" name="social[<?php echo esc_attr( $id ); ?>][url]" class="directorist-form-element directory_field atbdp_social_input" value="<?php echo esc_url( $social_info['url'] ); ?>" placeholder="<?php esc_attr_e( 'eg. http://example.com', 'directorist' ); ?>" required> + </div> + </div> + <div class="directorist-form-social-fields__action"> + <span data-id="<?php echo esc_attr( $id ); ?>" class="directorist-form-social-fields__remove dashicons" title="<?php esc_html_e( 'Remove this item', 'directorist' ); ?>"><?php directorist_icon( 'fas fa-trash-alt' ); ?></span> + </div> </div> diff --git a/templates/listing-form/submit.php b/templates/listing-form/submit.php index 686beb0ed0..b7d815ad88 100644 --- a/templates/listing-form/submit.php +++ b/templates/listing-form/submit.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-add-listing-form__action"> @@ -22,7 +24,7 @@ </p> </div> - <?php if ( $display_guest_listings && !is_user_logged_in() ): ?> + <?php if ( $display_guest_listings && ! is_user_logged_in() ) : ?> <div class="directorist-form-group"> <label for="guest_user_email"><?php echo esc_html( $guest_email_label ); ?>:<span class="directorist-form-required"> *</span></label> diff --git a/templates/payment/checkout.php b/templates/payment/checkout.php index 3a7f0937ff..176dd575b7 100644 --- a/templates/payment/checkout.php +++ b/templates/payment/checkout.php @@ -6,169 +6,178 @@ */ extract( $checkout ); -use \Directorist\Helper; -('after' == $c_position) ? $after = $symbol : $before = $symbol; ?> +use Directorist\Helper; +( 'after' == $c_position ) ? $after = $symbol : $before = $symbol; ?> <div id="directorist" class="atbd_wrapper directorist directorist-checkout-form directorist-w-100"> <div class="<?php Helper::directorist_container_fluid(); ?>"> - <div class="<?php Helper::directorist_row(); ?>"> - <div class="directorist-col-md-8 directorist-offset-md-2"> - <?php do_action('atbdp_before_checkout_form_start'); ?> - <form id="atbdp-checkout-form" class="form-vertical clearfix" method="post" action="#"> - <?php do_action('atbdp_after_checkout_form_start'); ?> - <div class="directorist-checkout-text directorist-text-center directorist-mb-40"> - <?php esc_html_e('Your order details are given below. Please review it and click on Proceed to Payment to complete this order.', 'directorist'); ?> - </div> - <?php - /** - * @since 6.5.6 - */ - do_action( 'atbdp_before_checkout_table', $form_data ); - ?> - <div class="directorist-card directorist-checkout-card"> - <div class="directorist-card__header"> - <h3 class="directorist-card__header__title">Order Summary</h3> - </div> - <div class="directorist-card__body"> - <div class="directorist-table-responsive"> - <table id="directorist-checkout-table" class="directorist-table"> - <tbody> - <?php - // $args is auto available available through the load_template(). - // var_dump( $form_data ); - $subtotal = 0; - $selected_product = 0; + <div class="<?php Helper::directorist_row(); ?>"> + <div class="directorist-col-md-8 directorist-offset-md-2"> + <?php do_action( 'atbdp_before_checkout_form_start' ); ?> + <form id="atbdp-checkout-form" class="form-vertical clearfix" method="post" action="#"> + <?php do_action( 'atbdp_after_checkout_form_start' ); ?> + <div class="directorist-checkout-text directorist-text-center directorist-mb-40"> + <?php esc_html_e( 'Your order details are given below. Please review it and click on Proceed to Payment to complete this order.', 'directorist' ); ?> + </div> + <?php + /** + * @since 6.5.6 + */ + do_action( 'atbdp_before_checkout_table', $form_data ); + ?> + <div class="directorist-card directorist-checkout-card"> + <div class="directorist-card__header"> + <h3 class="directorist-card__header__title">Order Summary</h3> + </div> + <div class="directorist-card__body"> + <div class="directorist-table-responsive"> + <table id="directorist-checkout-table" class="directorist-table"> + <tbody> + <?php + // $args is auto available available through the load_template(). + // var_dump( $form_data ); + $subtotal = 0; + $selected_product = 0; - foreach ( $form_data as $key => $option ) { - if ( 'header' == $option['type'] ) { ?><?php } else { /* Display other type of item here */ ?> - <tr> - <td colspan="2" class=""> - <?php - /* display proper type of checkbox/radio etc */ - $atts = [ - 'id' => $option['name'] . '_' . $key, - 'name' => $option['name'], - 'value' => $option['price'], - 'class' => 'atbdp-checkout-price-item atbdp_checkout_item_field', - 'data-price-type' => 'addition', - 'checked' => isset( $option['selected'] ) ? checked( 1, $option['selected'], false ) : '', - ]; - ?> + foreach ( $form_data as $key => $option ) { + if ( 'header' == $option['type'] ) { + ?> + <?php } else { /* Display other type of item here */ ?> + <tr> + <td colspan="2" class=""> + <?php + /* display proper type of checkbox/radio etc */ + $atts = array( + 'id' => $option['name'] . '_' . $key, + 'name' => $option['name'], + 'value' => $option['price'], + 'class' => 'atbdp-checkout-price-item atbdp_checkout_item_field', + 'data-price-type' => 'addition', + 'checked' => isset( $option['selected'] ) ? checked( 1, $option['selected'], false ) : '', + ); + ?> - <input type='hidden' id="<?php echo esc_attr( $atts['id'] ); ?>" name="<?php echo esc_attr( $atts['name'] ); ?>" class="<?php echo esc_attr( $atts['class'] ); ?>" value="<?php echo esc_attr( $atts['value'] ); ?>" data-price-type="<?php echo esc_attr( $atts['data-price-type'] ); ?>" <?php echo esc_attr( $atts['checked'] ); ?>/> + <input type='hidden' id="<?php echo esc_attr( $atts['id'] ); ?>" name="<?php echo esc_attr( $atts['name'] ); ?>" class="<?php echo esc_attr( $atts['class'] ); ?>" value="<?php echo esc_attr( $atts['value'] ); ?>" data-price-type="<?php echo esc_attr( $atts['data-price-type'] ); ?>" <?php echo esc_attr( $atts['checked'] ); ?>/> - <?php - // Add the price and product - if ( is_numeric( $atts['value'] ) && $option['selected'] && 'addition' === $atts['data-price-type'] ) { - $price = ( preg_match( '/[.]/', $atts['value'] ) ) ? ( float ) $atts['value'] : ( int ) $atts['value']; - $subtotal += $price; - $selected_product++; - } - ?> - <?php - if ( ! empty( $option['title'] ) ) { - printf( '<label for="%s"></label>', esc_attr( $atts['id'] ) ); - } - ?> - <span class="directorist-summery-label"> <?php echo esc_html( $option['title'] ) ?> </span> - <?php if ( ! empty( $option['desc'] ) ) echo '<p class="directorist-summery-label-description">'. esc_html($option['desc']) . '</p>'; ?> - </td> - <td class="directorist-text-right"> - <span class="directorist-summery-amount"> - <?php if (!empty($option['price'])) { - $output = $before. atbdp_format_payment_amount($option['price']) . $after; - echo wp_kses_post( $output ); - do_action('atbdp_checkout_after_total_price', $form_data); - } ?> - </span> - </td> - </tr> - <?php } - } + <?php + // Add the price and product + if ( is_numeric( $atts['value'] ) && $option['selected'] && 'addition' === $atts['data-price-type'] ) { + $price = ( preg_match( '/[.]/', $atts['value'] ) ) ? (float) $atts['value'] : (int) $atts['value']; + $subtotal += $price; + ++$selected_product; + } + ?> + <?php + if ( ! empty( $option['title'] ) ) { + printf( '<label for="%s"></label>', esc_attr( $atts['id'] ) ); + } + ?> + <span class="directorist-summery-label"> <?php echo esc_html( $option['title'] ); ?> </span> + <?php + if ( ! empty( $option['desc'] ) ) { + echo '<p class="directorist-summery-label-description">' . esc_html( $option['desc'] ) . '</p>';} + ?> + </td> + <td class="directorist-text-right"> + <span class="directorist-summery-amount"> + <?php + if ( ! empty( $option['price'] ) ) { + $output = $before . atbdp_format_payment_amount( $option['price'] ) . $after; + echo wp_kses_post( $output ); + do_action( 'atbdp_checkout_after_total_price', $form_data ); + } + ?> + </span> + </td> + </tr> + <?php + } + } - /** - * @since 6.5.6 - */ - do_action( 'atbdp_before_checkout_subtotal_tr', $form_data ); - ?> - <tr class="atbdp_ch_subtotal"> - <td colspan="2" class=""> - <span class="directorist-summery-label"><?php esc_html_e( 'Subtotal', 'directorist' ); ?></span> - </td> - <td class="directorist-text-right"> - <div id="atbdp_checkout_subtotal_amount" class="directorist-summery-amount"> - <?php - $output = $before. atbdp_format_payment_amount( $subtotal ) . $after; - echo wp_kses_post( $output ); - ?> - </div> - </td> - </tr> - <tr class="directorist-summery-total"> - <td colspan="2" class=""> - <span class="directorist-summery-label"><?php printf( esc_html__( 'Total amount [%s]', 'directorist' ), esc_html( $currency ) ); ?></h4> - </td> - <td class="directorist-text-right"> - <div id="atbdp_checkout_total_amount" class="directorist-summery-amount"><?php echo atbdp_format_payment_amount( $subtotal ) ?></div> - <input type="hidden" name="price" id="atbdp_checkout_total_amount_hidden" value="<?php echo esc_attr( $subtotal ) ?>"> - </td> - </tr> - </tbody> - </table> <!--ends table--> - </div> - </div> - </div> + /** + * @since 6.5.6 + */ + do_action( 'atbdp_before_checkout_subtotal_tr', $form_data ); + ?> + <tr class="atbdp_ch_subtotal"> + <td colspan="2" class=""> + <span class="directorist-summery-label"><?php esc_html_e( 'Subtotal', 'directorist' ); ?></span> + </td> + <td class="directorist-text-right"> + <div id="atbdp_checkout_subtotal_amount" class="directorist-summery-amount"> + <?php + $output = $before . atbdp_format_payment_amount( $subtotal ) . $after; + echo wp_kses_post( $output ); + ?> + </div> + </td> + </tr> + <tr class="directorist-summery-total"> + <td colspan="2" class=""> + <span class="directorist-summery-label"><?php printf( esc_html__( 'Total amount [%s]', 'directorist' ), esc_html( $currency ) ); ?></h4> + </td> + <td class="directorist-text-right"> + <div id="atbdp_checkout_total_amount" class="directorist-summery-amount"><?php echo atbdp_format_payment_amount( $subtotal ); ?></div> + <input type="hidden" name="price" id="atbdp_checkout_total_amount_hidden" value="<?php echo esc_attr( $subtotal ); ?>"> + </td> + </tr> + </tbody> + </table> <!--ends table--> + </div> + </div> + </div> - <?php if ( $subtotal > 0 ) : ?> - <div class="directorist-card directorist-mt-30 directorist-payment-gateways directorist-mb-15 directorist-checkout-card directorist-checkout-payment" id="directorist_payment_gateways"> - <div class="directorist-card__header"> - <h3 class="directorist-card__header__title"><?php esc_html_e('Choose a payment method', 'directorist'); ?></h3> - </div> + <?php if ( $subtotal > 0 ) : ?> + <div class="directorist-card directorist-mt-30 directorist-payment-gateways directorist-mb-15 directorist-checkout-card directorist-checkout-payment" id="directorist_payment_gateways"> + <div class="directorist-card__header"> + <h3 class="directorist-card__header__title"><?php esc_html_e( 'Choose a payment method', 'directorist' ); ?></h3> + </div> - <div class="directorist-card__body"> + <div class="directorist-card__body"> <?php echo directorist_kses( ATBDP_Gateway::gateways_markup(), 'all' ); ?> - </div> - </div> - <?php endif; ?> + </div> + </div> + <?php endif; ?> - <?php - do_action('atbdp_before_cc_form'); // Hook for dev - do_action('atbdp_cc_form'); // placeholder action for credit card form - do_action('atbdp_after_cc_form'); // Hook for dev - ?> + <?php + do_action( 'atbdp_before_cc_form' ); // Hook for dev + do_action( 'atbdp_cc_form' ); // placeholder action for credit card form + do_action( 'atbdp_after_cc_form' ); // Hook for dev + ?> - <p id="atbdp_checkout_errors" class="text-danger"></p> + <p id="atbdp_checkout_errors" class="text-danger"></p> - <?php wp_nonce_field('checkout_action', 'checkout_nonce'); - $directory_type = directorist_get_listing_directory( $listing_id ); - $new_l_status = get_term_meta( $directory_type, 'new_listing_status', true ); - $monitization = directorist_is_monetization_enabled(); - $featured_enabled = directorist_is_featured_listing_enabled(); - $submit_button_label = ( $selected_product > 0 && $subtotal < 1 ) ? __( 'Complete Submission', 'directorist' ) : __( 'Pay Now', 'directorist' ); + <?php + wp_nonce_field( 'checkout_action', 'checkout_nonce' ); + $directory_type = directorist_get_listing_directory( $listing_id ); + $new_l_status = get_term_meta( $directory_type, 'new_listing_status', true ); + $monitization = directorist_is_monetization_enabled(); + $featured_enabled = directorist_is_featured_listing_enabled(); + $submit_button_label = ( $selected_product > 0 && $subtotal < 1 ) ? __( 'Complete Submission', 'directorist' ) : __( 'Pay Now', 'directorist' ); - if ( is_fee_manager_active() ){ - $url = ATBDP_Permalink::get_dashboard_page_link(); - } + if ( is_fee_manager_active() ) { + $url = ATBDP_Permalink::get_dashboard_page_link(); + } - if (!empty($monitization && $featured_enabled)){ - $url = add_query_arg('listing_status', $new_l_status, ATBDP_Permalink::get_dashboard_page_link().'?listing_id='.$listing_id ); - } else{ - $url = add_query_arg('listing_status', $new_l_status, ATBDP_Permalink::get_dashboard_page_link().'?listing_id='.$listing_id ); - } - ?> - <input type="hidden" id="listing_id" name="listing_id" value="<?php echo esc_attr( $listing_id ); ?>"/> - <div class="directorist-payment-action directorist-flex directorist-justify-content-between" id="atbdp_pay_notpay_btn"> - <a href="<?php echo esc_url( apply_filters( 'atbdp_checkout_not_now_link', $url ) ); ?>" class="directorist-btn directorist-btn-lg directorist-btn-light atbdp_not_now_button"><?php esc_html_e('Not Now', 'directorist'); ?></a> - <button type="submit" id="atbdp_checkout_submit_btn" class="directorist-btn directorist-btn-lg directorist-btn-payment-submit" value="<?php echo esc_attr( $submit_button_label ); ?>"><?php echo esc_html( $submit_button_label ); ?></button> - <input type="hidden" id="atbdp_checkout_submit_btn_label" value="<?php echo esc_attr( $submit_button_label ); ?>"/> - </div> <!--ends pull-right--> + if ( ! empty( $monitization && $featured_enabled ) ) { + $url = add_query_arg( 'listing_status', $new_l_status, ATBDP_Permalink::get_dashboard_page_link() . '?listing_id=' . $listing_id ); + } else { + $url = add_query_arg( 'listing_status', $new_l_status, ATBDP_Permalink::get_dashboard_page_link() . '?listing_id=' . $listing_id ); + } + ?> + <input type="hidden" id="listing_id" name="listing_id" value="<?php echo esc_attr( $listing_id ); ?>"/> + <div class="directorist-payment-action directorist-flex directorist-justify-content-between" id="atbdp_pay_notpay_btn"> + <a href="<?php echo esc_url( apply_filters( 'atbdp_checkout_not_now_link', $url ) ); ?>" class="directorist-btn directorist-btn-lg directorist-btn-light atbdp_not_now_button"><?php esc_html_e( 'Not Now', 'directorist' ); ?></a> + <button type="submit" id="atbdp_checkout_submit_btn" class="directorist-btn directorist-btn-lg directorist-btn-payment-submit" value="<?php echo esc_attr( $submit_button_label ); ?>"><?php echo esc_html( $submit_button_label ); ?></button> + <input type="hidden" id="atbdp_checkout_submit_btn_label" value="<?php echo esc_attr( $submit_button_label ); ?>"/> + </div> <!--ends pull-right--> - <?php do_action('atbdp_before_checkout_form_end'); ?> + <?php do_action( 'atbdp_before_checkout_form_end' ); ?> - </form> <!--ends FORM --> - <?php do_action('atbdp_after_checkout_form_end'); ?> - </div> - </div> - </div> + </form> <!--ends FORM --> + <?php do_action( 'atbdp_after_checkout_form_end' ); ?> + </div> + </div> + </div> </div> <!-- ends directorist directorist-checkout-form--> \ No newline at end of file diff --git a/templates/payment/payment-receipt.php b/templates/payment/payment-receipt.php index ef058c000e..2d24b92163 100644 --- a/templates/payment/payment-receipt.php +++ b/templates/payment/payment-receipt.php @@ -4,170 +4,175 @@ * @since 7.0 * @version 7.7.0 */ -use \Directorist\Helper; +use Directorist\Helper; ?> <div id="directorist" class="atbd_wrapper directorist directory_wrapper single_area directorist-w-100"> - <div class="<?php Helper::directorist_container_fluid(); ?>"> - <div class="<?php Helper::directorist_row(); ?>"> - <div class="directorist-col-md-8 directorist-offset-md-2"> - <div class="directorist-payment-receipt"> - <p class="directorist-payment-thanks-text"><?php esc_html_e( 'Thank you for your order!', 'directorist' ); ?></p> - <?php - // show the user instruction for banking gateway - if( isset( $o_metas['_payment_gateway'] ) && 'bank_transfer' == $o_metas['_payment_gateway'][0] && 'created' == $o_metas['_payment_status'][0] ) { - $ins = get_directorist_option('bank_transfer_instruction'); - $output = !empty($ins) ? '<p class="directorist-payment-instructions">'.ATBDP()->email->replace_in_content($ins, @$order_id, @$o_metas['_listing_id'][0]).'</p>' : ''; + <div class="<?php Helper::directorist_container_fluid(); ?>"> + <div class="<?php Helper::directorist_row(); ?>"> + <div class="directorist-col-md-8 directorist-offset-md-2"> + <div class="directorist-payment-receipt"> + <p class="directorist-payment-thanks-text"><?php esc_html_e( 'Thank you for your order!', 'directorist' ); ?></p> + <?php + // show the user instruction for banking gateway + if ( isset( $o_metas['_payment_gateway'] ) && 'bank_transfer' == $o_metas['_payment_gateway'][0] && 'created' == $o_metas['_payment_status'][0] ) { + $ins = get_directorist_option( 'bank_transfer_instruction' ); + $output = ! empty( $ins ) ? '<p class="directorist-payment-instructions">' . ATBDP()->email->replace_in_content( $ins, @$order_id, @$o_metas['_listing_id'][0] ) . '</p>' : ''; echo wp_kses_post( $output ); - } - ?> + } + ?> - <div class="directorist-payment-table directorist-table-responsive directorist-mb-30"> - <table class="directorist-table"> - <thead> - <tr> - <th colspan="2"><?php esc_html_e( 'Order Summary', 'directorist' ); ?></th> - </tr> - </thead> - <tbody> - <tr> - <td class="directorist-payment-table__label"><?php esc_html_e( 'Order ID', 'directorist' ); ?></td> - <td><?php echo (!empty($order_id)) ? esc_html( $order_id ) : ''; ?></td> - </tr> - <tr> - <td class="directorist-payment-table__label"><?php esc_html_e( 'Date', 'directorist' ); ?></td> - <td><?php echo !empty($order) ? esc_html( get_the_time( get_option( 'date_format' ), $order_id ) ) : ''; ?></td> - </tr> - <tr> - <td class="directorist-payment-table__label"><?php esc_html_e( 'Transaction ID', 'directorist' ); ?></td> - <td><?php echo isset( $o_metas['_transaction_id'] ) ? esc_html( $o_metas['_transaction_id'][0] ) : 'NIL'; ?></td> - </tr> - <tr> - <td class="directorist-payment-table__label"><?php esc_html_e( 'Payment Method', 'directorist' ); ?></td> - <td> - <?php - $gateway = !empty($o_metas['_payment_gateway'][0]) ? $o_metas['_payment_gateway'][0] : 'unknown'; - if( 'free' == $gateway ) { - esc_html_e( 'Free Listing', 'directorist' ); - } else { - $gw_title = get_directorist_option("{$gateway}_title"); - echo ! empty( $gw_title ) ? esc_html( $gw_title ) : esc_html( $gateway ); - } - ?> - </td> - </tr> - <tr> - <td class="directorist-payment-table__label"><?php esc_html_e( 'Payment Status', 'directorist' ); ?></td> - <td> - <?php - $status = isset( $o_metas['_payment_status'] ) ? $o_metas['_payment_status'][0] : 'Invalid'; - echo esc_html( atbdp_get_payment_status_i18n( $status ) ); - ?> - </td> - </tr> - <tr> - <td class="directorist-payment-table__label"><?php esc_html_e( 'Amount', 'directorist' ); ?></td> - <td> - <?php - if( !empty( $o_metas['_amount'] ) ) { - $amount = $o_metas['_amount'][0] ; - $amount = atbdp_format_payment_amount( $amount ); - $before = ''; - $after = ''; - ('after' == $c_position) ? $after = $symbol : $before = $symbol; - $output = $before . $amount . $after; - echo wp_kses_post( $output ); - } - ?> - </td> - </tr> - </tbody> - </table> - </div> - + <div class="directorist-payment-table directorist-table-responsive directorist-mb-30"> + <table class="directorist-table"> + <thead> + <tr> + <th colspan="2"><?php esc_html_e( 'Order Summary', 'directorist' ); ?></th> + </tr> + </thead> + <tbody> + <tr> + <td class="directorist-payment-table__label"><?php esc_html_e( 'Order ID', 'directorist' ); ?></td> + <td><?php echo ( ! empty( $order_id ) ) ? esc_html( $order_id ) : ''; ?></td> + </tr> + <tr> + <td class="directorist-payment-table__label"><?php esc_html_e( 'Date', 'directorist' ); ?></td> + <td><?php echo ! empty( $order ) ? esc_html( get_the_time( get_option( 'date_format' ), $order_id ) ) : ''; ?></td> + </tr> + <tr> + <td class="directorist-payment-table__label"><?php esc_html_e( 'Transaction ID', 'directorist' ); ?></td> + <td><?php echo isset( $o_metas['_transaction_id'] ) ? esc_html( $o_metas['_transaction_id'][0] ) : 'NIL'; ?></td> + </tr> + <tr> + <td class="directorist-payment-table__label"><?php esc_html_e( 'Payment Method', 'directorist' ); ?></td> + <td> + <?php + $gateway = ! empty( $o_metas['_payment_gateway'][0] ) ? $o_metas['_payment_gateway'][0] : 'unknown'; + if ( 'free' == $gateway ) { + esc_html_e( 'Free Listing', 'directorist' ); + } else { + $gw_title = get_directorist_option( "{$gateway}_title" ); + echo ! empty( $gw_title ) ? esc_html( $gw_title ) : esc_html( $gateway ); + } + ?> + </td> + </tr> + <tr> + <td class="directorist-payment-table__label"><?php esc_html_e( 'Payment Status', 'directorist' ); ?></td> + <td> + <?php + $status = isset( $o_metas['_payment_status'] ) ? $o_metas['_payment_status'][0] : 'Invalid'; + echo esc_html( atbdp_get_payment_status_i18n( $status ) ); + ?> + </td> + </tr> + <tr> + <td class="directorist-payment-table__label"><?php esc_html_e( 'Amount', 'directorist' ); ?></td> + <td> + <?php + if ( ! empty( $o_metas['_amount'] ) ) { + $amount = $o_metas['_amount'][0]; + $amount = atbdp_format_payment_amount( $amount ); + $before = ''; + $after = ''; + ( 'after' == $c_position ) ? $after = $symbol : $before = $symbol; + $output = $before . $amount . $after; + echo wp_kses_post( $output ); + } + ?> + </td> + </tr> + </tbody> + </table> + </div> + - <?php - /*Show orders item if we have some*/ - if (!empty($order_items)){ ?> - <div class="directorist-payment-table directorist-table-responsive directorist-payment-summery-table"> - <table class="directorist-table"> - <thead> - <tr> - <th colspan="2"><?php esc_html_e( 'Item summary', 'directorist' ); ?></th> - </tr> - </thead> - <tbody> - <?php - $total = 0; - foreach( $order_items as $order_item ) { ?> - <tr> - <td> + <?php + /*Show orders item if we have some*/ + if ( ! empty( $order_items ) ) { + ?> + <div class="directorist-payment-table directorist-table-responsive directorist-payment-summery-table"> + <table class="directorist-table"> + <thead> + <tr> + <th colspan="2"><?php esc_html_e( 'Item summary', 'directorist' ); ?></th> + </tr> + </thead> + <tbody> + <?php + $total = 0; + foreach ( $order_items as $order_item ) { + ?> + <tr> + <td> - <?php - if ( !empty( $order_item['title'] ) ) { - printf( '<h5 class="directorist-payment-table__title">%s</h5>', esc_html( $order_item['title'] ) ); - } + <?php + if ( ! empty( $order_item['title'] ) ) { + printf( '<h5 class="directorist-payment-table__title">%s</h5>', esc_html( $order_item['title'] ) ); + } - if( !empty( $order_item['desc'] ) ) { ?> - <p> <?php echo esc_html( $order_item['desc'] ); ?> </p> - <?php } ?> + if ( ! empty( $order_item['desc'] ) ) { + ?> + <p> <?php echo esc_html( $order_item['desc'] ); ?> </p> + <?php } ?> - </td> - <td> - <?php - if( !empty( $order_item['price'] ) ){ - $price = $order_item['price']; - $output = $before.atbdp_format_payment_amount($order_item['price']).$after; - echo wp_kses_post( $output ); - do_action('atbdp_payment_receipt_after_total_price', $o_metas); - // increase the total amount - $total += $order_item['price']; - } - ?> - </td> - </tr> - <?php } - if( !empty( $discount ) ) { ?> - <tr> - <td class="directorist-payment-table__title"><?php esc_html_e( 'Subtotal', 'directorist' ); ?></td> - <td> - <?php - $output = $before.atbdp_format_payment_amount($total).$after; - ?> - <?php echo wp_kses_post( $output ); ?> - </td> - </tr> - <tr> - <td class="directorist-payment-table__title"><?php esc_html_e( 'Discount', 'directorist' ); ?></td> - <td> - <?php - $output = $before . atbdp_format_payment_amount( $discount ) . $after ; - echo wp_kses_post( $output ); - ?> - </td> - </tr> - <?php } ?> - <tr class="directorsit-payment-table-total"> - <td class="directorist-payment-table__title"><?php esc_html_e( 'Total amount', 'directorist' ); ?></td> - <td> - <?php - $grand_total = !empty( $discount ) ? atbdp_format_payment_amount( $total - $discount ) : atbdp_format_payment_amount( $total ); - $output = $before . atbdp_format_payment_amount( $grand_total ) . $after ; - ?> - <?php echo wp_kses_post( $output ); ?> - </td> - </tr> - </tbody> - </table> - </div> - <?php } ?> - </div> - <?php - $url = apply_filters('atbdp_payment_receipt_button_link', ATBDP_Permalink::get_dashboard_page_link(), $order_id); - $text = apply_filters('atbdp_payment_receipt_button_text', __( 'View your listings', 'directorist' ), $order_id); - ?> - <div class="directorist-text-center directorist-mt-30"><a href="<?php echo esc_url($url); ?>" class="directorist-btn directorist-btn-lg directorist-btn-view-listing"><?php echo esc_attr($text); ?></a></div> - </div> - </div> - </div> + </td> + <td> + <?php + if ( ! empty( $order_item['price'] ) ) { + $price = $order_item['price']; + $output = $before . atbdp_format_payment_amount( $order_item['price'] ) . $after; + echo wp_kses_post( $output ); + do_action( 'atbdp_payment_receipt_after_total_price', $o_metas ); + // increase the total amount + $total += $order_item['price']; + } + ?> + </td> + </tr> + <?php + } + if ( ! empty( $discount ) ) { + ?> + <tr> + <td class="directorist-payment-table__title"><?php esc_html_e( 'Subtotal', 'directorist' ); ?></td> + <td> + <?php + $output = $before . atbdp_format_payment_amount( $total ) . $after; + ?> + <?php echo wp_kses_post( $output ); ?> + </td> + </tr> + <tr> + <td class="directorist-payment-table__title"><?php esc_html_e( 'Discount', 'directorist' ); ?></td> + <td> + <?php + $output = $before . atbdp_format_payment_amount( $discount ) . $after; + echo wp_kses_post( $output ); + ?> + </td> + </tr> + <?php } ?> + <tr class="directorsit-payment-table-total"> + <td class="directorist-payment-table__title"><?php esc_html_e( 'Total amount', 'directorist' ); ?></td> + <td> + <?php + $grand_total = ! empty( $discount ) ? atbdp_format_payment_amount( $total - $discount ) : atbdp_format_payment_amount( $total ); + $output = $before . atbdp_format_payment_amount( $grand_total ) . $after; + ?> + <?php echo wp_kses_post( $output ); ?> + </td> + </tr> + </tbody> + </table> + </div> + <?php } ?> + </div> + <?php + $url = apply_filters( 'atbdp_payment_receipt_button_link', ATBDP_Permalink::get_dashboard_page_link(), $order_id ); + $text = apply_filters( 'atbdp_payment_receipt_button_text', __( 'View your listings', 'directorist' ), $order_id ); + ?> + <div class="directorist-text-center directorist-mt-30"><a href="<?php echo esc_url( $url ); ?>" class="directorist-btn directorist-btn-lg directorist-btn-view-listing"><?php echo esc_attr( $text ); ?></a></div> + </div> + </div> + </div> </div> \ No newline at end of file diff --git a/templates/payment/transaction-failure.php b/templates/payment/transaction-failure.php index dffda5d425..93c21a1ce4 100644 --- a/templates/payment/transaction-failure.php +++ b/templates/payment/transaction-failure.php @@ -5,4 +5,4 @@ * @version 7.3.1 */ -esc_html_e('Your Transaction was not successful. Please contact support', 'directorist'); \ No newline at end of file +esc_html_e( 'Your Transaction was not successful. Please contact support', 'directorist' ); diff --git a/templates/search-form-contents.php b/templates/search-form-contents.php index dc2205154a..13d417d7fe 100644 --- a/templates/search-form-contents.php +++ b/templates/search-form-contents.php @@ -5,26 +5,28 @@ * @version 7.7.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-contents directorist-contents-wrap" data-atts="<?php echo esc_attr( $searchform->get_atts_data() ); ?>"> <div class="<?php Helper::directorist_container_fluid(); ?>"> - <?php do_action('directorist_search_listing_before_title'); ?> + <?php do_action( 'directorist_search_listing_before_title' ); ?> - <?php if ( $searchform->show_title_subtitle && ( $searchform->search_bar_title || $searchform->search_bar_sub_title ) ): ?> + <?php if ( $searchform->show_title_subtitle && ( $searchform->search_bar_title || $searchform->search_bar_sub_title ) ) : ?> <div class="directorist-search-top"> - <?php if ( $searchform->search_bar_title ): ?> + <?php if ( $searchform->search_bar_title ) : ?> <h2 class="directorist-search-top__title"><?php echo esc_html( $searchform->search_bar_title ); ?></h2> <?php endif; ?> - <?php if ( $searchform->search_bar_sub_title ): ?> + <?php if ( $searchform->search_bar_sub_title ) : ?> <p class="directorist-search-top__subtitle"><?php echo esc_html( $searchform->search_bar_sub_title ); ?></p> <?php endif; ?> @@ -40,13 +42,13 @@ <input type="hidden" name="directory_type" class="listing_type" value="<?php echo esc_attr( $searchform->listing_type_slug() ); ?>"> - <?php Helper::get_template( 'search-form/form-box', ['searchform' => $searchform] ); ?> + <?php Helper::get_template( 'search-form/form-box', array( 'searchform' => $searchform ) ); ?> </div> </form> - <?php do_action('directorist_search_listing_after_search_bar'); ?> + <?php do_action( 'directorist_search_listing_after_search_bar' ); ?> <?php $searchform->top_categories_template(); ?> diff --git a/templates/search-form/adv-search.php b/templates/search-form/adv-search.php index 02b4f31d99..1313ef7503 100644 --- a/templates/search-form/adv-search.php +++ b/templates/search-form/adv-search.php @@ -5,7 +5,9 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $fields = $searchform->get_advance_fields(); ?> @@ -18,13 +20,17 @@ <span class="directorist-search-modal__minimizer"></span> </div> <div class="directorist-search-modal__contents__body"> - <?php if ( ! empty( $fields ) ) : - foreach ( $fields as $field ): ?> - <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] )?>"> + <?php + if ( ! empty( $fields ) ) : + foreach ( $fields as $field ) : + ?> + <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] ); ?>"> <?php $searchform->field_template( $field ); ?> </div> - <?php endforeach; - endif; ?> + <?php + endforeach; + endif; + ?> </div> <div class="directorist-search-modal__contents__footer"> <?php $searchform->buttons_template(); ?> diff --git a/templates/search-form/basic-search.php b/templates/search-form/basic-search.php index 7328058fc9..24bc785982 100644 --- a/templates/search-form/basic-search.php +++ b/templates/search-form/basic-search.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $fields = $searchform->get_basic_fields(); ?> @@ -16,7 +18,7 @@ <?php if ( ! empty( $fields ) ) : ?> - <?php foreach ( $fields as $key => $field ){ ?> + <?php foreach ( $fields as $key => $field ) { ?> <div class="directorist-search-modal__input <?php echo $key === 'radius_search' ? 'directorist-radius-search' : ''; ?>"> <?php $searchform->field_template( $field ); ?> </div> @@ -29,7 +31,7 @@ <?php directorist_icon( 'las la-search' ); ?> - <?php echo esc_html( $searchform->search_button_text );?> + <?php echo esc_html( $searchform->search_button_text ); ?> </button> </div> diff --git a/templates/search-form/buttons.php b/templates/search-form/buttons.php index 226329d73c..75e993f225 100644 --- a/templates/search-form/buttons.php +++ b/templates/search-form/buttons.php @@ -5,16 +5,18 @@ * @version 7.0.5.6 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-advanced-filter__action directorist-flex directorist-align-center directorist-justify-content-between flex-wrap"> - <?php if ( $searchform->has_apply_filters_button ): ?> + <?php if ( $searchform->has_apply_filters_button ) : ?> <button type="submit" class="directorist-btn directorist-btn-sm directorist-btn-submit"><?php echo esc_html( $searchform->apply_filters_text ); ?></button> <?php endif; ?> - <?php if ( $searchform->has_reset_filters_button ): ?> + <?php if ( $searchform->has_reset_filters_button ) : ?> <button type="submit" class="directorist-btn-reset-js"><?php echo esc_html( $searchform->reset_filters_text ); ?></button> <?php endif; ?> diff --git a/templates/search-form/custom-fields/checkbox.php b/templates/search-form/custom-fields/checkbox.php index e7cc9da82c..5549b5f6bf 100644 --- a/templates/search-form/custom-fields/checkbox.php +++ b/templates/search-form/custom-fields/checkbox.php @@ -5,16 +5,18 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} if ( $value == '' ) { - $value = []; + $value = array(); } ?> <div class="directorist-search-field directorist-search-form-dropdown directorist-form-group"> <div class="directorist-search-basic-dropdown directorist-search-field__input"> - <?php if ( !empty($data['label']) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <label class="directorist-search-field__label directorist-search-basic-dropdown-label"> <span class="directorist-search-basic-dropdown-selected-prefix"></span> <?php echo esc_html( $data['label'] ); ?> @@ -28,11 +30,11 @@ <?php if ( $data['options']['options'] ) { foreach ( $data['options']['options'] as $option ) { - $uniqid = $option['option_value'] . '-' .wp_rand(); + $uniqid = $option['option_value'] . '-' . wp_rand(); ?> <div class="directorist-checkbox directorist-checkbox-primary"> - <input <?php checked( in_array( $option[ 'option_value' ], $value ) ); ?> type="checkbox" id="<?php echo esc_attr( $uniqid ); ?>" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>][]" value="<?php echo esc_attr( $option['option_value'] ); ?>"> + <input <?php checked( in_array( $option['option_value'], $value ) ); ?> type="checkbox" id="<?php echo esc_attr( $uniqid ); ?>" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>][]" value="<?php echo esc_attr( $option['option_value'] ); ?>"> <label class="directorist-checkbox__label" for="<?php echo esc_attr( $uniqid ); ?>"><?php echo esc_html( $option['option_label'] ); ?></label> </div> diff --git a/templates/search-form/custom-fields/color_picker.php b/templates/search-form/custom-fields/color_picker.php index 5bf58f463b..9d8596de7a 100644 --- a/templates/search-form/custom-fields/color_picker.php +++ b/templates/search-form/custom-fields/color_picker.php @@ -5,17 +5,19 @@ * @version 7.3.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group directorist-color"> - <?php if ( !empty($data['label']) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <label class="directorist-search-field__label"><?php echo esc_html( $data['label'] ); ?></label> <?php endif; ?> <div class="directorist-form-group directorist-color-picker-wrap"> - <input class="directorist-form-element directorist-search-field__input directorist-color-picker" type="text" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo !empty( $data['placeholder'] ) ? esc_attr( $data['placeholder'] ) : ''; ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>> + <input class="directorist-form-element directorist-search-field__input directorist-color-picker" type="text" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo ! empty( $data['placeholder'] ) ? esc_attr( $data['placeholder'] ) : ''; ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>> </div> <div class="directorist-search-field__btn directorist-search-field__btn--clear"> diff --git a/templates/search-form/custom-fields/date.php b/templates/search-form/custom-fields/date.php index 55c9dcc253..1579d15dd8 100644 --- a/templates/search-form/custom-fields/date.php +++ b/templates/search-form/custom-fields/date.php @@ -5,12 +5,14 @@ * @version 7.0.5.3 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group directorist-date"> - <?php if ( !empty($data['label']) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <label class="directorist-search-field__label"><?php echo esc_html( $data['label'] ); ?></label> <?php endif; ?> diff --git a/templates/search-form/custom-fields/number.php b/templates/search-form/custom-fields/number.php index 5c01efb982..52a7ff738d 100644 --- a/templates/search-form/custom-fields/number.php +++ b/templates/search-form/custom-fields/number.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group"> @@ -14,13 +16,13 @@ <?php endif; ?> <div class="directorist-form-group__with-prefix"> - <?php if( ! empty( $data['options']['prepend'] ) ) : ?> + <?php if ( ! empty( $data['options']['prepend'] ) ) : ?> <span class="directorist-form-group__prefix directorist-form-group__prefix--start"><?php echo esc_html( $data['options']['prepend'] ); ?></span> <?php endif; ?> <input class="directorist-form-element directorist-search-field__input" type="number" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" step="<?php echo esc_attr( $data['options']['step'] ?? 1 ); ?>" min="0" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>> - <?php if( ! empty( $data['options']['append'] ) ) : ?> + <?php if ( ! empty( $data['options']['append'] ) ) : ?> <span class="directorist-form-group__prefix directorist-form-group__prefix--end"><?php echo esc_html( $data['options']['append'] ); ?></span> <?php endif; ?> </div> diff --git a/templates/search-form/custom-fields/number/dropdown.php b/templates/search-form/custom-fields/number/dropdown.php index e56ce8fe14..fbd8912c07 100644 --- a/templates/search-form/custom-fields/number/dropdown.php +++ b/templates/search-form/custom-fields/number/dropdown.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $options = directorist_calculate_number_options( $data ); ?> @@ -20,10 +22,10 @@ <select name='custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]' <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?> data-isSearch="true" data-placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>"> - <option value=""><?php echo esc_html( ! empty( $data['placeholder'] ) ? $data['placeholder'] : __( 'Select', 'directorist' ) )?></option> + <option value=""><?php echo esc_html( ! empty( $data['placeholder'] ) ? $data['placeholder'] : __( 'Select', 'directorist' ) ); ?></option> <?php - if( $options ) { + if ( $options ) { foreach ( $options['select'] as $option ) { printf( '<option value="%s"%s>%s</option>', esc_attr( $option ), esc_attr( selected( (int) $value === $option ) ), esc_html( $option ) ); } @@ -34,7 +36,7 @@ </div> - <div class="directorist-search-field__btn directorist-search-field__btn--clear"> + <div class="directorist-search-field__btn directorist-search-field__btn--clear"> <?php directorist_icon( 'fas fa-times-circle' ); ?> </div> diff --git a/templates/search-form/custom-fields/number/radio.php b/templates/search-form/custom-fields/number/radio.php index 033ad74de9..3526a8442e 100644 --- a/templates/search-form/custom-fields/number/radio.php +++ b/templates/search-form/custom-fields/number/radio.php @@ -5,14 +5,16 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $options = directorist_calculate_number_options( $data ); ?> <div class="directorist-search-field"> - <?php if ( !empty($data['label']) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <label><?php echo esc_html( $data['label'] ); ?></label> <?php endif; ?> @@ -20,13 +22,13 @@ <?php if ( $options['radio'] ) { - foreach ( $options['radio'] as $option ){ - $uniqid = $option['start'] . '-' . wp_rand(); - $option_value = ( $option['start'] === $option['end'] ) ? $option['start'] : $option['start'] . '-' . $option['end']; + foreach ( $options['radio'] as $option ) { + $uniqid = $option['start'] . '-' . wp_rand(); + $option_value = ( $option['start'] === $option['end'] ) ? $option['start'] : $option['start'] . '-' . $option['end']; ?> <div class="directorist-radio directorist-radio-circle"> - <input <?php checked( $value === $option_value ); ?> type="radio" id="<?php echo esc_attr( $uniqid ); ?>" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" value="<?php echo esc_attr( $option_value ); ?>"> + <input <?php checked( $value === $option_value ); ?> type="radio" id="<?php echo esc_attr( $uniqid ); ?>" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" value="<?php echo esc_attr( $option_value ); ?>"> <label class="directorist-radio__label" for="<?php echo esc_attr( $uniqid ); ?>"><?php echo esc_html( $option_value ); ?></label> </div> diff --git a/templates/search-form/custom-fields/number/range.php b/templates/search-form/custom-fields/number/range.php index dfeafc9c06..8e667930e2 100644 --- a/templates/search-form/custom-fields/number/range.php +++ b/templates/search-form/custom-fields/number/range.php @@ -5,29 +5,31 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $min_val = $data['options']['min_value'] ?? 1; $max_value = $data['options']['max_value'] ?? 100; ?> <div class="directorist-search-field directorist-search-field-text_range"> - <?php if ( !empty($data['label']) ): ?> - <label><?php echo esc_html( $data['label'] ); ?></label> - <?php endif; ?> - <div class="directorist-custom-range-slider"> - <div class="directorist-custom-range-slider__slide" step="<?php echo esc_attr( ! empty( $data['options']['step'] ) ? absint( $data['options']['step'] ) : 1 ); ?>" aria-label="Range" max-value="<?php echo esc_attr($max_value); ?>"></div> - <div class="directorist-custom-range-slider__wrap"> - <div class="directorist-custom-range-slider__value"> - <label for="directorist-custom-range-slider__value__min__number" class="directorist-custom-range-slider__label"><?php esc_html_e( 'Min', 'directorist' ); ?></label> - <input type="number" placeholder="Min" value="<?php echo esc_attr( $min_val ) ?>" name="directorist-custom-range-slider__value__min" id="directorist-custom-range-slider__value__min__number" class="directorist-custom-range-slider__text directorist-custom-range-slider__value__min"> - </div> - <div class="directorist-custom-range-slider__value"> - <label for="directorist-custom-range-slider__value__max__number" class="directorist-custom-range-slider__label"><?php esc_html_e( 'Max', 'directorist' ); ?></label> - <input type="number" placeholder="Max" value="<?php echo esc_attr( $max_value ) ?>" name="directorist-custom-range-slider__value__max" id="directorist-custom-range-slider__text directorist-custom-range-slider__value__max__number" class="directorist-custom-range-slider__value__max"> - </div> - <input type="hidden" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" class="directorist-custom-range-slider__range" value="<?php echo esc_attr( $min_val ) ?>-<?php echo esc_attr( $max_value ) ?>"> - </div> - </div> + <?php if ( ! empty( $data['label'] ) ) : ?> + <label><?php echo esc_html( $data['label'] ); ?></label> + <?php endif; ?> + <div class="directorist-custom-range-slider"> + <div class="directorist-custom-range-slider__slide" step="<?php echo esc_attr( ! empty( $data['options']['step'] ) ? absint( $data['options']['step'] ) : 1 ); ?>" aria-label="Range" max-value="<?php echo esc_attr( $max_value ); ?>"></div> + <div class="directorist-custom-range-slider__wrap"> + <div class="directorist-custom-range-slider__value"> + <label for="directorist-custom-range-slider__value__min__number" class="directorist-custom-range-slider__label"><?php esc_html_e( 'Min', 'directorist' ); ?></label> + <input type="number" placeholder="Min" value="<?php echo esc_attr( $min_val ); ?>" name="directorist-custom-range-slider__value__min" id="directorist-custom-range-slider__value__min__number" class="directorist-custom-range-slider__text directorist-custom-range-slider__value__min"> + </div> + <div class="directorist-custom-range-slider__value"> + <label for="directorist-custom-range-slider__value__max__number" class="directorist-custom-range-slider__label"><?php esc_html_e( 'Max', 'directorist' ); ?></label> + <input type="number" placeholder="Max" value="<?php echo esc_attr( $max_value ); ?>" name="directorist-custom-range-slider__value__max" id="directorist-custom-range-slider__text directorist-custom-range-slider__value__max__number" class="directorist-custom-range-slider__value__max"> + </div> + <input type="hidden" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" class="directorist-custom-range-slider__range" value="<?php echo esc_attr( $min_val ); ?>-<?php echo esc_attr( $max_value ); ?>"> + </div> + </div> </div> \ No newline at end of file diff --git a/templates/search-form/custom-fields/radio.php b/templates/search-form/custom-fields/radio.php index 6b419f8859..49ad08019d 100644 --- a/templates/search-form/custom-fields/radio.php +++ b/templates/search-form/custom-fields/radio.php @@ -5,12 +5,14 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-search-form-dropdown directorist-form-group"> <div class="directorist-search-basic-dropdown directorist-search-field__input"> - <?php if ( !empty($data['label']) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <label class="directorist-search-field__label directorist-search-basic-dropdown-label"> <?php echo esc_html( $data['label'] ); ?> <span class="directorist-search-basic-dropdown-selected-item"></span> @@ -22,12 +24,12 @@ <?php if ( $data['options']['options'] ) { - foreach ( $data['options']['options'] as $option ){ - $uniqid = $option['option_value'] . '-' .wp_rand(); + foreach ( $data['options']['options'] as $option ) { + $uniqid = $option['option_value'] . '-' . wp_rand(); ?> <div class="directorist-radio directorist-radio-circle"> - <input <?php checked( $value === $option[ 'option_value' ] ); ?> type="radio" id="<?php echo esc_attr( $uniqid ); ?>" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" value="<?php echo esc_attr( $option['option_value'] ); ?>"> + <input <?php checked( $value === $option['option_value'] ); ?> type="radio" id="<?php echo esc_attr( $uniqid ); ?>" name="custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]" value="<?php echo esc_attr( $option['option_value'] ); ?>"> <label class="directorist-radio__label" for="<?php echo esc_attr( $uniqid ); ?>"><?php echo esc_html( $option['option_label'] ); ?></label> </div> diff --git a/templates/search-form/custom-fields/select.php b/templates/search-form/custom-fields/select.php index e3066bb6d6..95852fc12d 100644 --- a/templates/search-form/custom-fields/select.php +++ b/templates/search-form/custom-fields/select.php @@ -5,7 +5,9 @@ * @version 7.5.4 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group"> @@ -16,14 +18,14 @@ <label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label> <?php endif; ?> - <select name='custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]' <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?> data-isSearch="true" data-placeholder="<?php echo esc_html( ! empty( $data['placeholder'] ) ? $data['placeholder'] : __( 'Select', 'directorist' ) )?>"> + <select name='custom_field[<?php echo esc_attr( $data['field_key'] ); ?>]' <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?> data-isSearch="true" data-placeholder="<?php echo esc_html( ! empty( $data['placeholder'] ) ? $data['placeholder'] : __( 'Select', 'directorist' ) ); ?>"> - <option value=""><?php echo esc_html( ! empty( $data['placeholder'] ) ? $data['placeholder'] : __( 'Select', 'directorist' ) )?></option> + <option value=""><?php echo esc_html( ! empty( $data['placeholder'] ) ? $data['placeholder'] : __( 'Select', 'directorist' ) ); ?></option> <?php - if( $data['options']['options'] ) { + if ( $data['options']['options'] ) { foreach ( $data['options']['options'] as $option ) { - printf( '<option value="%s"%s>%s</option>', esc_attr( $option['option_value'] ), esc_attr( selected( $value === $option[ 'option_value' ] ) ), esc_html( $option['option_label'] ) ); + printf( '<option value="%s"%s>%s</option>', esc_attr( $option['option_value'] ), esc_attr( selected( $value === $option['option_value'] ) ), esc_html( $option['option_label'] ) ); } } ?> diff --git a/templates/search-form/custom-fields/text.php b/templates/search-form/custom-fields/text.php index 20b468d188..d9d7aab46a 100644 --- a/templates/search-form/custom-fields/text.php +++ b/templates/search-form/custom-fields/text.php @@ -5,7 +5,9 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group"> diff --git a/templates/search-form/custom-fields/textarea.php b/templates/search-form/custom-fields/textarea.php index 4bd3da2015..765a807d1c 100644 --- a/templates/search-form/custom-fields/textarea.php +++ b/templates/search-form/custom-fields/textarea.php @@ -5,7 +5,9 @@ * @version 6.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group"> diff --git a/templates/search-form/custom-fields/time.php b/templates/search-form/custom-fields/time.php index 04bb704d69..ff87ea4467 100644 --- a/templates/search-form/custom-fields/time.php +++ b/templates/search-form/custom-fields/time.php @@ -5,12 +5,14 @@ * @version 8.0.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group directorist-time"> - <?php if ( !empty($data['label']) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <label class="directorist-search-field__label"><?php echo esc_html( $data['label'] ); ?></label> <?php endif; ?> diff --git a/templates/search-form/custom-fields/url.php b/templates/search-form/custom-fields/url.php index 50fd2b42b3..aeaa7dd6d8 100644 --- a/templates/search-form/custom-fields/url.php +++ b/templates/search-form/custom-fields/url.php @@ -5,7 +5,9 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field single_search_field directorist-form-group search-form-field"> diff --git a/templates/search-form/directory-type-nav.php b/templates/search-form/directory-type-nav.php index 824eee0ada..94317ab43d 100644 --- a/templates/search-form/directory-type-nav.php +++ b/templates/search-form/directory-type-nav.php @@ -5,15 +5,17 @@ * @version 7.7.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <ul class="directorist-listing-type-selection"> - <?php foreach ( $searchform->get_listing_type_data() as $id => $value ): ?> + <?php foreach ( $searchform->get_listing_type_data() as $id => $value ) : ?> - <li class="directorist-listing-type-selection__item"><a class="search_listing_types directorist-listing-type-selection__link<?php echo $searchform->get_default_listing_type() == $id ? '--current': ''; ?>" data-listing_type="<?php echo esc_attr( $value['term']->slug );?>" data-listing_type_id="<?php echo esc_attr( $id );?>" href="#"><?php directorist_icon( $value['data']['icon'] ); ?> <?php echo esc_html( $value['name'] );?></a></li> + <li class="directorist-listing-type-selection__item"><a class="search_listing_types directorist-listing-type-selection__link<?php echo $searchform->get_default_listing_type() == $id ? '--current' : ''; ?>" data-listing_type="<?php echo esc_attr( $value['term']->slug ); ?>" data-listing_type_id="<?php echo esc_attr( $id ); ?>" href="#"><?php directorist_icon( $value['data']['icon'] ); ?> <?php echo esc_html( $value['name'] ); ?></a></li> <?php endforeach; ?> </ul> \ No newline at end of file diff --git a/templates/search-form/fields/category.php b/templates/search-form/fields/category.php index c8c31314ae..9c95493a2f 100644 --- a/templates/search-form/fields/category.php +++ b/templates/search-form/fields/category.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $selected_item = $searchform::get_selected_category_option_data(); ?> <div class="directorist-search-field directorist-form-group <?php echo esc_attr( $empty_label ); ?>"> @@ -15,13 +17,13 @@ <label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label> <?php endif; ?> - <select name="in_cat" class="<?php echo esc_attr($searchform->category_class); ?>" data-placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?> data-isSearch="true" data-selected-id="<?php echo esc_attr( $selected_item['id'] ); ?>" data-selected-label="<?php echo esc_attr( $selected_item['label'] ); ?>"> + <select name="in_cat" class="<?php echo esc_attr( $searchform->category_class ); ?>" data-placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?> data-isSearch="true" data-selected-id="<?php echo esc_attr( $selected_item['id'] ); ?>" data-selected-label="<?php echo esc_attr( $selected_item['label'] ); ?>"> <?php echo '<option value="">' . esc_html__( 'Select Category', 'directorist' ) . '</option>'; - if ( empty( $data['lazy_load'] ) ) { - echo directorist_kses( $searchform->categories_fields, 'form_input' ); - } + if ( empty( $data['lazy_load'] ) ) { + echo directorist_kses( $searchform->categories_fields, 'form_input' ); + } ?> </select> diff --git a/templates/search-form/fields/email.php b/templates/search-form/fields/email.php index b25d3b0a89..38ab4113be 100644 --- a/templates/search-form/fields/email.php +++ b/templates/search-form/fields/email.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group <?php echo esc_attr( $empty_label ); ?>"> diff --git a/templates/search-form/fields/fax.php b/templates/search-form/fields/fax.php index 20f8acc12f..b8e14c32a0 100644 --- a/templates/search-form/fields/fax.php +++ b/templates/search-form/fields/fax.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group <?php echo esc_attr( $empty_label ); ?>"> diff --git a/templates/search-form/fields/location.php b/templates/search-form/fields/location.php index f154b0aa3f..5d32d7a7ca 100644 --- a/templates/search-form/fields/location.php +++ b/templates/search-form/fields/location.php @@ -5,9 +5,11 @@ * @version 8.0.9 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$location_source = !empty($data['location_source']) && $data['location_source'] == 'from_map_api' ? 'map' : 'listing'; +$location_source = ! empty( $data['location_source'] ) && $data['location_source'] == 'from_map_api' ? 'map' : 'listing'; if ( $location_source == 'listing' ) { $selected_item = $searchform::get_selected_location_option_data(); @@ -20,7 +22,7 @@ <label class="directorist-search-field__label"><?php echo esc_attr( $data['label'] ); ?></label> <?php endif; ?> - <select name="in_loc" class="<?php echo esc_attr($searchform->location_class); ?>" data-placeholder="<?php echo esc_attr($data['placeholder']); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?> data-isSearch="true" data-selected-id="<?php echo esc_attr( $selected_item['id'] ); ?>" data-selected-label="<?php echo esc_attr( $selected_item['label'] ); ?>"> + <select name="in_loc" class="<?php echo esc_attr( $searchform->location_class ); ?>" data-placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?> data-isSearch="true" data-selected-id="<?php echo esc_attr( $selected_item['id'] ); ?>" data-selected-label="<?php echo esc_attr( $selected_item['label'] ); ?>"> <?php echo '<option value="">' . esc_html__( 'Select Location', 'directorist' ) . '</option>'; @@ -37,9 +39,7 @@ </div> <?php -} - -elseif ( $location_source == 'map' ) { +} elseif ( $location_source == 'map' ) { $cityLat = isset( $_GET['cityLat'] ) ? sanitize_text_field( wp_unslash( $_GET['cityLat'] ) ) : ''; $cityLng = isset( $_GET['cityLng'] ) ? sanitize_text_field( wp_unslash( $_GET['cityLng'] ) ) : ''; $value = isset( $_GET['address'] ) ? sanitize_text_field( wp_unslash( $_GET['address'] ) ) : ''; @@ -53,8 +53,8 @@ <input type="text" name="address" id="addressId" value="<?php echo esc_attr( $value ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" autocomplete="off" class="directorist-form-element directorist-location-js location-name directorist-search-field__input" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>> <div class="address_result location-names" style="display: none"></div> - <input type="hidden" id="cityLat" name="cityLat" value="<?php echo esc_attr($cityLat); ?>" /> - <input type="hidden" id="cityLng" name="cityLng" value="<?php echo esc_attr($cityLng); ?>" /> + <input type="hidden" id="cityLat" name="cityLat" value="<?php echo esc_attr( $cityLat ); ?>" /> + <input type="hidden" id="cityLng" name="cityLng" value="<?php echo esc_attr( $cityLng ); ?>" /> <div class="directorist-search-field__btn directorist-search-field__btn--clear"> <?php directorist_icon( 'fas fa-times-circle' ); ?> diff --git a/templates/search-form/fields/phone.php b/templates/search-form/fields/phone.php index 272354181e..b0ac9266f9 100644 --- a/templates/search-form/fields/phone.php +++ b/templates/search-form/fields/phone.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group <?php echo esc_attr( $empty_label ); ?>"> diff --git a/templates/search-form/fields/phone2.php b/templates/search-form/fields/phone2.php index 491f3fda29..d7dda5337f 100644 --- a/templates/search-form/fields/phone2.php +++ b/templates/search-form/fields/phone2.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group <?php echo esc_attr( $empty_label ); ?>"> diff --git a/templates/search-form/fields/pricing.php b/templates/search-form/fields/pricing.php index a44142855d..5e49c7e639 100644 --- a/templates/search-form/fields/pricing.php +++ b/templates/search-form/fields/pricing.php @@ -5,11 +5,13 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $ptype = $searchform->get_pricing_type(); -$max_placeholder = !empty( $data['price_range_max_placeholder'] ) ? $data['price_range_max_placeholder'] : ''; -$min_placeholder = !empty( $data['price_range_min_placeholder'] ) ? $data['price_range_min_placeholder'] : ''; +$max_placeholder = ! empty( $data['price_range_max_placeholder'] ) ? $data['price_range_max_placeholder'] : ''; +$min_placeholder = ! empty( $data['price_range_min_placeholder'] ) ? $data['price_range_min_placeholder'] : ''; $label = ! empty( $data['label'] ) ? $data['label'] : __( 'Pricing', 'directorist' ); ?> @@ -24,39 +26,39 @@ <div class="directorist-search-basic-dropdown-content"> <div class="directorist-price-ranges"> - <?php if ( $ptype == 'both' || $ptype == 'price_unit' ): ?> + <?php if ( $ptype == 'both' || $ptype == 'price_unit' ) : ?> <div class="directorist-price-ranges__item directorist-form-group"> - <?php if ( !empty($min_placeholder) ): ?> + <?php if ( ! empty( $min_placeholder ) ) : ?> <label class="directorist-price-ranges__label" for="pricing-slider-range__input-values__min"><?php echo esc_attr( $min_placeholder ); ?></label> <?php endif; ?> <span class="directorist-price-ranges__currency"><?php echo $searchform->c_symbol ?? '$'; ?></span> - <input type="number" name="price[0]" class="directorist-form-element pricing-slider-range__input-values__min" id="pricing-slider-range__input-values__min" placeholder="" value="<?php echo esc_attr( $searchform->price_value('min') ); ?>" min="0"> + <input type="number" name="price[0]" class="directorist-form-element pricing-slider-range__input-values__min" id="pricing-slider-range__input-values__min" placeholder="" value="<?php echo esc_attr( $searchform->price_value( 'min' ) ); ?>" min="0"> </div> <div class="directorist-price-ranges__item directorist-form-group"> - <?php if ( !empty($max_placeholder) ): ?> + <?php if ( ! empty( $max_placeholder ) ) : ?> <label class="directorist-price-ranges__label" for="pricing-slider-range__input-values__max"><?php echo esc_attr( $max_placeholder ); ?></label> <?php endif; ?> <span class="directorist-price-ranges__currency"><?php echo $searchform->c_symbol ?? '$'; ?></span> - <input type="number" name="price[1]" class="directorist-form-element pricing-slider-range__input-values__max" id="pricing-slider-range__input-values__max" placeholder="" value="<?php echo esc_attr( $searchform->price_value('max') ); ?>" min="0"> + <input type="number" name="price[1]" class="directorist-form-element pricing-slider-range__input-values__max" id="pricing-slider-range__input-values__max" placeholder="" value="<?php echo esc_attr( $searchform->price_value( 'max' ) ); ?>" min="0"> </div> <?php endif; ?> - <?php if ( $ptype == 'both' || $ptype == 'price_range' ): ?> + <?php if ( $ptype == 'both' || $ptype == 'price_range' ) : ?> <div class="directorist-price-ranges__item directorist-price-ranges__price-frequency"> <label class="directorist-price-ranges__price-frequency__btn"> - <?php $searchform->the_price_range_input('bellow_economy');?><span class="directorist-pf-range"><?php echo esc_html( str_repeat($searchform->c_symbol, 1) ); ?></span> + <?php $searchform->the_price_range_input( 'bellow_economy' ); ?><span class="directorist-pf-range"><?php echo esc_html( str_repeat( $searchform->c_symbol, 1 ) ); ?></span> </label> <label class="directorist-price-ranges__price-frequency__btn"> - <?php $searchform->the_price_range_input('economy');?><span class="directorist-pf-range"><?php echo esc_html( str_repeat($searchform->c_symbol, 2) ); ?></span> + <?php $searchform->the_price_range_input( 'economy' ); ?><span class="directorist-pf-range"><?php echo esc_html( str_repeat( $searchform->c_symbol, 2 ) ); ?></span> </label> <label class="directorist-price-ranges__price-frequency__btn"> - <?php $searchform->the_price_range_input('moderate');?><span class="directorist-pf-range"><?php echo esc_html( str_repeat($searchform->c_symbol, 3) ); ?></span> + <?php $searchform->the_price_range_input( 'moderate' ); ?><span class="directorist-pf-range"><?php echo esc_html( str_repeat( $searchform->c_symbol, 3 ) ); ?></span> </label> <label class="directorist-price-ranges__price-frequency__btn"> - <?php $searchform->the_price_range_input('skimming');?><span class="directorist-pf-range"><?php echo esc_html( str_repeat($searchform->c_symbol, 4) ); ?></span> + <?php $searchform->the_price_range_input( 'skimming' ); ?><span class="directorist-pf-range"><?php echo esc_html( str_repeat( $searchform->c_symbol, 4 ) ); ?></span> </label> </div> diff --git a/templates/search-form/fields/radius_search.php b/templates/search-form/fields/radius_search.php index 9513b59c24..1a53330dfc 100644 --- a/templates/search-form/fields/radius_search.php +++ b/templates/search-form/fields/radius_search.php @@ -5,7 +5,9 @@ * @version 8.0.2 */ -if (!defined('ABSPATH')) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $min_distance = '0'; $default_distance = $data['default_radius_distance'] ?? 0; @@ -13,25 +15,25 @@ $value = ! empty( $_REQUEST['miles'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['miles'] ) ) : $min_distance . '-' . $max_distance; if ( ! empty( $_REQUEST['miles'] ) ) { - $distance = directorist_get_distance_range( $_REQUEST['miles'] ); + $distance = directorist_get_distance_range( $_REQUEST['miles'] ); $min_distance = $distance['min']; $max_distance = $distance['max']; } ?> <div class="directorist-search-field directorist-search-field-radius_search <?php echo esc_attr( $empty_label ); ?>"> - <?php if (!empty($data['label'])) : ?> - <label><?php echo esc_html($data['label']); ?></label> + <?php if ( ! empty( $data['label'] ) ) : ?> + <label><?php echo esc_html( $data['label'] ); ?></label> <?php endif; ?> <div class="directorist-custom-range-slider"> <div class="directorist-custom-range-slider__range__wrap"> <span class="directorist-custom-range-slider__range__show"></span> - <span><?php echo esc_attr($searchform->range_slider_unit($data)); ?></span> + <span><?php echo esc_attr( $searchform->range_slider_unit( $data ) ); ?></span> </div> - <div class="directorist-custom-range-slider__slide" value="<?php echo esc_attr($default_distance); ?>" max-value="<?php echo esc_attr($max_distance); ?>"></div> + <div class="directorist-custom-range-slider__slide" value="<?php echo esc_attr( $default_distance ); ?>" max-value="<?php echo esc_attr( $max_distance ); ?>"></div> <div class="directorist-custom-range-slider__wrap"> - <input type="hidden" placeholder="Min" value="<?php echo esc_attr($min_distance); ?>" class="directorist-custom-range-slider__radius directorist-custom-range-slider__value__min"> - <input type="hidden" placeholder="Max" value="<?php echo esc_attr($max_distance); ?>" class="directorist-custom-range-slider__radius directorist-custom-range-slider__value__max"> + <input type="hidden" placeholder="Min" value="<?php echo esc_attr( $min_distance ); ?>" class="directorist-custom-range-slider__radius directorist-custom-range-slider__value__min"> + <input type="hidden" placeholder="Max" value="<?php echo esc_attr( $max_distance ); ?>" class="directorist-custom-range-slider__radius directorist-custom-range-slider__value__max"> <input type="hidden" name="miles" class="directorist-custom-range-slider__range" value="<?php echo esc_attr( $value ); ?>"> </div> </div> diff --git a/templates/search-form/fields/review.php b/templates/search-form/fields/review.php index 983d45fd75..5040d37ea3 100644 --- a/templates/search-form/fields/review.php +++ b/templates/search-form/fields/review.php @@ -5,13 +5,15 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-search-field-review directorist-search-form-dropdown directorist-form-group <?php echo esc_attr( $empty_label ); ?>"> <div class="directorist-search-basic-dropdown directorist-search-field__input"> - <?php if ( !empty($data['label']) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <label class="directorist-search-field__label directorist-search-basic-dropdown-label"> <span class="directorist-search-basic-dropdown-selected-prefix"></span> <?php echo esc_html( $data['label'] ); ?> @@ -22,12 +24,13 @@ <div class="directorist-search-basic-dropdown-content"> <div class="directorist-search-review directorist-flex"> <div class="directorist-checkbox directorist-checkbox-rating"> - <?php foreach ( $searchform->rating_field_data() as $option ) { - $uniqid = $option['value'] . '_' .wp_rand(); - ?> + <?php + foreach ( $searchform->rating_field_data() as $option ) { + $uniqid = $option['value'] . '_' . wp_rand(); + ?> <input type="checkbox" name="search_by_rating[]" value="<?php echo esc_attr( $option['value'] ); ?>" id="<?php echo esc_attr( $uniqid ); ?>" <?php echo esc_attr( $option['checked'] ); ?>> <label for="<?php echo esc_attr( $uniqid ); ?>" class="directorist-checkbox__label"> - <?php + <?php directorist_icon( 'fas fa-star', true, 'star-empty' ); directorist_icon( 'fas fa-star', true, 'star-empty' ); directorist_icon( 'fas fa-star', true, 'star-empty' ); diff --git a/templates/search-form/fields/tag.php b/templates/search-form/fields/tag.php index 15977940ed..7023e19bc0 100644 --- a/templates/search-form/fields/tag.php +++ b/templates/search-form/fields/tag.php @@ -5,26 +5,28 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $tag_source = 'all_tags'; $tag_terms = $searchform->listing_tag_terms( $tag_source ); $in_tag = ! empty( $_REQUEST['in_tag'] ) ? $_REQUEST['in_tag'] : ''; if ( is_array( $in_tag ) ) { - $in_tag = array_map( 'sanitize_text_field', wp_unslash( $in_tag) ); + $in_tag = array_map( 'sanitize_text_field', wp_unslash( $in_tag ) ); } else { - $in_tag = array_map( 'sanitize_text_field', explode( ',', wp_unslash( $in_tag ) ) ); + $in_tag = array_map( 'sanitize_text_field', explode( ',', wp_unslash( $in_tag ) ) ); } -if ( !$tag_terms ) { +if ( ! $tag_terms ) { return; } ?> <div class="directorist-search-field directorist-search-form-dropdown directorist-form-group <?php echo esc_attr( $empty_label ); ?>"> <div class="directorist-search-basic-dropdown directorist-search-field__input"> - <?php if ( !empty($data['label']) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <label class="directorist-search-field__label directorist-search-basic-dropdown-label"> <span class="directorist-search-basic-dropdown-selected-prefix"></span> <?php echo esc_html( $data['label'] ); ?> @@ -41,7 +43,7 @@ ?> <div class="directorist-checkbox directorist-checkbox-primary"> - <input type="checkbox" name="in_tag[]" value="<?php echo esc_attr( $term->term_id ); ?>" id="<?php echo esc_attr( $id ); ?>" <?php checked( !empty($_REQUEST['in_tag']) && in_array($term->term_id, $in_tag) ); ?>> + <input type="checkbox" name="in_tag[]" value="<?php echo esc_attr( $term->term_id ); ?>" id="<?php echo esc_attr( $id ); ?>" <?php checked( ! empty( $_REQUEST['in_tag'] ) && in_array( $term->term_id, $in_tag ) ); ?>> <label for="<?php echo esc_attr( $id ); ?>" class="directorist-checkbox__label"><?php echo esc_html( $term->name ); ?></label> </div> diff --git a/templates/search-form/fields/title.php b/templates/search-form/fields/title.php index 0a60c12a48..b583da4127 100644 --- a/templates/search-form/fields/title.php +++ b/templates/search-form/fields/title.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $value = isset( $_GET['q'] ) ? sanitize_text_field( wp_unslash( $_GET['q'] ) ) : ''; ?> diff --git a/templates/search-form/fields/website.php b/templates/search-form/fields/website.php index 9cb4ddd4e7..dc66ab3c06 100644 --- a/templates/search-form/fields/website.php +++ b/templates/search-form/fields/website.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-field directorist-form-group <?php echo esc_attr( $empty_label ); ?>"> diff --git a/templates/search-form/fields/zip.php b/templates/search-form/fields/zip.php index c2f2112f15..3ce3fe80e6 100644 --- a/templates/search-form/fields/zip.php +++ b/templates/search-form/fields/zip.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $lat = ! empty( $_REQUEST['zip_cityLat'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['zip_cityLat'] ) ) : ''; $lng = ! empty( $_REQUEST['zip_cityLng'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['zip_cityLng'] ) ) : ''; ?> @@ -19,8 +21,8 @@ <input class="<?php echo esc_attr( $searchform->zip_code_class() ); ?> directorist-search-field__input" id="<?php echo esc_attr( $data['field_key'] ?? '' ); ?>" type="text" name="<?php echo esc_attr( $data['field_key'] ); ?>" value="<?php echo esc_attr( $value ); ?>" autocomplete="off" placeholder="<?php echo esc_attr( $data['placeholder'] ?? '' ); ?>" <?php echo ! empty( $data['required'] ) ? 'required="required"' : ''; ?>> <div class="directorist-country directorist-search-country" style="display: none"></div> - <input type="hidden" class="zip-cityLat" name="zip_cityLat" value="<?php echo esc_attr( $lat ) ?>" /> - <input type="hidden" class="zip-cityLng" name="zip_cityLng" value="<?php echo esc_attr( $lng ) ?>" /> + <input type="hidden" class="zip-cityLat" name="zip_cityLat" value="<?php echo esc_attr( $lat ); ?>" /> + <input type="hidden" class="zip-cityLng" name="zip_cityLng" value="<?php echo esc_attr( $lng ); ?>" /> <div class="directorist-search-field__btn directorist-search-field__btn--clear"> <?php directorist_icon( 'fas fa-times-circle' ); ?> diff --git a/templates/search-form/form-box.php b/templates/search-form/form-box.php index 8221baa2f5..d54dcf6e10 100644 --- a/templates/search-form/form-box.php +++ b/templates/search-form/form-box.php @@ -5,15 +5,17 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-form__box"> <div class="directorist-search-form-top directorist-flex directorist-align-center directorist-search-form-inline directorist-search-form__top directorist-search-modal directorist-search-modal--basic"> - <?php $searchform->advanced_search_form_basic_fields_template();?> + <?php $searchform->advanced_search_form_basic_fields_template(); ?> </div> <?php $searchform->more_buttons_template(); @@ -26,11 +28,11 @@ <?php directorist_icon( 'las la-search' ); ?> - <?php echo esc_html( $searchform->search_button_text );?> + <?php echo esc_html( $searchform->search_button_text ); ?> </a> - <?php if ( $searchform->has_more_filters_button ): ?> + <?php if ( $searchform->has_more_filters_button ) : ?> <a href="#" class="directorist-search-form-action__modal__btn-advanced directorist-modal-btn directorist-modal-btn--advanced"> <?php directorist_icon( 'fas fa-sliders-h' ); ?> diff --git a/templates/search-form/more-buttons.php b/templates/search-form/more-buttons.php index 000c6c4577..8271d8ebdc 100644 --- a/templates/search-form/more-buttons.php +++ b/templates/search-form/more-buttons.php @@ -5,35 +5,37 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-search-form-action"> - <?php if ( $searchform->has_more_filters_button ): ?> + <?php if ( $searchform->has_more_filters_button ) : ?> <div class="directorist-search-form-action__filter"> <a href="#" class="directorist-btn directorist-btn-lg directorist-filter-btn directorist-modal-btn directorist-modal-btn--advanced"> - <?php if ( $searchform->has_more_filters_icon() ): ?> + <?php if ( $searchform->has_more_filters_icon() ) : ?> <?php directorist_icon( 'fas fa-filter' ); ?> - <?php endif;?> + <?php endif; ?> - <?php echo esc_html( $searchform->more_filters_text );?> + <?php echo esc_html( $searchform->more_filters_text ); ?> </a> </div> <?php endif ?> - <?php if ( $searchform->has_search_button ): ?> + <?php if ( $searchform->has_search_button ) : ?> <div class="directorist-search-form-action__submit"> <button type="submit" class="directorist-btn directorist-btn-lg directorist-btn-primary directorist-btn-search"> - <?php if ( $searchform->has_search_button_icon() ): ?> + <?php if ( $searchform->has_search_button_icon() ) : ?> <?php directorist_icon( 'las la-search' ); ?> - <?php endif;?> + <?php endif; ?> - <?php echo esc_html( $searchform->search_button_text );?> + <?php echo esc_html( $searchform->search_button_text ); ?> </button> </div> diff --git a/templates/search-form/top-cats.php b/templates/search-form/top-cats.php index e8b3b47c70..b06720daa6 100644 --- a/templates/search-form/top-cats.php +++ b/templates/search-form/top-cats.php @@ -5,7 +5,9 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-listing-category-top"> @@ -13,7 +15,7 @@ <h3><?php echo esc_html( $title ); ?></h3> <ul> - <?php foreach ( $top_categories as $cat ): ?> + <?php foreach ( $top_categories as $cat ) : ?> <li> <a href="<?php echo esc_url( ATBDP_Permalink::atbdp_get_category_page( $cat ) ); ?>"> diff --git a/templates/sidebar-archive-contents.php b/templates/sidebar-archive-contents.php index 657b6d8227..6c43b73180 100644 --- a/templates/sidebar-archive-contents.php +++ b/templates/sidebar-archive-contents.php @@ -5,10 +5,17 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<div <?php $listings->wrapper_class(); $listings->data_atts(); ?>> +<div +<?php +$listings->wrapper_class(); +$listings->data_atts(); +?> +> <div class="listing-with-sidebar"> <div class="directorist-container"> <div class="listing-with-sidebar__wrapper"> @@ -18,7 +25,7 @@ ?> </div> - <?php if( ! $listings->hide_top_search_bar_on_sidebar_layout() ) : ?> + <?php if ( ! $listings->hide_top_search_bar_on_sidebar_layout() ) : ?> <div class="listing-with-sidebar__searchform"> <?php @@ -28,7 +35,7 @@ <?php endif; ?> - <?php if( $listings->header ) : ?> + <?php if ( $listings->header ) : ?> <div class="listing-with-sidebar__header"> <?php diff --git a/templates/single-contents.php b/templates/single-contents.php index fddc5ee93e..7e41b35ebc 100644 --- a/templates/single-contents.php +++ b/templates/single-contents.php @@ -5,15 +5,17 @@ * @version 8.0 */ -use \Directorist\Directorist_Single_Listing; -use \Directorist\Helper; +use Directorist\Directorist_Single_Listing; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $listing = Directorist_Single_Listing::instance(); ?> -<div class="directorist-single-contents-area directorist-w-100" data-id="<?php echo esc_attr( $listing->id ?? ''); ?>"> +<div class="directorist-single-contents-area directorist-w-100" data-id="<?php echo esc_attr( $listing->id ?? '' ); ?>"> <div class="<?php Helper::directorist_container_fluid(); ?>"> <?php $listing->notice_template(); ?> @@ -21,13 +23,14 @@ <div class="<?php Helper::directorist_single_column(); ?>"> - <?php - - $disable_single_listing = get_directorist_option( 'disable_single_listing') ? true : false; + <?php - if( !$disable_single_listing ){ ?> + $disable_single_listing = get_directorist_option( 'disable_single_listing' ) ? true : false; - <?php if ( $listing->single_page_enabled() ): ?> + if ( ! $disable_single_listing ) { + ?> + + <?php if ( $listing->single_page_enabled() ) : ?> <div class="directorist-single-wrapper"> @@ -39,7 +42,7 @@ </div> - <?php else: ?> + <?php else : ?> <div class="directorist-single-wrapper"> diff --git a/templates/single-reviews.php b/templates/single-reviews.php index 676edd5133..0fd9786b51 100644 --- a/templates/single-reviews.php +++ b/templates/single-reviews.php @@ -33,8 +33,15 @@ ?> <section id="<?php echo esc_attr( $section_id ); ?>" class="directorist-review-container <?php echo esc_attr( $section_class ); ?>"> <div class="directorist-card directorist-review-content"> - <div class="directorist-card__header directorist-review-content__header <?php if ( ! have_comments() ) : ?>directorist-review-content__header--noreviews<?php endif;?>"> - <?php if ( ! have_comments() ) : ?><?php endif;?> + <div class="directorist-card__header directorist-review-content__header + <?php + if ( ! have_comments() ) : + ?> + directorist-review-content__header--noreviews<?php endif; ?>"> + <?php + if ( ! have_comments() ) : + ?> + <?php endif; ?> <h3 class="directorist-card__header__title"> <?php if ( ! empty( $section_icon ) ) : ?> <span class="directorist-card__header-icon"><?php directorist_icon( $section_icon ); ?> </span> @@ -45,7 +52,18 @@ <?php if ( directorist_can_current_user_review() || directorist_can_guest_review() ) : ?> <a href="#respond" rel="nofollow" class="directorist-btn"><?php directorist_icon( 'las la-star' ); ?><?php esc_attr_e( 'Write a Review', 'directorist' ); ?></a> <?php elseif ( ! is_user_logged_in() ) : ?> - <a href="<?php echo esc_url( ATBDP_Permalink::get_login_page_url( array( 'redirect' => get_the_permalink(), 'scope' => 'review' ) ) ); ?>" rel="nofollow" class="directorist-btn"><?php directorist_icon( 'las la-star' ); ?><?php esc_attr_e( 'Login to Write Your Review', 'directorist' ); ?></a> + <a href=" + <?php + echo esc_url( + ATBDP_Permalink::get_login_page_url( + array( + 'redirect' => get_the_permalink(), + 'scope' => 'review', + ) + ) + ); + ?> + " rel="nofollow" class="directorist-btn"><?php directorist_icon( 'las la-star' ); ?><?php esc_attr_e( 'Login to Write Your Review', 'directorist' ); ?></a> <?php endif; ?> </div><!-- ends: .directorist-review-content__header --> @@ -53,27 +71,31 @@ <div class="directorist-card__body"> <p class="directorist-review-single directorist-noreviews"><?php esc_html_e( 'There are no reviews yet.', 'directorist' ); ?></p> </div> - <?php endif;?> + <?php endif; ?> - <?php if ( have_comments() ): ?> + <?php if ( have_comments() ) : ?> <div class="directorist-card__body directorist-review-content__overview"> <div class="directorist-review-content__overview__rating"> <div class="directorist-rating-point"><?php echo esc_html( $review_rating ); ?></div> <div class="directorist-rating-content"> - <span class="directorist-rating-stars"><?php Markup::show_rating_stars( $review_rating );?></span> - <span class="directorist-rating-overall"><?php echo esc_html( $review_text );?></span> + <span class="directorist-rating-stars"><?php Markup::show_rating_stars( $review_rating ); ?></span> + <span class="directorist-rating-overall"><?php echo esc_html( $review_text ); ?></span> </div> </div> </div><!-- ends: .directorist-review-content__overview --> <ul class="commentlist directorist-review-content__reviews"> - <?php wp_list_comments( array( - 'avatar_size' => 50, - 'format' => 'html5', - 'walker' => new Review_Walker(), - ) );?> + <?php + wp_list_comments( + array( + 'avatar_size' => 50, + 'format' => 'html5', + 'walker' => new Review_Walker(), + ) + ); + ?> </ul> - <?php endif;?> + <?php endif; ?> </div><!-- ends: .directorist-review-content --> <?php if ( get_comment_pages_count() > 1 ) : ?> @@ -81,15 +103,17 @@ <?php $prev_text = directorist_icon( 'las la-arrow-left', false ); $next_text = directorist_icon( 'las la-arrow-right', false ); - paginate_comments_links( array( - 'prev_text' => $prev_text, - 'next_text' => $next_text, - 'type' => 'plain', - 'add_fragment' => '#' . $section_id, - ) ); + paginate_comments_links( + array( + 'prev_text' => $prev_text, + 'next_text' => $next_text, + 'type' => 'plain', + 'add_fragment' => '#' . $section_id, + ) + ); ?> </nav> - <?php endif;?> + <?php endif; ?> <?php if ( is_user_logged_in() || directorist_is_guest_review_enabled() || directorist_is_review_reply_enabled() ) { @@ -144,12 +168,13 @@ $fields['cookies'] = ''; } - $comment_fields = array(); + $comment_fields = array(); $comment_fields['rating'] = '<div class="directorist-review-criteria">' . Markup::get_rating( 0 ) . '</div>'; $comment_fields['content'] = sprintf( '<div class="directorist-form-group form-group-comment">%s</div>', - sprintf( '<textarea id="comment" class="directorist-form-element" placeholder="%s" name="comment" cols="30" rows="10" maxlength="65525" required="required"></textarea>', + sprintf( + '<textarea id="comment" class="directorist-form-element" placeholder="%s" name="comment" cols="30" rows="10" maxlength="65525" required="required"></textarea>', $builder->get_comment_placeholder( __( 'Share your experience and help others make better choices', 'directorist' ) ) ) ); diff --git a/templates/single-sidebar.php b/templates/single-sidebar.php index c83fcca454..fd88e50f29 100644 --- a/templates/single-sidebar.php +++ b/templates/single-sidebar.php @@ -5,16 +5,18 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -if ( !is_active_sidebar( 'right-sidebar-listing' ) ) { +if ( ! is_active_sidebar( 'right-sidebar-listing' ) ) { return; } ?> -<div class="<?php Helper::directorist_column('lg-4'); ?>"> +<div class="<?php Helper::directorist_column( 'lg-4' ); ?>"> <div class="directorist-sidebar"> <?php dynamic_sidebar( 'right-sidebar-listing' ); ?> diff --git a/templates/single.php b/templates/single.php index 6718d814b2..f85bbc6fae 100644 --- a/templates/single.php +++ b/templates/single.php @@ -5,9 +5,11 @@ * @version 6.7 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} get_header( 'directorist' ); ?> diff --git a/templates/single/custom-fields/checkbox.php b/templates/single/custom-fields/checkbox.php index 94d64717a3..823f199feb 100644 --- a/templates/single/custom-fields/checkbox.php +++ b/templates/single/custom-fields/checkbox.php @@ -5,7 +5,9 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $value = $listing->get_custom_field_value( 'checkbox', $data ); ?> @@ -13,7 +15,7 @@ <div class="directorist-single-info directorist-single-info-checkbox"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/custom-fields/color_picker.php b/templates/single/custom-fields/color_picker.php index 956cc568e8..cbf40e8a5d 100644 --- a/templates/single/custom-fields/color_picker.php +++ b/templates/single/custom-fields/color_picker.php @@ -5,13 +5,15 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-picker"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/custom-fields/date.php b/templates/single/custom-fields/date.php index 525168800a..741f0bb95a 100644 --- a/templates/single/custom-fields/date.php +++ b/templates/single/custom-fields/date.php @@ -5,13 +5,15 @@ * @version 7.10.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-date"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/custom-fields/file.php b/templates/single/custom-fields/file.php index 0b3bae478b..07704879c8 100644 --- a/templates/single/custom-fields/file.php +++ b/templates/single/custom-fields/file.php @@ -5,9 +5,11 @@ * @version 7.3.1 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$done = str_replace( '|||', '', $value ); +$done = str_replace( '|||', '', $value ); $name_arr = explode( '/', $done ); $filename = end( $name_arr ); ?> @@ -15,10 +17,10 @@ <div class="directorist-single-info directorist-single-info-file"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> - <div class="directorist-single-info__value"><?php printf('<a href="%s" target="_blank" download>%s</a>', esc_url( $done ), esc_html( $filename ) ); ?></div> + <div class="directorist-single-info__value"><?php printf( '<a href="%s" target="_blank" download>%s</a>', esc_url( $done ), esc_html( $filename ) ); ?></div> </div> \ No newline at end of file diff --git a/templates/single/custom-fields/number.php b/templates/single/custom-fields/number.php index 0f09d5cb1a..ce8bc9a46b 100644 --- a/templates/single/custom-fields/number.php +++ b/templates/single/custom-fields/number.php @@ -5,24 +5,26 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-number"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> <div class="directorist-form-group__with-prefix"> - <?php if( ! empty( $data['form_data']['prepend'] ) ) : ?> + <?php if ( ! empty( $data['form_data']['prepend'] ) ) : ?> <span class="directorist-form-group__prefix directorist-form-group__prefix--start"><?php echo esc_html( $data['form_data']['prepend'] ); ?></span> <?php endif; ?> <div class="directorist-single-info__value"><?php echo esc_html( $value ); ?></div> - <?php if( ! empty( $data['form_data']['append'] ) ) : ?> + <?php if ( ! empty( $data['form_data']['append'] ) ) : ?> <span class="directorist-form-group__prefix directorist-form-group__prefix--end"><?php echo esc_html( $data['form_data']['append'] ); ?></span> <?php endif; ?> </div> diff --git a/templates/single/custom-fields/radio.php b/templates/single/custom-fields/radio.php index b21a0bd1a1..ad57e49d0f 100644 --- a/templates/single/custom-fields/radio.php +++ b/templates/single/custom-fields/radio.php @@ -5,7 +5,9 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $value = $listing->get_custom_field_value( 'radio', $data ); ?> @@ -13,7 +15,7 @@ <div class="directorist-single-info directorist-single-info-radio"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/custom-fields/select.php b/templates/single/custom-fields/select.php index 803f0434e8..11a88c2520 100644 --- a/templates/single/custom-fields/select.php +++ b/templates/single/custom-fields/select.php @@ -5,7 +5,9 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $value = $listing->get_custom_field_value( 'select', $data ); ?> @@ -13,7 +15,7 @@ <div class="directorist-single-info directorist-single-info-select"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/custom-fields/text.php b/templates/single/custom-fields/text.php index 6ff4aa2437..0816f9fa32 100644 --- a/templates/single/custom-fields/text.php +++ b/templates/single/custom-fields/text.php @@ -5,13 +5,15 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-text"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/custom-fields/textarea.php b/templates/single/custom-fields/textarea.php index 15a6f0b420..4031ae6e07 100644 --- a/templates/single/custom-fields/textarea.php +++ b/templates/single/custom-fields/textarea.php @@ -5,13 +5,15 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-textarea"> <?php if ( ! empty( $data['label'] ) ) : ?> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> <?php endif; ?> diff --git a/templates/single/custom-fields/time.php b/templates/single/custom-fields/time.php index 240e9018ed..b0a7fdb45d 100644 --- a/templates/single/custom-fields/time.php +++ b/templates/single/custom-fields/time.php @@ -5,13 +5,15 @@ * @version 7.10.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-time"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/custom-fields/url.php b/templates/single/custom-fields/url.php index 4b370310e2..d930772da3 100644 --- a/templates/single/custom-fields/url.php +++ b/templates/single/custom-fields/url.php @@ -5,16 +5,18 @@ * @version 7.10.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-url"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> - <div class="directorist-single-info__value"><a <?php echo ! empty( $data['form_data']['target'] ) ? esc_attr( 'target="_blank"' ) : ''; ?> href="<?php echo esc_url( $value ); ?>" <?php echo !empty( $data['use_nofollow'] ) ? 'rel="nofollow"' : ''; ?>><?php echo esc_html( $value ); ?></a></div> + <div class="directorist-single-info__value"><a <?php echo ! empty( $data['form_data']['target'] ) ? esc_attr( 'target="_blank"' ) : ''; ?> href="<?php echo esc_url( $value ); ?>" <?php echo ! empty( $data['use_nofollow'] ) ? 'rel="nofollow"' : ''; ?>><?php echo esc_html( $value ); ?></a></div> </div> \ No newline at end of file diff --git a/templates/single/fields/address.php b/templates/single/fields/address.php index 6eb4515ec3..2b2e3c9481 100644 --- a/templates/single/fields/address.php +++ b/templates/single/fields/address.php @@ -5,16 +5,18 @@ * @version 7.3.1 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $address_data = $listing->get_address( $data ); -$address = ( is_string( $address_data ) ) ? $address_data : ''; +$address = ( is_string( $address_data ) ) ? $address_data : ''; ?> <div class="directorist-single-info directorist-single-info-address"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo ( isset( $data['label'] ) ) ? esc_html( $data['label'] ) : ''; ?></span> </div> diff --git a/templates/single/fields/badges.php b/templates/single/fields/badges.php index 817b2209aa..a6ad20b654 100644 --- a/templates/single/fields/badges.php +++ b/templates/single/fields/badges.php @@ -5,29 +5,31 @@ * @version 6.7 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -if ( !$listing->has_badge( $data ) ) { +if ( ! $listing->has_badge( $data ) ) { return; } ?> <div class="directorist-info-item directorist-info-item-badges"> - <?php if ( $listing->display_new_badge( $data ) ): ?> + <?php if ( $listing->display_new_badge( $data ) ) : ?> <span class="directorist-badge directorist-badge-new"><?php echo esc_html( Helper::new_badge_text() ); ?></span> <?php endif; ?> - <?php if ( $listing->display_featured_badge( $data ) ): ?> + <?php if ( $listing->display_featured_badge( $data ) ) : ?> <span class="directorist-badge directorist-badge-featured "> <?php echo esc_html( Helper::featured_badge_text() ); ?> </span> <?php endif; ?> - <?php if ( $listing->display_popular_badge( $data ) ): ?> + <?php if ( $listing->display_popular_badge( $data ) ) : ?> <span class="directorist-badge directorist-badge-popular"><?php echo esc_html( Helper::popular_badge_text() ); ?></span> <?php endif; ?> diff --git a/templates/single/fields/bookmark.php b/templates/single/fields/bookmark.php index e8e03be089..cf0434c0fe 100644 --- a/templates/single/fields/bookmark.php +++ b/templates/single/fields/bookmark.php @@ -5,8 +5,10 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <button class="directorist-single-listing-action directorist-action-bookmark directorist-btn directorist-btn-sm directorist-btn-light atbdp-favourites <?php echo ! is_user_logged_in() ? 'atbdp-require-login' : ''; ?>" data-listing_id="<?php echo esc_attr( get_the_ID() ); ?>" aria-label="Add to Favorite Button"> - <?php echo wp_kses_post( the_atbdp_favourites_link( get_the_ID() ) ); ?> + <?php echo wp_kses_post( the_atbdp_favourites_link( get_the_ID() ) ); ?> </button> \ No newline at end of file diff --git a/templates/single/fields/category.php b/templates/single/fields/category.php index b7d47bf09c..5c8425eca2 100644 --- a/templates/single/fields/category.php +++ b/templates/single/fields/category.php @@ -5,7 +5,9 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} if ( empty( $listing->get_cat_list() ) ) { return; diff --git a/templates/single/fields/custom_content.php b/templates/single/fields/custom_content.php index f3894b5869..d4757e7382 100644 --- a/templates/single/fields/custom_content.php +++ b/templates/single/fields/custom_content.php @@ -5,15 +5,17 @@ * @version 7.0.5 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-custom"> - <?php if ( !empty( $data['label'] ) ): ?> + <?php if ( ! empty( $data['label'] ) ) : ?> <div class="directorist-single-info__label"> - <?php if ( $icon ): ?> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <?php if ( $icon ) : ?> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <?php endif; ?> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/fields/description.php b/templates/single/fields/description.php index 5d557b92af..0fe35b9a54 100644 --- a/templates/single/fields/description.php +++ b/templates/single/fields/description.php @@ -5,8 +5,10 @@ * @version 7.7 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-listing-details__text"> - <?php echo wp_kses_post( $listing->get_contents() ); ?> + <?php echo wp_kses_post( $listing->get_contents() ); ?> </div> \ No newline at end of file diff --git a/templates/single/fields/email.php b/templates/single/fields/email.php index 34c0df4b9d..0411864027 100644 --- a/templates/single/fields/email.php +++ b/templates/single/fields/email.php @@ -5,13 +5,15 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-email"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/fields/fax.php b/templates/single/fields/fax.php index f1b54b8427..cf4a0a8de5 100644 --- a/templates/single/fields/fax.php +++ b/templates/single/fields/fax.php @@ -5,15 +5,17 @@ * @version 7.0.5.2 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-fax"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/fields/image_upload.php b/templates/single/fields/image_upload.php index 8508ff2300..f2bed5d969 100644 --- a/templates/single/fields/image_upload.php +++ b/templates/single/fields/image_upload.php @@ -5,6 +5,8 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$listing->slider_field_template( $data ); \ No newline at end of file +$listing->slider_field_template( $data ); diff --git a/templates/single/fields/location.php b/templates/single/fields/location.php index f86a6ae8c9..599d330c96 100644 --- a/templates/single/fields/location.php +++ b/templates/single/fields/location.php @@ -5,7 +5,9 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} if ( empty( $listing->get_location_list() ) ) { return; diff --git a/templates/single/fields/map-favorite-badge.php b/templates/single/fields/map-favorite-badge.php index 9f8ed5eeaf..b711e101b9 100644 --- a/templates/single/fields/map-favorite-badge.php +++ b/templates/single/fields/map-favorite-badge.php @@ -5,13 +5,15 @@ * @version 8.0.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$fav_class = $listings->loop_is_favourite() ? 'directorist-added-to-favorite' : ''; +$fav_class = $listings->loop_is_favourite() ? 'directorist-added-to-favorite' : ''; ?> <div class="directorist-mark-as-favorite"> - <button class="directorist-mark-as-favorite__btn <?php echo esc_attr( $fav_class ); ?> directorist-fav_<?php echo esc_attr( $listings->id ); ?>" data-listing_id="<?php echo esc_attr( $listings->id ); ?>" aria-label="Add to Favorite Button"> + <button class="directorist-mark-as-favorite__btn <?php echo esc_attr( $fav_class ); ?> directorist-fav_<?php echo esc_attr( $listings->id ); ?>" data-listing_id="<?php echo esc_attr( $listings->id ); ?>" aria-label="Add to Favorite Button"> <span class="directorist-favorite-icon"></span> <span class="directorist-favorite-tooltip"></span> </button> diff --git a/templates/single/fields/map-rating.php b/templates/single/fields/map-rating.php index d62e9f0ed2..4902075d4a 100644 --- a/templates/single/fields/map-rating.php +++ b/templates/single/fields/map-rating.php @@ -5,7 +5,9 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} // Return early when review is disabled. if ( ! directorist_is_review_enabled() ) { @@ -13,7 +15,7 @@ } ?> <span class="directorist-info-item directorist-rating-meta directorist-rating-transparent"> - <?php echo wp_kses_post( $review_stars ); ?> - <span class="directorist-rating-avg"><?php echo esc_html( $average_reviews ); ?></span> - <span class="directorist-total-review">(<?php echo esc_html( $total_reviews ) ?>)</span> + <?php echo wp_kses_post( $review_stars ); ?> + <span class="directorist-rating-avg"><?php echo esc_html( $average_reviews ); ?></span> + <span class="directorist-total-review">(<?php echo esc_html( $total_reviews ); ?>)</span> </span> diff --git a/templates/single/fields/map.php b/templates/single/fields/map.php index a35936cd53..39b7b2d614 100644 --- a/templates/single/fields/map.php +++ b/templates/single/fields/map.php @@ -5,19 +5,21 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-map" data-map="<?php echo esc_attr( $listing->map_data() ); ?>"></div> <div class="directorist-single-map__location"> - <?php if( ! empty( $display_address_map ) && ! empty( $address) ) : ?> + <?php if ( ! empty( $display_address_map ) && ! empty( $address ) ) : ?> - <div class="directorist-single-map__address"><?php echo directorist_icon('fas fa-map-marker-alt') ?> <?php echo $address ?></div> + <div class="directorist-single-map__address"><?php echo directorist_icon( 'fas fa-map-marker-alt' ); ?> <?php echo $address; ?></div> - <?php endif; ?> + <?php endif; ?> - <?php if( ! empty( $display_direction_map ) && ! empty( $manual_lat ) && ! empty( $manual_lng ) ) : ?> - <div class='directorist-single-map__direction'> - <a href='http://www.google.com/maps?daddr=<?php echo esc_attr( $manual_lat ); ?>, <?php echo esc_attr( $manual_lng ); ?>' target='_blank'><?php echo directorist_icon('fas fa-paper-plane')?> <?php esc_html_e('Get Directions', 'directorist'); ?></a> - </div> - <?php endif; ?> + <?php if ( ! empty( $display_direction_map ) && ! empty( $manual_lat ) && ! empty( $manual_lng ) ) : ?> + <div class='directorist-single-map__direction'> + <a href='http://www.google.com/maps?daddr=<?php echo esc_attr( $manual_lat ); ?>, <?php echo esc_attr( $manual_lng ); ?>' target='_blank'><?php echo directorist_icon( 'fas fa-paper-plane' ); ?> <?php esc_html_e( 'Get Directions', 'directorist' ); ?></a> + </div> + <?php endif; ?> </div> diff --git a/templates/single/fields/phone.php b/templates/single/fields/phone.php index 889be31190..ca090d19ca 100644 --- a/templates/single/fields/phone.php +++ b/templates/single/fields/phone.php @@ -5,19 +5,21 @@ * @version 7.0.6 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $phone_args = array( - 'number' => $value, - 'whatsapp' => $listing->has_whatsapp( $data ), + 'number' => $value, + 'whatsapp' => $listing->has_whatsapp( $data ), ); ?> <div class="directorist-single-info directorist-single-info-phone"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/fields/phone2.php b/templates/single/fields/phone2.php index 475c21d9bc..8e353f58e4 100644 --- a/templates/single/fields/phone2.php +++ b/templates/single/fields/phone2.php @@ -5,19 +5,21 @@ * @version 7.0.6 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $phone_args = array( - 'number' => $value, - 'whatsapp' => $listing->has_whatsapp( $data ), + 'number' => $value, + 'whatsapp' => $listing->has_whatsapp( $data ), ); ?> <div class="directorist-single-info directorist-single-info-phone2"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/fields/price.php b/templates/single/fields/price.php index 4215635ab1..c47bbd6387 100644 --- a/templates/single/fields/price.php +++ b/templates/single/fields/price.php @@ -5,13 +5,15 @@ * @version 7.0.5.2 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $id = $listing->id; -if ( !Helper::has_price_range( $id ) && !Helper::has_price( $id ) ) { +if ( ! Helper::has_price_range( $id ) && ! Helper::has_price( $id ) ) { return; } ?> @@ -20,9 +22,7 @@ <?php if ( 'range' === Helper::pricing_type( $id ) ) { Helper::price_range_template( $id ); - } - - else { + } else { Helper::price_template( $id ); } ?> diff --git a/templates/single/fields/ratings_count.php b/templates/single/fields/ratings_count.php index c9940889fb..d4f6eaab64 100644 --- a/templates/single/fields/ratings_count.php +++ b/templates/single/fields/ratings_count.php @@ -5,7 +5,9 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} // Return early when review is disabled. if ( ! directorist_is_review_enabled() ) { @@ -18,7 +20,7 @@ <span class="directorist-info-item directorist-rating-meta directorist-info-item-rating"> - <?php directorist_icon( 'las la-star' ); ?><?php echo esc_html( $listing->get_rating_count() );?> + <?php directorist_icon( 'las la-star' ); ?><?php echo esc_html( $listing->get_rating_count() ); ?> <span class="directorist-review"><?php echo esc_html( $review_text ); ?></span> diff --git a/templates/single/fields/report.php b/templates/single/fields/report.php index c417605038..461c12ad79 100644 --- a/templates/single/fields/report.php +++ b/templates/single/fields/report.php @@ -5,15 +5,17 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<?php if ( is_user_logged_in() ): ?> +<?php if ( is_user_logged_in() ) : ?> <button class="directorist-single-listing-action directorist-btn directorist-btn-sm directorist-btn-light directorist-action-report directorist-action-report-loggedin directorist-btn-modal directorist-btn-modal-js" href="#" data-directorist_target="directorist-report-abuse-modal" aria-label="Report Open Modal"> - <?php directorist_icon( $icon );?><span class="directorist-single-listing-action__text"><?php esc_html_e( 'Report', 'directorist'); ?></span> + <?php directorist_icon( $icon ); ?><span class="directorist-single-listing-action__text"><?php esc_html_e( 'Report', 'directorist' ); ?></span> </button> -<?php else: ?> - <button class="directorist-single-listing-action directorist-btn directorist-btn-sm directorist-btn-light directorist-action-report directorist-action-report-not-loggedin directorist-btn-modal directorist-btn-modal-js"><?php directorist_icon( $icon );?> <span class="directorist-single-listing-action__text" aria-label="Report Modal"> <?php esc_html_e( 'Report', 'directorist'); ?></span></button> +<?php else : ?> + <button class="directorist-single-listing-action directorist-btn directorist-btn-sm directorist-btn-light directorist-action-report directorist-action-report-not-loggedin directorist-btn-modal directorist-btn-modal-js"><?php directorist_icon( $icon ); ?> <span class="directorist-single-listing-action__text" aria-label="Report Modal"> <?php esc_html_e( 'Report', 'directorist' ); ?></span></button> <?php endif; ?> <section class="directorist-modal directorist-modal-js directorist-fade directorist-report-abuse-modal"> @@ -26,7 +28,7 @@ <header class="directorist-modal__header"> - <div class="directorist-modal-title" id="directorist-report-abuse-modal__label"><?php esc_html_e('Report Abuse', 'directorist'); ?></div> + <div class="directorist-modal-title" id="directorist-report-abuse-modal__label"><?php esc_html_e( 'Report Abuse', 'directorist' ); ?></div> <button class="directorist-modal-close directorist-modal-close-js" aria-label="Report Modal Close"> <span aria-hidden="true">×</span> diff --git a/templates/single/fields/reviews.php b/templates/single/fields/reviews.php index 77bab45efb..2f8882323d 100644 --- a/templates/single/fields/reviews.php +++ b/templates/single/fields/reviews.php @@ -5,7 +5,9 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} // Return early when review is disabled. if ( ! directorist_is_review_enabled() ) { @@ -16,4 +18,4 @@ $review_text = sprintf( _nx( '%s Review', '%s Reviews', $count, 'Review count single template', 'directorist' ), $count ); ?> -<!-- <span class="directorist-info-item directorist-review-meta directorist-info-item-review"><?php //echo esc_html( $review_text ); ?></span> --> +<!-- <span class="directorist-info-item directorist-review-meta directorist-info-item-review"><?php // echo esc_html( $review_text ); ?></span> --> diff --git a/templates/single/fields/share.php b/templates/single/fields/share.php index 540f3b331b..b7f392bb6c 100644 --- a/templates/single/fields/share.php +++ b/templates/single/fields/share.php @@ -5,19 +5,21 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-listing-action directorist-social-share directorist-btn directorist-btn-sm directorist-btn-light"> - <?php directorist_icon( 'las la-share-square' );?> + <?php directorist_icon( 'las la-share-square' ); ?> - <?php esc_html_e( 'Share', 'directorist'); ?> + <?php esc_html_e( 'Share', 'directorist' ); ?> <ul class="directorist-social-share-links"> - <?php foreach ( $listing->social_share_data() as $social ): ?> + <?php foreach ( $listing->social_share_data() as $social ) : ?> <li class="directorist-social-links__item"> - <a href="<?php echo esc_url( $social['link'] ? $social['link'] : '#' );?>" target="_blank" class="<?php echo esc_attr( $social['icon'] ); ?>"><?php directorist_icon( $social['icon'] ); ?><?php echo esc_html( $social['title'] );?></a> + <a href="<?php echo esc_url( $social['link'] ? $social['link'] : '#' ); ?>" target="_blank" class="<?php echo esc_attr( $social['icon'] ); ?>"><?php directorist_icon( $social['icon'] ); ?><?php echo esc_html( $social['title'] ); ?></a> </li> <?php endforeach; ?> </ul> diff --git a/templates/single/fields/social_info.php b/templates/single/fields/social_info.php index c2d7fe7bea..00fac819fa 100644 --- a/templates/single/fields/social_info.php +++ b/templates/single/fields/social_info.php @@ -5,7 +5,9 @@ * @version 7.4.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $socials = $listing->get_socials(); @@ -16,15 +18,15 @@ <div class="directorist-single-info directorist-single-info-socials"> - <?php if ( $data['label'] ): ?> + <?php if ( $data['label'] ) : ?> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> <?php endif; ?> <div class="directorist-social-links"> - <?php foreach ( $socials as $social ): ?> + <?php foreach ( $socials as $social ) : ?> <?php $icon = 'lab la-' . $social['id']; ?> <a target='_blank' href="<?php echo esc_url( $social['url'] ); ?>" class="<?php echo esc_attr( $social['id'] ); ?>"> <?php directorist_icon( $icon ); ?> diff --git a/templates/single/fields/tag.php b/templates/single/fields/tag.php index 7b3ae7b581..ca5644b685 100644 --- a/templates/single/fields/tag.php +++ b/templates/single/fields/tag.php @@ -5,7 +5,9 @@ * @version 7.5.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} if ( empty( $listing->get_tags() ) ) { return; @@ -14,7 +16,7 @@ <ul class="directorist-single-tag-list"> - <?php foreach ( $listing->get_tags() as $tag ): ?> + <?php foreach ( $listing->get_tags() as $tag ) : ?> <li> <a href="<?php echo esc_url( get_term_link( $tag->term_id, ATBDP_TAGS ) ); ?>"><?php directorist_icon( $icon ); ?> <?php echo esc_html( $tag->name ); ?></a> diff --git a/templates/single/fields/user_avatar.php b/templates/single/fields/user_avatar.php index 7df3bf0e3e..5128871a3b 100644 --- a/templates/single/fields/user_avatar.php +++ b/templates/single/fields/user_avatar.php @@ -5,15 +5,16 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="map-listing-card-single__author"> <a href="<?php echo esc_url( $author_link ); ?>" aria-label="<?php echo esc_attr( $author_full_name ); ?>"> <?php if ( $u_pro_pic ) { ?> - <img src="<?php echo esc_url($u_pro_pic[0]); ?>" alt="<?php esc_attr_e( 'Author Image', 'directorist' );?>"> + <img src="<?php echo esc_url( $u_pro_pic[0] ); ?>" alt="<?php esc_attr_e( 'Author Image', 'directorist' ); ?>"> <?php - } - else { + } else { echo wp_kses_post( $avatar_img ); } ?> diff --git a/templates/single/fields/video.php b/templates/single/fields/video.php index 91b42abcd4..db053f3a71 100644 --- a/templates/single/fields/video.php +++ b/templates/single/fields/video.php @@ -5,9 +5,11 @@ * @version 7.8 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <iframe class="directorist-embaded-video embed-responsive-item" src="<?php echo esc_url( Helper::parse_video( $value ) ); ?>" allowfullscreen title="Single Listing Video"></iframe> \ No newline at end of file diff --git a/templates/single/fields/website.php b/templates/single/fields/website.php index c71552f54a..b95c1b0e98 100644 --- a/templates/single/fields/website.php +++ b/templates/single/fields/website.php @@ -5,18 +5,20 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-web"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> <div class="directorist-single-info__value"> - <a target="_blank" href="<?php echo esc_url( $value ); ?>"<?php echo !empty( $data['use_nofollow'] ) ? 'rel="nofollow"' : ''; ?>><?php echo esc_html( $value ); ?></a> + <a target="_blank" href="<?php echo esc_url( $value ); ?>"<?php echo ! empty( $data['use_nofollow'] ) ? 'rel="nofollow"' : ''; ?>><?php echo esc_html( $value ); ?></a> </div> </div> \ No newline at end of file diff --git a/templates/single/fields/zip.php b/templates/single/fields/zip.php index c2c453808a..f20a09e9dc 100644 --- a/templates/single/fields/zip.php +++ b/templates/single/fields/zip.php @@ -5,13 +5,15 @@ * @version 7.0.5.2 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-single-info directorist-single-info-zip"> <div class="directorist-single-info__label"> - <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-single-info__label-icon"><?php directorist_icon( $icon ); ?></span> <span class="directorist-single-info__label__text"><?php echo esc_html( $data['label'] ); ?></span> </div> diff --git a/templates/single/header-parts/listing-title.php b/templates/single/header-parts/listing-title.php index ff6635ddaa..d50cb3290b 100644 --- a/templates/single/header-parts/listing-title.php +++ b/templates/single/header-parts/listing-title.php @@ -5,18 +5,22 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -if ( $display_title ): ?> +if ( $display_title ) : ?> - <h1 class="directorist-listing-details__listing-title"><?php echo esc_html( $listing->get_title() ); ?></h1> + <h1 class="directorist-listing-details__listing-title"><?php echo esc_html( $listing->get_title() ); ?></h1> -<?php endif; + <?php +endif; -if ( $display_tagline && $listing->get_tagline() ): ?> +if ( $display_tagline && $listing->get_tagline() ) : + ?> - <p class="directorist-listing-details__tagline"><?php echo esc_html( $listing->get_tagline() ); ?></p> - + <p class="directorist-listing-details__tagline"><?php echo esc_html( $listing->get_tagline() ); ?></p> + <?php endif; ?> <?php do_action( 'directorist_single_listing_after_title', $listing->id ); ?> \ No newline at end of file diff --git a/templates/single/header-parts/more-widgets.php b/templates/single/header-parts/more-widgets.php index e61d34bbc9..22cb588d7f 100644 --- a/templates/single/header-parts/more-widgets.php +++ b/templates/single/header-parts/more-widgets.php @@ -5,11 +5,13 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-listing-details"> - <?php $listing->quick_info_template(); ?> + <?php $listing->quick_info_template(); ?> </div> \ No newline at end of file diff --git a/templates/single/header-parts/quick-widgets.php b/templates/single/header-parts/quick-widgets.php index a7208aad7c..e26af308a2 100644 --- a/templates/single/header-parts/quick-widgets.php +++ b/templates/single/header-parts/quick-widgets.php @@ -5,8 +5,10 @@ * @version 8.0 */ - use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -Helper::get_template( 'single/top-actions' ); \ No newline at end of file +Helper::get_template( 'single/top-actions' ); diff --git a/templates/single/header-parts/slider.php b/templates/single/header-parts/slider.php index a65e08661b..fb02760151 100644 --- a/templates/single/header-parts/slider.php +++ b/templates/single/header-parts/slider.php @@ -5,6 +5,8 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$listing->slider_template(); \ No newline at end of file +$listing->slider_template(); diff --git a/templates/single/header.php b/templates/single/header.php index 6876d700fe..b7eec29309 100644 --- a/templates/single/header.php +++ b/templates/single/header.php @@ -5,23 +5,26 @@ * @version 8.0 */ - use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <section class="directorist-single-listing-header"> <?php - $args = [ - 'listing' => $listing, - 'display_title' => $display_title, + $args = array( + 'listing' => $listing, + 'display_title' => $display_title, 'display_tagline' => $display_tagline, - ]; + ); foreach ( $listing->header_data as $data ) { if ( empty( $data['placeholderKey'] ) ) { continue; } - $template = str_replace( "-placeholder", "", $data['placeholderKey'] ); - Helper::get_template( 'single/header-parts/'. $template, $args ); - } ?> + $template = str_replace( '-placeholder', '', $data['placeholderKey'] ); + Helper::get_template( 'single/header-parts/' . $template, $args ); + } + ?> </section> \ No newline at end of file diff --git a/templates/single/notice.php b/templates/single/notice.php index 4ea7be3cbf..da486cf31c 100644 --- a/templates/single/notice.php +++ b/templates/single/notice.php @@ -5,9 +5,11 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -if ( !$notice_text ) { +if ( ! $notice_text ) { return; } ?> diff --git a/templates/single/quick-actions.php b/templates/single/quick-actions.php index 56711e2c49..0b6cb3d367 100644 --- a/templates/single/quick-actions.php +++ b/templates/single/quick-actions.php @@ -5,11 +5,13 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <?php -foreach ( $actions as $action ): +foreach ( $actions as $action ) : $listing->field_template( $action ); endforeach; -?> \ No newline at end of file + diff --git a/templates/single/quick-info.php b/templates/single/quick-info.php index 4d6018b64b..00db263839 100644 --- a/templates/single/quick-info.php +++ b/templates/single/quick-info.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-listing-single directorist-listing-single-quickinfo"> diff --git a/templates/single/section-author_info.php b/templates/single/section-author_info.php index b813f7ab03..78230b9441 100644 --- a/templates/single/section-author_info.php +++ b/templates/single/section-author_info.php @@ -5,19 +5,21 @@ * @version 8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $id = $listing->id; $author_id = $listing->author_id; -$u_pro_pic = get_user_meta($author_id, 'pro_pic', true); -$u_pro_pic = !empty($u_pro_pic) ? wp_get_attachment_image_src($u_pro_pic, 'thumbnail') : ''; -$author_img = !empty($u_pro_pic) ? $u_pro_pic[0] : ''; -$avatar_img = get_avatar($author_id, 32); +$u_pro_pic = get_user_meta( $author_id, 'pro_pic', true ); +$u_pro_pic = ! empty( $u_pro_pic ) ? wp_get_attachment_image_src( $u_pro_pic, 'thumbnail' ) : ''; +$author_img = ! empty( $u_pro_pic ) ? $u_pro_pic[0] : ''; +$avatar_img = get_avatar( $author_id, 32 ); ?> -<section class="directorist-card directorist-card-author-info <?php echo esc_attr( $class );?>" <?php $listing->section_id( $id ); ?>> +<section class="directorist-card directorist-card-author-info <?php echo esc_attr( $class ); ?>" <?php $listing->section_id( $id ); ?>> <header class="directorist-card__header"> @@ -37,9 +39,9 @@ <div class="directorist-single-author-avatar"> <figure class="directorist-single-author-avatar-inner"> - <?php if ( $author_img ): ?> - <img src="<?php echo esc_url( $author_img ); ?>" alt="<?php esc_attr_e( 'Avatar', 'directorist' );?>"> - <?php else: ?> + <?php if ( $author_img ) : ?> + <img src="<?php echo esc_url( $author_img ); ?>" alt="<?php esc_attr_e( 'Avatar', 'directorist' ); ?>"> + <?php else : ?> <?php echo wp_kses_post( $avatar_img ); ?> <?php endif; ?> </figure> @@ -54,7 +56,7 @@ <div class="directorist-single-author-contact-info"> <ul> - <?php if ( $address = $listing->author_info( 'address' ) ): ?> + <?php if ( $address = $listing->author_info( 'address' ) ) : ?> <li> <?php directorist_icon( 'fas fa-map-marker-alt' ); ?> <span class="directorist-single-author-contact-info-text"><?php echo esc_html( $address ); ?></span> @@ -62,7 +64,7 @@ <?php endif; ?> - <?php if ( $phone = $listing->author_info( 'phone' ) ): ?> + <?php if ( $phone = $listing->author_info( 'phone' ) ) : ?> <li> <?php directorist_icon( 'fas fa-phone-alt' ); ?> <span class="directorist-single-author-contact-info-text"> @@ -71,14 +73,14 @@ </li> <?php endif; ?> - <?php if ( $listing->author_display_email( $section_data ) ): ?> + <?php if ( $listing->author_display_email( $section_data ) ) : ?> <li> <?php directorist_icon( 'fas fa-envelope-open' ); ?> <span class="directorist-single-author-contact-info-text"><?php echo esc_html( $listing->author_info( 'email' ) ); ?></span> </li> <?php endif; ?> - <?php if ( $website = $listing->author_info( 'website' ) ): ?> + <?php if ( $website = $listing->author_info( 'website' ) ) : ?> <li> <?php directorist_icon( 'fas fa-globe-americas' ); ?> <a href="<?php echo esc_url( $website ); ?>" class="directorist-single-author-contact-info-text"><?php echo esc_url( $website ); ?></a> @@ -88,23 +90,23 @@ </div> - <?php if ( $listing->author_has_socials() ): ?> + <?php if ( $listing->author_has_socials() ) : ?> <ul class="directorist-author-social"> - <?php if ( $facebook = $listing->author_info( 'facebook' ) ): ?> + <?php if ( $facebook = $listing->author_info( 'facebook' ) ) : ?> <li class="directorist-author-social-item directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $facebook ); ?>"><?php directorist_icon( 'lab la-facebook' ); ?></a></li> <?php endif; ?> - <?php if ( $twitter = $listing->author_info( 'twitter' ) ): ?> + <?php if ( $twitter = $listing->author_info( 'twitter' ) ) : ?> <li class="directorist-author-social-item directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $twitter ); ?>"><?php directorist_icon( 'lab la-twitter' ); ?></a></li> <?php endif; ?> - <?php if ( $linkedin = $listing->author_info( 'linkedin' ) ): ?> + <?php if ( $linkedin = $listing->author_info( 'linkedin' ) ) : ?> <li class="directorist-author-social-item directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $linkedin ); ?>"><?php directorist_icon( 'lab la-linkedin' ); ?></a></li> <?php endif; ?> - <?php if ( $youtube = $listing->author_info( 'youtube' ) ): ?> + <?php if ( $youtube = $listing->author_info( 'youtube' ) ) : ?> <li class="directorist-author-social-item directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $youtube ); ?>"><?php directorist_icon( 'lab la-youtube' ); ?></a></li> <?php endif; ?> diff --git a/templates/single/section-contact_listings_owner.php b/templates/single/section-contact_listings_owner.php index be094c0867..69a27d2d11 100644 --- a/templates/single/section-contact_listings_owner.php +++ b/templates/single/section-contact_listings_owner.php @@ -5,24 +5,26 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -if( $listing->contact_owner_form_disabled() ) { +if ( $listing->contact_owner_form_disabled() ) { return; } $fields = $listing->contact_owner_fields( $section_data['fields'] ); ?> -<section class="directorist-card directorist-card-contact-owner <?php echo esc_attr( $class );?>" <?php $listing->section_id( $id ); ?>> +<section class="directorist-card directorist-card-contact-owner <?php echo esc_attr( $class ); ?>" <?php $listing->section_id( $id ); ?>> <header class="directorist-card__header"> <h3 class="directorist-card__header__title"> <?php if ( ! empty( $icon ) ) : ?> - <span class="directorist-card__header-icon"><?php directorist_icon( $icon );?></span> + <span class="directorist-card__header-icon"><?php directorist_icon( $icon ); ?></span> <?php endif; ?> - <span class="directorist-card__header-text"><?php echo esc_html( $label );?></span> + <span class="directorist-card__header-text"><?php echo esc_html( $label ); ?></span> </h3> </header> @@ -33,7 +35,7 @@ <div class="directorist-contact-owner-form-inner"> - <?php if( ! empty( $fields['name']['enable'] ) ) : ?> + <?php if ( ! empty( $fields['name']['enable'] ) ) : ?> <div class="directorist-form-group"> <input type="text" class="directorist-form-element" name="atbdp-contact-name" placeholder="<?php echo esc_attr( $fields['name']['placeholder'] ); ?>" required /> </div> diff --git a/templates/single/section-general.php b/templates/single/section-general.php index 5183182a15..523483dc7a 100644 --- a/templates/single/section-general.php +++ b/templates/single/section-general.php @@ -5,13 +5,15 @@ * @version 8.0.6 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> -<section class="directorist-card directorist-card-general-section <?php echo esc_attr( $class );?>" +<section class="directorist-card directorist-card-general-section <?php echo esc_attr( $class ); ?>" <?php $listing->section_id( $id ); ?>> - <?php if ( $label || $icon ): ?> + <?php if ( $label || $icon ) : ?> <header class="directorist-card__header"> <h3 class="directorist-card__header__title"> diff --git a/templates/single/section-related_listings.php b/templates/single/section-related_listings.php index 99be21b102..6edf8ab5dc 100644 --- a/templates/single/section-related_listings.php +++ b/templates/single/section-related_listings.php @@ -5,20 +5,22 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $related = $listing->get_related_listings( $section_data ); -if ( !$related->have_posts() ) { +if ( ! $related->have_posts() ) { return; } ?> -<section class="directorist-related-listing <?php echo esc_attr( $class );?>" <?php $listing->section_id( $id ); ?>> +<section class="directorist-related-listing <?php echo esc_attr( $class ); ?>" <?php $listing->section_id( $id ); ?>> <div class="directorist-related-listing-header"> - <h3 class="directorist-related-listing-header__title"><?php echo esc_html( $label );?></h3> + <h3 class="directorist-related-listing-header__title"><?php echo esc_html( $label ); ?></h3> </div> @@ -28,15 +30,15 @@ "1200": {"slidesPerView": "<?php echo esc_attr( $section_data['similar_listings_number_of_columns'] ?? 3 ); ?>"} }'> <div class='swiper-wrapper'> - <?php foreach ( $related->post_ids() as $listing_id ): ?> + <?php foreach ( $related->post_ids() as $listing_id ) : ?> <div class='swiper-slide'> <?php $related->loop_template( 'grid', $listing_id ); ?> </div> <?php endforeach; ?> </div> <div class='directorist-swiper__navigation'> - <div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-related'><?php directorist_icon('las la-angle-left')?></div> - <div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-related'><?php directorist_icon('las la-angle-right')?></div> + <div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-related'><?php directorist_icon( 'las la-angle-left' ); ?></div> + <div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-related'><?php directorist_icon( 'las la-angle-right' ); ?></div> </div> <div class='directorist-swiper__pagination directorist-swiper__pagination--related'></div> diff --git a/templates/single/slider.php b/templates/single/slider.php index 9af667745f..ad78566153 100644 --- a/templates/single/slider.php +++ b/templates/single/slider.php @@ -5,7 +5,9 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <section id="directorist-single-listing-slider-wrap" class="directorist-single-listing-slider-wrap background-<?php echo esc_attr( $data['background-size'] ); ?>" @@ -21,23 +23,23 @@ <div class="directorist-swiper directorist-single-listing-slider"> <div class="swiper-wrapper"> <?php - if ( ! empty( $data['images'] ) ): - foreach ( $data['images'] as $image ) { - if ( empty( $image['src'] ) ) { - continue; - } - printf( - '<div class="swiper-slide"><img src="%1$s" alt="%2$s"></div>', - esc_url( $image['src'] ), - esc_attr( $image['alt'] ) - ); + if ( ! empty( $data['images'] ) ) : + foreach ( $data['images'] as $image ) { + if ( empty( $image['src'] ) ) { + continue; } + printf( + '<div class="swiper-slide"><img src="%1$s" alt="%2$s"></div>', + esc_url( $image['src'] ), + esc_attr( $image['alt'] ) + ); + } endif; ?> </div> <div class='directorist-swiper__navigation'> - <div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-single-listing'><?php directorist_icon('las la-angle-left')?></div> - <div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-single-listing'><?php directorist_icon('las la-angle-right')?></div> + <div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-single-listing'><?php directorist_icon( 'las la-angle-left' ); ?></div> + <div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-single-listing'><?php directorist_icon( 'las la-angle-right' ); ?></div> </div> <div class='directorist-swiper__pagination directorist-swiper__pagination--single-listing'></div> @@ -47,7 +49,7 @@ <div class="directorist-swiper directorist-single-listing-slider-thumb"> <div class="swiper-wrapper"> <?php - if ( ! empty( $data['images'] ) ): + if ( ! empty( $data['images'] ) ) : foreach ( $data['images'] as $image ) { if ( empty( $image['src'] ) ) { continue; @@ -63,8 +65,8 @@ ?> </div> <div class='directorist-swiper__navigation'> - <div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-single-listing-thumb'><?php directorist_icon('las la-angle-left')?></div> - <div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-single-listing-thumb'><?php directorist_icon('las la-angle-right')?></div> + <div class='directorist-swiper__nav directorist-swiper__nav--prev directorist-swiper__nav--prev-single-listing-thumb'><?php directorist_icon( 'las la-angle-left' ); ?></div> + <div class='directorist-swiper__nav directorist-swiper__nav--next directorist-swiper__nav--next-single-listing-thumb'><?php directorist_icon( 'las la-angle-right' ); ?></div> </div> <div class='directorist-swiper__pagination directorist-swiper__pagination--single-listing-thumb'></div> diff --git a/templates/single/top-actions.php b/templates/single/top-actions.php index f15783934b..259ad58bba 100644 --- a/templates/single/top-actions.php +++ b/templates/single/top-actions.php @@ -5,30 +5,32 @@ * @version 8.0 */ -use \Directorist\Directorist_Single_Listing; +use Directorist\Directorist_Single_Listing; -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} $listing = Directorist_Single_Listing::instance(); ?> <div class="directorist-single-listing-top directorist-flex directorist-align-center directorist-justify-content-between"> - <?php if( $listing->display_back_link() ): ?> + <?php if ( $listing->display_back_link() ) : ?> - <a href="javascript:history.back()" class="directorist-single-listing-action directorist-return-back directorist-btn__back directorist-btn directorist-btn-sm directorist-btn-light"><?php directorist_icon( 'las la-arrow-left' ); ?> <span class="directorist-single-listing-action__text"><?php esc_html_e( 'Go Back', 'directorist'); ?></span> </a> + <a href="javascript:history.back()" class="directorist-single-listing-action directorist-return-back directorist-btn__back directorist-btn directorist-btn-sm directorist-btn-light"><?php directorist_icon( 'las la-arrow-left' ); ?> <span class="directorist-single-listing-action__text"><?php esc_html_e( 'Go Back', 'directorist' ); ?></span> </a> <?php endif; ?> <div class="directorist-single-listing-quick-action directorist-flex directorist-align-center directorist-justify-content-between"> - <?php if ( $listing->submit_link() ): ?> + <?php if ( $listing->submit_link() ) : ?> <div class="directorist-single-listing-top__btn-wrapper"> <a href="<?php echo esc_url( $listing->submit_link() ); ?>" class="directorist-single-listing-action directorist-btn directorist-btn-sm directorist-btn-light directorist-single-listing-top__btn-continue"><span class="directorist-single-listing-action__text"><?php esc_html_e( 'Continue to Publish', 'directorist' ); ?></span> </a> </div> <?php endif; ?> - <?php if ( $listing->current_user_is_author() ): ?> - <a href="<?php echo esc_url( $listing->edit_link() ) ?>" class="directorist-single-listing-action directorist-btn directorist-btn-sm directorist-btn-light directorist-single-listing-top__btn-edit"> + <?php if ( $listing->current_user_is_author() ) : ?> + <a href="<?php echo esc_url( $listing->edit_link() ); ?>" class="directorist-single-listing-action directorist-btn directorist-btn-sm directorist-btn-light directorist-single-listing-top__btn-edit"> <?php directorist_icon( 'las la-pen' ); ?> <span class="directorist-single-listing-action__text"><?php esc_html_e( 'Edit', 'directorist' ); ?></span> </a> diff --git a/templates/taxonomies/categories-grid.php b/templates/taxonomies/categories-grid.php index cbd998726d..7799205a3e 100644 --- a/templates/taxonomies/categories-grid.php +++ b/templates/taxonomies/categories-grid.php @@ -4,7 +4,7 @@ * @since 6.6 * @version 8.0.13 */ -use \Directorist\Helper; +use Directorist\Helper; $columns = floor( 12 / $taxonomy->columns ); @@ -18,7 +18,7 @@ <div id="directorist" class="atbd_wrapper directorist-w-100"> <div class="<?php Helper::directorist_container_fluid(); ?>"> - <div class="directorist-categories" data-attrs="<?php echo esc_attr(wp_json_encode( $taxonomy->atts )); ?>"> + <div class="directorist-categories" data-attrs="<?php echo esc_attr( wp_json_encode( $taxonomy->atts ) ); ?>"> <?php /** * @since 5.6.6 @@ -28,16 +28,16 @@ <?php if ( $categories ) : ?> <div class="<?php echo apply_filters( 'directorist_taxonomy_category_wrapper', Helper::directorist_row() . ' taxonomy-category-wrapper' ); ?>"> <?php - foreach ($categories as $category) { + foreach ( $categories as $category ) { $cat_class = $category['img'] ? ' directorist-categories__single--image' : ''; $img_src = esc_url( $category['img'] ); $category_count = $category['term']->count ?? 0; - + if ( $category_count === 0 ) { $listing_count_text = esc_html( 'listing', 'directorist' ); } else { - $listing_count_text = sprintf( - _nx( + $listing_count_text = sprintf( + _nx( 'listing', 'listings', $category_count, @@ -47,21 +47,22 @@ number_format_i18n( $category_count ) ); } - + $listing_count_text = sprintf( '%s <span class="directorist-category-term">%s</span>', $category['grid_count_html'], $listing_count_text ); ?> <div class="<?php Helper::directorist_column( $columns ); ?>"> - <div class="directorist-categories__single<?php echo esc_attr( $cat_class ); ?> directorist-categories__single--style-one" style="background-image: url('<?php echo $category['img'] ? esc_attr($img_src) : 'none'; ?>')" + <div class="directorist-categories__single<?php echo esc_attr( $cat_class ); ?> directorist-categories__single--style-one" style="background-image: url('<?php echo $category['img'] ? esc_attr( $img_src ) : 'none'; ?>')" > <div class="directorist-categories__single__content"> <?php - if ($category['has_icon']) { ?> + if ( $category['has_icon'] ) { + ?> <div class="directorist-categories__single__icon"><?php directorist_icon( $category['icon_class'] ); ?></div> <?php } ?> - <a href="<?php echo esc_url($category['permalink']); ?>" class="directorist-categories__single__name"><?php echo esc_html($category['name']); ?></a> + <a href="<?php echo esc_url( $category['permalink'] ); ?>" class="directorist-categories__single__name"><?php echo esc_html( $category['name'] ); ?></a> <?php if ( $taxonomy->show_count ) { ?> <div class="directorist-categories__single__total"> @@ -89,9 +90,9 @@ </div> <?php - /** - * @since 5.6.6 - */ - do_action( 'atbdp_after_all_categories_loop' ); - ?> + /** + * @since 5.6.6 + */ + do_action( 'atbdp_after_all_categories_loop' ); + ?> </div> \ No newline at end of file diff --git a/templates/taxonomies/categories-list.php b/templates/taxonomies/categories-list.php index 25932ae25e..470c376b32 100644 --- a/templates/taxonomies/categories-list.php +++ b/templates/taxonomies/categories-list.php @@ -5,7 +5,7 @@ * @version 8.0.13 */ -use \Directorist\Helper; +use Directorist\Helper; $columns = floor( 12 / $taxonomy->columns ); @@ -13,12 +13,12 @@ $columns = $columns . '-5'; } -$taxonomy->atts['type'] = 'category'; +$taxonomy->atts['type'] = 'category'; $taxonomy->atts['directory_type'] = isset( $_GET['directory_type'] ) && ! empty( $_GET['directory_type'] ) ? $_GET['directory_type'] : ''; ?> <div id="directorist" class="atbd_wrapper directorist-w-100"> <div class="<?php Helper::directorist_container_fluid(); ?>"> - <div class="directorist-categories" data-attrs="<?php echo esc_attr(wp_json_encode( $taxonomy->atts )); ?>"> + <div class="directorist-categories" data-attrs="<?php echo esc_attr( wp_json_encode( $taxonomy->atts ) ); ?>"> <?php /** * @since 5.6.6 @@ -28,36 +28,37 @@ <?php if ( $categories ) : ?> <div class="<?php echo apply_filters( 'directorist_taxonomy_category_wrapper', Helper::directorist_row() . ' taxonomy-category-wrapper' ); ?>"> <?php - foreach ($categories as $category) { + foreach ( $categories as $category ) { $toggle_class = $category['has_child'] ? 'directorist-taxonomy-list__toggle' : ''; - $toggle_icon = $category['has_child'] ? 'las la-angle-down' : ''; - $has_icon = $category['icon_class'] ? 'directorist-taxonomy-list__card--icon' : ''; + $toggle_icon = $category['has_child'] ? 'las la-angle-down' : ''; + $has_icon = $category['icon_class'] ? 'directorist-taxonomy-list__card--icon' : ''; ?> <div class="<?php Helper::directorist_column( $columns ); ?> directorist-taxonomy-list-one"> <div class="directorist-taxonomy-list"> - <a href="<?php echo esc_url($category['permalink']);?>" class="directorist-taxonomy-list__card <?php echo wp_kses_post( $toggle_class ); ?> <?php echo wp_kses_post( $has_icon ); ?> "> - <?php if($category['icon_class']){ ?> + <a href="<?php echo esc_url( $category['permalink'] ); ?>" class="directorist-taxonomy-list__card <?php echo wp_kses_post( $toggle_class ); ?> <?php echo wp_kses_post( $has_icon ); ?> "> + <?php if ( $category['icon_class'] ) { ?> <span class="directorist-taxonomy-list__icon"> <?php directorist_icon( $category['icon_class'] ); ?> </span> <?php } ?> <span class="directorist-taxonomy-list__name"> - <?php echo esc_html($category['name']);?> + <?php echo esc_html( $category['name'] ); ?> </span> <span class="directorist-taxonomy-list__count"> - <?php echo wp_kses_post( $category['list_count_html'] );?> + <?php echo wp_kses_post( $category['list_count_html'] ); ?> </span> - <?php if($category['has_child']){ ?> + <?php if ( $category['has_child'] ) { ?> <span class="directorist-taxonomy-list__toggler"> <?php directorist_icon( $toggle_icon ); ?> </span> <?php } ?> </a> - <?php echo wp_kses_post( $category['subterm_html'] );?> + <?php echo wp_kses_post( $category['subterm_html'] ); ?> </div> </div> <?php - }?> + } + ?> <?php $taxonomy->pagination(); ?> @@ -69,8 +70,8 @@ </div> <?php /** - * @since 5.6.6 - */ - do_action( 'atbdp_after_all_categories_loop' ); - ?> + * @since 5.6.6 + */ + do_action( 'atbdp_after_all_categories_loop' ); + ?> </div> \ No newline at end of file diff --git a/templates/taxonomies/locations-grid.php b/templates/taxonomies/locations-grid.php index 482f3284c4..fa1057174a 100644 --- a/templates/taxonomies/locations-grid.php +++ b/templates/taxonomies/locations-grid.php @@ -5,7 +5,7 @@ * @version 8.0.13 */ -use \Directorist\Helper; +use Directorist\Helper; $columns = floor( 12 / $taxonomy->columns ); @@ -13,12 +13,12 @@ $columns = $columns . '-5'; } -$taxonomy->atts['type'] = 'location'; +$taxonomy->atts['type'] = 'location'; $taxonomy->atts['directory_type'] = isset( $_GET['directory_type'] ) && ! empty( $_GET['directory_type'] ) ? $_GET['directory_type'] : ''; ?> <div id="directorist" class="atbd_wrapper directorist-w-100"> <div class="<?php Helper::directorist_container_fluid(); ?>"> - <div class="directorist-location directorist-location--grid directorist-location--grid-one" data-attrs="<?php echo esc_attr(wp_json_encode( $taxonomy->atts )); ?>"> + <div class="directorist-location directorist-location--grid directorist-location--grid-one" data-attrs="<?php echo esc_attr( wp_json_encode( $taxonomy->atts ) ); ?>"> <?php /** * @since 5.6.6 @@ -28,29 +28,30 @@ <?php if ( $locations ) : ?> <div class="<?php echo apply_filters( 'directorist_taxonomy_location_wrapper', Helper::directorist_row() . ' taxonomy-location-wrapper' ); ?>"> <?php - foreach ($locations as $location) { + foreach ( $locations as $location ) { $loc_class = $location['img'] ? ' directorist-location__single--img' : ''; ?> <div class="<?php Helper::directorist_column( $columns ); ?>"> <div class="directorist-location__single<?php echo esc_attr( $loc_class ); ?>"> - <?php if ($location['img']) { ?> - <div class="directorist-location__single__img"><img src="<?php echo esc_url( $location['img'] ); ?>" title="<?php echo esc_attr($location['name']); ?>" alt="<?php echo esc_attr($location['name']); ?>"></div> + <?php if ( $location['img'] ) { ?> + <div class="directorist-location__single__img"><img src="<?php echo esc_url( $location['img'] ); ?>" title="<?php echo esc_attr( $location['name'] ); ?>" alt="<?php echo esc_attr( $location['name'] ); ?>"></div> <?php } ?> <div class="directorist-location__content"> <h3> - <a href="<?php echo esc_url($location['permalink']); ?>"> - <?php echo esc_html($location['name']); ?> + <a href="<?php echo esc_url( $location['permalink'] ); ?>"> + <?php echo esc_html( $location['name'] ); ?> </a> </h3> - <span class="directorist-location__count"><?php echo wp_kses_post( $location['grid_count_html'] );?></span> + <span class="directorist-location__count"><?php echo wp_kses_post( $location['grid_count_html'] ); ?></span> </div> </div> </div> <?php - }?> + } + ?> <?php $taxonomy->pagination(); ?> @@ -62,8 +63,8 @@ </div> <?php /** - * @since 5.6.6 - */ - do_action( 'atbdp_after_all_locations_loop' ); - ?> + * @since 5.6.6 + */ + do_action( 'atbdp_after_all_locations_loop' ); + ?> </div> \ No newline at end of file diff --git a/templates/taxonomies/locations-list.php b/templates/taxonomies/locations-list.php index 383c2bb327..9f2bc91d4c 100644 --- a/templates/taxonomies/locations-list.php +++ b/templates/taxonomies/locations-list.php @@ -5,7 +5,7 @@ * @version 8.0.13 */ -use \Directorist\Helper; +use Directorist\Helper; $columns = floor( 12 / $taxonomy->columns ); @@ -13,7 +13,7 @@ $columns = $columns . '-5'; } -$taxonomy->atts['type'] = 'location'; +$taxonomy->atts['type'] = 'location'; $taxonomy->atts['directory_type'] = isset( $_GET['directory_type'] ) && ! empty( $_GET['directory_type'] ) ? $_GET['directory_type'] : ''; ?> <div id="directorist" class="atbd_wrapper directorist-w-100"> @@ -29,33 +29,32 @@ ?> </div> <?php - if( $locations ) { - foreach ($locations as $location) { + if ( $locations ) { + foreach ( $locations as $location ) { $toggle_class = $location['has_child'] ? 'directorist-taxonomy-list__toggle' : ''; - $toggle_icon = $location['has_child'] ? 'las la-angle-down' : ''; + $toggle_icon = $location['has_child'] ? 'las la-angle-down' : ''; ?> <div class="<?php Helper::directorist_column( $columns ); ?> directorist-taxonomy-list-one"> <div class="directorist-taxonomy-list"> - <a class="directorist-taxonomy-list__card <?php echo wp_kses_post( $toggle_class ); ?> " href="<?php echo esc_url($location['permalink']);?>"> + <a class="directorist-taxonomy-list__card <?php echo wp_kses_post( $toggle_class ); ?> " href="<?php echo esc_url( $location['permalink'] ); ?>"> <span class="directorist-taxonomy-list__name"> - <?php echo esc_html($location['name']);?> + <?php echo esc_html( $location['name'] ); ?> </span> <span class="directorist-taxonomy-list__count"> - <?php echo wp_kses_post( $location['list_count_html'] );?> + <?php echo wp_kses_post( $location['list_count_html'] ); ?> </span> - <?php if($location['has_child']){ ?> + <?php if ( $location['has_child'] ) { ?> <span class="directorist-taxonomy-list__toggler"> <?php directorist_icon( $toggle_icon ); ?> </span> <?php } ?> </a> - <?php echo wp_kses_post( $location['subterm_html'] );?> + <?php echo wp_kses_post( $location['subterm_html'] ); ?> </div> </div> <?php } - } - else { + } else { ?> <p><?php esc_html_e( 'No Results found!', 'directorist' ); ?></p> <?php @@ -68,8 +67,8 @@ </div> <?php /** - * @since 5.6.6 - */ - do_action( 'atbdp_after_all_locations_loop' ); - ?> + * @since 5.6.6 + */ + do_action( 'atbdp_after_all_locations_loop' ); + ?> </div> \ No newline at end of file diff --git a/templates/widgets/all-categories.php b/templates/widgets/all-categories.php index e26491a205..da95b26d9f 100644 --- a/templates/widgets/all-categories.php +++ b/templates/widgets/all-categories.php @@ -5,18 +5,22 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-card__body"> - <?php if( 'dropdown' == $query_args['template'] ) : ?> - <form action="<?php echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); ?>"> - <input type="hidden" name="q" placeholder=""> - <select name="in_cat" id="at_biz_dir-category" onchange="this.form.submit()"> - <?php echo directorist_kses( $categories, 'form_input' ); ?> - </select> - </form> - <?php else : - echo wp_kses_post( $categories ); - endif; ?> + <?php if ( 'dropdown' == $query_args['template'] ) : ?> + <form action="<?php echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); ?>"> + <input type="hidden" name="q" placeholder=""> + <select name="in_cat" id="at_biz_dir-category" onchange="this.form.submit()"> + <?php echo directorist_kses( $categories, 'form_input' ); ?> + </select> + </form> + <?php + else : + echo wp_kses_post( $categories ); + endif; + ?> </div> diff --git a/templates/widgets/all-locations.php b/templates/widgets/all-locations.php index db85478ba7..581d1ff22e 100644 --- a/templates/widgets/all-locations.php +++ b/templates/widgets/all-locations.php @@ -5,19 +5,23 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-card__body"> - <?php if( 'dropdown' == $query_args['template'] ) : ?> - <form action="<?php echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); ?>"> - <input type="hidden" name="q" placeholder=""> - <select id="at_biz_dir-location" name="in_loc" onchange="this.form.submit()"> + <?php if ( 'dropdown' == $query_args['template'] ) : ?> + <form action="<?php echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); ?>"> + <input type="hidden" name="q" placeholder=""> + <select id="at_biz_dir-location" name="in_loc" onchange="this.form.submit()"> <?php echo directorist_kses( $categories, 'form_input' ); ?> - </select> - </form> - <?php else : - echo wp_kses_post( $categories ); - endif; ?> + </select> + </form> + <?php + else : + echo wp_kses_post( $categories ); + endif; + ?> </div> diff --git a/templates/widgets/all-tags.php b/templates/widgets/all-tags.php index c60cc5d418..326d82fd07 100644 --- a/templates/widgets/all-tags.php +++ b/templates/widgets/all-tags.php @@ -5,20 +5,24 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-card__body"> - <div class="directorist-widget-tags"> - <?php if ('dropdown' == $query_args['template']) : ?> - <form action="<?php echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); ?>"> - <input type="hidden" name="q" placeholder=""> - <select class="form-control" name="in_tag" onchange="this.form.submit()"> - <?php echo directorist_kses( $tags, 'form_input' ); ?> - </select> - </form> - <?php else : - echo wp_kses_post( $tags ); - endif; ?> - </div> + <div class="directorist-widget-tags"> + <?php if ( 'dropdown' == $query_args['template'] ) : ?> + <form action="<?php echo esc_url( ATBDP_Permalink::get_search_result_page_link() ); ?>"> + <input type="hidden" name="q" placeholder=""> + <select class="form-control" name="in_tag" onchange="this.form.submit()"> + <?php echo directorist_kses( $tags, 'form_input' ); ?> + </select> + </form> + <?php + else : + echo wp_kses_post( $tags ); + endif; + ?> + </div> </div> diff --git a/templates/widgets/author-info.php b/templates/widgets/author-info.php index 85d77da2bd..19e9ac7c2b 100644 --- a/templates/widgets/author-info.php +++ b/templates/widgets/author-info.php @@ -5,126 +5,137 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-card__body directorist-widget__author-info"> - <div class="directorist-single-author-info"> - <?php - $listing_id = get_the_ID(); - $author_id = get_post_field('post_author', $listing_id); - $author_name = get_the_author_meta('display_name', $author_id); - $user_registered = get_the_author_meta('user_registered', $author_id); - $u_pro_pic = get_user_meta($author_id, 'pro_pic', true); - $u_pro_pic = !empty($u_pro_pic) ? wp_get_attachment_image_src($u_pro_pic, 'thumbnail') : ''; - $avatar_img = get_avatar($author_id, apply_filters('atbdp_avatar_size', 32)); - ?> - <div class="directorist-single-author-avatar"> - <figure class="directorist-single-author-avatar-inner"> - <?php if (empty($u_pro_pic)) { - echo wp_kses_post( $avatar_img ); - } - if (!empty($u_pro_pic)) { ?><img - src="<?php echo esc_url($u_pro_pic[0]); ?>" - alt="Avatar Image"><?php } ?> - </figure> - <div class="directorist-single-author-name"> - <h4><?php echo esc_html($author_name); ?></h4> - <span class="directorist-single-author-membership"><?php - printf( esc_html__('Member since %s ago', 'directorist'), esc_html( human_time_diff(strtotime($user_registered), current_time('timestamp'))) ); ?></span> - </div> - </div> - </div> - - <div class="directorist-single-author-contact-info"> - <ul> - <?php - $address = esc_attr(get_user_meta($author_id, 'address', true)); - $phone = esc_attr(get_user_meta($author_id, 'atbdp_phone', true)); - $email = get_the_author_meta('user_email', $author_id); - $website = get_the_author_meta('user_url', $author_id);; - $facebook = get_user_meta($author_id, 'atbdp_facebook', true); - $twitter = get_user_meta($author_id, 'atbdp_twitter', true); - $linkedIn = get_user_meta($author_id, 'atbdp_linkedin', true); - $youtube = get_user_meta($author_id, 'atbdp_youtube', true); - if (!empty($address)) { ?> - <li> - <?php directorist_icon( 'fas fa-map-marker-alt' ); ?> - <span class="directorist-single-author-contact-info-text"><?php echo !empty($address) ? esc_html($address) : ''; ?></span> - </li> - <?php } ?> - - <?php - if (isset($phone) && !is_empty_v($phone)) { ?> - <!-- In Future, We will have to use a loop to print more than 1 number--> - <li> - <?php directorist_icon( 'fas fa-phone-alt' ); ?> - <span class="directorist-single-author-contact-info-text"><a href="tel:<?php echo esc_html(stripslashes($phone)); ?>"><?php echo esc_html(stripslashes($phone)); ?></a></span> - </li> - <?php } ?> - - <?php - $display_email = get_user_meta( $author_id, 'directorist_display_author_email', true ); - $email_show = ! empty( $display_email ) ? $display_email : 'public'; - if ('public' === $email_show) { - if (!empty($email)) { - ?> - <li> - <?php directorist_icon( 'fas fa-envelope-open' ); ?> - <span class="directorist-single-author-contact-info-text"><?php echo esc_html($email); ?></span> - </li> - <?php - } - } elseif ('logged_in' === $email_show) { - if (is_user_logged_in()) { - if (!empty($email)) { - ?> - <li> + <div class="directorist-single-author-info"> + <?php + $listing_id = get_the_ID(); + $author_id = get_post_field( 'post_author', $listing_id ); + $author_name = get_the_author_meta( 'display_name', $author_id ); + $user_registered = get_the_author_meta( 'user_registered', $author_id ); + $u_pro_pic = get_user_meta( $author_id, 'pro_pic', true ); + $u_pro_pic = ! empty( $u_pro_pic ) ? wp_get_attachment_image_src( $u_pro_pic, 'thumbnail' ) : ''; + $avatar_img = get_avatar( $author_id, apply_filters( 'atbdp_avatar_size', 32 ) ); + ?> + <div class="directorist-single-author-avatar"> + <figure class="directorist-single-author-avatar-inner"> + <?php + if ( empty( $u_pro_pic ) ) { + echo wp_kses_post( $avatar_img ); + } + if ( ! empty( $u_pro_pic ) ) { + ?> + <img + src="<?php echo esc_url( $u_pro_pic[0] ); ?>" + alt="Avatar Image"><?php } ?> + </figure> + <div class="directorist-single-author-name"> + <h4><?php echo esc_html( $author_name ); ?></h4> + <span class="directorist-single-author-membership"> + <?php + printf( esc_html__( 'Member since %s ago', 'directorist' ), esc_html( human_time_diff( strtotime( $user_registered ), current_time( 'timestamp' ) ) ) ); + ?> + </span> + </div> + </div> + </div> + + <div class="directorist-single-author-contact-info"> + <ul> + <?php + $address = esc_attr( get_user_meta( $author_id, 'address', true ) ); + $phone = esc_attr( get_user_meta( $author_id, 'atbdp_phone', true ) ); + $email = get_the_author_meta( 'user_email', $author_id ); + $website = get_the_author_meta( 'user_url', $author_id ); + $facebook = get_user_meta( $author_id, 'atbdp_facebook', true ); + $twitter = get_user_meta( $author_id, 'atbdp_twitter', true ); + $linkedIn = get_user_meta( $author_id, 'atbdp_linkedin', true ); + $youtube = get_user_meta( $author_id, 'atbdp_youtube', true ); + if ( ! empty( $address ) ) { + ?> + <li> + <?php directorist_icon( 'fas fa-map-marker-alt' ); ?> + <span class="directorist-single-author-contact-info-text"><?php echo ! empty( $address ) ? esc_html( $address ) : ''; ?></span> + </li> + <?php } ?> + + <?php + if ( isset( $phone ) && ! is_empty_v( $phone ) ) { + ?> + <!-- In Future, We will have to use a loop to print more than 1 number--> + <li> + <?php directorist_icon( 'fas fa-phone-alt' ); ?> + <span class="directorist-single-author-contact-info-text"><a href="tel:<?php echo esc_html( stripslashes( $phone ) ); ?>"><?php echo esc_html( stripslashes( $phone ) ); ?></a></span> + </li> + <?php } ?> + + <?php + $display_email = get_user_meta( $author_id, 'directorist_display_author_email', true ); + $email_show = ! empty( $display_email ) ? $display_email : 'public'; + if ( 'public' === $email_show ) { + if ( ! empty( $email ) ) { + ?> + <li> + <?php directorist_icon( 'fas fa-envelope-open' ); ?> + <span class="directorist-single-author-contact-info-text"><?php echo esc_html( $email ); ?></span> + </li> + <?php + } + } elseif ( 'logged_in' === $email_show ) { + if ( is_user_logged_in() ) { + if ( ! empty( $email ) ) { + ?> + <li> <?php directorist_icon( 'fas fa-envelope-open' ); ?> - <span class="directorist-single-author-contact-info-text"><?php echo esc_html($email); ?></span> - </li> - <?php - } - } - } - if (!empty($website)) { ?> - <li> - <?php directorist_icon( 'fas fa-globe-americas' ); ?> - <a href="<?php echo esc_url($website); ?>" - class="directorist-single-author-contact-info-text" <?php echo is_directoria_active() ? 'style="text-transform: none;"' : ''; ?>><?php echo esc_url($website); ?></a> - </li> - <?php } ?> - - </ul> - </div> - - <?php if (!empty($facebook || $twitter || $linkedIn || $youtube )): ?> - - <ul class="directorist-author-social"> - - <?php if ( $facebook ): ?> + <span class="directorist-single-author-contact-info-text"><?php echo esc_html( $email ); ?></span> + </li> + <?php + } + } + } + if ( ! empty( $website ) ) { + ?> + <li> + <?php directorist_icon( 'fas fa-globe-americas' ); ?> + <a href="<?php echo esc_url( $website ); ?>" + class="directorist-single-author-contact-info-text" <?php echo is_directoria_active() ? 'style="text-transform: none;"' : ''; ?>><?php echo esc_url( $website ); ?></a> + </li> + <?php } ?> + + </ul> + </div> + + <?php if ( ! empty( $facebook || $twitter || $linkedIn || $youtube ) ) : ?> + + <ul class="directorist-author-social"> + + <?php if ( $facebook ) : ?> <li class="directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $facebook ); ?>"><?php directorist_icon( 'lab la-facebook' ); ?></a></li> <?php endif; ?> - <?php if ( $twitter ): ?> + <?php if ( $twitter ) : ?> <li class="directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $twitter ); ?>"><?php directorist_icon( 'lab la-twitter' ); ?></a></li> <?php endif; ?> - <?php if ( $linkedIn ): ?> + <?php if ( $linkedIn ) : ?> <li class="directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $linkedIn ); ?>"><?php directorist_icon( 'lab la-linkedin' ); ?></a></li> <?php endif; ?> - <?php if ( $youtube ): ?> + <?php if ( $youtube ) : ?> <li class="directorist-author-social__item"><a target="_blank" href="<?php echo esc_url( $youtube ); ?>"><?php directorist_icon( 'lab la-youtube' ); ?></a></li> <?php endif; ?> - </ul> + </ul> <?php endif; ?> - <a href="<?php echo esc_url( ATBDP_Permalink::get_user_profile_page_link($author_id) ); ?>" - class="<?php echo esc_attr( atbdp_directorist_button_classes('light') ); ?> diretorist-view-profile-btn"><?php esc_html_e('View Profile', 'directorist'); ?> - </a> + <a href="<?php echo esc_url( ATBDP_Permalink::get_user_profile_page_link( $author_id ) ); ?>" + class="<?php echo esc_attr( atbdp_directorist_button_classes( 'light' ) ); ?> diretorist-view-profile-btn"><?php esc_html_e( 'View Profile', 'directorist' ); ?> + </a> </div> \ No newline at end of file diff --git a/templates/widgets/contact-form.php b/templates/widgets/contact-form.php index a63a5122c0..44d4bd4626 100644 --- a/templates/widgets/contact-form.php +++ b/templates/widgets/contact-form.php @@ -5,37 +5,39 @@ * @version 7.10.4 */ -if ( ! defined( 'ABSPATH' ) ) exit; -$form_id = apply_filters('atbdp_contact_listing_owner_widget_form_id', 'directorist-contact-owner-form'); +if ( ! defined( 'ABSPATH' ) ) { + exit; +} +$form_id = apply_filters( 'atbdp_contact_listing_owner_widget_form_id', 'directorist-contact-owner-form' ); ?> <div class="directorist-card__body directorist-widget__listing-contact"> - <form id="<?php echo esc_attr( $form_id ); ?>" class="directorist-contact-owner-form"> - <div class="directorist-form-group"> - <input type="text" class="directorist-form-element" name="atbdp-contact-name" placeholder="<?php esc_attr_e('Name', 'directorist'); ?>" required /> - </div> + <form id="<?php echo esc_attr( $form_id ); ?>" class="directorist-contact-owner-form"> + <div class="directorist-form-group"> + <input type="text" class="directorist-form-element" name="atbdp-contact-name" placeholder="<?php esc_attr_e( 'Name', 'directorist' ); ?>" required /> + </div> - <div class="directorist-form-group"> - <input type="email" class="directorist-form-element" name="atbdp-contact-email" placeholder="<?php esc_attr_e('Email', 'directorist'); ?>" required /> - </div> + <div class="directorist-form-group"> + <input type="email" class="directorist-form-element" name="atbdp-contact-email" placeholder="<?php esc_attr_e( 'Email', 'directorist' ); ?>" required /> + </div> <div class="directorist-form-group"> - <textarea class="directorist-form-element" name="atbdp-contact-message" rows="3" placeholder="<?php esc_attr_e('Message...', 'directorist'); ?>" required ></textarea> + <textarea class="directorist-form-element" name="atbdp-contact-message" rows="3" placeholder="<?php esc_attr_e( 'Message...', 'directorist' ); ?>" required ></textarea> </div> - <input type="hidden" name="atbdp-post-id" value="<?php echo esc_attr( get_the_ID() ); ?>" /> - <input type="hidden" name="atbdp-listing-email" value="<?php echo ! empty( $email ) ? esc_attr( $email ) : ''; ?>" /> - - <?php - // Deprecated hook - do_action_deprecated( 'atbdp_before_contact_form_submit_button', array(), '7.10.4', 'directorist_before_contact_form_submit_button' ); - // New hook - do_action( 'directorist_before_contact_form_submit_button' ); - ?> - - <p class="atbdp-widget-elm directorist-contact-message-display"></p> + <input type="hidden" name="atbdp-post-id" value="<?php echo esc_attr( get_the_ID() ); ?>" /> + <input type="hidden" name="atbdp-listing-email" value="<?php echo ! empty( $email ) ? esc_attr( $email ) : ''; ?>" /> + + <?php + // Deprecated hook + do_action_deprecated( 'atbdp_before_contact_form_submit_button', array(), '7.10.4', 'directorist_before_contact_form_submit_button' ); + // New hook + do_action( 'directorist_before_contact_form_submit_button' ); + ?> + + <p class="atbdp-widget-elm directorist-contact-message-display"></p> - <button type="submit" class="directorist-btn directorist-btn-light directorist-btn-md"><?php esc_html_e('Submit Now', 'directorist'); ?></button> - </form> + <button type="submit" class="directorist-btn directorist-btn-light directorist-btn-md"><?php esc_html_e( 'Submit Now', 'directorist' ); ?></button> + </form> </div> diff --git a/templates/widgets/featured-listing.php b/templates/widgets/featured-listing.php index 689ead2280..ea09c0f885 100644 --- a/templates/widgets/featured-listing.php +++ b/templates/widgets/featured-listing.php @@ -5,23 +5,25 @@ * @version 8.0.8 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} use Directorist\Review\Markup; -$f_listing_num = !empty($instance['f_listing_num']) ? $instance['f_listing_num'] : 5; +$f_listing_num = ! empty( $instance['f_listing_num'] ) ? $instance['f_listing_num'] : 5; $featured_args = array( - 'post_type' => ATBDP_POST_TYPE, - 'post_status' => 'publish', - 'posts_per_page' => (int)$f_listing_num, - 'meta_query' => array( - array( - 'key' => '_featured', - 'value' => 1, - 'compare' => '=' - ) - ) + 'post_type' => ATBDP_POST_TYPE, + 'post_status' => 'publish', + 'posts_per_page' => (int) $f_listing_num, + 'meta_query' => array( + array( + 'key' => '_featured', + 'value' => 1, + 'compare' => '=', + ), + ), ); /** * Filter to modify featured listings arguments. @@ -30,67 +32,70 @@ * * @param array $featured_args Featured Arguments. */ -apply_filters( "directorist_widget_featured_listings_query_arguments", $featured_args ); +apply_filters( 'directorist_widget_featured_listings_query_arguments', $featured_args ); -$featured_listings = new WP_Query($featured_args); -$default_icon = 'las la-tags'; +$featured_listings = new WP_Query( $featured_args ); +$default_icon = 'las la-tags'; ?> <div class="directorist-card__body"> - <div class="directorist-widget-listing"> - <?php - if ($featured_listings->have_posts()) { - while ($featured_listings->have_posts()) { - $featured_listings->the_post(); - $review_rating = directorist_get_listing_rating( get_the_ID() ); - $review_count = directorist_get_listing_review_count( get_the_ID() ); - $review_text = sprintf( _n( '%s review', $review_count > 0 ? '%s reviews' : '%s review', $review_count, 'directorist' ), number_format_i18n( $review_count ) ); - // get only one parent or high level term object - $listing_img = directorist_get_listing_gallery_images( get_the_ID() ); - $listing_prv_img = directorist_get_listing_preview_image( get_the_ID() ); - $listing_reviews = get_post_meta( get_the_ID(), '_directorist_reviews', true ); - $price = get_post_meta(get_the_ID(), '_price', true); - $price_range = get_post_meta(get_the_ID(), '_price_range', true); - $listing_pricing = get_post_meta(get_the_ID(), '_atbd_listing_pricing', true); - $cats = get_the_terms(get_the_ID(), ATBDP_CATEGORY); - ?> - <div class="directorist-widget-listing__single"> - <div class="directorist-widget-listing__image"> - <?php - $default_image = get_directorist_option('default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg'); - if (!empty($listing_prv_img)) { - echo '<a href="'.esc_url( get_the_permalink() ).'"><img src="' . esc_url(wp_get_attachment_image_url($listing_prv_img, array(90, 90))) . '" alt="listing image"></a>'; - } elseif (!empty($listing_img[0]) && empty($listing_prv_img)) { - echo '<a href="'.esc_url( get_the_permalink() ).'"><img src="' . esc_url(wp_get_attachment_image_url($listing_img[0], array(90, 90))) . '" alt="listing image"></a>'; - } else { - echo '<a href="'.esc_url( get_the_permalink() ).'"><img src="' . esc_url( $default_image ) . '" alt="listing image"></a>'; - } + <div class="directorist-widget-listing"> + <?php + if ( $featured_listings->have_posts() ) { + while ( $featured_listings->have_posts() ) { + $featured_listings->the_post(); + $review_rating = directorist_get_listing_rating( get_the_ID() ); + $review_count = directorist_get_listing_review_count( get_the_ID() ); + $review_text = sprintf( _n( '%s review', $review_count > 0 ? '%s reviews' : '%s review', $review_count, 'directorist' ), number_format_i18n( $review_count ) ); + // get only one parent or high level term object + $listing_img = directorist_get_listing_gallery_images( get_the_ID() ); + $listing_prv_img = directorist_get_listing_preview_image( get_the_ID() ); + $listing_reviews = get_post_meta( get_the_ID(), '_directorist_reviews', true ); + $price = get_post_meta( get_the_ID(), '_price', true ); + $price_range = get_post_meta( get_the_ID(), '_price_range', true ); + $listing_pricing = get_post_meta( get_the_ID(), '_atbd_listing_pricing', true ); + $cats = get_the_terms( get_the_ID(), ATBDP_CATEGORY ); + ?> + <div class="directorist-widget-listing__single"> + <div class="directorist-widget-listing__image"> + <?php + $default_image = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); + if ( ! empty( $listing_prv_img ) ) { + echo '<a href="' . esc_url( get_the_permalink() ) . '"><img src="' . esc_url( wp_get_attachment_image_url( $listing_prv_img, array( 90, 90 ) ) ) . '" alt="listing image"></a>'; + } elseif ( ! empty( $listing_img[0] ) && empty( $listing_prv_img ) ) { + echo '<a href="' . esc_url( get_the_permalink() ) . '"><img src="' . esc_url( wp_get_attachment_image_url( $listing_img[0], array( 90, 90 ) ) ) . '" alt="listing image"></a>'; + } else { + echo '<a href="' . esc_url( get_the_permalink() ) . '"><img src="' . esc_url( $default_image ) . '" alt="listing image"></a>'; + } - ?> - </div> - <div class="directorist-widget-listing__content"> - <h4 class="directorist-widget-listing__title"><a href="<?php echo esc_url(get_post_permalink(get_the_ID())); ?>"><?php echo esc_html(stripslashes(get_the_title())); ?></a></h4> - <div class="directorist-widget-listing__meta"> - <span class="directorist-widget-listing__rating"> - <?php Markup::show_rating_stars( $review_rating );?> - </span> - <span class="directorist-widget-listing__rating-point"><?php echo esc_html( $review_rating ); ?></span> - <span class="directorist-widget-listing__reviews">(<?php echo $review_text ?>)</span> - </div> - <span class="directorist-widget-listing__price"> - <?php if (!empty($price) && ('price' === $listing_pricing)) { ?> - <span><?php atbdp_display_price($price); ?></span> + ?> + </div> + <div class="directorist-widget-listing__content"> + <h4 class="directorist-widget-listing__title"><a href="<?php echo esc_url( get_post_permalink( get_the_ID() ) ); ?>"><?php echo esc_html( stripslashes( get_the_title() ) ); ?></a></h4> + <div class="directorist-widget-listing__meta"> + <span class="directorist-widget-listing__rating"> + <?php Markup::show_rating_stars( $review_rating ); ?> + </span> + <span class="directorist-widget-listing__rating-point"><?php echo esc_html( $review_rating ); ?></span> + <span class="directorist-widget-listing__reviews">(<?php echo $review_text; ?>)</span> + </div> + <span class="directorist-widget-listing__price"> + <?php if ( ! empty( $price ) && ( 'price' === $listing_pricing ) ) { ?> + <span><?php atbdp_display_price( $price ); ?></span> - <?php } else { - $output = atbdp_display_price_range($price_range); - echo wp_kses_post( $output ); - } ?> - </span> - </div> - </div> - <?php - } - wp_reset_postdata(); - }; ?> - </div> + <?php + } else { + $output = atbdp_display_price_range( $price_range ); + echo wp_kses_post( $output ); + } + ?> + </span> + </div> + </div> + <?php + } + wp_reset_postdata(); + } + ?> + </div> </div> <!--ends featured listing--> \ No newline at end of file diff --git a/templates/widgets/listing-video.php b/templates/widgets/listing-video.php index 4c883428fb..7b3b14d321 100644 --- a/templates/widgets/listing-video.php +++ b/templates/widgets/listing-video.php @@ -5,13 +5,15 @@ * @version 7.8.0 */ -use \Directorist\Helper; +use Directorist\Helper; -if ( ! defined( 'ABSPATH' ) ) exit; -$videourl = ! empty( $videourl ) ? Helper::parse_video( $videourl ) : ''; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} +$videourl = ! empty( $videourl ) ? Helper::parse_video( $videourl ) : ''; ?> <div class="directorist-card__body directorist-widget__video"> - <iframe class="directorist-embaded-item" src="<?php echo esc_url( $videourl ); ?>" allowfullscreen></iframe> + <iframe class="directorist-embaded-item" src="<?php echo esc_url( $videourl ); ?>" allowfullscreen></iframe> </div> diff --git a/templates/widgets/login-form.php b/templates/widgets/login-form.php index 9b04e75b5e..054fcf7bf3 100644 --- a/templates/widgets/login-form.php +++ b/templates/widgets/login-form.php @@ -5,23 +5,25 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-card__body"> - <div class="directorist-widget-authentication"> - <?php - if (isset($_GET['login']) && $_GET['login'] == 'failed') { - ?> - <p class="alert-danger"> <?php directorist_icon( 'las la-exclamation' ); ?><?php esc_html_e(' Invalid username or password!', 'directorist');?></p> - <?php - } - wp_login_form(); - wp_register(); + <div class="directorist-widget-authentication"> + <?php + if ( isset( $_GET['login'] ) && $_GET['login'] == 'failed' ) { + ?> + <p class="alert-danger"> <?php directorist_icon( 'las la-exclamation' ); ?><?php esc_html_e( ' Invalid username or password!', 'directorist' ); ?></p> + <?php + } + wp_login_form(); + wp_register(); - $sign_up_text = sprintf(__( "Don't have an account? <a href='%s'>Sign up</a>", 'directorist' ), ATBDP_Permalink::get_registration_page_link() ); - ?> - <p><?php echo wp_kses_post( $sign_up_text );?></p> - </div> + $sign_up_text = sprintf( __( "Don't have an account? <a href='%s'>Sign up</a>", 'directorist' ), ATBDP_Permalink::get_registration_page_link() ); + ?> + <p><?php echo wp_kses_post( $sign_up_text ); ?></p> + </div> </div> diff --git a/templates/widgets/popular-listings.php b/templates/widgets/popular-listings.php index bd5be43f14..721ed921eb 100644 --- a/templates/widgets/popular-listings.php +++ b/templates/widgets/popular-listings.php @@ -5,96 +5,99 @@ * @version 8.0.8 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} use Directorist\Review\Markup; -if ( !$query->have_posts() ) { - return; +if ( ! $query->have_posts() ) { + return; } $default_icon = 'las la-tags'; ?> <div class="directorist-card__body"> - <div class="directorist-widget-listing"> - <?php while ( $query->have_posts() ): ?> + <div class="directorist-widget-listing"> + <?php while ( $query->have_posts() ) : ?> - <?php - $query->the_post(); - $id = get_the_ID(); - $disable_single_listing = get_directorist_option( 'disable_single_listing' ); - $top_category = ATBDP()->taxonomy->get_one_high_level_term( $id, ATBDP_CATEGORY ); - $listing_img = directorist_get_listing_gallery_images( $id ); - $listing_prv_img = directorist_get_listing_preview_image( $id ); - $cats = get_the_terms( $id, ATBDP_CATEGORY ); - $post_link = get_the_permalink( $id ); - $review_rating = directorist_get_listing_rating( get_the_ID() ); - $review_count = directorist_get_listing_review_count( get_the_ID() ); - $review_text = sprintf( _n( '%s review', $review_count > 0 ? '%s reviews' : '%s review', $review_count, 'directorist' ), number_format_i18n( $review_count ) ); - $price = get_post_meta( $id, '_price', true ); - $price_range = get_post_meta( $id, '_price_range', true ); - $listing_pricing = get_post_meta( $id, '_atbd_listing_pricing', true ); - ?> + <?php + $query->the_post(); + $id = get_the_ID(); + $disable_single_listing = get_directorist_option( 'disable_single_listing' ); + $top_category = ATBDP()->taxonomy->get_one_high_level_term( $id, ATBDP_CATEGORY ); + $listing_img = directorist_get_listing_gallery_images( $id ); + $listing_prv_img = directorist_get_listing_preview_image( $id ); + $cats = get_the_terms( $id, ATBDP_CATEGORY ); + $post_link = get_the_permalink( $id ); + $review_rating = directorist_get_listing_rating( get_the_ID() ); + $review_count = directorist_get_listing_review_count( get_the_ID() ); + $review_text = sprintf( _n( '%s review', $review_count > 0 ? '%s reviews' : '%s review', $review_count, 'directorist' ), number_format_i18n( $review_count ) ); + $price = get_post_meta( $id, '_price', true ); + $price_range = get_post_meta( $id, '_price_range', true ); + $listing_pricing = get_post_meta( $id, '_atbd_listing_pricing', true ); + ?> - <div class="directorist-widget-listing__single"> - <div class="directorist-widget-listing__image"> - <?php if ( empty( $disable_single_listing ) ) { ?> - <a href="<?php echo esc_url( get_the_permalink() ); ?>"> - <?php - } - $default_image = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); - if ( ! empty( $listing_prv_img ) ) { - echo '<img src="' . esc_url( wp_get_attachment_image_url( $listing_prv_img, array( 90, 90 ) ) ) . '" alt="' . esc_attr( get_the_title() ) . '">'; - } elseif ( ! empty( $listing_img[0] ) && empty( $listing_prv_img ) ) { - echo '<img src="' . esc_url( wp_get_attachment_image_url( $listing_img[0], array( 90, 90 ) ) ) . '" alt="' . esc_attr( get_the_title() ) . '">'; - } else { - echo '<img src="' . esc_url( $default_image ) . '" alt="' . esc_attr( get_the_title() ) . '">'; - } - if ( empty( $disable_single_listing ) ) { - echo '</a>'; - } - ?> - </div> + <div class="directorist-widget-listing__single"> + <div class="directorist-widget-listing__image"> + <?php if ( empty( $disable_single_listing ) ) { ?> + <a href="<?php echo esc_url( get_the_permalink() ); ?>"> + <?php + } + $default_image = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); + if ( ! empty( $listing_prv_img ) ) { + echo '<img src="' . esc_url( wp_get_attachment_image_url( $listing_prv_img, array( 90, 90 ) ) ) . '" alt="' . esc_attr( get_the_title() ) . '">'; + } elseif ( ! empty( $listing_img[0] ) && empty( $listing_prv_img ) ) { + echo '<img src="' . esc_url( wp_get_attachment_image_url( $listing_img[0], array( 90, 90 ) ) ) . '" alt="' . esc_attr( get_the_title() ) . '">'; + } else { + echo '<img src="' . esc_url( $default_image ) . '" alt="' . esc_attr( get_the_title() ) . '">'; + } + if ( empty( $disable_single_listing ) ) { + echo '</a>'; + } + ?> + </div> - <div class="directorist-widget-listing__content"> - <h4 class="directorist-widget-listing__title"> - <?php - if ( empty( $disable_single_listing ) ) { - ?> - <a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a> - <?php - } else { - echo esc_html( get_the_title() ); - } ?> - </h4> + <div class="directorist-widget-listing__content"> + <h4 class="directorist-widget-listing__title"> + <?php + if ( empty( $disable_single_listing ) ) { + ?> + <a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a> + <?php + } else { + echo esc_html( get_the_title() ); + } + ?> + </h4> - <div class="directorist-widget-listing__meta"> - <span class="directorist-widget-listing__rating"> - <?php Markup::show_rating_stars( $review_rating );?> - </span> - <span class="directorist-widget-listing__rating-point"><?php echo esc_html( $review_rating ); ?></span> - <span class="directorist-widget-listing__reviews">(<?php echo wp_kses_post( $review_text ); ?>)</span> - </div> - <div class="directorist-widget-listing__price"> - <?php if ( ! empty( $price ) && ( 'price' === $listing_pricing ) ) { ?> + <div class="directorist-widget-listing__meta"> + <span class="directorist-widget-listing__rating"> + <?php Markup::show_rating_stars( $review_rating ); ?> + </span> + <span class="directorist-widget-listing__rating-point"><?php echo esc_html( $review_rating ); ?></span> + <span class="directorist-widget-listing__reviews">(<?php echo wp_kses_post( $review_text ); ?>)</span> + </div> + <div class="directorist-widget-listing__price"> + <?php if ( ! empty( $price ) && ( 'price' === $listing_pricing ) ) { ?> - <span><?php atbdp_display_price( $price ); ?></span> + <span><?php atbdp_display_price( $price ); ?></span> - <?php - } else { + <?php + } else { - $output = atbdp_display_price_range( $price_range ); - echo wp_kses_post( $output ); + $output = atbdp_display_price_range( $price_range ); + echo wp_kses_post( $output ); - } - ?> - </div> - </div> + } + ?> + </div> + </div> - </div> + </div> - <?php endwhile; ?> + <?php endwhile; ?> <?php wp_reset_postdata(); ?> - </div> + </div> </div> \ No newline at end of file diff --git a/templates/widgets/search-form.php b/templates/widgets/search-form.php index 473efa3de0..df2c07f296 100644 --- a/templates/widgets/search-form.php +++ b/templates/widgets/search-form.php @@ -5,31 +5,33 @@ * @version 7.7.0 */ -if (!defined('ABSPATH')) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} -$search_form_fields = Directorist\Helper::get_directory_type_term_data(get_the_ID(), 'search_form_fields'); -$directoriy_type = get_post_meta(get_the_ID(), '_directory_type', true); -$searchform = new Directorist\Directorist_Listing_Search_Form('listing', $directoriy_type); +$search_form_fields = Directorist\Helper::get_directory_type_term_data( get_the_ID(), 'search_form_fields' ); +$directoriy_type = get_post_meta( get_the_ID(), '_directory_type', true ); +$searchform = new Directorist\Directorist_Listing_Search_Form( 'listing', $directoriy_type ); -if (is_numeric($searchform->listing_type)) { - $term = get_term_by('id', $searchform->listing_type, ATBDP_TYPE); +if ( is_numeric( $searchform->listing_type ) ) { + $term = get_term_by( 'id', $searchform->listing_type, ATBDP_TYPE ); $listing_type = $term->slug; } ?> <div class="directorist-card__body"> - <div class="directorist-widget-advanced-search directorist-contents-wrap <?php echo is_singular(ATBDP_POST_TYPE) ? esc_html('directorist_single') : ''; ?>"> + <div class="directorist-widget-advanced-search directorist-contents-wrap <?php echo is_singular( ATBDP_POST_TYPE ) ? esc_html( 'directorist_single' ) : ''; ?>"> <form action="<?php atbdp_search_result_page_link(); ?>" class="directorist-search-form directorist-advanced-filter__form"> - <input type="hidden" name='directory_type' value='<?php echo !empty($listing_type) ? esc_attr( $listing_type ) : esc_attr( $searchform->listing_type ); ?>'> + <input type="hidden" name='directory_type' value='<?php echo ! empty( $listing_type ) ? esc_attr( $listing_type ) : esc_attr( $searchform->listing_type ); ?>'> <div class="directorist-advanced-filter__basic"> - <?php foreach ($searchform->form_data[0]['fields'] as $field) : ?> - <div class="directorist-advanced-filter__basic__element"><?php $searchform->field_template($field); ?></div> + <?php foreach ( $searchform->form_data[0]['fields'] as $field ) : ?> + <div class="directorist-advanced-filter__basic__element"><?php $searchform->field_template( $field ); ?></div> <?php endforeach; ?> </div> <div class="directorist-advanced-filter__advanced"> - <?php foreach ($searchform->form_data[1]['fields'] as $field) : ?> - <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr($field['widget_name']) ?>"><?php $searchform->field_template($field); ?></div> + <?php foreach ( $searchform->form_data[1]['fields'] as $field ) : ?> + <div class="directorist-advanced-filter__advanced__element directorist-search-field-<?php echo esc_attr( $field['widget_name'] ); ?>"><?php $searchform->field_template( $field ); ?></div> <?php endforeach; ?> </div> <?php $searchform->buttons_template(); ?> diff --git a/templates/widgets/similar-listing.php b/templates/widgets/similar-listing.php index f52b1d8c93..7d7612f1cd 100644 --- a/templates/widgets/similar-listing.php +++ b/templates/widgets/similar-listing.php @@ -5,87 +5,92 @@ * @version 8.0.8 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} use Directorist\Review\Markup; if ( empty( $related_listings->posts ) ) { - return; + return; } $default_icon = 'las la-tags'; ?> <div class="directorist-card__body"> - <div class="directorist-widget-listing"> - <?php - foreach ($related_listings->posts as $related_listing) { + <div class="directorist-widget-listing"> + <?php + foreach ( $related_listings->posts as $related_listing ) { - // get only one parent or high level term object - $top_category = ATBDP()->taxonomy->get_one_high_level_term($related_listing->ID, ATBDP_CATEGORY); - $listing_img = directorist_get_listing_gallery_images( $related_listing->ID ); - $listing_prv_img = directorist_get_listing_preview_image( $related_listing->ID ); - $review_rating = directorist_get_listing_rating( get_the_ID() ); - $review_count = directorist_get_listing_review_count( get_the_ID() ); - $review_text = sprintf( _n( '%s review', $review_count > 0 ? '%s reviews' : '%s review', $review_count, 'directorist' ), number_format_i18n( $review_count ) ); - $price = get_post_meta($related_listing->ID, '_price', true); - $price_range = get_post_meta($related_listing->ID, '_price_range', true); - $listing_pricing = get_post_meta($related_listing->ID, '_atbd_listing_pricing', true); - $cats = get_the_terms($related_listing->ID, ATBDP_CATEGORY); - ?> - <div class="directorist-widget-listing__single"> - <div class="directorist-widget-listing__image"> - <?php - $disable_single_listing = get_directorist_option('disable_single_listing'); - if (empty($disable_single_listing)) { - ?> - <a href="<?php echo esc_url(get_post_permalink($related_listing->ID)); ?>"> - <?php - } - $default_image = get_directorist_option('default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg'); - if (!empty($listing_prv_img)) { - echo '<img src="' . esc_url(wp_get_attachment_image_url($listing_prv_img, array(90, 90))) . '" alt="listing image">'; - } elseif (!empty($listing_img[0]) && empty($listing_prv_img)) { - echo '<img src="' . esc_url(wp_get_attachment_image_url($listing_img[0], array(90, 90))) . '" alt="listing image">'; - } else { - echo '<img src="' . esc_url( $default_image ) . '" alt="listing image">'; - } - if (empty($disable_single_listing)) { - echo '</a>'; - } - ?> - </div> - <div class="directorist-widget-listing__content"> - <h4 class="directorist-widget-listing__title"> - <?php - if (empty($disable_single_listing)) { - ?> - <a href="<?php echo esc_url(get_post_permalink($related_listing->ID)); ?>"><?php echo esc_html($related_listing->post_title); ?></a> - <?php - } else { - echo esc_html($related_listing->post_title); - } ?> + // get only one parent or high level term object + $top_category = ATBDP()->taxonomy->get_one_high_level_term( $related_listing->ID, ATBDP_CATEGORY ); + $listing_img = directorist_get_listing_gallery_images( $related_listing->ID ); + $listing_prv_img = directorist_get_listing_preview_image( $related_listing->ID ); + $review_rating = directorist_get_listing_rating( get_the_ID() ); + $review_count = directorist_get_listing_review_count( get_the_ID() ); + $review_text = sprintf( _n( '%s review', $review_count > 0 ? '%s reviews' : '%s review', $review_count, 'directorist' ), number_format_i18n( $review_count ) ); + $price = get_post_meta( $related_listing->ID, '_price', true ); + $price_range = get_post_meta( $related_listing->ID, '_price_range', true ); + $listing_pricing = get_post_meta( $related_listing->ID, '_atbd_listing_pricing', true ); + $cats = get_the_terms( $related_listing->ID, ATBDP_CATEGORY ); + ?> + <div class="directorist-widget-listing__single"> + <div class="directorist-widget-listing__image"> + <?php + $disable_single_listing = get_directorist_option( 'disable_single_listing' ); + if ( empty( $disable_single_listing ) ) { + ?> + <a href="<?php echo esc_url( get_post_permalink( $related_listing->ID ) ); ?>"> + <?php + } + $default_image = get_directorist_option( 'default_preview_image', DIRECTORIST_ASSETS . 'images/grid.jpg' ); + if ( ! empty( $listing_prv_img ) ) { + echo '<img src="' . esc_url( wp_get_attachment_image_url( $listing_prv_img, array( 90, 90 ) ) ) . '" alt="listing image">'; + } elseif ( ! empty( $listing_img[0] ) && empty( $listing_prv_img ) ) { + echo '<img src="' . esc_url( wp_get_attachment_image_url( $listing_img[0], array( 90, 90 ) ) ) . '" alt="listing image">'; + } else { + echo '<img src="' . esc_url( $default_image ) . '" alt="listing image">'; + } + if ( empty( $disable_single_listing ) ) { + echo '</a>'; + } + ?> + </div> + <div class="directorist-widget-listing__content"> + <h4 class="directorist-widget-listing__title"> + <?php + if ( empty( $disable_single_listing ) ) { + ?> + <a href="<?php echo esc_url( get_post_permalink( $related_listing->ID ) ); ?>"><?php echo esc_html( $related_listing->post_title ); ?></a> + <?php + } else { + echo esc_html( $related_listing->post_title ); + } + ?> - </h4> - <div class="directorist-widget-listing__meta"> - <span class="directorist-widget-listing__rating"> - <?php Markup::show_rating_stars( $review_rating );?> - </span> - <span class="directorist-widget-listing__rating-point"><?php echo esc_html( $review_rating ); ?></span> - <span class="directorist-widget-listing__reviews">(<?php echo $review_text ?>)</span> - </div> - <div class="directorist-widget-listing__price"> - <?php if (!empty($price) && ('price' === $listing_pricing)) { ?> - <span><?php atbdp_display_price($price); ?></span> + </h4> + <div class="directorist-widget-listing__meta"> + <span class="directorist-widget-listing__rating"> + <?php Markup::show_rating_stars( $review_rating ); ?> + </span> + <span class="directorist-widget-listing__rating-point"><?php echo esc_html( $review_rating ); ?></span> + <span class="directorist-widget-listing__reviews">(<?php echo $review_text; ?>)</span> + </div> + <div class="directorist-widget-listing__price"> + <?php if ( ! empty( $price ) && ( 'price' === $listing_pricing ) ) { ?> + <span><?php atbdp_display_price( $price ); ?></span> - <?php } else { - $output = atbdp_display_price_range($price_range); - echo wp_kses_post( $output ); - } ?> - </div> - </div> - </div> - <?php } ?> - </div> + <?php + } else { + $output = atbdp_display_price_range( $price_range ); + echo wp_kses_post( $output ); + } + ?> + </div> + </div> + </div> + <?php } ?> + </div> </div> <!--ends .categorized_listings--> \ No newline at end of file diff --git a/templates/widgets/single-map.php b/templates/widgets/single-map.php index 126e740fe9..3bc005b37a 100644 --- a/templates/widgets/single-map.php +++ b/templates/widgets/single-map.php @@ -5,8 +5,10 @@ * @version 8.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-card__body"> - <div class="directorist-single-map directorist-widget__map" data-map="<?php echo esc_attr( $map_data ); ?>"></div> + <div class="directorist-single-map directorist-widget__map" data-map="<?php echo esc_attr( $map_data ); ?>"></div> </div> \ No newline at end of file diff --git a/templates/widgets/submit-listing.php b/templates/widgets/submit-listing.php index 9e1fb5c973..ac2e1fa56c 100644 --- a/templates/widgets/submit-listing.php +++ b/templates/widgets/submit-listing.php @@ -5,10 +5,12 @@ * @version 7.7.0 */ -if ( ! defined( 'ABSPATH' ) ) exit; +if ( ! defined( 'ABSPATH' ) ) { + exit; +} ?> <div class="directorist-card__body directorist-widget__submit-listing"> - <a href="<?php echo is_fee_manager_active() ? esc_url(ATBDP_Permalink::get_fee_plan_page_link()): esc_url(ATBDP_Permalink::get_add_listing_page_link()); ?>" - class="<?php echo esc_attr( atbdp_directorist_button_classes() ); ?>"><?php esc_html_e('Submit New Listing', 'directorist'); ?></a> + <a href="<?php echo is_fee_manager_active() ? esc_url( ATBDP_Permalink::get_fee_plan_page_link() ) : esc_url( ATBDP_Permalink::get_add_listing_page_link() ); ?>" + class="<?php echo esc_attr( atbdp_directorist_button_classes() ); ?>"><?php esc_html_e( 'Submit New Listing', 'directorist' ); ?></a> </div> diff --git a/uninstall.php b/uninstall.php index 5c4f134f09..cbecf3649b 100644 --- a/uninstall.php +++ b/uninstall.php @@ -2,115 +2,115 @@ /** * @package Directorist */ -defined('WP_UNINSTALL_PLUGIN') || exit; +defined( 'WP_UNINSTALL_PLUGIN' ) || exit; global $wpdb; -include_once("directorist-base.php"); +require_once 'directorist-base.php'; // Clear schedules -wp_clear_scheduled_hook('directorist_hourly_scheduled_events'); +wp_clear_scheduled_hook( 'directorist_hourly_scheduled_events' ); function directorist_uninstall() { - global $wpdb; - - // Delete selected pages - wp_delete_post(get_directorist_option('add_listing_page'), true); - wp_delete_post(get_directorist_option('all_listing_page'), true); - wp_delete_post(get_directorist_option('user_dashboard'), true); - wp_delete_post(get_directorist_option('author_profile_page'), true); - wp_delete_post(get_directorist_option('all_categories_page'), true); - wp_delete_post(get_directorist_option('single_category_page'), true); - wp_delete_post(get_directorist_option('all_locations_page'), true); - wp_delete_post(get_directorist_option('single_location_page'), true); - wp_delete_post(get_directorist_option('single_tag_page'), true); - wp_delete_post(get_directorist_option('custom_registration'), true); - wp_delete_post(get_directorist_option('user_login'), true); - wp_delete_post(get_directorist_option('search_listing'), true); - wp_delete_post(get_directorist_option('search_result_page'), true); - wp_delete_post(get_directorist_option('checkout_page'), true); - wp_delete_post(get_directorist_option('payment_receipt_page'), true); - wp_delete_post(get_directorist_option('transaction_failure_page'), true); - wp_delete_post(get_directorist_option('privacy_policy'), true); - wp_delete_post(get_directorist_option('terms_conditions'), true); - - // Delete posts and data - $wpdb->query("DELETE FROM {$wpdb->posts} WHERE post_type IN ('at_biz_dir', 'atbdp_fields', 'atbdp_orders', 'atbdp_listing_review', 'atbdp_pricing_plans', 'dcl_claim_listing');"); - - // Delete all metabox - $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id NOT IN (SELECT ID FROM {$wpdb->posts});"); - - // Delete term relationships - $wpdb->query("DELETE FROM {$wpdb->term_relationships} WHERE object_id NOT IN (SELECT ID FROM {$wpdb->posts});"); - - // Delete all taxonomy - $wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-location'"); - $wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-category'"); - $wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-tags'"); - $wpdb->query("DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'atbdp_listing_types'"); - - // Delete all term meta - $wpdb->query("DELETE FROM {$wpdb->termmeta} WHERE term_id NOT IN (SELECT term_id FROM {$wpdb->term_taxonomy});"); - $wpdb->query("DELETE FROM {$wpdb->terms} WHERE term_id NOT IN (SELECT term_id FROM {$wpdb->term_taxonomy});"); - - // Delete review database - $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}atbdp_review"); - - // Delete usermeta - $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '%atbdp%';"); - $wpdb->query("DELETE FROM $wpdb->usermeta WHERE meta_key = 'pro_pic';"); - - // Delete all the Plugin Options - $atbdp_settings = array( - "{$wpdb->prefix}atbdp_review_db_version", - 'atbdp_option', - 'widget_bdpl_widget', - 'widget_bdvd_widget', - 'widget_bdco_widget', - 'widget_bdsb_widget', - 'widget_bdlf_widget', - 'widget_bdcw_widget', - 'widget_bdlw_widget', - 'widget_bdtw_widget', - 'widget_bdsw_widget', - 'widget_bdmw_widget', - 'widget_bdamw_widget', - 'widget_bdsl_widget', - 'widget_bdsi_widget', - 'widget_bdfl_widget', - 'atbdp_meta_version', - 'atbdp_pages_version', - 'atbdp_roles_mapped', - 'atbdp_roles_version', - 'at_biz_dir-location_children', - 'at_biz_dir-category_children', - ); - - foreach ($atbdp_settings as $settings) { - delete_option($settings); - } + global $wpdb; + + // Delete selected pages + wp_delete_post( get_directorist_option( 'add_listing_page' ), true ); + wp_delete_post( get_directorist_option( 'all_listing_page' ), true ); + wp_delete_post( get_directorist_option( 'user_dashboard' ), true ); + wp_delete_post( get_directorist_option( 'author_profile_page' ), true ); + wp_delete_post( get_directorist_option( 'all_categories_page' ), true ); + wp_delete_post( get_directorist_option( 'single_category_page' ), true ); + wp_delete_post( get_directorist_option( 'all_locations_page' ), true ); + wp_delete_post( get_directorist_option( 'single_location_page' ), true ); + wp_delete_post( get_directorist_option( 'single_tag_page' ), true ); + wp_delete_post( get_directorist_option( 'custom_registration' ), true ); + wp_delete_post( get_directorist_option( 'user_login' ), true ); + wp_delete_post( get_directorist_option( 'search_listing' ), true ); + wp_delete_post( get_directorist_option( 'search_result_page' ), true ); + wp_delete_post( get_directorist_option( 'checkout_page' ), true ); + wp_delete_post( get_directorist_option( 'payment_receipt_page' ), true ); + wp_delete_post( get_directorist_option( 'transaction_failure_page' ), true ); + wp_delete_post( get_directorist_option( 'privacy_policy' ), true ); + wp_delete_post( get_directorist_option( 'terms_conditions' ), true ); + + // Delete posts and data + $wpdb->query( "DELETE FROM {$wpdb->posts} WHERE post_type IN ('at_biz_dir', 'atbdp_fields', 'atbdp_orders', 'atbdp_listing_review', 'atbdp_pricing_plans', 'dcl_claim_listing');" ); + + // Delete all metabox + $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE post_id NOT IN (SELECT ID FROM {$wpdb->posts});" ); + + // Delete term relationships + $wpdb->query( "DELETE FROM {$wpdb->term_relationships} WHERE object_id NOT IN (SELECT ID FROM {$wpdb->posts});" ); + + // Delete all taxonomy + $wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-location'" ); + $wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-category'" ); + $wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'at_biz_dir-tags'" ); + $wpdb->query( "DELETE FROM {$wpdb->term_taxonomy} WHERE taxonomy = 'atbdp_listing_types'" ); + + // Delete all term meta + $wpdb->query( "DELETE FROM {$wpdb->termmeta} WHERE term_id NOT IN (SELECT term_id FROM {$wpdb->term_taxonomy});" ); + $wpdb->query( "DELETE FROM {$wpdb->terms} WHERE term_id NOT IN (SELECT term_id FROM {$wpdb->term_taxonomy});" ); + + // Delete review database + $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}atbdp_review" ); + + // Delete usermeta + $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key LIKE '%atbdp%';" ); + $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'pro_pic';" ); + + // Delete all the Plugin Options + $atbdp_settings = array( + "{$wpdb->prefix}atbdp_review_db_version", + 'atbdp_option', + 'widget_bdpl_widget', + 'widget_bdvd_widget', + 'widget_bdco_widget', + 'widget_bdsb_widget', + 'widget_bdlf_widget', + 'widget_bdcw_widget', + 'widget_bdlw_widget', + 'widget_bdtw_widget', + 'widget_bdsw_widget', + 'widget_bdmw_widget', + 'widget_bdamw_widget', + 'widget_bdsl_widget', + 'widget_bdsi_widget', + 'widget_bdfl_widget', + 'atbdp_meta_version', + 'atbdp_pages_version', + 'atbdp_roles_mapped', + 'atbdp_roles_version', + 'at_biz_dir-location_children', + 'at_biz_dir-category_children', + ); + + foreach ( $atbdp_settings as $settings ) { + delete_option( $settings ); + } } -if (is_multisite()) { - $original_blog_id = get_current_blog_id(); - $sites = get_sites(); +if ( is_multisite() ) { + $original_blog_id = get_current_blog_id(); + $sites = get_sites(); - foreach ($sites as $site) { - switch_to_blog($site->blog_id); - - if( ! get_directorist_option('enable_uninstall',0) ) { - continue; - } + foreach ( $sites as $site ) { + switch_to_blog( $site->blog_id ); - directorist_uninstall(); - restore_current_blog(); - } + if ( ! get_directorist_option( 'enable_uninstall', 0 ) ) { + continue; + } - switch_to_blog($original_blog_id); + directorist_uninstall(); + restore_current_blog(); + } + + switch_to_blog( $original_blog_id ); } else { - if( ! get_directorist_option('enable_uninstall',0) ) { - return; - } - - directorist_uninstall(); -} \ No newline at end of file + if ( ! get_directorist_option( 'enable_uninstall', 0 ) ) { + return; + } + + directorist_uninstall(); +} diff --git a/views/admin-templates/admin-promo-banner.php b/views/admin-templates/admin-promo-banner.php index 21d891e676..68c3e8944d 100644 --- a/views/admin-templates/admin-promo-banner.php +++ b/views/admin-templates/admin-promo-banner.php @@ -5,12 +5,12 @@ * @version 1.0 */ -$response_body = ATBDP_Upgrade::promo_remote_get(); -$display_promo = ! empty( $response_body->display_promo ) ? $response_body->display_promo : ''; -$promo_version = ! empty( $response_body->promo_version ) ? $response_body->promo_version : ''; +$response_body = ATBDP_Upgrade::promo_remote_get(); +$display_promo = ! empty( $response_body->display_promo ) ? $response_body->display_promo : ''; +$promo_version = ! empty( $response_body->promo_version ) ? $response_body->promo_version : ''; $directorist_promo_closed = get_user_meta( get_current_user_id(), '_directorist_promo_closed', true ); -if( ! $display_promo || ( $directorist_promo_closed && ( $directorist_promo_closed == $promo_version ) ) ) { +if ( ! $display_promo || ( $directorist_promo_closed && ( $directorist_promo_closed == $promo_version ) ) ) { return; } @@ -18,50 +18,59 @@ $banner_description = ! empty( $response_body->banner_description ) ? $response_body->banner_description : ''; $sale_button_text = ! empty( $response_body->sale_button_text ) ? $response_body->sale_button_text : ''; $sale_button_link = ! empty( $response_body->sale_button_link ) ? ATBDP_Upgrade::promo_link( $response_body->sale_button_link ) : ''; -$offer_lists = ! empty( $response_body->offer_lists ) ? $response_body->offer_lists : []; +$offer_lists = ! empty( $response_body->offer_lists ) ? $response_body->offer_lists : array(); $get_now_button_text = ! empty( $response_body->get_now_button_text ) ? $response_body->get_now_button_text : ''; $get_now_button_link = ! empty( $response_body->get_now_button_link ) ? ATBDP_Upgrade::promo_link( $response_body->get_now_button_link ) : ''; -$url_args = [ +$url_args = array( 'close-directorist-promo-version' => $promo_version, - 'directorist_promo_nonce' => wp_create_nonce( 'directorist_promo_nonce' ) -]; + 'directorist_promo_nonce' => wp_create_nonce( 'directorist_promo_nonce' ), +); ?> - <div class="directorist_membership-notice"> - <div class="directorist_membership-notice__content"> - <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/promo-logo.jpg' ); ?>" alt="Drectorist membership notice"> - <div class="directorist_membership-notice__text"> - <?php - if( $banner_title ){ ?> - <h4><?php echo esc_html( $banner_title ); ?></h4> - <?php } - if( $banner_description ){ ?> - <p><?php echo esc_html( $banner_description ); ?></p> - <?php } - if( $sale_button_text ){ ?> - <a class="directorist_membership-sale-badge" target="_blank" href="<?php echo esc_url( $sale_button_link ); ?>"><?php echo esc_html( $sale_button_text ); ?></a> - <?php } ?> - </div> - </div> +<div class="directorist_membership-notice"> + <div class="directorist_membership-notice__content"> + <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/promo-logo.jpg' ); ?>" alt="Drectorist membership notice"> + <div class="directorist_membership-notice__text"> + <?php + if ( $banner_title ) { + ?> + <h4><?php echo esc_html( $banner_title ); ?></h4> + <?php + } + if ( $banner_description ) { + ?> + <p><?php echo esc_html( $banner_description ); ?></p> + <?php + } + if ( $sale_button_text ) { + ?> + <a class="directorist_membership-sale-badge" target="_blank" href="<?php echo esc_url( $sale_button_link ); ?>"><?php echo esc_html( $sale_button_text ); ?></a> + <?php } ?> + </div> + </div> - <?php - if( $offer_lists ) { ?> - <ul class="directorist_membership-notice__list"> - <?php - foreach( $offer_lists as $offer ){ ?> - <li> - <span class="directorist_membership-notice__list__icon"><i class="fa fa-check"></i></span> - <span class="directorist_membership-notice__list__text"><?php echo esc_html( $offer ); ?></span> - </li> - <?php } ?> - </ul> - <?php } - if( $get_now_button_text ) { ?> - <div class="directorist_membership-notice__action"> - <a href="<?php echo esc_url( $get_now_button_link ); ?>" target="_blank" class="directorist_membership-btn"><?php echo esc_html( $get_now_button_text ); ?></a> - </div> - <?php } ?> - <a href="<?php echo esc_url( add_query_arg( $url_args, atbdp_get_current_url() ) );?>" class="directorist_membership-notice-close"> - <i class="fa fa-times"></i> - </a> + <?php + if ( $offer_lists ) { + ?> + <ul class="directorist_membership-notice__list"> + <?php + foreach ( $offer_lists as $offer ) { + ?> + <li> + <span class="directorist_membership-notice__list__icon"><i class="fa fa-check"></i></span> + <span class="directorist_membership-notice__list__text"><?php echo esc_html( $offer ); ?></span> + </li> + <?php } ?> + </ul> + <?php + } + if ( $get_now_button_text ) { + ?> + <div class="directorist_membership-notice__action"> + <a href="<?php echo esc_url( $get_now_button_link ); ?>" target="_blank" class="directorist_membership-btn"><?php echo esc_html( $get_now_button_text ); ?></a> + </div> + <?php } ?> + <a href="<?php echo esc_url( add_query_arg( $url_args, atbdp_get_current_url() ) ); ?>" class="directorist_membership-notice-close"> + <i class="fa fa-times"></i> + </a> </div> \ No newline at end of file diff --git a/views/admin-templates/import-export/body-templates/step-done.php b/views/admin-templates/import-export/body-templates/step-done.php index 70703a3727..65aeb59ef9 100644 --- a/views/admin-templates/import-export/body-templates/step-done.php +++ b/views/admin-templates/import-export/body-templates/step-done.php @@ -16,12 +16,16 @@ <div class="wc-actions"> <span class="dashicons dashicons-yes"></span> <p class="import-complete"><?php esc_html_e( 'Import Completed!', 'directorist' ); ?></p> - <p><strong><?php echo esc_attr($imported)?></strong> <?php esc_html_e('listings imported', 'directorist'); - if(($failed != 'NaN') && ($failed != '0')){ - ?> - &<strong><?php echo ' ' .esc_attr($failed);?></strong> <?php esc_html_e('were skipped.', 'directorist'); - } - ?> + <p><strong><?php echo esc_attr( $imported ); ?></strong> + <?php + esc_html_e( 'listings imported', 'directorist' ); + if ( ( $failed != 'NaN' ) && ( $failed != '0' ) ) { + ?> + &<strong><?php echo ' ' . esc_attr( $failed ); ?></strong> + <?php + esc_html_e( 'were skipped.', 'directorist' ); + } + ?> </p> </div> </div> diff --git a/views/admin-templates/import-export/body-templates/step-one.php b/views/admin-templates/import-export/body-templates/step-one.php index 0aa25a53cb..eb9819f81d 100644 --- a/views/admin-templates/import-export/body-templates/step-one.php +++ b/views/admin-templates/import-export/body-templates/step-one.php @@ -5,8 +5,8 @@ defined( 'ABSPATH' ) || exit; -$bytes = apply_filters('import_upload_size_limit', wp_max_upload_size()); -$size = size_format($bytes); +$bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); +$size = size_format( $bytes ); $upload_dir = wp_upload_dir(); ?> diff --git a/views/admin-templates/import-export/body-templates/step-two.php b/views/admin-templates/import-export/body-templates/step-two.php index 883465cb00..7a7325d822 100644 --- a/views/admin-templates/import-export/body-templates/step-two.php +++ b/views/admin-templates/import-export/body-templates/step-two.php @@ -23,12 +23,12 @@ $total = ( $csv_from_builder ) ? count( $builder_posts ) : $total; // csv_from_builder -function csv_from_builder( $data = [] ) { +function csv_from_builder( $data = array() ) { if ( ! is_array( $data ) || count( $data ) < 1 ) { return false; } - if ( empty( $data[0]['directory_type'] ) ) { + if ( empty( $data[0]['directory_type'] ) ) { return false; } @@ -41,45 +41,54 @@ function csv_from_builder( $data = [] ) { <form class="atbdp-progress-form-content directorist-importer" id="atbdp_csv_step_two" method="post"> <header> <?php if ( $csv_from_builder ) : ?> - <h2><?php esc_html_e('Importing listings', 'directorist'); ?></h2> - <?php else: ?> - <h2><?php esc_html_e('Map CSV fields to listings', 'directorist'); ?></h2> - <p><?php esc_html_e('Select Directorist fields to map it against your CSV file fields, leave it as "Do not import" to skip certain fields.', 'directorist'); ?></p> + <h2><?php esc_html_e( 'Importing listings', 'directorist' ); ?></h2> + <?php else : ?> + <h2><?php esc_html_e( 'Map CSV fields to listings', 'directorist' ); ?></h2> + <p><?php esc_html_e( 'Select Directorist fields to map it against your CSV file fields, leave it as "Do not import" to skip certain fields.', 'directorist' ); ?></p> <?php endif; ?> </header> <div class="form-content"> <section class="atbdp-importer-mapping-table-wrapper"> - <h3><?php printf( esc_html__('Total %s items selected ', 'directorist'), esc_attr( $total ) ); ?></h3> + <h3><?php printf( esc_html__( 'Total %s items selected ', 'directorist' ), esc_attr( $total ) ); ?></h3> <div class="directory_type_wrapper"> - <?php if ( $csv_from_builder ) : - ?><input type="hidden" class="directorist-listings-importer-config-field" name="csv_file" value="<?php echo esc_attr( $file ) ?>"><?php - foreach ( $builder_posts[0] as $post_key => $post_value ) { - ?><input type="hidden" class="atbdp_map_to" name="<?php echo esc_attr( $post_key ); ?>" value="<?php echo esc_attr( $post_key ); ?>"><?php + <?php + if ( $csv_from_builder ) : + ?> + <input type="hidden" class="directorist-listings-importer-config-field" name="csv_file" value="<?php echo esc_attr( $file ); ?>"> + <?php + foreach ( $builder_posts[0] as $post_key => $post_value ) { + ?> + <input type="hidden" class="atbdp_map_to" name="<?php echo esc_attr( $post_key ); ?>" value="<?php echo esc_attr( $post_key ); ?>"> + <?php } - else: - if( count( directory_types() ) > 1 ) { ?> - <label for="directory_type"><?php esc_html_e('Select Directory', 'directorist'); ?></label> + else : + if ( count( directory_types() ) > 1 ) { + ?> + <label for="directory_type"><?php esc_html_e( 'Select Directory', 'directorist' ); ?></label> <select class="directorist_directory_type_in_import" id="directory_type"> <option value="">--Select--</option> <?php - foreach( directory_types() as $term ) { - $default = get_term_meta( $term->term_id, '_default', true ); ?> - <option <?php echo !empty( $default ) ? 'selected' : ''; ?> value="<?php echo esc_attr( $term->term_id); ?>"><?php echo esc_attr( $term->name ); ?></option> + foreach ( directory_types() as $term ) { + $default = get_term_meta( $term->term_id, '_default', true ); + ?> + <option <?php echo ! empty( $default ) ? 'selected' : ''; ?> value="<?php echo esc_attr( $term->term_id ); ?>"><?php echo esc_attr( $term->name ); ?></option> <?php } ?> </select> - <?php } + <?php + } $this->tools->get_data_table( $file, $delimiter ); - endif; ?> + endif; + ?> </div> </section> </div> <div class="atbdp-actions"> - <button type="submit" class="button btn-run-importer" value="<?php esc_attr_e('Run the importer', 'directorist'); ?>" name="save_step_two"><?php esc_html_e('Run the importer', 'directorist'); ?></button> + <button type="submit" class="button btn-run-importer" value="<?php esc_attr_e( 'Run the importer', 'directorist' ); ?>" name="save_step_two"><?php esc_html_e( 'Run the importer', 'directorist' ); ?></button> <input type="hidden" class="directorist-listings-importer-config-field" name="csv_file" value="<?php echo esc_attr( $file ); ?>"> <input type="hidden" class="directorist-listings-importer-config-field" name="delimiter" value="<?php echo esc_attr( $delimiter ); ?>" /> <input type="hidden" class="directorist-listings-importer-config-field" name="update_existing" value="<?php echo esc_attr( $update_existing ); ?>" /> - <?php wp_nonce_field('directorist-csv-importer'); ?> + <?php wp_nonce_field( 'directorist-csv-importer' ); ?> </div> </form> <div id="directorist-type-preloader"> @@ -94,13 +103,19 @@ function csv_from_builder( $data = [] ) { <div class="directorist-importer__importing" style="display: none;"> <header> <span class="spinner is-active"></span> - <h2><?php esc_html_e( 'Importing', 'directorist' ); - ?></h2> - <p><?php esc_html_e( 'Your listings are now being imported...', 'directorist' ); - ?></p> + <h2> + <?php + esc_html_e( 'Importing', 'directorist' ); + ?> + </h2> + <p> + <?php + esc_html_e( 'Your listings are now being imported...', 'directorist' ); + ?> + </p> </header> <section> - <span class="importer-notice"><?php esc_html_e('Please don\'t reload the page', 'directorist')?></span> + <span class="importer-notice"><?php esc_html_e( 'Please don\'t reload the page', 'directorist' ); ?></span> <div class="directorist-importer-wrapper"> <progress class="directorist-importer-progress" max="100" value="0"></progress> <span class="directorist-importer-length"></span> diff --git a/views/admin-templates/import-export/data-table.php b/views/admin-templates/import-export/data-table.php index 2379864ed3..f0a9459c1d 100644 --- a/views/admin-templates/import-export/data-table.php +++ b/views/admin-templates/import-export/data-table.php @@ -3,46 +3,47 @@ * @author wpWax */ -if ( ! defined( 'ABSPATH' ) ) { exit; } +if ( ! defined( 'ABSPATH' ) ) { + exit; } $headers = $args['data']; $fields = $args['fields']; ?> -<input type="hidden" name="csv_file" value="<?php echo esc_attr( $args['csv_file'] ) ?>"> +<input type="hidden" name="csv_file" value="<?php echo esc_attr( $args['csv_file'] ); ?>"> <table class="widefat atbdp-importer-mapping-table"> - <thead> - <tr> - <th><?php esc_html_e('Column name', 'directorist'); ?></th> - <th><?php esc_html_e('Map to field', 'directorist'); ?></th> - </tr> - </thead> - <tbody> - <?php - if ( is_array( $headers ) ) : - foreach ($headers as $index => $name) : + <thead> + <tr> + <th><?php esc_html_e( 'Column name', 'directorist' ); ?></th> + <th><?php esc_html_e( 'Map to field', 'directorist' ); ?></th> + </tr> + </thead> + <tbody> + <?php + if ( is_array( $headers ) ) : + foreach ( $headers as $index => $name ) : $field_key = directorist_translate_to_listing_field_key( $index ); ?> - <tr> - <td class="atbdp-importer-mapping-table-name"> - <p><?php echo esc_html($index); ?></p> - <?php if (!empty($name)) : ?> - <span class="description"><?php esc_html_e('Sample:', 'directorist'); ?> <code><?php echo esc_html($name); ?></code></span> - <?php endif; ?> - </td> - <td class="atbdp-importer-mapping-table-field"> - <input type="hidden" name="map_from[<?php echo esc_attr($index); ?>]" value="<?php echo esc_attr($name); ?>" /> - <select class="atbdp_map_to" name="<?php echo esc_attr($index); ?>"> - <option value=""><?php esc_html_e( 'Do not import', 'directorist' ); ?></option> - <option value="">— Select a field —</option> - <?php foreach ( $fields as $key => $value ) : ?> - <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $field_key ); ?>><?php echo esc_html( $value ); ?></option> - <?php endforeach ?> - </select> - </td> - </tr> - <?php - endforeach; - endif; - ?> - </tbody> + <tr> + <td class="atbdp-importer-mapping-table-name"> + <p><?php echo esc_html( $index ); ?></p> + <?php if ( ! empty( $name ) ) : ?> + <span class="description"><?php esc_html_e( 'Sample:', 'directorist' ); ?> <code><?php echo esc_html( $name ); ?></code></span> + <?php endif; ?> + </td> + <td class="atbdp-importer-mapping-table-field"> + <input type="hidden" name="map_from[<?php echo esc_attr( $index ); ?>]" value="<?php echo esc_attr( $name ); ?>" /> + <select class="atbdp_map_to" name="<?php echo esc_attr( $index ); ?>"> + <option value=""><?php esc_html_e( 'Do not import', 'directorist' ); ?></option> + <option value="">— Select a field —</option> + <?php foreach ( $fields as $key => $value ) : ?> + <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $key, $field_key ); ?>><?php echo esc_html( $value ); ?></option> + <?php endforeach ?> + </select> + </td> + </tr> + <?php + endforeach; + endif; + ?> + </tbody> </table> \ No newline at end of file diff --git a/views/admin-templates/import-export/header-templates/header.php b/views/admin-templates/import-export/header-templates/header.php index 936abb8896..2dafa35baf 100644 --- a/views/admin-templates/import-export/header-templates/header.php +++ b/views/admin-templates/import-export/header-templates/header.php @@ -8,9 +8,11 @@ <div class="csv-action-steps"> <ul> - <?php foreach( $args['nav_menu'] as $nav_menu_index => $nav_menu_item ) : - $nav_menu_item['step_count'] = $nav_menu_index + 1; + <?php + foreach ( $args['nav_menu'] as $nav_menu_index => $nav_menu_item ) : + $nav_menu_item['step_count'] = $nav_menu_index + 1; $args['controller']->importer_header_nav_menu_item_template( $nav_menu_item ); - endforeach; ?> + endforeach; + ?> </ul> </div> \ No newline at end of file diff --git a/views/admin-templates/import-export/header-templates/nav-item.php b/views/admin-templates/import-export/header-templates/nav-item.php index 6152695c1f..cf649ebb78 100644 --- a/views/admin-templates/import-export/header-templates/nav-item.php +++ b/views/admin-templates/import-export/header-templates/nav-item.php @@ -1,9 +1,9 @@ <?php defined( 'ABSPATH' ) || exit; ?> <li class="<?php echo esc_attr( $args['nav_item_class'] ); ?>"> - <span class="step"> - <span class="step-count"><?php echo esc_html( $args['step_count'] ); ?></span> - <span class="dashicons dashicons-yes"></span> - </span> - <span class="step-text"><?php echo esc_html( $args['label'] ); ?></span> + <span class="step"> + <span class="step-count"><?php echo esc_html( $args['step_count'] ); ?></span> + <span class="dashicons dashicons-yes"></span> + </span> + <span class="step-text"><?php echo esc_html( $args['label'] ); ?></span> </li> \ No newline at end of file diff --git a/views/admin-templates/import-export/import-export.php b/views/admin-templates/import-export/import-export.php index 9d590b20c9..a9c6eff709 100644 --- a/views/admin-templates/import-export/import-export.php +++ b/views/admin-templates/import-export/import-export.php @@ -1,9 +1,6 @@ -<?php +<?php -defined( 'ABSPATH' ) || exit; +defined( 'ABSPATH' ) || exit; $args['controller']->importer_header_template(); $args['controller']->importer_body_template(); - -?> - diff --git a/views/admin-templates/listing-form/expiration-featured-fields.php b/views/admin-templates/listing-form/expiration-featured-fields.php index 8321efea22..262642eb0a 100644 --- a/views/admin-templates/listing-form/expiration-featured-fields.php +++ b/views/admin-templates/listing-form/expiration-featured-fields.php @@ -1,63 +1,67 @@ <?php -if (!empty($args['data']) ) extract($args['data']) ; +if ( ! empty( $args['data'] ) ) { + extract( $args['data'] ); +} // show the expiration date if never expiration is not set // display never expiration checkbox // Display featured checkbox // var_dump($never_expire); - if( empty($never_expire) && isset( $expiry_date ) ) : ?> - <div class="misc-pub-section misc-pub-atbdp-expiration-time"> +if ( empty( $never_expire ) && isset( $expiry_date ) ) : ?> + <div class="misc-pub-section misc-pub-atbdp-expiration-time"> <span id="atbdp-timestamp"> - <strong><?php esc_html_e( "Expiration", 'directorist' ); ?></strong> - <?php esc_html_e( "Date & Time", 'directorist' ); ?> - </span> - <div id="atbdp-timestamp-wrap" class="atbdp-timestamp-wrap"> - <label> - <select id="atbdp-mm" name="exp_date[mm]"> - <?php - $months = atbdp_get_months();// get an array of translatable month names - foreach( $months as $key => $month_name ) { - $key += 1; - printf( '<option value="%1$d" %2$s>%1$d-%3$s</option>', esc_attr( $key ), selected( $key, (int) $expiry_date['month']), esc_attr( $month_name ) ); - } - ?> - </select> - </label> - <label> - <input type="text" id="atbdp-jj" placeholder="day" name="exp_date[jj]" value="<?php echo esc_attr( $expiry_date['day'] ); ?>" size="2" maxlength="2" /> - </label>, - <label> - <input type="text" id="atbdp-aa" placeholder="year" name="exp_date[aa]" value="<?php echo esc_attr( $expiry_date['year'] ); ?>" size="4" maxlength="4" /> - </label>@ - <label> - <input type="text" id="atbdp-hh" placeholder="hour" name="exp_date[hh]" value="<?php echo esc_attr( $expiry_date['hour'] ); ?>" size="2" maxlength="2" /> - </label> : - <label> - <input type="text" id="atbdp-mn" placeholder="min" name="exp_date[mn]" value="<?php echo esc_attr( $expiry_date['min'] ); ?>" size="2" maxlength="2" /> - </label> - </div> - </div> -<?php endif; -if (!is_fee_manager_active() || !empty($never_expire)): - ?> + <strong><?php esc_html_e( 'Expiration', 'directorist' ); ?></strong> + <?php esc_html_e( 'Date & Time', 'directorist' ); ?> + </span> + <div id="atbdp-timestamp-wrap" class="atbdp-timestamp-wrap"> + <label> + <select id="atbdp-mm" name="exp_date[mm]"> + <?php + $months = atbdp_get_months();// get an array of translatable month names + foreach ( $months as $key => $month_name ) { + $key += 1; + printf( '<option value="%1$d" %2$s>%1$d-%3$s</option>', esc_attr( $key ), selected( $key, (int) $expiry_date['month'] ), esc_attr( $month_name ) ); + } + ?> + </select> + </label> + <label> + <input type="text" id="atbdp-jj" placeholder="day" name="exp_date[jj]" value="<?php echo esc_attr( $expiry_date['day'] ); ?>" size="2" maxlength="2" /> + </label>, + <label> + <input type="text" id="atbdp-aa" placeholder="year" name="exp_date[aa]" value="<?php echo esc_attr( $expiry_date['year'] ); ?>" size="4" maxlength="4" /> + </label>@ + <label> + <input type="text" id="atbdp-hh" placeholder="hour" name="exp_date[hh]" value="<?php echo esc_attr( $expiry_date['hour'] ); ?>" size="2" maxlength="2" /> + </label> : + <label> + <input type="text" id="atbdp-mn" placeholder="min" name="exp_date[mn]" value="<?php echo esc_attr( $expiry_date['min'] ); ?>" size="2" maxlength="2" /> + </label> + </div> + </div> + <?php +endif; +if ( ! is_fee_manager_active() || ! empty( $never_expire ) ) : + ?> <div class="misc-pub-section misc-pub-atbdp-never-expires"> - <label> - <input type="checkbox" name="never_expire" value="1" <?php checked(1, $never_expire, true); ?>> - <strong><?php esc_html_e( "Never Expires", 'directorist' ); ?></strong> - </label> + <label> + <input type="checkbox" name="never_expire" value="1" <?php checked( 1, $never_expire, true ); ?>> + <strong><?php esc_html_e( 'Never Expires', 'directorist' ); ?></strong> + </label> </div> -<?php + <?php endif; ?> <!--Show featured option if it is enabled by the user--> -<?php if( $f_active || is_fee_manager_active()) { ?> - <div class="misc-pub-section misc-pub-atbdp-featured"> - <label> - <input type="checkbox" name="featured" value="1" <?php checked(1, $featured, true); ?>> - <?php esc_html_e( "Mark as", 'directorist' ); ?> - <strong><?php esc_html_e( "Featured", 'directorist' ); ?></strong> - </label> - </div> -<?php } +<?php if ( $f_active || is_fee_manager_active() ) { ?> + <div class="misc-pub-section misc-pub-atbdp-featured"> + <label> + <input type="checkbox" name="featured" value="1" <?php checked( 1, $featured, true ); ?>> + <?php esc_html_e( 'Mark as', 'directorist' ); ?> + <strong><?php esc_html_e( 'Featured', 'directorist' ); ?></strong> + </label> + </div> + <?php +} $listing_types = array(); $all_types = directorist_get_directories(); diff --git a/views/admin-templates/listing-form/image_upload.php b/views/admin-templates/listing-form/image_upload.php index 13574fe83c..bbbaca7d5a 100644 --- a/views/admin-templates/listing-form/image_upload.php +++ b/views/admin-templates/listing-form/image_upload.php @@ -7,14 +7,14 @@ $listing_id = $listing_form->get_add_listing_id(); $listing_imgs = directorist_get_listing_gallery_images( $listing_id ); $listing_prv_img_id = directorist_get_listing_preview_image( $listing_id ); -$listing_prv_img = !empty($listing_prv_img_id) ? atbdp_get_image_source($listing_prv_img_id) : ''; -$display_prv_field = get_directorist_option('display_prv_field', 1); -$display_gallery_field = get_directorist_option('display_gallery_field', 1); -$image_links = []; // define a link placeholder variable -if( !empty( $listing_imgs ) && is_array( $listing_imgs ) ) { - foreach ($listing_imgs as $id) { - $image_links[$id] = atbdp_get_image_source($id); // store the attachment id and url - } +$listing_prv_img = ! empty( $listing_prv_img_id ) ? atbdp_get_image_source( $listing_prv_img_id ) : ''; +$display_prv_field = get_directorist_option( 'display_prv_field', 1 ); +$display_gallery_field = get_directorist_option( 'display_gallery_field', 1 ); +$image_links = array(); // define a link placeholder variable +if ( ! empty( $listing_imgs ) && is_array( $listing_imgs ) ) { + foreach ( $listing_imgs as $id ) { + $image_links[ $id ] = atbdp_get_image_source( $id ); // store the attachment id and url + } } // is multiple image upload extension is active ? @@ -22,66 +22,77 @@ ?> <div class="directorist-form-group add_listing_form_wrapper" id="gallery_upload"> - <?php if (!empty($display_prv_field)) { ?> - <div class="form-group"> - <!-- image container, which can be manipulated with js --> - <div class="listing-prv-img-container"> - <div class="single_prv_attachment"> - <input class="listing_prv_img" name="listing_prv_img" type="hidden" - value="<?php echo esc_attr( $listing_prv_img_id ); ?>"> - <div> - <img style="max-height: 150px;max-width: 150px" class="change_listing_prv_img" - src="<?php echo $listing_prv_img ? esc_url($listing_prv_img) : ''; ?>"> - <a href="" class="remove_prev_img"><span class="fa fa-times" title="Remove it"></span></a> - </div> - </div> - <div class="default_img"> - </div> - </div> - <!-- add & remove image links --> - <p class="hide-if-no-js"> - <a href="#" - class="upload-header btn btn-primary"><?php $preview_label = get_directorist_option('preview_label', __('Upload Preview Image', 'directorist')); - esc_html_e($preview_label, 'directorist'); ?></a> - </p> - </div> - <?php } ?> - <?php if (!empty($display_gallery_field)) { ?> - <div class="form-group"> - <!-- image container, which can be manipulated with js --> - <div class="listing-img-container"> - <?php if (!empty($image_links)) { - foreach ($image_links as $id => $image_link) { ?> - <div class="single_attachment"> - <input class="listing_image_attachment" name="listing_img[]" type="hidden" - value="<?php echo intval($id); ?>"> - <img style="width: 100%; height: 100%;" - src="<?php echo esc_url($image_link) ?>" - alt="<?php esc_attr_e('Listing Image', 'directorist'); ?>"> - <span class="remove_image dashicons dashicons-dismiss" - title="<?php echo esc_html__('Remove it', 'directorist'); ?>"></span> - </div> - <?php } // ends foreach for looping image - } else { ?> - <img src="<?php echo esc_url(DIRECTORIST_ASSETS . 'images/no-image.png'); ?>" - alt="<?php esc_attr_e('No Image Found', 'directorist'); ?>"> - <p><?php esc_attr_e('No Images', 'directorist'); ?></p> - <?php } // ends if statement ?> - </div> - <?php - /* A hidden input to set and post the chosen image id - <input id="listing_image_id" name="listing[listing_img]" type="hidden" value="">*/ - ?> - <!-- add & remove image links --> - <p class="hide-if-no-js"> - <a href="#" id="listing_image_btn" class="btn btn-primary"> - <span class="dashicons dashicons-format-image"></span> - <?php $gallery_label = get_directorist_option('gallery_label', __('Upload Slider Images', 'directorist')); - esc_html_e($gallery_label, 'directorist'); ?> - </a> - <a id="delete-custom-img" class="btn btn-danger <?php echo (!empty($image_links)) ? '' : 'hidden' ?>" - href="#"> <?php echo esc_html( (1 == $active_mi_ext) ? esc_html__('Remove Images', 'directorist') : esc_html__('Remove Image', 'directorist') ); ?></a> - </p> - </div> - <?php } ?> + <?php if ( ! empty( $display_prv_field ) ) { ?> + <div class="form-group"> + <!-- image container, which can be manipulated with js --> + <div class="listing-prv-img-container"> + <div class="single_prv_attachment"> + <input class="listing_prv_img" name="listing_prv_img" type="hidden" + value="<?php echo esc_attr( $listing_prv_img_id ); ?>"> + <div> + <img style="max-height: 150px;max-width: 150px" class="change_listing_prv_img" + src="<?php echo $listing_prv_img ? esc_url( $listing_prv_img ) : ''; ?>"> + <a href="" class="remove_prev_img"><span class="fa fa-times" title="Remove it"></span></a> + </div> + </div> + <div class="default_img"> + </div> + </div> + <!-- add & remove image links --> + <p class="hide-if-no-js"> + <a href="#" + class="upload-header btn btn-primary"> + <?php + $preview_label = get_directorist_option( 'preview_label', __( 'Upload Preview Image', 'directorist' ) ); + esc_html_e( $preview_label, 'directorist' ); + ?> + </a> + </p> + </div> + <?php } ?> + <?php if ( ! empty( $display_gallery_field ) ) { ?> + <div class="form-group"> + <!-- image container, which can be manipulated with js --> + <div class="listing-img-container"> + <?php + if ( ! empty( $image_links ) ) { + foreach ( $image_links as $id => $image_link ) { + ?> + <div class="single_attachment"> + <input class="listing_image_attachment" name="listing_img[]" type="hidden" + value="<?php echo intval( $id ); ?>"> + <img style="width: 100%; height: 100%;" + src="<?php echo esc_url( $image_link ); ?>" + alt="<?php esc_attr_e( 'Listing Image', 'directorist' ); ?>"> + <span class="remove_image dashicons dashicons-dismiss" + title="<?php echo esc_html__( 'Remove it', 'directorist' ); ?>"></span> + </div> + <?php + } // ends foreach for looping image + } else { + ?> + <img src="<?php echo esc_url( DIRECTORIST_ASSETS . 'images/no-image.png' ); ?>" + alt="<?php esc_attr_e( 'No Image Found', 'directorist' ); ?>"> + <p><?php esc_attr_e( 'No Images', 'directorist' ); ?></p> + <?php } // ends if statement ?> + </div> + <?php + /* + A hidden input to set and post the chosen image id + <input id="listing_image_id" name="listing[listing_img]" type="hidden" value="">*/ + ?> + <!-- add & remove image links --> + <p class="hide-if-no-js"> + <a href="#" id="listing_image_btn" class="btn btn-primary"> + <span class="dashicons dashicons-format-image"></span> + <?php + $gallery_label = get_directorist_option( 'gallery_label', __( 'Upload Slider Images', 'directorist' ) ); + esc_html_e( $gallery_label, 'directorist' ); + ?> + </a> + <a id="delete-custom-img" class="btn btn-danger <?php echo ( ! empty( $image_links ) ) ? '' : 'hidden'; ?>" + href="#"> <?php echo esc_html( ( 1 == $active_mi_ext ) ? esc_html__( 'Remove Images', 'directorist' ) : esc_html__( 'Remove Image', 'directorist' ) ); ?></a> + </p> + </div> + <?php } ?> </div> <!--ends add_listing_form_wrapper--> \ No newline at end of file diff --git a/views/admin-templates/post-types-manager/ai/step-one.php b/views/admin-templates/post-types-manager/ai/step-one.php index b958d5b879..a523deb4a7 100644 --- a/views/admin-templates/post-types-manager/ai/step-one.php +++ b/views/admin-templates/post-types-manager/ai/step-one.php @@ -2,8 +2,8 @@ <div class="directorist-create-directory__header"> <div class="directorist-create-directory__close"> <a href="<?php echo esc_attr( - admin_url() - ); ?>" class="directorist-create-directory__close__btn"> + admin_url() + ); ?>" class="directorist-create-directory__close__btn"> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M5.24408 5.24408C5.56951 4.91864 6.09715 4.91864 6.42259 5.24408L10 8.82149L13.5774 5.24408C13.9028 4.91864 14.4305 4.91864 14.7559 5.24408C15.0814 5.56951 15.0814 6.09715 14.7559 6.42259L11.1785 10L14.7559 13.5774C15.0814 13.9028 15.0814 14.4305 14.7559 14.7559C14.4305 15.0814 13.9028 15.0814 13.5774 14.7559L10 11.1785L6.42259 14.7559C6.09715 15.0814 5.56951 15.0814 5.24408 14.7559C4.91864 14.4305 4.91864 13.9028 5.24408 13.5774L8.82149 10L5.24408 6.42259C4.91864 6.09715 4.91864 5.56951 5.24408 5.24408Z" @@ -44,33 +44,39 @@ class="directorist-create-directory__upgrade__link"> <div class="directorist-create-directory__wrapper"> <div class="directorist-create-directory__top"> <div class="directorist-create-directory__step"> - <ul class="atbdp-setup-steps <?php echo esc_attr($hide); ?>"> + <ul class="atbdp-setup-steps <?php echo esc_attr( $hide ); ?>"> <li class="active"></li> <li></li> <li></li> </ul> <span class="step-count"> <span class="current-step"> - <?php esc_html_e( - sprintf("%d", $active_number), - "directorist" - ); ?> + <?php + esc_html_e( + sprintf( '%d', $active_number ), + 'directorist' + ); + ?> </span>/ <span class="total-step">3</span> </span> </div> <div class="directorist-create-directory__info"> <h1 class="directorist-create-directory__info__title"> - <?php esc_html_e( - "Let’s set up your directory", - "directorist" - ); ?> + <?php + esc_html_e( + 'Let’s set up your directory', + 'directorist' + ); + ?> </h1> <p class="directorist-create-directory__info__desc"> - <?php esc_html_e( - "Build your directory instantly. Customize with Directorist AI", - "directorist" - ); ?> + <?php + esc_html_e( + 'Build your directory instantly. Customize with Directorist AI', + 'directorist' + ); + ?> </p> </div> </div> @@ -605,9 +611,13 @@ class="form-control directorist-create-directory__content__input --textarea dire <!-- Footer --> <div class="directorist-create-directory__content__footer"> <div class="directorist-create-directory__back"> - <a href="<?php echo esc_url( - wp_get_referer() - ); ?>" class="directorist-create-directory__back__btn"> + <a href=" + <?php + echo esc_url( + wp_get_referer() + ); + ?> + " class="directorist-create-directory__back__btn"> <svg width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M13 5L8 10L13 15" stroke="currentColor" stroke-width="1.5" stroke-miterlimit="16" /> diff --git a/views/admin-templates/post-types-manager/ai/step-two.php b/views/admin-templates/post-types-manager/ai/step-two.php index 7fbcbaf194..bf3e6060fe 100644 --- a/views/admin-templates/post-types-manager/ai/step-two.php +++ b/views/admin-templates/post-types-manager/ai/step-two.php @@ -1,11 +1,12 @@ <h1>Step 2 Select Keyword</h1> <select name="keywords" id="directorist-ai-keywords"> <option value="">Select Keywords</option> -<?php -if( ! empty( $list ) ) { - foreach( $list as $keyword ) { ?> - <option value="<?php echo esc_attr( $keyword ); ?>"><?php echo esc_html( $keyword ); ?></option> - <?php } +<?php +if ( ! empty( $list ) ) { + foreach ( $list as $keyword ) { ?> + <option value="<?php echo esc_attr( $keyword ); ?>"><?php echo esc_html( $keyword ); ?></option> + <?php + } } ?> </select> diff --git a/views/admin-templates/post-types-manager/all-listing-types.php b/views/admin-templates/post-types-manager/all-listing-types.php index 761777f3bd..a6788cea34 100644 --- a/views/admin-templates/post-types-manager/all-listing-types.php +++ b/views/admin-templates/post-types-manager/all-listing-types.php @@ -1,409 +1,421 @@ <?php $show_migration_button = apply_filters( 'directorist_show_migration_button', false ); ?> <div class="wrap"> - <?php atbdp_show_flush_alerts( ['page' => 'all-listing-type'] ) ?> + <?php atbdp_show_flush_alerts( array( 'page' => 'all-listing-type' ) ); ?> - <hr class="wp-header-end"> + <hr class="wp-header-end"> - <div class="directorist_builder-wrap"> - <?php - /** - * Fires before all directory types table - * @since 7.2.0 - */ - do_action( 'directorist_before_all_directory_types' ); - ?> - <div class="directorist_builder-header"> - <div class="directorist_builder-header__left"> - <div class="directorist_logo"> - <img src="https://directorist.com/wp-content/uploads/2020/08/directorist_logo.png" alt=""> - </div> - </div> - <div class="directorist_builder-header__right"> - <ul class="directorist_builder-links"> - <li> - <a href="https://directorist.com/documentation/" target="_blank"> - <div class="svg-icon"> - <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M5.83913 0.666626H10.1609C10.6975 0.666618 11.1404 0.666611 11.5012 0.696089C11.8759 0.726706 12.2204 0.792415 12.544 0.957276C13.0457 1.21294 13.4537 1.62089 13.7094 2.12265C13.8742 2.44621 13.9399 2.79068 13.9705 3.16541C14 3.5262 14 3.9691 14 4.50574V11.4942C14 12.0308 14 12.4737 13.9705 12.8345C13.9399 13.2092 13.8742 13.5537 13.7094 13.8773C13.4537 14.379 13.0457 14.787 12.544 15.0426C12.2204 15.2075 11.8759 15.2732 11.5012 15.3038C11.1404 15.3333 10.6975 15.3333 10.1609 15.3333H5.83912C5.30248 15.3333 4.85958 15.3333 4.49878 15.3038C4.12405 15.2732 3.77958 15.2075 3.45603 15.0426C2.95426 14.787 2.54631 14.379 2.29065 13.8773C2.12579 13.5537 2.06008 13.2092 2.02946 12.8345C1.99998 12.4737 1.99999 12.0308 2 11.4942V4.50576C1.99999 3.96911 1.99998 3.52621 2.02946 3.16541C2.06008 2.79068 2.12579 2.44621 2.29065 2.12265C2.54631 1.62089 2.95426 1.21294 3.45603 0.957276C3.77958 0.792415 4.12405 0.726706 4.49878 0.696089C4.85958 0.666611 5.30249 0.666618 5.83913 0.666626ZM4.60736 2.02499C4.31508 2.04887 4.16561 2.09216 4.06135 2.14528C3.81046 2.27312 3.60649 2.47709 3.47866 2.72797C3.42553 2.83224 3.38225 2.98171 3.35837 3.27399C3.33385 3.57404 3.33333 3.96224 3.33333 4.53329V11.4666C3.33333 12.0377 3.33385 12.4259 3.35837 12.7259C3.38225 13.0182 3.42553 13.1677 3.47866 13.2719C3.60649 13.5228 3.81046 13.7268 4.06135 13.8546C4.16561 13.9078 4.31508 13.951 4.60736 13.9749C4.90742 13.9994 5.29561 14 5.86667 14H10.1333C10.7044 14 11.0926 13.9994 11.3926 13.9749C11.6849 13.951 11.8344 13.9078 11.9387 13.8546C12.1895 13.7268 12.3935 13.5228 12.5213 13.2719C12.5745 13.1677 12.6178 13.0182 12.6416 12.7259C12.6661 12.4259 12.6667 12.0377 12.6667 11.4666V4.53329C12.6667 3.96224 12.6661 3.57404 12.6416 3.27399C12.6178 2.98171 12.5745 2.83224 12.5213 2.72797C12.3935 2.47709 12.1895 2.27312 11.9387 2.14528C11.8344 2.09216 11.6849 2.04887 11.3926 2.02499C11.0926 2.00048 10.7044 1.99996 10.1333 1.99996H5.86667C5.29561 1.99996 4.90742 2.00048 4.60736 2.02499ZM4.66667 4.66663C4.66667 4.29844 4.96514 3.99996 5.33333 3.99996H10.6667C11.0349 3.99996 11.3333 4.29844 11.3333 4.66663C11.3333 5.03482 11.0349 5.33329 10.6667 5.33329H5.33333C4.96514 5.33329 4.66667 5.03482 4.66667 4.66663ZM4.66667 7.33329C4.66667 6.9651 4.96514 6.66663 5.33333 6.66663H9.33333C9.70152 6.66663 10 6.9651 10 7.33329C10 7.70148 9.70152 7.99996 9.33333 7.99996H5.33333C4.96514 7.99996 4.66667 7.70148 4.66667 7.33329ZM4.66667 9.99996C4.66667 9.63177 4.96514 9.33329 5.33333 9.33329H6.66667C7.03486 9.33329 7.33333 9.63177 7.33333 9.99996C7.33333 10.3682 7.03486 10.6666 6.66667 10.6666H5.33333C4.96514 10.6666 4.66667 10.3682 4.66667 9.99996Z" fill="currentColor"/> - </svg> - </div> - <span class="link-text"><?php esc_html_e( 'Documentation', 'directorist' ); ?></span> - </a> - </li> - <li> - <a href="https://directorist.com/dashboard/#support" target="_blank"> - <div class="svg-icon"> - <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> - <g clip-path="url(#clip0_5025_920)"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.99996C4.6863 1.99996 2.00001 4.68625 2.00001 7.99996C2.00001 11.3137 4.6863 14 8 14C11.3137 14 14 11.3137 14 7.99996C14 4.68625 11.3137 1.99996 8 1.99996ZM0.666672 7.99996C0.666672 3.94987 3.94992 0.666626 8 0.666626C12.0501 0.666626 15.3333 3.94987 15.3333 7.99996C15.3333 12.05 12.0501 15.3333 8 15.3333C3.94992 15.3333 0.666672 12.05 0.666672 7.99996ZM8.17208 5.3495C7.86174 5.29627 7.54256 5.35459 7.2711 5.51414C6.99963 5.67368 6.79339 5.92415 6.68889 6.22119C6.56671 6.56851 6.1861 6.75103 5.83878 6.62885C5.49145 6.50667 5.30893 6.12606 5.43112 5.77873C5.6401 5.18466 6.05258 4.68371 6.59552 4.36463C7.13845 4.04554 7.7768 3.9289 8.39749 4.03536C9.01819 4.14183 9.58117 4.46453 9.98674 4.94631C10.3922 5.42799 10.6142 6.03761 10.6133 6.66723C10.613 7.68747 9.85663 8.36122 9.31647 8.72133C9.02605 8.91494 8.74037 9.0573 8.52993 9.15083C8.42376 9.19802 8.33436 9.23383 8.26994 9.25837C8.23767 9.27066 8.21151 9.28019 8.19247 9.28696L8.16932 9.29506L8.16194 9.29758L8.15935 9.29846L8.15832 9.2988C8.15812 9.29887 8.15749 9.29908 7.94667 8.66663L8.15749 9.29908C7.80819 9.41551 7.43065 9.22674 7.31422 8.87744C7.19782 8.52826 7.38643 8.15085 7.7355 8.03429L7.74579 8.03067C7.75605 8.02702 7.77286 8.02093 7.79528 8.01238C7.84023 7.99526 7.90708 7.96856 7.98841 7.93242C8.15297 7.85928 8.36729 7.75164 8.57687 7.61193C9.0366 7.30544 9.28 6.97938 9.28 6.66663L9.28001 6.66563C9.28047 6.35075 9.16949 6.04587 8.96671 5.80498C8.76392 5.56409 8.48243 5.40274 8.17208 5.3495ZM7.33334 11.3333C7.33334 10.9651 7.63181 10.6666 8 10.6666H8.00667C8.37486 10.6666 8.67334 10.9651 8.67334 11.3333C8.67334 11.7015 8.37486 12 8.00667 12H8C7.63181 12 7.33334 11.7015 7.33334 11.3333Z" fill="currentColor"/> - </g> - <defs> - <clipPath id="clip0_5025_920"> - <rect width="16" height="16" fill="white"/> - </clipPath> - </defs> - </svg> - </div> - <span class="link-text"><?php esc_html_e( 'Support', 'directorist' ); ?></span> - </a> - </li> - <li> - <a href="https://directorist.com/contact/" target="_blank"> - <div class="svg-icon"> - <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M7.56962 1.18378C7.84186 1.05398 8.15814 1.05398 8.43038 1.18378C8.66572 1.29599 8.79548 1.49081 8.86091 1.59769C8.92856 1.70819 8.998 1.84895 9.06569 1.98614C9.06915 1.99315 9.0726 2.00014 9.07605 2.00713L10.5028 4.89765L13.7175 5.36753C13.8689 5.38961 14.0241 5.41228 14.1501 5.44256C14.2719 5.47186 14.4972 5.53523 14.6765 5.72445C14.8839 5.94336 14.9814 6.24417 14.9419 6.54313C14.9078 6.80155 14.7626 6.98505 14.6811 7.08027C14.5969 7.17869 14.4845 7.28815 14.3749 7.39482L12.0497 9.65959L12.5983 12.8584C12.6242 13.0092 12.6508 13.164 12.661 13.2932C12.6709 13.4181 12.6805 13.6521 12.556 13.8812C12.412 14.1463 12.1561 14.3322 11.8595 14.3871C11.6031 14.4347 11.3836 14.3533 11.2679 14.3052C11.1482 14.2556 11.0092 14.1825 10.8738 14.1112L8 12.5999L5.12622 14.1112C4.99078 14.1825 4.85184 14.2556 4.73214 14.3052C4.61638 14.3533 4.39686 14.4347 4.14045 14.3871C3.84387 14.3322 3.58796 14.1463 3.44399 13.8812C3.31952 13.6521 3.32908 13.4181 3.33897 13.2932C3.3492 13.164 3.37578 13.0093 3.40168 12.8584L3.95032 9.65958L1.64187 7.41116C1.6363 7.40573 1.63071 7.40029 1.62512 7.39485C1.51555 7.28817 1.40311 7.1787 1.3189 7.08027C1.23743 6.98505 1.0922 6.80155 1.05808 6.54313C1.0186 6.24417 1.11613 5.94337 1.32353 5.72445C1.5028 5.53523 1.72807 5.47186 1.84991 5.44256C1.97586 5.41228 2.13114 5.38961 2.28247 5.36752C2.29019 5.3664 2.2979 5.36527 2.3056 5.36415L5.49716 4.89765L6.92395 2.00713C6.9274 2.00014 6.93085 1.99315 6.93431 1.98614C7.00199 1.84895 7.07144 1.70819 7.13909 1.59769C7.20452 1.49081 7.33428 1.29599 7.56962 1.18378ZM5.42822 5.03569C5.42812 5.03585 5.42812 5.03585 5.42822 5.03569V5.03569ZM5.64972 4.87462C5.6499 4.87459 5.6499 4.87459 5.64972 4.87462V4.87462ZM12.0243 9.50715C12.0242 9.50696 12.0242 9.50695 12.0243 9.50715V9.50715ZM8 2.83951L6.66177 5.55061C6.65922 5.55579 6.6563 5.56183 6.65302 5.56861C6.62126 5.63438 6.55548 5.77056 6.45118 5.88282C6.36313 5.97759 6.25753 6.05437 6.14024 6.10892C6.00129 6.17353 5.85147 6.19412 5.77911 6.20407C5.77164 6.20509 5.765 6.206 5.75928 6.20684L2.76561 6.64441L4.93087 8.75337C4.93501 8.75741 4.93986 8.76206 4.94532 8.76727C4.99815 8.81786 5.10754 8.92259 5.18219 9.05666C5.2452 9.16984 5.28563 9.29417 5.30122 9.42275C5.31969 9.57509 5.29281 9.72414 5.27983 9.79611C5.27849 9.80354 5.2773 9.81015 5.27632 9.81586L4.76545 12.7945L7.44146 11.3872C7.44658 11.3845 7.4525 11.3813 7.45915 11.3777C7.52358 11.3431 7.65699 11.2715 7.80755 11.242C7.93464 11.2171 8.06536 11.2171 8.19245 11.242C8.34301 11.2715 8.47642 11.3431 8.54085 11.3777C8.5475 11.3813 8.55342 11.3845 8.55854 11.3872L11.2345 12.7945L10.7237 9.81586C10.7227 9.81015 10.7215 9.80354 10.7202 9.79611C10.7072 9.72413 10.6803 9.57509 10.6988 9.42275C10.7144 9.29417 10.7548 9.16984 10.8178 9.05666C10.8925 8.92259 11.0019 8.81786 11.0547 8.76728C11.0601 8.76206 11.065 8.75741 11.0691 8.75337L13.2344 6.64441L10.2407 6.20684C10.235 6.206 10.2284 6.20509 10.2209 6.20407C10.1485 6.19412 9.99871 6.17353 9.85976 6.10892C9.74246 6.05437 9.63687 5.97759 9.54882 5.88282C9.44451 5.77056 9.37874 5.63438 9.34698 5.56861C9.3437 5.56183 9.34078 5.55579 9.33822 5.55061L8 2.83951Z" fill="currentColor"/> - </svg> - </div> - <span class="link-text"><?php esc_html_e( 'Feedback', 'directorist' ); ?></span> - </a> - </li> - </ul> - </div> - </div> - <div class="directorist_builder-body"> - <div class="directorist_builder__content"> - <div class="directorist_builder__content__left"> - <h2 class="directorist_builder__title"><?php esc_html_e( 'All Directory Types', 'directorist' ); ?></h2> - <div class="directorist_link-block-wrapper"> - <button class="directorist_link-block directorist_link-block-primary directorist_new-directory cptm-modal-toggle" data-target="cptm-create-directory-modal"> - <span class="directorist_link-icon"> - <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M7.99998 1.33337C8.46022 1.33337 8.83331 1.70647 8.83331 2.16671V7.16671H13.8333C14.2936 7.16671 14.6666 7.5398 14.6666 8.00004C14.6666 8.46028 14.2936 8.83337 13.8333 8.83337H8.83331V13.8334C8.83331 14.2936 8.46022 14.6667 7.99998 14.6667C7.53974 14.6667 7.16665 14.2936 7.16665 13.8334V8.83337H2.16665C1.70641 8.83337 1.33331 8.46028 1.33331 8.00004C1.33331 7.5398 1.70641 7.16671 2.16665 7.16671H7.16665V2.16671C7.16665 1.70647 7.53974 1.33337 7.99998 1.33337Z" fill="#ffffff"/> - </svg> - </span> - <span class="directorist_link-text"><?php esc_html_e( 'Create New Directory', 'directorist' ); ?></span> - </button> + <div class="directorist_builder-wrap"> + <?php + /** + * Fires before all directory types table + * + * @since 7.2.0 + */ + do_action( 'directorist_before_all_directory_types' ); + ?> + <div class="directorist_builder-header"> + <div class="directorist_builder-header__left"> + <div class="directorist_logo"> + <img src="https://directorist.com/wp-content/uploads/2020/08/directorist_logo.png" alt=""> + </div> + </div> + <div class="directorist_builder-header__right"> + <ul class="directorist_builder-links"> + <li> + <a href="https://directorist.com/documentation/" target="_blank"> + <div class="svg-icon"> + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M5.83913 0.666626H10.1609C10.6975 0.666618 11.1404 0.666611 11.5012 0.696089C11.8759 0.726706 12.2204 0.792415 12.544 0.957276C13.0457 1.21294 13.4537 1.62089 13.7094 2.12265C13.8742 2.44621 13.9399 2.79068 13.9705 3.16541C14 3.5262 14 3.9691 14 4.50574V11.4942C14 12.0308 14 12.4737 13.9705 12.8345C13.9399 13.2092 13.8742 13.5537 13.7094 13.8773C13.4537 14.379 13.0457 14.787 12.544 15.0426C12.2204 15.2075 11.8759 15.2732 11.5012 15.3038C11.1404 15.3333 10.6975 15.3333 10.1609 15.3333H5.83912C5.30248 15.3333 4.85958 15.3333 4.49878 15.3038C4.12405 15.2732 3.77958 15.2075 3.45603 15.0426C2.95426 14.787 2.54631 14.379 2.29065 13.8773C2.12579 13.5537 2.06008 13.2092 2.02946 12.8345C1.99998 12.4737 1.99999 12.0308 2 11.4942V4.50576C1.99999 3.96911 1.99998 3.52621 2.02946 3.16541C2.06008 2.79068 2.12579 2.44621 2.29065 2.12265C2.54631 1.62089 2.95426 1.21294 3.45603 0.957276C3.77958 0.792415 4.12405 0.726706 4.49878 0.696089C4.85958 0.666611 5.30249 0.666618 5.83913 0.666626ZM4.60736 2.02499C4.31508 2.04887 4.16561 2.09216 4.06135 2.14528C3.81046 2.27312 3.60649 2.47709 3.47866 2.72797C3.42553 2.83224 3.38225 2.98171 3.35837 3.27399C3.33385 3.57404 3.33333 3.96224 3.33333 4.53329V11.4666C3.33333 12.0377 3.33385 12.4259 3.35837 12.7259C3.38225 13.0182 3.42553 13.1677 3.47866 13.2719C3.60649 13.5228 3.81046 13.7268 4.06135 13.8546C4.16561 13.9078 4.31508 13.951 4.60736 13.9749C4.90742 13.9994 5.29561 14 5.86667 14H10.1333C10.7044 14 11.0926 13.9994 11.3926 13.9749C11.6849 13.951 11.8344 13.9078 11.9387 13.8546C12.1895 13.7268 12.3935 13.5228 12.5213 13.2719C12.5745 13.1677 12.6178 13.0182 12.6416 12.7259C12.6661 12.4259 12.6667 12.0377 12.6667 11.4666V4.53329C12.6667 3.96224 12.6661 3.57404 12.6416 3.27399C12.6178 2.98171 12.5745 2.83224 12.5213 2.72797C12.3935 2.47709 12.1895 2.27312 11.9387 2.14528C11.8344 2.09216 11.6849 2.04887 11.3926 2.02499C11.0926 2.00048 10.7044 1.99996 10.1333 1.99996H5.86667C5.29561 1.99996 4.90742 2.00048 4.60736 2.02499ZM4.66667 4.66663C4.66667 4.29844 4.96514 3.99996 5.33333 3.99996H10.6667C11.0349 3.99996 11.3333 4.29844 11.3333 4.66663C11.3333 5.03482 11.0349 5.33329 10.6667 5.33329H5.33333C4.96514 5.33329 4.66667 5.03482 4.66667 4.66663ZM4.66667 7.33329C4.66667 6.9651 4.96514 6.66663 5.33333 6.66663H9.33333C9.70152 6.66663 10 6.9651 10 7.33329C10 7.70148 9.70152 7.99996 9.33333 7.99996H5.33333C4.96514 7.99996 4.66667 7.70148 4.66667 7.33329ZM4.66667 9.99996C4.66667 9.63177 4.96514 9.33329 5.33333 9.33329H6.66667C7.03486 9.33329 7.33333 9.63177 7.33333 9.99996C7.33333 10.3682 7.03486 10.6666 6.66667 10.6666H5.33333C4.96514 10.6666 4.66667 10.3682 4.66667 9.99996Z" fill="currentColor"/> + </svg> + </div> + <span class="link-text"><?php esc_html_e( 'Documentation', 'directorist' ); ?></span> + </a> + </li> + <li> + <a href="https://directorist.com/dashboard/#support" target="_blank"> + <div class="svg-icon"> + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + <g clip-path="url(#clip0_5025_920)"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M8 1.99996C4.6863 1.99996 2.00001 4.68625 2.00001 7.99996C2.00001 11.3137 4.6863 14 8 14C11.3137 14 14 11.3137 14 7.99996C14 4.68625 11.3137 1.99996 8 1.99996ZM0.666672 7.99996C0.666672 3.94987 3.94992 0.666626 8 0.666626C12.0501 0.666626 15.3333 3.94987 15.3333 7.99996C15.3333 12.05 12.0501 15.3333 8 15.3333C3.94992 15.3333 0.666672 12.05 0.666672 7.99996ZM8.17208 5.3495C7.86174 5.29627 7.54256 5.35459 7.2711 5.51414C6.99963 5.67368 6.79339 5.92415 6.68889 6.22119C6.56671 6.56851 6.1861 6.75103 5.83878 6.62885C5.49145 6.50667 5.30893 6.12606 5.43112 5.77873C5.6401 5.18466 6.05258 4.68371 6.59552 4.36463C7.13845 4.04554 7.7768 3.9289 8.39749 4.03536C9.01819 4.14183 9.58117 4.46453 9.98674 4.94631C10.3922 5.42799 10.6142 6.03761 10.6133 6.66723C10.613 7.68747 9.85663 8.36122 9.31647 8.72133C9.02605 8.91494 8.74037 9.0573 8.52993 9.15083C8.42376 9.19802 8.33436 9.23383 8.26994 9.25837C8.23767 9.27066 8.21151 9.28019 8.19247 9.28696L8.16932 9.29506L8.16194 9.29758L8.15935 9.29846L8.15832 9.2988C8.15812 9.29887 8.15749 9.29908 7.94667 8.66663L8.15749 9.29908C7.80819 9.41551 7.43065 9.22674 7.31422 8.87744C7.19782 8.52826 7.38643 8.15085 7.7355 8.03429L7.74579 8.03067C7.75605 8.02702 7.77286 8.02093 7.79528 8.01238C7.84023 7.99526 7.90708 7.96856 7.98841 7.93242C8.15297 7.85928 8.36729 7.75164 8.57687 7.61193C9.0366 7.30544 9.28 6.97938 9.28 6.66663L9.28001 6.66563C9.28047 6.35075 9.16949 6.04587 8.96671 5.80498C8.76392 5.56409 8.48243 5.40274 8.17208 5.3495ZM7.33334 11.3333C7.33334 10.9651 7.63181 10.6666 8 10.6666H8.00667C8.37486 10.6666 8.67334 10.9651 8.67334 11.3333C8.67334 11.7015 8.37486 12 8.00667 12H8C7.63181 12 7.33334 11.7015 7.33334 11.3333Z" fill="currentColor"/> + </g> + <defs> + <clipPath id="clip0_5025_920"> + <rect width="16" height="16" fill="white"/> + </clipPath> + </defs> + </svg> + </div> + <span class="link-text"><?php esc_html_e( 'Support', 'directorist' ); ?></span> + </a> + </li> + <li> + <a href="https://directorist.com/contact/" target="_blank"> + <div class="svg-icon"> + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M7.56962 1.18378C7.84186 1.05398 8.15814 1.05398 8.43038 1.18378C8.66572 1.29599 8.79548 1.49081 8.86091 1.59769C8.92856 1.70819 8.998 1.84895 9.06569 1.98614C9.06915 1.99315 9.0726 2.00014 9.07605 2.00713L10.5028 4.89765L13.7175 5.36753C13.8689 5.38961 14.0241 5.41228 14.1501 5.44256C14.2719 5.47186 14.4972 5.53523 14.6765 5.72445C14.8839 5.94336 14.9814 6.24417 14.9419 6.54313C14.9078 6.80155 14.7626 6.98505 14.6811 7.08027C14.5969 7.17869 14.4845 7.28815 14.3749 7.39482L12.0497 9.65959L12.5983 12.8584C12.6242 13.0092 12.6508 13.164 12.661 13.2932C12.6709 13.4181 12.6805 13.6521 12.556 13.8812C12.412 14.1463 12.1561 14.3322 11.8595 14.3871C11.6031 14.4347 11.3836 14.3533 11.2679 14.3052C11.1482 14.2556 11.0092 14.1825 10.8738 14.1112L8 12.5999L5.12622 14.1112C4.99078 14.1825 4.85184 14.2556 4.73214 14.3052C4.61638 14.3533 4.39686 14.4347 4.14045 14.3871C3.84387 14.3322 3.58796 14.1463 3.44399 13.8812C3.31952 13.6521 3.32908 13.4181 3.33897 13.2932C3.3492 13.164 3.37578 13.0093 3.40168 12.8584L3.95032 9.65958L1.64187 7.41116C1.6363 7.40573 1.63071 7.40029 1.62512 7.39485C1.51555 7.28817 1.40311 7.1787 1.3189 7.08027C1.23743 6.98505 1.0922 6.80155 1.05808 6.54313C1.0186 6.24417 1.11613 5.94337 1.32353 5.72445C1.5028 5.53523 1.72807 5.47186 1.84991 5.44256C1.97586 5.41228 2.13114 5.38961 2.28247 5.36752C2.29019 5.3664 2.2979 5.36527 2.3056 5.36415L5.49716 4.89765L6.92395 2.00713C6.9274 2.00014 6.93085 1.99315 6.93431 1.98614C7.00199 1.84895 7.07144 1.70819 7.13909 1.59769C7.20452 1.49081 7.33428 1.29599 7.56962 1.18378ZM5.42822 5.03569C5.42812 5.03585 5.42812 5.03585 5.42822 5.03569V5.03569ZM5.64972 4.87462C5.6499 4.87459 5.6499 4.87459 5.64972 4.87462V4.87462ZM12.0243 9.50715C12.0242 9.50696 12.0242 9.50695 12.0243 9.50715V9.50715ZM8 2.83951L6.66177 5.55061C6.65922 5.55579 6.6563 5.56183 6.65302 5.56861C6.62126 5.63438 6.55548 5.77056 6.45118 5.88282C6.36313 5.97759 6.25753 6.05437 6.14024 6.10892C6.00129 6.17353 5.85147 6.19412 5.77911 6.20407C5.77164 6.20509 5.765 6.206 5.75928 6.20684L2.76561 6.64441L4.93087 8.75337C4.93501 8.75741 4.93986 8.76206 4.94532 8.76727C4.99815 8.81786 5.10754 8.92259 5.18219 9.05666C5.2452 9.16984 5.28563 9.29417 5.30122 9.42275C5.31969 9.57509 5.29281 9.72414 5.27983 9.79611C5.27849 9.80354 5.2773 9.81015 5.27632 9.81586L4.76545 12.7945L7.44146 11.3872C7.44658 11.3845 7.4525 11.3813 7.45915 11.3777C7.52358 11.3431 7.65699 11.2715 7.80755 11.242C7.93464 11.2171 8.06536 11.2171 8.19245 11.242C8.34301 11.2715 8.47642 11.3431 8.54085 11.3777C8.5475 11.3813 8.55342 11.3845 8.55854 11.3872L11.2345 12.7945L10.7237 9.81586C10.7227 9.81015 10.7215 9.80354 10.7202 9.79611C10.7072 9.72413 10.6803 9.57509 10.6988 9.42275C10.7144 9.29417 10.7548 9.16984 10.8178 9.05666C10.8925 8.92259 11.0019 8.81786 11.0547 8.76728C11.0601 8.76206 11.065 8.75741 11.0691 8.75337L13.2344 6.64441L10.2407 6.20684C10.235 6.206 10.2284 6.20509 10.2209 6.20407C10.1485 6.19412 9.99871 6.17353 9.85976 6.10892C9.74246 6.05437 9.63687 5.97759 9.54882 5.88282C9.44451 5.77056 9.37874 5.63438 9.34698 5.56861C9.3437 5.56183 9.34078 5.55579 9.33822 5.55061L8 2.83951Z" fill="currentColor"/> + </svg> + </div> + <span class="link-text"><?php esc_html_e( 'Feedback', 'directorist' ); ?></span> + </a> + </li> + </ul> + </div> + </div> + <div class="directorist_builder-body"> + <div class="directorist_builder__content"> + <div class="directorist_builder__content__left"> + <h2 class="directorist_builder__title"><?php esc_html_e( 'All Directory Types', 'directorist' ); ?></h2> + <div class="directorist_link-block-wrapper"> + <button class="directorist_link-block directorist_link-block-primary directorist_new-directory cptm-modal-toggle" data-target="cptm-create-directory-modal"> + <span class="directorist_link-icon"> + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M7.99998 1.33337C8.46022 1.33337 8.83331 1.70647 8.83331 2.16671V7.16671H13.8333C14.2936 7.16671 14.6666 7.5398 14.6666 8.00004C14.6666 8.46028 14.2936 8.83337 13.8333 8.83337H8.83331V13.8334C8.83331 14.2936 8.46022 14.6667 7.99998 14.6667C7.53974 14.6667 7.16665 14.2936 7.16665 13.8334V8.83337H2.16665C1.70641 8.83337 1.33331 8.46028 1.33331 8.00004C1.33331 7.5398 1.70641 7.16671 2.16665 7.16671H7.16665V2.16671C7.16665 1.70647 7.53974 1.33337 7.99998 1.33337Z" fill="#ffffff"/> + </svg> + </span> + <span class="directorist_link-text"><?php esc_html_e( 'Create New Directory', 'directorist' ); ?></span> + </button> - <button class="directorist_link-block directorist_link-block-primary-outline directorist_btn-import cptm-modal-toggle" data-target="cptm-import-directory-modal"> - <span class="directorist_link-icon"> - <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M8.00002 1.99996C4.68631 1.99996 2.00002 4.68625 2.00002 7.99996C2.00002 10.22 3.20536 12.1592 5.0005 13.1977C5.31921 13.382 5.42812 13.7899 5.24376 14.1086C5.0594 14.4273 4.65158 14.5362 4.33287 14.3518C2.14267 13.0849 0.666687 10.7152 0.666687 7.99996C0.666687 3.94987 3.94993 0.666626 8.00002 0.666626C12.0501 0.666626 15.3334 3.94987 15.3334 7.99996C15.3334 10.8292 13.731 13.2831 11.3874 14.5056C11.3776 14.5107 11.3678 14.5159 11.3579 14.521C11.1424 14.6336 10.9031 14.7586 10.6303 14.8297C10.3237 14.9097 10.0142 14.9146 9.642 14.8642C9.30035 14.8179 8.9282 14.6439 8.63816 14.4681C8.34812 14.2923 8.02176 14.0428 7.8227 13.7613C7.33206 13.0674 7.33261 12.4037 7.3333 11.563C7.33333 11.5311 7.33335 11.499 7.33335 11.4666V6.94277L5.80476 8.47136C5.54441 8.73171 5.1223 8.73171 4.86195 8.47136C4.6016 8.21101 4.6016 7.7889 4.86195 7.52855L7.52862 4.86189C7.65364 4.73686 7.82321 4.66663 8.00002 4.66663C8.17683 4.66663 8.3464 4.73686 8.47143 4.86189L11.1381 7.52855C11.3984 7.7889 11.3984 8.21101 11.1381 8.47136C10.8777 8.73171 10.4556 8.73171 10.1953 8.47136L8.66669 6.94277V11.4666C8.66669 12.4341 8.68658 12.6736 8.91136 12.9915C8.95616 13.0548 9.10277 13.1905 9.32937 13.3279C9.55597 13.4653 9.74412 13.5325 9.82101 13.5429C10.0787 13.5778 10.2038 13.563 10.2939 13.5395C10.4053 13.5105 10.5154 13.4567 10.7707 13.3235C12.6913 12.3216 14 10.3131 14 7.99996C14 4.68625 11.3137 1.99996 8.00002 1.99996Z" fill="#3E62F5"/> - </svg> - </span> - <span class="directorist_link-text"> - <?php esc_html_e( 'Import Directory', 'directorist' ) ?> - </span> - </button> - </div> + <button class="directorist_link-block directorist_link-block-primary-outline directorist_btn-import cptm-modal-toggle" data-target="cptm-import-directory-modal"> + <span class="directorist_link-icon"> + <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M8.00002 1.99996C4.68631 1.99996 2.00002 4.68625 2.00002 7.99996C2.00002 10.22 3.20536 12.1592 5.0005 13.1977C5.31921 13.382 5.42812 13.7899 5.24376 14.1086C5.0594 14.4273 4.65158 14.5362 4.33287 14.3518C2.14267 13.0849 0.666687 10.7152 0.666687 7.99996C0.666687 3.94987 3.94993 0.666626 8.00002 0.666626C12.0501 0.666626 15.3334 3.94987 15.3334 7.99996C15.3334 10.8292 13.731 13.2831 11.3874 14.5056C11.3776 14.5107 11.3678 14.5159 11.3579 14.521C11.1424 14.6336 10.9031 14.7586 10.6303 14.8297C10.3237 14.9097 10.0142 14.9146 9.642 14.8642C9.30035 14.8179 8.9282 14.6439 8.63816 14.4681C8.34812 14.2923 8.02176 14.0428 7.8227 13.7613C7.33206 13.0674 7.33261 12.4037 7.3333 11.563C7.33333 11.5311 7.33335 11.499 7.33335 11.4666V6.94277L5.80476 8.47136C5.54441 8.73171 5.1223 8.73171 4.86195 8.47136C4.6016 8.21101 4.6016 7.7889 4.86195 7.52855L7.52862 4.86189C7.65364 4.73686 7.82321 4.66663 8.00002 4.66663C8.17683 4.66663 8.3464 4.73686 8.47143 4.86189L11.1381 7.52855C11.3984 7.7889 11.3984 8.21101 11.1381 8.47136C10.8777 8.73171 10.4556 8.73171 10.1953 8.47136L8.66669 6.94277V11.4666C8.66669 12.4341 8.68658 12.6736 8.91136 12.9915C8.95616 13.0548 9.10277 13.1905 9.32937 13.3279C9.55597 13.4653 9.74412 13.5325 9.82101 13.5429C10.0787 13.5778 10.2038 13.563 10.2939 13.5395C10.4053 13.5105 10.5154 13.4567 10.7707 13.3235C12.6913 12.3216 14 10.3131 14 7.99996C14 4.68625 11.3137 1.99996 8.00002 1.99996Z" fill="#3E62F5"/> + </svg> + </span> + <span class="directorist_link-text"> + <?php esc_html_e( 'Import Directory', 'directorist' ); ?> + </span> + </button> + </div> - <?php if ( $show_migration_button ) : ?> - <button class="directorist_link-block directorist_link-block-success directorist_btn-migrate cptm-modal-toggle" data-target="cptm-directory-mirgation-modal"> - <span class="directorist_link-icon"> - <i class="la la-download"></i> - </span> - <span class="directorist_link-text"> - <?php esc_html_e( 'Migrate', 'directorist' ) ?> - </span> - </button> - <?php endif; ?> - </div> - <?php - $all_items = wp_count_terms('atbdp_listing_types'); - $listing_types = get_terms([ - 'taxonomy' => 'atbdp_listing_types', - 'hide_empty' => false, - 'orderby' => 'date', - 'order' => 'DSCE', - ]); - ?> - <div class="directorist_builder__content__right"> - <div class="directorist-total-types"> - <?php esc_html_e( 'All Directories','directorist' ); ?><span class="directorist_count">(<?php echo esc_attr( ! empty( $all_items ) ? $all_items : 0 ); ?>)</span> - </div> - <div class="directorist_table"> - <div class="directorist_table-header"> - <div class="directorist_table-row"> - <div class="directorist_listing-title"><?php esc_html_e( 'Name', 'directorist' ); ?></div> - <div class="directorist_listing-slug"><?php esc_html_e( 'Slug', 'directorist' ); ?></div> - <div class="directorist_listing-count"><span class="directorist_listing-count-title"><?php esc_html_e( 'Listings', 'directorist' ); ?></span></div> - <div class="directorist_listing-c-date"><?php esc_html_e( 'Created Date', 'directorist' ); ?></div> - <div class="directorist_listing-c-action"><?php esc_html_e( 'Action', 'directorist' ); ?></div> - </div> - </div> - <div class="directorist_table-body"> - <?php if( $listing_types ) { foreach( $listing_types as $listing_type) { - $default = get_term_meta( $listing_type->term_id, '_default', true ); - $edit_link = admin_url('edit.php?post_type=at_biz_dir&page=atbdp-directory-types&listing_type_id=' . absint( $listing_type->term_id ) . '&action=edit'); - $delete_link = admin_url('admin-post.php?listing_type_id=' . absint( $listing_type->term_id ) . '&action=delete_listing_type'); - $delete_link = wp_nonce_url( $delete_link, 'delete_listing_type'); - $created_time = get_term_meta( $listing_type->term_id, '_created_date', true ); - ?> - <div class="directorist_table-row directory-type-row" data-term-id="<?php echo esc_attr( $listing_type->term_id ); ?>"> - <div class="directorist_title"> - <a href="<?php echo esc_url( ! empty( $edit_link ) ? $edit_link : '#' ); ?>"> - <?php echo esc_html( ! empty( $listing_type->name ) ? $listing_type->name : '-' ); ?> - <?php if( $default ) { ?> - <span class="directorist_badge"><?php esc_html_e( 'Default', 'directorist' ); ?></span> - <?php } ?> - </a> - <div class="directorist_listing-id">ID: #<?php echo esc_attr( ! empty( $listing_type->term_id ) ? $listing_type->term_id : '' ); ?></div> - </div> - <div class="directorist-type-slug"> - <div class="directorist-type-slug-content directorist-row-tooltip" data-tooltip="Click here to rename the slug." data-flow="bottom"> - <span class=" directorist_listing-slug-text directorist-slug-text-<?php echo esc_attr( $listing_type->term_id ); ?>" data-value="<?php echo esc_attr( ! empty( $listing_type->slug ) ? $listing_type->slug : '-' ); ?>" contenteditable="false" data-type-id="<?php echo absint( $listing_type->term_id ); ?>"> - <?php echo esc_html( html_entity_decode( $listing_type->slug ) ); ?> - </span> - </div> - <p class="directorist-slug-notice directorist-slug-notice-<?php echo esc_attr( $listing_type->term_id ); ?>"></p> - </div> - <div class="directorist-type-count"> - <span class="directorist_listing-count"><?php echo esc_html( $listing_type->count ); ?></span> - </div> - <div class="directorist-type-date"> - <?php if( $created_time ) { echo esc_attr( date( 'F j, Y', $created_time ) ); } ?> - </div> - <div class="directorist-type-actions"> - <div class="directorist_listing-actions"> - <a href="<?php echo esc_url( ! empty( $edit_link ) ? $edit_link : '#' ); ?>" class="directorist_btn directorist_btn-primary"> - <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"> - <g clip-path="url(#clip0_5013_877)"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M10.0875 0.754228C10.3153 0.526423 10.6847 0.526423 10.9125 0.754228L13.2458 3.08756C13.4736 3.31537 13.4736 3.68471 13.2458 3.91252C13.018 4.14033 12.6487 4.14033 12.4208 3.91252L10.0875 1.57919C9.85971 1.35138 9.85971 0.982034 10.0875 0.754228ZM8.4796 2.49701C8.65534 2.43991 8.84464 2.43991 9.02038 2.49701C9.15609 2.5411 9.25444 2.61434 9.31923 2.66934C9.37514 2.71681 9.43379 2.77551 9.48291 2.82466C9.48613 2.82789 9.48932 2.83107 9.49245 2.83421L11.1754 4.51714C11.2245 4.56625 11.2832 4.6249 11.3307 4.68081C11.3857 4.7456 11.4589 4.84395 11.503 4.97965C11.5601 5.15539 11.5601 5.34469 11.503 5.52043C11.4589 5.65613 11.3857 5.75448 11.3307 5.81928C11.2832 5.8752 11.2245 5.93385 11.1754 5.98297L5.138 12.0203C5.1306 12.0277 5.12327 12.0351 5.11599 12.0423C5.00709 12.1514 4.91099 12.2476 4.79963 12.3287C4.70164 12.4001 4.59649 12.4612 4.48588 12.5108C4.36019 12.5672 4.22896 12.603 4.08027 12.6434C4.07034 12.6461 4.06032 12.6488 4.05023 12.6516L1.32014 13.3962C1.11819 13.4512 0.902202 13.3939 0.754181 13.2459C0.60616 13.0978 0.548802 12.8818 0.603881 12.6799L1.34845 9.94981C1.3512 9.93971 1.35393 9.9297 1.35663 9.91976C1.39709 9.77107 1.43279 9.63984 1.48922 9.51415C1.53888 9.40354 1.5999 9.2984 1.67129 9.20041C1.75243 9.08905 1.84865 8.99294 1.95768 8.88405C1.96496 8.87677 1.97231 8.86944 1.97971 8.86203L8.00753 2.83421C8.01067 2.83108 8.01384 2.82789 8.01707 2.82467C8.06618 2.77552 8.12484 2.71682 8.18076 2.66935C8.24555 2.61434 8.3439 2.5411 8.4796 2.49701ZM8.74999 3.74167L2.80467 9.68699C2.66171 9.82995 2.63489 9.85906 2.61423 9.88741C2.59043 9.92008 2.57009 9.95513 2.55354 9.992C2.53917 10.024 2.5272 10.0617 2.47401 10.2568L1.99804 12.002L3.74326 11.526C3.93831 11.4728 3.97603 11.4609 4.00804 11.4465C4.0449 11.4299 4.07995 11.4096 4.11262 11.3858C4.14098 11.3651 4.17008 11.3383 4.31304 11.1954L10.2584 5.25004L8.74999 3.74167Z" fill="currentColor"/> - </g> - <defs> - <clipPath id="clip0_5013_877"> - <rect width="14" height="14" fill="white"/> - </clipPath> - </defs> - </svg> - <?php esc_html_e( 'Edit', 'directorist' ); ?> - </a> + <?php if ( $show_migration_button ) : ?> + <button class="directorist_link-block directorist_link-block-success directorist_btn-migrate cptm-modal-toggle" data-target="cptm-directory-mirgation-modal"> + <span class="directorist_link-icon"> + <i class="la la-download"></i> + </span> + <span class="directorist_link-text"> + <?php esc_html_e( 'Migrate', 'directorist' ); ?> + </span> + </button> + <?php endif; ?> + </div> + <?php + $all_items = wp_count_terms( 'atbdp_listing_types' ); + $listing_types = get_terms( + array( + 'taxonomy' => 'atbdp_listing_types', + 'hide_empty' => false, + 'orderby' => 'date', + 'order' => 'DSCE', + ) + ); + ?> + <div class="directorist_builder__content__right"> + <div class="directorist-total-types"> + <?php esc_html_e( 'All Directories', 'directorist' ); ?><span class="directorist_count">(<?php echo esc_attr( ! empty( $all_items ) ? $all_items : 0 ); ?>)</span> + </div> + <div class="directorist_table"> + <div class="directorist_table-header"> + <div class="directorist_table-row"> + <div class="directorist_listing-title"><?php esc_html_e( 'Name', 'directorist' ); ?></div> + <div class="directorist_listing-slug"><?php esc_html_e( 'Slug', 'directorist' ); ?></div> + <div class="directorist_listing-count"><span class="directorist_listing-count-title"><?php esc_html_e( 'Listings', 'directorist' ); ?></span></div> + <div class="directorist_listing-c-date"><?php esc_html_e( 'Created Date', 'directorist' ); ?></div> + <div class="directorist_listing-c-action"><?php esc_html_e( 'Action', 'directorist' ); ?></div> + </div> + </div> + <div class="directorist_table-body"> + <?php + if ( $listing_types ) { + foreach ( $listing_types as $listing_type ) { + $default = get_term_meta( $listing_type->term_id, '_default', true ); + $edit_link = admin_url( 'edit.php?post_type=at_biz_dir&page=atbdp-directory-types&listing_type_id=' . absint( $listing_type->term_id ) . '&action=edit' ); + $delete_link = admin_url( 'admin-post.php?listing_type_id=' . absint( $listing_type->term_id ) . '&action=delete_listing_type' ); + $delete_link = wp_nonce_url( $delete_link, 'delete_listing_type' ); + $created_time = get_term_meta( $listing_type->term_id, '_created_date', true ); + ?> + <div class="directorist_table-row directory-type-row" data-term-id="<?php echo esc_attr( $listing_type->term_id ); ?>"> + <div class="directorist_title"> + <a href="<?php echo esc_url( ! empty( $edit_link ) ? $edit_link : '#' ); ?>"> + <?php echo esc_html( ! empty( $listing_type->name ) ? $listing_type->name : '-' ); ?> + <?php if ( $default ) { ?> + <span class="directorist_badge"><?php esc_html_e( 'Default', 'directorist' ); ?></span> + <?php } ?> + </a> + <div class="directorist_listing-id">ID: #<?php echo esc_attr( ! empty( $listing_type->term_id ) ? $listing_type->term_id : '' ); ?></div> + </div> + <div class="directorist-type-slug"> + <div class="directorist-type-slug-content directorist-row-tooltip" data-tooltip="Click here to rename the slug." data-flow="bottom"> + <span class=" directorist_listing-slug-text directorist-slug-text-<?php echo esc_attr( $listing_type->term_id ); ?>" data-value="<?php echo esc_attr( ! empty( $listing_type->slug ) ? $listing_type->slug : '-' ); ?>" contenteditable="false" data-type-id="<?php echo absint( $listing_type->term_id ); ?>"> + <?php echo esc_html( html_entity_decode( $listing_type->slug ) ); ?> + </span> + </div> + <p class="directorist-slug-notice directorist-slug-notice-<?php echo esc_attr( $listing_type->term_id ); ?>"></p> + </div> + <div class="directorist-type-count"> + <span class="directorist_listing-count"><?php echo esc_html( $listing_type->count ); ?></span> + </div> + <div class="directorist-type-date"> + <?php + if ( $created_time ) { + echo esc_attr( date( 'F j, Y', $created_time ) ); } + ?> + </div> + <div class="directorist-type-actions"> + <div class="directorist_listing-actions"> + <a href="<?php echo esc_url( ! empty( $edit_link ) ? $edit_link : '#' ); ?>" class="directorist_btn directorist_btn-primary"> + <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none"> + <g clip-path="url(#clip0_5013_877)"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M10.0875 0.754228C10.3153 0.526423 10.6847 0.526423 10.9125 0.754228L13.2458 3.08756C13.4736 3.31537 13.4736 3.68471 13.2458 3.91252C13.018 4.14033 12.6487 4.14033 12.4208 3.91252L10.0875 1.57919C9.85971 1.35138 9.85971 0.982034 10.0875 0.754228ZM8.4796 2.49701C8.65534 2.43991 8.84464 2.43991 9.02038 2.49701C9.15609 2.5411 9.25444 2.61434 9.31923 2.66934C9.37514 2.71681 9.43379 2.77551 9.48291 2.82466C9.48613 2.82789 9.48932 2.83107 9.49245 2.83421L11.1754 4.51714C11.2245 4.56625 11.2832 4.6249 11.3307 4.68081C11.3857 4.7456 11.4589 4.84395 11.503 4.97965C11.5601 5.15539 11.5601 5.34469 11.503 5.52043C11.4589 5.65613 11.3857 5.75448 11.3307 5.81928C11.2832 5.8752 11.2245 5.93385 11.1754 5.98297L5.138 12.0203C5.1306 12.0277 5.12327 12.0351 5.11599 12.0423C5.00709 12.1514 4.91099 12.2476 4.79963 12.3287C4.70164 12.4001 4.59649 12.4612 4.48588 12.5108C4.36019 12.5672 4.22896 12.603 4.08027 12.6434C4.07034 12.6461 4.06032 12.6488 4.05023 12.6516L1.32014 13.3962C1.11819 13.4512 0.902202 13.3939 0.754181 13.2459C0.60616 13.0978 0.548802 12.8818 0.603881 12.6799L1.34845 9.94981C1.3512 9.93971 1.35393 9.9297 1.35663 9.91976C1.39709 9.77107 1.43279 9.63984 1.48922 9.51415C1.53888 9.40354 1.5999 9.2984 1.67129 9.20041C1.75243 9.08905 1.84865 8.99294 1.95768 8.88405C1.96496 8.87677 1.97231 8.86944 1.97971 8.86203L8.00753 2.83421C8.01067 2.83108 8.01384 2.82789 8.01707 2.82467C8.06618 2.77552 8.12484 2.71682 8.18076 2.66935C8.24555 2.61434 8.3439 2.5411 8.4796 2.49701ZM8.74999 3.74167L2.80467 9.68699C2.66171 9.82995 2.63489 9.85906 2.61423 9.88741C2.59043 9.92008 2.57009 9.95513 2.55354 9.992C2.53917 10.024 2.5272 10.0617 2.47401 10.2568L1.99804 12.002L3.74326 11.526C3.93831 11.4728 3.97603 11.4609 4.00804 11.4465C4.0449 11.4299 4.07995 11.4096 4.11262 11.3858C4.14098 11.3651 4.17008 11.3383 4.31304 11.1954L10.2584 5.25004L8.74999 3.74167Z" fill="currentColor"/> + </g> + <defs> + <clipPath id="clip0_5013_877"> + <rect width="14" height="14" fill="white"/> + </clipPath> + </defs> + </svg> + <?php esc_html_e( 'Edit', 'directorist' ); ?> + </a> - <div class="directorist_more-dropdown <?php echo ( $default ) ? 'default' : ''; ?>"> - <a href="#" class="directorist_more-dropdown-toggle"> - <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 10C2.5 9.07957 3.24619 8.33337 4.16667 8.33337C5.08714 8.33337 5.83333 9.07957 5.83333 10C5.83333 10.9205 5.08714 11.6667 4.16667 11.6667C3.24619 11.6667 2.5 10.9205 2.5 10ZM8.33333 10C8.33333 9.07957 9.07953 8.33337 10 8.33337C10.9205 8.33337 11.6667 9.07957 11.6667 10C11.6667 10.9205 10.9205 11.6667 10 11.6667C9.07953 11.6667 8.33333 10.9205 8.33333 10ZM14.1667 10C14.1667 9.07957 14.9129 8.33337 15.8333 8.33337C16.7538 8.33337 17.5 9.07957 17.5 10C17.5 10.9205 16.7538 11.6667 15.8333 11.6667C14.9129 11.6667 14.1667 10.9205 14.1667 10Z" fill="currentColor"/> - </svg> - </a> - <div class="directorist_more-dropdown-option"> - <ul> - <li> - <div data-type-id="<?php echo absint( $listing_type->term_id ); ?>" class="directorist_listing-type-checkbox directorist_custom-checkbox submitdefault"> - <input class="submitDefaultCheckbox" type="checkbox" name="check-1" id="check-1"> - <label for="check-1"> - <span class="checkbox-text"><?php esc_html_e( 'Make It Default', 'directorist' ); ?></span> - </label> - </div> - </li> - <li> - <a href="#" class="cptm-modal-toggle atbdp-directory-delete-link-action" data-delete-link="<?php echo esc_url( $delete_link ); ?>" data-target="cptm-delete-directory-modal"> - <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M6 2.25C6 1.83579 6.33579 1.5 6.75 1.5H11.25C11.6642 1.5 12 1.83579 12 2.25C12 2.66421 11.6642 3 11.25 3H6.75C6.33579 3 6 2.66421 6 2.25ZM3.74418 3.75H2.25C1.83579 3.75 1.5 4.08579 1.5 4.5C1.5 4.91421 1.83579 5.25 2.25 5.25H3.04834L3.52961 12.4691C3.56737 13.0357 3.59862 13.5045 3.65465 13.8862C3.71299 14.2835 3.80554 14.6466 3.99832 14.985C4.29842 15.5118 4.75109 15.9353 5.29667 16.1997C5.64714 16.3695 6.0156 16.4377 6.41594 16.4695C6.80046 16.5 7.27037 16.5 7.8382 16.5H10.1618C10.7296 16.5 11.1995 16.5 11.5841 16.4695C11.9844 16.4377 12.3529 16.3695 12.7033 16.1997C13.2489 15.9353 13.7016 15.5118 14.0017 14.985C14.1945 14.6466 14.287 14.2835 14.3453 13.8862C14.4014 13.5045 14.4326 13.0356 14.4704 12.469L14.9517 5.25H15.75C16.1642 5.25 16.5 4.91421 16.5 4.5C16.5 4.08579 16.1642 3.75 15.75 3.75H14.2558C14.2514 3.74996 14.2471 3.74996 14.2427 3.75H3.75731C3.75294 3.74996 3.74857 3.74996 3.74418 3.75ZM13.4483 5.25H4.55166L5.0243 12.3396C5.06455 12.9433 5.09238 13.3525 5.13874 13.6683C5.18377 13.9749 5.23878 14.1321 5.30166 14.2425C5.45171 14.5059 5.67804 14.7176 5.95083 14.8498C6.06513 14.9052 6.22564 14.9497 6.53464 14.9742C6.85277 14.9995 7.26289 15 7.86799 15H10.132C10.7371 15 11.1472 14.9995 11.4654 14.9742C11.7744 14.9497 11.9349 14.9052 12.0492 14.8498C12.322 14.7176 12.5483 14.5059 12.6983 14.2425C12.7612 14.1321 12.8162 13.9749 12.8613 13.6683C12.9076 13.3525 12.9354 12.9433 12.9757 12.3396L13.4483 5.25ZM7.5 7.125C7.91421 7.125 8.25 7.46079 8.25 7.875V11.625C8.25 12.0392 7.91421 12.375 7.5 12.375C7.08579 12.375 6.75 12.0392 6.75 11.625V7.875C6.75 7.46079 7.08579 7.125 7.5 7.125ZM10.5 7.125C10.9142 7.125 11.25 7.46079 11.25 7.875V11.625C11.25 12.0392 10.9142 12.375 10.5 12.375C10.0858 12.375 9.75 12.0392 9.75 11.625V7.875C9.75 7.46079 10.0858 7.125 10.5 7.125Z" fill="#D94A4A"/> - </svg> - <?php esc_html_e( 'Delete', 'directorist' ); ?></a> - </li> - </ul> - </div> - </div> - </div> - <div class="directorist_notifier"></div> - </div> - </div> - <?php } } ?> - </div> - </div> - </div> - </div> - </div> - </div> + <div class="directorist_more-dropdown <?php echo ( $default ) ? 'default' : ''; ?>"> + <a href="#" class="directorist_more-dropdown-toggle"> + <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 10C2.5 9.07957 3.24619 8.33337 4.16667 8.33337C5.08714 8.33337 5.83333 9.07957 5.83333 10C5.83333 10.9205 5.08714 11.6667 4.16667 11.6667C3.24619 11.6667 2.5 10.9205 2.5 10ZM8.33333 10C8.33333 9.07957 9.07953 8.33337 10 8.33337C10.9205 8.33337 11.6667 9.07957 11.6667 10C11.6667 10.9205 10.9205 11.6667 10 11.6667C9.07953 11.6667 8.33333 10.9205 8.33333 10ZM14.1667 10C14.1667 9.07957 14.9129 8.33337 15.8333 8.33337C16.7538 8.33337 17.5 9.07957 17.5 10C17.5 10.9205 16.7538 11.6667 15.8333 11.6667C14.9129 11.6667 14.1667 10.9205 14.1667 10Z" fill="currentColor"/> + </svg> + </a> + <div class="directorist_more-dropdown-option"> + <ul> + <li> + <div data-type-id="<?php echo absint( $listing_type->term_id ); ?>" class="directorist_listing-type-checkbox directorist_custom-checkbox submitdefault"> + <input class="submitDefaultCheckbox" type="checkbox" name="check-1" id="check-1"> + <label for="check-1"> + <span class="checkbox-text"><?php esc_html_e( 'Make It Default', 'directorist' ); ?></span> + </label> + </div> + </li> + <li> + <a href="#" class="cptm-modal-toggle atbdp-directory-delete-link-action" data-delete-link="<?php echo esc_url( $delete_link ); ?>" data-target="cptm-delete-directory-modal"> + <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M6 2.25C6 1.83579 6.33579 1.5 6.75 1.5H11.25C11.6642 1.5 12 1.83579 12 2.25C12 2.66421 11.6642 3 11.25 3H6.75C6.33579 3 6 2.66421 6 2.25ZM3.74418 3.75H2.25C1.83579 3.75 1.5 4.08579 1.5 4.5C1.5 4.91421 1.83579 5.25 2.25 5.25H3.04834L3.52961 12.4691C3.56737 13.0357 3.59862 13.5045 3.65465 13.8862C3.71299 14.2835 3.80554 14.6466 3.99832 14.985C4.29842 15.5118 4.75109 15.9353 5.29667 16.1997C5.64714 16.3695 6.0156 16.4377 6.41594 16.4695C6.80046 16.5 7.27037 16.5 7.8382 16.5H10.1618C10.7296 16.5 11.1995 16.5 11.5841 16.4695C11.9844 16.4377 12.3529 16.3695 12.7033 16.1997C13.2489 15.9353 13.7016 15.5118 14.0017 14.985C14.1945 14.6466 14.287 14.2835 14.3453 13.8862C14.4014 13.5045 14.4326 13.0356 14.4704 12.469L14.9517 5.25H15.75C16.1642 5.25 16.5 4.91421 16.5 4.5C16.5 4.08579 16.1642 3.75 15.75 3.75H14.2558C14.2514 3.74996 14.2471 3.74996 14.2427 3.75H3.75731C3.75294 3.74996 3.74857 3.74996 3.74418 3.75ZM13.4483 5.25H4.55166L5.0243 12.3396C5.06455 12.9433 5.09238 13.3525 5.13874 13.6683C5.18377 13.9749 5.23878 14.1321 5.30166 14.2425C5.45171 14.5059 5.67804 14.7176 5.95083 14.8498C6.06513 14.9052 6.22564 14.9497 6.53464 14.9742C6.85277 14.9995 7.26289 15 7.86799 15H10.132C10.7371 15 11.1472 14.9995 11.4654 14.9742C11.7744 14.9497 11.9349 14.9052 12.0492 14.8498C12.322 14.7176 12.5483 14.5059 12.6983 14.2425C12.7612 14.1321 12.8162 13.9749 12.8613 13.6683C12.9076 13.3525 12.9354 12.9433 12.9757 12.3396L13.4483 5.25ZM7.5 7.125C7.91421 7.125 8.25 7.46079 8.25 7.875V11.625C8.25 12.0392 7.91421 12.375 7.5 12.375C7.08579 12.375 6.75 12.0392 6.75 11.625V7.875C6.75 7.46079 7.08579 7.125 7.5 7.125ZM10.5 7.125C10.9142 7.125 11.25 7.46079 11.25 7.875V11.625C11.25 12.0392 10.9142 12.375 10.5 12.375C10.0858 12.375 9.75 12.0392 9.75 11.625V7.875C9.75 7.46079 10.0858 7.125 10.5 7.125Z" fill="#D94A4A"/> + </svg> + <?php esc_html_e( 'Delete', 'directorist' ); ?></a> + </li> + </ul> + </div> + </div> + </div> + <div class="directorist_notifier"></div> + </div> + </div> + <?php + } + } + ?> + </div> + </div> + </div> + </div> + </div> + </div> </div> <!-- Model : Import Directory --> <div class="cptm-modal-container cptm-create-directory-modal"> - <div class="cptm-modal-wrap"> - <div class="cptm-modal"> - <div class="cptm-modal-content"> - <div class="cptm-modal-header cptm-create-directory-modal__header"> - <div class="cptm-create-directory-modal__header__content"> - <h3 class="cptm-modal-header-title cptm-create-directory-modal__title"><?php esc_html_e( 'Create New Directory', 'directorist' ); ?></h3> - <p class="cptm-create-directory-modal__desc"><?php esc_html_e( ' Let AI create it or choose a template or start from scratch.', 'directorist' ); ?></p> - </div> - <button class="cptm-modal-action-link cptm-modal-toggle" data-target="cptm-create-directory-modal"> - <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> - <path fill-rule="evenodd" clip-rule="evenodd" d="M6.29289 6.29289C6.68342 5.90237 7.31658 5.90237 7.70711 6.29289L12 10.5858L16.2929 6.29289C16.6834 5.90237 17.3166 5.90237 17.7071 6.29289C18.0976 6.68342 18.0976 7.31658 17.7071 7.70711L13.4142 12L17.7071 16.2929C18.0976 16.6834 18.0976 17.3166 17.7071 17.7071C17.3166 18.0976 16.6834 18.0976 16.2929 17.7071L12 13.4142L7.70711 17.7071C7.31658 18.0976 6.68342 18.0976 6.29289 17.7071C5.90237 17.3166 5.90237 16.6834 6.29289 16.2929L10.5858 12L6.29289 7.70711C5.90237 7.31658 5.90237 6.68342 6.29289 6.29289Z" fill="currentColor"/> - </svg> - </button> - </div> + <div class="cptm-modal-wrap"> + <div class="cptm-modal"> + <div class="cptm-modal-content"> + <div class="cptm-modal-header cptm-create-directory-modal__header"> + <div class="cptm-create-directory-modal__header__content"> + <h3 class="cptm-modal-header-title cptm-create-directory-modal__title"><?php esc_html_e( 'Create New Directory', 'directorist' ); ?></h3> + <p class="cptm-create-directory-modal__desc"><?php esc_html_e( ' Let AI create it or choose a template or start from scratch.', 'directorist' ); ?></p> + </div> + <button class="cptm-modal-action-link cptm-modal-toggle" data-target="cptm-create-directory-modal"> + <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> + <path fill-rule="evenodd" clip-rule="evenodd" d="M6.29289 6.29289C6.68342 5.90237 7.31658 5.90237 7.70711 6.29289L12 10.5858L16.2929 6.29289C16.6834 5.90237 17.3166 5.90237 17.7071 6.29289C18.0976 6.68342 18.0976 7.31658 17.7071 7.70711L13.4142 12L17.7071 16.2929C18.0976 16.6834 18.0976 17.3166 17.7071 17.7071C17.3166 18.0976 16.6834 18.0976 16.2929 17.7071L12 13.4142L7.70711 17.7071C7.31658 18.0976 6.68342 18.0976 6.29289 17.7071C5.90237 17.3166 5.90237 16.6834 6.29289 16.2929L10.5858 12L6.29289 7.70711C5.90237 7.31658 5.90237 6.68342 6.29289 6.29289Z" fill="currentColor"/> + </svg> + </button> + </div> - <div class="cptm-modal-body cptm-center-content cptm-content-wide cptm-create-directory-modal__body"> - <div class="cptm-create-directory-modal__action"> - <a href="<?php echo admin_url( 'admin.php?page=templatiq' ) ?>" class="cptm-create-directory-modal__action__single <?php echo ! is_plugin_active( 'templatiq/templatiq.php' ) ? 'directorist_directory_template_library' : ''; ?>"> - <span class="modal-btn-icon create-template"> - <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> - <g clip-path="url(#clip0_5814_6155)"> - <path d="M9.18492 1.6665L9.40142 0.94843C9.21009 0.890745 9.00364 0.911803 8.8279 1.00693C8.65216 1.10206 8.52164 1.2634 8.46532 1.45514L9.18492 1.6665ZM18.334 4.4249L19.0536 4.63627C19.1697 4.24085 18.9451 3.82579 18.5505 3.70683L18.334 4.4249ZM14.983 15.8332L14.7665 16.5512C14.9579 16.6089 15.1643 16.5879 15.3401 16.4927C15.5158 16.3976 15.6463 16.2363 15.7026 16.0445L14.983 15.8332ZM5.83398 13.0748L5.11438 12.8634C4.99824 13.2588 5.22291 13.6739 5.61749 13.7928L5.83398 13.0748ZM10.5416 6.57169L14.5191 7.63143L14.9052 6.18199L10.9278 5.12225L10.5416 6.57169ZM9.68903 9.73568L11.6777 10.2656L12.0639 8.81612L10.0752 8.28625L9.68903 9.73568ZM8.96843 2.38458L18.1175 5.14297L18.5505 3.70683L9.40142 0.94843L8.96843 2.38458ZM15.1995 15.1151L6.05048 12.3567L5.61749 13.7928L14.7665 16.5512L15.1995 15.1151ZM6.55358 13.2861L9.90452 1.87787L8.46532 1.45514L5.11438 12.8634L6.55358 13.2861ZM17.6144 4.21353L14.2634 15.6218L15.7026 16.0445L19.0536 4.63627L17.6144 4.21353Z" fill="white"/> - <path d="M5.83366 5.66846L1.66699 6.92469L5.01793 18.333L10.8337 16.5795" stroke="white" stroke-width="1.5" stroke-linejoin="round"/> - </g> - <defs> - <clipPath id="clip0_5814_6155"> - <rect width="20" height="20" fill="white"/> - </clipPath> - </defs> - </svg> - </span> - <span class="modal-btn-text"><?php esc_html_e( 'Use Template', 'directorist' ); ?></span> - <span class="modal-btn-desc"><?php echo esc_html( 'This will install the Templatiq plugin', 'directorist' ); ?></span> - </a> - <a href="<?php echo esc_attr( $data['add_new_link'] ); ?>" class="cptm-create-directory-modal__action__single"> - <span class="modal-btn-icon create-scratch"> - <svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg"> - <path d="M7.5 12.9998H6.75V13.7498H7.5V12.9998ZM7.5 10.0832L6.96967 9.55284L6.75 9.77251V10.0832H7.5ZM10.4167 12.9998V13.7498H10.7273L10.947 13.5302L10.4167 12.9998ZM15.4167 2.1665L15.947 1.63617C15.6541 1.34328 15.1792 1.34328 14.8863 1.63617L15.4167 2.1665ZM18.3333 5.08317L18.8637 5.6135C19.0043 5.47285 19.0833 5.28208 19.0833 5.08317C19.0833 4.88426 19.0043 4.69349 18.8637 4.55284L18.3333 5.08317ZM8.25 12.9998V10.0832H6.75V12.9998H8.25ZM7.5 13.7498H10.4167V12.2498H7.5V13.7498ZM8.03033 10.6135L15.947 2.69683L14.8863 1.63617L6.96967 9.55284L8.03033 10.6135ZM14.8863 2.69683L17.803 5.6135L18.8637 4.55284L15.947 1.63617L14.8863 2.69683ZM17.803 4.55284L9.88634 12.4695L10.947 13.5302L18.8637 5.6135L17.803 4.55284Z" fill="white"/> - <path d="M5.00033 13H3.12533C2.31991 13 1.66699 13.6529 1.66699 14.4583C1.66699 15.2637 2.31991 15.9167 3.12533 15.9167H11.042C11.8474 15.9167 12.5003 16.5696 12.5003 17.375C12.5003 18.1804 11.8474 18.8333 11.042 18.8333H9.16699" stroke="white" stroke-width="1.5" stroke-linejoin="round"/> - </svg> - </span> - <span class="modal-btn-text"><?php esc_html_e( 'Create from Scratch', 'directorist' ); ?></span> - </a> - <a href="" class="cptm-create-directory-modal__action__single directorist-ai-directory-creation"> - <span class="modal-badge modal-badge--new"> - <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> - <path d="M6.85753 1.4856L7.31468 0.91417C7.54325 0.685598 7.8861 0.571312 8.22896 0.799884C8.34325 0.91417 8.45753 1.14274 8.45753 1.25703V1.94274C8.45753 2.2856 8.57182 2.62846 8.91468 2.97131L11.429 5.25703C12.8004 6.62846 13.6004 8.45703 13.6004 10.3999C13.6004 13.1427 11.3147 15.4285 8.57182 15.4285H8.00039C4.91468 15.4285 2.40039 12.9142 2.40039 9.82846C2.40039 8.34274 2.97182 6.97131 4.00039 5.94274C4.22896 5.59988 4.68611 5.59988 4.91468 5.94274C5.02896 6.05703 5.14325 6.2856 5.14325 6.39988V9.02846C5.14325 10.057 6.05753 10.857 7.0861 10.857C8.11468 10.857 8.91468 10.057 8.91468 9.02846C8.91468 8.34274 8.6861 7.8856 8.34325 7.54274L7.20039 6.39988C5.94325 5.14274 5.71468 2.97131 6.85753 1.4856Z" fill="#3E62F5"/> - </svg> - Beta - </span> - <span class="modal-btn-icon create-ai"> - <svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg"> - <path d="M15.4362 10.5828L11.4065 9.09375L9.92212 5.06094C9.83422 4.82213 9.67518 4.61604 9.46647 4.47046C9.25775 4.32488 9.0094 4.24682 8.75493 4.24682C8.50046 4.24682 8.25212 4.32488 8.0434 4.47046C7.83469 4.61604 7.67565 4.82213 7.58775 5.06094L6.094 9.09375L2.06118 10.5781C1.82238 10.666 1.61628 10.8251 1.4707 11.0338C1.32513 11.2425 1.24707 11.4908 1.24707 11.7453C1.24707 11.9998 1.32513 12.2481 1.4707 12.4568C1.61628 12.6656 1.82238 12.8246 2.06118 12.9125L6.094 14.4062L7.57837 18.4391C7.66627 18.6779 7.82531 18.884 8.03403 19.0295C8.24274 19.1751 8.49109 19.2532 8.74556 19.2532C9.00003 19.2532 9.24838 19.1751 9.45709 19.0295C9.66581 18.884 9.82484 18.6779 9.91275 18.4391L11.4065 14.4062L15.4393 12.9219C15.6781 12.834 15.8842 12.6749 16.0298 12.4662C16.1754 12.2575 16.2534 12.0092 16.2534 11.7547C16.2534 11.5002 16.1754 11.2519 16.0298 11.0432C15.8842 10.8344 15.6781 10.6754 15.4393 10.5875L15.4362 10.5828ZM10.7034 13.3297C10.6185 13.361 10.5415 13.4103 10.4776 13.4742C10.4136 13.5381 10.3643 13.6152 10.3331 13.7L8.75025 17.9883L7.17056 13.7031C7.13934 13.6174 7.08974 13.5395 7.02522 13.475C6.96071 13.4105 6.88285 13.3609 6.79712 13.3297L2.51197 11.75L6.79712 10.1703C6.88285 10.1391 6.96071 10.0895 7.02522 10.025C7.08974 9.96046 7.13934 9.88261 7.17056 9.79688L8.75025 5.51172L10.3299 9.79688C10.3612 9.88171 10.4105 9.95875 10.4744 10.0227C10.5384 10.0866 10.6154 10.1359 10.7002 10.1672L14.9885 11.75L10.7034 13.3297ZM11.2502 3.625C11.2502 3.45924 11.3161 3.30027 11.4333 3.18306C11.5505 3.06585 11.7095 3 11.8752 3H13.1252V1.75C13.1252 1.58424 13.1911 1.42527 13.3083 1.30806C13.4255 1.19085 13.5845 1.125 13.7502 1.125C13.916 1.125 14.075 1.19085 14.1922 1.30806C14.3094 1.42527 14.3752 1.58424 14.3752 1.75V3H15.6252C15.791 3 15.95 3.06585 16.0672 3.18306C16.1844 3.30027 16.2502 3.45924 16.2502 3.625C16.2502 3.79076 16.1844 3.94973 16.0672 4.06694C15.95 4.18415 15.791 4.25 15.6252 4.25H14.3752V5.5C14.3752 5.66576 14.3094 5.82473 14.1922 5.94194C14.075 6.05915 13.916 6.125 13.7502 6.125C13.5845 6.125 13.4255 6.05915 13.3083 5.94194C13.1911 5.82473 13.1252 5.66576 13.1252 5.5V4.25H11.8752C11.7095 4.25 11.5505 4.18415 11.4333 4.06694C11.3161 3.94973 11.2502 3.79076 11.2502 3.625ZM19.3752 7.375C19.3752 7.54076 19.3094 7.69973 19.1922 7.81694C19.075 7.93415 18.916 8 18.7502 8H18.1252V8.625C18.1252 8.79076 18.0594 8.94973 17.9422 9.06694C17.825 9.18415 17.666 9.25 17.5002 9.25C17.3345 9.25 17.1755 9.18415 17.0583 9.06694C16.9411 8.94973 16.8752 8.79076 16.8752 8.625V8H16.2502C16.0845 8 15.9255 7.93415 15.8083 7.81694C15.6911 7.69973 15.6252 7.54076 15.6252 7.375C15.6252 7.20924 15.6911 7.05027 15.8083 6.93306C15.9255 6.81585 16.0845 6.75 16.2502 6.75H16.8752V6.125C16.8752 5.95924 16.9411 5.80027 17.0583 5.68306C17.1755 5.56585 17.3345 5.5 17.5002 5.5C17.666 5.5 17.825 5.56585 17.9422 5.68306C18.0594 5.80027 18.1252 5.95924 18.1252 6.125V6.75H18.7502C18.916 6.75 19.075 6.81585 19.1922 6.93306C19.3094 7.05027 19.3752 7.20924 19.3752 7.375Z" fill="white"/> - </svg> - </span> - <span class="modal-btn-text"><?php esc_html_e( 'Create with AI', 'directorist' ); ?></span> - </a> - </div> - </div> - </div> - </div> - </div> + <div class="cptm-modal-body cptm-center-content cptm-content-wide cptm-create-directory-modal__body"> + <div class="cptm-create-directory-modal__action"> + <a href="<?php echo admin_url( 'admin.php?page=templatiq' ); ?>" class="cptm-create-directory-modal__action__single <?php echo ! is_plugin_active( 'templatiq/templatiq.php' ) ? 'directorist_directory_template_library' : ''; ?>"> + <span class="modal-btn-icon create-template"> + <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> + <g clip-path="url(#clip0_5814_6155)"> + <path d="M9.18492 1.6665L9.40142 0.94843C9.21009 0.890745 9.00364 0.911803 8.8279 1.00693C8.65216 1.10206 8.52164 1.2634 8.46532 1.45514L9.18492 1.6665ZM18.334 4.4249L19.0536 4.63627C19.1697 4.24085 18.9451 3.82579 18.5505 3.70683L18.334 4.4249ZM14.983 15.8332L14.7665 16.5512C14.9579 16.6089 15.1643 16.5879 15.3401 16.4927C15.5158 16.3976 15.6463 16.2363 15.7026 16.0445L14.983 15.8332ZM5.83398 13.0748L5.11438 12.8634C4.99824 13.2588 5.22291 13.6739 5.61749 13.7928L5.83398 13.0748ZM10.5416 6.57169L14.5191 7.63143L14.9052 6.18199L10.9278 5.12225L10.5416 6.57169ZM9.68903 9.73568L11.6777 10.2656L12.0639 8.81612L10.0752 8.28625L9.68903 9.73568ZM8.96843 2.38458L18.1175 5.14297L18.5505 3.70683L9.40142 0.94843L8.96843 2.38458ZM15.1995 15.1151L6.05048 12.3567L5.61749 13.7928L14.7665 16.5512L15.1995 15.1151ZM6.55358 13.2861L9.90452 1.87787L8.46532 1.45514L5.11438 12.8634L6.55358 13.2861ZM17.6144 4.21353L14.2634 15.6218L15.7026 16.0445L19.0536 4.63627L17.6144 4.21353Z" fill="white"/> + <path d="M5.83366 5.66846L1.66699 6.92469L5.01793 18.333L10.8337 16.5795" stroke="white" stroke-width="1.5" stroke-linejoin="round"/> + </g> + <defs> + <clipPath id="clip0_5814_6155"> + <rect width="20" height="20" fill="white"/> + </clipPath> + </defs> + </svg> + </span> + <span class="modal-btn-text"><?php esc_html_e( 'Use Template', 'directorist' ); ?></span> + <span class="modal-btn-desc"><?php echo esc_html( 'This will install the Templatiq plugin', 'directorist' ); ?></span> + </a> + <a href="<?php echo esc_attr( $data['add_new_link'] ); ?>" class="cptm-create-directory-modal__action__single"> + <span class="modal-btn-icon create-scratch"> + <svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg"> + <path d="M7.5 12.9998H6.75V13.7498H7.5V12.9998ZM7.5 10.0832L6.96967 9.55284L6.75 9.77251V10.0832H7.5ZM10.4167 12.9998V13.7498H10.7273L10.947 13.5302L10.4167 12.9998ZM15.4167 2.1665L15.947 1.63617C15.6541 1.34328 15.1792 1.34328 14.8863 1.63617L15.4167 2.1665ZM18.3333 5.08317L18.8637 5.6135C19.0043 5.47285 19.0833 5.28208 19.0833 5.08317C19.0833 4.88426 19.0043 4.69349 18.8637 4.55284L18.3333 5.08317ZM8.25 12.9998V10.0832H6.75V12.9998H8.25ZM7.5 13.7498H10.4167V12.2498H7.5V13.7498ZM8.03033 10.6135L15.947 2.69683L14.8863 1.63617L6.96967 9.55284L8.03033 10.6135ZM14.8863 2.69683L17.803 5.6135L18.8637 4.55284L15.947 1.63617L14.8863 2.69683ZM17.803 4.55284L9.88634 12.4695L10.947 13.5302L18.8637 5.6135L17.803 4.55284Z" fill="white"/> + <path d="M5.00033 13H3.12533C2.31991 13 1.66699 13.6529 1.66699 14.4583C1.66699 15.2637 2.31991 15.9167 3.12533 15.9167H11.042C11.8474 15.9167 12.5003 16.5696 12.5003 17.375C12.5003 18.1804 11.8474 18.8333 11.042 18.8333H9.16699" stroke="white" stroke-width="1.5" stroke-linejoin="round"/> + </svg> + </span> + <span class="modal-btn-text"><?php esc_html_e( 'Create from Scratch', 'directorist' ); ?></span> + </a> + <a href="" class="cptm-create-directory-modal__action__single directorist-ai-directory-creation"> + <span class="modal-badge modal-badge--new"> + <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> + <path d="M6.85753 1.4856L7.31468 0.91417C7.54325 0.685598 7.8861 0.571312 8.22896 0.799884C8.34325 0.91417 8.45753 1.14274 8.45753 1.25703V1.94274C8.45753 2.2856 8.57182 2.62846 8.91468 2.97131L11.429 5.25703C12.8004 6.62846 13.6004 8.45703 13.6004 10.3999C13.6004 13.1427 11.3147 15.4285 8.57182 15.4285H8.00039C4.91468 15.4285 2.40039 12.9142 2.40039 9.82846C2.40039 8.34274 2.97182 6.97131 4.00039 5.94274C4.22896 5.59988 4.68611 5.59988 4.91468 5.94274C5.02896 6.05703 5.14325 6.2856 5.14325 6.39988V9.02846C5.14325 10.057 6.05753 10.857 7.0861 10.857C8.11468 10.857 8.91468 10.057 8.91468 9.02846C8.91468 8.34274 8.6861 7.8856 8.34325 7.54274L7.20039 6.39988C5.94325 5.14274 5.71468 2.97131 6.85753 1.4856Z" fill="#3E62F5"/> + </svg> + Beta + </span> + <span class="modal-btn-icon create-ai"> + <svg width="20" height="21" viewBox="0 0 20 21" fill="none" xmlns="http://www.w3.org/2000/svg"> + <path d="M15.4362 10.5828L11.4065 9.09375L9.92212 5.06094C9.83422 4.82213 9.67518 4.61604 9.46647 4.47046C9.25775 4.32488 9.0094 4.24682 8.75493 4.24682C8.50046 4.24682 8.25212 4.32488 8.0434 4.47046C7.83469 4.61604 7.67565 4.82213 7.58775 5.06094L6.094 9.09375L2.06118 10.5781C1.82238 10.666 1.61628 10.8251 1.4707 11.0338C1.32513 11.2425 1.24707 11.4908 1.24707 11.7453C1.24707 11.9998 1.32513 12.2481 1.4707 12.4568C1.61628 12.6656 1.82238 12.8246 2.06118 12.9125L6.094 14.4062L7.57837 18.4391C7.66627 18.6779 7.82531 18.884 8.03403 19.0295C8.24274 19.1751 8.49109 19.2532 8.74556 19.2532C9.00003 19.2532 9.24838 19.1751 9.45709 19.0295C9.66581 18.884 9.82484 18.6779 9.91275 18.4391L11.4065 14.4062L15.4393 12.9219C15.6781 12.834 15.8842 12.6749 16.0298 12.4662C16.1754 12.2575 16.2534 12.0092 16.2534 11.7547C16.2534 11.5002 16.1754 11.2519 16.0298 11.0432C15.8842 10.8344 15.6781 10.6754 15.4393 10.5875L15.4362 10.5828ZM10.7034 13.3297C10.6185 13.361 10.5415 13.4103 10.4776 13.4742C10.4136 13.5381 10.3643 13.6152 10.3331 13.7L8.75025 17.9883L7.17056 13.7031C7.13934 13.6174 7.08974 13.5395 7.02522 13.475C6.96071 13.4105 6.88285 13.3609 6.79712 13.3297L2.51197 11.75L6.79712 10.1703C6.88285 10.1391 6.96071 10.0895 7.02522 10.025C7.08974 9.96046 7.13934 9.88261 7.17056 9.79688L8.75025 5.51172L10.3299 9.79688C10.3612 9.88171 10.4105 9.95875 10.4744 10.0227C10.5384 10.0866 10.6154 10.1359 10.7002 10.1672L14.9885 11.75L10.7034 13.3297ZM11.2502 3.625C11.2502 3.45924 11.3161 3.30027 11.4333 3.18306C11.5505 3.06585 11.7095 3 11.8752 3H13.1252V1.75C13.1252 1.58424 13.1911 1.42527 13.3083 1.30806C13.4255 1.19085 13.5845 1.125 13.7502 1.125C13.916 1.125 14.075 1.19085 14.1922 1.30806C14.3094 1.42527 14.3752 1.58424 14.3752 1.75V3H15.6252C15.791 3 15.95 3.06585 16.0672 3.18306C16.1844 3.30027 16.2502 3.45924 16.2502 3.625C16.2502 3.79076 16.1844 3.94973 16.0672 4.06694C15.95 4.18415 15.791 4.25 15.6252 4.25H14.3752V5.5C14.3752 5.66576 14.3094 5.82473 14.1922 5.94194C14.075 6.05915 13.916 6.125 13.7502 6.125C13.5845 6.125 13.4255 6.05915 13.3083 5.94194C13.1911 5.82473 13.1252 5.66576 13.1252 5.5V4.25H11.8752C11.7095 4.25 11.5505 4.18415 11.4333 4.06694C11.3161 3.94973 11.2502 3.79076 11.2502 3.625ZM19.3752 7.375C19.3752 7.54076 19.3094 7.69973 19.1922 7.81694C19.075 7.93415 18.916 8 18.7502 8H18.1252V8.625C18.1252 8.79076 18.0594 8.94973 17.9422 9.06694C17.825 9.18415 17.666 9.25 17.5002 9.25C17.3345 9.25 17.1755 9.18415 17.0583 9.06694C16.9411 8.94973 16.8752 8.79076 16.8752 8.625V8H16.2502C16.0845 8 15.9255 7.93415 15.8083 7.81694C15.6911 7.69973 15.6252 7.54076 15.6252 7.375C15.6252 7.20924 15.6911 7.05027 15.8083 6.93306C15.9255 6.81585 16.0845 6.75 16.2502 6.75H16.8752V6.125C16.8752 5.95924 16.9411 5.80027 17.0583 5.68306C17.1755 5.56585 17.3345 5.5 17.5002 5.5C17.666 5.5 17.825 5.56585 17.9422 5.68306C18.0594 5.80027 18.1252 5.95924 18.1252 6.125V6.75H18.7502C18.916 6.75 19.075 6.81585 19.1922 6.93306C19.3094 7.05027 19.3752 7.20924 19.3752 7.375Z" fill="white"/> + </svg> + </span> + <span class="modal-btn-text"><?php esc_html_e( 'Create with AI', 'directorist' ); ?></span> + </a> + </div> + </div> + </div> + </div> + </div> </div> <!-- Model : Import Directory --> <div class="cptm-modal-container cptm-import-directory-modal"> - <div class="cptm-modal-wrap"> - <div class="cptm-modal"> - <div class="cptm-modal-content"> - <div class="cptm-modal-header"> - <h3 class="cptm-modal-header-title"><?php esc_html_e( 'Import', 'directorist' ); ?></h3> - <div class="cptm-modal-actions"> - <a href="#" class="cptm-modal-action-link cptm-modal-toggle" data-target="cptm-import-directory-modal"> - <span class="fa fa-times"></span> - </a> - </div> - </div> + <div class="cptm-modal-wrap"> + <div class="cptm-modal"> + <div class="cptm-modal-content"> + <div class="cptm-modal-header"> + <h3 class="cptm-modal-header-title"><?php esc_html_e( 'Import', 'directorist' ); ?></h3> + <div class="cptm-modal-actions"> + <a href="#" class="cptm-modal-action-link cptm-modal-toggle" data-target="cptm-import-directory-modal"> + <span class="fa fa-times"></span> + </a> + </div> + </div> - <div class="cptm-modal-body cptm-center-content cptm-content-wide"> - <form action="#" method="post" class="cptm-import-directory-form"> - <div class="cptm-form-group cptm-mb-10"> - <input type="text" name="directory-name" class="cptm-form-control cptm-text-center cptm-form-field" placeholder="Directory Name or ID"> - <div class="cptm-file-input-wrap"> - <label for="directory-import-file" class="cptm-btn cptm-btn-secondery"><?php esc_html_e( 'Select File', 'directorist' ); ?></label> - <button type="submit" class="cptm-btn cptm-btn-primary"> - <span class="cptm-loading-icon cptm-d-none"> - <span class="fa fa-spin fa fa-spinner"></span> - </span> - <?php esc_html_e( 'Import', 'directorist' ); ?> - </button> - <input id="directory-import-file" name="directory-import-file" type="file" accept=".json" class="cptm-d-none cptm-form-field cptm-file-field"> - </div> + <div class="cptm-modal-body cptm-center-content cptm-content-wide"> + <form action="#" method="post" class="cptm-import-directory-form"> + <div class="cptm-form-group cptm-mb-10"> + <input type="text" name="directory-name" class="cptm-form-control cptm-text-center cptm-form-field" placeholder="Directory Name or ID"> + <div class="cptm-file-input-wrap"> + <label for="directory-import-file" class="cptm-btn cptm-btn-secondery"><?php esc_html_e( 'Select File', 'directorist' ); ?></label> + <button type="submit" class="cptm-btn cptm-btn-primary"> + <span class="cptm-loading-icon cptm-d-none"> + <span class="fa fa-spin fa fa-spinner"></span> + </span> + <?php esc_html_e( 'Import', 'directorist' ); ?> + </button> + <input id="directory-import-file" name="directory-import-file" type="file" accept=".json" class="cptm-d-none cptm-form-field cptm-file-field"> + </div> - <p class="cptm-info-text"> - <b><?php esc_html_e( 'Note:', 'directorist' ); ?></b> - <?php esc_html_e( 'You can use an existed directory ID to update it the importing file', 'directorist' ); ?> - </p> - </div> + <p class="cptm-info-text"> + <b><?php esc_html_e( 'Note:', 'directorist' ); ?></b> + <?php esc_html_e( 'You can use an existed directory ID to update it the importing file', 'directorist' ); ?> + </p> + </div> - <div class="cptm-form-group-feedback cptm-text-center cptm-mb-10"></div> - </form> - </div> - </div> + <div class="cptm-form-group-feedback cptm-text-center cptm-mb-10"></div> + </form> + </div> + </div> - <div class="cptm-section-alert-area cptm-import-directory-modal-alert cptm-d-none"> - <div class="cptm-section-alert-content"> - <div class="cptm-section-alert-icon cptm-alert-success"> - <span class="fa fa-check"></span> - </div> + <div class="cptm-section-alert-area cptm-import-directory-modal-alert cptm-d-none"> + <div class="cptm-section-alert-content"> + <div class="cptm-section-alert-icon cptm-alert-success"> + <span class="fa fa-check"></span> + </div> - <div class="cptm-section-alert-message"> - <?php esc_html_e( 'The directory has been imported successfuly, redirecting...', 'directorist' ); ?> - </div> - </div> - </div> - </div> - </div> + <div class="cptm-section-alert-message"> + <?php esc_html_e( 'The directory has been imported successfuly, redirecting...', 'directorist' ); ?> + </div> + </div> + </div> + </div> + </div> </div> <!-- Model : Delete Directory --> <div class="cptm-modal-container cptm-delete-directory-modal"> - <div class="cptm-modal-wrap"> - <div class="cptm-modal"> - <div class="cptm-modal-content"> - <div class="cptm-modal-header"> - <h3 class="cptm-modal-header-title"><?php esc_html_e( 'Delete Derectory', 'directorist' ); ?></h3> - <div class="cptm-modal-actions"> - <a href="#" class="cptm-modal-action-link cptm-modal-toggle" data-target="cptm-delete-directory-modal"> - <span class="fa fa-times"></span> - </a> - </div> - </div> + <div class="cptm-modal-wrap"> + <div class="cptm-modal"> + <div class="cptm-modal-content"> + <div class="cptm-modal-header"> + <h3 class="cptm-modal-header-title"><?php esc_html_e( 'Delete Derectory', 'directorist' ); ?></h3> + <div class="cptm-modal-actions"> + <a href="#" class="cptm-modal-action-link cptm-modal-toggle" data-target="cptm-delete-directory-modal"> + <span class="fa fa-times"></span> + </a> + </div> + </div> - <div class="cptm-modal-body cptm-center-content cptm-content-wide"> - <form action="#" method="post" class="cptm-import-directory-form"> - <div class="cptm-form-group-feedback cptm-text-center cptm-mb-10"></div> + <div class="cptm-modal-body cptm-center-content cptm-content-wide"> + <form action="#" method="post" class="cptm-import-directory-form"> + <div class="cptm-form-group-feedback cptm-text-center cptm-mb-10"></div> - <h2 class="cptm-title-2 cptm-text-center"><?php esc_html_e( 'Are you sure?', 'directorist' ) ?></h2> + <h2 class="cptm-title-2 cptm-text-center"><?php esc_html_e( 'Are you sure?', 'directorist' ); ?></h2> - <div class="cptm-file-input-wrap"> - <a href="#" class="cptm-btn cptm-btn-secondary cptm-modal-toggle atbdp-directory-delete-cancel-link" data-target="cptm-delete-directory-modal"> - <?php esc_html_e( 'Cancel', 'directorist' ); ?> - </a> + <div class="cptm-file-input-wrap"> + <a href="#" class="cptm-btn cptm-btn-secondary cptm-modal-toggle atbdp-directory-delete-cancel-link" data-target="cptm-delete-directory-modal"> + <?php esc_html_e( 'Cancel', 'directorist' ); ?> + </a> - <a href="#" class="cptm-btn cptm-btn-danger atbdp-directory-delete-link"> - <?php esc_html_e( 'Delete', 'directorist' ); ?> - </a> - </div> - </form> - </div> - </div> - </div> - </div> + <a href="#" class="cptm-btn cptm-btn-danger atbdp-directory-delete-link"> + <?php esc_html_e( 'Delete', 'directorist' ); ?> + </a> + </div> + </form> + </div> + </div> + </div> + </div> </div> <?php -; -if ( $show_migration_button ) : ?> + +if ( $show_migration_button ) : + ?> <!-- Model : Migration --> <div class="cptm-modal-container cptm-directory-mirgation-modal"> - <div class="cptm-modal-wrap"> - <div class="cptm-modal"> - <div class="cptm-modal-content"> - <div class="cptm-modal-header"> - <h3 class="cptm-modal-header-title"><?php esc_html_e( 'Migrate', 'directorist' ); ?></h3> - <div class="cptm-modal-actions"> - <a href="#" class="cptm-modal-action-link cptm-modal-toggle" data-target="cptm-directory-mirgation-modal"> - <span class="fa fa-times"></span> - </a> - </div> - </div> + <div class="cptm-modal-wrap"> + <div class="cptm-modal"> + <div class="cptm-modal-content"> + <div class="cptm-modal-header"> + <h3 class="cptm-modal-header-title"><?php esc_html_e( 'Migrate', 'directorist' ); ?></h3> + <div class="cptm-modal-actions"> + <a href="#" class="cptm-modal-action-link cptm-modal-toggle" data-target="cptm-directory-mirgation-modal"> + <span class="fa fa-times"></span> + </a> + </div> + </div> - <div class="cptm-modal-body cptm-center-content cptm-content-wide"> - <form action="#" method="post" class="cptm-directory-migration-form"> - <div class="cptm-form-group-feedback cptm-text-center cptm-mb-10"></div> + <div class="cptm-modal-body cptm-center-content cptm-content-wide"> + <form action="#" method="post" class="cptm-directory-migration-form"> + <div class="cptm-form-group-feedback cptm-text-center cptm-mb-10"></div> - <h2 class="cptm-title-2 cptm-text-center cptm-comfirmation-text"> - <?php esc_html_e( 'Are you sure?', 'directorist' ) ?> - </h2> + <h2 class="cptm-title-2 cptm-text-center cptm-comfirmation-text"> + <?php esc_html_e( 'Are you sure?', 'directorist' ); ?> + </h2> - <div class="cptm-file-input-wrap"> - <a href="#" class="cptm-btn cptm-btn-secondery cptm-modal-toggle atbdp-directory-migration-cencel-link" data-target="cptm-directory-mirgation-modal"> - <?php esc_html_e( 'No', 'directorist' ); ?> - </a> + <div class="cptm-file-input-wrap"> + <a href="#" class="cptm-btn cptm-btn-secondery cptm-modal-toggle atbdp-directory-migration-cencel-link" data-target="cptm-directory-mirgation-modal"> + <?php esc_html_e( 'No', 'directorist' ); ?> + </a> - <a href="#" class="cptm-btn cptm-btn-primary atbdp-directory-migration-link"> - <?php esc_html_e( 'Yes', 'directorist' ); ?> - </a> - </div> - </form> - </div> - </div> - </div> - </div> + <a href="#" class="cptm-btn cptm-btn-primary atbdp-directory-migration-link"> + <?php esc_html_e( 'Yes', 'directorist' ); ?> + </a> + </div> + </form> + </div> + </div> + </div> + </div> </div> <?php endif; ?> \ No newline at end of file diff --git a/views/admin-templates/post-types-manager/edit-listing-type.php b/views/admin-templates/post-types-manager/edit-listing-type.php index 6fbe6ba539..d83daffad6 100644 --- a/views/admin-templates/post-types-manager/edit-listing-type.php +++ b/views/admin-templates/post-types-manager/edit-listing-type.php @@ -1,20 +1,21 @@ <div class="wrap"> - <?php - $builder_data = base64_encode( json_encode( $data['directory_builder_data'] ) ); + <?php + $builder_data = base64_encode( json_encode( $data['directory_builder_data'] ) ); - /** - * Fires before single directory edited header - * @since 7.2.0 - */ - do_action( 'directorist_before_directory_type_edited' ); + /** + * Fires before single directory edited header + * + * @since 7.2.0 + */ + do_action( 'directorist_before_directory_type_edited' ); - if ( isset( $_GET['action'] ) && $_GET['action'] === 'add_new' ) { - $label = __( 'Add New Directory', 'directorist' ); - } else { - $label = __( 'Edit Directory', 'directorist' ); - } - ?> - <div id="atbdp-cpt-manager" data-builder-data="<?php echo esc_attr( $builder_data ); ?>"> - <cpt-manager /> - </div> + if ( isset( $_GET['action'] ) && $_GET['action'] === 'add_new' ) { + $label = __( 'Add New Directory', 'directorist' ); + } else { + $label = __( 'Edit Directory', 'directorist' ); + } + ?> + <div id="atbdp-cpt-manager" data-builder-data="<?php echo esc_attr( $builder_data ); ?>"> + <cpt-manager /> + </div> </div> \ No newline at end of file diff --git a/views/admin-templates/settings-manager/settings.php b/views/admin-templates/settings-manager/settings.php index f8889305f4..cdc3bc6bdb 100644 --- a/views/admin-templates/settings-manager/settings.php +++ b/views/admin-templates/settings-manager/settings.php @@ -1,40 +1,41 @@ <div class="wrap"> - <?php - /** - * Fires before settings pane - * @since 7.2.0 - */ - do_action( 'directorist_before_settings_panel_header' ); - ?> - <div id="atbdp-settings-manager" class="atbdp-settings-manager" data-builder-data="<?php echo esc_attr( $data['settings_builder_data'] ); ?>"> + <?php + /** + * Fires before settings pane + * + * @since 7.2.0 + */ + do_action( 'directorist_before_settings_panel_header' ); + ?> + <div id="atbdp-settings-manager" class="atbdp-settings-manager" data-builder-data="<?php echo esc_attr( $data['settings_builder_data'] ); ?>"> - <div class="atbdp-settings-manager__top"> - <h4 class="atbdp-settings-manager__title"> - <span><?php esc_html_e( 'Settings', 'directorist' ) ?></span> - <span class="directorist_settings-trigger"> - <span></span> - <span></span> - <span></span> - </span> - </h4> + <div class="atbdp-settings-manager__top"> + <h4 class="atbdp-settings-manager__title"> + <span><?php esc_html_e( 'Settings', 'directorist' ); ?></span> + <span class="directorist_settings-trigger"> + <span></span> + <span></span> + <span></span> + </span> + </h4> - <ul class="directorist_builder-links"> - <li> - <a href="https://directorist.com/documentation/" target="_blank"> - <i class="la la-file"></i> - <span class="link-text"><?php esc_html_e( 'Documentation', 'directorist' ); ?></span> - </a> - </li> - <li> - <a href="https://directorist.com/dashboard/#support" target="_blank" class="directorist_alert-warning"> - <i class="la la-question-circle"></i> - <span class="link-text"><?php esc_html_e( 'Support', 'directorist' ); ?></span> - </a> - </li> - </ul> - </div> + <ul class="directorist_builder-links"> + <li> + <a href="https://directorist.com/documentation/" target="_blank"> + <i class="la la-file"></i> + <span class="link-text"><?php esc_html_e( 'Documentation', 'directorist' ); ?></span> + </a> + </li> + <li> + <a href="https://directorist.com/dashboard/#support" target="_blank" class="directorist_alert-warning"> + <i class="la la-question-circle"></i> + <span class="link-text"><?php esc_html_e( 'Support', 'directorist' ); ?></span> + </a> + </li> + </ul> + </div> - <span class="directorist_settings-panel-shade"></span> - <settings-manager /> - </div> + <span class="directorist_settings-panel-shade"></span> + <settings-manager /> + </div> </div> \ No newline at end of file diff --git a/views/admin-templates/theme-extensions/all-themes-extensions.php b/views/admin-templates/theme-extensions/all-themes-extensions.php index 0a64b46a94..f3ec4dd259 100644 --- a/views/admin-templates/theme-extensions/all-themes-extensions.php +++ b/views/admin-templates/theme-extensions/all-themes-extensions.php @@ -1,52 +1,54 @@ <br> <!-- Themes and Extensions --> <div class="extension-theme-wrapper"> - <?php - if ( ! empty( $args['ATBDP_Extensions']->extensions ) ) : ?> - <div class="et-column"> - <h3><?php esc_html_e( 'Extensions', 'directorist' ) ?></h3> + <?php + if ( ! empty( $args['ATBDP_Extensions']->extensions ) ) : ?> + <div class="et-column"> + <h3><?php esc_html_e( 'Extensions', 'directorist' ); ?></h3> - <?php foreach( $args['ATBDP_Extensions']->extensions as $extension_key => $extension ) : - $link = ATBDP_Upgrade::promo_link( $extension['link'] ); - ?> - <div class="et-card"> - <div class="et-card__image"> - <img src="<?php echo esc_url( $extension['thumbnail'] ); ?>" alt=""> - </div><!-- ends: .et-card__image --> - <div class="et-card__details"> - <h3><?php echo esc_html( $extension['name'] ); ?></h3> - <p><?php echo esc_html( $extension['description'] ); ?></p> - <ul> - <li><a href="<?php echo esc_url( $link ); ?>" class="et-card__btn et-card__btn--primary"><?php esc_html_e( 'View Details', 'directorist' ); ?></a></li> - <li><a href="<?php echo esc_url( $link ); ?>" class="et-card__btn et-card__btn--secondary"><?php esc_html_e( 'Get It Now', 'directorist' ); ?></a></li> - </ul> - </div> - </div><!-- ends: .et-card --> - <?php endforeach; ?> - </div><!-- ends: .et-column --> - <?php endif; ?> - - <?php if ( ! empty( $args['ATBDP_Extensions']->themes ) ) : ?> - <div class="et-column"> - <h3><?php esc_html_e( 'Themes', 'directorist' ) ?></h3> + <?php + foreach ( $args['ATBDP_Extensions']->extensions as $extension_key => $extension ) : + $link = ATBDP_Upgrade::promo_link( $extension['link'] ); + ?> + <div class="et-card"> + <div class="et-card__image"> + <img src="<?php echo esc_url( $extension['thumbnail'] ); ?>" alt=""> + </div><!-- ends: .et-card__image --> + <div class="et-card__details"> + <h3><?php echo esc_html( $extension['name'] ); ?></h3> + <p><?php echo esc_html( $extension['description'] ); ?></p> + <ul> + <li><a href="<?php echo esc_url( $link ); ?>" class="et-card__btn et-card__btn--primary"><?php esc_html_e( 'View Details', 'directorist' ); ?></a></li> + <li><a href="<?php echo esc_url( $link ); ?>" class="et-card__btn et-card__btn--secondary"><?php esc_html_e( 'Get It Now', 'directorist' ); ?></a></li> + </ul> + </div> + </div><!-- ends: .et-card --> + <?php endforeach; ?> + </div><!-- ends: .et-column --> + <?php endif; ?> + + <?php if ( ! empty( $args['ATBDP_Extensions']->themes ) ) : ?> + <div class="et-column"> + <h3><?php esc_html_e( 'Themes', 'directorist' ); ?></h3> - <?php foreach( $args['ATBDP_Extensions']->themes as $theme_key => $theme ) : - $link = ATBDP_Upgrade::promo_link( $theme['link'] ); - ?> - <div class="et-card"> - <div class="et-card__image"> - <img src="<?php echo esc_url( $theme['thumbnail'] ); ?>" alt=""> - </div><!-- ends: .et-card__image --> - <div class="et-card__details"> - <h3><?php echo esc_html( $theme['name'] ); ?></h3> - <p><?php echo esc_html( $theme['description'] ); ?></p> - <ul> - <li><a href="<?php echo esc_url( $link ); ?>" class="et-card__btn et-card__btn--primary"><?php esc_html_e( 'View Details', 'directorist' ) ?></a></li> - <li><a href="<?php echo esc_url( $link ); ?>" class="et-card__btn et-card__btn--secondary"><?php esc_html_e( 'Get It Now', 'directorist' ) ?></a></li> - </ul> - </div> - </div><!-- ends: .et-card --> - <?php endforeach; ?> - </div><!-- ends: .et-column --> - <?php endif; ?> + <?php + foreach ( $args['ATBDP_Extensions']->themes as $theme_key => $theme ) : + $link = ATBDP_Upgrade::promo_link( $theme['link'] ); + ?> + <div class="et-card"> + <div class="et-card__image"> + <img src="<?php echo esc_url( $theme['thumbnail'] ); ?>" alt=""> + </div><!-- ends: .et-card__image --> + <div class="et-card__details"> + <h3><?php echo esc_html( $theme['name'] ); ?></h3> + <p><?php echo esc_html( $theme['description'] ); ?></p> + <ul> + <li><a href="<?php echo esc_url( $link ); ?>" class="et-card__btn et-card__btn--primary"><?php esc_html_e( 'View Details', 'directorist' ); ?></a></li> + <li><a href="<?php echo esc_url( $link ); ?>" class="et-card__btn et-card__btn--secondary"><?php esc_html_e( 'Get It Now', 'directorist' ); ?></a></li> + </ul> + </div> + </div><!-- ends: .et-card --> + <?php endforeach; ?> + </div><!-- ends: .et-column --> + <?php endif; ?> </div><!-- ends: .theme-extension-wrapper --> \ No newline at end of file diff --git a/views/admin-templates/theme-extensions/my-themes-extensions/extensions-tab.php b/views/admin-templates/theme-extensions/my-themes-extensions/extensions-tab.php index 83c8aab37e..ac8a4ca1b7 100644 --- a/views/admin-templates/theme-extensions/my-themes-extensions/extensions-tab.php +++ b/views/admin-templates/theme-extensions/my-themes-extensions/extensions-tab.php @@ -1,287 +1,287 @@ -<?php $outdated_plugins_key = array_keys($args['outdated_plugin_list']); ?> +<?php $outdated_plugins_key = array_keys( $args['outdated_plugin_list'] ); ?> <div id="atbdp-extensions-tab" class="ext-wrapper et-contents__tab-item atbdp-tab__content active"> - <div class="ext-installed"> - <h4>Installed</h4> - <div class="ext-installed-table"> - <?php if ( ! empty( $args['installed_extension_list'] ) ) : ?> - <div class="ext-table-responsive"> - <form id="atbdp-my-extensions-form" class="atbdp-my-extensions-form" method="post"> - <table> - <thead> - <tr> - <th colspan="4"> - <div class="ei-action-wrapper"> - <div class="ei-select-all"> - <div class="directorist-checkbox directorist-checkbox-success"> - <input type="checkbox" name="select-all-installed" id="select-all-installed"> - <label class="directorist-checkbox__label" for="select-all-installed" ></label> - </div> - </div> - <div class="ei-action-dropdown"> - <select id="bulk-actions" name="bulk-actions"> - <option value="">Bulk Action</option> - <option value="activate">Activate</option> - <option value="deactivate">Deactivate</option> - </select> - </div> - <button type="submit" class="ei-action-btn">Apply</button> - </div> - </th> - </tr> - </thead> - <tbody> - <?php foreach ($args['installed_extension_list'] as $extension_base => $extension) : ?> - <tr> - <td> - <div class="extension-name"> - <div class="directorist-checkbox directorist-checkbox-success"> - <input type="checkbox" id="<?php echo esc_attr( $extension_base ); ?>" name="<?php echo esc_attr( $extension_base ); ?>" class="extension-name-checkbox"> - <label class="directorist-checkbox__label" for="<?php echo esc_attr( $extension_base ); ?>"> - <?php + <div class="ext-installed"> + <h4>Installed</h4> + <div class="ext-installed-table"> + <?php if ( ! empty( $args['installed_extension_list'] ) ) : ?> + <div class="ext-table-responsive"> + <form id="atbdp-my-extensions-form" class="atbdp-my-extensions-form" method="post"> + <table> + <thead> + <tr> + <th colspan="4"> + <div class="ei-action-wrapper"> + <div class="ei-select-all"> + <div class="directorist-checkbox directorist-checkbox-success"> + <input type="checkbox" name="select-all-installed" id="select-all-installed"> + <label class="directorist-checkbox__label" for="select-all-installed" ></label> + </div> + </div> + <div class="ei-action-dropdown"> + <select id="bulk-actions" name="bulk-actions"> + <option value="">Bulk Action</option> + <option value="activate">Activate</option> + <option value="deactivate">Deactivate</option> + </select> + </div> + <button type="submit" class="ei-action-btn">Apply</button> + </div> + </th> + </tr> + </thead> + <tbody> + <?php foreach ( $args['installed_extension_list'] as $extension_base => $extension ) : ?> + <tr> + <td> + <div class="extension-name"> + <div class="directorist-checkbox directorist-checkbox-success"> + <input type="checkbox" id="<?php echo esc_attr( $extension_base ); ?>" name="<?php echo esc_attr( $extension_base ); ?>" class="extension-name-checkbox"> + <label class="directorist-checkbox__label" for="<?php echo esc_attr( $extension_base ); ?>"> + <?php - $ext_key = preg_replace( '/\/.+/', '', $extension_base ); - $ext_key_alias = $args['ATBDP_Extensions']->get_extension_alias_key( $ext_key );; - $img = 'https://via.placeholder.com/44' ; + $ext_key = preg_replace( '/\/.+/', '', $extension_base ); + $ext_key_alias = $args['ATBDP_Extensions']->get_extension_alias_key( $ext_key ); + $img = 'https://via.placeholder.com/44'; - if ( ! empty( $args[ 'extension_list' ][ $ext_key ] ) ) { - $img = $args['extension_list'][$ext_key]['thumbnail']; - } else if ( ! empty( $args[ 'extension_list' ][ $ext_key_alias ] ) ) { - $img = $args['extension_list'][$ext_key_alias]['thumbnail']; - } - ?> - <img src="<?php echo esc_url( $img ); ?>" alt="" width="44" height="44"> - <span class="ext-text"> - <?php echo esc_html( $extension['Name'] ); ?> - <span class="ext-version">v<?php echo esc_html( $extension['Version'] ); ?></span> - </span> - </label> - </div> - </div> - </td> + if ( ! empty( $args['extension_list'][ $ext_key ] ) ) { + $img = $args['extension_list'][ $ext_key ]['thumbnail']; + } elseif ( ! empty( $args['extension_list'][ $ext_key_alias ] ) ) { + $img = $args['extension_list'][ $ext_key_alias ]['thumbnail']; + } + ?> + <img src="<?php echo esc_url( $img ); ?>" alt="" width="44" height="44"> + <span class="ext-text"> + <?php echo esc_html( $extension['Name'] ); ?> + <span class="ext-version">v<?php echo esc_html( $extension['Version'] ); ?></span> + </span> + </label> + </div> + </div> + </td> - <td class="directorist_status-badge"> - <?php if (is_plugin_active($extension_base)) : ?> - <span class="active-badge">Active</span> - <?php endif; ?> - </td> + <td class="directorist_status-badge"> + <?php if ( is_plugin_active( $extension_base ) ) : ?> + <span class="active-badge">Active</span> + <?php endif; ?> + </td> - <td class="directorist_ext-update"> - <?php if (in_array($extension_base, $outdated_plugins_key)) : ?> - <p class="ext-update-info">Update available <!-- <span>What's new?</span></p> --> - <?php else : ?> - <p class="atbdp-text-muted atbdp-mb-0">Up to date</p> - <?php endif; ?> - </td> + <td class="directorist_ext-update"> + <?php if ( in_array( $extension_base, $outdated_plugins_key ) ) : ?> + <p class="ext-update-info">Update available <!-- <span>What's new?</span></p> --> + <?php else : ?> + <p class="atbdp-text-muted atbdp-mb-0">Up to date</p> + <?php endif; ?> + </td> - <td> - <div class="ext-action"> - <?php if (in_array($extension_base, $outdated_plugins_key)) : ?> - <a href="#" class="ext-update-btn ext-action-btn" data-key="<?php echo esc_attr( $extension_base ); ?>"><?php echo $args['is_beta'] ? 'Update Beta' : 'Update'; ?></a> - <?php endif; ?> - <a href="<?php echo esc_url( $args['settings_url'] ); ?>" class="ext-action-btn"><i class="la la-settings"></i> Settings</a> - <div> - <a href="" class="ext-action-drop"><i class="uil uil-ellipsis-h"></i></a> - <div class="ext-action-drop__item"> - <a href="#" class="ext-action-link ext-action-uninstall" data-target="<?php echo esc_attr( $extension_base ); ?>">Uninstall</a> - </div> - </div> - </div> - </td> - </tr> - <?php endforeach; ?> - </tbody> - </table> - </form> - </div> - <?php else : ?> - <p class="atbdp-text-center"><?php esc_html_e('No extension found') ?></p> - <?php endif; ?> - </div> - </div><!-- ends: .ext-installed --> + <td> + <div class="ext-action"> + <?php if ( in_array( $extension_base, $outdated_plugins_key ) ) : ?> + <a href="#" class="ext-update-btn ext-action-btn" data-key="<?php echo esc_attr( $extension_base ); ?>"><?php echo $args['is_beta'] ? 'Update Beta' : 'Update'; ?></a> + <?php endif; ?> + <a href="<?php echo esc_url( $args['settings_url'] ); ?>" class="ext-action-btn"><i class="la la-settings"></i> Settings</a> + <div> + <a href="" class="ext-action-drop"><i class="uil uil-ellipsis-h"></i></a> + <div class="ext-action-drop__item"> + <a href="#" class="ext-action-link ext-action-uninstall" data-target="<?php echo esc_attr( $extension_base ); ?>">Uninstall</a> + </div> + </div> + </div> + </td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + </form> + </div> + <?php else : ?> + <p class="atbdp-text-center"><?php esc_html_e( 'No extension found' ); ?></p> + <?php endif; ?> + </div> + </div><!-- ends: .ext-installed --> - <?php if (!empty($args['extensions_available_in_subscriptions'])) : ?> - <div class="ext-available"> - <h4><?php esc_html_e('Available in your subscription (' . count( array_keys( $args['extensions_available_in_subscriptions'] ) ) .')', 'directorist') ?></h4> - <div class="ext-available-table"> - <div class="ext-table-responsive"> - <form id="atbdp-my-subscribed-extensions-form" class="atbdp-my-subscribed-extensions-form" method="post"> - <table> - <thead> - <tr> - <th colspan="4"> - <div class="ei-action-wrapper"> - <div class="ei-select-all"> - <div class="directorist-checkbox directorist-checkbox-success"> - <input type="checkbox" name="select-all-subscription" id="select-all-subscription"> - <label class="directorist-checkbox__label" for="select-all-subscription"></label> - </div> - </div> - <div class="ei-action-dropdown"> - <select id="bulk-actions" name="bulk-actions"> - <option value="">Bulk Action</option> - <option value="activate"><?php echo $args['is_beta'] ? 'Install Beta' : 'Install'; ?></option> - </select> - </div> - <button type="submit" class="ei-action-btn">Apply</button> - </div> - </th> - </tr> - </thead> - <tbody> - <?php foreach ($args['extensions_available_in_subscriptions'] as $extension_base => $extension) : ?> - <?php $extension_base_alias = $args['ATBDP_Extensions']->get_extension_alias_key( $extension_base ); ?> - <tr> - <td> - <div class="extension-name"> - <div class="directorist-checkbox directorist-checkbox-success"> - <input type="checkbox" id="<?php echo esc_attr( $extension_base ); ?>" name="<?php echo esc_attr( $extension_base ); ?>" class="extension-name-checkbox"> - <label class="directorist-checkbox__label" for="<?php echo esc_attr( $extension_base ); ?>"> - <?php - $img = ! empty( $extension['thumbnail'] ) ? $extension['thumbnail'] : DIRECTORIST_ASSETS . 'images/no-image.png'; - ?> - <img src="<?php echo esc_url( $img ); ?>" width="44" height="44" alt=""><?php echo esc_html( $extension['title'] ) ?> - </label> - </div> - </div> - </td> + <?php if ( ! empty( $args['extensions_available_in_subscriptions'] ) ) : ?> + <div class="ext-available"> + <h4><?php esc_html_e( 'Available in your subscription (' . count( array_keys( $args['extensions_available_in_subscriptions'] ) ) . ')', 'directorist' ); ?></h4> + <div class="ext-available-table"> + <div class="ext-table-responsive"> + <form id="atbdp-my-subscribed-extensions-form" class="atbdp-my-subscribed-extensions-form" method="post"> + <table> + <thead> + <tr> + <th colspan="4"> + <div class="ei-action-wrapper"> + <div class="ei-select-all"> + <div class="directorist-checkbox directorist-checkbox-success"> + <input type="checkbox" name="select-all-subscription" id="select-all-subscription"> + <label class="directorist-checkbox__label" for="select-all-subscription"></label> + </div> + </div> + <div class="ei-action-dropdown"> + <select id="bulk-actions" name="bulk-actions"> + <option value="">Bulk Action</option> + <option value="activate"><?php echo $args['is_beta'] ? 'Install Beta' : 'Install'; ?></option> + </select> + </div> + <button type="submit" class="ei-action-btn">Apply</button> + </div> + </th> + </tr> + </thead> + <tbody> + <?php foreach ( $args['extensions_available_in_subscriptions'] as $extension_base => $extension ) : ?> + <?php $extension_base_alias = $args['ATBDP_Extensions']->get_extension_alias_key( $extension_base ); ?> + <tr> + <td> + <div class="extension-name"> + <div class="directorist-checkbox directorist-checkbox-success"> + <input type="checkbox" id="<?php echo esc_attr( $extension_base ); ?>" name="<?php echo esc_attr( $extension_base ); ?>" class="extension-name-checkbox"> + <label class="directorist-checkbox__label" for="<?php echo esc_attr( $extension_base ); ?>"> + <?php + $img = ! empty( $extension['thumbnail'] ) ? $extension['thumbnail'] : DIRECTORIST_ASSETS . 'images/no-image.png'; + ?> + <img src="<?php echo esc_url( $img ); ?>" width="44" height="44" alt=""><?php echo esc_html( $extension['title'] ); ?> + </label> + </div> + </div> + </td> - <td> - <span class="ext-info"> - <?php - if (!empty($args['extension_list'][$extension_base])) { - esc_html_e($args['extension_list'][$extension_base]['description'], 'directorust'); - } else if (!empty($args['extension_list'][$extension_base_alias])) { - esc_html_e($args['extension_list'][$extension_base_alias]['description'], 'directorust'); - } - ?> - </span> - </td> - <td> - <div class="ext-action ext-action-<?php echo esc_attr( $extension_base ); ?>"> - <a href="#" class="file-install-btn ext-action-btn" data-type="plugin" data-key="<?php echo esc_attr( $extension_base ); ?>"> - <i class="la la-download"></i> <?php echo $args['is_beta'] ? 'Install Beta' : 'Install'; ?> - </a> - </div> - </td> - </tr> - <?php endforeach; ?> - </tbody> - </table> - </form> - </div> - </div> - </div><!-- ends: .ext-available --> - <?php endif; ?> + <td> + <span class="ext-info"> + <?php + if ( ! empty( $args['extension_list'][ $extension_base ] ) ) { + esc_html_e( $args['extension_list'][ $extension_base ]['description'], 'directorust' ); + } elseif ( ! empty( $args['extension_list'][ $extension_base_alias ] ) ) { + esc_html_e( $args['extension_list'][ $extension_base_alias ]['description'], 'directorust' ); + } + ?> + </span> + </td> + <td> + <div class="ext-action ext-action-<?php echo esc_attr( $extension_base ); ?>"> + <a href="#" class="file-install-btn ext-action-btn" data-type="plugin" data-key="<?php echo esc_attr( $extension_base ); ?>"> + <i class="la la-download"></i> <?php echo $args['is_beta'] ? 'Install Beta' : 'Install'; ?> + </a> + </div> + </td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + </form> + </div> + </div> + </div><!-- ends: .ext-available --> + <?php endif; ?> - <?php if (!empty($args['required_extensions_list'])) : ?> - <div class="ext-available"> - <h4 class="req-ext-title"><?php esc_html_e('Required Extensions (' . count( array_keys( $args['required_extensions_list'] ) ) .')', 'directorist') ?></h4> - <div class="ext-available-table"> - <div class="ext-table-responsive"> - <form id="atbdp-required-extensions-form" class="atbdp-my-required-extensions-form" method="post"> - <table> - <thead> - <tr> - <th colspan="4"> - <div class="ei-action-wrapper"> - <div class="ei-select-all"> - <div class="directorist-checkbox directorist-checkbox-success"> - <input type="checkbox" name="select-all" id="select-all-required-extensions"> - <label class="directorist-checkbox__label" for="select-all-required-extensions"></label> - </div> - </div> - <div class="ei-action-dropdown"> - <select name="bulk-actions"> - <option value="">Bulk Action</option> - <option value="install">Install</option> - <option value="activate">Activate</option> - </select> - </div> - <button type="submit" class="ei-action-btn">Apply</button> - </div> - </th> - </tr> - </thead> - <tbody> - <?php foreach ( $args['required_extensions_list'] as $extension_base => $extension) : ?> - <?php $extension_base_alias = $args['ATBDP_Extensions']->get_extension_alias_key( $extension_base ); ?> - <tr> - <td> - <div class="extension-name"> - <div class="directorist-checkbox directorist-checkbox-success"> - <?php if ( $extension[ 'installed' ] ) : ?> - <input type="checkbox" id="<?php echo 'required_' . esc_attr( $extension_base ); ?>" name="<?php echo esc_attr( $extension_base ); ?>" value="<?php echo esc_attr( $extension[ 'base'] ); ?>" class="extension-name-checkbox extension-activate-checkbox"> - <?php elseif ( $extension[ 'purchased' ] ) : ?> - <input type="checkbox" id="<?php echo 'required_' . esc_attr( $extension_base ); ?>" name="<?php echo esc_attr( $extension_base ); ?>" value="<?php echo esc_attr( $extension_base ); ?>" class="extension-name-checkbox extension-install-checkbox"> - <?php endif; ?> - - <label for="<?php echo 'required_' . esc_attr( $extension_base ); ?>" class="directorist-checkbox__label"> - <?php - - $ext_name = ( isset( $args['extension_list'][$extension_base] ) ) ? $args['extension_list'][$extension_base]['name'] : ''; - - if ( empty( $ext_name ) ) { - $ext_name = ( isset( $args['extension_list'][$extension_base_alias] ) ) ? $args['extension_list'][$extension_base_alias]['name'] : ''; - } - - $img = 'https://via.placeholder.com/44'; - if ( ! empty( $args['extension_list'][$extension_base] ) ) { - $img = $args['extension_list'][$extension_base]['thumbnail']; - } else if ( ! empty( $args['extension_list'][$extension_base_alias] ) ) { - $img = $args['extension_list'][$extension_base_alias]['thumbnail']; - } + <?php if ( ! empty( $args['required_extensions_list'] ) ) : ?> + <div class="ext-available"> + <h4 class="req-ext-title"><?php esc_html_e( 'Required Extensions (' . count( array_keys( $args['required_extensions_list'] ) ) . ')', 'directorist' ); ?></h4> + <div class="ext-available-table"> + <div class="ext-table-responsive"> + <form id="atbdp-required-extensions-form" class="atbdp-my-required-extensions-form" method="post"> + <table> + <thead> + <tr> + <th colspan="4"> + <div class="ei-action-wrapper"> + <div class="ei-select-all"> + <div class="directorist-checkbox directorist-checkbox-success"> + <input type="checkbox" name="select-all" id="select-all-required-extensions"> + <label class="directorist-checkbox__label" for="select-all-required-extensions"></label> + </div> + </div> + <div class="ei-action-dropdown"> + <select name="bulk-actions"> + <option value="">Bulk Action</option> + <option value="install">Install</option> + <option value="activate">Activate</option> + </select> + </div> + <button type="submit" class="ei-action-btn">Apply</button> + </div> + </th> + </tr> + </thead> + <tbody> + <?php foreach ( $args['required_extensions_list'] as $extension_base => $extension ) : ?> + <?php $extension_base_alias = $args['ATBDP_Extensions']->get_extension_alias_key( $extension_base ); ?> + <tr> + <td> + <div class="extension-name"> + <div class="directorist-checkbox directorist-checkbox-success"> + <?php if ( $extension['installed'] ) : ?> + <input type="checkbox" id="<?php echo 'required_' . esc_attr( $extension_base ); ?>" name="<?php echo esc_attr( $extension_base ); ?>" value="<?php echo esc_attr( $extension['base'] ); ?>" class="extension-name-checkbox extension-activate-checkbox"> + <?php elseif ( $extension['purchased'] ) : ?> + <input type="checkbox" id="<?php echo 'required_' . esc_attr( $extension_base ); ?>" name="<?php echo esc_attr( $extension_base ); ?>" value="<?php echo esc_attr( $extension_base ); ?>" class="extension-name-checkbox extension-install-checkbox"> + <?php endif; ?> + + <label for="<?php echo 'required_' . esc_attr( $extension_base ); ?>" class="directorist-checkbox__label"> + <?php - echo "<img src='". esc_url( $img ) . "' width='44' height='44' alt=''>"; - echo esc_html( $ext_name ); - ?> - </label> - </div> - </div> - </td> + $ext_name = ( isset( $args['extension_list'][ $extension_base ] ) ) ? $args['extension_list'][ $extension_base ]['name'] : ''; - <td> - <span class="ext-info"> - <?php - if ( ! empty($args['extension_list'][$extension_base])) { - esc_html_e($args['extension_list'][$extension_base]['description'], 'directorust'); - } - else if ( ! empty($args['extension_list'][$extension_base_alias])) { - esc_html_e($args['extension_list'][$extension_base_alias]['description'], 'directorust'); - } - ?> - </span> - </td> - <td> - <div class="ext-action ext-action-<?php echo esc_attr( $extension_base ); ?>"> - <?php if ( $extension[ 'installed' ] ) : ?> - <a href="#" class="plugin-active-btn ext-action-btn" data-type="plugin" data-key="<?php echo esc_attr( $extension[ 'base' ] ); ?>"> - <?php esc_html_e('Activate', 'directorist') ?> - </a> - <?php elseif ( $extension[ 'purchased' ] ) : ?> - <a href="#" class="file-install-btn ext-action-btn" data-type="plugin" data-key="<?php echo esc_attr( $extension_base ); ?>"> - <?php echo $args['is_beta'] ? 'Install Beta' : 'Install'; ?> - </a> - <?php else: - $download_link = ( ! empty( $args['extension_list'][$extension_base] ) ) ? $args['extension_list'][$extension_base]['link'] : ''; - - if ( empty( $download_link ) ) { - $download_link = ( ! empty( $args['extension_list'][$extension_base_alias] ) ) ? $args['extension_list'][$extension_base_alias]['link'] : ''; - } - ?> - <a href="<?php echo esc_url( $download_link ); ?>" class="ext-action-btn" target="_blank"> - <i class="la la-download"></i> <?php esc_html_e('Get Now', 'directorist') ?> - </a> - <?php endif; ?> - </div> - </td> - </tr> - <?php endforeach; ?> - </tbody> - </table> - </form> - </div> - </div> - </div><!-- ends: .ext-available --> - <?php endif; ?> + if ( empty( $ext_name ) ) { + $ext_name = ( isset( $args['extension_list'][ $extension_base_alias ] ) ) ? $args['extension_list'][ $extension_base_alias ]['name'] : ''; + } + + $img = 'https://via.placeholder.com/44'; + if ( ! empty( $args['extension_list'][ $extension_base ] ) ) { + $img = $args['extension_list'][ $extension_base ]['thumbnail']; + } elseif ( ! empty( $args['extension_list'][ $extension_base_alias ] ) ) { + $img = $args['extension_list'][ $extension_base_alias ]['thumbnail']; + } + + echo "<img src='" . esc_url( $img ) . "' width='44' height='44' alt=''>"; + echo esc_html( $ext_name ); + ?> + </label> + </div> + </div> + </td> + + <td> + <span class="ext-info"> + <?php + if ( ! empty( $args['extension_list'][ $extension_base ] ) ) { + esc_html_e( $args['extension_list'][ $extension_base ]['description'], 'directorust' ); + } elseif ( ! empty( $args['extension_list'][ $extension_base_alias ] ) ) { + esc_html_e( $args['extension_list'][ $extension_base_alias ]['description'], 'directorust' ); + } + ?> + </span> + </td> + <td> + <div class="ext-action ext-action-<?php echo esc_attr( $extension_base ); ?>"> + <?php if ( $extension['installed'] ) : ?> + <a href="#" class="plugin-active-btn ext-action-btn" data-type="plugin" data-key="<?php echo esc_attr( $extension['base'] ); ?>"> + <?php esc_html_e( 'Activate', 'directorist' ); ?> + </a> + <?php elseif ( $extension['purchased'] ) : ?> + <a href="#" class="file-install-btn ext-action-btn" data-type="plugin" data-key="<?php echo esc_attr( $extension_base ); ?>"> + <?php echo $args['is_beta'] ? 'Install Beta' : 'Install'; ?> + </a> + <?php + else : + $download_link = ( ! empty( $args['extension_list'][ $extension_base ] ) ) ? $args['extension_list'][ $extension_base ]['link'] : ''; + + if ( empty( $download_link ) ) { + $download_link = ( ! empty( $args['extension_list'][ $extension_base_alias ] ) ) ? $args['extension_list'][ $extension_base_alias ]['link'] : ''; + } + ?> + <a href="<?php echo esc_url( $download_link ); ?>" class="ext-action-btn" target="_blank"> + <i class="la la-download"></i> <?php esc_html_e( 'Get Now', 'directorist' ); ?> + </a> + <?php endif; ?> + </div> + </td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + </form> + </div> + </div> + </div><!-- ends: .ext-available --> + <?php endif; ?> </div><!-- ends: .ext-wrapper --> \ No newline at end of file diff --git a/views/admin-templates/theme-extensions/my-themes-extensions/my-themes-extensions.php b/views/admin-templates/theme-extensions/my-themes-extensions/my-themes-extensions.php index 4962a6ae0d..059e67704b 100644 --- a/views/admin-templates/theme-extensions/my-themes-extensions/my-themes-extensions.php +++ b/views/admin-templates/theme-extensions/my-themes-extensions/my-themes-extensions.php @@ -1,73 +1,73 @@ <div class="et-wrapper"> - <div class="et-wrapper-head"> - <div class="et-header-title-area"> - <h3>My Themes and Extensions</h3> + <div class="et-wrapper-head"> + <div class="et-header-title-area"> + <h3>My Themes and Extensions</h3> - <div class="et-header-actions"> - <div class="et-auth-section atbdp-hide"> - <form id="purchase-refresh-form" action="#" method="post"> - <div class="et-auth-section-wrap"> - <div class="atbdp-input-group atbdp-input-group-append"> - <div class="atbdp-input-group-wrap"> - <input type="password" class="atbdp-form-control" placeholder="Confirm Password" id="password" name="password"> - <button type="submit" class="atbdp-btn atbdp-btn-primary"> - <i class="fas fa-arrow-right"></i> - </button> - </div> + <div class="et-header-actions"> + <div class="et-auth-section atbdp-hide"> + <form id="purchase-refresh-form" action="#" method="post"> + <div class="et-auth-section-wrap"> + <div class="atbdp-input-group atbdp-input-group-append"> + <div class="atbdp-input-group-wrap"> + <input type="password" class="atbdp-form-control" placeholder="Confirm Password" id="password" name="password"> + <button type="submit" class="atbdp-btn atbdp-btn-primary"> + <i class="fas fa-arrow-right"></i> + </button> + </div> - <div class="atbdp-form-feedback"></div> - </div> - + <div class="atbdp-form-feedback"></div> + </div> + - <div class="atbdp-action-group"> - <button class="atbdp-btn atbdp-btn-danger atbdp-mx-5 et-close-auth-btn"> - <i class="fas fa-times"></i> - </button> - </div> - </div> - </form> - </div> + <div class="atbdp-action-group"> + <button class="atbdp-btn atbdp-btn-danger atbdp-mx-5 et-close-auth-btn"> + <i class="fas fa-times"></i> + </button> + </div> + </div> + </form> + </div> - <div class="atbdp-action-group"> - <div class="atbdp-btn-wrapper purchase-refresh-btn-wrapper"> - <a href="#" class="ext-action-btn purchase-refresh-btn atbdp-show"> - <i class="la la-refresh"></i> <?php esc_html_e('Refresh Purchase', 'directorist') ?> - </a> - </div> + <div class="atbdp-action-group"> + <div class="atbdp-btn-wrapper purchase-refresh-btn-wrapper"> + <a href="#" class="ext-action-btn purchase-refresh-btn atbdp-show"> + <i class="la la-refresh"></i> <?php esc_html_e( 'Refresh Purchase', 'directorist' ); ?> + </a> + </div> - <div class="atbdp-btn-wrapper"> - <a href="#" class="ext-action-btn subscriptions-logout-btn" data-hard-logout="<?php echo esc_attr( $args['hard_logout'] ); ?>"> - <i class="fas fa-sign-out-alt"></i> <?php esc_html_e('Logout', 'directorist') ?> - </a> - </div> - </div> - </div> - </div> + <div class="atbdp-btn-wrapper"> + <a href="#" class="ext-action-btn subscriptions-logout-btn" data-hard-logout="<?php echo esc_attr( $args['hard_logout'] ); ?>"> + <i class="fas fa-sign-out-alt"></i> <?php esc_html_e( 'Logout', 'directorist' ); ?> + </a> + </div> + </div> + </div> + </div> - <!-- <div class="et-search"> - <input type="text" placeholder="Search extensions and themes"> - <span class="la la-search"></span> - </div> --> - </div><!-- ends: .et-wrapper-head --> - <div class="et-contents"> - <ul class="et-contents__tab-nav"> - <li class="et-contents__tab-nav-item atbdp-tab__nav-item active"> - <a href="#" class="atbdp-tab__nav-link" data-parent="#atbdp-themes-extensions-contents" data-target="#atbdp-extensions-tab"> - Extensions - </a> - </li> + <!-- <div class="et-search"> + <input type="text" placeholder="Search extensions and themes"> + <span class="la la-search"></span> + </div> --> + </div><!-- ends: .et-wrapper-head --> + <div class="et-contents"> + <ul class="et-contents__tab-nav"> + <li class="et-contents__tab-nav-item atbdp-tab__nav-item active"> + <a href="#" class="atbdp-tab__nav-link" data-parent="#atbdp-themes-extensions-contents" data-target="#atbdp-extensions-tab"> + Extensions + </a> + </li> - <li class="et-contents__tab-nav-item atbdp-tab__nav-item"> - <a href="#" class="atbdp-tab__nav-link" data-parent="#atbdp-themes-extensions-contents" data-target="#atbdp-themes-tab"> - Themes - </a> - </li> - </ul> + <li class="et-contents__tab-nav-item atbdp-tab__nav-item"> + <a href="#" class="atbdp-tab__nav-link" data-parent="#atbdp-themes-extensions-contents" data-target="#atbdp-themes-tab"> + Themes + </a> + </li> + </ul> - <div id="atbdp-themes-extensions-contents" class="et-contents__tab-contents atbdp-tab__contents"> - <?php ATBDP()->load_template('admin-templates/theme-extensions/my-themes-extensions/extensions-tab', $args); ?> - <?php ATBDP()->load_template('admin-templates/theme-extensions/my-themes-extensions/themes-tab', $args); ?> - </div> - </div><!-- ends: .et-contents --> + <div id="atbdp-themes-extensions-contents" class="et-contents__tab-contents atbdp-tab__contents"> + <?php ATBDP()->load_template( 'admin-templates/theme-extensions/my-themes-extensions/extensions-tab', $args ); ?> + <?php ATBDP()->load_template( 'admin-templates/theme-extensions/my-themes-extensions/themes-tab', $args ); ?> + </div> + </div><!-- ends: .et-contents --> </div><!-- ends: .et-wrapper --> \ No newline at end of file diff --git a/views/admin-templates/theme-extensions/my-themes-extensions/themes-tab.php b/views/admin-templates/theme-extensions/my-themes-extensions/themes-tab.php index 68b19de078..c18e5de64c 100644 --- a/views/admin-templates/theme-extensions/my-themes-extensions/themes-tab.php +++ b/views/admin-templates/theme-extensions/my-themes-extensions/themes-tab.php @@ -1,126 +1,127 @@ <div id="atbdp-themes-tab" class="ext-wrapper et-contents__tab-item atbdp-tab__content"> - <h4><?php esc_html_e( 'Active Theme', 'directorist' )?></h4> - <div class="theme-card-wrapper"> - <div class="theme-card"> - <figure> - <?php - if ( ! empty( $args['current_active_theme_info']['thumbnail'] ) ): ?> - <img src="<?php echo esc_url( $args['current_active_theme_info']['thumbnail'] ); ?>" alt=""> - <?php endif;?> + <h4><?php esc_html_e( 'Active Theme', 'directorist' ); ?></h4> + <div class="theme-card-wrapper"> + <div class="theme-card"> + <figure> + <?php + if ( ! empty( $args['current_active_theme_info']['thumbnail'] ) ) : + ?> + <img src="<?php echo esc_url( $args['current_active_theme_info']['thumbnail'] ); ?>" alt=""> + <?php endif; ?> - <figcaption> - <div class="theme-title"> - <h5><?php echo esc_html( $args['current_active_theme_info']['name'] ); ?></h5> - <span class="theme-version">v<?php echo esc_html( $args['current_active_theme_info']['version'] ); ?></span> - </div> - <div class="theme-action"> - <a href="<?php echo esc_url( $args['current_active_theme_info']['customizer_link'] ); ?>" target="_blank" class="theme-action-btn btn-customize"><?php esc_html_e( 'Customize', 'directorist' )?></a> - </div> - </figcaption> - </figure> + <figcaption> + <div class="theme-title"> + <h5><?php echo esc_html( $args['current_active_theme_info']['name'] ); ?></h5> + <span class="theme-version">v<?php echo esc_html( $args['current_active_theme_info']['version'] ); ?></span> + </div> + <div class="theme-action"> + <a href="<?php echo esc_url( $args['current_active_theme_info']['customizer_link'] ); ?>" target="_blank" class="theme-action-btn btn-customize"><?php esc_html_e( 'Customize', 'directorist' ); ?></a> + </div> + </figcaption> + </figure> - <?php if ( $args['current_active_theme_info']['has_update'] ): ?> - <div class="theme-card__footer"> - <p class="theme-update theme-update--available"><?php esc_html_e( 'Update available', 'directorist' )?> <!-- <a hre="#" class="whats-new" data-target="whats-new-modal">What's new?</a> --></p> - <a href="#" class="theme-update-btn" data-target="<?php echo esc_attr( $args['current_active_theme_info']['stylesheet'] ); ?>"><?php echo $args['is_beta'] ? 'Update Beta' : 'Update'; ?></a> - </div> - <?php endif;?> + <?php if ( $args['current_active_theme_info']['has_update'] ) : ?> + <div class="theme-card__footer"> + <p class="theme-update theme-update--available"><?php esc_html_e( 'Update available', 'directorist' ); ?> <!-- <a hre="#" class="whats-new" data-target="whats-new-modal">What's new?</a> --></p> + <a href="#" class="theme-update-btn" data-target="<?php echo esc_attr( $args['current_active_theme_info']['stylesheet'] ); ?>"><?php echo $args['is_beta'] ? 'Update Beta' : 'Update'; ?></a> + </div> + <?php endif; ?> - <div class="at-modal atm-fade" id="whats-new-modal"> - <div class="at-modal-content at-modal-lg"> - <div class="atm-contents-inner"> - <a href="" class="at-modal-close"><span aria-hidden="true">×</span></a> - <div class="row align-items-center"> - <div class="col-lg-12"> - <div class="modal-header"> - <h3 class="modal-title" id="whats-new-modal-label">Version: <span>6.5.3</span></h3> - </div> - <div class="modal-body"> - <div class="update-list update-list--new"> - <span class="update-badge update-badge--new">New</span> - <ul class="update-list-items"> - <li>Add – Option to set custom redirection after login</li> - <li>Add – Option to set custom redirection after login</li> - <li>Add – Option to set custom redirection after login</li> - <li>Add – Option to set custom redirection after login</li> - <li>Add – Option to set custom redirection after login</li> - </ul> - </div><!-- ends: .update-list --> - <div class="update-list update-list--fixed"> - <span class="update-badge update-badge--fixd">Fixed</span> - <ul class="update-list-items"> - <li>Fixed – Option to set custom redirection after login</li> - <li>Fixed – Option to set custom redirection after login</li> - <li>Fixed – Option to set custom redirection after login</li> - </ul> - </div><!-- ends: .update-list --> - <div class="update-list update-list--improved"> - <span class="update-badge update-badge--improved">Improved</span> - <ul class="update-list-items"> - <li>Improved – Option to set custom redirection after login</li> - <li>Improved – Option to set custom redirection after login</li> - <li>Improved – Option to set custom redirection after login</li> - </ul> - </div><!-- ends: .update-list --> - <div class="update-list update-list--removed"> - <span class="update-badge update-badge--removed">Removed</span> - <ul class="update-list-items"> - <li>Removed – Option to set custom redirection after login</li> - <li>Removed – Option to set custom redirection after login</li> - <li>Removed – Option to set custom redirection after login</li> - </ul> - </div><!-- ends: .update-list --> - </div> - <div class="modal-footer"> - <button type="submit" class="btn btn-primary"><?php echo $args['is_beta'] ? 'Update Beta' : 'Update'; ?></button> - </div> - </div> - </div> + <div class="at-modal atm-fade" id="whats-new-modal"> + <div class="at-modal-content at-modal-lg"> + <div class="atm-contents-inner"> + <a href="" class="at-modal-close"><span aria-hidden="true">×</span></a> + <div class="row align-items-center"> + <div class="col-lg-12"> + <div class="modal-header"> + <h3 class="modal-title" id="whats-new-modal-label">Version: <span>6.5.3</span></h3> + </div> + <div class="modal-body"> + <div class="update-list update-list--new"> + <span class="update-badge update-badge--new">New</span> + <ul class="update-list-items"> + <li>Add – Option to set custom redirection after login</li> + <li>Add – Option to set custom redirection after login</li> + <li>Add – Option to set custom redirection after login</li> + <li>Add – Option to set custom redirection after login</li> + <li>Add – Option to set custom redirection after login</li> + </ul> + </div><!-- ends: .update-list --> + <div class="update-list update-list--fixed"> + <span class="update-badge update-badge--fixd">Fixed</span> + <ul class="update-list-items"> + <li>Fixed – Option to set custom redirection after login</li> + <li>Fixed – Option to set custom redirection after login</li> + <li>Fixed – Option to set custom redirection after login</li> + </ul> + </div><!-- ends: .update-list --> + <div class="update-list update-list--improved"> + <span class="update-badge update-badge--improved">Improved</span> + <ul class="update-list-items"> + <li>Improved – Option to set custom redirection after login</li> + <li>Improved – Option to set custom redirection after login</li> + <li>Improved – Option to set custom redirection after login</li> + </ul> + </div><!-- ends: .update-list --> + <div class="update-list update-list--removed"> + <span class="update-badge update-badge--removed">Removed</span> + <ul class="update-list-items"> + <li>Removed – Option to set custom redirection after login</li> + <li>Removed – Option to set custom redirection after login</li> + <li>Removed – Option to set custom redirection after login</li> + </ul> + </div><!-- ends: .update-list --> + </div> + <div class="modal-footer"> + <button type="submit" class="btn btn-primary"><?php echo $args['is_beta'] ? 'Update Beta' : 'Update'; ?></button> + </div> + </div> + </div> - </div> - </div> - </div> - </div> - </div> + </div> + </div> + </div> + </div> + </div> - <?php if ( ! empty( $args['themes_available_in_subscriptions'] ) ): ?> - <div class="available-themes-wrapper"> - <h4><?php esc_html_e( 'Available in your subscription', 'directorist' )?></h4> - <div class="available-themes"> - <?php foreach ( $args['themes_available_in_subscriptions'] as $_theme_base => $_theme_args ): ?> - <div class="available-theme-card"> - <figure> - <?php if ( ! empty( $_theme_args['thumbnail'] ) ): ?> - <img src="<?php echo esc_url( $_theme_args['thumbnail'] ); ?>" alt=""> - <?php endif;?> + <?php if ( ! empty( $args['themes_available_in_subscriptions'] ) ) : ?> + <div class="available-themes-wrapper"> + <h4><?php esc_html_e( 'Available in your subscription', 'directorist' ); ?></h4> + <div class="available-themes"> + <?php foreach ( $args['themes_available_in_subscriptions'] as $_theme_base => $_theme_args ) : ?> + <div class="available-theme-card"> + <figure> + <?php if ( ! empty( $_theme_args['thumbnail'] ) ) : ?> + <img src="<?php echo esc_url( $_theme_args['thumbnail'] ); ?>" alt=""> + <?php endif; ?> - <figcaption> - <h5><?php echo esc_html( $_theme_args['name'] ); ?></h5> - <div class="theme-action"> - <?php if ( $_theme_args['is_installed'] ): ?> -<?php if ( ! empty( $_theme_args['stylesheet'] ) ): ?> - <a href="#" data-target="<?php echo esc_attr( $_theme_args['stylesheet'] ); ?>" class="theme-action-btn theme-activate-btn"><?php esc_html_e( 'Activate', 'directorist' )?></a> - <?php endif;?> + <figcaption> + <h5><?php echo esc_html( $_theme_args['name'] ); ?></h5> + <div class="theme-action"> + <?php if ( $_theme_args['is_installed'] ) : ?> + <?php if ( ! empty( $_theme_args['stylesheet'] ) ) : ?> + <a href="#" data-target="<?php echo esc_attr( $_theme_args['stylesheet'] ); ?>" class="theme-action-btn theme-activate-btn"><?php esc_html_e( 'Activate', 'directorist' ); ?></a> + <?php endif; ?> - <?php if ( ! empty( $_theme_args['customizer_link'] ) ): ?> - <a href="<?php echo esc_url( $_theme_args['customizer_link'] ); ?>" target="_blank" class="theme-action-btn theme-preview-btn"><?php esc_html_e( 'Live Preview', 'directorist' )?></a> - <?php endif;?> + <?php if ( ! empty( $_theme_args['customizer_link'] ) ) : ?> + <a href="<?php echo esc_url( $_theme_args['customizer_link'] ); ?>" target="_blank" class="theme-action-btn theme-preview-btn"><?php esc_html_e( 'Live Preview', 'directorist' ); ?></a> + <?php endif; ?> - <?php else: ?> - <a href="#" data-type="theme" data-key="<?php echo esc_attr( $_theme_base ) ?>" class="theme-action-btn file-install-btn"> - <i class="la la-download"></i> <?php echo $args['is_beta'] ? 'Install Beta' : 'Install'; ?> - </a> + <?php else : ?> + <a href="#" data-type="theme" data-key="<?php echo esc_attr( $_theme_base ); ?>" class="theme-action-btn file-install-btn"> + <i class="la la-download"></i> <?php echo $args['is_beta'] ? 'Install Beta' : 'Install'; ?> + </a> - <?php if ( ! empty( $_theme_args['demo_link'] ) ): ?> - <a href="<?php echo esc_url( $_theme_args['demo_link'] ); ?>" target="_blank" class="theme-action-btn theme-preview-btn"><?php esc_html_e( 'Demo', 'directorist' )?></a> - <?php endif;?> -<?php endif;?> - </div> - </figcaption> - </figure> - </div> - <?php endforeach;?> - </div> - </div> - <?php endif;?> + <?php if ( ! empty( $_theme_args['demo_link'] ) ) : ?> + <a href="<?php echo esc_url( $_theme_args['demo_link'] ); ?>" target="_blank" class="theme-action-btn theme-preview-btn"><?php esc_html_e( 'Demo', 'directorist' ); ?></a> + <?php endif; ?> +<?php endif; ?> + </div> + </figcaption> + </figure> + </div> + <?php endforeach; ?> + </div> + </div> + <?php endif; ?> </div> \ No newline at end of file diff --git a/views/admin-templates/theme-extensions/statistics/statistics.php b/views/admin-templates/theme-extensions/statistics/statistics.php index ddf0e4b009..0bf4e08b8f 100644 --- a/views/admin-templates/theme-extensions/statistics/statistics.php +++ b/views/admin-templates/theme-extensions/statistics/statistics.php @@ -1,69 +1,69 @@ <div class="row"> - <div class="col-md-8"> - <div class="atbdp-section-content atbdp-state-section-content"> - <ul class="atbdp-counter-list"> - <!-- atbdp-counter-list__item --> - <li class="atbdp-counter-list__item"> - <span class="atbdp-counter-list__number atbdp-text-success"> - <?php echo esc_html( $args[ 'total_active_extensions' ] ) ?> - </span> - <span class="atbdp-counter-list__label"><?php esc_html_e( 'Active Extensions', 'directorist'); ?></span> - </li> + <div class="col-md-8"> + <div class="atbdp-section-content atbdp-state-section-content"> + <ul class="atbdp-counter-list"> + <!-- atbdp-counter-list__item --> + <li class="atbdp-counter-list__item"> + <span class="atbdp-counter-list__number atbdp-text-success"> + <?php echo esc_html( $args['total_active_extensions'] ); ?> + </span> + <span class="atbdp-counter-list__label"><?php esc_html_e( 'Active Extensions', 'directorist' ); ?></span> + </li> - <!-- atbdp-counter-list__item --> - <li class="atbdp-counter-list__item"> - <span class="atbdp-counter-list__number"> - <?php echo esc_html( $args[ 'total_available_extensions' ] ); ?> - </span> - <span class="atbdp-counter-list__label"><?php esc_html_e( 'Available Extensions', 'directorist'); ?></span> - </li> + <!-- atbdp-counter-list__item --> + <li class="atbdp-counter-list__item"> + <span class="atbdp-counter-list__number"> + <?php echo esc_html( $args['total_available_extensions'] ); ?> + </span> + <span class="atbdp-counter-list__label"><?php esc_html_e( 'Available Extensions', 'directorist' ); ?></span> + </li> - <!-- atbdp-counter-list__item --> - <li class="atbdp-counter-list__item"> - <span class="atbdp-counter-list__number"> - <?php echo esc_html( $args[ 'total_available_themes' ] ); ?> - </span> - <span class="atbdp-counter-list__label"><?php esc_html_e( 'Available Theme', 'directorist'); ?></span> - </li> - </ul> - </div> - </div> + <!-- atbdp-counter-list__item --> + <li class="atbdp-counter-list__item"> + <span class="atbdp-counter-list__number"> + <?php echo esc_html( $args['total_available_themes'] ); ?> + </span> + <span class="atbdp-counter-list__label"><?php esc_html_e( 'Available Theme', 'directorist' ); ?></span> + </li> + </ul> + </div> + </div> - <div class="col-md-4"> - <div class="atbdp-section-content atbdp-state-section-content atbdp-state-vertical"> - <ul class="atbdp-counter-list atbdp-counter-list-vertical"> - <!-- atbdp-counter-list__item --> - <li class="atbdp-counter-list__item"> - <span class="atbdp-counter-list__number atbdp-text-success"> - <?php echo esc_html( $args[ 'total_outdated_extensions' ] ); ?> - </span> - - <span class="atbdp-counter-list__label"><?php esc_html_e( 'Extensions updates Available', 'directorist'); ?></span> - - <span class="atbdp-counter-list__actions"> - <?php if ( ! empty( $args[ 'total_outdated_extensions' ] ) ) : ?> - <button class="button button-primary ext-update-btn"><?php esc_html_e( 'Update All', 'directorist'); ?></button> - <?php else: ?> - <span class="atbdp-text-muted"><?php esc_html_e( 'All up to date', 'directorist'); ?></span> - <?php endif ?> - </span> - </li> + <div class="col-md-4"> + <div class="atbdp-section-content atbdp-state-section-content atbdp-state-vertical"> + <ul class="atbdp-counter-list atbdp-counter-list-vertical"> + <!-- atbdp-counter-list__item --> + <li class="atbdp-counter-list__item"> + <span class="atbdp-counter-list__number atbdp-text-success"> + <?php echo esc_html( $args['total_outdated_extensions'] ); ?> + </span> + + <span class="atbdp-counter-list__label"><?php esc_html_e( 'Extensions updates Available', 'directorist' ); ?></span> + + <span class="atbdp-counter-list__actions"> + <?php if ( ! empty( $args['total_outdated_extensions'] ) ) : ?> + <button class="button button-primary ext-update-btn"><?php esc_html_e( 'Update All', 'directorist' ); ?></button> + <?php else : ?> + <span class="atbdp-text-muted"><?php esc_html_e( 'All up to date', 'directorist' ); ?></span> + <?php endif ?> + </span> + </li> - <!-- atbdp-counter-list__item --> - <li class="atbdp-counter-list__item"> - <span class="atbdp-counter-list__number"> - <?php echo esc_html( $args[ 'total_outdated_themes' ] ); ?> - </span> - <span class="atbdp-counter-list__label"><?php esc_html_e( 'Theme updates Available', 'directorist'); ?></span> - <span class="atbdp-counter-list__actions"> - <?php if ( ! empty( $args[ 'total_outdated_themes' ] ) ) : ?> - <button class="button button-primary theme-update-btn"><?php esc_html_e( 'Update All', 'directorist'); ?></button> - <?php else: ?> - <span class="atbdp-text-muted"><?php esc_html_e( 'All up to date', 'directorist'); ?></span> - <?php endif ?> - </span> - </li> - </ul> - </div> - </div> + <!-- atbdp-counter-list__item --> + <li class="atbdp-counter-list__item"> + <span class="atbdp-counter-list__number"> + <?php echo esc_html( $args['total_outdated_themes'] ); ?> + </span> + <span class="atbdp-counter-list__label"><?php esc_html_e( 'Theme updates Available', 'directorist' ); ?></span> + <span class="atbdp-counter-list__actions"> + <?php if ( ! empty( $args['total_outdated_themes'] ) ) : ?> + <button class="button button-primary theme-update-btn"><?php esc_html_e( 'Update All', 'directorist' ); ?></button> + <?php else : ?> + <span class="atbdp-text-muted"><?php esc_html_e( 'All up to date', 'directorist' ); ?></span> + <?php endif ?> + </span> + </li> + </ul> + </div> + </div> </div> \ No newline at end of file diff --git a/views/admin-templates/theme-extensions/theme-extension.php b/views/admin-templates/theme-extensions/theme-extension.php index 93de609c2c..7fd8e511ee 100644 --- a/views/admin-templates/theme-extensions/theme-extension.php +++ b/views/admin-templates/theme-extensions/theme-extension.php @@ -1,16 +1,16 @@ <div id="directorist" class="wrap atbd_wrapper"> - <!-- my-themes-extensions --> - <div id="my-themes-extensions" class="atbdp-tab-content active"> + <!-- my-themes-extensions --> + <div id="my-themes-extensions" class="atbdp-tab-content active"> - <?php - if ( ! $args[ 'is_logged_in' ] ) { - ATBDP()->load_template('admin-templates/theme-extensions/auth/license-auth-section', $args ); - } else { - ATBDP()->load_template('admin-templates/theme-extensions/statistics/statistics', $args); - ATBDP()->load_template('admin-templates/theme-extensions/my-themes-extensions/my-themes-extensions', $args); - } + <?php + if ( ! $args['is_logged_in'] ) { + ATBDP()->load_template( 'admin-templates/theme-extensions/auth/license-auth-section', $args ); + } else { + ATBDP()->load_template( 'admin-templates/theme-extensions/statistics/statistics', $args ); + ATBDP()->load_template( 'admin-templates/theme-extensions/my-themes-extensions/my-themes-extensions', $args ); + } - ATBDP()->load_template('admin-templates/theme-extensions/all-themes-extensions', $args); - ?> - </div> + ATBDP()->load_template( 'admin-templates/theme-extensions/all-themes-extensions', $args ); + ?> + </div> </div> \ No newline at end of file