Changeset 3352831
- Timestamp:
- 08/29/2025 05:46:07 PM (7 months ago)
- Location:
- quick-ajax-post-loader/trunk
- Files:
-
- 18 edited
-
admin/admin-pages-config.php (modified) (13 diffs)
-
admin/pages/settings-page.php (modified) (7 diffs)
-
admin/pages/shortcode-page.php (modified) (6 diffs)
-
css/admin-style.css (modified) (2 diffs)
-
css/admin-style.min.css (modified) (1 diff)
-
inc/actions.php (modified) (8 diffs)
-
inc/class-activator.php (modified) (1 diff)
-
inc/class-ajax.php (modified) (26 diffs)
-
inc/class-deprecated-hooks-handler.php (modified) (1 diff)
-
inc/class-helper.php (modified) (13 diffs)
-
inc/class-shortcode.php (modified) (6 diffs)
-
inc/class-template-hooks.php (modified) (10 diffs)
-
inc/class-updater.php (modified) (12 diffs)
-
inc/functions.php (modified) (4 diffs)
-
js/admin-script.js (modified) (2 diffs)
-
js/admin-script.min.js (modified) (1 diff)
-
quick-ajax-post-loader.php (modified) (2 diffs)
-
readme.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
quick-ajax-post-loader/trunk/admin/admin-pages-config.php
r3295741 r3352831 16 16 'Quick AJAX', 17 17 'manage_options', 18 QAPL_Quick_Ajax_ Helper::menu_slug(),18 QAPL_Quick_Ajax_Plugin_Constants::PLUGIN_MENU_SLUG, 19 19 array($this, 'options_page_content'), 20 20 'dashicons-editor-code', … … 23 23 // "Add New" 24 24 add_submenu_page( 25 QAPL_Quick_Ajax_ Helper::menu_slug(),25 QAPL_Quick_Ajax_Plugin_Constants::PLUGIN_MENU_SLUG, 26 26 __('Add New', 'quick-ajax-post-loader'), 27 27 __('Add New', 'quick-ajax-post-loader'), 28 28 'edit_posts', 29 'post-new.php?post_type=' . QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug()29 'post-new.php?post_type=' . QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG 30 30 ); 31 31 } … … 33 33 // "settings" 34 34 add_submenu_page( 35 QAPL_Quick_Ajax_ Helper::menu_slug(),35 QAPL_Quick_Ajax_Plugin_Constants::PLUGIN_MENU_SLUG, 36 36 __('Settings & Features', 'quick-ajax-post-loader'), 37 37 __('Settings & Features', 'quick-ajax-post-loader'), 38 38 'manage_options', 39 QAPL_Quick_Ajax_ Helper::settings_page_slug(),39 QAPL_Quick_Ajax_Plugin_Constants::SETTINGS_PAGE_SLUG, 40 40 array($this, 'render_quick_ajax_settings_page') 41 41 ); … … 47 47 } 48 48 if (class_exists('QAPL_Quick_Ajax_Creator_Settings_Page')) { 49 $form = new QAPL_Quick_Ajax_Creator_Settings_Page(QAPL_Quick_Ajax_ Helper::admin_page_settings_field_option_group(), QAPL_Quick_Ajax_Helper::admin_page_global_options_name());49 $form = new QAPL_Quick_Ajax_Creator_Settings_Page(QAPL_Quick_Ajax_Plugin_Constants::ADMIN_PAGE_SETTINGS_GROUP, QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME); 50 50 $form->render_quick_ajax_page(); 51 51 } … … 54 54 // Register the settings group 55 55 register_setting( 56 QAPL_Quick_Ajax_ Helper::admin_page_settings_field_option_group(),57 QAPL_Quick_Ajax_ Helper::admin_page_global_options_name(),56 QAPL_Quick_Ajax_Plugin_Constants::ADMIN_PAGE_SETTINGS_GROUP, 57 QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME, 58 58 array($this, 'quick_ajax_sanitize_callback') 59 59 ); … … 82 82 public function __construct() { 83 83 add_action('init', array($this, 'register_quick_ajax_post_type')); 84 add_action('manage_' . QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(). '_posts_columns', array($this, 'quick_ajax_shortcode_column'));85 add_action('manage_' . QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(). '_posts_custom_column', array($this, 'quick_ajax_shortcode_column_content'), 10, 2);86 add_filter('manage_' . QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(). '_posts_columns', array($this, 'quick_ajax_shortcode_column_sort'));84 add_action('manage_' . QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG . '_posts_columns', array($this, 'quick_ajax_shortcode_column')); 85 add_action('manage_' . QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG . '_posts_custom_column', array($this, 'quick_ajax_shortcode_column_content'), 10, 2); 86 add_filter('manage_' . QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG . '_posts_columns', array($this, 'quick_ajax_shortcode_column_sort')); 87 87 } 88 88 … … 108 108 'publicly_queryable' => false, 109 109 'show_ui' => true, 110 'show_in_menu' => QAPL_Quick_Ajax_ Helper::menu_slug(),110 'show_in_menu' => QAPL_Quick_Ajax_Plugin_Constants::PLUGIN_MENU_SLUG, 111 111 'query_var' => true, 112 'rewrite' => array( 'slug' => QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug()),112 'rewrite' => array( 'slug' => QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG ), 113 113 'capability_type' => 'post', 114 114 'has_archive' => true, … … 118 118 'menu_icon' => 'dashicons-editor-code' 119 119 ); 120 register_post_type( QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(), $args );120 register_post_type( QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG, $args ); 121 121 } 122 122 … … 130 130 //add Shortcode Column Content 131 131 if ($column_name === 'quick_ajax_shortcode_column') { 132 $excluded_post_ids = ''; 133 $shortcode = QAPL_Quick_Ajax_Helper::generate_shortcode($post_id); 132 $shortcode = QAPL_Quick_Ajax_Shortcode_Generator::generate_shortcode($post_id); 134 133 echo '<div class="quick-ajax-shortcode">' . esc_html($shortcode) . '</div>'; 135 134 } … … 384 383 protected function get_taxonomy_options_for_post_type(?string $post_type = null): array{ 385 384 if (empty($post_type)) { 386 $post_type = $this->get_the_value_if_exist(QAPL_Quick_Ajax_ Helper::shortcode_page_select_post_type());385 $post_type = $this->get_the_value_if_exist(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POST_TYPE); 387 386 if (empty($post_type)) { 388 $post_type = QAPL_Quick_Ajax_ Helper::shortcode_page_select_post_type_default_value();387 $post_type = QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POST_TYPE_DEFAULT; 389 388 } 390 389 } … … 416 415 if (empty($taxonomy)) { 417 416 // try to get taxonomy from saved shortcode value 418 $taxonomy = $this->get_the_value_if_exist(QAPL_Quick_Ajax_ Helper::shortcode_page_select_taxonomy());417 $taxonomy = $this->get_the_value_if_exist(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_TAXONOMY); 419 418 } 420 419 if (empty($taxonomy)) { 421 420 // try to get first available taxonomy based on post type 422 $post_type = $this->get_the_value_if_exist(QAPL_Quick_Ajax_ Helper::shortcode_page_select_post_type());421 $post_type = $this->get_the_value_if_exist(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POST_TYPE); 423 422 if (empty($post_type)) { 424 423 // fallback to default post type 425 $post_type = QAPL_Quick_Ajax_ Helper::shortcode_page_select_post_type_default_value();424 $post_type = QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POST_TYPE_DEFAULT; 426 425 } 427 426 if (!empty($post_type)) { … … 626 625 echo '<div class="quick-ajax-form-wrap '.esc_attr($this->get_quick_ajax_form_class()).'" id="' . esc_attr($this->form_id) . '">'; 627 626 echo wp_kses($this->render_quick_ajax_form(), $this->wp_kses_allowed_tags()); 628 wp_nonce_field(QAPL_Quick_Ajax_ Helper::wp_nonce_form_quick_ajax_action(), QAPL_Quick_Ajax_Helper::wp_nonce_form_quick_ajax_field());627 wp_nonce_field(QAPL_Quick_Ajax_Plugin_Constants::NONCE_FORM_QUICK_AJAX_ACTION, QAPL_Quick_Ajax_Plugin_Constants::NONCE_FORM_QUICK_AJAX_FIELD); 629 628 echo '</div>'; 630 629 } … … 635 634 return; 636 635 } 637 if (!isset($_POST[QAPL_Quick_Ajax_ Helper::wp_nonce_form_quick_ajax_field()]) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST[QAPL_Quick_Ajax_Helper::wp_nonce_form_quick_ajax_field()])), QAPL_Quick_Ajax_Helper::wp_nonce_form_quick_ajax_action())) {636 if (!isset($_POST[QAPL_Quick_Ajax_Plugin_Constants::NONCE_FORM_QUICK_AJAX_FIELD]) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST[QAPL_Quick_Ajax_Plugin_Constants::NONCE_FORM_QUICK_AJAX_FIELD])), QAPL_Quick_Ajax_Plugin_Constants::NONCE_FORM_QUICK_AJAX_ACTION)) { 638 637 return; 639 638 } -
quick-ajax-post-loader/trunk/admin/pages/settings-page.php
r3321429 r3352831 18 18 private function init_global_options_fields() { 19 19 //select loader icon 20 $field_properties = QAPL_Form_Fields_Helper::get_global_field_select_loader_icon(); 21 $this->create_field($field_properties); 22 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_read_more_label(); 23 $this->create_field($field_properties); 24 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_show_all_label(); 25 $this->create_field($field_properties); 26 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_load_more_label(); 27 $this->create_field($field_properties); 28 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_no_post_message(); 29 $this->create_field($field_properties); 30 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_end_post_message(); 20 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_select_loader_icon(); 21 $field_properties = $field->get_field(); 22 $this->create_field($field_properties); 23 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_read_more_text_field(); 24 $field_properties = $field->get_field(); 25 $this->create_field($field_properties); 26 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_show_all_label_field(); 27 $field_properties = $field->get_field(); 28 $this->create_field($field_properties); 29 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_load_more_label_field(); 30 $field_properties = $field->get_field(); 31 $this->create_field($field_properties); 32 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_no_post_message_field(); 33 $field_properties = $field->get_field(); 34 $this->create_field($field_properties); 35 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_end_post_message_field(); 36 $field_properties = $field->get_field(); 31 37 $this->create_field($field_properties); 32 38 33 39 //Sorting Options 34 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_sort_option_date_desc_label(); 35 $this->create_field($field_properties); 36 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_sort_option_date_asc_label(); 37 $this->create_field($field_properties); 38 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_sort_option_comment_count_desc_label(); 39 $this->create_field($field_properties); 40 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_sort_option_title_desc_label(); 41 $this->create_field($field_properties); 42 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_sort_option_title_asc_label(); 43 $this->create_field($field_properties); 44 $field_properties = QAPL_Form_Fields_Helper::get_global_options_field_set_sort_option_rand_label(); 40 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_sort_option_date_desc_label_field(); 41 $field_properties = $field->get_field(); 42 $this->create_field($field_properties); 43 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_sort_option_date_asc_label_field(); 44 $field_properties = $field->get_field(); 45 $this->create_field($field_properties); 46 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_sort_option_comment_count_desc_label_field(); 47 $field_properties = $field->get_field(); 48 $this->create_field($field_properties); 49 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_sort_option_title_desc_label_field(); 50 $field_properties = $field->get_field(); 51 $this->create_field($field_properties); 52 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_sort_option_title_asc_label_field(); 53 $field_properties = $field->get_field(); 54 $this->create_field($field_properties); 55 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_sort_option_rand_label_field(); 56 $field_properties = $field->get_field(); 45 57 $this->create_field($field_properties); 46 58 } … … 48 60 private function init_function_generator_fields() { 49 61 //select post type 50 $field_properties = QAPL_Form_Fields_Helper::get_field_select_post_type(); 62 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_post_type_field(); 63 $field_properties = $field->get_field(); 51 64 $this->create_field($field_properties); 52 65 //show taxonomy checkbox 53 $field_properties = QAPL_Form_Fields_Helper::get_field_show_taxonomy_filter(); 66 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_taxonomy_filter_field(); 67 $field_properties = $field->get_field(); 54 68 $this->create_field($field_properties); 55 69 //select taxonomy 56 $field_properties = QAPL_Form_Fields_Helper::get_field_select_taxonomy(); 70 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_taxonomy_field(); 71 $field_properties = $field->get_field(); 57 72 $this->create_field($field_properties); 58 73 //manual term selection checkbox 59 $field_properties = QAPL_Form_Fields_Helper::get_field_manual_term_selection(); 74 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_manual_term_selection_field(); 75 $field_properties = $field->get_field(); 60 76 $this->create_field($field_properties); 61 77 //manual selected terms multiselect 62 $field_properties = QAPL_Form_Fields_Helper::get_field_manual_selected_terms(); 63 $this->create_field($field_properties); 64 //select post status 65 //$field_properties = QAPL_Form_Fields_Helper::get_field_select_post_status(); 66 //$this->create_field($field_properties); 78 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_manual_selected_terms_field(); 79 $field_properties = $field->get_field(); 80 $this->create_field($field_properties); 67 81 //post per page number 68 $field_properties = QAPL_Form_Fields_Helper::get_field_select_posts_per_page(); 82 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_posts_per_page_field(); 83 $field_properties = $field->get_field(); 69 84 $this->create_field($field_properties); 70 85 //select post order 71 $field_properties = QAPL_Form_Fields_Helper::get_field_select_order(); 86 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_order_field(); 87 $field_properties = $field->get_field(); 72 88 $this->create_field($field_properties); 73 89 //select post orderby 74 $field_properties = QAPL_Form_Fields_Helper::get_field_select_orderby(); 90 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_orderby_field(); 91 $field_properties = $field->get_field(); 75 92 $this->create_field($field_properties); 76 93 77 94 //Sorting Settings 78 $field_properties = QAPL_Form_Fields_Helper::get_field_show_sort_button(); 95 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_sort_button_field(); 96 $field_properties = $field->get_field(); 79 97 $this->create_field($field_properties); 80 98 //select sort options 81 $field_properties = QAPL_Form_Fields_Helper::get_field_select_sort_button_options(); 99 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_sort_button_options_field(); 100 $field_properties = $field->get_field(); 82 101 $this->create_field($field_properties); 83 102 //Additional Settings 84 103 85 104 //add Excluded Post IDs 86 $field_properties = QAPL_Form_Fields_Helper::get_field_set_post_not_in(); 105 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_excluded_post_ids_field(); 106 $field_properties = $field->get_field(); 87 107 $this->create_field($field_properties); 88 108 //set ignore sticky 89 $field_properties = QAPL_Form_Fields_Helper::get_field_set_ignore_sticky_posts(); 109 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_ignore_sticky_posts_field(); 110 $field_properties = $field->get_field(); 90 111 $this->create_field($field_properties); 91 112 //load posts via AJAX on initial load 92 $field_properties = QAPL_Form_Fields_Helper::get_field_set_ajax_on_initial_load(); 113 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_ajax_on_initial_load_field(); 114 $field_properties = $field->get_field(); 93 115 $this->create_field($field_properties); 94 116 //Infinite Scroll 95 $field_properties = QAPL_Form_Fields_Helper::get_field_set_ajax_infinite_scroll(); 117 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_ajax_infinite_scroll_field(); 118 $field_properties = $field->get_field(); 96 119 $this->create_field($field_properties); 97 120 //Show end message 98 $field_properties = QAPL_Form_Fields_Helper::get_field_set_show_end_message(); 121 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_end_message_field(); 122 $field_properties = $field->get_field(); 99 123 $this->create_field($field_properties); 100 124 101 125 //Additional Settings 102 126 //apply quick ajax css style 103 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_quick_ajax_css_style(); 127 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_quick_ajax_css_style_field(); 128 $field_properties = $field->get_field(); 104 129 $field_properties['default'] = 0; 105 130 $this->create_field($field_properties); 106 131 //select number of columns 107 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_select_columns_qty(); 132 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_columns_qty_field(); 133 $field_properties = $field->get_field(); 108 134 $this->create_field($field_properties); 109 135 //select post item template 110 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_post_item_template(); 136 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_post_item_template_field(); 137 $field_properties = $field->get_field(); 111 138 $this->create_field($field_properties); 112 139 //add custom class for taxonomy filter 113 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_taxonomy_filter_class(); 140 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_taxonomy_filter_class_field(); 141 $field_properties = $field->get_field(); 114 142 $this->create_field($field_properties); 115 143 //add custom class for container 116 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_container_class(); 144 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_container_class_field(); 145 $field_properties = $field->get_field(); 117 146 $this->create_field($field_properties); 118 147 //show custom load more post quantity 119 $field_properties = QAPL_Form_Fields_Helper::get_field_show_custom_load_more_post_quantity(); 148 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_custom_load_more_post_quantity_field(); 149 $field_properties = $field->get_field(); 120 150 $this->create_field($field_properties); 121 151 //select custom load more post quantity 122 $field_properties = QAPL_Form_Fields_Helper::get_field_select_custom_load_more_post_quantity(); 152 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_custom_load_more_post_quantity_field(); 153 $field_properties = $field->get_field(); 123 154 $this->create_field($field_properties); 124 155 //override loader icon 125 $field_properties = QAPL_Form_Fields_Helper::get_field_override_global_loader_icon(); 156 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_override_global_loader_icon_field(); 157 $field_properties = $field->get_field(); 126 158 $this->create_field($field_properties); 127 159 //select loader icon 128 $field_properties = QAPL_Form_Fields_Helper::get_field_select_loader_icon(); 160 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_loader_icon(); 161 $field_properties = $field->get_field(); 129 162 $this->create_field($field_properties); 130 163 } … … 132 165 private function init_content_clear_old_data_fields() { 133 166 //remove old data 134 $field_properties = QAPL_Form_Fields_Helper::get_global_field_remove_old_data(); 167 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_global_remove_old_data_field(); 168 $field_properties = $field->get_field(); 135 169 $this->create_field($field_properties); 136 170 } … … 142 176 $tab_title = esc_html__('Help', 'quick-ajax-post-loader'); 143 177 $this->add_quick_ajax_page_content($this->tabIndex++, $tab_title, $this->quick_ajax_content_help()); 144 $cleanup_flags = QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_cleanup_flags();178 $cleanup_flags = QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_CLEANUP_FLAGS; 145 179 if (!empty(get_option($cleanup_flags))) { 146 180 $tab_title = esc_html__('Purge Old Data', 'quick-ajax-post-loader'); … … 169 203 $content .= '<form method="post" action="options.php">'; 170 204 $content .= '<h3>'.__('Global Options', 'quick-ajax-post-loader').'</h3>'; 171 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_select_loader_icon());172 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_read_more_label());173 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_show_all_label());174 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_load_more_label());175 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_no_post_message());176 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_end_post_message());205 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_LOADER_ICON_FIELD); 206 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_READ_MORE_LABEL_FIELD); 207 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_SHOW_ALL_LABEL_FIELD); 208 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_LOAD_MORE_LABEL_FIELD); 209 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_NO_POST_MESSAGE_FIELD); 210 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_END_POST_MESSAGE_FIELD); 177 211 $content .= '<h4>'.__('Sorting Option Labels', 'quick-ajax-post-loader').'</h4>'; 178 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_sort_option_date_desc_label());179 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_sort_option_date_asc_label());180 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_sort_option_comment_count_desc_label());181 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_sort_option_title_asc_label());182 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_sort_option_title_desc_label());183 $content .= $this->add_field(QAPL_Quick_Ajax_ Helper::global_options_field_set_sort_option_rand_label());212 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_SORT_OPTION_DATE_DESC_LABEL_FIELD); 213 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_SORT_OPTION_DATE_ASC_LABEL_FIELD); 214 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_SORT_OPTION_COMMENT_COUNT_DESC_LABEL_FIELD); 215 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_SORT_OPTION_TITLE_ASC_LABEL_FIELD); 216 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_SORT_OPTION_TITLE_DESC_LABEL_FIELD); 217 $content .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_SORT_OPTION_RAND_LABEL_FIELD); 184 218 $content .= $settings_fields_html; 185 219 $content .= get_submit_button(esc_html__('Save Settings', 'quick-ajax-post-loader'), 'primary', 'save_settings_button', false); … … 192 226 $form_tab_function_generator = '<h3>'.esc_html__('Function Generator', 'quick-ajax-post-loader').'</h3> 193 227 <div class="function-generator-wrap"> 194 <div class="function-generator-options" id="'.QAPL_Quick_Ajax_ Helper::settings_wrapper_id().'">';228 <div class="function-generator-options" id="'.QAPL_Quick_Ajax_Plugin_Constants::SETTINGS_WRAPPER_ID.'">'; 195 229 $form_tab_function_generator .= '<div class="quick-ajax-layout-settings">'; 196 230 $form_tab_function_generator .= '<h4>'.__('General Settings', 'quick-ajax-post-loader').'</h4>'; 197 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_post_type());231 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POST_TYPE); 198 232 //show taxonomy checkbox 199 233 $field_options = $this->field_options([ 200 234 'is_trigger' => true, 201 235 ]); 202 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter(), $field_options);236 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER, $field_options); 203 237 //taxonomy select option 204 $this->fields[QAPL_Quick_Ajax_ Helper::shortcode_page_select_taxonomy()]['options'] = $this->get_taxonomy_options_for_post_type();238 $this->fields[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_TAXONOMY]['options'] = $this->get_taxonomy_options_for_post_type(); 205 239 $field_options = $this->field_options([ 206 240 'is_trigger' => false, 207 241 'visible_if' => [ 208 QAPL_Quick_Ajax_Helper::shortcode_page_show_taxonomy_filter() => '1' 209 ] 210 ]); 211 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Helper::shortcode_page_select_taxonomy(), $field_options); 212 //$form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Helper::shortcode_page_select_post_status()); 242 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER => '1' 243 ] 244 ]); 245 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_TAXONOMY, $field_options); 213 246 // manual term selection checkbox 214 247 $field_options = $this->field_options([ 215 248 'is_trigger' => true, 216 249 'visible_if' => [ 217 QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter()=> '1'218 ] 219 ]); 220 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_manual_term_selection(), $field_options);250 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER => '1' 251 ] 252 ]); 253 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_MANUAL_TERM_SELECTION, $field_options); 221 254 222 255 // assign term options to field 223 $this->fields[QAPL_Quick_Ajax_ Helper::shortcode_page_manual_selected_terms()]['options'] = $this->get_term_options_for_taxonomy();256 $this->fields[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECTED_TERMS]['options'] = $this->get_term_options_for_taxonomy(); 224 257 225 258 // render field with multiple conditions 226 259 $field_options = $this->field_options([ 227 260 'visible_if' => [ 228 QAPL_Quick_Ajax_ Helper::shortcode_page_manual_term_selection()=> '1',229 QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter()=> '1'230 ] 231 ]); 232 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_manual_selected_terms(), $field_options);261 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_MANUAL_TERM_SELECTION => '1', 262 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER => '1' 263 ] 264 ]); 265 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECTED_TERMS, $field_options); 233 266 234 267 //end manual term selection checkbox 235 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_posts_per_page());268 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POSTS_PER_PAGE); 236 269 $form_tab_function_generator .= '</div>'; 237 270 //post settings 238 271 $form_tab_function_generator .= '<div class="quick-ajax-layout-settings" style="margin-top:20px">'; 239 272 $form_tab_function_generator .= '<h4>'.__('Sorting Settings', 'quick-ajax-post-loader').'</h4>'; 240 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_order());241 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_orderby());273 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_ORDER); 274 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_ORDERBY); 242 275 $field_options = $this->field_options([ 243 276 'is_trigger' => true, 244 277 ]); 245 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_sort_button(), $field_options);246 $field_options = $this->field_options([ 247 'visible_if' => [ 248 QAPL_Quick_Ajax_ Helper::shortcode_page_show_sort_button()=> '1'249 ] 250 ]); 251 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_sort_button_options(), $field_options);278 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON, $field_options); 279 $field_options = $this->field_options([ 280 'visible_if' => [ 281 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON => '1' 282 ] 283 ]); 284 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_SORT_BUTTON_OPTIONS, $field_options); 252 285 $form_tab_function_generator .= '</div>'; 253 286 $form_tab_function_generator .= '<div class="quick-ajax-layout-settings" style="margin-top:20px">'; 254 287 $form_tab_function_generator .= '<h4>'.esc_html__('Additional Settings', 'quick-ajax-post-loader').'</h4>'; 255 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_set_post_not_in());256 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_ignore_sticky_posts());257 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_ajax_on_initial_load());258 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_ajax_infinite_scroll());259 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_end_message());288 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SET_POST_NOT_IN); 289 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_IGNORE_STICKY_POSTS); 290 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_AJAX_ON_INITIAL_LOAD); 291 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_AJAX_INFINITE_SCROLL); 292 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_END_MESSAGE); 260 293 $form_tab_function_generator .= '</div>'; 261 294 $form_tab_function_generator .= '<div class="quick-ajax-layout-settings" style="margin-top:20px">'; … … 265 298 'is_trigger' => true, 266 299 ]); 267 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_quick_ajax_css_style(), $field_options);268 $field_options = $this->field_options([ 269 'visible_if' => [ 270 QAPL_Quick_Ajax_ Helper::shortcode_page_layout_quick_ajax_css_style()=> '1'271 ] 272 ]); 273 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_select_columns_qty(), $field_options);274 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_post_item_template());300 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE, $field_options); 301 $field_options = $this->field_options([ 302 'visible_if' => [ 303 QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE => '1' 304 ] 305 ]); 306 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_SELECT_COLUMNS_QTY, $field_options); 307 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_POST_ITEM_TEMPLATE); 275 308 $field_options = $this->field_options([ 276 309 'is_trigger' => false, 277 310 'visible_if' => [ 278 QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter()=> '1'279 ] 280 ]); 281 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_taxonomy_filter_class(), $field_options);282 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_container_class());283 $field_options = $this->field_options([ 284 'is_trigger' => true, 285 ]); 286 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_custom_load_more_post_quantity(), $field_options);311 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER => '1' 312 ] 313 ]); 314 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_TAXONOMY_FILTER_CLASS, $field_options); 315 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_CONTAINER_CLASS); 316 $field_options = $this->field_options([ 317 'is_trigger' => true, 318 ]); 319 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY, $field_options); 287 320 $field_options = $this->field_options([ 288 321 'is_trigger' => false, 289 322 'visible_if' => [ 290 QAPL_Quick_Ajax_ Helper::shortcode_page_show_custom_load_more_post_quantity()=> '1'291 ] 292 ]); 293 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_custom_load_more_post_quantity(), $field_options);294 $field_options = $this->field_options([ 295 'is_trigger' => true, 296 ]); 297 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_override_global_loader_icon(), $field_options);323 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY => '1' 324 ] 325 ]); 326 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_CUSTOM_LOAD_MORE_POST_QUANTITY, $field_options); 327 $field_options = $this->field_options([ 328 'is_trigger' => true, 329 ]); 330 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON, $field_options); 298 331 $field_options = $this->field_options([ 299 332 'is_trigger' => false, 300 333 'visible_if' => [ 301 QAPL_Quick_Ajax_ Helper::shortcode_page_override_global_loader_icon()=> '1'302 ] 303 ]); 304 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_loader_icon(), $field_options);334 QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON => '1' 335 ] 336 ]); 337 $form_tab_function_generator .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_SELECT_LOADER_ICON, $field_options); 305 338 $form_tab_function_generator .= '</div>'; 306 339 $form_tab_function_generator .= '</div>'; -
quick-ajax-post-loader/trunk/admin/pages/shortcode-page.php
r3287563 r3352831 8 8 function qapl_quick_ajax_display_shortcode_on_single_page($post) { 9 9 //check the post type 10 if ($post && $post->post_type === QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug()) {11 $shortcode = QAPL_Quick_Ajax_ Helper::generate_shortcode($post->ID);10 if ($post && $post->post_type === QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG) { 11 $shortcode = QAPL_Quick_Ajax_Shortcode_Generator::generate_shortcode($post->ID); 12 12 echo '<div id="shortcode-box-wrap">'; 13 13 echo '<span class="shortcode-description">' . esc_html__('Copy and paste this shortcode on the page to display the posts list', 'quick-ajax-post-loader') . '</span>'; … … 24 24 public function init_quick_ajax_creator_fields(){ 25 25 //select post type 26 $field_properties = QAPL_Form_Fields_Helper::get_field_select_post_type(); 26 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_post_type_field(); 27 $field_properties = $field->get_field(); 27 28 $this->create_field($field_properties); 28 29 //show taxonomy checkbox 29 $field_properties = QAPL_Form_Fields_Helper::get_field_show_taxonomy_filter(); 30 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_taxonomy_filter_field(); 31 $field_properties = $field->get_field(); 30 32 $this->create_field($field_properties); 31 33 //select taxonomy 32 $field_properties = QAPL_Form_Fields_Helper::get_field_select_taxonomy(); 34 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_taxonomy_field(); 35 $field_properties = $field->get_field(); 33 36 $this->create_field($field_properties); 34 37 //manual term selection checkbox 35 $field_properties = QAPL_Form_Fields_Helper::get_field_manual_term_selection(); 38 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_manual_term_selection_field(); 39 $field_properties = $field->get_field(); 36 40 $this->create_field($field_properties); 37 41 //manual selected terms multiselect 38 $field_properties = QAPL_Form_Fields_Helper::get_field_manual_selected_terms(); 42 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_manual_selected_terms_field(); 43 $field_properties = $field->get_field(); 39 44 $this->create_field($field_properties); 40 45 //post per page number 41 $field_properties = QAPL_Form_Fields_Helper::get_field_select_posts_per_page(); 46 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_posts_per_page_field(); 47 $field_properties = $field->get_field(); 42 48 $this->create_field($field_properties); 43 49 //select post order 44 $field_properties = QAPL_Form_Fields_Helper::get_field_select_order(); 50 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_order_field(); 51 $field_properties = $field->get_field(); 45 52 $this->create_field($field_properties); 46 53 //select post orderby 47 $field_properties = QAPL_Form_Fields_Helper::get_field_select_orderby(); 54 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_orderby_field(); 55 $field_properties = $field->get_field(); 48 56 $this->create_field($field_properties); 49 57 50 58 //show sort button 51 $field_properties = QAPL_Form_Fields_Helper::get_field_show_sort_button(); 59 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_sort_button_field(); 60 $field_properties = $field->get_field(); 52 61 $this->create_field($field_properties); 53 62 //select sort options 54 $field _properties = QAPL_Form_Fields_Helper::get_field_select_sort_button_options();55 $ this->create_field($field_properties);56 $ field_properties = QAPL_Form_Fields_Helper::get_field_show_inline_filter_sorting();57 $this->create_field($field_properties);58 59 //select post status60 //$field_properties = QAPL_Form_Fields_Helper::get_field_select_post_status();61 //$this->create_field($field_properties); 63 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_sort_button_options_field(); 64 $field_properties = $field->get_field(); 65 $this->create_field($field_properties); 66 //inline Filter & Sorting 67 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_inline_filter_sorting_field(); 68 $field_properties = $field->get_field(); 69 $this->create_field($field_properties); 70 62 71 //add Excluded Post IDs 63 $field_properties = QAPL_Form_Fields_Helper::get_field_set_post_not_in(); 72 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_excluded_post_ids_field(); 73 $field_properties = $field->get_field(); 64 74 $this->create_field($field_properties); 65 75 //set ignore sticky 66 $field_properties = QAPL_Form_Fields_Helper::get_field_set_ignore_sticky_posts(); 76 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_ignore_sticky_posts_field(); 77 $field_properties = $field->get_field(); 67 78 $this->create_field($field_properties); 68 79 //load posts via AJAX on initial load 69 $field_properties = QAPL_Form_Fields_Helper::get_field_set_ajax_on_initial_load(); 80 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_ajax_on_initial_load_field(); 81 $field_properties = $field->get_field(); 70 82 $this->create_field($field_properties); 71 83 //Infinite Scroll 72 $field_properties = QAPL_Form_Fields_Helper::get_field_set_ajax_infinite_scroll(); 84 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_ajax_infinite_scroll_field(); 85 $field_properties = $field->get_field(); 73 86 $this->create_field($field_properties); 74 87 //Show end message 75 $field_properties = QAPL_Form_Fields_Helper::get_field_set_show_end_message(); 88 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_end_message_field(); 89 $field_properties = $field->get_field(); 76 90 $this->create_field($field_properties); 77 91 //apply quick ajax css style 78 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_quick_ajax_css_style(); 92 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_quick_ajax_css_style_field(); 93 $field_properties = $field->get_field(); 79 94 $this->create_field($field_properties); 80 95 //select number of columns 81 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_select_columns_qty(); 96 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_columns_qty_field(); 97 $field_properties = $field->get_field(); 82 98 $this->create_field($field_properties); 83 99 //select post item template 84 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_post_item_template(); 100 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_post_item_template_field(); 101 $field_properties = $field->get_field(); 85 102 $this->create_field($field_properties); 86 103 //add custom class for taxonomy filter 87 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_taxonomy_filter_class(); 104 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_taxonomy_filter_class_field(); 105 $field_properties = $field->get_field(); 88 106 $this->create_field($field_properties); 89 107 //add custom class for container 90 $field_properties = QAPL_Form_Fields_Helper::get_field_layout_container_class(); 108 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_container_class_field(); 109 $field_properties = $field->get_field(); 91 110 $this->create_field($field_properties); 92 111 //show custom load more post quantity 93 $field_properties = QAPL_Form_Fields_Helper::get_field_show_custom_load_more_post_quantity(); 112 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_show_custom_load_more_post_quantity_field(); 113 $field_properties = $field->get_field(); 94 114 $this->create_field($field_properties); 95 115 //select custom load more post quantity 96 $field_properties = QAPL_Form_Fields_Helper::get_field_select_custom_load_more_post_quantity(); 116 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_custom_load_more_post_quantity_field(); 117 $field_properties = $field->get_field(); 97 118 $this->create_field($field_properties); 98 119 //override loader icon 99 $field_properties = QAPL_Form_Fields_Helper::get_field_override_global_loader_icon(); 120 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_override_global_loader_icon_field(); 121 $field_properties = $field->get_field(); 100 122 $this->create_field($field_properties); 101 123 //select loader icon 102 $field_properties = QAPL_Form_Fields_Helper::get_field_select_loader_icon(); 124 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_loader_icon(); 125 $field_properties = $field->get_field(); 103 126 $this->create_field($field_properties); 104 127 } … … 108 131 $shortcode_page .= '<h4>'.esc_html__('General Settings', 'quick-ajax-post-loader').'</h4>'; 109 132 //select post type 110 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_post_type());133 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POST_TYPE); 111 134 //show taxonomy checkbox 112 135 $field_options = $this->field_options([ 113 136 'is_trigger' => true, 114 137 ]); 115 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter(), $field_options);138 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER, $field_options); 116 139 //select taxonomy 117 $this->fields[QAPL_Quick_Ajax_ Helper::shortcode_page_select_taxonomy()]['options'] = $this->get_taxonomy_options_for_post_type();118 $field_options = $this->field_options([ 119 'is_trigger' => false, 120 'visible_if' => [ 121 QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter()=> '1'140 $this->fields[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_TAXONOMY]['options'] = $this->get_taxonomy_options_for_post_type(); 141 $field_options = $this->field_options([ 142 'is_trigger' => false, 143 'visible_if' => [ 144 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER => '1' 122 145 ] 123 146 ]); 124 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Helper::shortcode_page_select_taxonomy(), $field_options); 125 //$shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Helper::shortcode_page_select_post_status()); 147 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_TAXONOMY, $field_options); 126 148 127 149 // manual term selection checkbox … … 129 151 'is_trigger' => true, 130 152 'visible_if' => [ 131 QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter()=> '1'132 ] 133 ]); 134 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_manual_term_selection(), $field_options);153 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER => '1' 154 ] 155 ]); 156 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_MANUAL_TERM_SELECTION, $field_options); 135 157 136 158 // assign term options to field 137 $this->fields[QAPL_Quick_Ajax_ Helper::shortcode_page_manual_selected_terms()]['options'] = $this->get_term_options_for_taxonomy();159 $this->fields[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECTED_TERMS]['options'] = $this->get_term_options_for_taxonomy(); 138 160 139 161 // render field with multiple conditions 140 162 $field_options = $this->field_options([ 141 163 'visible_if' => [ 142 QAPL_Quick_Ajax_ Helper::shortcode_page_manual_term_selection()=> '1',143 QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter()=> '1'144 ] 145 ]); 146 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_manual_selected_terms(), $field_options);164 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_MANUAL_TERM_SELECTION => '1', 165 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER => '1' 166 ] 167 ]); 168 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECTED_TERMS, $field_options); 147 169 148 170 //end manual term selection checkbox 149 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_posts_per_page());171 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POSTS_PER_PAGE); 150 172 $shortcode_page .= '</div>'; 151 173 $shortcode_page .= '<div class="quick-ajax-layout-settings" style="margin-top:20px">'; 152 174 $shortcode_page .= '<h4>'.esc_html__('Sorting Settings', 'quick-ajax-post-loader').'</h4>'; 153 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_order());154 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_orderby());175 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_ORDER); 176 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_ORDERBY); 155 177 $field_options = $this->field_options([ 156 178 'is_trigger' => true, 157 179 ]); 158 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_sort_button(), $field_options);159 $field_options = $this->field_options([ 160 'visible_if' => [ 161 QAPL_Quick_Ajax_ Helper::shortcode_page_show_sort_button()=> '1'162 ] 163 ]); 164 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_sort_button_options(), $field_options);165 $field_options = $this->field_options([ 166 'visible_if' => [ 167 QAPL_Quick_Ajax_ Helper::shortcode_page_show_sort_button()=> '1'168 ] 169 ]); 170 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_inline_filter_sorting(), $field_options);180 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON, $field_options); 181 $field_options = $this->field_options([ 182 'visible_if' => [ 183 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON => '1' 184 ] 185 ]); 186 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_SORT_BUTTON_OPTIONS, $field_options); 187 $field_options = $this->field_options([ 188 'visible_if' => [ 189 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON => '1' 190 ] 191 ]); 192 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_INLINE_FILTER_SORTING, $field_options); 171 193 $shortcode_page .= '</div>'; 172 194 $shortcode_page .= '<div class="quick-ajax-layout-settings" style="margin-top:20px">'; 173 195 $shortcode_page .= '<h4>'.esc_html__('Additional Settings', 'quick-ajax-post-loader').'</h4>'; 174 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_set_post_not_in());175 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_ignore_sticky_posts());176 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_ajax_on_initial_load());177 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_ajax_infinite_scroll());178 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_end_message());196 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SET_POST_NOT_IN); 197 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_IGNORE_STICKY_POSTS); 198 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_AJAX_ON_INITIAL_LOAD); 199 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_AJAX_INFINITE_SCROLL); 200 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_END_MESSAGE); 179 201 $shortcode_page .= '</div>'; 180 202 … … 185 207 'is_trigger' => true, 186 208 ]); 187 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_quick_ajax_css_style(), $field_options);188 $field_options = $this->field_options([ 189 'visible_if' => [ 190 QAPL_Quick_Ajax_ Helper::shortcode_page_layout_quick_ajax_css_style()=> '1'191 ] 192 ]); 193 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_select_columns_qty(), $field_options);194 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_post_item_template());195 $field_options = $this->field_options([ 196 'is_trigger' => false, 197 'visible_if' => [ 198 QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter()=> '1'199 ] 200 ]); 201 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_taxonomy_filter_class(), $field_options);202 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_layout_container_class());203 $field_options = $this->field_options([ 204 'is_trigger' => true, 205 ]); 206 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_show_custom_load_more_post_quantity(),$field_options);207 $field_options = $this->field_options([ 208 'is_trigger' => false, 209 'visible_if' => [ 210 QAPL_Quick_Ajax_ Helper::shortcode_page_show_custom_load_more_post_quantity()=> '1'211 ] 212 ]); 213 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_custom_load_more_post_quantity(), $field_options);214 $field_options = $this->field_options([ 215 'is_trigger' => true, 216 ]); 217 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_override_global_loader_icon(), $field_options);218 $field_options = $this->field_options([ 219 'is_trigger' => false, 220 'visible_if' => [ 221 QAPL_Quick_Ajax_ Helper::shortcode_page_override_global_loader_icon()=> '1'222 ] 223 ]); 224 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_ Helper::shortcode_page_select_loader_icon(), $field_options);209 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE, $field_options); 210 $field_options = $this->field_options([ 211 'visible_if' => [ 212 QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE => '1' 213 ] 214 ]); 215 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_SELECT_COLUMNS_QTY, $field_options); 216 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_POST_ITEM_TEMPLATE); 217 $field_options = $this->field_options([ 218 'is_trigger' => false, 219 'visible_if' => [ 220 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER => '1' 221 ] 222 ]); 223 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_TAXONOMY_FILTER_CLASS, $field_options); 224 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_CONTAINER_CLASS); 225 $field_options = $this->field_options([ 226 'is_trigger' => true, 227 ]); 228 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY, $field_options); 229 $field_options = $this->field_options([ 230 'is_trigger' => false, 231 'visible_if' => [ 232 QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY => '1' 233 ] 234 ]); 235 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_CUSTOM_LOAD_MORE_POST_QUANTITY, $field_options); 236 $field_options = $this->field_options([ 237 'is_trigger' => true, 238 ]); 239 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON, $field_options); 240 $field_options = $this->field_options([ 241 'is_trigger' => false, 242 'visible_if' => [ 243 QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON => '1' 244 ] 245 ]); 246 $shortcode_page .= $this->add_field(QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_SELECT_LOADER_ICON, $field_options); 225 247 $shortcode_page .= '</div>'; 226 248 … … 238 260 } 239 261 } 240 if ($post_type === QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug()) {241 $form = new QAPL_Quick_Ajax_Form_Creator(QAPL_Quick_Ajax_ Helper::settings_wrapper_id(), QAPL_Quick_Ajax_Helper::quick_ajax_shortcode_settings(), $post_type);262 if ($post_type === QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG) { 263 $form = new QAPL_Quick_Ajax_Form_Creator(QAPL_Quick_Ajax_Plugin_Constants::SETTINGS_WRAPPER_ID, QAPL_Quick_Ajax_Plugin_Constants::DB_POSTMETA_SHORTCODE_SETTINGS, $post_type); 242 264 } 243 265 } -
quick-ajax-post-loader/trunk/css/admin-style.css
r3337932 r3352831 191 191 flex: 1 1 0; 192 192 } 193 .quick-ajax-form-wrap .quick-ajax-field-container select,194 .quick-ajax-form-wrap .quick-ajax-field-container input{195 margin: 0;196 }197 193 .quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field > div, 198 194 .quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field > select, … … 200 196 max-width: 100%; 201 197 width: 100%; 198 margin: 0; 202 199 } 203 200 .quick-ajax-form-wrap .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options{ -
quick-ajax-post-loader/trunk/css/admin-style.min.css
r3337932 r3352831 1 #shortcode-box-wrap,.quick-ajax-form-wrap{--qapl-theme-color:#2271b1;--qapl-bg:#ffffff;--qapl-bg-muted:#f6f7f7;--qapl-border:#c3c4c7;--qapl-text-muted:#50575e;--qapl-switch-bg:#cccccc;--qapl-switch-shadow:rgba(0,0,0,0.5);--qapl-tab-bg:#dcdcdc;--qapl-code-bg:#fcfcfc}.light-style{--qapl-theme-color:#04a4cc}.modern-style{--qapl-theme-color:#3858e9}.blue-style{--qapl-theme-color:#e1a948}.coffee-style{--qapl-theme-color:#c7a589}.ectoplasm-style{--qapl-theme-color:#a3b745}.midnight-style{--qapl-theme-color:#e14d43}.ocean-style{--qapl-theme-color:#9ebaa0}.sunrise-style{--qapl-theme-color:#dd823b}#shortcode-box-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;margin-top:16px}#shortcode-box-wrap .shortcode-description{padding:0 2px;margin-bottom:4px}#shortcode-box-wrap .click-and-select-all{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-right:auto}#shortcode-box-wrap pre{margin:0;padding:10px 10px 11px;border:1px solid #8c8f94;border-radius:3px;background:var(--qapl-code-bg)}#shortcode-box-wrap code{line-height:1;background:var(--qapl-code-bg);white-space:pre-wrap;word-break:break-word;cursor:pointer}.quick-ajax-form-wrap .switch-checkbox{display:inline-block;min-height:30px}.quick-ajax-form-wrap .switch-wrap{position:relative;width:40px;height:20px;margin-top:6px}.quick-ajax-form-wrap .switch-wrap input{opacity:0;width:0;height:0}.quick-ajax-form-wrap .switch{border-radius:12px}.quick-ajax-form-wrap .switch:before{border-radius:50%}.quick-ajax-form-wrap input+.switch{position:absolute;cursor:pointer;top:-1px;left:0;right:0;bottom:1px;background-color:var(--qapl-switch-bg);-webkit-box-shadow:inset 0 0 3px var(--qapl-switch-shadow);box-shadow:inset 0 0 3px var(--qapl-switch-shadow);-webkit-transition:background-color .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease;transition:background-color .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease;transition:background-color .3s ease,box-shadow .3s ease,transform .3s ease;transition:background-color .3s ease,box-shadow .3s ease,transform .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease}.quick-ajax-form-wrap .switch:before{position:absolute;content:"";height:14px;width:14px;left:3px;bottom:3px;background-color:var(--qapl-bg);-webkit-transition:background-color .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease;transition:background-color .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease;transition:background-color .3s ease,box-shadow .3s ease,transform .3s ease;transition:background-color .3s ease,box-shadow .3s ease,transform .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease}.quick-ajax-form-wrap input:checked+.switch{background-color:var(--qapl-theme-color);-webkit-box-shadow:inset 0 0 3px var(--qapl-switch-shadow);box-shadow:inset 0 0 3px var(--qapl-switch-shadow)}.quick-ajax-form-wrap input:checked+.switch:before{-webkit-transform:translateX(20px);-ms-transform:translateX(20px);transform:translateX(20px)}.quick-ajax-form-wrap{margin-top:2rem;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.quick-ajax-form-wrap select:focus{border-color:var(--qapl-theme-color);-webkit-box-shadow:0 0 0 1px var(--qapl-theme-color);box-shadow:0 0 0 1px var(--qapl-theme-color)}.quick-ajax-form-wrap .quick-ajax-field-container{position:relative;width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;gap:16px;visibility:visible;opacity:1;margin-bottom:16px;-webkit-transition:opacity .15s ease,margin-bottom .15s ease;transition:opacity .15s ease,margin-bottom .15s ease}.quick-ajax-form-wrap .quick-ajax-field-container.inactive{visibility:hidden;height:0;opacity:0;margin-bottom:0}.quick-ajax-form-wrap .quick-ajax-field-container>label{-webkit-box-flex:0;-ms-flex:0 0 210px;flex:0 0 210px;margin-top:6px}.quick-ajax-form-wrap .quick-ajax-field-container>.quick-ajax-field{max-width:580px;-webkit-box-flex:1;-ms-flex:1 1 0px;flex:1 1 0}.quick-ajax-form-wrap .quick-ajax-field-container input,.quick-ajax-form-wrap .quick-ajax-field-container select{margin:0}.quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field>div,.quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field>input,.quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field>select{max-width:100%;width:100%}.quick-ajax-form-wrap .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.quick-ajax-form-wrap .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options>.quick-ajax-multiselect-option{-webkit-box-flex:0;-ms-flex:0 1 calc(100% / 3);flex:0 1 calc(100% / 3);min-width:180px;padding:6px 0;min-height:32px;-webkit-box-sizing:border-box;box-sizing:border-box}.quick-ajax-form-wrap .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options>.quick-ajax-multiselect-option label{cursor:pointer}.quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field-desc{margin-top:5px;margin-bottom:0;color:var(--qapl-text-muted);font-style:italic}@media (max-width:782px){.quick-ajax-form-wrap .quick-ajax-field-container>label{-ms-flex-preferred-size:100%;flex-basis:100%;margin-top:0;margin-right:0}.quick-ajax-form-wrap .quick-ajax-field-container>.quick-ajax-field{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}}.quick-ajax-tabs{display:-webkit-box;display:-ms-flexbox;display:flex;position:relative;overflow:hidden}.quick-ajax-tabs:before{content:'';position:absolute;width:100%;bottom:0;height:1px;background-color:var(--qapl-border)}.quick-ajax-tab-button{position:relative;padding:5px 10px;cursor:pointer;z-index:0;background:var(--qapl-tab-bg);border:1px solid var(--qapl-border);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-left-radius:0;border-bottom-right-radius:0;margin:0 5px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-transition:background-color .3s ease,border-color .3s ease;transition:background-color .3s ease,border-color .3s ease}.quick-ajax-tab-button:first-of-type{margin-left:0}.quick-ajax-tab-button:hover{background:var(--qapl-bg-mute)}.quick-ajax-tab-button.active{background:var(--qapl-bg);z-index:1;border-bottom:1px solid var(--qapl-bg)}.quick-ajax-tab-content,.quick-ajax-tab-content[hidden]{position:relative;background:var(--qapl-bg);padding:16px;border:1px solid var(--qapl-border);-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);display:none}.quick-ajax-tab-content.active{display:block}.quick-ajax-tab-content+.quick-ajax-tab-content,.quick-ajax-tabs+.quick-ajax-tab-content{border-top:none}.function-generator-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:start;-webkit-column-gap:100px;-moz-column-gap:100px;column-gap:100px}.function-generator-options{max-width:580px}.function-generator-options .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options>.quick-ajax-multiselect-option{min-width:50%}.function-generator-result{width:auto;-webkit-box-flex:1;-ms-flex:1;flex:1;max-width:480px}.function-generator-result>pre{overflow:auto}@media (max-width:1200px){.function-generator-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.function-generator-options,function-generator-result{width:100%;max-width:unset}}.quick-ajax-form-wrap code.no-background{background:0 0;padding:3px 0 2px;font-size:14px}.quick-ajax-form-wrap code.code-tag{padding:2px 4px 3px;margin:0 1px;background:rgba(0,0,0,.07)}.quick-ajax-form-wrap pre{white-space:pre-wrap;word-wrap:break-word}.quick-ajax-form-wrap ul.ul-numbered{list-style-type:decimal;padding-left:13px}.quick-ajax-form-wrap li ul{margin-top:6px}.quick-ajax-accordion-wrapper{position:relative;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap;overflow:hidden;margin-bottom:16px}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle{position:relative;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-wrap:wrap;flex-wrap:wrap;padding:0 1.5em;min-height:44px;background:var(--qapl-bg);border:1px solid var(--qapl-border);cursor:pointer;outline:unset}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle:hover{background:var(--qapl-bg-muted)}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle:active,.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle:focus{outline-width:2px;outline-style:solid;outline-offset:-2px;outline-color:var(--qapl-theme-color);background-color:var(--qapl-bg-muted);z-index:1}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle.active{background:var(--qapl-bg)}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle.active:hover{background:var(--qapl-bg-muted)}.quick-ajax-accordion-wrapper .accordion-title{max-width:calc(100% - 26px);font-size:13px;font-weight:600;line-height:1;margin:0}.quick-ajax-accordion-wrapper .accordion-icon{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-transform:rotateX(0);transform:rotateX(0);-webkit-transition:-webkit-transform .3s ease-in-out;transition:-webkit-transform .3s ease-in-out;transition:transform .3s ease-in-out;transition:transform .3s ease-in-out,-webkit-transform .3s ease-in-out}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle.active .accordion-icon{-webkit-transform:rotateX(180deg);transform:rotateX(180deg)}.quick-ajax-accordion-wrapper .accordion-icon span{pointer-events:none;position:absolute;border:solid #50575e;border-width:0 2px 2px 0;height:.5rem;width:.5rem;top:50%;right:0;-webkit-transform:translateY(-70%) rotate(45deg);-ms-transform:translateY(-70%) rotate(45deg);transform:translateY(-70%) rotate(45deg)}.quick-ajax-accordion-wrapper .quick-ajax-accordion-content{display:none;border:1px solid var(--qapl-border);border-top:none;padding:0 1.5em 1em 1.5em}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle.active+.quick-ajax-accordion-content:before{content:"";position:absolute;display:block;background:var(--qapl-bg);height:1px;left:1px;right:1px;margin-top:-1px}.qapl-admin-page-loader{position:relative;height:20px;width:40px;padding:6px 0;margin-left:0;vertical-align:middle}.qapl-admin-page-loader span{position:absolute;top:50%;left:0;width:6px;height:6px;background-color:#50575e;border-radius:50%;-webkit-transform:translate(0,-50%);-ms-transform:translate(0,-50%);transform:translate(0,-50%);opacity:0;-webkit-animation:qapl-admin-loader-animation 1.8s linear infinite;animation:qapl-admin-loader-animation 1.8s linear infinite}.qapl-admin-page-loader span:nth-child(1){-webkit-animation-delay:0s;animation-delay:0s}.qapl-admin-page-loader span:nth-child(2){-webkit-animation-delay:.6s;animation-delay:.6s}.qapl-admin-page-loader span:nth-child(3){-webkit-animation-delay:1.2s;animation-delay:1.2s}@-webkit-keyframes qapl-admin-loader-animation{0%{-webkit-transform:translate(0,-50%);transform:translate(0,-50%);opacity:0}10%{opacity:1}50%{-webkit-transform:translate(20px,-50%);transform:translate(20px,-50%);opacity:1}90%{opacity:0}100%{-webkit-transform:translate(40px,-50%);transform:translate(40px,-50%);opacity:0}}@keyframes qapl-admin-loader-animation{0%{-webkit-transform:translate(0,-50%);transform:translate(0,-50%);opacity:0}10%{opacity:1}50%{-webkit-transform:translate(20px,-50%);transform:translate(20px,-50%);opacity:1}90%{opacity:0}100%{-webkit-transform:translate(40px,-50%);transform:translate(40px,-50%);opacity:0}}1 #shortcode-box-wrap,.quick-ajax-form-wrap{--qapl-theme-color:#2271b1;--qapl-bg:#ffffff;--qapl-bg-muted:#f6f7f7;--qapl-border:#c3c4c7;--qapl-text-muted:#50575e;--qapl-switch-bg:#cccccc;--qapl-switch-shadow:rgba(0,0,0,0.5);--qapl-tab-bg:#dcdcdc;--qapl-code-bg:#fcfcfc}.light-style{--qapl-theme-color:#04a4cc}.modern-style{--qapl-theme-color:#3858e9}.blue-style{--qapl-theme-color:#e1a948}.coffee-style{--qapl-theme-color:#c7a589}.ectoplasm-style{--qapl-theme-color:#a3b745}.midnight-style{--qapl-theme-color:#e14d43}.ocean-style{--qapl-theme-color:#9ebaa0}.sunrise-style{--qapl-theme-color:#dd823b}#shortcode-box-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;margin-top:16px}#shortcode-box-wrap .shortcode-description{padding:0 2px;margin-bottom:4px}#shortcode-box-wrap .click-and-select-all{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap;margin-right:auto}#shortcode-box-wrap pre{margin:0;padding:10px 10px 11px;border:1px solid #8c8f94;border-radius:3px;background:var(--qapl-code-bg)}#shortcode-box-wrap code{line-height:1;background:var(--qapl-code-bg);white-space:pre-wrap;word-break:break-word;cursor:pointer}.quick-ajax-form-wrap .switch-checkbox{display:inline-block;min-height:30px}.quick-ajax-form-wrap .switch-wrap{position:relative;width:40px;height:20px;margin-top:6px}.quick-ajax-form-wrap .switch-wrap input{opacity:0;width:0;height:0}.quick-ajax-form-wrap .switch{border-radius:12px}.quick-ajax-form-wrap .switch:before{border-radius:50%}.quick-ajax-form-wrap input+.switch{position:absolute;cursor:pointer;top:-1px;left:0;right:0;bottom:1px;background-color:var(--qapl-switch-bg);-webkit-box-shadow:inset 0 0 3px var(--qapl-switch-shadow);box-shadow:inset 0 0 3px var(--qapl-switch-shadow);-webkit-transition:background-color .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease;transition:background-color .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease;transition:background-color .3s ease,box-shadow .3s ease,transform .3s ease;transition:background-color .3s ease,box-shadow .3s ease,transform .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease}.quick-ajax-form-wrap .switch:before{position:absolute;content:"";height:14px;width:14px;left:3px;bottom:3px;background-color:var(--qapl-bg);-webkit-transition:background-color .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease;transition:background-color .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease;transition:background-color .3s ease,box-shadow .3s ease,transform .3s ease;transition:background-color .3s ease,box-shadow .3s ease,transform .3s ease,-webkit-box-shadow .3s ease,-webkit-transform .3s ease}.quick-ajax-form-wrap input:checked+.switch{background-color:var(--qapl-theme-color);-webkit-box-shadow:inset 0 0 3px var(--qapl-switch-shadow);box-shadow:inset 0 0 3px var(--qapl-switch-shadow)}.quick-ajax-form-wrap input:checked+.switch:before{-webkit-transform:translateX(20px);-ms-transform:translateX(20px);transform:translateX(20px)}.quick-ajax-form-wrap{margin-top:2rem;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.quick-ajax-form-wrap select:focus{border-color:var(--qapl-theme-color);-webkit-box-shadow:0 0 0 1px var(--qapl-theme-color);box-shadow:0 0 0 1px var(--qapl-theme-color)}.quick-ajax-form-wrap .quick-ajax-field-container{position:relative;width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;gap:16px;visibility:visible;opacity:1;margin-bottom:16px;-webkit-transition:opacity .15s ease,margin-bottom .15s ease;transition:opacity .15s ease,margin-bottom .15s ease}.quick-ajax-form-wrap .quick-ajax-field-container.inactive{visibility:hidden;height:0;opacity:0;margin-bottom:0}.quick-ajax-form-wrap .quick-ajax-field-container>label{-webkit-box-flex:0;-ms-flex:0 0 210px;flex:0 0 210px;margin-top:6px}.quick-ajax-form-wrap .quick-ajax-field-container>.quick-ajax-field{max-width:580px;-webkit-box-flex:1;-ms-flex:1 1 0px;flex:1 1 0}.quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field>div,.quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field>input,.quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field>select{max-width:100%;width:100%;margin:0}.quick-ajax-form-wrap .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.quick-ajax-form-wrap .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options>.quick-ajax-multiselect-option{-webkit-box-flex:0;-ms-flex:0 1 calc(100% / 3);flex:0 1 calc(100% / 3);min-width:180px;padding:6px 0;min-height:32px;-webkit-box-sizing:border-box;box-sizing:border-box}.quick-ajax-form-wrap .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options>.quick-ajax-multiselect-option label{cursor:pointer}.quick-ajax-form-wrap .quick-ajax-field-container .quick-ajax-field-desc{margin-top:5px;margin-bottom:0;color:var(--qapl-text-muted);font-style:italic}@media (max-width:782px){.quick-ajax-form-wrap .quick-ajax-field-container>label{-ms-flex-preferred-size:100%;flex-basis:100%;margin-top:0;margin-right:0}.quick-ajax-form-wrap .quick-ajax-field-container>.quick-ajax-field{-ms-flex-preferred-size:100%;flex-basis:100%;max-width:100%}}.quick-ajax-tabs{display:-webkit-box;display:-ms-flexbox;display:flex;position:relative;overflow:hidden}.quick-ajax-tabs:before{content:'';position:absolute;width:100%;bottom:0;height:1px;background-color:var(--qapl-border)}.quick-ajax-tab-button{position:relative;padding:5px 10px;cursor:pointer;z-index:0;background:var(--qapl-tab-bg);border:1px solid var(--qapl-border);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-left-radius:0;border-bottom-right-radius:0;margin:0 5px;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-transition:background-color .3s ease,border-color .3s ease;transition:background-color .3s ease,border-color .3s ease}.quick-ajax-tab-button:first-of-type{margin-left:0}.quick-ajax-tab-button:hover{background:var(--qapl-bg-mute)}.quick-ajax-tab-button.active{background:var(--qapl-bg);z-index:1;border-bottom:1px solid var(--qapl-bg)}.quick-ajax-tab-content,.quick-ajax-tab-content[hidden]{position:relative;background:var(--qapl-bg);padding:16px;border:1px solid var(--qapl-border);-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);display:none}.quick-ajax-tab-content.active{display:block}.quick-ajax-tab-content+.quick-ajax-tab-content,.quick-ajax-tabs+.quick-ajax-tab-content{border-top:none}.function-generator-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:start;-webkit-column-gap:100px;-moz-column-gap:100px;column-gap:100px}.function-generator-options{max-width:580px}.function-generator-options .quick-ajax-field-container.quick-ajax-multiselect-field .quick-ajax-field .quick-ajax-field-options>.quick-ajax-multiselect-option{min-width:50%}.function-generator-result{width:auto;-webkit-box-flex:1;-ms-flex:1;flex:1;max-width:480px}.function-generator-result>pre{overflow:auto}@media (max-width:1200px){.function-generator-wrap{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.function-generator-options,function-generator-result{width:100%;max-width:unset}}.quick-ajax-form-wrap code.no-background{background:0 0;padding:3px 0 2px;font-size:14px}.quick-ajax-form-wrap code.code-tag{padding:2px 4px 3px;margin:0 1px;background:rgba(0,0,0,.07)}.quick-ajax-form-wrap pre{white-space:pre-wrap;word-wrap:break-word}.quick-ajax-form-wrap ul.ul-numbered{list-style-type:decimal;padding-left:13px}.quick-ajax-form-wrap li ul{margin-top:6px}.quick-ajax-accordion-wrapper{position:relative;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:wrap;flex-wrap:wrap;overflow:hidden;margin-bottom:16px}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle{position:relative;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-wrap:wrap;flex-wrap:wrap;padding:0 1.5em;min-height:44px;background:var(--qapl-bg);border:1px solid var(--qapl-border);cursor:pointer;outline:unset}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle:hover{background:var(--qapl-bg-muted)}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle:active,.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle:focus{outline-width:2px;outline-style:solid;outline-offset:-2px;outline-color:var(--qapl-theme-color);background-color:var(--qapl-bg-muted);z-index:1}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle.active{background:var(--qapl-bg)}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle.active:hover{background:var(--qapl-bg-muted)}.quick-ajax-accordion-wrapper .accordion-title{max-width:calc(100% - 26px);font-size:13px;font-weight:600;line-height:1;margin:0}.quick-ajax-accordion-wrapper .accordion-icon{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-transform:rotateX(0);transform:rotateX(0);-webkit-transition:-webkit-transform .3s ease-in-out;transition:-webkit-transform .3s ease-in-out;transition:transform .3s ease-in-out;transition:transform .3s ease-in-out,-webkit-transform .3s ease-in-out}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle.active .accordion-icon{-webkit-transform:rotateX(180deg);transform:rotateX(180deg)}.quick-ajax-accordion-wrapper .accordion-icon span{pointer-events:none;position:absolute;border:solid #50575e;border-width:0 2px 2px 0;height:.5rem;width:.5rem;top:50%;right:0;-webkit-transform:translateY(-70%) rotate(45deg);-ms-transform:translateY(-70%) rotate(45deg);transform:translateY(-70%) rotate(45deg)}.quick-ajax-accordion-wrapper .quick-ajax-accordion-content{display:none;border:1px solid var(--qapl-border);border-top:none;padding:0 1.5em 1em 1.5em}.quick-ajax-accordion-wrapper .quick-ajax-accordion-toggle.active+.quick-ajax-accordion-content:before{content:"";position:absolute;display:block;background:var(--qapl-bg);height:1px;left:1px;right:1px;margin-top:-1px}.qapl-admin-page-loader{position:relative;height:20px;width:40px;padding:6px 0;margin-left:0;vertical-align:middle}.qapl-admin-page-loader span{position:absolute;top:50%;left:0;width:6px;height:6px;background-color:#50575e;border-radius:50%;-webkit-transform:translate(0,-50%);-ms-transform:translate(0,-50%);transform:translate(0,-50%);opacity:0;-webkit-animation:qapl-admin-loader-animation 1.8s linear infinite;animation:qapl-admin-loader-animation 1.8s linear infinite}.qapl-admin-page-loader span:nth-child(1){-webkit-animation-delay:0s;animation-delay:0s}.qapl-admin-page-loader span:nth-child(2){-webkit-animation-delay:.6s;animation-delay:.6s}.qapl-admin-page-loader span:nth-child(3){-webkit-animation-delay:1.2s;animation-delay:1.2s}@-webkit-keyframes qapl-admin-loader-animation{0%{-webkit-transform:translate(0,-50%);transform:translate(0,-50%);opacity:0}10%{opacity:1}50%{-webkit-transform:translate(20px,-50%);transform:translate(20px,-50%);opacity:1}90%{opacity:0}100%{-webkit-transform:translate(40px,-50%);transform:translate(40px,-50%);opacity:0}}@keyframes qapl-admin-loader-animation{0%{-webkit-transform:translate(0,-50%);transform:translate(0,-50%);opacity:0}10%{opacity:1}50%{-webkit-transform:translate(20px,-50%);transform:translate(20px,-50%);opacity:1}90%{opacity:0}100%{-webkit-transform:translate(40px,-50%);transform:translate(40px,-50%);opacity:0}} -
quick-ajax-post-loader/trunk/inc/actions.php
r3321429 r3352831 11 11 } 12 12 // nonce verification 13 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), QAPL_Quick_Ajax_ Helper::wp_nonce_form_quick_ajax_action())) {13 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), QAPL_Quick_Ajax_Plugin_Constants::NONCE_FORM_QUICK_AJAX_ACTION)) { 14 14 wp_send_json_error(['message' => 'Quick Ajax Post Loader: Unauthorized request']); 15 15 } … … 18 18 wp_send_json_error(['message' => 'Quick Ajax Post Loader: Invalid request, Missing arguments.']); 19 19 } else { 20 $ qapl_helper = QAPL_Quick_Ajax_Helper::get_instance();21 $ajax_class = new QAPL_Quick_Ajax_Handler ;20 $file_manager = new QAPL_Quick_Ajax_File_Manager(); 21 $ajax_class = new QAPL_Quick_Ajax_Handler($file_manager); 22 22 23 23 // Sanitize 'args' … … 64 64 while ($query->have_posts()) { 65 65 $query->the_post(); 66 $template_path = $ qapl_helper->plugin_templates_post_item_template(esc_attr($ajax_class->attributes[QAPL_Quick_Ajax_Helper::layout_post_item_template()]));66 $template_path = $file_manager->get_post_item_template(esc_attr($ajax_class->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_POST_ITEM_TEMPLATE])); 67 67 if (!$template_path || !file_exists($template_path)) { 68 68 wp_send_json_error(['message' => 'Quick Ajax Post Loader: Template file not found']); … … 79 79 $qapl_no_post_template = QAPL_Post_Template_Factory::get_template($container_settings); 80 80 QAPL_Post_Template_Context::set_template($qapl_no_post_template); 81 $no_posts_template = $ qapl_helper->plugin_templates_no_posts();81 $no_posts_template = $file_manager->get_no_posts_template(); 82 82 if (!$no_posts_template || !file_exists($no_posts_template)) { 83 83 wp_send_json_error(['message' => 'Quick Ajax Post Loader: Template file not found']); … … 90 90 $output = ob_get_clean(); 91 91 $load_more = $ajax_class->load_more_button(esc_attr($query->get('paged')), esc_attr($query->max_num_pages), esc_attr($query->found_posts), esc_attr($ajax_class->attributes['infinite_scroll'])); 92 $show_end_message = $ajax_class->render_end_of_posts_message($ ajax_class->attributes['show_end_message'], $load_more, esc_attr($query->max_num_pages), esc_attr($ajax_class->attributes['quick_ajax_id']));92 $show_end_message = $ajax_class->render_end_of_posts_message($load_more, esc_attr($query->max_num_pages), esc_attr($ajax_class->attributes['quick_ajax_id']), $ajax_class->attributes['show_end_message']); 93 93 94 94 … … 111 111 wp_send_json_error(['message' => 'Quick Ajax Post Loader: Not an AJAX request']); 112 112 } 113 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), QAPL_Quick_Ajax_ Helper::wp_nonce_form_quick_ajax_action())) {113 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), QAPL_Quick_Ajax_Plugin_Constants::NONCE_FORM_QUICK_AJAX_ACTION)) { 114 114 wp_send_json_error(['message' => 'Quick Ajax Post Loader: Unauthorized request']); 115 115 } … … 144 144 wp_send_json_error(['message' => 'Quick Ajax Post Loader: Not an AJAX request']); 145 145 } 146 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), QAPL_Quick_Ajax_ Helper::wp_nonce_form_quick_ajax_action())) {146 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), QAPL_Quick_Ajax_Plugin_Constants::NONCE_FORM_QUICK_AJAX_ACTION)) { 147 147 wp_send_json_error(['message' => 'Quick Ajax Post Loader: Unauthorized request']); 148 148 } … … 169 169 if ($post_id > 0) { 170 170 // get saved terms from post meta 171 $post_meta = get_post_meta($post_id, QAPL_Quick_Ajax_ Helper::quick_ajax_shortcode_settings(), true);171 $post_meta = get_post_meta($post_id, QAPL_Quick_Ajax_Plugin_Constants::DB_POSTMETA_SHORTCODE_SETTINGS, true); 172 172 $post_meta_values = maybe_unserialize($post_meta); 173 173 // if terms exist in post meta -
quick-ajax-post-loader/trunk/inc/class-activator.php
r3199656 r3352831 7 7 public static function activate() { 8 8 require_once plugin_dir_path(__FILE__) . 'class-helper.php'; 9 $qapl_helper = QAPL_Quick_Ajax_Helper::get_instance();10 9 $default_value = [ 11 'loader_icon' => $qapl_helper::shortcode_page_select_loader_icon_default_value(),10 'loader_icon' => QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_SELECT_LOADER_ICON_DEFAULT, 12 11 ]; 13 $qapl_helper::add_or_update_option_autoload($qapl_helper::admin_page_global_options_name(), $default_value, 'off');12 QAPL_Quick_Ajax_Utilities::add_or_update_option_autoload(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME, $default_value, 'off'); 14 13 } 15 14 } -
quick-ajax-post-loader/trunk/inc/class-ajax.php
r3321429 r3352831 6 6 if (!class_exists('QAPL_Quick_Ajax_Handler')) { 7 7 class QAPL_Quick_Ajax_Handler{ 8 private static $instance = null; 9 private $helper; 8 private $file_manager; 10 9 private $input_args = []; 11 10 private $action_args = []; … … 18 17 //private $placeholder_replacer; 19 18 20 public function __construct(){ 21 $this->helper = QAPL_Quick_Ajax_Helper::get_instance(); 19 public function __construct(QAPL_Quick_Ajax_File_Manager $file_manager){ 22 20 $this->quick_ajax_id = 0; 23 $this->global_options = get_option($this->helper->admin_page_global_options_name(), []); 21 $this->global_options = get_option(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME, []); 22 $this->file_manager = $file_manager; 24 23 //$this->placeholder_replacer = new QAPL_Placeholder_Replacer(); // not in use after removing placeholders 25 24 // Filter hooks for filter wrapper 26 25 /* 27 add_action(QAPL_ Hooks::HOOK_FILTER_CONTAINER_BEFORE, array($this, 'action_filter_wrapper_pre'));28 add_action(QAPL_ Hooks::HOOK_FILTER_CONTAINER_START, array($this, 'action_filter_wrapper_open'));29 add_action(QAPL_ Hooks::HOOK_FILTER_CONTAINER_END, array($this, 'action_filter_wrapper_close'));30 add_action(QAPL_ Hooks::HOOK_FILTER_CONTAINER_AFTER, array($this, 'action_filter_wrapper_complete'));26 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_BEFORE, array($this, 'action_filter_wrapper_pre')); 27 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_START, array($this, 'action_filter_wrapper_open')); 28 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_END, array($this, 'action_filter_wrapper_close')); 29 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_AFTER, array($this, 'action_filter_wrapper_complete')); 31 30 32 31 // Filter hooks for posts wrapper 33 add_action(QAPL_ Hooks::HOOK_POSTS_CONTAINER_BEFORE, array($this, 'action_posts_wrapper_pre'));34 add_action(QAPL_ Hooks::HOOK_POSTS_CONTAINER_START, array($this, 'action_posts_wrapper_open'));35 add_action(QAPL_ Hooks::HOOK_POSTS_CONTAINER_END, array($this, 'action_posts_wrapper_close'));36 add_action(QAPL_ Hooks::HOOK_POSTS_CONTAINER_AFTER, array($this, 'action_posts_wrapper_complete'));32 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_BEFORE, array($this, 'action_posts_wrapper_pre')); 33 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_START, array($this, 'action_posts_wrapper_open')); 34 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_END, array($this, 'action_posts_wrapper_close')); 35 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_AFTER, array($this, 'action_posts_wrapper_complete')); 37 36 38 37 // Filter hooks for load more button 39 add_action(QAPL_ Hooks::HOOK_LOAD_MORE_BEFORE, array($this, 'action_load_more_button_pre'));40 add_action(QAPL_ Hooks::HOOK_LOAD_MORE_AFTER, array($this, 'action_load_more_button_complete'));38 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOAD_MORE_BEFORE, array($this, 'action_load_more_button_pre')); 39 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOAD_MORE_AFTER, array($this, 'action_load_more_button_complete')); 41 40 42 41 // Filter hooks for loader icon 43 add_action(QAPL_ Hooks::HOOK_LOADER_BEFORE, array($this, 'action_loader_icon_pre'));44 add_action(QAPL_ Hooks::HOOK_LOADER_AFTER, array($this, 'action_loader_icon_complete'));42 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOADER_BEFORE, array($this, 'action_loader_icon_pre')); 43 add_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOADER_AFTER, array($this, 'action_loader_icon_complete')); 45 44 */ 46 45 // Filters with arguments (query and taxonomy buttons) 47 //add_filter(QAPL_Hooks::HOOK_MODIFY_POSTS_QUERY_ARGS, array($this, 'filter_modify_query_args'), 10, 2); 48 //add_filter(QAPL_Hooks::HOOK_MODIFY_TAXONOMY_FILTER_BUTTONS, array($this, 'filter_modify_taxonomy_filter_buttons'), 10, 2); 49 } 50 51 public static function get_instance() { 52 if (null === self::$instance) { 53 self::$instance = new self(); 54 } 55 return self::$instance; 56 } 46 //add_filter(QAPL_Quick_Ajax_Plugin_Constants::HOOK_MODIFY_POSTS_QUERY_ARGS, array($this, 'filter_modify_query_args'), 10, 2); 47 //add_filter(QAPL_Quick_Ajax_Plugin_Constants::HOOK_MODIFY_TAXONOMY_FILTER_BUTTONS, array($this, 'filter_modify_taxonomy_filter_buttons'), 10, 2); 48 } 49 57 50 58 51 public function get_quick_ajax_id() { … … 78 71 private function generate_block_id($attributes = false) { 79 72 if (!is_array($attributes)) { 80 $attributes = [ $this->helper->layout_quick_ajax_id()=> sanitize_text_field($attributes)];81 } 82 if (isset($attributes[ $this->helper->layout_quick_ajax_id()])) {73 $attributes = [QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID => sanitize_text_field($attributes)]; 74 } 75 if (isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID])) { 83 76 // Prefix 'p' for 'shortcode' equal to true, otherwise 'c' 84 77 $prefix = (isset($attributes['shortcode']) && $attributes['shortcode'] === true) ? 'p' : 'c'; 85 $this->quick_ajax_id = esc_attr($prefix . $attributes[ $this->helper->layout_quick_ajax_id()]);78 $this->quick_ajax_id = esc_attr($prefix . $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID]); 86 79 } else { 87 80 // Increment qapl_id if 'quick_ajax_id' is not set … … 137 130 $quick_ajax_args = $this->initialize_query_args($this->input_args); 138 131 139 $this->args['post_status'] = $this->helper->shortcode_page_select_post_status_default_value();132 $this->args['post_status'] = QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POST_STATUS_DEFAULT; 140 133 141 134 if (isset($quick_ajax_args['post_type']) && !empty($quick_ajax_args['post_type'])) { … … 152 145 */ 153 146 154 $this->args = apply_filters(QAPL_ Hooks::HOOK_MODIFY_POSTS_QUERY_ARGS, $this->args, $this->quick_ajax_id);147 $this->args = apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_MODIFY_POSTS_QUERY_ARGS, $this->args, $this->quick_ajax_id); 155 148 156 149 if (empty($this->args)) { … … 170 163 return [ 171 164 'post_type' => isset($args['post_type']) ? sanitize_text_field($args['post_type']) : null, 172 'posts_per_page' => isset($args['posts_per_page']) ? intval($args['posts_per_page']) : $this->helper->shortcode_page_select_posts_per_page_default_value(),173 'orderby' => isset($args['orderby']) ? sanitize_text_field($args['orderby']) : $this->helper->shortcode_page_select_orderby_default_value(),174 'order' => isset($args['order']) ? sanitize_text_field($args['order']) : $this->helper->shortcode_page_select_order_default_value(),165 'posts_per_page' => isset($args['posts_per_page']) ? intval($args['posts_per_page']) : QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POSTS_PER_PAGE_DEFAULT, 166 'orderby' => isset($args['orderby']) ? sanitize_text_field($args['orderby']) : QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_ORDERBY_DEFAULT, 167 'order' => isset($args['order']) ? sanitize_text_field($args['order']) : QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_ORDER_DEFAULT, 175 168 'post__not_in' => $args['post__not_in'] ?? [], 176 'ignore_sticky_posts' => isset($args['ignore_sticky_posts']) ? intval($args['ignore_sticky_posts']) : $this->helper->shortcode_page_ignore_sticky_posts_default_value(),169 'ignore_sticky_posts' => isset($args['ignore_sticky_posts']) ? intval($args['ignore_sticky_posts']) : QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_IGNORE_STICKY_POSTS_DEFAULT, 177 170 'paged' => isset($args['paged']) ? intval($args['paged']) : 1, 178 171 ]; … … 287 280 $block_id = 'quick-ajax-filter-'.$this->quick_ajax_id; 288 281 $class_container = 'quick-ajax-filter-container'; 289 if (isset($this->layout[ $this->helper->layout_quick_ajax_css_style()]) && $this->layout[$this->helper->layout_quick_ajax_css_style()] != 0) {282 if (isset($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE]) && $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE] != 0) { 290 283 $class_container .= ' quick-ajax-theme'; 291 284 } 292 if(isset($this->layout[ $this->helper->layout_taxonomy_filter_class()]) && !empty(trim($this->layout[$this->helper->layout_taxonomy_filter_class()]))){293 $class_container .= ' '.$this->layout[ $this->helper->layout_taxonomy_filter_class()];285 if(isset($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_TAXONOMY_FILTER_CLASS]) && !empty(trim($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_TAXONOMY_FILTER_CLASS]))){ 286 $class_container .= ' '.$this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_TAXONOMY_FILTER_CLASS]; 294 287 } 295 288 $container_class = $this->extract_classes_from_string($class_container); … … 297 290 ob_start(); // Start output buffering 298 291 299 do_action(QAPL_ Hooks::HOOK_FILTER_CONTAINER_BEFORE, $this->quick_ajax_id);292 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_BEFORE, $this->quick_ajax_id); 300 293 echo '<div id="'.esc_attr($block_id).'" class="'.esc_attr($container_class).'">'; 301 do_action(QAPL_ Hooks::HOOK_FILTER_CONTAINER_START, $this->quick_ajax_id);294 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_START, $this->quick_ajax_id); 302 295 if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { 303 $this->attributes[ $this->helper->layout_quick_ajax_id()] = $this->quick_ajax_id;296 $this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID] = $this->quick_ajax_id; 304 297 305 298 $navigation_buttons = []; 306 299 $button_base = [ 307 'data-button' => $this->helper->taxonomy_filter_button_data_button(),308 'template' => $this-> helper->plugin_templates_taxonomy_filter_button(),300 'data-button' => QAPL_Quick_Ajax_Plugin_Constants::TERM_FILTER_BUTTON_DATA_BUTTON, 301 'template' => $this->file_manager->get_taxonomy_filter_button_template(), 309 302 'data-attributes' => $this->attributes, 310 303 ]; … … 339 332 } 340 333 341 $navigation_buttons = apply_filters(QAPL_ Hooks::HOOK_MODIFY_TAXONOMY_FILTER_BUTTONS, $navigation_buttons, $this->quick_ajax_id);334 $navigation_buttons = apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_MODIFY_TAXONOMY_FILTER_BUTTONS, $navigation_buttons, $this->quick_ajax_id); 342 335 $filter_buttons=''; 343 336 foreach ( $navigation_buttons as $button ) { … … 346 339 echo wp_kses_post($filter_buttons); 347 340 } 348 do_action(QAPL_ Hooks::HOOK_FILTER_CONTAINER_END, $this->quick_ajax_id);341 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_END, $this->quick_ajax_id); 349 342 echo '</div>'; 350 do_action(QAPL_ Hooks::HOOK_FILTER_CONTAINER_AFTER, $this->quick_ajax_id);343 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_AFTER, $this->quick_ajax_id); 351 344 352 345 $output = ob_get_clean(); // Get the buffered content into a variable … … 357 350 $block_id = 'quick-ajax-sort-options-'.$this->quick_ajax_id; 358 351 $class_container = 'quick-ajax-sort-options-container'; 359 if (isset($this->layout[ $this->helper->layout_quick_ajax_css_style()]) && $this->layout[$this->helper->layout_quick_ajax_css_style()] != 0) {352 if (isset($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE]) && $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE] != 0) { 360 353 $class_container .= ' quick-ajax-theme'; 361 354 } … … 396 389 echo '<div id="'.esc_attr($block_id).'" class="'.esc_attr($container_class).'">'; 397 390 if(isset($sort_options) && is_array($sort_options)){ 398 $default_sort_options = $this->helper->shortcode_page_select_sort_button_options_values(); 391 $field = QAPL_Quick_Ajax_Form_Field_Factory::build_select_sort_button_options_field(); 392 $default_sort_options = $field->get_options(); 399 393 $label_map = []; 400 394 foreach ($default_sort_options as $option) { … … 415 409 ]; 416 410 } 417 $sorted_options = apply_filters(QAPL_ Hooks::HOOK_MODIFY_SORTING_OPTIONS_VARIANTS, $sorted_options, $this->quick_ajax_id);411 $sorted_options = apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_MODIFY_SORTING_OPTIONS_VARIANTS, $sorted_options, $this->quick_ajax_id); 418 412 $filtered_orderby_options = []; 419 413 foreach ($sorted_options as $option) { … … 441 435 } 442 436 private function create_sort_button($button_data) { 443 $this->attributes[ $this->helper->layout_quick_ajax_id()] = $this->quick_ajax_id;437 $this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID] = $this->quick_ajax_id; 444 438 $sort_option = '<div class="quick-ajax-sort-option-wrapper">'; 445 439 $default_option = strtolower($this->args['orderby']).'-'.strtolower($this->args['order']); … … 454 448 } 455 449 $sort_option .= '</select>'; 456 $sort_option .= '<span class="quick-ajax-settings" data-button="'. $this->helper->sort_option_button_data_button().'" data-attributes="' . esc_attr(wp_json_encode($this->attributes)) . '" data-action="' . esc_attr(wp_json_encode($this->action_args)) . '"></span>';450 $sort_option .= '<span class="quick-ajax-settings" data-button="'.QAPL_Quick_Ajax_Plugin_Constants::SORT_OPTION_BUTTON_DATA_BUTTON.'" data-attributes="' . esc_attr(wp_json_encode($this->attributes)) . '" data-action="' . esc_attr(wp_json_encode($this->action_args)) . '"></span>'; 457 451 $sort_option .= '</div>'; 458 452 return $sort_option; … … 464 458 return ''; 465 459 } 466 if($button_data['data-button'] == $this->helper->load_more_button_data_button()){460 if($button_data['data-button'] == QAPL_Quick_Ajax_Plugin_Constants::LOAD_MORE_BUTTON_DATA_BUTTON){ 467 461 $load_more_settings = [ 468 462 'quick_ajax_id' => $this->quick_ajax_id, … … 578 572 $this->layout = []; 579 573 //Apply quick AJAX CSS Style 580 $this->layout[ $this->helper->layout_quick_ajax_css_style()] = (isset($attributes[$this->helper->layout_quick_ajax_css_style()])) ? esc_attr($attributes[$this->helper->layout_quick_ajax_css_style()]) : 0;574 $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE] = (isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE])) ? esc_attr($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE]) : 0; 581 575 //Number of columns 582 $this->layout[ $this->helper->layout_container_num_columns()] = (isset($attributes[$this->helper->layout_container_num_columns()])) ? esc_attr($attributes[$this->helper->layout_container_num_columns()]) : 0;576 $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_GRID_NUM_COLUMNS] = (isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_GRID_NUM_COLUMNS])) ? esc_attr($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_GRID_NUM_COLUMNS]) : 0; 583 577 //add custom class for taxonomy filter 584 if(isset($attributes[ $this->helper->layout_taxonomy_filter_class()])){585 $this->layout[ $this->helper->layout_taxonomy_filter_class()] = $this->extract_classes_from_string($attributes[$this->helper->layout_taxonomy_filter_class()]);578 if(isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_TAXONOMY_FILTER_CLASS])){ 579 $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_TAXONOMY_FILTER_CLASS] = $this->extract_classes_from_string($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_TAXONOMY_FILTER_CLASS]); 586 580 } 587 581 //Add class to post container 588 if(isset($attributes[ $this->helper->layout_container_class()])){589 $this->layout[ $this->helper->layout_container_class()] = $this->extract_classes_from_string($attributes[$this->helper->layout_container_class()]);582 if(isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_CONTAINER_CLASS])){ 583 $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_CONTAINER_CLASS] = $this->extract_classes_from_string($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_CONTAINER_CLASS]); 590 584 } 591 585 //Post Item Template 592 $post_item_template = isset($attributes[ $this->helper->layout_post_item_template()]) ? $attributes[$this->helper->layout_post_item_template()] : false;593 $this->layout[ $this->helper->layout_post_item_template()] = $this->helper->plugin_templates_post_item_template($post_item_template);594 $this->attributes[ $this->helper->layout_post_item_template()] = $post_item_template;586 $post_item_template = isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_POST_ITEM_TEMPLATE]) ? $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_POST_ITEM_TEMPLATE] : false; 587 $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_POST_ITEM_TEMPLATE] = $this->file_manager->get_post_item_template($post_item_template); 588 $this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_POST_ITEM_TEMPLATE] = $post_item_template; 595 589 //Custom Load More Post Quantity 596 if(isset($attributes[ $this->helper->layout_load_more_posts()])){597 $this->attributes[ $this->helper->layout_load_more_posts()] = intval($attributes[$this->helper->layout_load_more_posts()]);590 if(isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOAD_MORE_POSTS])){ 591 $this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOAD_MORE_POSTS] = intval($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOAD_MORE_POSTS]); 598 592 } 599 593 //Select Loader Icon 600 if (isset($attributes[ $this->helper->layout_select_loader_icon()]) && !empty($attributes[$this->helper->layout_select_loader_icon()])) {601 $loader_icon = $attributes[ $this->helper->layout_select_loader_icon()];594 if (isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOADER_ICON]) && !empty($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOADER_ICON])) { 595 $loader_icon = $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOADER_ICON]; 602 596 } elseif (isset($this->global_options['loader_icon']) && !empty($this->global_options['loader_icon'])) { 603 597 // fallback to global option if attributes value is invalid … … 605 599 } else { 606 600 // final fallback to default value 607 $loader_icon = $this->helper->shortcode_page_select_loader_icon_default_value();608 } 609 $this->layout[ $this->helper->layout_select_loader_icon()] = $this->helper->plugin_templates_loader_icon_template($loader_icon);610 $this->attributes[ $this->helper->layout_select_loader_icon()] = $loader_icon;601 $loader_icon = QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_SELECT_LOADER_ICON_DEFAULT; 602 } 603 $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOADER_ICON] = $this->file_manager->get_loader_icon_template($loader_icon); 604 $this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOADER_ICON] = $loader_icon; 611 605 // infinite_scroll 612 if(isset($attributes[ $this->helper->layout_ajax_infinite_scroll()])){613 $this->attributes[ $this->helper->layout_ajax_infinite_scroll()] = intval($attributes[$this->helper->layout_ajax_infinite_scroll()]);606 if(isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_AJAX_INFINITE_SCROLL])){ 607 $this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_AJAX_INFINITE_SCROLL] = intval($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_AJAX_INFINITE_SCROLL]); 614 608 } 615 609 // show_end_message 616 if(isset($attributes[ $this->helper->layout_show_end_message()])){617 $this->attributes[ $this->helper->layout_show_end_message()] = intval($attributes[$this->helper->layout_show_end_message()]);618 } 619 $this->ajax_initial_load = isset($attributes[ $this->helper->query_settings_ajax_on_initial_load()]) ? intval($attributes[$this->helper->query_settings_ajax_on_initial_load()]) : $this->helper->shortcode_page_ajax_on_initial_load_default_value();610 if(isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_SHOW_END_MESSAGE])){ 611 $this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_SHOW_END_MESSAGE] = intval($attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_SHOW_END_MESSAGE]); 612 } 613 $this->ajax_initial_load = isset($attributes[QAPL_Quick_Ajax_Plugin_Constants::AJAX_SETTING_AJAX_INITIAL_LOAD]) ? intval($attributes[QAPL_Quick_Ajax_Plugin_Constants::AJAX_SETTING_AJAX_INITIAL_LOAD]) : QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_AJAX_ON_INITIAL_LOAD_DEFAULT; 620 614 } 621 615 … … 629 623 $args['selected_terms'] = isset($this->input_args['selected_terms']) && is_array($this->input_args['selected_terms']) ? array_map('absint', $this->input_args['selected_terms']) : []; 630 624 $query = new WP_Query($args); 631 $this->attributes[ $this->helper->layout_quick_ajax_id()] = $this->quick_ajax_id;632 $layout_quick_ajax_id = esc_attr($this->attributes[ $this->helper->layout_quick_ajax_id()]);625 $this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID] = $this->quick_ajax_id; 626 $layout_quick_ajax_id = esc_attr($this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID]); 633 627 $class_container = $class_inner_container = ''; 634 if (isset($this->layout[ $this->helper->layout_quick_ajax_css_style()]) && $this->layout[$this->helper->layout_quick_ajax_css_style()] != 0) {628 if (isset($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE]) && $this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE] != 0) { 635 629 $class_container .= 'quick-ajax-theme'; 636 630 } 637 if(isset($this->layout[ $this->helper->layout_container_num_columns()]) && (!empty($this->layout[$this->helper->layout_container_num_columns()]))){638 $class_inner_container .= 'col-qty-'.$this->layout[ $this->helper->layout_container_num_columns()];639 } 640 if(isset($this->layout[ $this->helper->layout_container_class()]) && !empty(trim($this->layout[$this->helper->layout_container_class()]))){641 $class_inner_container .= ' '.$this->layout[ $this->helper->layout_container_class()];631 if(isset($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_GRID_NUM_COLUMNS]) && (!empty($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_GRID_NUM_COLUMNS]))){ 632 $class_inner_container .= 'col-qty-'.$this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_GRID_NUM_COLUMNS]; 633 } 634 if(isset($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_CONTAINER_CLASS]) && !empty(trim($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_CONTAINER_CLASS]))){ 635 $class_inner_container .= ' '.$this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_CONTAINER_CLASS]; 642 636 } 643 637 $container_class = $this->extract_classes_from_string($class_container); … … 645 639 ob_start(); 646 640 // Start output buffering 647 do_action(QAPL_ Hooks::HOOK_POSTS_CONTAINER_BEFORE, $this->quick_ajax_id);641 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_BEFORE, $this->quick_ajax_id); 648 642 echo '<div id="quick-ajax-'.esc_attr($layout_quick_ajax_id).'" class="quick-ajax-posts-container '.esc_attr($container_class).'">'; 649 do_action(QAPL_ Hooks::HOOK_POSTS_CONTAINER_START, $this->quick_ajax_id);643 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_START, $this->quick_ajax_id); 650 644 echo '<div class="quick-ajax-posts-wrapper '.esc_attr($container_inner_class).'">'; 651 645 … … 663 657 while ($query->have_posts()) { 664 658 $query->the_post(); 665 include($this->layout[ $this->helper->layout_post_item_template()]);659 include($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_POST_ITEM_TEMPLATE]); 666 660 } 667 661 } … … 675 669 $qapl_no_post_template = QAPL_Post_Template_Factory::get_template($container_settings); 676 670 QAPL_Post_Template_Context::set_template($qapl_no_post_template); 677 include($this-> helper->plugin_templates_no_posts());671 include($this->file_manager->get_no_posts_template()); 678 672 QAPL_Post_Template_Context::clear_template(); 679 673 } 680 674 681 675 echo '</div>'; 682 do_action(QAPL_ Hooks::HOOK_LOADER_BEFORE, $this->quick_ajax_id);676 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOADER_BEFORE, $this->quick_ajax_id); 683 677 echo '<div class="quick-ajax-loader-container">'; 684 include($this->layout[ $this->helper->layout_select_loader_icon()]);678 include($this->layout[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOADER_ICON]); 685 679 echo '</div>'; 686 do_action(QAPL_ Hooks::HOOK_LOADER_AFTER, $this->quick_ajax_id);680 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOADER_AFTER, $this->quick_ajax_id); 687 681 if (!$this->ajax_initial_load) { 688 $infinite_scroll = isset($this->attributes[ $this->helper->layout_ajax_infinite_scroll()]) ? intval($this->attributes[$this->helper->layout_ajax_infinite_scroll()]) : $this->helper->shortcode_page_ajax_on_initial_load_default_value();682 $infinite_scroll = isset($this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_AJAX_INFINITE_SCROLL]) ? intval($this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_AJAX_INFINITE_SCROLL]) : QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_AJAX_ON_INITIAL_LOAD_DEFAULT; 689 683 echo wp_kses_post($this->load_more_button(intval($query->get('paged')), intval($query->max_num_pages), intval($query->found_posts), $infinite_scroll)); 690 684 } 691 do_action(QAPL_ Hooks::HOOK_POSTS_CONTAINER_END, $this->quick_ajax_id);685 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_END, $this->quick_ajax_id); 692 686 echo '</div>'; 693 do_action(QAPL_ Hooks::HOOK_POSTS_CONTAINER_AFTER, $this->quick_ajax_id);687 do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_AFTER, $this->quick_ajax_id); 694 688 695 689 wp_reset_postdata(); … … 708 702 $load_more_args = $this->action_args; 709 703 $load_more_args['paged'] = isset($this->args['paged']) ? intval($this->args['paged']) : 1; 710 if (isset($this->attributes[ $this->helper->layout_load_more_posts()]) && !empty($this->attributes[$this->helper->layout_load_more_posts()])) {704 if (isset($this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOAD_MORE_POSTS]) && !empty($this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOAD_MORE_POSTS])) { 711 705 // Check if load_more_posts attribute is set 712 706 // if we want to add a different number of posts than displayed at the start 713 707 // use 'offset' not 'paged' 714 $load_more_posts = intval($this->attributes[ $this->helper->layout_load_more_posts()]);708 $load_more_posts = intval($this->attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOAD_MORE_POSTS]); 715 709 $offset = isset($load_more_args['offset']) ? $load_more_args['offset'] + $load_more_posts : + $load_more_posts; 716 710 … … 732 726 $class = ' infinite-scroll'; 733 727 } 734 //do_action(QAPL_ Hooks::HOOK_LOAD_MORE_BEFORE);735 $button_data['template'] = $this-> helper->plugin_templates_load_more_button();728 //do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOAD_MORE_BEFORE); 729 $button_data['template'] = $this->file_manager->get_load_more_button_template(); 736 730 $button_data['button_label'] = __('Load More', 'quick-ajax-post-loader'); 737 $button_data['data-button'] = $this->helper->load_more_button_data_button();731 $button_data['data-button'] = QAPL_Quick_Ajax_Plugin_Constants::LOAD_MORE_BUTTON_DATA_BUTTON; 738 732 $button_data['data-action'] = $load_more_args; 739 733 $button_data['data-attributes'] = $this->attributes; … … 742 736 $load_more_button .= '</div>'; 743 737 return $load_more_button; 744 //do_action(QAPL_ Hooks::HOOK_LOAD_MORE_AFTER);738 //do_action(QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOAD_MORE_AFTER); 745 739 } 746 740 public function render_end_of_posts_message($load_more, $max_num_pages, $quick_ajax_id, $show_end_post_message = false) { … … 763 757 ob_start(); 764 758 echo '<div class="quick-ajax-end-message-container">'; 765 include($this-> helper->plugin_templates_end_posts());759 include($this->file_manager->get_end_posts_template()); 766 760 echo '</div>'; 767 761 $content = ob_get_clean(); -
quick-ajax-post-loader/trunk/inc/class-deprecated-hooks-handler.php
r3238174 r3352831 59 59 $deprecated_hooks = [ 60 60 // Filter Wrapper Hooks 61 'qapl_filter_wrapper_pre' => QAPL_ Hooks::HOOK_FILTER_CONTAINER_BEFORE,62 'qapl_filter_wrapper_open' => QAPL_ Hooks::HOOK_FILTER_CONTAINER_START,63 'qapl_filter_wrapper_close' => QAPL_ Hooks::HOOK_FILTER_CONTAINER_END,64 'qapl_filter_wrapper_complete' => QAPL_ Hooks::HOOK_FILTER_CONTAINER_AFTER,61 'qapl_filter_wrapper_pre' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_BEFORE, 62 'qapl_filter_wrapper_open' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_START, 63 'qapl_filter_wrapper_close' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_END, 64 'qapl_filter_wrapper_complete' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_FILTER_CONTAINER_AFTER, 65 65 66 66 // Posts Wrapper Hooks 67 'qapl_posts_wrapper_pre' => QAPL_ Hooks::HOOK_POSTS_CONTAINER_BEFORE,68 'qapl_posts_wrapper_open' => QAPL_ Hooks::HOOK_POSTS_CONTAINER_START,69 'qapl_posts_wrapper_close' => QAPL_ Hooks::HOOK_POSTS_CONTAINER_END,70 'qapl_posts_wrapper_complete' => QAPL_ Hooks::HOOK_POSTS_CONTAINER_AFTER,67 'qapl_posts_wrapper_pre' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_BEFORE, 68 'qapl_posts_wrapper_open' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_START, 69 'qapl_posts_wrapper_close' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_END, 70 'qapl_posts_wrapper_complete' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_POSTS_CONTAINER_AFTER, 71 71 72 72 // Load More Button Hooks 73 //'qapl_load_more_button_pre' => QAPL_ Hooks::HOOK_LOAD_MORE_BEFORE,74 //'qapl_load_more_button_complete' => QAPL_ Hooks::HOOK_LOAD_MORE_AFTER,73 //'qapl_load_more_button_pre' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOAD_MORE_BEFORE, 74 //'qapl_load_more_button_complete' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOAD_MORE_AFTER, 75 75 76 76 // Loader Icon Hooks 77 'qapl_loader_icon_pre' => QAPL_ Hooks::HOOK_LOADER_BEFORE,78 'qapl_loader_icon_complete' => QAPL_ Hooks::HOOK_LOADER_AFTER,77 'qapl_loader_icon_pre' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOADER_BEFORE, 78 'qapl_loader_icon_complete' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_LOADER_AFTER, 79 79 80 80 // Filters 81 'qapl_modify_query' => QAPL_ Hooks::HOOK_MODIFY_POSTS_QUERY_ARGS,82 'qapl_modify_term_buttons' => QAPL_ Hooks::HOOK_MODIFY_TAXONOMY_FILTER_BUTTONS81 'qapl_modify_query' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_MODIFY_POSTS_QUERY_ARGS, 82 'qapl_modify_term_buttons' => QAPL_Quick_Ajax_Plugin_Constants::HOOK_MODIFY_TAXONOMY_FILTER_BUTTONS 83 83 ]; 84 84 -
quick-ajax-post-loader/trunk/inc/class-helper.php
r3337932 r3352831 3 3 exit; 4 4 } 5 6 class QAPL_Quick_Ajax_Helper{ 7 private static $instance = null; 5 use QAPL_Quick_Ajax_Plugin_Constants as QAPLC; 6 7 class QAPL_Quick_Ajax_Plugin_Starter{ 8 private $initializer; 9 private $enqueue_handler; 10 11 public function __construct(QAPL_Quick_Ajax_Plugin_Bootstrap_Interface $initializer, QAPL_Quick_Ajax_Enqueue_Handler_Interface $enqueue_handler) { 12 $this->initializer = $initializer; 13 $this->enqueue_handler = $enqueue_handler; 14 } 15 16 public function run(): void { 17 $this->initializer->initialize_plugin_components(); 18 $this->initializer->initialize_plugin_pages(); 19 $this->enqueue_handler->register_hooks(); 20 } 21 } 22 23 interface QAPL_Quick_Ajax_Plugin_Bootstrap_Interface { 24 public function initialize_plugin_pages(); 25 public function initialize_plugin_components(); 26 } 27 class QAPL_Quick_Ajax_Plugin_Bootstrap implements QAPL_Quick_Ajax_Plugin_Bootstrap_Interface { 28 //private $file_helper; 29 private $pages_helper; 30 public function __construct(QAPL_Quick_Ajax_Resource_Manager_Interface $pages_helper) { 31 //$this->file_helper = $file_helper; 32 $this->pages_helper = $pages_helper; 33 } 34 public function initialize_plugin_pages(): void { 35 // initialize file and page helpers or any other required helpers 36 $this->pages_helper->initialize_pages(); 37 } 38 public function initialize_plugin_components(): void { 39 // initialize other plugin components like AJAX handlers, shortcode classes, etc. 40 $this->pages_helper->initialize_components(); 41 } 42 } 43 44 interface QAPL_Quick_Ajax_Enqueue_Handler_Interface { 45 public function enqueue_frontend_styles_and_scripts(); 46 public function enqueue_admin_styles_and_scripts(); 47 public function register_hooks(); 48 } 49 class QAPL_Quick_Ajax_Enqueue_Handler implements QAPL_Quick_Ajax_Enqueue_Handler_Interface { 8 50 private $file_helper; 9 private $pages_helper; 10 private function __construct() { 11 $this->initialize_helpers(); 12 $this->initialize_components(); 13 } 14 public static function get_plugin_info() { 15 return [ 16 'version' => '1.7.7', 17 'name' => 'Quick Ajax Post Loader', 18 'text_domain' => 'quick-ajax-post-loader', 19 'slug' => 'quick-ajax-post-loader', 20 'minimum_php_version' => '7.4', 21 'minimum_wp_version' => '5.6', 22 'tested_wp_version' => '6.8' 23 ]; 24 } 25 public static function get_instance() { 26 if (self::$instance === null) { 27 self::$instance = new self(); 28 } 29 return self::$instance; 30 } 31 private function initialize_helpers() { 32 $this->file_helper = QAPL_File_Helper::get_instance(); 33 $this->pages_helper = new QAPL_Pages_Helper($this->file_helper); 34 35 } 36 // initialize plugin components 37 private function initialize_components() { 38 $initialize_list = [ 39 $this->pages_helper->plugin_admin_pages_config(), 40 $this->pages_helper->plugin_settings_page(), 41 $this->pages_helper->plugin_shortcode_page(), 42 $this->pages_helper->plugin_ajax_class(), 43 $this->pages_helper->plugin_ajax_actions(), 44 $this->pages_helper->plugin_functions(), 45 $this->pages_helper->plugin_updater(), 46 $this->pages_helper->plugin_shortcode_class(), 47 $this->pages_helper->plugin_template_hooks(), 48 $this->pages_helper->plugin_deprecated_hooks_handler(), 49 $this->pages_helper->plugin_register_dev_hooks(), 50 ]; 51 foreach ($initialize_list as $initialize) { 52 if (($initialize !== false)) { 53 require_once($initialize); 54 } 55 } 51 52 public function __construct(QAPL_Quick_Ajax_File_Manager_Interface $file_helper) { 53 $this->file_helper = $file_helper; 54 } 55 public function register_hooks(): void { 56 add_action('wp_enqueue_scripts', [$this, 'enqueue_frontend_styles_and_scripts']); 57 add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_styles_and_scripts']); 56 58 } 57 59 public function enqueue_frontend_styles_and_scripts() { … … 59 61 $style_suffix = $this->get_file_suffix('/css/', 'style.css'); 60 62 $script_suffix = $this->get_file_suffix('/js/', 'script.js'); 61 $version = $this-> is_dev_mode() ? time() : self::get_plugin_info()['version'];63 $version = $this->get_version(); 62 64 wp_enqueue_style('qapl-quick-ajax-style', $this->file_helper->get_plugin_css_directory() . 'style' . $style_suffix . '.css', [], $version); 63 65 wp_enqueue_script('qapl-quick-ajax-script', $this->file_helper->get_plugin_js_directory() . 'script' . $script_suffix . '.js', ['jquery'], $version, true); … … 68 70 if (is_admin()) { 69 71 // Check if the current page matches the plugin-related pages 70 $plugin_pages = [ self::cpt_shortcode_slug(), self::settings_page_slug()];72 $plugin_pages = [QAPLC::CPT_SHORTCODE_SLUG, QAPLC::SETTINGS_PAGE_SLUG]; 71 73 if (qapl_quick_ajax_check_page_type($plugin_pages)) { 72 74 $style_suffix = $this->get_file_suffix('/css/', 'admin-style.css'); 73 75 $script_suffix = $this->get_file_suffix('/js/', 'admin-script.js'); 74 $version = $this-> is_dev_mode() ? time() : self::get_plugin_info()['version'];76 $version = $this->get_version(); 75 77 wp_enqueue_style('qapl-quick-ajax-admin-style', $this->file_helper->get_plugin_css_directory() . 'admin-style' . $style_suffix . '.css', [], $version); 76 78 wp_register_script('qapl-quick-ajax-admin-script', $this->file_helper->get_plugin_js_directory() . 'admin-script' . $script_suffix . '.js', ['jquery'], $version, true); … … 87 89 return false; 88 90 } 91 private function get_version(): string { 92 return $this->is_dev_mode() ? (string) time() : QAPLC::PLUGIN_VERSION; 93 } 89 94 private function get_file_suffix($base_path, $file_name) { 90 95 // Set the default suffix to '.min' if WP_DEBUG is disabled … … 107 112 108 113 private function get_localized_data() { 109 $nonce = wp_create_nonce( self::wp_nonce_form_quick_ajax_action());114 $nonce = wp_create_nonce(QAPLC::NONCE_FORM_QUICK_AJAX_ACTION); 110 115 if (!$nonce) { 111 116 if (defined('WP_DEBUG') && WP_DEBUG) { … … 118 123 'nonce' => $nonce, 119 124 'helper' => [ 120 'block_id' => self::layout_quick_ajax_id(),121 'filter_data_button' => self::taxonomy_filter_button_data_button(),122 'sort_button' => self::sort_option_button_data_button(),123 'load_more_data_button' => self::load_more_button_data_button(),125 'block_id' => QAPLC::ATTRIBUTE_QUICK_AJAX_ID, 126 'filter_data_button' => QAPLC::TERM_FILTER_BUTTON_DATA_BUTTON, 127 'sort_button' => QAPLC::SORT_OPTION_BUTTON_DATA_BUTTON, 128 'load_more_data_button' => QAPLC::LOAD_MORE_BUTTON_DATA_BUTTON, 124 129 ] 125 130 ]; … … 128 133 return [ 129 134 'ajax_url' => admin_url('admin-ajax.php'), 130 'nonce' => wp_create_nonce( self::wp_nonce_form_quick_ajax_action()),131 'quick_ajax_settings_wrapper' => self::settings_wrapper_id(),132 'quick_ajax_post_type' => self::shortcode_page_select_post_type(),133 'quick_ajax_taxonomy' => self::shortcode_page_select_taxonomy(),134 'quick_ajax_manual_selected_terms' => self::shortcode_page_manual_selected_terms(),135 'quick_ajax_css_style' => self::layout_quick_ajax_css_style(),136 'grid_num_columns' => self::layout_container_num_columns(),137 'post_item_template' => self::layout_post_item_template(),138 'post_item_template_default' => self::shortcode_page_layout_post_item_template_default_value(),139 'taxonomy_filter_class' => self::layout_taxonomy_filter_class(),140 'container_class' => self::layout_container_class(),141 'load_more_posts' => self::layout_load_more_posts(),142 'loader_icon' => self::layout_select_loader_icon(),143 'loader_icon_default' => self::shortcode_page_select_loader_icon_default_value(),144 'ajax_initial_load' => self::query_settings_ajax_on_initial_load(),145 'infinite_scroll' => self::layout_ajax_infinite_scroll(),146 'show_end_message' => self::layout_show_end_message(),147 'quick_ajax_id' => self::layout_quick_ajax_id(),135 'nonce' => wp_create_nonce(QAPLC::NONCE_FORM_QUICK_AJAX_ACTION), 136 'quick_ajax_settings_wrapper' => QAPLC::SETTINGS_WRAPPER_ID, 137 'quick_ajax_post_type' => QAPLC::QUERY_SETTING_SELECT_POST_TYPE, 138 'quick_ajax_taxonomy' => QAPLC::QUERY_SETTING_SELECT_TAXONOMY, 139 'quick_ajax_manual_selected_terms' => QAPLC::QUERY_SETTING_SELECTED_TERMS, 140 'quick_ajax_css_style' => QAPLC::ATTRIBUTE_QUICK_AJAX_CSS_STYLE, 141 'grid_num_columns' => QAPLC::ATTRIBUTE_GRID_NUM_COLUMNS, 142 'post_item_template' => QAPLC::ATTRIBUTE_POST_ITEM_TEMPLATE, 143 'post_item_template_default' => QAPLC::LAYOUT_SETTING_POST_ITEM_TEMPLATE_DEFAULT, 144 'taxonomy_filter_class' => QAPLC::ATTRIBUTE_TAXONOMY_FILTER_CLASS, 145 'container_class' => QAPLC::ATTRIBUTE_CONTAINER_CLASS, 146 'load_more_posts' => QAPLC::ATTRIBUTE_LOAD_MORE_POSTS, 147 'loader_icon' => QAPLC::ATTRIBUTE_LOADER_ICON, 148 'loader_icon_default' => QAPLC::LAYOUT_SETTING_SELECT_LOADER_ICON_DEFAULT, 149 'ajax_initial_load' => QAPLC::AJAX_SETTING_AJAX_INITIAL_LOAD, 150 'infinite_scroll' => QAPLC::ATTRIBUTE_AJAX_INFINITE_SCROLL, 151 'show_end_message' => QAPLC::ATTRIBUTE_SHOW_END_MESSAGE, 152 'quick_ajax_id' => QAPLC::ATTRIBUTE_QUICK_AJAX_ID, 148 153 ]; 149 154 } 150 /* 151 public function load_admin_pages() { 152 $admin_pages = [ 153 'admin_config' => $this->pages_helper->plugin_admin_pages_config(), 154 'settings_page' => $this->pages_helper->plugin_settings_page(), 155 'shortcode_page' => $this->pages_helper->plugin_shortcode_page(), 156 ]; 157 158 foreach ($admin_pages as $page) { 159 if ($page && $this->file_helper->file_exists($page)) { 160 require_once($page); 155 } 156 157 interface QAPL_Quick_Ajax_Resource_Manager_Interface { 158 public function initialize_components(); 159 public function initialize_pages(); 160 } 161 class QAPL_Quick_Ajax_Resource_Manager implements QAPL_Quick_Ajax_Resource_Manager_Interface { 162 163 private QAPL_Quick_Ajax_File_Manager_Interface $file_helper; 164 165 // constants for page files 166 private const PAGE_FILES = [ 167 'admin_pages_config' => 'admin/admin-pages-config.php', 168 'settings_page' => 'admin/pages/settings-page.php', 169 'shortcode_page' => 'admin/pages/shortcode-page.php', 170 ]; 171 172 // constants for component files 173 private const COMPONENT_FILES = [ 174 'ajax_class' => 'inc/class-ajax.php', 175 'shortcode_class' => 'inc/class-shortcode.php', 176 'ajax_actions' => 'inc/actions.php', 177 'functions' => 'inc/functions.php', 178 'updater' => 'inc/class-updater.php', 179 'template_hooks' => 'inc/class-template-hooks.php', 180 'deprecated_hooks_handler' => 'inc/class-deprecated-hooks-handler.php', 181 'dev-hooks' => 'dev-tools/dev-hooks.php', 182 ]; 183 184 //construct expects instance of QAPL_File_Helper 185 public function __construct(QAPL_Quick_Ajax_File_Manager_Interface $file_helper) { 186 $this->file_helper = $file_helper; 187 } 188 public function initialize_pages(): void{ 189 $this->load_files(self::PAGE_FILES); 190 } 191 192 public function initialize_components(): void{ 193 $this->load_files(self::COMPONENT_FILES); 194 } 195 196 private function load_files(array $files): void{ 197 foreach ($files as $file) { 198 // start: refactoring class 199 if (class_exists('QAPL_Refactoring_Helper')) { 200 $resolver = new QAPL_Refactoring_Helper($this->file_helper); 201 $new_file = $resolver->get_new_file($file); 202 if($new_file){ 203 $file = $new_file; 204 } 161 205 } 162 } 163 } 164 165 //facade method to load AJAX classes 166 public function load_ajax_classes() { 167 $ajax_classes = [ 168 'ajax_class' => $this->pages_helper->plugin_ajax_class(), 169 'ajax_actions' => $this->pages_helper->plugin_ajax_actions(), 170 ]; 171 172 foreach ($ajax_classes as $class) { 173 if ($class && $this->file_helper->file_exists($class)) { 174 require_once($class); 206 // end: refactoring class 207 $path = $this->file_helper->file_exists($file); 208 if ($path !== false) { 209 require_once $path; 175 210 } 176 211 } 177 212 } 178 179 //facade method for templates 180 public function get_template_path($template_name, $type = 'post_items') { 181 $base_path = $type === 'loader_icon' ? '/loader-icon/' : '/post-items/'; 182 return $this->file_helper->get_templates_file_path($template_name, $this->get_default_template($type), $base_path); 183 } 184 185 private function get_default_template($type) { 186 return $type === 'loader_icon' ? 'loader-icon' : 'post-item'; 187 } 188 189 190 } 191 */ 213 } 214 215 interface QAPL_Quick_Ajax_File_Manager_Interface { 216 public function file_exists($file_path); 217 public function get_plugin_directory(); 218 public function get_plugin_js_directory(); 219 public function get_plugin_css_directory(); 220 public function get_templates_dir_path($file); 221 } 222 class QAPL_Quick_Ajax_File_Manager implements QAPL_Quick_Ajax_File_Manager_Interface { 223 private $plugin_dir_path; 224 private $plugin_dir_url; 225 226 public function __construct() { 227 $this->plugin_dir_path = plugin_dir_path(__DIR__); 228 $this->plugin_dir_url = plugin_dir_url(__DIR__); 229 } 230 public function file_exists($file_path) { 231 $full_path = $this->plugin_dir_path . ltrim($file_path, '/'); 232 return file_exists($full_path) ? $full_path : false; 233 } 234 public function get_plugin_directory() { 235 return $this->plugin_dir_url; 236 } 237 public function get_plugin_js_directory() { 238 return $this->plugin_dir_url . 'js/'; 239 } 240 public function get_plugin_css_directory() { 241 return $this->plugin_dir_url . 'css/'; 242 } 192 243 193 public static function add_or_update_option_autoload($option_name, $default_value = '', $autoload = 'auto') { 244 //template dir path 245 public function get_templates_dir_path($file) { 246 // Path to the template in the child theme (or the theme itself if not using a child theme) 247 $child_theme_template_path = get_stylesheet_directory() . '/quick-ajax-post-loader/templates' . $file; 248 // Check if the template exists in the child theme 249 if (file_exists($child_theme_template_path)) { 250 return $child_theme_template_path; 251 } 252 // Path to the template in the parent theme 253 $theme_template_path = get_template_directory() . '/quick-ajax-post-loader/templates' . $file; 254 // Check if the template exists in the parent theme 255 if (file_exists($theme_template_path)) { 256 return $theme_template_path; 257 } 258 // Path to the template in the plugin 259 $plugin_template_path = $this->plugin_dir_path . 'templates' . $file; 260 // Check if the template exists in the plugin 261 if (file_exists($plugin_template_path)) { 262 return $plugin_template_path; 263 } 264 // Template was not found 265 return false; 266 } 267 //template file path 268 public function get_templates_file_path($template_name, $default_name, $base_path) { 269 // Use the provided template name if given; otherwise, use the default name. 270 $template_name = sanitize_file_name(empty($template_name) ? $default_name : $template_name); 271 $file_path = $this->get_templates_dir_path($base_path . $template_name . '.php'); 272 // Check if the template file exists. If not, use the default file. 273 if (!file_exists($file_path)) { 274 $file_path = $this->get_templates_dir_path($base_path . $default_name . '.php'); 275 } 276 return $file_path; 277 } 278 279 private static function find_template_files($path) { 280 $files = []; 281 foreach (glob($path) as $file) { 282 if (is_file($file)) { 283 $files[] = $file; 284 } 285 } 286 return $files; 287 } 288 289 private static function get_template_name_from_file($file_path, $template_name) { 290 require_once(ABSPATH . 'wp-admin/includes/file.php'); 291 WP_Filesystem(); 292 global $wp_filesystem; 293 294 if (!$wp_filesystem || !$wp_filesystem->exists($file_path)) { 295 return basename(sanitize_file_name($file_path), '.php'); 296 } 297 298 $file_contents = $wp_filesystem->get_contents($file_path); 299 $lines = explode("\n", $file_contents); 300 301 foreach ($lines as $line) { 302 if (stripos($line, $template_name) !== false) { 303 $line = str_replace(['/* ', $template_name, '*/'], '', $line); 304 $line = trim($line); 305 return !empty($line) ? $line : basename($file_path, '.php'); 306 } 307 } 308 return basename($file_path, '.php'); 309 } 310 311 public function get_templates_items_array($template_file_location, $template_name, $default_file = false) { 312 $plugin_template_files = self::find_template_files($this->plugin_dir_path . 'templates/' . $template_file_location); 313 // Attempt to get templates from the parent theme directory 314 $parent_template_files = self::find_template_files(get_template_directory() . '/quick-ajax-post-loader/templates/' . $template_file_location); 315 // Attempt to get templates from the child theme directory 316 $child_template_files = []; 317 if (get_template_directory() !== get_stylesheet_directory()) { 318 $child_template_files = self::find_template_files(get_stylesheet_directory() . '/quick-ajax-post-loader/templates/' . $template_file_location); 319 } 320 321 $template_files_map = []; 322 foreach ([$plugin_template_files, $parent_template_files, $child_template_files] as $files) { 323 foreach ($files as $file_path) { 324 $file_name = sanitize_file_name(basename($file_path, '.php')); 325 $template_files_map[$file_name] = sanitize_text_field($file_path); 326 } 327 } 328 $file_names = []; 329 foreach ($template_files_map as $file_name => $file_path) { 330 $file_names[] = [ 331 'file_name' => $file_name, 332 'template_name' => self::get_template_name_from_file($file_path, $template_name) 333 ]; 334 } 335 if (!empty($default_file)) { 336 // Iterate over the array to find the default file 337 foreach ($file_names as $index => $file) { 338 if ($file['file_name'] == $default_file) { 339 // Remove the item from its current position 340 $item = array_splice($file_names, $index, 1)[0]; 341 // Add the item at the beginning of the array 342 array_unshift($file_names, $item); 343 break; 344 } 345 } 346 } 347 return $file_names; 348 } 349 //template post item 350 public function get_post_item_template(string $template_name = ''): string { 351 $default_name = QAPLC::LAYOUT_SETTING_POST_ITEM_TEMPLATE_DEFAULT; 352 return $this->get_templates_file_path($template_name, $default_name, '/post-items/'); 353 } 354 //template loader icon 355 public function get_loader_icon_template(string $template_name = ''): string { 356 $default_name = QAPLC::LAYOUT_SETTING_SELECT_LOADER_ICON_DEFAULT; 357 return $this->get_templates_file_path($template_name, $default_name, '/loader-icon/'); 358 } 359 //template for no posts found message 360 public function get_no_posts_template(): string { 361 return $this->get_templates_dir_path('/post-items/no-posts.php'); 362 } 363 //template for end of posts message 364 public function get_end_posts_template(): string { 365 return $this->get_templates_dir_path('/post-items/end-posts.php'); 366 } 367 //template for taxonomy filter button 368 public function get_taxonomy_filter_button_template(): string { 369 return $this->get_templates_dir_path('/taxonomy-filter/taxonomy-filter-button.php'); 370 } 371 //template for load more button 372 public function get_load_more_button_template(): string { 373 return $this->get_templates_dir_path('/load-more-button.php'); 374 } 375 } 376 class QAPL_Quick_Ajax_Utilities { 377 public static function element_exists(string $type, string $name) { 378 $exists = false; 379 $type_formatted = ''; 380 $plugin_name = QAPLC::PLUGIN_NAME; 381 if ($type === 'class' && class_exists($name)) { 382 $exists = true; 383 $type_formatted = 'class'; 384 } else if ($type === 'function' && function_exists($name)) { 385 $exists = true; 386 $type_formatted = 'function'; 387 } 388 if ($exists) { 389 add_action('admin_notices', function() use ($name, $type_formatted, $plugin_name) { 390 echo '<div class="notice notice-error"><p><strong>' . esc_html($plugin_name) . '</strong> is not working properly. Error: A ' . esc_html($type_formatted) . ' named <strong>' . esc_html($name) . '</strong> already exists, which may have been declared by another plugin.</p></div>'; 391 }); 392 return false; 393 } 394 return true; 395 } 396 public static function add_or_update_option_autoload(string $option_name, $default_value = '', string $autoload = 'auto'): void { 397 global $wpdb; 398 194 399 // Check if the option exists 195 400 $existing_option = get_option($option_name, false); 196 401 197 402 if ($existing_option !== false) { 198 // Update autoload value if the option exists 199 global $wpdb; 403 // Update autoload value if the option exists 200 404 $updated = $wpdb->update( 201 405 $wpdb->options, … … 212 416 } else { 213 417 // Add the option with specified autoload value 214 add_option($option_name, $default_value, '', $autoload); 215 418 add_option($option_name, $default_value, '', $autoload); 216 419 //clear cache after adding 217 420 wp_cache_delete($option_name, 'options'); 218 421 } 219 } 220 221 public static function element_exists($type, $name) { 222 $exists = false; 223 $type_formatted = ''; 224 $plugin_info = self::get_plugin_info(); 225 $plugin_name = $plugin_info['name']; 226 if ($type === 'class' && class_exists($name)) { 227 $exists = true; 228 $type_formatted = 'class'; 229 } else if ($type === 'function' && function_exists($name)) { 230 $exists = true; 231 $type_formatted = 'function'; 232 } 233 if ($exists) { 234 add_action('admin_notices', function() use ($name, $type_formatted, $plugin_name) { 235 echo '<div class="notice notice-error"><p><strong>' . esc_html($plugin_name) . '</strong> is not working properly. Error: A ' . esc_html($type_formatted) . ' named <strong>' . esc_html($name) . '</strong> already exists, which may have been declared by another plugin.</p></div>'; 236 }); 237 return false; 238 } 239 return true; 240 } 241 242 //template post item 243 public function plugin_templates_post_item_template($template_name = false) { 244 $default_name = self::shortcode_page_layout_post_item_template_default_value(); 245 return $this->file_helper->get_templates_file_path($template_name, $default_name, '/post-items/'); 246 } 247 //template loader icon 248 public function plugin_templates_loader_icon_template($template_name = false) { 249 $default_name = self::shortcode_page_select_loader_icon_default_value(); 250 return $this->file_helper->get_templates_file_path($template_name, $default_name, '/loader-icon/'); 251 } 252 public function plugin_templates_no_posts() { 253 return $this->file_helper->get_templates_dir_path('/post-items/no-posts.php'); 254 } 255 public function plugin_templates_end_posts() { 256 return $this->file_helper->get_templates_dir_path('/post-items/end-posts.php'); 257 } 258 public static function taxonomy_filter_button_data_button(){ 259 return 'quick-ajax-filter-button'; 260 } 261 public static function sort_option_button_data_button(){ 262 return 'quick-ajax-sort-option-button'; 263 } 264 public function plugin_templates_taxonomy_filter_button() { 265 return $this->file_helper->get_templates_dir_path('/taxonomy-filter/taxonomy-filter-button.php'); 266 } 267 public static function load_more_button_data_button(){ 268 return 'quick-ajax-load-more-button'; 269 } 270 public function plugin_templates_load_more_button() { 271 return $this->file_helper->get_templates_dir_path('/load-more-button.php'); 272 } 273 274 public static function generate_shortcode($post_id) { 422 } 423 } 424 class QAPL_Quick_Ajax_Shortcode_Generator { 425 426 public static function generate_shortcode(int $post_id): string { 275 427 // guard clause to check if $post_id is valid 276 $post_id = intval($post_id);277 428 if ($post_id <= 0) { 278 429 return ''; … … 283 434 $excluded_post_ids = ''; 284 435 // get serialized meta data from the post 285 $serialized_data = get_post_meta($post_id, self::quick_ajax_shortcode_settings(), true);436 $serialized_data = get_post_meta($post_id, QAPLC::DB_POSTMETA_SHORTCODE_SETTINGS, true); 286 437 // check if serialized data exists and process it 287 438 if ($serialized_data) { … … 289 440 // ensure that the unserialized data is a valid array 290 441 if (is_array($form_data)) { 291 foreach ($form_data as $field_name => $field_value) { 292 // check for specific field and set excluded post ids 293 if ($field_name === self::shortcode_page_set_post_not_in() && !empty($field_value)) { 294 $excluded_post_ids = ' excluded_post_ids="' . esc_attr($field_value) . '"'; 295 } 442 $excluded_key = QAPLC::QUERY_SETTING_SET_POST_NOT_IN; 443 if (isset($form_data[$excluded_key]) && !empty($form_data[$excluded_key])) { 444 $excluded_post_ids = ' excluded_post_ids="' . esc_attr($form_data[$excluded_key]) . '"'; 296 445 } 297 446 } … … 299 448 // generate the shortcode with post ID and title, include excluded post ids if available 300 449 $shortcode = '[qapl-quick-ajax id="' . $post_id . '" title="' . esc_attr($post_title) . '"' . $excluded_post_ids . ']'; 301 //apply filters for extendability302 //$shortcode = apply_filters('generate_shortcode', $shortcode, $post_id)303 450 return $shortcode; 304 451 } 305 306 public static function menu_slug() { 307 return 'qapl-menu'; 308 } 309 public static function cpt_shortcode_slug() { 310 return 'qapl-creator'; 311 } 312 public static function settings_page_slug() { 313 return 'qapl-settings'; 314 } 315 316 /* quick-ajax-creator shortcode field names */ 317 public static function quick_ajax_shortcode_settings() { 318 return '_qapl_quick_ajax_shortcode_settings'; 319 } 320 /* old value, not in use from 1.3.3 321 public static function quick_ajax_shortcode_code() { 322 return 'qapl_quick_ajax_shortcode_code'; 323 } 324 */ 325 public static function quick_ajax_plugin_version() { 326 return 'qapl_quick_ajax_plugin_version'; 327 } 328 public static function quick_ajax_plugin_cleanup_flags() { 329 return 'qapl_quick_ajax_cleanup_flags'; 330 } 331 public static function settings_wrapper_id() { 332 return 'qapl_settings_wrapper'; 333 } 334 public static function wp_nonce_form_quick_ajax_field() { 335 return 'qapl_quick_ajax_nonce'; 336 } 337 public static function wp_nonce_form_quick_ajax_action() { 338 return 'qapl_quick_ajax_nonce_action'; 339 } 340 public static function shortcode_page_select_post_type() { 341 return 'qapl_select_post_type'; 342 } 343 public static function shortcode_page_select_post_type_default_value(){ 344 return 'post'; 345 } 346 public static function shortcode_page_show_taxonomy_filter(){ 347 return 'qapl_show_select_taxonomy'; 348 } 349 public static function shortcode_page_show_taxonomy_filter_default_value(){ 350 return 0; 351 } 352 public static function shortcode_page_select_taxonomy(){ 353 return 'qapl_select_taxonomy'; 354 } 355 public static function shortcode_page_manual_term_selection(){ 356 return 'qapl_manual_term_selection'; 357 } 358 public static function shortcode_page_manual_term_selection_default_value(){ 359 return 0; 360 } 361 public static function shortcode_page_manual_selected_terms(){ 362 return 'qapl_manual_selected_terms'; 363 } 364 public static function shortcode_page_select_posts_per_page(){ 365 return 'qapl_select_posts_per_page'; 366 } 367 public static function shortcode_page_select_posts_per_page_default_value() { 368 return 6; 369 } 370 public static function shortcode_page_select_order(){ 371 return 'qapl_select_order'; 372 } 373 public static function shortcode_page_select_order_default_value() { 374 return 'DESC'; 375 } 376 public static function shortcode_page_select_orderby(){ 377 return 'qapl_select_orderby'; 378 } 379 public static function shortcode_page_select_orderby_default_value() { 380 return 'date'; 381 } 382 383 384 public static function shortcode_page_show_sort_button(){ 385 return 'qapl_show_order_button'; 386 } 387 public static function shortcode_page_show_sort_button_default_value(){ 388 return 0; 389 } 390 public static function shortcode_page_select_sort_button_options(){ 391 return 'qapl_select_orderby_button_options'; 392 } 393 public static function shortcode_page_select_sort_button_options_values() { 394 $global_sort_labels = get_option(self::admin_page_global_options_name(), []); 395 // Define sort options array with dynamic labels from global settings 452 } 453 /////////////////////// 454 // Fields 455 456 457 //interface for form field data 458 //it defines the methods that must exist in any field class 459 interface QAPL_Quick_Ajax_Form_Field_Interface { 460 public function get_name(): string; 461 public function get_label(): string; 462 public function get_type(): string; 463 public function get_options(): array; 464 public function get_default(); 465 public function get_description(): string; 466 public function get_placeholder(): string; 467 public function get_field(): array; 468 } 469 470 //this class holds all field data, 471 //it is the final field object 472 class QAPL_Quick_Ajax_Form_Field implements QAPL_Quick_Ajax_Form_Field_Interface { 473 private string $name; 474 private string $label; 475 private string $type; 476 private array $options; 477 private $default; 478 private string $description; 479 private string $placeholder; 480 481 //this constructor sets all properties for the field 482 public function __construct(string $name, string $label, string $type, array $options, $default, string $description, string $placeholder) { 483 $this->name = $name; 484 $this->label = $label; 485 $this->type = $type; 486 $this->options = $options; 487 $this->default = $default; 488 $this->description = $description; 489 $this->placeholder = $placeholder; 490 } 491 //simple get methods to return each property 492 public function get_name(): string { 493 return $this->name; 494 } 495 public function get_label(): string { 496 return $this->label; 497 } 498 public function get_type(): string { 499 return $this->type; 500 } 501 public function get_options(): array { 502 return $this->options; 503 } 504 public function get_default() { 505 return $this->default; 506 } 507 public function get_description(): string { 508 return $this->description; 509 } 510 public function get_placeholder(): string { 511 return $this->placeholder; 512 } 513 //returns all field data in array format 514 public function get_field(): array { 515 return [ 516 'name' => $this->name, 517 'label' => $this->label, 518 'type' => $this->type, 519 'options' => $this->options, 520 'default' => $this->default, 521 'description' => $this->description, 522 'placeholder' => $this->placeholder, 523 ]; 524 } 525 } 526 527 //this class helps build the field object step by step 528 //it is useful if you don't want to pass all parameters in constructor 529 class QAPL_Quick_Ajax_Form_Field_Builder { 530 private string $name = ''; 531 private string $label = ''; 532 private string $type = 'text'; 533 private array $options = []; 534 private $default = ''; 535 private string $description = ''; 536 private string $placeholder = ''; 537 538 public function set_name(string $name): self { 539 $this->name = $name; 540 return $this; 541 } 542 public function set_label(string $label): self { 543 $this->label = $label; 544 return $this; 545 } 546 public function set_type(string $type): self { 547 $this->type = $type; 548 return $this; 549 } 550 public function set_options(array $options): self { 551 $this->options = $options; 552 return $this; 553 } 554 public function set_default($default): self { 555 $this->default = $default; 556 return $this; 557 } 558 public function set_description(string $description): self { 559 $this->description = $description; 560 return $this; 561 } 562 public function set_placeholder(string $placeholder): self { 563 $this->placeholder = $placeholder; 564 return $this; 565 } 566 567 //finally this method creates the final field object 568 //using all the properties you set before 569 public function build(): QAPL_Quick_Ajax_Form_Field_Interface { 570 return new QAPL_Quick_Ajax_Form_Field( 571 $this->name, 572 $this->label, 573 $this->type, 574 $this->options, 575 $this->default, 576 $this->description, 577 $this->placeholder 578 ); 579 } 580 } 581 582 class QAPL_Quick_Ajax_Form_Field_Factory { 583 //select post type 584 public static function build_select_post_type_field(): QAPL_Quick_Ajax_Form_Field_Interface { 585 $post_types = get_post_types(['public' => true], 'objects'); 586 $options = []; 587 foreach ($post_types as $post_type) { 588 if (isset($post_type->labels->name) && $post_type->labels->name !== 'Media') { 589 $options[] = [ 590 'label' => $post_type->labels->name, 591 'value' => $post_type->name 592 ]; 593 } 594 } 595 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 596 $builder->set_name(QAPLC::QUERY_SETTING_SELECT_POST_TYPE); 597 $builder->set_label(__('Select Post Type', 'quick-ajax-post-loader')); 598 $builder->set_type('select'); 599 $builder->set_options($options); 600 $builder->set_default(QAPLC::QUERY_SETTING_SELECT_POST_TYPE_DEFAULT); 601 $builder->set_description(__('Choose the post type you want to display using AJAX.', 'quick-ajax-post-loader')); 602 return $builder->build(); 603 } 604 //show taxonomy checkbox 605 public static function build_show_taxonomy_filter_field(): QAPL_Quick_Ajax_Form_Field_Interface { 606 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 607 $builder->set_name(QAPLC::QUERY_SETTING_SHOW_TAXONOMY_FILTER); 608 $builder->set_label(__('Show Taxonomy Filter', 'quick-ajax-post-loader')); 609 $builder->set_type('checkbox'); 610 $builder->set_default(QAPLC::QUERY_SETTING_SHOW_TAXONOMY_FILTER_DEFAULT); 611 $builder->set_description(__('Enable filtering by taxonomy/category.', 'quick-ajax-post-loader')); 612 return $builder->build(); 613 } 614 //select taxonomy 615 public static function build_select_taxonomy_field(): QAPL_Quick_Ajax_Form_Field_Interface { 616 $options = []; 617 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 618 $builder->set_name(QAPLC::QUERY_SETTING_SELECT_TAXONOMY); 619 $builder->set_label(__('Select Taxonomy', 'quick-ajax-post-loader')); 620 $builder->set_type('select'); 621 $builder->set_options($options); 622 $builder->set_default(''); 623 $builder->set_description(__('Select the taxonomy to be used for filtering posts.', 'quick-ajax-post-loader')); 624 return $builder->build(); 625 } 626 //manual term selection checkbox 627 public static function build_manual_term_selection_field(): QAPL_Quick_Ajax_Form_Field_Interface { 628 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 629 $builder->set_name(QAPLC::QUERY_SETTING_MANUAL_TERM_SELECTION); 630 $builder->set_label(__('Select Specific Terms', 'quick-ajax-post-loader')); 631 $builder->set_type('checkbox'); 632 $builder->set_default(QAPLC::QUERY_SETTING_MANUAL_TERM_SELECTION_DEFAULT); 633 $builder->set_description(__('Enable manual selection of taxonomy terms to be used for filtering.', 'quick-ajax-post-loader')); 634 return $builder->build(); 635 } 636 //manual selected terms multiselect 637 public static function build_manual_selected_terms_field(): QAPL_Quick_Ajax_Form_Field_Interface { 638 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 639 $builder->set_name(QAPLC::QUERY_SETTING_SELECTED_TERMS); 640 $builder->set_label(__('Choose Terms', 'quick-ajax-post-loader')); 641 $builder->set_type('multiselect'); 642 $builder->set_options([]); 643 $builder->set_default([]); 644 $builder->set_description(__('Select the specific terms to be used for filtering posts. If left empty, no results will be shown.', 'quick-ajax-post-loader')); 645 return $builder->build(); 646 } 647 //post per page number 648 public static function build_posts_per_page_field(): QAPL_Quick_Ajax_Form_Field_Interface { 649 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 650 $builder->set_name(QAPLC::QUERY_SETTING_SELECT_POSTS_PER_PAGE); 651 $builder->set_label(__('Posts Per Page', 'quick-ajax-post-loader')); 652 $builder->set_type('number'); 653 $builder->set_default(QAPLC::QUERY_SETTING_SELECT_POSTS_PER_PAGE_DEFAULT); 654 $builder->set_description(__('Determine the number of posts to be loaded per AJAX request.', 'quick-ajax-post-loader')); 655 return $builder->build(); 656 } 657 //select post order 658 public static function build_select_order_field(): QAPL_Quick_Ajax_Form_Field_Interface { 659 $order_options = [ 660 [ 661 'label' => __('Descending - order from highest to lowest', 'quick-ajax-post-loader'), 662 'value' => 'DESC' 663 ], 664 [ 665 'label' => __('Ascending - order from lowest to highest', 'quick-ajax-post-loader'), 666 'value' => 'ASC' 667 ], 668 ]; 669 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 670 $builder->set_name(QAPLC::QUERY_SETTING_SELECT_ORDER); 671 $builder->set_label(__('Default Sort Order', 'quick-ajax-post-loader')); 672 $builder->set_type('select'); 673 $builder->set_options($order_options); 674 $builder->set_default(QAPLC::QUERY_SETTING_SELECT_ORDER_DEFAULT); 675 $builder->set_description(__('Specify the order of posts.', 'quick-ajax-post-loader')); 676 return $builder->build(); 677 } 678 //select post orderby 679 public static function build_select_orderby_field(): QAPL_Quick_Ajax_Form_Field_Interface { 680 $orderby_options = [ 681 [ 682 'label' => __('Date: Sort by publication date', 'quick-ajax-post-loader'), 683 'value' => 'date' 684 ], 685 [ 686 'label' => __('Title: Sort by post title', 'quick-ajax-post-loader'), 687 'value' => 'title' 688 ], 689 [ 690 'label' => __('Comments: Sort by comment count', 'quick-ajax-post-loader'), 691 'value' => 'comment_count' 692 ], 693 [ 694 'label' => __('Random: Random order', 'quick-ajax-post-loader'), 695 'value' => 'rand' 696 ], 697 ]; 698 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 699 $builder->set_name(QAPLC::QUERY_SETTING_SELECT_ORDERBY); 700 $builder->set_label(__('Default Sort By', 'quick-ajax-post-loader')); 701 $builder->set_type('select'); 702 $builder->set_options($orderby_options); 703 $builder->set_default(QAPLC::QUERY_SETTING_SELECT_ORDERBY_DEFAULT); 704 $builder->set_description(__('Choose the sorting criteria for posts.', 'quick-ajax-post-loader')); 705 return $builder->build(); 706 } 707 //show sort button 708 public static function build_show_sort_button_field(): QAPL_Quick_Ajax_Form_Field_Interface { 709 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 710 $builder->set_name(QAPLC::QUERY_SETTING_SHOW_SORT_BUTTON); 711 $builder->set_label(__('Show Sorting Button', 'quick-ajax-post-loader')); 712 $builder->set_type('checkbox'); 713 $builder->set_default(QAPLC::QUERY_SETTING_SHOW_SORT_BUTTON_DEFAULT); 714 $builder->set_description(__('Enable a button that allows users to switch between ascending and descending order.', 'quick-ajax-post-loader')); 715 return $builder->build(); 716 } 717 //select sort button 718 public static function build_select_sort_button_options_field(): QAPL_Quick_Ajax_Form_Field_Interface { 719 $global_sort_labels = get_option(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME, []); 396 720 $sort_options = [ 397 721 [ … … 415 739 [ 416 740 'value' => 'title-asc', 741 'label' => isset($global_sort_labels['sort_option_title_desc_label']) 742 ? $global_sort_labels['sort_option_title_desc_label'] 743 : __('A → Z', 'quick-ajax-post-loader') 744 ], 745 [ 746 'value' => 'title-desc', 417 747 'label' => isset($global_sort_labels['sort_option_title_asc_label']) 418 748 ? $global_sort_labels['sort_option_title_asc_label'] 419 : __('A → Z', 'quick-ajax-post-loader')420 ],421 [422 'value' => 'title-desc',423 'label' => isset($global_sort_labels['sort_option_title_desc_label'])424 ? $global_sort_labels['sort_option_title_desc_label']425 749 : __('Z → A', 'quick-ajax-post-loader') 426 750 ], … … 432 756 ], 433 757 ]; 434 435 return $sort_options; 436 } 437 public static function shortcode_page_select_sort_button_options_default_value(){ 438 return 1; 439 } 440 public static function shortcode_page_show_inline_filter_sorting(){ 441 return 'qapl_show_inline_filter_sorting'; 442 } 443 public static function shortcode_page_show_inline_filter_sorting_default_value(){ 444 return 1; 445 } 446 //public static function shortcode_page_select_post_status(){ 447 // return 'qapl_select_post_status'; 448 //} 449 public static function shortcode_page_select_post_status_default_value(){ 450 return 'publish'; 451 } 452 public static function shortcode_page_ignore_sticky_posts(){ 453 return 'qapl_ignore_sticky_posts'; 454 } 455 public static function shortcode_page_ignore_sticky_posts_default_value() { 456 return false; 457 } 458 public static function shortcode_page_ajax_on_initial_load(){ 459 return 'qapl_ajax_on_initial_load'; 460 } 461 public static function shortcode_page_ajax_on_initial_load_default_value(){ 462 return false; 463 } 464 public static function shortcode_page_ajax_infinite_scroll(){ 465 return 'qapl_ajax_infinite_scroll'; 466 } 467 public static function shortcode_page_ajax_infinite_scroll_default_value(){ 468 return false; 469 } 470 public static function shortcode_page_show_end_message(){ 471 return 'qapl_show_end_post_message'; 472 } 473 public static function shortcode_page_show_end_message_default_value(){ 474 return false; 475 } 476 public static function shortcode_page_set_post_not_in(){ 477 return 'qapl_select_post_not_in'; 478 } 479 public static function shortcode_page_layout_select_columns_qty(){ 480 return 'qapl_layout_select_columns_qty'; 481 } 482 public static function shortcode_page_layout_select_columns_qty_default_value(){ 483 return 3; 484 } 485 public static function shortcode_page_layout_taxonomy_filter_class(){ 486 return 'qapl_layout_add_taxonomy_filter_class'; 487 } 488 public static function shortcode_page_layout_container_class(){ 489 return 'qapl_layout_add_container_class'; 490 } 491 public static function shortcode_page_layout_quick_ajax_css_style(){ 492 return 'qapl_layout_quick_ajax_css_style'; 493 } 494 public static function shortcode_page_layout_quick_ajax_css_style_default_value(){ 495 return 1; 496 } 497 public static function shortcode_page_layout_post_item_template(){ 498 return 'qapl_layout_quick_ajax_post_item_template'; 499 } 500 public static function shortcode_page_layout_post_item_template_default_value(){ 501 return 'post-item'; 502 } 503 public static function shortcode_page_show_custom_load_more_post_quantity(){ 504 return 'qapl_show_custom_load_more_post_quantity'; 505 } 506 public static function shortcode_page_show_custom_load_more_post_quantity_default_value(){ 507 return 0; 508 } 509 public static function shortcode_page_select_custom_load_more_post_quantity(){ 510 return 'qapl_select_custom_load_more_post_quantity'; 511 } 512 public static function shortcode_page_select_custom_load_more_post_quantity_default_value(){ 513 return 4; 514 } 515 public static function shortcode_page_override_global_loader_icon(){ 516 return 'qapl_override_global_loader_icon'; 517 } 518 public static function shortcode_page_override_global_loader_icon_default_value(){ 519 return 0; 520 } 521 public static function shortcode_page_select_loader_icon(){ 522 return 'qapl_loader_icon'; 523 } 524 public static function shortcode_page_select_loader_icon_default_value(){ 525 return 'loader-icon'; 526 } 527 // attributes query names 528 public static function query_settings_ajax_on_initial_load(){ 529 return 'ajax_initial_load'; 530 } 531 public static function layout_quick_ajax_id(){ 532 return 'quick_ajax_id'; 533 } 534 public static function layout_quick_ajax_css_style(){ 535 return 'quick_ajax_css_style'; 536 } 537 public static function layout_container_num_columns(){ 538 return 'grid_num_columns'; 539 } 540 public static function layout_post_item_template(){ 541 return 'post_item_template'; 542 } 543 public static function layout_taxonomy_filter_class(){ 544 return 'taxonomy_filter_class'; 545 } 546 public static function layout_container_class(){ 547 return 'container_class'; 548 } 549 public static function layout_load_more_posts(){ 550 return 'load_more_posts'; 551 } 552 public static function layout_select_loader_icon(){ 553 return 'loader_icon'; 554 } 555 public static function layout_ajax_infinite_scroll(){ 556 return 'infinite_scroll'; 557 } 558 public static function layout_show_end_message(){ 559 return 'show_end_message'; 560 } 561 /* Quick AJAX Settings */ 562 public static function admin_page_settings_field_option_group(){ 563 return 'qapl_settings_group'; 564 } 565 public static function admin_page_global_options_name(){ 566 return 'qapl_quick_ajax_global_options'; 567 } 568 /* Quick AJAX Global Options */ 569 public static function global_options_field_select_loader_icon(){ 570 return self::admin_page_global_options_name().'[loader_icon]'; 571 } 572 public static function global_options_field_set_read_more_label(){ 573 return self::admin_page_global_options_name().'[read_more_label]'; 574 } 575 public static function global_options_field_set_post_date_format(){ 576 return self::admin_page_global_options_name().'[post_date_format]'; 577 } 578 public static function global_options_field_set_show_all_label(){ 579 return self::admin_page_global_options_name().'[show_all_label]'; 580 } 581 public static function global_options_field_set_load_more_label(){ 582 return self::admin_page_global_options_name().'[load_more_label]'; 583 } 584 public static function global_options_field_set_no_post_message(){ 585 return self::admin_page_global_options_name().'[no_post_message]'; 586 } 587 public static function global_options_field_set_end_post_message(){ 588 return self::admin_page_global_options_name().'[end_post_message]'; 589 } 590 591 //Sorting Options Labels 592 public static function global_options_field_set_sort_option_date_desc_label(){ 593 return self::admin_page_global_options_name().'[sort_option_date_desc_label]'; 594 } 595 public static function global_options_field_set_sort_option_date_asc_label(){ 596 return self::admin_page_global_options_name().'[sort_option_date_asc_label]'; 597 } 598 public static function global_options_field_set_sort_option_comment_count_desc_label(){ 599 return self::admin_page_global_options_name().'[sort_option_comment_count_desc_label]'; 600 } 601 public static function global_options_field_set_sort_option_title_desc_label(){ 602 return self::admin_page_global_options_name().'[sort_option_title_desc_label]'; 603 } 604 public static function global_options_field_set_sort_option_title_asc_label(){ 605 return self::admin_page_global_options_name().'[sort_option_title_asc_label]'; 606 } 607 public static function global_options_field_set_sort_option_rand_label(){ 608 return self::admin_page_global_options_name().'[sort_option_rand_label]'; 609 } 610 /* Quick AJAX placeholders */ 611 /* not in use after removing placeholders 612 public static function placeholder_read_more_label() { 613 return [ 614 'placeholder' => '[[QAPL::READ_MORE_LABEL]]', 615 'option_key' => 'read_more_label', 616 'default' => __('Read More', 'quick-ajax-post-loader'), 617 ]; 618 } 619 public static function placeholder_show_all_label() { 620 return [ 621 'placeholder' => '[[QAPL::SHOW_ALL_LABEL]]', 622 'option_key' => 'show_all_label', 623 'default' => __('Show All', 'quick-ajax-post-loader'), 624 ]; 625 } 626 public static function placeholder_load_more_label() { 627 return [ 628 'placeholder' => '[[QAPL::LOAD_MORE_LABEL]]', 629 'option_key' => 'load_more_label', 630 'default' => __('Load More', 'quick-ajax-post-loader'), 631 ]; 632 } 633 public static function get_all_placeholders() { 634 return [ 635 self::placeholder_read_more_label(), 636 self::placeholder_load_more_label(), 637 self::placeholder_show_all_label(), 638 ]; 639 } 640 */ 641 } 642 643 class QAPL_File_Helper { 644 private static $instance = null; 645 private $plugin_dir_path; 646 private $plugin_dir_url; 647 648 private function __construct($plugin_dir_path, $plugin_dir_url) { 649 $this->plugin_dir_path = $plugin_dir_path; 650 $this->plugin_dir_url = $plugin_dir_url; 651 } 652 653 public static function get_instance() { 654 if (self::$instance === null) { 655 // set base plugin directory paths 656 $plugin_dir_path = plugin_dir_path(__DIR__); 657 $plugin_dir_url = plugin_dir_url(__DIR__); 658 self::$instance = new self($plugin_dir_path, $plugin_dir_url); 659 } 660 return self::$instance; 661 } 662 public function file_exists($file_path) { 663 //print_r($file_path); 664 $full_path = $this->plugin_dir_path . ltrim($file_path, '/'); 665 return file_exists($full_path) ? $full_path : false; 666 } 667 public function get_plugin_directory() { 668 return $this->plugin_dir_url; 669 } 670 public function get_plugin_js_directory() { 671 return $this->plugin_dir_url . 'js/'; 672 } 673 public function get_plugin_css_directory() { 674 return $this->plugin_dir_url . 'css/'; 675 } 676 677 //template dir path 678 public function get_templates_dir_path($file) { 679 // Path to the template in the child theme (or the theme itself if not using a child theme) 680 $child_theme_template_path = get_stylesheet_directory() . '/quick-ajax-post-loader/templates' . $file; 681 // Check if the template exists in the child theme 682 if (file_exists($child_theme_template_path)) { 683 return $child_theme_template_path; 684 } 685 // Path to the template in the parent theme 686 $theme_template_path = get_template_directory() . '/quick-ajax-post-loader/templates' . $file; 687 // Check if the template exists in the parent theme 688 if (file_exists($theme_template_path)) { 689 return $theme_template_path; 690 } 691 // Path to the template in the plugin 692 $plugin_template_path = $this->plugin_dir_path . 'templates' . $file; 693 // Check if the template exists in the plugin 694 if (file_exists($plugin_template_path)) { 695 return $plugin_template_path; 696 } 697 // Template was not found 698 return false; 699 } 700 //template file path 701 public function get_templates_file_path($template_name, $default_name, $base_path) { 702 // Use the provided template name if given; otherwise, use the default name. 703 $template_name = sanitize_file_name(empty($template_name) ? $default_name : $template_name); 704 $file_path = $this->get_templates_dir_path($base_path . $template_name . '.php'); 705 // Check if the template file exists. If not, use the default file. 706 if (!file_exists($file_path)) { 707 $file_path = $this->get_templates_dir_path($base_path . $default_name . '.php'); 708 } 709 return $file_path; 710 } 711 712 private static function find_template_files($path) { 713 $files = []; 714 foreach (glob($path) as $file) { 715 if (is_file($file)) { 716 $files[] = $file; 717 } 718 } 719 return $files; 720 } 721 722 private static function get_template_name_from_file($file_path, $template_name) { 723 require_once(ABSPATH . 'wp-admin/includes/file.php'); 724 WP_Filesystem(); 725 global $wp_filesystem; 726 727 if (!$wp_filesystem || !$wp_filesystem->exists($file_path)) { 728 return basename(sanitize_file_name($file_path), '.php'); 729 } 730 731 $file_contents = $wp_filesystem->get_contents($file_path); 732 $lines = explode("\n", $file_contents); 733 734 foreach ($lines as $line) { 735 if (stripos($line, $template_name) !== false) { 736 $line = str_replace(['/* ', $template_name, '*/'], '', $line); 737 $line = trim($line); 738 return !empty($line) ? $line : basename($file_path, '.php'); 739 } 740 } 741 return basename($file_path, '.php'); 742 } 743 744 public function plugin_get_templates_items_array($template_file_location, $template_name, $default_file = false) { 745 $plugin_template_files = self::find_template_files($this->plugin_dir_path . 'templates/' . $template_file_location); 746 // Attempt to get templates from the parent theme directory 747 $parent_template_files = self::find_template_files(get_template_directory() . '/quick-ajax-post-loader/templates/' . $template_file_location); 748 // Attempt to get templates from the child theme directory 749 $child_template_files = []; 750 if (get_template_directory() !== get_stylesheet_directory()) { 751 $child_template_files = self::find_template_files(get_stylesheet_directory() . '/quick-ajax-post-loader/templates/' . $template_file_location); 752 } 753 754 $template_files_map = []; 755 foreach ([$plugin_template_files, $parent_template_files, $child_template_files] as $files) { 756 foreach ($files as $file_path) { 757 $file_name = sanitize_file_name(basename($file_path, '.php')); 758 $template_files_map[$file_name] = sanitize_text_field($file_path); 759 } 760 } 761 762 $file_names = []; 763 foreach ($template_files_map as $file_name => $file_path) { 764 $file_names[] = [ 765 'file_name' => $file_name, 766 'template_name' => self::get_template_name_from_file($file_path, $template_name) 767 ]; 768 } 769 770 if (!empty($default_file)) { 771 // Iterate over the array to find the default file 772 foreach ($file_names as $index => $file) { 773 if ($file['file_name'] == $default_file) { 774 // Remove the item from its current position 775 $item = array_splice($file_names, $index, 1)[0]; 776 // Add the item at the beginning of the array 777 array_unshift($file_names, $item); 778 break; 779 } 780 } 781 } 782 return $file_names; 783 } 784 } 785 786 class QAPL_Pages_Helper{ 787 private $file_helper; 788 //construct expects instance of QAPL_File_Helper 789 public function __construct(QAPL_File_Helper $file_helper) { 790 $this->file_helper = $file_helper; 791 } 792 public function plugin_admin_pages_config() { 793 return $this->file_helper->file_exists('admin/admin-pages-config.php'); 794 } 795 public function plugin_settings_page() { 796 return $this->file_helper->file_exists('admin/pages/settings-page.php'); 797 } 798 public function plugin_shortcode_page() { 799 return $this->file_helper->file_exists('admin/pages/shortcode-page.php'); 800 } 801 public function plugin_ajax_class() { 802 return $this->file_helper->file_exists('inc/class-ajax.php'); 803 } 804 public function plugin_shortcode_class() { 805 return $this->file_helper->file_exists('inc/class-shortcode.php'); 806 } 807 public function plugin_ajax_actions() { 808 return $this->file_helper->file_exists('inc/actions.php'); 809 } 810 public function plugin_functions() { 811 return $this->file_helper->file_exists('inc/functions.php'); 812 } 813 public function plugin_updater() { 814 return $this->file_helper->file_exists('inc/class-updater.php'); 815 } 816 public function plugin_template_hooks() { 817 return $this->file_helper->file_exists('inc/class-template-hooks.php'); 818 } 819 public function plugin_deprecated_hooks_handler() { 820 return $this->file_helper->file_exists('inc/class-deprecated-hooks-handler.php'); 821 } 822 public function plugin_register_dev_hooks() { 823 return $this->file_helper->file_exists('dev-tools/dev-hooks.php'); 824 } 825 } 826 827 class QAPL_Form_Fields_Helper{ 828 private static $file_helper; 829 //set the QAPL_File_Helper instance if not already done 830 private static function get_file_helper() { 831 if (!self::$file_helper) { 832 self::$file_helper = QAPL_File_Helper::get_instance(); 833 } 834 return self::$file_helper; 835 } 836 //select post type 837 public static function get_field_select_post_type(){ 838 $post_types = get_post_types(array('public' => true, 'publicly_queryable' => true), 'objects'); 839 $post_type_options = array(); 840 foreach ($post_types as $post_type) { 841 if (isset($post_type->labels->name) && $post_type->labels->name !== 'Media') { 842 $post_type_options[] = array( 843 'label' => $post_type->labels->name, 844 'value' => $post_type->name, 845 ); 846 } 847 } 848 $field_properties = array( 849 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_select_post_type(), 850 'label' => __('Select Post Type', 'quick-ajax-post-loader'), 851 'type' => 'select', 852 'options' => $post_type_options, 853 'description' => __('Choose the post type you want to display using AJAX.', 'quick-ajax-post-loader') 854 ); 855 return $field_properties; 856 } 857 //show taxonomy checkbox 858 public static function get_field_show_taxonomy_filter(){ 859 return array( 860 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_show_taxonomy_filter(), 861 'label' => __('Show Taxonomy Filter', 'quick-ajax-post-loader'), 862 'type' => 'checkbox', 863 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_show_taxonomy_filter_default_value(), 864 'description' => __('Enable filtering by taxonomy/category.', 'quick-ajax-post-loader') 865 ); 866 } 867 //select taxonomy 868 public static function get_field_select_taxonomy(){ 869 return array( 870 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_select_taxonomy(), 871 'label' => __('Select Taxonomy', 'quick-ajax-post-loader'), 872 'type' => 'select', 873 'options' => '', 874 'default' => '', 875 'description' => __('Select the taxonomy to be used for filtering posts.', 'quick-ajax-post-loader') 876 ); 877 } 878 //manual term selection checkbox 879 public static function get_field_manual_term_selection(){ 880 return array( 881 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_manual_term_selection(), 882 'label' => __('Select Specific Terms', 'quick-ajax-post-loader'), 883 'type' => 'checkbox', 884 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_manual_term_selection_default_value(), 885 'description' => __('Enable manual selection of taxonomy terms to be used for filtering.', 'quick-ajax-post-loader') 886 ); 887 } 888 //manual selected terms multiselect 889 public static function get_field_manual_selected_terms(){ 890 return array( 891 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_manual_selected_terms(), 892 'label' => __('Choose Terms', 'quick-ajax-post-loader'), 893 'type' => 'multiselect', 894 'options' => '', 895 'default' => array(), 896 'description' => __('Select the specific terms to be used for filtering posts. If left empty, no results will be shown.', 'quick-ajax-post-loader') 897 ); 898 } 899 //post per page number 900 public static function get_field_select_posts_per_page(){ 901 return array( 902 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_select_posts_per_page(), 903 'label' => __('Posts Per Page', 'quick-ajax-post-loader'), 904 'type' => 'number', 905 'options' => '', 906 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_select_posts_per_page_default_value(), 907 'description' => __('Determine the number of posts to be loaded per AJAX request.', 'quick-ajax-post-loader') 908 ); 909 } 910 //select post order 911 public static function get_field_select_order(){ 912 $order_options = array( 913 array( 914 'label' => __('Descending - order from highest to lowest', 'quick-ajax-post-loader'), 915 'value' => 'DESC' 916 ), 917 array( 918 'label' => __('Ascending - order from lowest to highest', 'quick-ajax-post-loader'), 919 'value' => 'ASC' 920 ) 921 ); 922 $field_properties = array( 923 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_select_order(), 924 'label' => __('Default Sort Order', 'quick-ajax-post-loader'), 925 'type' => 'select', 926 'options' => $order_options, 927 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_select_order_default_value(), 928 'description' => __('Specify the order of posts.', 'quick-ajax-post-loader') 929 ); 930 return $field_properties; 931 } 932 933 //select post orderby 934 public static function get_field_select_orderby(){ 935 $orderby_options = [ 936 ['value' => 'date', 'label' => __('Date: Sort by publication date', 'quick-ajax-post-loader')], 937 ['value' => 'title', 'label' => __('Title: Sort by post title', 'quick-ajax-post-loader')], 938 ['value' => 'comment_count', 'label' => __('Comments: Sort by comment count', 'quick-ajax-post-loader')], 939 ['value' => 'rand', 'label' => __('Random: Random order', 'quick-ajax-post-loader')], 940 //['value' => 'menu_order', 'label' => __('Menu Order: Sort by custom menu order', 'quick-ajax-post-loader')], 941 ]; 942 $field_properties = array( 943 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_select_orderby(), 944 'label' => __('Default Sort By', 'quick-ajax-post-loader'), 945 'type' => 'select', 946 'options' => $orderby_options, 947 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_select_orderby_default_value(), 948 'description' => __('Choose the sorting criteria for posts.', 'quick-ajax-post-loader') 949 ); 950 return $field_properties; 951 } 952 953 //show sort button 954 public static function get_field_show_sort_button(){ 955 return array( 956 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_show_sort_button(), 957 'label' => __('Show Sorting Button', 'quick-ajax-post-loader'), 958 'type' => 'checkbox', 959 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_show_sort_button_default_value(), 960 'description' => __('Enable a button that allows users to switch between ascending and descending order.', 'quick-ajax-post-loader') 961 ); 962 } 963 964 //select sort button 965 public static function get_field_select_sort_button_options(){ 966 return array( 967 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_select_sort_button_options(), 968 'label' => __('Available Sorting Options', 'quick-ajax-post-loader'), 969 'type' => 'multiselect', 970 'options' => QAPL_Quick_Ajax_Helper::shortcode_page_select_sort_button_options_values(), 971 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_select_sort_button_options_default_value(), 972 'description' => __('Select which sorting options will be available to users.', 'quick-ajax-post-loader') 973 ); 974 } 975 public static function get_field_show_inline_filter_sorting(){ 976 return array( 977 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_show_inline_filter_sorting(), 978 'label' => __('Inline Filter & Sorting', 'quick-ajax-post-loader'), 979 'type' => 'checkbox', 980 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_show_inline_filter_sorting_default_value(), 981 'description' => __('Display taxonomy filter and sorting options in a single row to save space and improve layout', 'quick-ajax-post-loader') 982 ); 983 } 984 985 //select post status 986 /*public static function get_field_select_post_status(){ 987 $post_status_options = array( 988 array( 758 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 759 $builder->set_name(QAPLC::QUERY_SETTING_SELECT_SORT_BUTTON_OPTIONS); 760 $builder->set_label(__('Available Sorting Options', 'quick-ajax-post-loader')); 761 $builder->set_type('multiselect'); 762 $builder->set_options($sort_options); 763 $builder->set_default(QAPLC::QUERY_SETTING_SELECT_SORT_BUTTON_OPTIONS_DEFAULT); 764 $builder->set_description(__('Select which sorting options will be available to users.', 'quick-ajax-post-loader')); 765 return $builder->build(); 766 } 767 //Inline Filter & Sorting 768 public static function build_show_inline_filter_sorting_field(): QAPL_Quick_Ajax_Form_Field_Interface { 769 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 770 $builder->set_name(QAPLC::QUERY_SETTING_SHOW_INLINE_FILTER_SORTING); 771 $builder->set_label(__('Inline Filter & Sorting', 'quick-ajax-post-loader')); 772 $builder->set_type('checkbox'); 773 $builder->set_default(QAPLC::QUERY_SETTING_SHOW_INLINE_FILTER_SORTING_DEFAULT); 774 $builder->set_description(__('Display taxonomy filter and sorting options in a single row to save space and improve layout.', 'quick-ajax-post-loader')); 775 return $builder->build(); 776 } 777 /* 778 public static function create_post_status_field(): QAPL_Quick_Ajax_Form_Field_Interface { 779 $post_status_options = [ 780 [ 989 781 'label' => __('Publish: Published posts', 'quick-ajax-post-loader'), 990 782 'value' => 'publish' 991 ),992 array(783 ], 784 [ 993 785 'label' => __('Draft: Draft posts', 'quick-ajax-post-loader'), 994 786 'value' => 'draft' 995 ),996 array(787 ], 788 [ 997 789 'label' => __('Pending: Pending review posts', 'quick-ajax-post-loader'), 998 790 'value' => 'pending' 999 ),1000 array(791 ], 792 [ 1001 793 'label' => __('Private: Private posts', 'quick-ajax-post-loader'), 1002 794 'value' => 'private' 1003 ),1004 array(795 ], 796 [ 1005 797 'label' => __('Trash: Trashed posts', 'quick-ajax-post-loader'), 1006 798 'value' => 'trash' 1007 ),1008 array(799 ], 800 [ 1009 801 'label' => __('Auto-Draft: Auto-draft posts', 'quick-ajax-post-loader'), 1010 802 'value' => 'auto-draft' 1011 ),1012 array(803 ], 804 [ 1013 805 'label' => __('Inherit: Inherited posts', 'quick-ajax-post-loader'), 1014 806 'value' => 'inherit' 1015 ), 1016 ); 1017 $field_properties = array( 1018 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_select_post_status(), 1019 'label' => __('Post Status', 'quick-ajax-post-loader'), 1020 'type' => 'select', 1021 'options' => $post_status_options, 1022 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_select_post_status_default_value(), 1023 'description' => __('Select the post status to be used by AJAX.', 'quick-ajax-post-loader') 1024 ); 1025 return $field_properties; 807 ], 808 ]; 809 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 810 $builder->set_name(QAPLC::QUERY_SETTING_SELECT_POST_STATUS); 811 $builder->set_label(__('Post Status', 'quick-ajax-post-loader')); 812 $builder->set_type('select'); 813 $builder->set_options($post_status_options); 814 $builder->set_default(QAPLC::QUERY_SETTING_SELECT_POST_STATUS_DEFAULT); 815 $builder->set_description(__('Select the post status to be used by AJAX.', 'quick-ajax-post-loader')); 816 return $builder->build(); 1026 817 }*/ 1027 818 //add Excluded Post IDs 1028 public static function get_field_set_post_not_in(){ 1029 $field_properties = array( 1030 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_set_post_not_in(), 1031 'label' => __('Excluded Post IDs', 'quick-ajax-post-loader'), 1032 'type' => 'text', 1033 'options' => '', 1034 'default' => '', 1035 'placeholder' => '3, 66, 999', 1036 'description' => __('Enter a list of post IDs to exclude from the query.', 'quick-ajax-post-loader'), 1037 ); 1038 return $field_properties; 819 public static function build_excluded_post_ids_field(): QAPL_Quick_Ajax_Form_Field_Interface { 820 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 821 $builder->set_name(QAPLC::QUERY_SETTING_SET_POST_NOT_IN); 822 $builder->set_label(__('Excluded Post IDs', 'quick-ajax-post-loader')); 823 $builder->set_type('text'); 824 $builder->set_default(''); 825 $builder->set_placeholder('3, 66, 999'); 826 $builder->set_description(__('Enter a list of post IDs to exclude from the query.', 'quick-ajax-post-loader')); 827 return $builder->build(); 1039 828 } 1040 829 //set Ignore Sticky Posts 1041 public static function get_field_set_ignore_sticky_posts(){ 1042 return array( 1043 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_ignore_sticky_posts(), 1044 'label' => __('Ignore Sticky Posts', 'quick-ajax-post-loader'), 1045 'type' => 'checkbox', 1046 'options' => '', 1047 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_ignore_sticky_posts_default_value(), 1048 'description' => __('Specify to ignore sticky posts, treating them as regular posts in the query.', 'quick-ajax-post-loader') 1049 ); 830 public static function build_ignore_sticky_posts_field(): QAPL_Quick_Ajax_Form_Field_Interface { 831 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 832 $builder->set_name(QAPLC::QUERY_SETTING_IGNORE_STICKY_POSTS); 833 $builder->set_label(__('Ignore Sticky Posts', 'quick-ajax-post-loader')); 834 $builder->set_type('checkbox'); 835 $builder->set_default(QAPLC::QUERY_SETTING_IGNORE_STICKY_POSTS_DEFAULT); 836 $builder->set_description(__('Specify to ignore sticky posts, treating them as regular posts in the query.', 'quick-ajax-post-loader')); 837 return $builder->build(); 1050 838 } 1051 839 //add Load Posts via AJAX on Initial Load 1052 public static function get_field_set_ajax_on_initial_load(){ 1053 return array( 1054 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_ajax_on_initial_load(), 1055 'label' => __('Load Initial Posts via AJAX', 'quick-ajax-post-loader'), 1056 'type' => 'checkbox', 1057 'options' => '', 1058 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_ajax_on_initial_load_default_value(), 1059 'description' => __('Enable this option to load the initial set of posts via AJAX on page load. This can help in cases where caching might cause outdated content to be displayed.', 'quick-ajax-post-loader') 1060 ); 840 public static function build_ajax_on_initial_load_field(): QAPL_Quick_Ajax_Form_Field_Interface { 841 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 842 $builder->set_name(QAPLC::QUERY_SETTING_AJAX_ON_INITIAL_LOAD); 843 $builder->set_label(__('Load Initial Posts via AJAX', 'quick-ajax-post-loader')); 844 $builder->set_type('checkbox'); 845 $builder->set_default(QAPLC::QUERY_SETTING_AJAX_ON_INITIAL_LOAD_DEFAULT); 846 $builder->set_description(__('Enable this option to load the initial set of posts via AJAX on page load. This can help in cases where caching might cause outdated content to be displayed.', 'quick-ajax-post-loader')); 847 return $builder->build(); 1061 848 } 1062 849 // add Infinite Scroll via AJAX 1063 public static function get_field_set_ajax_infinite_scroll(){ 1064 return array( 1065 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_ajax_infinite_scroll(), 1066 'label' => __('Enable Infinite Scroll', 'quick-ajax-post-loader'), 1067 'type' => 'checkbox', 1068 'options' => '', 1069 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_ajax_infinite_scroll_default_value(), 1070 'description' => __('Enable this option to automatically load more posts via AJAX as the user scrolls down the page.', 'quick-ajax-post-loader') 1071 ); 850 public static function build_ajax_infinite_scroll_field(): QAPL_Quick_Ajax_Form_Field_Interface { 851 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 852 $builder->set_name(QAPLC::QUERY_SETTING_AJAX_INFINITE_SCROLL); 853 $builder->set_label(__('Enable Infinite Scroll', 'quick-ajax-post-loader')); 854 $builder->set_type('checkbox'); 855 $builder->set_default(QAPLC::QUERY_SETTING_AJAX_INFINITE_SCROLL_DEFAULT); 856 $builder->set_description(__('Enable this option to automatically load more posts via AJAX as the user scrolls down the page.', 'quick-ajax-post-loader')); 857 return $builder->build(); 1072 858 } 1073 859 // show end message 1074 public static function get_field_set_show_end_message() { 1075 return array( 1076 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_show_end_message(), 1077 'label' => __('Show End Message', 'quick-ajax-post-loader'), 1078 'type' => 'checkbox', 1079 'options' => '', 1080 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_show_end_message_default_value(), 1081 'description' => __('Display a message when there are no more posts to load via AJAX.', 'quick-ajax-post-loader') 1082 ); 1083 } 1084 860 public static function build_show_end_message_field(): QAPL_Quick_Ajax_Form_Field_Interface { 861 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 862 $builder->set_name(QAPLC::QUERY_SETTING_SHOW_END_MESSAGE); 863 $builder->set_label(__('Show End Message', 'quick-ajax-post-loader')); 864 $builder->set_type('checkbox'); 865 $builder->set_default(QAPLC::QUERY_SETTING_SHOW_END_MESSAGE_DEFAULT); 866 $builder->set_description(__('Display a message when there are no more posts to load via AJAX.', 'quick-ajax-post-loader')); 867 return $builder->build(); 868 } 1085 869 //apply quick ajax css style 1086 public static function get_field_layout_quick_ajax_css_style(){ 1087 $field_properties = array( 1088 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_layout_quick_ajax_css_style(), 1089 'label' => __('Apply Quick AJAX CSS Style', 'quick-ajax-post-loader'), 1090 'type' => 'checkbox', 1091 'options' => '', 1092 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_layout_quick_ajax_css_style_default_value(), 1093 'description' => __('Apply Quick AJAX CSS styles and column layout.', 'quick-ajax-post-loader') 1094 ); 1095 return $field_properties; 870 public static function build_quick_ajax_css_style_field(): QAPL_Quick_Ajax_Form_Field_Interface { 871 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 872 $builder->set_name(QAPLC::LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE); 873 $builder->set_label(__('Apply Quick AJAX CSS Style', 'quick-ajax-post-loader')); 874 $builder->set_type('checkbox'); 875 $builder->set_default(QAPLC::LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE_DEFAULT); 876 $builder->set_description(__('Apply Quick AJAX CSS styles and column layout.', 'quick-ajax-post-loader')); 877 return $builder->build(); 1096 878 } 1097 879 //select number of columns 1098 public static function get_field_layout_select_columns_qty(){1099 $columns_ qty_options = array();1100 for ($i = 1; $i <= 12; $i++) {1101 $columns_ qty_options[] = array(880 public static function build_select_columns_qty_field(): QAPL_Quick_Ajax_Form_Field_Interface { 881 $columns_options = []; 882 for ($i = 1; $i <= 12; $i++) { 883 $columns_options[] = array( 1102 884 'label' => strval($i), 1103 885 'value' => $i 1104 886 ); 1105 887 } 1106 $field_properties = array( 1107 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_layout_select_columns_qty(), 1108 'label' => __('Number of Columns', 'quick-ajax-post-loader'), 1109 'type' => 'select', 1110 'options' => $columns_qty_options, 1111 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_layout_select_columns_qty_default_value(), 1112 'description' => __('Specify the quantity of columns.', 'quick-ajax-post-loader') 888 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 889 $builder->set_name(QAPLC::LAYOUT_SETTING_SELECT_COLUMNS_QTY); 890 $builder->set_label(__('Number of Columns', 'quick-ajax-post-loader')); 891 $builder->set_type('select'); 892 $builder->set_options($columns_options); 893 $builder->set_default(QAPLC::LAYOUT_SETTING_SELECT_COLUMNS_QTY_DEFAULT); 894 $builder->set_description(__('Specify the quantity of columns.', 'quick-ajax-post-loader')); 895 return $builder->build(); 896 } 897 //select post item template 898 public static function build_post_item_template_field(): QAPL_Quick_Ajax_Form_Field_Interface { 899 $file_manager = new QAPL_Quick_Ajax_File_Manager(); 900 $templates = $file_manager->get_templates_items_array('post-items/post-item*.php', 'Post Item Name:', QAPLC::LAYOUT_SETTING_POST_ITEM_TEMPLATE_DEFAULT); 901 $options = []; 902 foreach ($templates as $template) { 903 $options[] = [ 904 'label' => $template['template_name'], 905 'value' => $template['file_name'] 906 ]; 907 } 908 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 909 $builder->set_name(QAPLC::LAYOUT_SETTING_POST_ITEM_TEMPLATE); 910 $builder->set_label(__('Select Post Item Template', 'quick-ajax-post-loader')); 911 $builder->set_type('select'); 912 $builder->set_options($options); 913 $builder->set_default(QAPLC::LAYOUT_SETTING_POST_ITEM_TEMPLATE_DEFAULT); 914 $builder->set_description(__('Choose a template for displaying post items.', 'quick-ajax-post-loader')); 915 return $builder->build(); 916 } 917 //add custom class for taxonomy filter 918 public static function build_taxonomy_filter_class_field(): QAPL_Quick_Ajax_Form_Field_Interface { 919 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 920 $builder->set_name(QAPLC::LAYOUT_SETTING_TAXONOMY_FILTER_CLASS); 921 $builder->set_label(__('Add Class to Taxonomy Filter', 'quick-ajax-post-loader')); 922 $builder->set_type('text'); 923 $builder->set_default(QAPLC::LAYOUT_SETTING_TAXONOMY_FILTER_CLASS_DEFAULT); 924 $builder->set_placeholder(__('class-name, another-class-name', 'quick-ajax-post-loader')); 925 $builder->set_description(__('Add classes to the filter: class-one, class-two, class-three', 'quick-ajax-post-loader')); 926 return $builder->build(); 927 } 928 //add custom class for container 929 public static function build_container_class_field(): QAPL_Quick_Ajax_Form_Field_Interface { 930 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 931 $builder->set_name(QAPLC::LAYOUT_SETTING_CONTAINER_CLASS); 932 $builder->set_label(__('Add Class to Post Container', 'quick-ajax-post-loader')); 933 $builder->set_type('text'); 934 $builder->set_default(QAPLC::LAYOUT_SETTING_CONTAINER_CLASS_DEFAULT); 935 $builder->set_placeholder(__('class-name, another-class-name', 'quick-ajax-post-loader')); 936 $builder->set_description(__('Add classes to the post container: class-one, class-two, class-three', 'quick-ajax-post-loader')); 937 return $builder->build(); 938 } 939 //show custom load more post quantity 940 public static function build_show_custom_load_more_post_quantity_field(): QAPL_Quick_Ajax_Form_Field_Interface { 941 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 942 $builder->set_name(QAPLC::QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY); 943 $builder->set_label(__('Load More Post Quantity', 'quick-ajax-post-loader')); 944 $builder->set_type('checkbox'); 945 $builder->set_default(QAPLC::QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY_DEFAULT); 946 $builder->set_description(__('Load a different number of posts after the initial display.', 'quick-ajax-post-loader')); 947 return $builder->build(); 948 } 949 //select custom load more post quantity 950 public static function build_select_custom_load_more_post_quantity_field(): QAPL_Quick_Ajax_Form_Field_Interface { 951 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 952 $builder->set_name(QAPLC::QUERY_SETTING_SELECT_CUSTOM_LOAD_MORE_POST_QUANTITY); 953 $builder->set_label(__('Posts Per Load (After Initial)', 'quick-ajax-post-loader')); 954 $builder->set_type('number'); 955 $builder->set_default(QAPLC::QUERY_SETTING_SELECT_CUSTOM_LOAD_MORE_POST_QUANTITY_DEFAULT); 956 $builder->set_description(__('Set how many posts to load each time the "Load More" button is clicked.', 'quick-ajax-post-loader')); 957 return $builder->build(); 958 } 959 //override global loader icon 960 public static function build_override_global_loader_icon_field(): QAPL_Quick_Ajax_Form_Field_Interface { 961 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 962 $builder->set_name(QAPLC::LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON); 963 $builder->set_label(__('Override Global Loader Icon', 'quick-ajax-post-loader')); 964 $builder->set_type('checkbox'); 965 $builder->set_default(QAPLC::LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON_DEFAULT); 966 $builder->set_description(__('Set a different loader icon than the one specified in global options.', 'quick-ajax-post-loader')); 967 return $builder->build(); 968 } 969 //select loader icon 970 public static function build_select_loader_icon(): QAPL_Quick_Ajax_Form_Field_Interface { 971 return self::loader_icon_get_field( 972 QAPLC::LAYOUT_SETTING_SELECT_LOADER_ICON, 973 QAPLC::LAYOUT_SETTING_SELECT_LOADER_ICON_DEFAULT 1113 974 ); 1114 return $field_properties; 1115 } 1116 //select post item template 1117 public static function get_field_layout_post_item_template(){ 1118 $post_item_template_options = array(); 1119 $file_helper = self::get_file_helper(); 1120 $post_item_templates = $file_helper->plugin_get_templates_items_array('post-items/post-item*.php', 'Post Item Name:', QAPL_Quick_Ajax_Helper::shortcode_page_layout_post_item_template_default_value()); 1121 foreach($post_item_templates as $item){ 1122 $post_item_template_options[] = array( 975 } 976 //select loader icon global 977 public static function build_global_select_loader_icon(): QAPL_Quick_Ajax_Form_Field_Interface { 978 return self::loader_icon_get_field( 979 QAPLC::GLOBAL_LOADER_ICON_FIELD, 980 QAPLC::LAYOUT_SETTING_SELECT_LOADER_ICON_DEFAULT 981 ); 982 } 983 //build loader icon select field 984 private static function loader_icon_get_field(string $name, string $default): QAPL_Quick_Ajax_Form_Field_Interface { 985 $file_helper = new QAPL_Quick_Ajax_File_Manager(); 986 $templates = $file_helper->get_templates_items_array('loader-icon/*.php','Loader Icon Name:',$default); 987 $options = []; 988 foreach ($templates as $item) { 989 $options[] = [ 1123 990 'label' => $item['template_name'], 1124 991 'value' => $item['file_name'] 1125 ); 1126 } 1127 $field_properties = array( 1128 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_layout_post_item_template(), 1129 'label' => __('Select Post Item Template', 'quick-ajax-post-loader'), 1130 'type' => 'select', 1131 'options' => $post_item_template_options, 1132 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_layout_post_item_template_default_value(), 1133 'description' => __('Choose a template for displaying post items.', 'quick-ajax-post-loader') 1134 ); 1135 return $field_properties; 1136 } 1137 //add custom class for taxonomy filter 1138 public static function get_field_layout_taxonomy_filter_class(){ 1139 $field_properties = array( 1140 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_layout_taxonomy_filter_class(), 1141 'label' => __('Add Class to Taxonomy Filter', 'quick-ajax-post-loader'), 1142 'type' => 'text', 1143 'options' => '', 1144 'default' => '', 1145 'placeholder' => __('class-name, another-class-name', 'quick-ajax-post-loader'), 1146 'description' => __('Add classes to the filter: class-one, class-two, class-three', 'quick-ajax-post-loader') 1147 ); 1148 return $field_properties; 1149 } 1150 //add custom class for container 1151 public static function get_field_layout_container_class(){ 1152 $field_properties = array( 1153 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_layout_container_class(), 1154 'label' => __('Add Class to Post Container', 'quick-ajax-post-loader'), 1155 'type' => 'text', 1156 'options' => '', 1157 'default' => '', 1158 'placeholder' => __('class-name, another-class-name', 'quick-ajax-post-loader'), 1159 'description' => __('Add classes to the post container: class-one, class-two, class-three', 'quick-ajax-post-loader') 1160 ); 1161 return $field_properties; 1162 } 1163 //show custom load more post quantity 1164 public static function get_field_show_custom_load_more_post_quantity(){ 1165 $field_properties = array( 1166 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_show_custom_load_more_post_quantity(), 1167 'label' => __('Load More Post Quantity', 'quick-ajax-post-loader'), 1168 'type' => 'checkbox', 1169 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_show_custom_load_more_post_quantity_default_value(), 1170 'description' => __('Load a different number of posts after the initial display.', 'quick-ajax-post-loader') 1171 ); 1172 return $field_properties; 1173 } 1174 //select custom load more post quantity 1175 public static function get_field_select_custom_load_more_post_quantity(){ 1176 $field_properties = array( 1177 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_select_custom_load_more_post_quantity(), 1178 'label' => __('Posts Per Load (After Initial)', 'quick-ajax-post-loader'), 1179 'type' => 'number', 1180 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_select_custom_load_more_post_quantity_default_value(), 1181 'description' => __('Set how many posts to load each time the "Load More" button is clicked.', 'quick-ajax-post-loader') 1182 ); 1183 return $field_properties; 1184 } 1185 //override global loader icon 1186 public static function get_field_override_global_loader_icon(){ 1187 $field_properties = array( 1188 'name' => QAPL_Quick_Ajax_Helper::shortcode_page_override_global_loader_icon(), 1189 'label' => __('Override Global Loader Icon', 'quick-ajax-post-loader'), 1190 'type' => 'checkbox', 1191 'default' => QAPL_Quick_Ajax_Helper::shortcode_page_override_global_loader_icon_default_value(), 1192 'description' => __('Set a different loader icon than the one specified in global options.', 'quick-ajax-post-loader') 1193 ); 1194 return $field_properties; 1195 } 1196 //select loader icon 1197 public static function get_field_select_loader_icon(){ 1198 $field_properties = self::select_loader_icon_properties(QAPL_Quick_Ajax_Helper::shortcode_page_select_loader_icon(), QAPL_Quick_Ajax_Helper::shortcode_page_select_loader_icon_default_value()); 1199 return $field_properties; 1200 } 1201 //select loader icon global 1202 public static function get_global_field_select_loader_icon(){ 1203 $field_properties = self::select_loader_icon_properties(QAPL_Quick_Ajax_Helper::global_options_field_select_loader_icon(), QAPL_Quick_Ajax_Helper::shortcode_page_select_loader_icon_default_value()); 1204 return $field_properties; 1205 } 1206 private static function select_loader_icon_properties($field_name, $field_default_value) { 1207 $loader_icon_options = array(); 1208 $file_helper = self::get_file_helper(); 1209 $loader_icon_templates = $file_helper->plugin_get_templates_items_array('loader-icon/*.php', 'Loader Icon Name:', QAPL_Quick_Ajax_Helper::shortcode_page_select_loader_icon_default_value()); 1210 foreach($loader_icon_templates as $item){ 1211 $loader_icon_options[] = array( 1212 'label' => $item['template_name'], 1213 'value' => $item['file_name'] 1214 ); 1215 } 1216 $field_properties = array( 1217 'name' => $field_name, 1218 'label' => __('Select Loader Icon', 'quick-ajax-post-loader'), 1219 'type' => 'select', 1220 'options' => $loader_icon_options, 1221 'default' => $field_default_value, 1222 'description' => __('Choose an icon to display as the loading indicator when the "Load More" button is clicked.', 'quick-ajax-post-loader') 1223 ); 1224 return $field_properties; 1225 } 1226 public static function get_global_options_field_set_read_more_label(){ 1227 $field_properties = array( 1228 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_read_more_label(), 1229 'label' => __('Set "Read More" Label', 'quick-ajax-post-loader'), 1230 'type' => 'text', 1231 'options' => '', // Not required for text field 1232 'default' => __('Read More', 'quick-ajax-post-loader'), 1233 'placeholder' => __('Enter custom label for Read More', 'quick-ajax-post-loader'), 1234 'description' => __('Customize the "Read More" text for your templates. This label will appear as a link or button for each post item. Examples: "Read More", "Continue Reading", or "Learn More".', 'quick-ajax-post-loader') 1235 ); 1236 return $field_properties; 1237 } 1238 public static function get_global_options_field_set_show_all_label(){ 1239 $field_properties = array( 1240 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_show_all_label(), 1241 'label' => __('Set "Show All" Label', 'quick-ajax-post-loader'), 1242 'type' => 'text', 1243 'options' => '', // Not required for text field 1244 'default' => __('Show All', 'quick-ajax-post-loader'), 1245 'placeholder' => __('Enter custom label for Show All', 'quick-ajax-post-loader'), 1246 'description' => __('Customize the "Show All" text label for the filter. This label will appear as an option to display all posts without filtering. Examples: "Show All", "View All", or "Display All".', 'quick-ajax-post-loader') 1247 ); 1248 return $field_properties; 1249 } 1250 public static function get_global_options_field_set_load_more_label() { 1251 $field_properties = array( 1252 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_load_more_label(), 1253 'label' => __('Set "Load More" Label', 'quick-ajax-post-loader'), 1254 'type' => 'text', 1255 'options' => '', // Not required for text field 1256 'default' => __('Load More', 'quick-ajax-post-loader'), 1257 'placeholder' => __('Enter custom label for Load More', 'quick-ajax-post-loader'), 1258 'description' => __('Customize the "Load More" button text. This label will appear on the button used to load additional posts dynamically. Examples: "Load More", "Show More", or "View More".', 'quick-ajax-post-loader') 1259 ); 1260 return $field_properties; 1261 } 1262 public static function get_global_options_field_set_no_post_message() { 1263 $field_properties = array( 1264 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_no_post_message(), 1265 'label' => __('Set "No Posts Found" Message', 'quick-ajax-post-loader'), 1266 'type' => 'text', 1267 'options' => '', // Not required for text field 1268 'default' => __('No posts found', 'quick-ajax-post-loader'), 1269 'placeholder' => __('Enter message for no posts found', 'quick-ajax-post-loader'), 1270 'description' => __('Customize the message shown when no posts match the selected filters. Examples: "No posts found", "Nothing to display", or "Try adjusting your filters".', 'quick-ajax-post-loader') 1271 ); 1272 return $field_properties; 1273 } 1274 public static function get_global_options_field_set_end_post_message() { 1275 $field_properties = array( 1276 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_end_post_message(), 1277 'label' => __('Set "End of Posts" Message', 'quick-ajax-post-loader'), 1278 'type' => 'text', 1279 'options' => '', // Not required for text field 1280 'default' => __('No more posts to load', 'quick-ajax-post-loader'), 1281 'placeholder' => __('Enter message for end of posts', 'quick-ajax-post-loader'), 1282 'description' => __('Customize the message that appears when there are no more posts to load. Examples: "No more posts", "You have reached the end", or "That\'s all for now".', 'quick-ajax-post-loader') 1283 ); 1284 return $field_properties; 1285 } 1286 public static function get_global_options_field_set_post_date_format() { 1287 $field_properties = array( 1288 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_post_date_format(), 1289 'label' => __('Set Date Format', 'quick-ajax-post-loader'), 1290 'type' => 'text', 1291 'options' => '', // Not required for text field 1292 'default' => 'F j, Y', 1293 'placeholder' => __('Enter date format (e.g., F j, Y)', 'quick-ajax-post-loader'), 1294 'description' => __('Customize the format for displaying post dates. This text will replace the default date format. For example: "F j, Y" (January 1, 2023) or "Y-m-d" (2023-01-01). Refer to the PHP date format documentation for more options.', 'quick-ajax-post-loader'), 1295 ); 1296 return $field_properties; 1297 } 1298 public static function get_global_options_field_set_sort_option_date_desc_label() { 1299 $field_properties = array( 1300 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_sort_option_date_desc_label(), 1301 'label' => __('Set "Newest" Label', 'quick-ajax-post-loader'), 1302 'type' => 'text', 1303 'options' => '', // Not required for text field 1304 'default' => __('Newest', 'quick-ajax-post-loader'), 1305 'placeholder' => __('Newest', 'quick-ajax-post-loader'), 1306 'description' => __('Set the label for sorting posts from newest to oldest (based on publication date). Examples: "Newest", "Latest", "Recent".', 'quick-ajax-post-loader') 1307 ); 1308 return $field_properties; 1309 } 1310 public static function get_global_options_field_set_sort_option_date_asc_label() { 1311 $field_properties = array( 1312 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_sort_option_date_asc_label(), 1313 'label' => __('Set "Oldest" Label', 'quick-ajax-post-loader'), 1314 'type' => 'text', 1315 'options' => '', // Not required for text field 1316 'default' => __('Oldest', 'quick-ajax-post-loader'), 1317 'placeholder' => __('Oldest', 'quick-ajax-post-loader'), 1318 'description' => __('Set the label for sorting posts from oldest to newest (based on publication date). Examples: "Oldest", "First", "Earliest".', 'quick-ajax-post-loader') 1319 ); 1320 return $field_properties; 1321 } 1322 public static function get_global_options_field_set_sort_option_comment_count_desc_label() { 1323 $field_properties = array( 1324 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_sort_option_comment_count_desc_label(), 1325 'label' => __('Set "Popular" Label', 'quick-ajax-post-loader'), 1326 'type' => 'text', 1327 'options' => '', // Not required for text field 1328 'default' => __('Popular', 'quick-ajax-post-loader'), 1329 'placeholder' => __('Popular', 'quick-ajax-post-loader'), 1330 'description' => __('Set the label for sorting posts by the highest number of comments. Examples: "Popular", "Trending", "Most Discussed".', 'quick-ajax-post-loader') 1331 ); 1332 return $field_properties; 1333 } 1334 public static function get_global_options_field_set_sort_option_title_asc_label() { 1335 $field_properties = array( 1336 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_sort_option_title_asc_label(), 1337 'label' => __('Set "A → Z" Label', 'quick-ajax-post-loader'), 1338 'type' => 'text', 1339 'options' => '', // Not required for text field 1340 'default' => __('A → Z', 'quick-ajax-post-loader'), 1341 'placeholder' => __('A → Z', 'quick-ajax-post-loader'), 1342 'description' => __('Set the label for sorting posts alphabetically (A to Z) based on the post title. Examples: "Alphabetical", "A → Z", "Sort by Name".', 'quick-ajax-post-loader') 1343 ); 1344 return $field_properties; 1345 } 1346 public static function get_global_options_field_set_sort_option_title_desc_label() { 1347 $field_properties = array( 1348 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_sort_option_title_desc_label(), 1349 'label' => __('Set "Z → A" Label', 'quick-ajax-post-loader'), 1350 'type' => 'text', 1351 'options' => '', // Not required for text field 1352 'default' => __('Z → A', 'quick-ajax-post-loader'), 1353 'placeholder' => __('Z → A', 'quick-ajax-post-loader'), 1354 'description' => __('Set the label for sorting posts alphabetically (Z to A) based on the post title. Examples: "Reverse Alphabetical", "Z → A", "Sort by Name Descending".', 'quick-ajax-post-loader') 1355 ); 1356 return $field_properties; 1357 } 1358 public static function get_global_options_field_set_sort_option_rand_label() { 1359 $field_properties = array( 1360 'name' => QAPL_Quick_Ajax_Helper::global_options_field_set_sort_option_rand_label(), 1361 'label' => __('Set "Random" Label', 'quick-ajax-post-loader'), 1362 'type' => 'text', 1363 'options' => '', // Not required for text field 1364 'default' => __('Random', 'quick-ajax-post-loader'), 1365 'placeholder' => __('Random', 'quick-ajax-post-loader'), 1366 'description' => __('Set the label for sorting posts in a random order. Examples: "Shuffle", "Random", "Surprise Me".', 'quick-ajax-post-loader') 1367 ); 1368 return $field_properties; 1369 } 1370 public static function get_global_field_remove_old_data(){ 1371 return array( 1372 'name' => 'qapl_remove_old_meta', 1373 'label' => __('Confirm Purge of Old Data', 'quick-ajax-post-loader'), 1374 'type' => 'checkbox', 1375 'options' => '', 1376 'default' => 0, 1377 'description' => __('Choose this option to remove old, unused data from the database. This will help keep your site clean and efficient. Be aware that if you switch back to an older version of the plugin, it might not work as expected.', 'quick-ajax-post-loader'), 1378 ); 1379 } 1380 } 1381 1382 class QAPL_Hooks { 992 ]; 993 } 994 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 995 $builder->set_name($name); 996 $builder->set_label(__('Select Loader Icon', 'quick-ajax-post-loader')); 997 $builder->set_type('select'); 998 $builder->set_options($options); 999 $builder->set_default($default); 1000 $builder->set_description(__('Choose an icon to display as the loading indicator when the "Load More" button is clicked.', 'quick-ajax-post-loader')); 1001 return $builder->build(); 1002 } 1003 //build global options set read more 1004 public static function build_global_read_more_text_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1005 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1006 $builder->set_name(QAPLC::GLOBAL_READ_MORE_LABEL_FIELD); 1007 $builder->set_label(__('Set "Read More" Label', 'quick-ajax-post-loader')); 1008 $builder->set_type('text'); 1009 $builder->set_default(__('Read More', 'quick-ajax-post-loader')); 1010 $builder->set_placeholder(__('Enter custom label for Read More', 'quick-ajax-post-loader')); 1011 $builder->set_description(__('Customize the "Read More" text for your templates. This label will appear as a link or button for each post item. Examples: "Read More", "Continue Reading", or "Learn More".', 'quick-ajax-post-loader')); 1012 return $builder->build(); 1013 } 1014 //build global options set show all label 1015 public static function build_global_show_all_label_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1016 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1017 $builder->set_name(QAPLC::GLOBAL_SHOW_ALL_LABEL_FIELD); 1018 $builder->set_label(__('Set "Show All" Label', 'quick-ajax-post-loader')); 1019 $builder->set_type('text'); 1020 $builder->set_default(__('Show All', 'quick-ajax-post-loader')); 1021 $builder->set_placeholder(__('Enter custom label for Show All', 'quick-ajax-post-loader')); 1022 $builder->set_description(__('Customize the "Show All" text label for the filter. This label will appear as an option to display all posts without filtering. Examples: "Show All", "View All", or "Display All".', 'quick-ajax-post-loader')); 1023 return $builder->build(); 1024 } 1025 //build global options set load more label 1026 public static function build_global_load_more_label_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1027 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1028 $builder->set_name(QAPLC::GLOBAL_LOAD_MORE_LABEL_FIELD); 1029 $builder->set_label(__('Set "Load More" Label', 'quick-ajax-post-loader')); 1030 $builder->set_type('text'); 1031 $builder->set_default(__('Load More', 'quick-ajax-post-loader')); 1032 $builder->set_placeholder(__('Enter custom label for Load More', 'quick-ajax-post-loader')); 1033 $builder->set_description(__('Customize the "Load More" button text. This label will appear on the button used to load additional posts dynamically. Examples: "Load More", "Show More", or "View More".', 'quick-ajax-post-loader')); 1034 return $builder->build(); 1035 } 1036 //build global options set no post message 1037 public static function build_global_no_post_message_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1038 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1039 $builder->set_name(QAPLC::GLOBAL_NO_POST_MESSAGE_FIELD); 1040 $builder->set_label(__('Set "No Posts Found" Message', 'quick-ajax-post-loader')); 1041 $builder->set_type('text'); 1042 $builder->set_default(__('No posts found', 'quick-ajax-post-loader')); 1043 $builder->set_placeholder(__('Enter message for no posts found', 'quick-ajax-post-loader')); 1044 $builder->set_description(__('Customize the message shown when no posts match the selected filters. Examples: "No posts found", "Nothing to display", or "Try adjusting your filters".', 'quick-ajax-post-loader')); 1045 return $builder->build(); 1046 } 1047 //build global options set end post message 1048 public static function build_global_end_post_message_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1049 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1050 $builder->set_name(QAPLC::GLOBAL_END_POST_MESSAGE_FIELD); 1051 $builder->set_label(__('Set "End of Posts" Message', 'quick-ajax-post-loader')); 1052 $builder->set_type('text'); 1053 $builder->set_default(__('No more posts to load', 'quick-ajax-post-loader')); 1054 $builder->set_placeholder(__('Enter message for end of posts', 'quick-ajax-post-loader')); 1055 $builder->set_description(__('Customize the message that appears when there are no more posts to load. Examples: "No more posts", "You have reached the end", or "That\'s all for now".', 'quick-ajax-post-loader')); 1056 return $builder->build(); 1057 } 1058 //build global options set post date format 1059 /* 1060 public static function build_global_post_date_format_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1061 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1062 $builder->set_name(QAPLC::GLOBAL_POST_DATE_FORMAT_FIELD); 1063 $builder->set_label(__('Set Date Format', 'quick-ajax-post-loader')); 1064 $builder->set_type('text'); 1065 $builder->set_default('F j, Y'); 1066 $builder->set_placeholder(__('Enter date format (e.g., F j, Y)', 'quick-ajax-post-loader')); 1067 $builder->set_description(__('Customize the format for displaying post dates. This text will replace the default date format. For example: "F j, Y" (January 1, 2023) or "Y-m-d" (2023-01-01). Refer to the PHP date format documentation for more options.', 'quick-ajax-post-loader')); 1068 return $builder->build(); 1069 } 1070 */ 1071 //build global options set sort option date desc label 1072 public static function build_global_sort_option_date_desc_label_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1073 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1074 $builder->set_name(QAPLC::GLOBAL_SORT_OPTION_DATE_DESC_LABEL_FIELD); 1075 $builder->set_label(__('Set "Newest" Label', 'quick-ajax-post-loader')); 1076 $builder->set_type('text'); 1077 $builder->set_default(__('Newest', 'quick-ajax-post-loader')); 1078 $builder->set_placeholder(__('Newest', 'quick-ajax-post-loader')); 1079 $builder->set_description(__('Set the label for sorting posts from newest to oldest (based on publication date). Examples: "Newest", "Latest", "Recent".', 'quick-ajax-post-loader')); 1080 return $builder->build(); 1081 } 1082 //build global options set sort option date asc label 1083 public static function build_global_sort_option_date_asc_label_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1084 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1085 $builder->set_name(QAPLC::GLOBAL_SORT_OPTION_DATE_ASC_LABEL_FIELD); 1086 $builder->set_label(__('Set "Oldest" Label', 'quick-ajax-post-loader')); 1087 $builder->set_type('text'); 1088 $builder->set_default(__('Oldest', 'quick-ajax-post-loader')); 1089 $builder->set_placeholder(__('Oldest', 'quick-ajax-post-loader')); 1090 $builder->set_description(__('Set the label for sorting posts from oldest to newest (based on publication date). Examples: "Oldest", "First", "Earliest".', 'quick-ajax-post-loader')); 1091 return $builder->build(); 1092 } 1093 //build global options set sort option comment count desc label 1094 public static function build_global_sort_option_comment_count_desc_label_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1095 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1096 $builder->set_name(QAPLC::GLOBAL_SORT_OPTION_COMMENT_COUNT_DESC_LABEL_FIELD); 1097 $builder->set_label(__('Set "Popular" Label', 'quick-ajax-post-loader')); 1098 $builder->set_type('text'); 1099 $builder->set_default(__('Popular', 'quick-ajax-post-loader')); 1100 $builder->set_placeholder(__('Popular', 'quick-ajax-post-loader')); 1101 $builder->set_description(__('Set the label for sorting posts by the highest number of comments. Examples: "Popular", "Trending", "Most Discussed".', 'quick-ajax-post-loader')); 1102 return $builder->build(); 1103 } 1104 //build global options set sort option title asc label 1105 public static function build_global_sort_option_title_asc_label_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1106 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1107 $builder->set_name(QAPLC::GLOBAL_SORT_OPTION_TITLE_ASC_LABEL_FIELD); 1108 $builder->set_label(__('Set "A → Z" Label', 'quick-ajax-post-loader')); 1109 $builder->set_type('text'); 1110 $builder->set_default(__('A → Z', 'quick-ajax-post-loader')); 1111 $builder->set_placeholder(__('A → Z', 'quick-ajax-post-loader')); 1112 $builder->set_description(__('Set the label for sorting posts alphabetically (A to Z) based on the post title. Examples: "Alphabetical", "A → Z", "Sort by Name".', 'quick-ajax-post-loader')); 1113 return $builder->build(); 1114 } 1115 //build global options set sort option title desc label 1116 public static function build_global_sort_option_title_desc_label_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1117 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1118 $builder->set_name(QAPLC::GLOBAL_SORT_OPTION_TITLE_DESC_LABEL_FIELD); 1119 $builder->set_label(__('Set "Z → A" Label', 'quick-ajax-post-loader')); 1120 $builder->set_type('text'); 1121 $builder->set_default(__('Z → A', 'quick-ajax-post-loader')); 1122 $builder->set_placeholder(__('Z → A', 'quick-ajax-post-loader')); 1123 $builder->set_description(__('Set the label for sorting posts alphabetically (Z to A) based on the post title. Examples: "Reverse Alphabetical", "Z → A", "Sort by Name Descending".', 'quick-ajax-post-loader')); 1124 return $builder->build(); 1125 } 1126 //build global options set sort option rand label 1127 public static function build_global_sort_option_rand_label_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1128 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1129 $builder->set_name(QAPLC::GLOBAL_SORT_OPTION_RAND_LABEL_FIELD); 1130 $builder->set_label(__('Set "Random" Label', 'quick-ajax-post-loader')); 1131 $builder->set_type('text'); 1132 $builder->set_default(__('Random', 'quick-ajax-post-loader')); 1133 $builder->set_placeholder(__('Random', 'quick-ajax-post-loader')); 1134 $builder->set_description(__('Set the label for sorting posts in a random order. Examples: "Shuffle", "Random", "Surprise Me".', 'quick-ajax-post-loader')); 1135 return $builder->build(); 1136 } 1137 //build global field remove old data 1138 public static function build_global_remove_old_data_field(): QAPL_Quick_Ajax_Form_Field_Interface { 1139 $builder = new QAPL_Quick_Ajax_Form_Field_Builder(); 1140 $builder->set_name(QAPLC::REMOVE_OLD_DATA_FIELD); 1141 $builder->set_label(__('Confirm Purge of Old Data', 'quick-ajax-post-loader')); 1142 $builder->set_type('checkbox'); 1143 $builder->set_default(QAPLC::REMOVE_OLD_DATA_FIELD_DEFAULT); 1144 $builder->set_description(__('Choose this option to remove old, unused data from the database. This will help keep your site clean and efficient. Be aware that if you switch back to an older version of the plugin, it might not work as expected.', 'quick-ajax-post-loader')); 1145 return $builder->build(); 1146 } 1147 } 1148 1149 1150 1151 1152 1153 1154 1155 //////////////////////////////// 1156 class QAPL_Quick_Ajax_Plugin_Constants{ 1157 // Plugin info 1158 public const PLUGIN_VERSION = '1.8.0'; 1159 public const PLUGIN_NAME = 'Quick Ajax Post Loader'; 1160 public const PLUGIN_TEXT_DOMAIN = 'quick-ajax-post-loader'; 1161 public const PLUGIN_SLUG = 'quick-ajax-post-loader'; 1162 public const PLUGIN_MINIMUM_PHP_VERSION = '7.4'; 1163 public const PLUGIN_MINIMUM_WP_VERSION = '5.6'; 1164 public const PLUGIN_TESTED_WP_VERSION = '6.8'; 1165 1166 // Menu and page slugs 1167 public const PLUGIN_MENU_SLUG = 'qapl-menu'; 1168 public const CPT_SHORTCODE_SLUG = 'qapl-creator'; 1169 public const SETTINGS_PAGE_SLUG = 'qapl-settings'; 1170 1171 // Quick AJAX Creator shortcode field names 1172 public const DB_POSTMETA_SHORTCODE_SETTINGS = '_qapl_quick_ajax_shortcode_settings'; 1173 1174 // Old value, not in use since 1.3.3 1175 // public const DB_SHORTCODE_CODE = 'qapl_quick_ajax_shortcode_code'; // Uncomment if needed later 1176 1177 // Plugin metadata 1178 public const DB_OPTION_PLUGIN_VERSION = 'qapl_quick_ajax_plugin_version'; 1179 public const DB_OPTION_PLUGIN_CLEANUP_FLAGS = 'qapl_quick_ajax_cleanup_flags'; 1180 1181 // Settings 1182 public const SETTINGS_WRAPPER_ID = 'qapl_settings_wrapper'; 1183 1184 // Nonce fields 1185 public const NONCE_FORM_QUICK_AJAX_FIELD = 'qapl_quick_ajax_nonce'; 1186 public const NONCE_FORM_QUICK_AJAX_ACTION = 'qapl_quick_ajax_nonce_action'; 1187 1188 // Query settings field names 1189 public const QUERY_SETTING_SELECT_POST_TYPE = 'qapl_select_post_type'; 1190 public const QUERY_SETTING_SELECT_POST_TYPE_DEFAULT = 'post'; 1191 1192 public const QUERY_SETTING_SHOW_TAXONOMY_FILTER = 'qapl_show_select_taxonomy'; 1193 public const QUERY_SETTING_SHOW_TAXONOMY_FILTER_DEFAULT = 0; 1194 1195 public const QUERY_SETTING_SELECT_TAXONOMY = 'qapl_select_taxonomy'; 1196 1197 public const QUERY_SETTING_MANUAL_TERM_SELECTION = 'qapl_manual_term_selection'; 1198 public const QUERY_SETTING_MANUAL_TERM_SELECTION_DEFAULT = 0; 1199 1200 public const QUERY_SETTING_SELECTED_TERMS = 'qapl_manual_selected_terms'; 1201 1202 public const QUERY_SETTING_SELECT_POSTS_PER_PAGE = 'qapl_select_posts_per_page'; 1203 public const QUERY_SETTING_SELECT_POSTS_PER_PAGE_DEFAULT = 6; 1204 1205 public const QUERY_SETTING_SELECT_ORDER = 'qapl_select_order'; 1206 public const QUERY_SETTING_SELECT_ORDER_DEFAULT = 'DESC'; 1207 1208 public const QUERY_SETTING_SELECT_ORDERBY = 'qapl_select_orderby'; 1209 public const QUERY_SETTING_SELECT_ORDERBY_DEFAULT = 'date'; 1210 1211 public const QUERY_SETTING_SHOW_SORT_BUTTON = 'qapl_show_order_button'; 1212 public const QUERY_SETTING_SHOW_SORT_BUTTON_DEFAULT = 0; 1213 1214 public const QUERY_SETTING_SELECT_SORT_BUTTON_OPTIONS = 'qapl_select_orderby_button_options'; 1215 public const QUERY_SETTING_SELECT_SORT_BUTTON_OPTIONS_DEFAULT = 1; 1216 1217 public const QUERY_SETTING_SHOW_INLINE_FILTER_SORTING = 'qapl_show_inline_filter_sorting'; 1218 public const QUERY_SETTING_SHOW_INLINE_FILTER_SORTING_DEFAULT = 1; 1219 1220 public const QUERY_SETTING_SELECT_POST_STATUS = 'qapl_select_post_status'; 1221 public const QUERY_SETTING_SELECT_POST_STATUS_DEFAULT = 'publish'; 1222 1223 public const QUERY_SETTING_IGNORE_STICKY_POSTS = 'qapl_ignore_sticky_posts'; 1224 public const QUERY_SETTING_IGNORE_STICKY_POSTS_DEFAULT = false; 1225 1226 public const QUERY_SETTING_AJAX_ON_INITIAL_LOAD = 'qapl_ajax_on_initial_load'; 1227 public const QUERY_SETTING_AJAX_ON_INITIAL_LOAD_DEFAULT = false; 1228 1229 public const QUERY_SETTING_AJAX_INFINITE_SCROLL = 'qapl_ajax_infinite_scroll'; 1230 public const QUERY_SETTING_AJAX_INFINITE_SCROLL_DEFAULT = false; 1231 1232 public const QUERY_SETTING_SHOW_END_MESSAGE = 'qapl_show_end_post_message'; 1233 public const QUERY_SETTING_SHOW_END_MESSAGE_DEFAULT = false; 1234 1235 public const QUERY_SETTING_SET_POST_NOT_IN = 'qapl_select_post_not_in'; 1236 public const QUERY_SETTING_SET_POST_NOT_IN_DEFAULT = false; 1237 1238 public const QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY = 'qapl_show_custom_load_more_post_quantity'; 1239 public const QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY_DEFAULT = 0; 1240 1241 public const QUERY_SETTING_SELECT_CUSTOM_LOAD_MORE_POST_QUANTITY = 'qapl_select_custom_load_more_post_quantity'; 1242 public const QUERY_SETTING_SELECT_CUSTOM_LOAD_MORE_POST_QUANTITY_DEFAULT = 4; 1243 1244 // Layout settings field names 1245 public const LAYOUT_SETTING_SELECT_COLUMNS_QTY = 'qapl_layout_select_columns_qty'; 1246 public const LAYOUT_SETTING_SELECT_COLUMNS_QTY_DEFAULT = 3; 1247 1248 public const LAYOUT_SETTING_TAXONOMY_FILTER_CLASS = 'qapl_layout_add_taxonomy_filter_class'; 1249 public const LAYOUT_SETTING_TAXONOMY_FILTER_CLASS_DEFAULT = false; 1250 1251 public const LAYOUT_SETTING_CONTAINER_CLASS = 'qapl_layout_add_container_class'; 1252 public const LAYOUT_SETTING_CONTAINER_CLASS_DEFAULT = false; 1253 1254 public const LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE = 'qapl_layout_quick_ajax_css_style'; 1255 public const LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE_DEFAULT = 1; 1256 1257 public const LAYOUT_SETTING_POST_ITEM_TEMPLATE = 'qapl_layout_quick_ajax_post_item_template'; 1258 public const LAYOUT_SETTING_POST_ITEM_TEMPLATE_DEFAULT = 'post-item'; 1259 1260 public const LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON = 'qapl_override_global_loader_icon'; 1261 public const LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON_DEFAULT = 0; 1262 1263 public const LAYOUT_SETTING_SELECT_LOADER_ICON = 'qapl_loader_icon'; 1264 public const LAYOUT_SETTING_SELECT_LOADER_ICON_DEFAULT = 'loader-icon'; 1265 1266 // Ajax settings 1267 public const AJAX_SETTING_AJAX_INITIAL_LOAD = 'ajax_initial_load'; 1268 1269 // Attributes query names 1270 public const ATTRIBUTE_QUICK_AJAX_ID = 'quick_ajax_id'; 1271 public const ATTRIBUTE_QUICK_AJAX_CSS_STYLE = 'quick_ajax_css_style'; 1272 public const ATTRIBUTE_GRID_NUM_COLUMNS = 'grid_num_columns'; 1273 public const ATTRIBUTE_POST_ITEM_TEMPLATE = 'post_item_template'; 1274 public const ATTRIBUTE_TAXONOMY_FILTER_CLASS = 'taxonomy_filter_class'; 1275 public const ATTRIBUTE_CONTAINER_CLASS = 'container_class'; 1276 public const ATTRIBUTE_LOAD_MORE_POSTS = 'load_more_posts'; 1277 public const ATTRIBUTE_LOADER_ICON = 'loader_icon'; 1278 public const ATTRIBUTE_AJAX_INFINITE_SCROLL = 'infinite_scroll'; 1279 public const ATTRIBUTE_SHOW_END_MESSAGE = 'show_end_message'; 1280 1281 // Quick AJAX settings 1282 public const ADMIN_PAGE_SETTINGS_GROUP = 'qapl_settings_group'; // used by register_setting to group fields for shared validation and security in admin forms 1283 public const GLOBAL_OPTIONS_NAME = 'qapl_quick_ajax_global_options'; 1284 1285 // Global options 1286 public const GLOBAL_LOADER_ICON_FIELD = self::GLOBAL_OPTIONS_NAME . '[loader_icon]'; 1287 public const GLOBAL_READ_MORE_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[read_more_label]'; 1288 //public const GLOBAL_POST_DATE_FORMAT_FIELD = self::GLOBAL_OPTIONS_NAME . '[post_date_format]'; 1289 public const GLOBAL_SHOW_ALL_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[show_all_label]'; 1290 public const GLOBAL_LOAD_MORE_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[load_more_label]'; 1291 public const GLOBAL_NO_POST_MESSAGE_FIELD = self::GLOBAL_OPTIONS_NAME . '[no_post_message]'; 1292 public const GLOBAL_END_POST_MESSAGE_FIELD = self::GLOBAL_OPTIONS_NAME . '[end_post_message]'; 1293 public const GLOBAL_SORT_OPTION_DATE_DESC_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[sort_option_date_desc_label]'; 1294 public const GLOBAL_SORT_OPTION_DATE_ASC_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[sort_option_date_asc_label]'; 1295 public const GLOBAL_SORT_OPTION_COMMENT_COUNT_DESC_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[sort_option_comment_count_desc_label]'; 1296 public const GLOBAL_SORT_OPTION_TITLE_ASC_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[sort_option_title_asc_label]'; 1297 public const GLOBAL_SORT_OPTION_TITLE_DESC_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[sort_option_title_desc_label]'; 1298 public const GLOBAL_SORT_OPTION_RAND_LABEL_FIELD = self::GLOBAL_OPTIONS_NAME . '[sort_option_rand_label]'; 1299 1300 //Settings Page 1301 public const REMOVE_OLD_DATA_FIELD = 'qapl_remove_old_meta'; 1302 public const REMOVE_OLD_DATA_FIELD_DEFAULT = 0; 1303 // Buttons 1304 public const TERM_FILTER_BUTTON_DATA_BUTTON = 'quick-ajax-filter-button'; 1305 public const SORT_OPTION_BUTTON_DATA_BUTTON = 'quick-ajax-sort-option-button'; 1306 public const LOAD_MORE_BUTTON_DATA_BUTTON = 'quick-ajax-load-more-button'; 1307 1308 // Hooks 1383 1309 // Filter Container Hooks 1384 const HOOK_FILTER_CONTAINER_BEFORE = 'qapl_filter_container_before';1385 const HOOK_FILTER_CONTAINER_START = 'qapl_filter_container_start';1386 const HOOK_FILTER_CONTAINER_END = 'qapl_filter_container_end';1387 const HOOK_FILTER_CONTAINER_AFTER = 'qapl_filter_container_after';1310 public const HOOK_FILTER_CONTAINER_BEFORE = 'qapl_filter_container_before'; 1311 public const HOOK_FILTER_CONTAINER_START = 'qapl_filter_container_start'; 1312 public const HOOK_FILTER_CONTAINER_END = 'qapl_filter_container_end'; 1313 public const HOOK_FILTER_CONTAINER_AFTER = 'qapl_filter_container_after'; 1388 1314 1389 1315 // Posts Container Hooks 1390 const HOOK_POSTS_CONTAINER_BEFORE = 'qapl_posts_container_before';1391 const HOOK_POSTS_CONTAINER_START = 'qapl_posts_container_start';1392 const HOOK_POSTS_CONTAINER_END = 'qapl_posts_container_end';1393 const HOOK_POSTS_CONTAINER_AFTER = 'qapl_posts_container_after';1316 public const HOOK_POSTS_CONTAINER_BEFORE = 'qapl_posts_container_before'; 1317 public const HOOK_POSTS_CONTAINER_START = 'qapl_posts_container_start'; 1318 public const HOOK_POSTS_CONTAINER_END = 'qapl_posts_container_end'; 1319 public const HOOK_POSTS_CONTAINER_AFTER = 'qapl_posts_container_after'; 1394 1320 1395 1321 // Load More Button Hooks 1396 // const HOOK_LOAD_MORE_BEFORE = 'qapl_load_more_before';1397 // const HOOK_LOAD_MORE_AFTER = 'qapl_load_more_after';1322 //public const HOOK_LOAD_MORE_BEFORE = 'qapl_load_more_before'; 1323 //public const HOOK_LOAD_MORE_AFTER = 'qapl_load_more_after'; 1398 1324 1399 1325 // Loader Hooks 1400 const HOOK_LOADER_BEFORE = 'qapl_loader_before';1401 const HOOK_LOADER_AFTER = 'qapl_loader_after';1326 public const HOOK_LOADER_BEFORE = 'qapl_loader_before'; 1327 public const HOOK_LOADER_AFTER = 'qapl_loader_after'; 1402 1328 1403 1329 // Filters 1404 const HOOK_MODIFY_POSTS_QUERY_ARGS = 'qapl_modify_posts_query_args';1405 const HOOK_MODIFY_TAXONOMY_FILTER_BUTTONS = 'qapl_modify_taxonomy_filter_buttons';1406 const HOOK_MODIFY_SORTING_OPTIONS_VARIANTS = 'qapl_modify_sorting_options_variants';1330 public const HOOK_MODIFY_POSTS_QUERY_ARGS = 'qapl_modify_posts_query_args'; 1331 public const HOOK_MODIFY_TAXONOMY_FILTER_BUTTONS = 'qapl_modify_taxonomy_filter_buttons'; 1332 public const HOOK_MODIFY_SORTING_OPTIONS_VARIANTS = 'qapl_modify_sorting_options_variants'; 1407 1333 1408 1334 // Template Hooks 1409 const HOOK_TEMPLATE_POST_ITEM_DATE = 'qapl_template_post_item_date'; 1410 const HOOK_TEMPLATE_POST_ITEM_IMAGE = 'qapl_template_post_item_image'; 1411 const HOOK_TEMPLATE_POST_ITEM_TITLE = 'qapl_template_post_item_title'; 1412 const HOOK_TEMPLATE_POST_ITEM_EXCERPT = 'qapl_template_post_item_excerpt'; 1413 const HOOK_TEMPLATE_POST_ITEM_READ_MORE = 'qapl_template_post_item_read_more'; 1414 const HOOK_TEMPLATE_LOAD_MORE_BUTTON = 'qapl_template_load_more_button'; 1415 const HOOK_TEMPLATE_NO_POST_MESSAGE = 'qapl_template_no_post_message'; 1416 const HOOK_TEMPLATE_END_POST_MESSAGE = 'qapl_template_end_post_message'; 1417 } 1418 1419 1420 /* 1421 class QAPL_Logger { 1422 private static $instance = null; 1423 private $file_helper; 1424 private $logs = []; 1425 1426 private function __construct() { 1427 $this->file_helper = QAPL_File_Helper::get_instance(); 1428 } 1429 public static function getInstance() { 1430 if (self::$instance === null) { 1431 self::$instance = new self(); 1432 } 1433 return self::$instance; 1434 } 1435 public function addLog($message, $level = 'info') { 1436 $this->logs[] = '[' . strtoupper($level) . '] ' . $message; 1437 } 1438 public function getLogs() { 1439 return $this->logs; 1440 } 1441 1442 public function saveLogs() { 1443 $log_file = $this->file_helper->get_plugin_directory() . '/app.log'; 1444 file_put_contents($log_file, implode(PHP_EOL, $this->logs) . PHP_EOL, FILE_APPEND); 1445 $this->logs = []; 1446 } 1447 } 1448 */ 1449 /* not in use after removing placeholders 1450 class QAPL_Placeholder_Replacer{ 1451 private static $instance = null; 1452 private $placeholders = []; 1453 private $helper; 1454 private $global_options; 1455 1456 public function __construct() { 1457 // Initialize helper instance 1458 $this->helper = QAPL_Quick_Ajax_Helper::get_instance(); 1459 // Fetch global options once and store them 1460 $this->global_options = get_option($this->helper->admin_page_global_options_name(), []); 1461 // Initialize placeholders 1462 $this->initialize_placeholders(); 1463 } 1464 public static function get_instance() { 1465 if (self::$instance === null) { 1466 self::$instance = new self(); 1467 } 1468 return self::$instance; 1469 } 1470 1471 // Initialize placeholders from global options. 1472 private function initialize_placeholders() { 1473 $all_placeholders = QAPL_Quick_Ajax_Helper::get_all_placeholders(); 1474 foreach ($all_placeholders as $placeholder_config) { 1475 $option_key = $placeholder_config['option_key']; 1476 $default_value = $placeholder_config['default']; 1477 $placeholder = $placeholder_config['placeholder']; 1478 // Use global option value or fallback to default 1479 $this->placeholders[$placeholder] = $this->global_options[$option_key] ?? $default_value; 1480 } 1481 } 1482 public function replace_placeholders($content) { 1483 // replace placeholders in content 1484 foreach ($this->placeholders as $placeholder => $value) { 1485 $content = str_replace($placeholder, $value, $content); 1486 } 1487 return $content; 1488 } 1489 public function get_placeholders() { 1490 // return all placeholders 1491 return $this->placeholders; 1492 } 1493 } 1494 */ 1335 public const HOOK_TEMPLATE_POST_ITEM_DATE = 'qapl_template_post_item_date'; 1336 public const HOOK_TEMPLATE_POST_ITEM_IMAGE = 'qapl_template_post_item_image'; 1337 public const HOOK_TEMPLATE_POST_ITEM_TITLE = 'qapl_template_post_item_title'; 1338 public const HOOK_TEMPLATE_POST_ITEM_EXCERPT = 'qapl_template_post_item_excerpt'; 1339 public const HOOK_TEMPLATE_POST_ITEM_READ_MORE = 'qapl_template_post_item_read_more'; 1340 public const HOOK_TEMPLATE_LOAD_MORE_BUTTON = 'qapl_template_load_more_button'; 1341 public const HOOK_TEMPLATE_NO_POST_MESSAGE = 'qapl_template_no_post_message'; 1342 public const HOOK_TEMPLATE_END_POST_MESSAGE = 'qapl_template_end_post_message'; 1343 } 1344 1345 $file_helper = new QAPL_Quick_Ajax_File_Manager(); 1346 $enqueue_handler = new QAPL_Quick_Ajax_Enqueue_Handler($file_helper); 1347 $pages_helper = new QAPL_Quick_Ajax_Resource_Manager($file_helper); 1348 $plugin_bootstrap = new QAPL_Quick_Ajax_Plugin_Bootstrap($pages_helper); 1349 1350 $plugin_starter = new QAPL_Quick_Ajax_Plugin_Starter($plugin_bootstrap, $enqueue_handler); 1351 $plugin_starter->run(); -
quick-ajax-post-loader/trunk/inc/class-shortcode.php
r3295741 r3352831 64 64 class QAPL_Shortcode_Post_Meta_Handler { 65 65 public static function load_and_sanitize($id) { 66 $serialized_data = get_post_meta($id, QAPL_Quick_Ajax_ Helper::quick_ajax_shortcode_settings(), true);66 $serialized_data = get_post_meta($id, QAPL_Quick_Ajax_Plugin_Constants::DB_POSTMETA_SHORTCODE_SETTINGS, true); 67 67 if (!$serialized_data) { 68 68 return array(); … … 138 138 if (!empty($this->shortcode_params['id'])) { 139 139 $attributes['shortcode'] = true; 140 $attributes[QAPL_Quick_Ajax_ Helper::layout_quick_ajax_id()] = absint($this->shortcode_params['id']);140 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID] = absint($this->shortcode_params['id']); 141 141 } else { 142 $attributes[QAPL_Quick_Ajax_ Helper::layout_quick_ajax_id()] = $this->get_sanitized_attribute([143 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_quick_ajax_id(),142 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID] = $this->get_sanitized_attribute([ 143 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_ID, 144 144 'type' => 'number', 145 145 ]); 146 146 } 147 $attributes[QAPL_Quick_Ajax_ Helper::layout_quick_ajax_css_style()] = $this->get_sanitized_attribute([148 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_quick_ajax_css_style(),149 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_layout_quick_ajax_css_style(),147 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE] = $this->get_sanitized_attribute([ 148 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_QUICK_AJAX_CSS_STYLE, 149 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_QUICK_AJAX_CSS_STYLE, 150 150 'type' => 'string', 151 151 ]); 152 $attributes[QAPL_Quick_Ajax_ Helper::layout_container_num_columns()] = $this->get_sanitized_attribute([153 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_container_num_columns(),154 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_layout_select_columns_qty(),152 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_GRID_NUM_COLUMNS] = $this->get_sanitized_attribute([ 153 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_GRID_NUM_COLUMNS, 154 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_SELECT_COLUMNS_QTY, 155 155 'type' => 'number', 156 156 ]); 157 $attributes[QAPL_Quick_Ajax_ Helper::layout_post_item_template()] = $this->get_sanitized_attribute([158 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_post_item_template(),159 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_layout_post_item_template(),157 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_POST_ITEM_TEMPLATE] = $this->get_sanitized_attribute([ 158 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_POST_ITEM_TEMPLATE, 159 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_POST_ITEM_TEMPLATE, 160 160 'type' => 'string', 161 161 ]); 162 $attributes[QAPL_Quick_Ajax_ Helper::layout_taxonomy_filter_class()] = $this->get_sanitized_attribute([163 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_taxonomy_filter_class(),164 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_layout_taxonomy_filter_class(),162 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_TAXONOMY_FILTER_CLASS] = $this->get_sanitized_attribute([ 163 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_TAXONOMY_FILTER_CLASS, 164 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_TAXONOMY_FILTER_CLASS, 165 165 'type' => 'html_class', 166 166 ]); 167 $attributes[QAPL_Quick_Ajax_ Helper::layout_container_class()] = $this->get_sanitized_attribute([168 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_container_class(),169 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_layout_container_class(),167 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_CONTAINER_CLASS] = $this->get_sanitized_attribute([ 168 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_CONTAINER_CLASS, 169 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_CONTAINER_CLASS, 170 170 'type' => 'html_class', 171 171 ]); 172 $attributes[QAPL_Quick_Ajax_ Helper::layout_load_more_posts()] = $this->get_sanitized_attribute([173 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_load_more_posts(),174 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_select_custom_load_more_post_quantity(),175 'only_if_meta_key_true' => QAPL_Quick_Ajax_ Helper::shortcode_page_show_custom_load_more_post_quantity(),172 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOAD_MORE_POSTS] = $this->get_sanitized_attribute([ 173 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOAD_MORE_POSTS, 174 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_CUSTOM_LOAD_MORE_POST_QUANTITY, 175 'only_if_meta_key_true' => QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_CUSTOM_LOAD_MORE_POST_QUANTITY, 176 176 'type' => 'number', 177 177 ]); 178 $attributes[QAPL_Quick_Ajax_ Helper::layout_select_loader_icon()] = $this->get_sanitized_attribute([179 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_select_loader_icon(),180 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_select_loader_icon(),181 'only_if_meta_key_true' => QAPL_Quick_Ajax_ Helper::shortcode_page_override_global_loader_icon(),178 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOADER_ICON] = $this->get_sanitized_attribute([ 179 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_LOADER_ICON, 180 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_SELECT_LOADER_ICON, 181 'only_if_meta_key_true' => QAPL_Quick_Ajax_Plugin_Constants::LAYOUT_SETTING_OVERRIDE_GLOBAL_LOADER_ICON, 182 182 'type' => 'string', 183 183 ]); 184 $attributes[QAPL_Quick_Ajax_ Helper::query_settings_ajax_on_initial_load()] = $this->get_sanitized_attribute([185 'shortcode_key' => QAPL_Quick_Ajax_ Helper::query_settings_ajax_on_initial_load(),186 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_ajax_on_initial_load(),184 $attributes[QAPL_Quick_Ajax_Plugin_Constants::AJAX_SETTING_AJAX_INITIAL_LOAD] = $this->get_sanitized_attribute([ 185 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::AJAX_SETTING_AJAX_INITIAL_LOAD, 186 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_AJAX_ON_INITIAL_LOAD, 187 187 'type' => 'bool', 188 188 ]); 189 $attributes[QAPL_Quick_Ajax_ Helper::layout_ajax_infinite_scroll()] = $this->get_sanitized_attribute([190 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_ajax_infinite_scroll(),191 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_ajax_infinite_scroll(),189 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_AJAX_INFINITE_SCROLL] = $this->get_sanitized_attribute([ 190 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_AJAX_INFINITE_SCROLL, 191 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_AJAX_INFINITE_SCROLL, 192 192 'type' => 'bool', 193 193 ]); 194 $attributes[QAPL_Quick_Ajax_ Helper::layout_show_end_message()] = $this->get_sanitized_attribute([195 'shortcode_key' => QAPL_Quick_Ajax_ Helper::layout_show_end_message(),196 'postmeta_key' => QAPL_Quick_Ajax_ Helper::shortcode_page_show_end_message(),194 $attributes[QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_SHOW_END_MESSAGE] = $this->get_sanitized_attribute([ 195 'shortcode_key' => QAPL_Quick_Ajax_Plugin_Constants::ATTRIBUTE_SHOW_END_MESSAGE, 196 'postmeta_key' => QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_END_MESSAGE, 197 197 'type' => 'bool', 198 198 ]); … … 270 270 $data_args = new QAPL_Shortcode_Query_Args_Provider($this->shortcode_params, $this->shortcode_postmeta); 271 271 $args = array(); 272 // get main query params from shortcode or postmeta 273 $selected_post_type = $data_args->get_arg_value('post_type', QAPL_Quick_Ajax_ Helper::shortcode_page_select_post_type());274 $post_per_page = $data_args->get_arg_value('posts_per_page', QAPL_Quick_Ajax_ Helper::shortcode_page_select_posts_per_page());275 $post_order = $data_args->get_arg_value('order', QAPL_Quick_Ajax_ Helper::shortcode_page_select_order());276 $post_orderby = $data_args->get_arg_value('orderby', QAPL_Quick_Ajax_ Helper::shortcode_page_select_orderby());277 $post_not_in = $data_args->get_arg_value('excluded_post_ids', QAPL_Quick_Ajax_ Helper::shortcode_page_set_post_not_in());278 $ignore_sticky_posts = $data_args->get_arg_value('ignore_sticky_posts', QAPL_Quick_Ajax_ Helper::shortcode_page_ignore_sticky_posts());279 $show_taxonomy = $data_args->get_arg_value('show_taxonomy', QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter());280 $select_taxonomy = $data_args->get_arg_value('select_taxonomy', QAPL_Quick_Ajax_ Helper::shortcode_page_select_taxonomy());281 $manual_term_selection = $data_args->get_arg_value('manual_term_selection', QAPL_Quick_Ajax_ Helper::shortcode_page_manual_term_selection());282 $manual_selected_terms = $data_args->get_arg_value('manual_selected_terms', QAPL_Quick_Ajax_ Helper::shortcode_page_manual_selected_terms());272 // get main query params from shortcode or postmeta 273 $selected_post_type = $data_args->get_arg_value('post_type', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POST_TYPE); 274 $post_per_page = $data_args->get_arg_value('posts_per_page', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_POSTS_PER_PAGE); 275 $post_order = $data_args->get_arg_value('order', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_ORDER); 276 $post_orderby = $data_args->get_arg_value('orderby', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_ORDERBY); 277 $post_not_in = $data_args->get_arg_value('excluded_post_ids', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SET_POST_NOT_IN); 278 $ignore_sticky_posts = $data_args->get_arg_value('ignore_sticky_posts', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_IGNORE_STICKY_POSTS); 279 $show_taxonomy = $data_args->get_arg_value('show_taxonomy', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER); 280 $select_taxonomy = $data_args->get_arg_value('select_taxonomy', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_TAXONOMY); 281 $manual_term_selection = $data_args->get_arg_value('manual_term_selection', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_MANUAL_TERM_SELECTION); 282 $manual_selected_terms = $data_args->get_arg_value('manual_selected_terms', QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECTED_TERMS); 283 283 // return query args if post type is defined 284 284 if(!empty($selected_post_type)){ … … 335 335 return null; 336 336 } 337 $show_taxonomies_filter = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_ Helper::shortcode_page_show_taxonomy_filter()]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Helper::shortcode_page_show_taxonomy_filter()] : null;337 $show_taxonomies_filter = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_TAXONOMY_FILTER] : null; 338 338 if($show_taxonomies_filter==1){ 339 $selectedTaxonomy = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_ Helper::shortcode_page_select_taxonomy()]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Helper::shortcode_page_select_taxonomy()] : null;339 $selectedTaxonomy = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_TAXONOMY]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_TAXONOMY] : null; 340 340 $selectedTaxonomy = esc_attr($selectedTaxonomy); 341 341 } … … 347 347 private function create_shortcode_controls_container(){ 348 348 if(!empty($this->shortcode_params['id'])){ 349 $show_sort_orderby_button = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_ Helper::shortcode_page_show_sort_button()]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Helper::shortcode_page_show_sort_button()] : null;349 $show_sort_orderby_button = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON] : null; 350 350 if($show_sort_orderby_button==1){ 351 $add_wrapper = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_ Helper::shortcode_page_show_inline_filter_sorting()]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Helper::shortcode_page_show_inline_filter_sorting()] : null;351 $add_wrapper = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_INLINE_FILTER_SORTING]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_INLINE_FILTER_SORTING] : null; 352 352 return $add_wrapper; 353 353 } … … 357 357 private function create_shortcode_sort_button(){ 358 358 if(!empty($this->shortcode_params['id'])){ 359 $show_sort_orderby_button = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_ Helper::shortcode_page_show_sort_button()]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Helper::shortcode_page_show_sort_button()] : null;359 $show_sort_orderby_button = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SHOW_SORT_BUTTON] : null; 360 360 if($show_sort_orderby_button==1){ 361 $sort_orderby = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_ Helper::shortcode_page_select_sort_button_options()]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Helper::shortcode_page_select_sort_button_options()] : null;361 $sort_orderby = isset($this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_SORT_BUTTON_OPTIONS]) ? $this->shortcode_postmeta[QAPL_Quick_Ajax_Plugin_Constants::QUERY_SETTING_SELECT_SORT_BUTTON_OPTIONS] : null; 362 362 if (is_array($sort_orderby)) { 363 363 $sort_orderby = array_map('esc_attr', $sort_orderby); -
quick-ajax-post-loader/trunk/inc/class-template-hooks.php
r3305166 r3352831 158 158 $date_format = $this->config->get('date_format'); 159 159 $output = '<div class="qapl-post-date"><span>' . esc_html(get_the_date($date_format)) . '</span></div>'; 160 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_DATE, $output, $this->template_name, $this->quick_ajax_id);160 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_DATE, $output, $this->template_name, $this->quick_ajax_id); 161 161 } 162 162 … … 167 167 : '<div class="qapl-post-image qapl-no-image"></div>'; 168 168 169 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_IMAGE, $output, $this->template_name, $this->quick_ajax_id);169 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_IMAGE, $output, $this->template_name, $this->quick_ajax_id); 170 170 } 171 171 172 172 public function render_title() { 173 173 $output = '<div class="qapl-post-title"><h3>' . esc_html(get_the_title()) . '</h3></div>'; 174 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_TITLE, $output, $this->template_name, $this->quick_ajax_id);174 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_TITLE, $output, $this->template_name, $this->quick_ajax_id); 175 175 } 176 176 177 177 public function render_excerpt() { 178 178 $output = '<div class="qapl-post-description"><p>' . esc_html(wp_trim_words(get_the_excerpt(), 20)) . '</p></div>'; 179 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_EXCERPT, $output, $this->template_name, $this->quick_ajax_id);179 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_EXCERPT, $output, $this->template_name, $this->quick_ajax_id); 180 180 } 181 181 … … 186 186 $label = $this->config->get('read_more_label'); 187 187 $output = '<div class="qapl-read-more"><p>' . esc_html($label) . '</p></div>'; 188 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_READ_MORE, $output, $this->template_name, $this->quick_ajax_id);188 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_READ_MORE, $output, $this->template_name, $this->quick_ajax_id); 189 189 } 190 190 } … … 204 204 $date_format = $this->config->get('date_format'); 205 205 $output = '<div class="qapl-post-date"><span>' . esc_html(get_the_date($date_format)) . '</span></div>'; 206 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_DATE, $output, $this->template_name, $this->quick_ajax_id);206 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_DATE, $output, $this->template_name, $this->quick_ajax_id); 207 207 } 208 208 … … 213 213 : '<span class="qapl-no-image"></span>'; 214 214 215 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_IMAGE, $output, $this->template_name, $this->quick_ajax_id);215 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_IMAGE, $output, $this->template_name, $this->quick_ajax_id); 216 216 } 217 217 218 218 public function render_title() { 219 219 $output = '<div class="qapl-post-title"><h3>' . esc_html(get_the_title()) . '</h3></div>'; 220 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_TITLE, $output, $this->template_name, $this->quick_ajax_id);220 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_TITLE, $output, $this->template_name, $this->quick_ajax_id); 221 221 } 222 222 223 223 public function render_excerpt() { 224 224 $output = '<div class="qapl-post-description"><p>' . esc_html(wp_trim_words(get_the_excerpt(), 20)) . '</p></div>'; 225 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_EXCERPT, $output, $this->template_name, $this->quick_ajax_id);225 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_EXCERPT, $output, $this->template_name, $this->quick_ajax_id); 226 226 } 227 227 … … 232 232 $label = $this->config->get('read_more_label'); 233 233 $output = '<div class="qapl-read-more"><p>' . esc_html($label) . '</p></div>'; 234 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_POST_ITEM_READ_MORE, $output, $this->template_name, $this->quick_ajax_id);234 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_POST_ITEM_READ_MORE, $output, $this->template_name, $this->quick_ajax_id); 235 235 } 236 236 } … … 240 240 $label = $this->config->get('load_more_label'); 241 241 $output = '<button type="button" class="qapl-load-more-button qapl-button" data-button="quick-ajax-load-more-button">' . esc_html($label) . '</button>'; 242 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_LOAD_MORE_BUTTON, $output, $this->quick_ajax_id);242 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_LOAD_MORE_BUTTON, $output, $this->quick_ajax_id); 243 243 } 244 244 } … … 248 248 $end_post_message = $this->config->get('end_post_message'); 249 249 $output = '<p>' . esc_html($end_post_message) . '</p>'; 250 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_END_POST_MESSAGE, $output, $this->quick_ajax_id);250 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_END_POST_MESSAGE, $output, $this->quick_ajax_id); 251 251 } 252 252 } … … 256 256 $no_post_message = $this->config->get('no_post_message'); 257 257 $output = '<p>' . esc_html($no_post_message) . '</p>'; 258 return apply_filters(QAPL_ Hooks::HOOK_TEMPLATE_NO_POST_MESSAGE, $output, $this->quick_ajax_id);258 return apply_filters(QAPL_Quick_Ajax_Plugin_Constants::HOOK_TEMPLATE_NO_POST_MESSAGE, $output, $this->quick_ajax_id); 259 259 } 260 260 } … … 286 286 $quick_ajax_id = $container_settings['quick_ajax_id'] ?? ''; 287 287 $config_array = $container_settings['config'] ?? []; 288 $global_options = get_option(QAPL_Quick_Ajax_ Helper::admin_page_global_options_name(), []);288 $global_options = get_option(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME, []); 289 289 $config = new QAPL_Quick_Ajax_Template_Config($config_array); 290 290 -
quick-ajax-post-loader/trunk/inc/class-updater.php
r3321429 r3352831 11 11 12 12 public function __construct(array $update_strategies) { 13 $this->current_version = get_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_version());14 $this->new_version = QAPL_Quick_Ajax_ Helper::get_plugin_info()['version'];13 $this->current_version = get_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_VERSION); 14 $this->new_version = QAPL_Quick_Ajax_Plugin_Constants::PLUGIN_VERSION; 15 15 QAPL_Update_Validator::init(); // initialise flags 16 16 $this->update_strategies = $update_strategies; // save the given update classes to the class property … … 43 43 private function finalise_updates() { 44 44 QAPL_Update_Validator::save_cleanup_flags(); 45 update_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_version(), $this->new_version);45 update_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_VERSION, $this->new_version); 46 46 } 47 47 private function check_and_downgrade_version(): bool { 48 $stored_version = get_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_version());48 $stored_version = get_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_VERSION); 49 49 if ($stored_version === false) { 50 add_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_version(), $this->new_version, '', 'off');50 add_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_VERSION, $this->new_version, '', 'off'); 51 51 //error_log('QAPL Updater: Version record created.'); 52 52 return true; 53 53 } 54 54 if (version_compare($stored_version, $this->new_version, '>')) { 55 update_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_version(), $this->new_version);55 update_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_VERSION, $this->new_version); 56 56 //error_log('QAPL Updater: Version downgraded successfully.'); 57 57 return true; … … 63 63 add_action('init', 'qapl_action_quick_ajax_check_version_and_run_updates'); 64 64 function qapl_action_quick_ajax_check_version_and_run_updates() { 65 $current_version = get_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_version());66 $plugin_version = QAPL_Quick_Ajax_ Helper::get_plugin_info()['version'];65 $current_version = get_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_VERSION); 66 $plugin_version = QAPL_Quick_Ajax_Plugin_Constants::PLUGIN_VERSION; 67 67 if ($current_version !== $plugin_version) { 68 68 // register update strategies and send them to the constructor … … 86 86 public function run_update(): bool { 87 87 $results = array(); 88 $results[] = QAPL_Data_Migrator::migrate_meta_for_all_posts(QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(), 'qapl_quick_ajax_meta_box_shortcode_shortcode', 'qapl_quick_ajax_shortcode_code');89 $results[] = QAPL_Data_Migrator::migrate_meta_for_all_posts(QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(), 'qapl_settings_wrapper' , 'qapl_quick_ajax_shortcode_settings');88 $results[] = QAPL_Data_Migrator::migrate_meta_for_all_posts(QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG, 'qapl_quick_ajax_meta_box_shortcode_shortcode', 'qapl_quick_ajax_shortcode_code'); 89 $results[] = QAPL_Data_Migrator::migrate_meta_for_all_posts(QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG, 'qapl_settings_wrapper' , 'qapl_quick_ajax_shortcode_settings'); 90 90 return QAPL_Update_Validator::check_migration_results($results, '1.3.2'); 91 91 } … … 95 95 public function run_update(): bool { 96 96 $results = array(); 97 $results[] = QAPL_Data_Migrator::migrate_option('qapl-global-options', QAPL_Quick_Ajax_ Helper::admin_page_global_options_name());98 $results[] = QAPL_Data_Migrator::migrate_meta_for_all_posts(QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(), 'qapl_quick_ajax_shortcode_settings', QAPL_Quick_Ajax_Helper::quick_ajax_shortcode_settings());97 $results[] = QAPL_Data_Migrator::migrate_option('qapl-global-options', QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME); 98 $results[] = QAPL_Data_Migrator::migrate_meta_for_all_posts(QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG, 'qapl_quick_ajax_shortcode_settings', QAPL_Quick_Ajax_Plugin_Constants::DB_POSTMETA_SHORTCODE_SETTINGS); 99 99 $return = QAPL_Update_Validator::check_migration_results($results, '1.3.3'); 100 100 return $return; … … 104 104 public function run_update(): bool { 105 105 $results = array(); 106 $results[] = QAPL_Data_Migrator::update_autoload_for_option(QAPL_Quick_Ajax_ Helper::admin_page_global_options_name(),'off');107 $results[] = QAPL_Data_Migrator::update_autoload_for_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_version(),'off');106 $results[] = QAPL_Data_Migrator::update_autoload_for_option(QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME,'off'); 107 $results[] = QAPL_Data_Migrator::update_autoload_for_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_VERSION,'off'); 108 108 $return = QAPL_Update_Validator::check_migration_results($results, '1.3.4'); 109 109 return $return; … … 113 113 // fix wrong label assignment for title ASC and DESC sort options due to naming issue 114 114 public function run_update(): bool { 115 $option_name = QAPL_Quick_Ajax_ Helper::admin_page_global_options_name();115 $option_name = QAPL_Quick_Ajax_Plugin_Constants::GLOBAL_OPTIONS_NAME; 116 116 $options = get_option($option_name, array()); 117 117 if (!is_array($options)) { … … 246 246 247 247 public static function init() { 248 $flags = get_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_cleanup_flags(), array());248 $flags = get_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_CLEANUP_FLAGS, array()); 249 249 if (is_array($flags)) { 250 250 self::$cleanup_flags = array_map('boolval', $flags); … … 298 298 //error_log('QAPL_Quick_Ajax_Cleaner: cleanup ' . json_encode(self::$cleanup_flags)); 299 299 if (empty(self::$cleanup_flags)) { 300 delete_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_cleanup_flags());300 delete_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_CLEANUP_FLAGS); 301 301 } else { 302 if (get_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_cleanup_flags()) === false) {303 add_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_cleanup_flags(), self::$cleanup_flags, '', 'off');302 if (get_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_CLEANUP_FLAGS) === false) { 303 add_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_CLEANUP_FLAGS, self::$cleanup_flags, '', 'off'); 304 304 } else { 305 update_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_cleanup_flags(), self::$cleanup_flags);305 update_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_CLEANUP_FLAGS, self::$cleanup_flags); 306 306 } 307 307 } … … 317 317 318 318 public function __construct($cleanup_strategies) { 319 $this->cleanup_flags = get_option(QAPL_Quick_Ajax_ Helper::quick_ajax_plugin_cleanup_flags(), []);319 $this->cleanup_flags = get_option(QAPL_Quick_Ajax_Plugin_Constants::DB_OPTION_PLUGIN_CLEANUP_FLAGS, []); 320 320 if (!is_array($this->cleanup_flags)) { 321 321 $this->cleanup_flags = []; … … 424 424 public function run_cleanup(): bool { 425 425 $results = []; 426 $results[] = QAPL_Data_Cleaner::remove_old_meta_for_all_posts(QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(), 'qapl_quick_ajax_meta_box_shortcode_shortcode');427 $results[] = QAPL_Data_Cleaner::remove_old_meta_for_all_posts(QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(), 'qapl_settings_wrapper');426 $results[] = QAPL_Data_Cleaner::remove_old_meta_for_all_posts(QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG, 'qapl_quick_ajax_meta_box_shortcode_shortcode'); 427 $results[] = QAPL_Data_Cleaner::remove_old_meta_for_all_posts(QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG, 'qapl_settings_wrapper'); 428 428 return QAPL_Update_Validator::check_result_array_if_all_true($results); 429 429 } … … 438 438 $results[] = false; 439 439 } 440 $results[] = QAPL_Data_Cleaner::remove_old_meta_for_all_posts(QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(), 'qapl_quick_ajax_shortcode_settings');441 $results[] = QAPL_Data_Cleaner::remove_old_meta_for_all_posts(QAPL_Quick_Ajax_ Helper::cpt_shortcode_slug(), 'qapl_quick_ajax_shortcode_code');440 $results[] = QAPL_Data_Cleaner::remove_old_meta_for_all_posts(QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG, 'qapl_quick_ajax_shortcode_settings'); 441 $results[] = QAPL_Data_Cleaner::remove_old_meta_for_all_posts(QAPL_Quick_Ajax_Plugin_Constants::CPT_SHORTCODE_SLUG, 'qapl_quick_ajax_shortcode_code'); 442 442 return QAPL_Update_Validator::check_result_array_if_all_true($results); 443 443 } -
quick-ajax-post-loader/trunk/inc/functions.php
r3321429 r3352831 6 6 //add get qapl_render_taxonomy_filter 7 7 function qapl_render_post_container($args, $attributes = null, $render_context = null, $meta_query = null) { 8 if (!class_exists('QAPL_Quick_Ajax_Handler') || !method_exists('QAPL_Quick_Ajax_Handler', 'get_instance')) { 9 if (defined('WP_DEBUG') && WP_DEBUG) { 10 //error_log('Quick Ajax Post Loader: QAPL_Quick_Ajax_Handler class or method get_instance not found'); 11 } 8 if (!class_exists('QAPL_Quick_Ajax_Handler')) { 12 9 return; 13 10 } 14 $ajax_class = QAPL_Quick_Ajax_Handler::get_instance(); 15 $attributes = $attributes ?? []; 11 if (!is_array($args)) { 12 return; 13 } 14 15 $attributes = is_array($attributes) ? $attributes : []; 16 $file_manager = new QAPL_Quick_Ajax_File_Manager(); 17 $ajax_class = new QAPL_Quick_Ajax_Handler($file_manager); 18 16 19 $ajax_class->wp_query_args($args, $attributes); 17 20 $ajax_class->layout_customization($attributes); 21 18 22 $output = ''; 19 23 $filter_wrapper_start = $filter_wrapper_end = ''; … … 41 45 42 46 function qapl_render_taxonomy_filter($args, $attributes, $taxonomy = null){ 43 if (!class_exists('QAPL_Quick_Ajax_Handler') || !method_exists('QAPL_Quick_Ajax_Handler', 'get_instance')) { 44 if (defined('WP_DEBUG') && WP_DEBUG) { 45 //error_log('Quick Ajax Post Loader: QAPL_Quick_Ajax_Handler class or method get_instance not found'); 46 } 47 if (!class_exists('QAPL_Quick_Ajax_Handler')) { 47 48 return; 48 49 } 49 $ajax_class = QAPL_Quick_Ajax_Handler::get_instance(); 50 $attributes = $attributes ?? []; 51 $ajax_class->wp_query_args($args, $attributes); 52 $ajax_class->layout_customization($attributes); 50 $attributes = is_array($attributes) ? $attributes : []; 51 $file_manager = new QAPL_Quick_Ajax_File_Manager(); 52 $ajax_handler = new QAPL_Quick_Ajax_Handler($file_manager); 53 54 $ajax_handler->wp_query_args($args, $attributes); 55 $ajax_handler->layout_customization($attributes); 53 56 $selected_taxonomy = null; 54 57 … … 59 62 } 60 63 if(!empty($selected_taxonomy) && is_string($selected_taxonomy)) { 61 echo $ajax_ class->render_taxonomy_terms_filter($selected_taxonomy);// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped64 echo $ajax_handler->render_taxonomy_terms_filter($selected_taxonomy);// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 62 65 } 63 66 } … … 68 71 69 72 function qapl_render_sort_controls($args, $attributes, $sort_options){ 70 if (!class_exists('QAPL_Quick_Ajax_Handler') || !method_exists('QAPL_Quick_Ajax_Handler', 'get_instance')) { 71 if (defined('WP_DEBUG') && WP_DEBUG) { 72 //error_log('Quick Ajax Post Loader: QAPL_Quick_Ajax_Handler class or method get_instance not found'); 73 } 73 if (!class_exists('QAPL_Quick_Ajax_Handler')) { 74 74 return; 75 75 } 76 $ajax_class = QAPL_Quick_Ajax_Handler::get_instance(); 77 $attributes = $attributes ?? []; 78 $ajax_class->wp_query_args($args, $attributes); 79 $ajax_class->layout_customization($attributes); 76 $attributes = is_array($attributes) ? $attributes : []; 77 $file_manager = new QAPL_Quick_Ajax_File_Manager(); 78 $ajax_handler = new QAPL_Quick_Ajax_Handler($file_manager); 79 80 $ajax_handler->wp_query_args($args, $attributes); 81 $ajax_handler->layout_customization($attributes); 82 80 83 if(!empty($sort_options) && is_array($sort_options)) { 81 echo $ajax_ class->render_sort_options($sort_options);// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped84 echo $ajax_handler->render_sort_options($sort_options);// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 82 85 } 83 }84 85 function qapl_quick_ajax_get_quick_ajax_id(){86 if (!class_exists('QAPL_Quick_Ajax_Handler') || !method_exists('QAPL_Quick_Ajax_Handler', 'get_instance')) {87 if (defined('WP_DEBUG') && WP_DEBUG) {88 //error_log('Quick Ajax Post Loader: QAPL_Quick_Ajax_Handler class or method get_instance not found');89 }90 return '';91 }92 $instance = QAPL_Quick_Ajax_Handler::get_instance();93 return sanitize_text_field($instance->get_quick_ajax_id());94 86 } 95 87 -
quick-ajax-post-loader/trunk/js/admin-script.js
r3328398 r3352831 380 380 var quickAjaxSortControlValue = ""; 381 381 var quickAjaxSortControlText = ""; 382 if (quickAjaxSortControl !== null ) {382 if (quickAjaxSortControl !== null && quickAjaxSortControlValueOptions) { 383 383 quickAjaxSortControlValue = ""; 384 384 quickAjaxSortControlValue += quickAjaxSortControlValueOptions; … … 394 394 } 395 395 let formattedText = ""; 396 if ( quickAjaxSortControlValue.trim() !== "") {396 if (typeof quickAjaxSortControlValue === "string" && quickAjaxSortControlValue.trim() !== "") { 397 397 formattedText += "\n// Set the sort options for the button.\n"; 398 398 formattedText += quickAjaxSortControlValue.trim() + "\n"; 399 399 } 400 if ( quickAjaxSortControlText.trim() !== "") {400 if (typeof quickAjaxSortControlText === "string" && quickAjaxSortControlText.trim() !== "") { 401 401 formattedText += "\n// Render the sorting control button.\n"; 402 402 formattedText += quickAjaxSortControlText.trim() + "\n"; -
quick-ajax-post-loader/trunk/js/admin-script.min.js
r3328398 r3352831 1 !function(e){var t={helper_available:"undefined"!=typeof qapl_quick_ajax_helper&&qapl_quick_ajax_helper,init:function(){this.click_and_select_shortcode(),this.click_and_select_all(),this.handle_post_type_change(),this.handle_taxonomy_change(),this.show_hide_element_on_change(),this.quick_ajax_tabs(),this.copy_code(),this.quick_ajax_function_generator(),this.accordion_block_toggle()},handle_post_type_change:function(){if(!this.helper_available)return;const t=this,a=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_post_type);a.length&&a.on("change",(function(){const a=e(this).val();e.ajax({url:qapl_quick_ajax_helper.ajax_url,type:"POST",data:{action:"qapl_quick_ajax_get_taxonomies_by_post_type",post_type:a,nonce:qapl_quick_ajax_helper.nonce},success:function(a){if(a&&a.data){const n=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_taxonomy);n.empty(),n.append(a.data),t.trigger_taxonomy_change()}},error:function(e,t,a){}})}))},handle_taxonomy_change:function(){if(!this.helper_available)return;const t=this,a=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_taxonomy),n=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_manual_selected_terms);a.length&&a.on("change",(function(){n.empty(),t.admin_page_loader(n);let a=e(this).val(),_="";e("#post_ID").length&&(_=e("#post_ID").val()),e.ajax({url:qapl_quick_ajax_helper.ajax_url,type:"POST",data:{action:"qapl_quick_ajax_get_terms_by_taxonomy",taxonomy:a,post_id:_,nonce:qapl_quick_ajax_helper.nonce},success:function(e){e&&e.data&&n.fadeOut(100,(function(){n.empty(),n.append(e.data),n.fadeIn(100)}))},error:function(e,t,a){}})}))},trigger_taxonomy_change:function(){if(!this.helper_available)return;const t=this,a=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_taxonomy),n=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_manual_selected_terms);n.length&&(t.admin_page_loader(n),a.trigger("change"))},admin_page_loader:function(e){e.append('<div class="qapl-admin-page-loader"><span></span><span></span><span></span></div>')},show_hide_element_on_change:function(){e(".show-hide-trigger input, .show-hide-trigger select").on("change",(function(){e(".quick-ajax-field-container[data-conditional]").each((function(){const t=e(this),a=t.data("conditional");let n=!0;for(const t in a){if(!a.hasOwnProperty(t))continue;const _=a[t],o=e("#"+t);if((o.is(":checkbox")?o.is(":checked")?"1":"0":o.val())!==_){n=!1;break}}n?t.removeClass("inactive"):t.addClass("inactive")}))}))},quick_ajax_tabs:function(){if(e(".quick-ajax-tabs").length){const t=e(".quick-ajax-tab-button"),a=e(".quick-ajax-tab-content");t.on("click",(function(n){n.preventDefault();const _=e(this).data("tab");t.removeClass("active").attr("aria-selected","false").attr("tabindex","-1"),a.removeClass("active").attr("hidden",!0),e(this).addClass("active").attr("aria-selected","true").attr("tabindex","0"),e("#"+_).addClass("active").attr("hidden",!1)})),t.on("keydown",(function(e){const a=t.index(this);let n;if("ArrowRight"===e.key)n=(a+1)%t.length;else{if("ArrowLeft"!==e.key)return;n=(a-1+t.length)%t.length}t.eq(n).focus().click()}))}},copy_code:function(){e(".copy-button").on("click",(function(){var t=e("#"+e(this).data("copy")),a=e("<textarea>").val(t.text()).appendTo("body").select();try{navigator.clipboard.writeText(t.text()).then((()=>{})).catch((e=>{}))}finally{a.remove(),e(this).text("Code Copied"),setTimeout((()=>{e(this).text("Copy Code")}),2e3)}}))},generateId:function(e){let t=0;for(let a=0;a<e.length;a++)t+=e.charCodeAt(a),a%2==0?t+=e.charCodeAt(a):t-=e.charCodeAt(a);return t},getExcludedPostIds:function(e){var t=e.split(/[,\s]+/),a=[];return t.forEach((function(e){/^\d+$/.test(e)&&-1===a.indexOf(e)&&a.push(e)})),a.join(", ")},cleanClassNames:function(e){let t=e.replace(/,/g," ").split(/\s+/);return t=t.filter(((e,t,a)=>!/^\d/.test(e)&&""!==e&&a.indexOf(e)===t)),t.join(", ")},qapl_collect_input_data:function(){const t={};return e(".function-generator-wrap input, .function-generator-wrap select").each((function(a,n){const _=e(n),o=_.attr("name"),i=_.attr("id");if("checkbox"===n.type)if(o&&o.endsWith("[]")){let e=o.replace(/\[\]$/,"");t[e]||(t[e]=[]),_.prop("checked")&&t[e].push(_.val())}else t[i]=_.prop("checked")?1:0;else t[i]=_.val()})),t},qapl_generate_args:function(e){const t=this;let a="",n="",_="";(a+="$quick_ajax_args = [\n",a+=" 'post_type' => '"+e.qapl_select_post_type+"',\n",a+=" 'posts_per_page' => "+e.qapl_select_posts_per_page+",\n","none"!==e.qapl_select_orderby&&(a+=" 'orderby' => '"+e.qapl_select_orderby+"',\n"),a+=" 'order' => '"+e.qapl_select_order+"',\n",""!==e.qapl_select_post_not_in)&&(a+=" 'post__not_in' => ["+t.getExcludedPostIds(e.qapl_select_post_not_in)+"],\n");if(1===e.qapl_ignore_sticky_posts&&(a+=" 'ignore_sticky_posts' => "+e.qapl_ignore_sticky_posts+",\n"),1===e.qapl_show_select_taxonomy&&(a+=" 'selected_taxonomy' => '"+e.qapl_select_taxonomy+"',\n"),1===e.qapl_show_select_taxonomy&&1===e.qapl_manual_term_selection){var o=e.qapl_manual_selected_terms;o&&o.length>0&&(n="[",n+=o.map((e=>`${e}`)).join(", "),n+="]"),n&&(a+=" 'selected_terms' => "+n+",\n")}let i=a.trimEnd();return i.endsWith(",")&&(a=i.slice(0,-1)+"\n"),a+="];",""!==a.trim()&&(_+="\n// Define AJAX query parameters for '"+e.qapl_select_post_type+"' type posts.\n",_+=a.trim()+"\n"),_},qapl_generate_attributes:function(e,t){const a=this;let n={},_="";n[qapl_quick_ajax_helper.quick_ajax_id]=t,1===e.qapl_layout_quick_ajax_css_style&&(n[qapl_quick_ajax_helper.quick_ajax_css_style]=e.qapl_layout_quick_ajax_css_style,n[qapl_quick_ajax_helper.grid_num_columns]=e.qapl_layout_select_columns_qty),e.qapl_layout_quick_ajax_post_item_template&&(n[qapl_quick_ajax_helper.post_item_template]=e.qapl_layout_quick_ajax_post_item_template),e.qapl_layout_add_taxonomy_filter_class&&""!==e.qapl_layout_add_taxonomy_filter_class&&(n[qapl_quick_ajax_helper.taxonomy_filter_class]=a.cleanClassNames(e.qapl_layout_add_taxonomy_filter_class)),e.qapl_layout_add_container_class&&""!==e.qapl_layout_add_container_class&&(n[qapl_quick_ajax_helper.container_class]=a.cleanClassNames(e.qapl_layout_add_container_class)),1===e.qapl_show_custom_load_more_post_quantity&&(n[qapl_quick_ajax_helper.load_more_posts]=e.qapl_select_custom_load_more_post_quantity),1===e.qapl_override_global_loader_icon&&(n[qapl_quick_ajax_helper.loader_icon]=e.qapl_loader_icon),1===e.qapl_ajax_on_initial_load&&(n[qapl_quick_ajax_helper.ajax_initial_load]=e.qapl_ajax_on_initial_load),1===e.qapl_ajax_infinite_scroll&&(n[qapl_quick_ajax_helper.infinite_scroll]=e.qapl_ajax_infinite_scroll),1===e.qapl_show_end_post_message&&(n[qapl_quick_ajax_helper.show_end_message]=e.qapl_show_end_post_message);var o="";return Object.keys(n).length>0&&(o="",o+="$quick_ajax_attributes = [\n",Object.entries(n).forEach((([e,t])=>{let n;n=a.quick_ajax_is_numeric(t)?parseInt(t):"string"==typeof t?`'${t}'`:t,o+=` '${e}' => ${n},\n`})),o=o.slice(0,-2)+"\n",o+="];"),""!==o.trim()&&(_+="\n// Define attributes for AJAX.\n",_+=o.trim()+"\n"),_},qapl_generate_sort_controls:function(e){let t=null,a=null;1===e.qapl_show_order_button&&(t=e.qapl_select_orderby_button_options,t&&t.length>0&&(a="$quick_ajax_sort_options = [",a+=t.map((e=>`'${e}'`)).join(", "),a+="];"));var n="",_="";null!==t&& (n="",n+=a,_="",_+="if(function_exists('qapl_render_sort_controls')){\n",_+=" qapl_render_sort_controls(\n",_+=" $quick_ajax_args,\n",_+=" $quick_ajax_attributes,\n",_+=" $quick_ajax_sort_options\n",_+=" );\n",_+="}");let o="";return""!==n.trim()&&(o+="\n// Set the sort options for the button.\n",o+=n.trim()+"\n"),""!==_.trim()&&(o+="\n// Render the sorting control button.\n",o+=_.trim()+"\n"),o},qapl_generate_taxonomy_filter:function(e){let t=null,a="",n="";return 1===e.qapl_show_select_taxonomy&&(t=e.qapl_select_taxonomy),null!==t&&(n+="if(function_exists('qapl_render_taxonomy_filter')){\n",n+=" qapl_render_taxonomy_filter(\n",n+=" $quick_ajax_args,\n",n+=" $quick_ajax_attributes,\n",n=n.slice(0,-2)+"\n",n+=" );\n",n+="}"),""!==n.trim()&&(a+="\n// Render the navigation for '"+e.qapl_select_taxonomy+"' taxonomy.\n",a+=n.trim()+"\n"),a},qapl_generate_post_container:function(e,t){let a="",n="";return n+="if(function_exists('qapl_render_post_container')){\n",n+=" qapl_render_post_container(\n",n+=" $quick_ajax_args,\n",""!==t&&(n+=" $quick_ajax_attributes,\n"),n=n.slice(0,-2)+"\n",n+=" );\n",n+="}",""!==n.trim()&&(a+="\n// Render the grid for '"+e.qapl_select_post_type+"' type posts.\n",a+=n.trim()+"\n"),a},quick_ajax_function_generator:function(){const t=this;this.helper_available&&e(".generate-function-button").on("click",(function(){const a=e(this),n=a.attr("data-output"),_=e("#"+n),o=e('.copy-button[data-copy="'+n+'"]');a.prop("disabled",!0),o.prop("disabled",!0);const i=t.qapl_collect_input_data(),l=Object.values(i).join(""),c=t.generateId(l),s=t.qapl_generate_args(i),r=t.qapl_generate_attributes(i,c),p=[s,r,t.qapl_generate_sort_controls(i),t.qapl_generate_taxonomy_filter(i),t.qapl_generate_post_container(i,r)].filter(Boolean).join("");_.empty();for(var u=p.split("\n"),d=0;d<u.length;d++)!function(e){setTimeout((function(){_.append(u[e]+"\n"),e===u.length-1&&(a.prop("disabled",!1),o.prop("disabled",!1))}),50*d)}(d)}))},quick_ajax_is_numeric:function(e){return/^-?\d+(\.\d+)?$/.test(e)},quick_ajax_color_picker:function(){e(".color-picker-field").wpColorPicker()},quick_ajax_select_text:function(e){var t,a;document.body.createTextRange?((t=document.body.createTextRange()).moveToElementText(e),t.select()):window.getSelection&&(a=window.getSelection(),(t=document.createRange()).selectNodeContents(e),a.removeAllRanges(),a.addRange(t))},click_and_select_shortcode:function(){const t=this;e(".quick-ajax-shortcode").on("click",(function(){t.quick_ajax_select_text(this)}))},click_and_select_all:function(){const t=this;e(".click-and-select-all").on("click",(function(){var a=e(this).find("code").get(0);t.quick_ajax_select_text(a)}))},accordion_block_toggle:function(){var t=e("#wpbody-content");if(t.find(".quick-ajax-tabs").length>0){var a=e("#adminmenuwrap").outerHeight();t.css("min-height",a)}e(".quick-ajax-accordion-toggle").click((function(){e(this).toggleClass("active").next(".quick-ajax-accordion-content").slideToggle(200)}))}};e(document).ready((function(){t.init()}))}(jQuery);1 !function(e){var t={helper_available:"undefined"!=typeof qapl_quick_ajax_helper&&qapl_quick_ajax_helper,init:function(){this.click_and_select_shortcode(),this.click_and_select_all(),this.handle_post_type_change(),this.handle_taxonomy_change(),this.show_hide_element_on_change(),this.quick_ajax_tabs(),this.copy_code(),this.quick_ajax_function_generator(),this.accordion_block_toggle()},handle_post_type_change:function(){if(!this.helper_available)return;const t=this,a=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_post_type);a.length&&a.on("change",(function(){const a=e(this).val();e.ajax({url:qapl_quick_ajax_helper.ajax_url,type:"POST",data:{action:"qapl_quick_ajax_get_taxonomies_by_post_type",post_type:a,nonce:qapl_quick_ajax_helper.nonce},success:function(a){if(a&&a.data){const n=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_taxonomy);n.empty(),n.append(a.data),t.trigger_taxonomy_change()}},error:function(e,t,a){}})}))},handle_taxonomy_change:function(){if(!this.helper_available)return;const t=this,a=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_taxonomy),n=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_manual_selected_terms);a.length&&a.on("change",(function(){n.empty(),t.admin_page_loader(n);let a=e(this).val(),_="";e("#post_ID").length&&(_=e("#post_ID").val()),e.ajax({url:qapl_quick_ajax_helper.ajax_url,type:"POST",data:{action:"qapl_quick_ajax_get_terms_by_taxonomy",taxonomy:a,post_id:_,nonce:qapl_quick_ajax_helper.nonce},success:function(e){e&&e.data&&n.fadeOut(100,(function(){n.empty(),n.append(e.data),n.fadeIn(100)}))},error:function(e,t,a){}})}))},trigger_taxonomy_change:function(){if(!this.helper_available)return;const t=this,a=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_taxonomy),n=e("#"+qapl_quick_ajax_helper.quick_ajax_settings_wrapper+" #"+qapl_quick_ajax_helper.quick_ajax_manual_selected_terms);n.length&&(t.admin_page_loader(n),a.trigger("change"))},admin_page_loader:function(e){e.append('<div class="qapl-admin-page-loader"><span></span><span></span><span></span></div>')},show_hide_element_on_change:function(){e(".show-hide-trigger input, .show-hide-trigger select").on("change",(function(){e(".quick-ajax-field-container[data-conditional]").each((function(){const t=e(this),a=t.data("conditional");let n=!0;for(const t in a){if(!a.hasOwnProperty(t))continue;const _=a[t],o=e("#"+t);if((o.is(":checkbox")?o.is(":checked")?"1":"0":o.val())!==_){n=!1;break}}n?t.removeClass("inactive"):t.addClass("inactive")}))}))},quick_ajax_tabs:function(){if(e(".quick-ajax-tabs").length){const t=e(".quick-ajax-tab-button"),a=e(".quick-ajax-tab-content");t.on("click",(function(n){n.preventDefault();const _=e(this).data("tab");t.removeClass("active").attr("aria-selected","false").attr("tabindex","-1"),a.removeClass("active").attr("hidden",!0),e(this).addClass("active").attr("aria-selected","true").attr("tabindex","0"),e("#"+_).addClass("active").attr("hidden",!1)})),t.on("keydown",(function(e){const a=t.index(this);let n;if("ArrowRight"===e.key)n=(a+1)%t.length;else{if("ArrowLeft"!==e.key)return;n=(a-1+t.length)%t.length}t.eq(n).focus().click()}))}},copy_code:function(){e(".copy-button").on("click",(function(){var t=e("#"+e(this).data("copy")),a=e("<textarea>").val(t.text()).appendTo("body").select();try{navigator.clipboard.writeText(t.text()).then((()=>{})).catch((e=>{}))}finally{a.remove(),e(this).text("Code Copied"),setTimeout((()=>{e(this).text("Copy Code")}),2e3)}}))},generateId:function(e){let t=0;for(let a=0;a<e.length;a++)t+=e.charCodeAt(a),a%2==0?t+=e.charCodeAt(a):t-=e.charCodeAt(a);return t},getExcludedPostIds:function(e){var t=e.split(/[,\s]+/),a=[];return t.forEach((function(e){/^\d+$/.test(e)&&-1===a.indexOf(e)&&a.push(e)})),a.join(", ")},cleanClassNames:function(e){let t=e.replace(/,/g," ").split(/\s+/);return t=t.filter(((e,t,a)=>!/^\d/.test(e)&&""!==e&&a.indexOf(e)===t)),t.join(", ")},qapl_collect_input_data:function(){const t={};return e(".function-generator-wrap input, .function-generator-wrap select").each((function(a,n){const _=e(n),o=_.attr("name"),i=_.attr("id");if("checkbox"===n.type)if(o&&o.endsWith("[]")){let e=o.replace(/\[\]$/,"");t[e]||(t[e]=[]),_.prop("checked")&&t[e].push(_.val())}else t[i]=_.prop("checked")?1:0;else t[i]=_.val()})),t},qapl_generate_args:function(e){const t=this;let a="",n="",_="";(a+="$quick_ajax_args = [\n",a+=" 'post_type' => '"+e.qapl_select_post_type+"',\n",a+=" 'posts_per_page' => "+e.qapl_select_posts_per_page+",\n","none"!==e.qapl_select_orderby&&(a+=" 'orderby' => '"+e.qapl_select_orderby+"',\n"),a+=" 'order' => '"+e.qapl_select_order+"',\n",""!==e.qapl_select_post_not_in)&&(a+=" 'post__not_in' => ["+t.getExcludedPostIds(e.qapl_select_post_not_in)+"],\n");if(1===e.qapl_ignore_sticky_posts&&(a+=" 'ignore_sticky_posts' => "+e.qapl_ignore_sticky_posts+",\n"),1===e.qapl_show_select_taxonomy&&(a+=" 'selected_taxonomy' => '"+e.qapl_select_taxonomy+"',\n"),1===e.qapl_show_select_taxonomy&&1===e.qapl_manual_term_selection){var o=e.qapl_manual_selected_terms;o&&o.length>0&&(n="[",n+=o.map((e=>`${e}`)).join(", "),n+="]"),n&&(a+=" 'selected_terms' => "+n+",\n")}let i=a.trimEnd();return i.endsWith(",")&&(a=i.slice(0,-1)+"\n"),a+="];",""!==a.trim()&&(_+="\n// Define AJAX query parameters for '"+e.qapl_select_post_type+"' type posts.\n",_+=a.trim()+"\n"),_},qapl_generate_attributes:function(e,t){const a=this;let n={},_="";n[qapl_quick_ajax_helper.quick_ajax_id]=t,1===e.qapl_layout_quick_ajax_css_style&&(n[qapl_quick_ajax_helper.quick_ajax_css_style]=e.qapl_layout_quick_ajax_css_style,n[qapl_quick_ajax_helper.grid_num_columns]=e.qapl_layout_select_columns_qty),e.qapl_layout_quick_ajax_post_item_template&&(n[qapl_quick_ajax_helper.post_item_template]=e.qapl_layout_quick_ajax_post_item_template),e.qapl_layout_add_taxonomy_filter_class&&""!==e.qapl_layout_add_taxonomy_filter_class&&(n[qapl_quick_ajax_helper.taxonomy_filter_class]=a.cleanClassNames(e.qapl_layout_add_taxonomy_filter_class)),e.qapl_layout_add_container_class&&""!==e.qapl_layout_add_container_class&&(n[qapl_quick_ajax_helper.container_class]=a.cleanClassNames(e.qapl_layout_add_container_class)),1===e.qapl_show_custom_load_more_post_quantity&&(n[qapl_quick_ajax_helper.load_more_posts]=e.qapl_select_custom_load_more_post_quantity),1===e.qapl_override_global_loader_icon&&(n[qapl_quick_ajax_helper.loader_icon]=e.qapl_loader_icon),1===e.qapl_ajax_on_initial_load&&(n[qapl_quick_ajax_helper.ajax_initial_load]=e.qapl_ajax_on_initial_load),1===e.qapl_ajax_infinite_scroll&&(n[qapl_quick_ajax_helper.infinite_scroll]=e.qapl_ajax_infinite_scroll),1===e.qapl_show_end_post_message&&(n[qapl_quick_ajax_helper.show_end_message]=e.qapl_show_end_post_message);var o="";return Object.keys(n).length>0&&(o="",o+="$quick_ajax_attributes = [\n",Object.entries(n).forEach((([e,t])=>{let n;n=a.quick_ajax_is_numeric(t)?parseInt(t):"string"==typeof t?`'${t}'`:t,o+=` '${e}' => ${n},\n`})),o=o.slice(0,-2)+"\n",o+="];"),""!==o.trim()&&(_+="\n// Define attributes for AJAX.\n",_+=o.trim()+"\n"),_},qapl_generate_sort_controls:function(e){let t=null,a=null;1===e.qapl_show_order_button&&(t=e.qapl_select_orderby_button_options,t&&t.length>0&&(a="$quick_ajax_sort_options = [",a+=t.map((e=>`'${e}'`)).join(", "),a+="];"));var n="",_="";null!==t&&a&&(n="",n+=a,_="",_+="if(function_exists('qapl_render_sort_controls')){\n",_+=" qapl_render_sort_controls(\n",_+=" $quick_ajax_args,\n",_+=" $quick_ajax_attributes,\n",_+=" $quick_ajax_sort_options\n",_+=" );\n",_+="}");let o="";return"string"==typeof n&&""!==n.trim()&&(o+="\n// Set the sort options for the button.\n",o+=n.trim()+"\n"),"string"==typeof _&&""!==_.trim()&&(o+="\n// Render the sorting control button.\n",o+=_.trim()+"\n"),o},qapl_generate_taxonomy_filter:function(e){let t=null,a="",n="";return 1===e.qapl_show_select_taxonomy&&(t=e.qapl_select_taxonomy),null!==t&&(n+="if(function_exists('qapl_render_taxonomy_filter')){\n",n+=" qapl_render_taxonomy_filter(\n",n+=" $quick_ajax_args,\n",n+=" $quick_ajax_attributes,\n",n=n.slice(0,-2)+"\n",n+=" );\n",n+="}"),""!==n.trim()&&(a+="\n// Render the navigation for '"+e.qapl_select_taxonomy+"' taxonomy.\n",a+=n.trim()+"\n"),a},qapl_generate_post_container:function(e,t){let a="",n="";return n+="if(function_exists('qapl_render_post_container')){\n",n+=" qapl_render_post_container(\n",n+=" $quick_ajax_args,\n",""!==t&&(n+=" $quick_ajax_attributes,\n"),n=n.slice(0,-2)+"\n",n+=" );\n",n+="}",""!==n.trim()&&(a+="\n// Render the grid for '"+e.qapl_select_post_type+"' type posts.\n",a+=n.trim()+"\n"),a},quick_ajax_function_generator:function(){const t=this;this.helper_available&&e(".generate-function-button").on("click",(function(){const a=e(this),n=a.attr("data-output"),_=e("#"+n),o=e('.copy-button[data-copy="'+n+'"]');a.prop("disabled",!0),o.prop("disabled",!0);const i=t.qapl_collect_input_data(),l=Object.values(i).join(""),c=t.generateId(l),s=t.qapl_generate_args(i),r=t.qapl_generate_attributes(i,c),p=[s,r,t.qapl_generate_sort_controls(i),t.qapl_generate_taxonomy_filter(i),t.qapl_generate_post_container(i,r)].filter(Boolean).join("");_.empty();for(var u=p.split("\n"),d=0;d<u.length;d++)!function(e){setTimeout((function(){_.append(u[e]+"\n"),e===u.length-1&&(a.prop("disabled",!1),o.prop("disabled",!1))}),50*d)}(d)}))},quick_ajax_is_numeric:function(e){return/^-?\d+(\.\d+)?$/.test(e)},quick_ajax_color_picker:function(){e(".color-picker-field").wpColorPicker()},quick_ajax_select_text:function(e){var t,a;document.body.createTextRange?((t=document.body.createTextRange()).moveToElementText(e),t.select()):window.getSelection&&(a=window.getSelection(),(t=document.createRange()).selectNodeContents(e),a.removeAllRanges(),a.addRange(t))},click_and_select_shortcode:function(){const t=this;e(".quick-ajax-shortcode").on("click",(function(){t.quick_ajax_select_text(this)}))},click_and_select_all:function(){const t=this;e(".click-and-select-all").on("click",(function(){var a=e(this).find("code").get(0);t.quick_ajax_select_text(a)}))},accordion_block_toggle:function(){var t=e("#wpbody-content");if(t.find(".quick-ajax-tabs").length>0){var a=e("#adminmenuwrap").outerHeight();t.css("min-height",a)}e(".quick-ajax-accordion-toggle").click((function(){e(this).toggleClass("active").next(".quick-ajax-accordion-content").slideToggle(200)}))}};e(document).ready((function(){t.init()}))}(jQuery); -
quick-ajax-post-loader/trunk/quick-ajax-post-loader.php
r3337932 r3352831 5 5 * Text Domain: quick-ajax-post-loader 6 6 * Domain Path: /languages 7 * Version: 1. 7.77 * Version: 1.8.0 8 8 * Description: Supercharge post loading with Quick Ajax Post Loader. Enhance user experience and optimize site performance using AJAX technology. 9 9 * Author: Pawel Grzelkowski … … 20 20 register_activation_hook(__FILE__, ['QAPL_Quick_Ajax_Activator', 'activate']); 21 21 22 function qapl_quick_ajax_load_textdomain() {23 load_plugin_textdomain('quick-ajax-post-loader', false, dirname(plugin_basename(__FILE__)) . '/languages/');24 }25 add_action('plugins_loaded', 'qapl_quick_ajax_load_textdomain');26 27 22 function qapl_initialize_plugin() { 28 if (class_exists('QAPL_Quick_Ajax_ Helper')) {23 if (class_exists('QAPL_Quick_Ajax_Plugin_Starter')) { 29 24 function qapl_quick_ajax_admin_notice() { 30 echo '<div class="error"><p><strong>Quick Ajax Post Loader:</strong> A class named <strong>"QAPL_Quick_Ajax_ Helper"</strong> already exists, which may have been declared by another plugin.</p></div>';25 echo '<div class="error"><p><strong>Quick Ajax Post Loader:</strong> A class named <strong>"QAPL_Quick_Ajax_Plugin_Starter"</strong> already exists, which may have been declared by another plugin.</p></div>'; 31 26 } 32 27 add_action('admin_notices', 'qapl_quick_ajax_admin_notice'); 33 28 }else{ 34 29 require_once(plugin_dir_path( __FILE__ ).'inc/class-helper.php'); 35 $qapl_helper = QAPL_Quick_Ajax_Helper::get_instance();36 // Register frontend styles and scripts37 add_action('wp_enqueue_scripts', [$qapl_helper, 'enqueue_frontend_styles_and_scripts']);38 // Register admin styles and scripts39 add_action('admin_enqueue_scripts', [$qapl_helper, 'enqueue_admin_styles_and_scripts']);40 30 } 41 31 } -
quick-ajax-post-loader/trunk/readme.txt
r3337932 r3352831 5 5 Requires at least: 5.6 6 6 Tested up to: 6.8 7 Stable tag: 1. 7.77 Stable tag: 1.8.0 8 8 Requires PHP: 7.4 9 9 License: GPLv2 or later … … 106 106 == Changelog == 107 107 108 = 1.8.0 - 2025-08-29 = 109 - Major internal refactoring to improve plugin stability and long-term reliability. 110 - Fixed several issues in the Function Generator for more consistent output. 111 - Corrected minor CSS and JavaScript bugs to improve layout and functionality. 112 - Optimized performance across both frontend and admin interface. 113 - Improved compatibility with the latest WordPress versions. 114 115 **Note:** 116 - Most changes are behind the scenes. You may notice smoother performance and fewer issues, while the plugin remains fully compatible with your setup. 117 108 118 = 1.7.7 - 2025-08-01 = 109 119 - Improved CSS for better layout adaptability and responsiveness across various screen sizes. … … 312 322 == Upgrade Notice == 313 323 324 = 1.8.0 = 325 Includes major internal improvements, bug fixes, and performance optimizations. 326 Recommended update for better stability and compatibility. 327 314 328 = 1.7.3 = 315 329 **Important:** … … 318 332 319 333 = 1.7.0 = 320 This update introduces improvements to filter buttons, loader styling, and shortcode parameter handling. 321 322 **Important:** 323 - New support for selecting taxonomy terms directly in shortcode settings offers better control. 324 - The `qapl_render_taxonomy_filter()` function now auto-detects taxonomy and remains backward compatible. 325 326 Recommended update for improved developer experience and enhanced plugin stability. 334 Improves filter buttons, loader styling, and shortcode parameters. Adds taxonomy term selection in settings. `qapl_render_taxonomy_filter()` now auto-detects taxonomy. Recommended for better stability. 335 327 336 328 337 = 1.6.4 = … … 336 345 337 346 = 1.6.3 = 338 This update adds support for an "End Message" that appears when there are no more posts to load. 339 340 **Important:** 341 - The message can be set globally, edited in the template, or modified via the `qapl_template_end_post_message` filter. 342 343 Recommended update for improved usability and developer flexibility. 347 Adds support for an "End Message" shown when no more posts load. It can be set globally, edited in the template, or modified via the `qapl_template_end_post_message` filter. 344 348 345 349 = 1.6.0 = … … 351 355 352 356 = 1.5.0 = 353 Introduces a new sorting button feature and global sorting label options. 354 355 **Important:** 356 - The plugin now supports only `publish` posts, removing unnecessary settings. 357 - Removed unused `orderby` values (can still be re-added via the `qapl_modify_posts_query_args` hook). 358 359 Recommended update for improved sorting control and better plugin stability. 357 Adds new sorting button and global sorting labels. Now supports only `publish` posts. Unused `orderby` values removed (can be restored via `qapl_modify_posts_query_args`). Improves sorting control and plugin stability. 360 358 361 359 = 1.4.0 =
Note: See TracChangeset
for help on using the changeset viewer.