← All changes
|
includes/widgets/Dynamic_Posts_Grid/Dynamic_Posts_Grid.php
+26
-14
51.1.35
→
51.1.83
View file →
| @@ -22,9 +22,22 @@ | ||
| 22 | 22 | * Features different post types, color coding, and responsive design. |
| 23 | 23 | */ |
| 24 | 24 | class Dynamic_Posts_Grid extends Widget_Base |
| 25 | 25 | { |
| 26 | + /** | |
| 27 | + * Allow Pro to fully override widget output without using parent::render(). | |
| 28 | + * | |
| 29 | + * Pro can return true to indicate it rendered the widget output completely. | |
| 30 | + * | |
| 31 | + * @param array<string, mixed> $settings Widget settings for display. | |
| 32 | + * @return bool Whether Pro rendered output. | |
| 33 | + */ | |
| 34 | + public function maybe_render_pro(array $settings): bool | |
| 35 | + { | |
| 36 | + return false; | |
| 37 | + } | |
| 26 | 38 | |
| 39 | + | |
| 27 | 40 | /** |
| 28 | 41 | * Get widget name. |
| 29 | 42 | * |
| 30 | 43 | * @return string Widget name. |
| @@ -70,9 +83,12 @@ | ||
| 70 | 83 | * @return array Script dependencies. |
| 71 | 84 | */ |
| 72 | 85 | public function get_script_depends(): array |
| 73 | 86 | { |
| 74 | - return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-dynamic-posts-grid-script']; | |
| 87 | + return [ | |
| 88 | + KING_ADDONS_ASSETS_UNIQUE_KEY . '-dompurify-purify.min', | |
| 89 | + KING_ADDONS_ASSETS_UNIQUE_KEY . '-dynamic-posts-grid-script' | |
| 90 | + ]; | |
| 75 | 91 | } |
| 76 | 92 | |
| 77 | 93 | /** |
| 78 | 94 | * Get widget categories. |
| @@ -495,8 +511,12 @@ | ||
| 495 | 511 | |
| 496 | 512 | // PRO: Meta Fields Control |
| 497 | 513 | $this->add_control_meta_fields(); |
| 498 | 514 | |
| 515 | + // Both controls above are Pro-only, so without this the free build shows | |
| 516 | + // a section header that expands onto an empty panel. | |
| 517 | + Core::renderUpgradeProSection($this, Controls_Manager::RAW_HTML, 'dynamic-posts-grid', 'kng_dynamic_posts_meta_fields_pro_notice_'); | |
| 518 | + | |
| 499 | 519 | $this->end_controls_section(); |
| 500 | 520 | |
| 501 | 521 | // Category Colors Section |
| 502 | 522 | $this->start_controls_section( |
| @@ -3864,20 +3884,8 @@ | ||
| 3864 | 3884 | ], |
| 3865 | 3885 | ] |
| 3866 | 3886 | ); |
| 3867 | 3887 | |
| 3868 | - $this->add_control( | |
| 3869 | - 'kng_dynamic_posts_default_button_border_color', | |
| 3870 | - [ | |
| 3871 | - 'label' => esc_html__('Default Button Border Color', 'king-addons'), | |
| 3872 | - 'type' => Controls_Manager::COLOR, | |
| 3873 | - 'default' => 'rgba(0, 0, 0, 0.1)', | |
| 3874 | - 'selectors' => [ | |
| 3875 | - '{{WRAPPER}} .king-addons-dpg-button' => 'border-color: {{VALUE}};', | |
| 3876 | - ], | |
| 3877 | - ] | |
| 3878 | - ); | |
| 3879 | - | |
| 3880 | 3888 | // Category-specific colors |
| 3881 | 3889 | $default_colors = [ |
| 3882 | 3890 | ['color' => '#FFFFFF', 'bg' => '#EF4444', 'hover_color' => '#FFFFFF', 'hover_bg' => '#DC2626', 'border' => '#EF4444'], // Red |
| 3883 | 3891 | ['color' => '#FFFFFF', 'bg' => '#3B82F6', 'hover_color' => '#FFFFFF', 'hover_bg' => '#2563EB', 'border' => '#3B82F6'], // Blue |
| @@ -4155,8 +4163,12 @@ | ||
| 4155 | 4163 | { |
| 4156 | 4164 | $settings = $this->get_settings_for_display(); |
| 4157 | 4165 | $widget_id = $this->get_id(); |
| 4158 | 4166 | |
| 4167 | + if ($this->maybe_render_pro($settings)) { | |
| 4168 | + return; | |
| 4169 | + } | |
| 4170 | + | |
| 4159 | 4171 | // Query posts |
| 4160 | 4172 | $query_args = [ |
| 4161 | 4173 | 'post_type' => $settings['kng_dynamic_posts_post_types'], |
| 4162 | 4174 | 'posts_per_page' => $settings['kng_dynamic_posts_per_page'], |
| @@ -4256,9 +4268,9 @@ | ||
| 4256 | 4268 | </div> |
| 4257 | 4269 | <?php endif; ?> |
| 4258 | 4270 | |
| 4259 | 4271 | <!-- Grid Container --> |
| 4260 | - <div class="king-addons-dpg-grid" data-columns="<?php echo esc_attr($settings['kng_dynamic_posts_columns']); ?>"> | |
| 4272 | + <div class="king-addons-dpg-grid" data-columns="<?php echo esc_attr($settings['kng_dynamic_posts_columns'] ?? '3'); ?>"> | |
| 4261 | 4273 | <?php $this->render_posts($posts_query, $settings); ?> |
| 4262 | 4274 | </div> |
| 4263 | 4275 | |
| 4264 | 4276 | <?php if ($settings['kng_dynamic_posts_enable_load_more'] === 'yes'): ?> |