dep
1 month ago
premium-banner.php
3 weeks ago
premium-blog.php
3 weeks ago
premium-button.php
3 weeks ago
premium-carousel.php
3 weeks ago
premium-contactform.php
3 weeks ago
premium-countdown.php
3 weeks ago
premium-counter.php
3 weeks ago
premium-dual-header.php
3 weeks ago
premium-fancytext.php
3 weeks ago
premium-grid.php
3 weeks ago
premium-icon-list.php
3 weeks ago
premium-image-button.php
3 weeks ago
premium-image-scroll.php
3 weeks ago
premium-image-separator.php
3 weeks ago
premium-lottie.php
3 weeks ago
premium-maps.php
3 weeks ago
premium-media-wheel.php
3 weeks ago
premium-mobile-menu.php
3 weeks ago
premium-modalbox.php
3 weeks ago
premium-nav-menu.php
3 weeks ago
premium-notifications.php
3 weeks ago
premium-person.php
3 weeks ago
premium-pinterest-feed.php
3 weeks ago
premium-post-ticker.php
3 weeks ago
premium-pricing-table.php
3 weeks ago
premium-progressbar.php
3 weeks ago
premium-search-form.php
3 weeks ago
premium-svg-drawer.php
3 weeks ago
premium-tcloud.php
3 weeks ago
premium-testimonials.php
3 weeks ago
premium-textual-showcase.php
3 weeks ago
premium-tiktok-feed.php
3 weeks ago
premium-title.php
3 weeks ago
premium-videobox.php
3 weeks ago
premium-vscroll.php
3 weeks ago
premium-weather.php
3 weeks ago
premium-world-clock.php
3 weeks ago
premium-tcloud.php
1134 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Premium Tags Cloud. |
| 4 | */ |
| 5 | |
| 6 | namespace PremiumAddons\Widgets; |
| 7 | |
| 8 | // Elementor Classes. |
| 9 | use Elementor\Modules\DynamicTags\Module as TagsModule; |
| 10 | use Elementor\Plugin; |
| 11 | use Elementor\Widget_Base; |
| 12 | use Elementor\Utils; |
| 13 | use Elementor\Control_Media; |
| 14 | use Elementor\Controls_Manager; |
| 15 | use Elementor\Icons_Manager; |
| 16 | use Elementor\Group_Control_Border; |
| 17 | use Elementor\Group_Control_Css_Filter; |
| 18 | use Elementor\Group_Control_Box_Shadow; |
| 19 | use Elementor\Group_Control_Text_Shadow; |
| 20 | use Elementor\Group_Control_Image_Size; |
| 21 | use Elementor\Group_Control_Typography; |
| 22 | |
| 23 | // PremiumAddons Classes. |
| 24 | use PremiumAddons\Includes\Premium_Template_Tags as Blog_Helper; |
| 25 | use PremiumAddons\Admin\Includes\Admin_Helper; |
| 26 | use PremiumAddons\Includes\Helper_Functions; |
| 27 | use PremiumAddons\Includes\Controls\Premium_Tax_Filter; |
| 28 | |
| 29 | if ( ! defined( 'ABSPATH' ) ) { |
| 30 | exit; // If this file is called directly, abort. |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Class Premium_Tcloud |
| 35 | */ |
| 36 | class Premium_Tcloud extends Widget_Base { |
| 37 | |
| 38 | /** |
| 39 | * Retrieve Widget Name. |
| 40 | * |
| 41 | * @since 1.0.0 |
| 42 | * @access public |
| 43 | */ |
| 44 | public function get_name() { |
| 45 | return 'premium-tcloud'; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Retrieve Widget Title. |
| 50 | * |
| 51 | * @since 1.0.0 |
| 52 | * @access public |
| 53 | */ |
| 54 | public function get_title() { |
| 55 | return __( 'Tags Cloud', 'premium-addons-for-elementor' ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * Retrieve Widget Dependent CSS. |
| 60 | * |
| 61 | * @since 1.0.0 |
| 62 | * @access public |
| 63 | * |
| 64 | * @return array CSS style handles. |
| 65 | */ |
| 66 | public function get_style_depends() { |
| 67 | return array( |
| 68 | 'pa-glass', |
| 69 | 'premium-addons', |
| 70 | ); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Retrieve Widget Dependent JS. |
| 75 | * |
| 76 | * @since 1.0.0 |
| 77 | * @access public |
| 78 | * |
| 79 | * @return array JS script handles. |
| 80 | */ |
| 81 | public function get_script_depends() { |
| 82 | |
| 83 | $is_edit = Helper_Functions::is_edit_mode(); |
| 84 | |
| 85 | $scripts = array(); |
| 86 | |
| 87 | if ( $is_edit ) { |
| 88 | |
| 89 | $scripts = array( 'pa-glass', 'pa-awesomecloud', 'pa-tagcanvas' ); |
| 90 | |
| 91 | } else { |
| 92 | $settings = $this->get_settings(); |
| 93 | |
| 94 | if ( 'none' !== $settings['term_lq_effect'] ) { |
| 95 | $scripts[] = 'pa-glass'; |
| 96 | } |
| 97 | |
| 98 | if ( 'sphere' === $settings['words_order'] ) { |
| 99 | $scripts[] = 'pa-tagcanvas'; |
| 100 | } elseif ( 'shape' === $settings['words_order'] ) { |
| 101 | $scripts[] = 'pa-awesomecloud'; |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | $scripts[] = 'premium-addons'; |
| 106 | |
| 107 | return $scripts; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Retrieve Widget Icon. |
| 112 | * |
| 113 | * @since 1.0.0 |
| 114 | * @access public |
| 115 | * |
| 116 | * @return string widget icon. |
| 117 | */ |
| 118 | public function get_icon() { |
| 119 | return 'pa-tags-cloud'; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Retrieve Widget Categories. |
| 124 | * |
| 125 | * @since 1.5.1 |
| 126 | * @access public |
| 127 | * |
| 128 | * @return array Widget categories. |
| 129 | */ |
| 130 | public function get_categories() { |
| 131 | return array( 'premium-elements' ); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Retrieve Widget Keywords. |
| 136 | * |
| 137 | * @since 1.0.0 |
| 138 | * @access public |
| 139 | * |
| 140 | * @return string Widget keywords. |
| 141 | */ |
| 142 | public function get_keywords() { |
| 143 | return array( 'pa', 'premium', 'premium tags cloud', 'tag', 'cat', 'product', 'woo', 'query', 'cpt' ); |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * Retrieve Widget Support URL. |
| 148 | * |
| 149 | * @access public |
| 150 | * |
| 151 | * @return string support URL. |
| 152 | */ |
| 153 | public function get_custom_help_url() { |
| 154 | return 'https://premiumaddons.com/support/'; |
| 155 | } |
| 156 | |
| 157 | public function has_widget_inner_wrapper(): bool { |
| 158 | return ! Helper_Functions::check_elementor_experiment( 'e_optimized_markup' ); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Register Image Controls controls. |
| 163 | * |
| 164 | * @since 1.0.0 |
| 165 | * @access protected |
| 166 | */ |
| 167 | protected function register_controls() { // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore |
| 168 | |
| 169 | $papro_activated = Helper_Functions::check_papro_version(); |
| 170 | |
| 171 | $this->start_controls_section( |
| 172 | 'display_options_section', |
| 173 | array( |
| 174 | 'label' => __( 'Display Options', 'premium-addons-for-elementor' ), |
| 175 | ) |
| 176 | ); |
| 177 | |
| 178 | $options = apply_filters( |
| 179 | 'pa_tcloud_layouts', |
| 180 | array( |
| 181 | 'layouts' => array( |
| 182 | 'default' => __( 'Default', 'premium-addons-for-elementor' ), |
| 183 | 'ribbon' => __( 'Label', 'premium-addons-for-elementor' ), |
| 184 | 'shape' => __( 'Shape (Pro)', 'premium-addons-for-elementor' ), |
| 185 | 'sphere' => __( 'Sphere (Pro)', 'premium-addons-for-elementor' ), |
| 186 | ), |
| 187 | 'order_condition' => array( 'shape', 'sphere' ), |
| 188 | 'source_condition' => array( |
| 189 | 'post_type_filter' => 'post', |
| 190 | ), |
| 191 | ) |
| 192 | ); |
| 193 | |
| 194 | $this->add_control( |
| 195 | 'words_order', |
| 196 | array( |
| 197 | 'label' => __( 'Words Order', 'premium-addons-for-elementor' ), |
| 198 | 'type' => Controls_Manager::SELECT, |
| 199 | 'options' => $options['layouts'], |
| 200 | 'default' => 'default', |
| 201 | 'frontend_available' => true, |
| 202 | ) |
| 203 | ); |
| 204 | |
| 205 | $this->add_responsive_control( |
| 206 | 'circle_position', |
| 207 | array( |
| 208 | 'label' => __( 'Circle Position', 'premium-addons-for-elementor' ), |
| 209 | 'type' => Controls_Manager::SLIDER, |
| 210 | 'size_units' => array( 'px', 'em', '%', 'custom' ), |
| 211 | 'selectors' => array( |
| 212 | '{{WRAPPER}} .premium-tcloud-term::after' => 'left: {{SIZE}}{{UNIT}}', |
| 213 | ), |
| 214 | 'frontend_available' => true, |
| 215 | 'condition' => array( |
| 216 | 'words_order' => 'ribbon', |
| 217 | ), |
| 218 | ) |
| 219 | ); |
| 220 | |
| 221 | $this->add_control( |
| 222 | 'words_remove', |
| 223 | array( |
| 224 | 'label' => __( 'Words to Remove', 'premium-addons-for-elementor' ), |
| 225 | 'type' => Controls_Manager::TEXT, |
| 226 | 'description' => __( 'Add a list of words separated by comma to be removed. For example, word1,word2, etc.', 'premium-addons-for-elementor' ), |
| 227 | 'label_block' => true, |
| 228 | 'condition' => array( |
| 229 | 'words_order!' => $options['order_condition'], |
| 230 | ), |
| 231 | ) |
| 232 | ); |
| 233 | |
| 234 | $this->add_control( |
| 235 | 'words_number', |
| 236 | array( |
| 237 | 'label' => __( 'Max Number of Words', 'premium-addons-for-elementor' ), |
| 238 | 'description' => __( 'Use this option to strip term to specific number of words.', 'premium-addons-for-elementor' ), |
| 239 | 'type' => Controls_Manager::NUMBER, |
| 240 | 'condition' => array( |
| 241 | 'words_order!' => $options['order_condition'], |
| 242 | ), |
| 243 | ) |
| 244 | ); |
| 245 | |
| 246 | $this->add_control( |
| 247 | 'show_posts_number', |
| 248 | array( |
| 249 | 'label' => __( 'Show Posts Number', 'premium-addons-for-elementor' ), |
| 250 | 'type' => Controls_Manager::SWITCHER, |
| 251 | 'default' => 'yes', |
| 252 | 'condition' => array( |
| 253 | 'words_order' => array( 'default', 'ribbon' ), |
| 254 | 'get_from_current!' => 'yes', |
| 255 | ), |
| 256 | ) |
| 257 | ); |
| 258 | |
| 259 | $this->add_control( |
| 260 | 'suffix_word', |
| 261 | array( |
| 262 | 'label' => __( 'Replace With', 'premium-addons-for-elementor' ), |
| 263 | 'type' => Controls_Manager::TEXT, |
| 264 | 'description' => __( 'Use this option if the number of words is larger than a specific number.', 'premium-addons-for-elementor' ), |
| 265 | 'label_block' => true, |
| 266 | 'condition' => array( |
| 267 | 'words_order!' => $options['order_condition'], |
| 268 | 'words_number!' => '', |
| 269 | ), |
| 270 | ) |
| 271 | ); |
| 272 | |
| 273 | if ( ! $papro_activated ) { |
| 274 | $get_pro = Helper_Functions::get_campaign_link( 'https://premiumaddons.com/pro', 'tcloud-widget', 'wp-editor', 'get-pro' ); |
| 275 | |
| 276 | $this->add_control( |
| 277 | 'tcloud_notice', |
| 278 | array( |
| 279 | 'type' => Controls_Manager::RAW_HTML, |
| 280 | 'raw' => __( 'This option is available in Premium Addons Pro.', 'premium-addons-for-elementor' ) . '<a href="' . esc_url( $get_pro ) . '" target="_blank">' . __( 'Upgrade now!', 'premium-addons-for-elementor' ) . '</a>', |
| 281 | 'content_classes' => 'papro-upgrade-notice', |
| 282 | 'condition' => array( |
| 283 | 'words_order' => $options['order_condition'], |
| 284 | ), |
| 285 | ) |
| 286 | ); |
| 287 | |
| 288 | } else { |
| 289 | do_action( 'pa_tcloud_shape_controls', $this ); |
| 290 | } |
| 291 | |
| 292 | $this->add_control( |
| 293 | 'new_tab', |
| 294 | array( |
| 295 | 'label' => __( 'Open Links in New Tab', 'premium-addons-for-elementor' ), |
| 296 | 'type' => Controls_Manager::SWITCHER, |
| 297 | 'default' => 'yes', |
| 298 | 'frontend_available' => true, |
| 299 | 'condition' => array( |
| 300 | 'words_order!' => $options['order_condition'], |
| 301 | ), |
| 302 | ) |
| 303 | ); |
| 304 | |
| 305 | $this->add_control( |
| 306 | 'colors_select', |
| 307 | array( |
| 308 | 'label' => __( 'Words Colors', 'premium-addons-for-elementor' ), |
| 309 | 'type' => Controls_Manager::SELECT, |
| 310 | 'options' => array( |
| 311 | 'random-light' => __( 'Random Light', 'premium-addons-for-elementor' ), |
| 312 | 'random-dark' => __( 'Random Dark', 'premium-addons-for-elementor' ), |
| 313 | 'custom' => __( 'Custom', 'premium-addons-for-elementor' ), |
| 314 | ), |
| 315 | 'default' => 'random-light', |
| 316 | 'frontend_available' => true, |
| 317 | 'condition' => array( |
| 318 | 'words_order!' => $options['order_condition'], |
| 319 | ), |
| 320 | ) |
| 321 | ); |
| 322 | |
| 323 | $this->add_control( |
| 324 | 'words_colors', |
| 325 | array( |
| 326 | 'label' => __( 'Colors to Select From', 'premium-addons-for-elementor' ), |
| 327 | 'type' => Controls_Manager::TEXTAREA, |
| 328 | 'description' => __( 'Add the colors you want to select from. Each color in a separate line. You can use this ', 'premium-addons-for-elementor' ) . '<a href="https://www.w3schools.com/colors/colors_names.asp" target="_blank">link</a>' . __( ' to get colors.', 'premium-addons-for-elementor' ), |
| 329 | |
| 330 | 'label_block' => true, |
| 331 | 'frontend_available' => true, |
| 332 | 'condition' => array( |
| 333 | 'words_order!' => $options['order_condition'], |
| 334 | 'colors_select' => 'custom', |
| 335 | ), |
| 336 | 'ai' => array( |
| 337 | 'active' => false, |
| 338 | ), |
| 339 | ) |
| 340 | ); |
| 341 | |
| 342 | if ( $papro_activated ) { |
| 343 | do_action( 'pa_tcloud_sphere_controls', $this ); |
| 344 | } |
| 345 | |
| 346 | $this->add_responsive_control( |
| 347 | 'direction', |
| 348 | array( |
| 349 | 'label' => __( 'Direction', 'premium-addons-for-elementor' ), |
| 350 | 'type' => Controls_Manager::CHOOSE, |
| 351 | 'options' => array( |
| 352 | 'row' => array( |
| 353 | 'title' => __( 'Row', 'premium-addons-for-elementor' ), |
| 354 | 'icon' => 'eicon-arrow-right', |
| 355 | ), |
| 356 | 'column' => array( |
| 357 | 'title' => __( 'Column', 'premium-addons-for-elementor' ), |
| 358 | 'icon' => 'eicon-arrow-down', |
| 359 | ), |
| 360 | ), |
| 361 | 'default' => 'row', |
| 362 | 'toggle' => false, |
| 363 | 'prefix_class' => 'premium-tcloud__', |
| 364 | 'selectors' => array( |
| 365 | '{{WRAPPER}} .premium-tcloud-canvas-container' => 'flex-direction: {{VALUE}};', |
| 366 | ), |
| 367 | 'condition' => array( |
| 368 | 'words_order!' => $options['order_condition'], |
| 369 | ), |
| 370 | ) |
| 371 | ); |
| 372 | |
| 373 | $this->add_responsive_control( |
| 374 | 'align', |
| 375 | array( |
| 376 | 'label' => __( 'Alignment', 'premium-addons-for-elementor' ), |
| 377 | 'type' => Controls_Manager::CHOOSE, |
| 378 | 'options' => array( |
| 379 | 'flex-start' => array( |
| 380 | 'title' => __( 'Start', 'premium-addons-for-elementor' ), |
| 381 | 'icon' => is_rtl() ? 'eicon-text-align-right' : 'eicon-text-align-left', |
| 382 | ), |
| 383 | 'center' => array( |
| 384 | 'title' => __( 'Center', 'premium-addons-for-elementor' ), |
| 385 | 'icon' => 'eicon-text-align-justify', |
| 386 | ), |
| 387 | 'flex-end' => array( |
| 388 | 'title' => __( 'End', 'premium-addons-for-elementor' ), |
| 389 | 'icon' => is_rtl() ? 'eicon-text-align-left' : 'eicon-text-align-right', |
| 390 | ), |
| 391 | ), |
| 392 | 'default' => 'flex-start', |
| 393 | 'toggle' => false, |
| 394 | 'selectors' => array( |
| 395 | '{{WRAPPER}}.premium-tcloud__row .premium-tcloud-canvas-container' => 'justify-content: {{VALUE}};', |
| 396 | '{{WRAPPER}}.premium-tcloud__column .premium-tcloud-canvas-container' => 'align-items: {{VALUE}};', |
| 397 | ), |
| 398 | 'condition' => array( |
| 399 | 'words_order!' => $options['order_condition'], |
| 400 | ), |
| 401 | ) |
| 402 | ); |
| 403 | |
| 404 | $this->end_controls_section(); |
| 405 | |
| 406 | $this->start_controls_section( |
| 407 | 'query_section', |
| 408 | array( |
| 409 | 'label' => __( 'Query', 'premium-addons-for-elementor' ), |
| 410 | 'condition' => array( |
| 411 | 'words_order!' => $options['order_condition'], |
| 412 | ), |
| 413 | ) |
| 414 | ); |
| 415 | |
| 416 | $post_types = Blog_Helper::get_posts_types(); |
| 417 | |
| 418 | foreach ( $post_types as $id => $label ) { |
| 419 | |
| 420 | if ( 'post' !== $id ) { |
| 421 | $post_types[ $id ] .= apply_filters( 'pa_pro_label', __( ' (Pro)', 'premium-addons-for-elementor' ) ); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | $this->add_control( |
| 426 | 'post_type_filter', |
| 427 | array( |
| 428 | 'label' => __( 'Post Type', 'premium-addons-for-elementor' ), |
| 429 | 'type' => Controls_Manager::SELECT, |
| 430 | 'label_block' => true, |
| 431 | 'options' => $post_types, |
| 432 | 'default' => 'post', |
| 433 | ) |
| 434 | ); |
| 435 | |
| 436 | $this->add_control( |
| 437 | 'filter_tabs_type', |
| 438 | array( |
| 439 | 'label' => __( 'Source', 'premium-addons-for-elementor' ), |
| 440 | 'type' => Premium_Tax_Filter::TYPE, |
| 441 | 'default' => 'category', |
| 442 | 'condition' => $options['source_condition'], |
| 443 | ) |
| 444 | ); |
| 445 | |
| 446 | $this->add_control( |
| 447 | 'no_tax_notice', |
| 448 | array( |
| 449 | 'raw' => __( 'This post type has no taxonomies to show.', 'premium-addons-for-elementor' ), |
| 450 | 'type' => Controls_Manager::RAW_HTML, |
| 451 | 'classes' => 'premium-live-temp-title control-hidden', |
| 452 | 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', |
| 453 | 'condition' => $options['source_condition'], |
| 454 | ) |
| 455 | ); |
| 456 | |
| 457 | $this->add_control( |
| 458 | 'get_from_current', |
| 459 | array( |
| 460 | 'label' => __( 'Get from Current Page', 'premium-addons-for-elementor' ), |
| 461 | 'type' => Controls_Manager::SWITCHER, |
| 462 | 'description' => __( 'Use this to get the terms of the current page. Useful when building a Single Post/Product template.', 'premium-addons-for-elementor' ), |
| 463 | 'condition' => $options['source_condition'], |
| 464 | ) |
| 465 | ); |
| 466 | |
| 467 | $this->add_control( |
| 468 | 'show_parents_only', |
| 469 | array( |
| 470 | 'label' => __( 'Show Parent Terms Only', 'premium-addons-for-elementor' ), |
| 471 | 'type' => Controls_Manager::SWITCHER, |
| 472 | 'condition' => $options['source_condition'], |
| 473 | ) |
| 474 | ); |
| 475 | |
| 476 | $this->add_control( |
| 477 | 'terms_number', |
| 478 | array( |
| 479 | 'label' => __( 'Number of Terms to Show', 'premium-addons-for-elementor' ), |
| 480 | 'type' => Controls_Manager::NUMBER, |
| 481 | 'condition' => $options['source_condition'], |
| 482 | ) |
| 483 | ); |
| 484 | |
| 485 | $this->add_control( |
| 486 | 'order_by', |
| 487 | array( |
| 488 | 'label' => __( 'Order By', 'premium-addons-for-elementor' ), |
| 489 | 'type' => Controls_Manager::SELECT, |
| 490 | 'separator' => 'before', |
| 491 | 'label_block' => true, |
| 492 | 'options' => array( |
| 493 | 'none' => __( 'None', 'premium-addons-for-elementor' ), |
| 494 | 'name' => __( 'Name Alphabetically', 'premium-addons-for-elementor' ), |
| 495 | 'slug' => __( 'Slug Alphabetically', 'premium-addons-for-elementor' ), |
| 496 | 'description' => __( 'Description Alphabetically', 'premium-addons-for-elementor' ), |
| 497 | 'ID' => __( 'Term ID', 'premium-addons-for-elementor' ), |
| 498 | 'count' => __( 'Posts Number', 'premium-addons-for-elementor' ), |
| 499 | ), |
| 500 | 'default' => 'none', |
| 501 | 'condition' => $options['source_condition'], |
| 502 | ) |
| 503 | ); |
| 504 | |
| 505 | $this->add_control( |
| 506 | 'order', |
| 507 | array( |
| 508 | 'label' => __( 'Order', 'premium-addons-for-elementor' ), |
| 509 | 'type' => Controls_Manager::SELECT, |
| 510 | 'label_block' => true, |
| 511 | 'options' => array( |
| 512 | 'ASC' => __( 'Ascending', 'premium-addons-for-elementor' ), |
| 513 | 'DESC' => __( 'Descending', 'premium-addons-for-elementor' ), |
| 514 | ), |
| 515 | 'default' => 'ASC', |
| 516 | 'condition' => $options['source_condition'], |
| 517 | ) |
| 518 | ); |
| 519 | |
| 520 | $this->end_controls_section(); |
| 521 | |
| 522 | $this->start_controls_section( |
| 523 | 'section_pa_docs', |
| 524 | array( |
| 525 | 'label' => __( 'Help & Docs', 'premium-addons-for-elementor' ), |
| 526 | ) |
| 527 | ); |
| 528 | |
| 529 | $docs = array( |
| 530 | 'https://premiumaddons.com/docs/elementor-tags-cloud-widget/' => __( 'Getting started »', 'premium-addons-for-elementor' ), |
| 531 | ); |
| 532 | |
| 533 | $doc_index = 1; |
| 534 | foreach ( $docs as $url => $title ) { |
| 535 | |
| 536 | $doc_url = Helper_Functions::get_campaign_link( $url, 'tcloud-widget', 'wp-editor', 'get-support' ); |
| 537 | |
| 538 | $this->add_control( |
| 539 | 'doc_' . $doc_index, |
| 540 | array( |
| 541 | 'type' => Controls_Manager::RAW_HTML, |
| 542 | 'raw' => sprintf( '<a href="%s" target="_blank">%s</a>', $doc_url, $title ), |
| 543 | 'content_classes' => 'editor-pa-doc', |
| 544 | ) |
| 545 | ); |
| 546 | |
| 547 | ++$doc_index; |
| 548 | |
| 549 | } |
| 550 | |
| 551 | Helper_Functions::register_element_feedback_controls( $this ); |
| 552 | |
| 553 | $this->end_controls_section(); |
| 554 | |
| 555 | $this->start_controls_section( |
| 556 | 'term_style', |
| 557 | array( |
| 558 | 'label' => __( 'Term', 'premium-addons-for-elementor' ), |
| 559 | 'tab' => Controls_Manager::TAB_STYLE, |
| 560 | 'condition' => array( |
| 561 | 'words_order' => array( 'default', 'ribbon' ), |
| 562 | ), |
| 563 | ) |
| 564 | ); |
| 565 | |
| 566 | $this->add_group_control( |
| 567 | Group_Control_Typography::get_type(), |
| 568 | array( |
| 569 | 'name' => 'term_typo', |
| 570 | 'selector' => '{{WRAPPER}} .premium-tcloud-term-link', |
| 571 | ) |
| 572 | ); |
| 573 | |
| 574 | $this->add_control( |
| 575 | 'fsize_scale', |
| 576 | array( |
| 577 | 'label' => __( 'Font Size Scale (px)', 'premium-addons-for-elementor' ), |
| 578 | 'type' => Controls_Manager::SLIDER, |
| 579 | 'description' => __( 'This option is used to increase the font size of each term based on the number of posts in it.', 'premium-addons-for-elementor' ), |
| 580 | 'range' => array( |
| 581 | 'px' => array( |
| 582 | 'min' => 0, |
| 583 | 'max' => 5, |
| 584 | 'step' => 0.1, |
| 585 | ), |
| 586 | ), |
| 587 | 'default' => array( |
| 588 | 'size' => 0, |
| 589 | ), |
| 590 | 'frontend_available' => true, |
| 591 | ) |
| 592 | ); |
| 593 | |
| 594 | $this->start_controls_tabs( 'term_style_tabs' ); |
| 595 | |
| 596 | $this->start_controls_tab( |
| 597 | 'term_style_normal', |
| 598 | array( |
| 599 | 'label' => __( 'Normal', 'premium-addons-for-elementor' ), |
| 600 | ) |
| 601 | ); |
| 602 | |
| 603 | $this->add_control( |
| 604 | 'term_color', |
| 605 | array( |
| 606 | 'label' => __( 'Text Color', 'premium-addons-for-elementor' ), |
| 607 | 'type' => Controls_Manager::COLOR, |
| 608 | 'selectors' => array( |
| 609 | '{{WRAPPER}} .premium-tcloud-term-link' => 'color: {{VALUE}}', |
| 610 | ), |
| 611 | ) |
| 612 | ); |
| 613 | |
| 614 | $this->add_control( |
| 615 | 'circle_color', |
| 616 | array( |
| 617 | 'label' => __( 'Circle Color', 'premium-addons-for-elementor' ), |
| 618 | 'type' => Controls_Manager::COLOR, |
| 619 | 'selectors' => array( |
| 620 | '{{WRAPPER}} .premium-tcloud-term::after' => 'background-color: {{VALUE}}', |
| 621 | ), |
| 622 | 'condition' => array( |
| 623 | 'words_order' => 'ribbon', |
| 624 | ), |
| 625 | ) |
| 626 | ); |
| 627 | |
| 628 | $this->add_control( |
| 629 | 'term_background_color', |
| 630 | array( |
| 631 | 'label' => __( 'Background Color', 'premium-addons-for-elementor' ), |
| 632 | 'type' => Controls_Manager::COLOR, |
| 633 | 'selectors' => array( |
| 634 | '{{WRAPPER}} .premium-tcloud-term' => 'background-color: {{VALUE}} !important', |
| 635 | '{{WRAPPER}} .premium-tcloud-ribbon .premium-tcloud-term::before' => 'border-right-color: {{VALUE}} !important', |
| 636 | ), |
| 637 | ) |
| 638 | ); |
| 639 | |
| 640 | $this->add_control( |
| 641 | 'term_lq_effect', |
| 642 | array( |
| 643 | 'label' => __( 'Liquid Glass Effect', 'premium-addons-for-elementor' ), |
| 644 | 'type' => Controls_Manager::SELECT, |
| 645 | 'description' => sprintf( |
| 646 | /* translators: 1: `<a>` opening tag, 2: `</a>` closing tag. */ |
| 647 | esc_html__( 'Important: Make sure this element has a semi-transparent background color to see the effect. See all presets from %1$shere%2$s.', 'premium-addons-for-elementor' ), |
| 648 | '<a href="https://premiumaddons.com/liquid-glass/" target="_blank">', |
| 649 | '</a>' |
| 650 | ), |
| 651 | 'options' => array( |
| 652 | 'none' => __( 'None', 'premium-addons-for-elementor' ), |
| 653 | 'glass1' => __( 'Preset 01', 'premium-addons-for-elementor' ), |
| 654 | 'glass2' => __( 'Preset 02', 'premium-addons-for-elementor' ), |
| 655 | 'glass3' => apply_filters( 'pa_pro_label', __( 'Preset 03 (Pro)', 'premium-addons-for-elementor' ) ), |
| 656 | 'glass4' => apply_filters( 'pa_pro_label', __( 'Preset 04 (Pro)', 'premium-addons-for-elementor' ) ), |
| 657 | 'glass5' => apply_filters( 'pa_pro_label', __( 'Preset 05 (Pro)', 'premium-addons-for-elementor' ) ), |
| 658 | 'glass6' => apply_filters( 'pa_pro_label', __( 'Preset 06 (Pro)', 'premium-addons-for-elementor' ) ), |
| 659 | ), |
| 660 | 'default' => 'none', |
| 661 | 'label_block' => true, |
| 662 | 'render_type' => 'template', |
| 663 | ) |
| 664 | ); |
| 665 | |
| 666 | $this->add_group_control( |
| 667 | Group_Control_Border::get_type(), |
| 668 | array( |
| 669 | 'name' => 'term_border', |
| 670 | 'selector' => '{{WRAPPER}} .premium-tcloud-term', |
| 671 | 'condition' => array( |
| 672 | 'words_order' => 'default', |
| 673 | ), |
| 674 | ) |
| 675 | ); |
| 676 | |
| 677 | $this->add_control( |
| 678 | 'term_border_radius', |
| 679 | array( |
| 680 | 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ), |
| 681 | 'type' => Controls_Manager::SLIDER, |
| 682 | 'size_units' => array( 'px', 'em', '%' ), |
| 683 | 'selectors' => array( |
| 684 | '{{WRAPPER}} .premium-tcloud-term' => 'border-radius: {{SIZE}}{{UNIT}};', |
| 685 | ), |
| 686 | 'condition' => array( |
| 687 | 'words_order' => 'default', |
| 688 | ), |
| 689 | ) |
| 690 | ); |
| 691 | |
| 692 | $this->add_group_control( |
| 693 | Group_Control_Text_Shadow::get_type(), |
| 694 | array( |
| 695 | 'name' => 'term_text_shadow', |
| 696 | 'selector' => '{{WRAPPER}} .premium-tcloud-term', |
| 697 | ) |
| 698 | ); |
| 699 | |
| 700 | $this->add_group_control( |
| 701 | Group_Control_Box_Shadow::get_type(), |
| 702 | array( |
| 703 | 'name' => 'term_shadow', |
| 704 | 'selector' => '{{WRAPPER}} .premium-tcloud-term', |
| 705 | ) |
| 706 | ); |
| 707 | |
| 708 | $this->add_responsive_control( |
| 709 | 'term_spacing', |
| 710 | array( |
| 711 | 'label' => __( 'Margin', 'premium-addons-for-elementor' ), |
| 712 | 'type' => Controls_Manager::DIMENSIONS, |
| 713 | 'size_units' => array( 'px', 'em', '%' ), |
| 714 | 'selectors' => array( |
| 715 | '{{WRAPPER}} .premium-tcloud-term-wrap' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 716 | ), |
| 717 | ) |
| 718 | ); |
| 719 | |
| 720 | $this->add_responsive_control( |
| 721 | 'term_padding', |
| 722 | array( |
| 723 | 'label' => __( 'Padding', 'premium-addons-for-elementor' ), |
| 724 | 'type' => Controls_Manager::DIMENSIONS, |
| 725 | 'size_units' => array( 'px', 'em', '%' ), |
| 726 | 'selectors' => array( |
| 727 | '{{WRAPPER}} .premium-tcloud-term' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 728 | ), |
| 729 | ) |
| 730 | ); |
| 731 | |
| 732 | $this->end_controls_tab(); |
| 733 | |
| 734 | $this->start_controls_tab( |
| 735 | 'term_style_hover', |
| 736 | array( |
| 737 | 'label' => __( 'Hover', 'premium-addons-for-elementor' ), |
| 738 | ) |
| 739 | ); |
| 740 | |
| 741 | $this->add_control( |
| 742 | 'term_hover_color', |
| 743 | array( |
| 744 | 'label' => __( 'Text Color', 'premium-addons-for-elementor' ), |
| 745 | 'type' => Controls_Manager::COLOR, |
| 746 | 'selectors' => array( |
| 747 | '{{WRAPPER}} .premium-tcloud-term:hover .premium-tcloud-term-link' => 'color: {{VALUE}}', |
| 748 | ), |
| 749 | ) |
| 750 | ); |
| 751 | |
| 752 | $this->add_control( |
| 753 | 'circle_hover_color', |
| 754 | array( |
| 755 | 'label' => __( 'Circle Color', 'premium-addons-for-elementor' ), |
| 756 | 'type' => Controls_Manager::COLOR, |
| 757 | 'selectors' => array( |
| 758 | '{{WRAPPER}} .premium-tcloud-term:hover::after' => 'background-color: {{VALUE}}', |
| 759 | ), |
| 760 | 'condition' => array( |
| 761 | 'words_order' => 'ribbon', |
| 762 | ), |
| 763 | ) |
| 764 | ); |
| 765 | |
| 766 | $this->add_control( |
| 767 | 'term_hover_background_color', |
| 768 | array( |
| 769 | 'label' => __( 'Background Color', 'premium-addons-for-elementor' ), |
| 770 | 'type' => Controls_Manager::COLOR, |
| 771 | 'selectors' => array( |
| 772 | '{{WRAPPER}} .premium-tcloud-term:hover' => 'background-color: {{VALUE}} !important', |
| 773 | '{{WRAPPER}} .premium-tcloud-ribbon .premium-tcloud-term:hover::before' => 'border-right-color: {{VALUE}} !important', |
| 774 | ), |
| 775 | ) |
| 776 | ); |
| 777 | |
| 778 | $this->add_group_control( |
| 779 | Group_Control_Border::get_type(), |
| 780 | array( |
| 781 | 'name' => 'term_hover_border', |
| 782 | 'selector' => '{{WRAPPER}} .premium-tcloud-term:hover', |
| 783 | 'condition' => array( |
| 784 | 'words_order' => 'default', |
| 785 | ), |
| 786 | ) |
| 787 | ); |
| 788 | |
| 789 | $this->add_control( |
| 790 | 'term_hover_border_radius', |
| 791 | array( |
| 792 | 'label' => __( 'Border Radius', 'premium-addons-for-elementor' ), |
| 793 | 'type' => Controls_Manager::SLIDER, |
| 794 | 'size_units' => array( 'px', 'em', '%' ), |
| 795 | 'selectors' => array( |
| 796 | '{{WRAPPER}} .premium-tcloud-term:hover' => 'border-radius: {{SIZE}}{{UNIT}};', |
| 797 | ), |
| 798 | 'condition' => array( |
| 799 | 'words_order' => 'default', |
| 800 | ), |
| 801 | ) |
| 802 | ); |
| 803 | |
| 804 | $this->add_group_control( |
| 805 | Group_Control_Text_Shadow::get_type(), |
| 806 | array( |
| 807 | 'name' => 'term_hover_text_shadow', |
| 808 | 'selector' => '{{WRAPPER}} .premium-tcloud-term:hover', |
| 809 | ) |
| 810 | ); |
| 811 | |
| 812 | $this->add_group_control( |
| 813 | Group_Control_Box_Shadow::get_type(), |
| 814 | array( |
| 815 | 'name' => 'term_hover_shadow', |
| 816 | 'selector' => '{{WRAPPER}} .premium-tcloud-term:hover', |
| 817 | ) |
| 818 | ); |
| 819 | |
| 820 | $this->add_responsive_control( |
| 821 | 'term_hover_spacing', |
| 822 | array( |
| 823 | 'label' => __( 'Margin', 'premium-addons-for-elementor' ), |
| 824 | 'type' => Controls_Manager::DIMENSIONS, |
| 825 | 'size_units' => array( 'px', 'em', '%' ), |
| 826 | 'selectors' => array( |
| 827 | '{{WRAPPER}} .premium-tcloud-term-wrap:hover' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 828 | ), |
| 829 | ) |
| 830 | ); |
| 831 | |
| 832 | $this->add_responsive_control( |
| 833 | 'term_hover_padding', |
| 834 | array( |
| 835 | 'label' => __( 'Padding', 'premium-addons-for-elementor' ), |
| 836 | 'type' => Controls_Manager::DIMENSIONS, |
| 837 | 'size_units' => array( 'px', 'em', '%' ), |
| 838 | 'selectors' => array( |
| 839 | '{{WRAPPER}} .premium-tcloud-term:hover' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 840 | ), |
| 841 | ) |
| 842 | ); |
| 843 | |
| 844 | $this->end_controls_tab(); |
| 845 | |
| 846 | $this->end_controls_tabs(); |
| 847 | |
| 848 | $this->end_controls_section(); |
| 849 | } |
| 850 | |
| 851 | /** |
| 852 | * Render Image Separator widget output on the frontend. |
| 853 | * |
| 854 | * Written in PHP and used to generate the final HTML. |
| 855 | * |
| 856 | * @since 1.0.0 |
| 857 | * @access protected |
| 858 | */ |
| 859 | protected function render() { |
| 860 | |
| 861 | $settings = $this->get_settings_for_display(); |
| 862 | |
| 863 | $papro_activated = Helper_Functions::check_papro_version(); |
| 864 | |
| 865 | if ( ! $papro_activated && ( 'shape' === $settings['words_order'] || 'post' !== $settings['post_type_filter'] ) ) { |
| 866 | return; |
| 867 | } |
| 868 | |
| 869 | $tax = $settings['filter_tabs_type']; |
| 870 | |
| 871 | $id = $this->get_id(); |
| 872 | |
| 873 | $terms = $this->get_taxs( $tax ); |
| 874 | |
| 875 | $words_array = array(); |
| 876 | |
| 877 | foreach ( $terms as $index => $term ) { |
| 878 | |
| 879 | $term_id = $term->term_id; |
| 880 | |
| 881 | $name = $term->name; |
| 882 | |
| 883 | $full_name = $name; |
| 884 | |
| 885 | if ( ! empty( $settings['words_remove'] ) ) { |
| 886 | |
| 887 | $words_to_remove = explode( ',', $settings['words_remove'] ); |
| 888 | |
| 889 | $cleaned_string = str_ireplace( $words_to_remove, '', $name ); |
| 890 | |
| 891 | $name = $cleaned_string; |
| 892 | |
| 893 | } |
| 894 | |
| 895 | $should_suffix = false; |
| 896 | if ( ! empty( $settings['words_number'] ) ) { |
| 897 | |
| 898 | $name_array = explode( ' ', $term->name ); |
| 899 | |
| 900 | if ( count( $name_array ) > 1 && count( $name_array ) > $settings['words_number'] ) { |
| 901 | |
| 902 | $should_suffix = true; |
| 903 | |
| 904 | $new_name = ''; |
| 905 | |
| 906 | for ( $i = 0; $i < $settings['words_number']; $i++ ) { |
| 907 | |
| 908 | if ( $i < $settings['words_number'] - 2 ) { |
| 909 | $new_name .= $name_array[ $i ] . ' '; |
| 910 | } else { |
| 911 | $new_name .= $name_array[ $i ]; |
| 912 | } |
| 913 | } |
| 914 | |
| 915 | $name = $new_name; |
| 916 | |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | if ( ! empty( $settings['suffix_word'] ) && $should_suffix ) { |
| 921 | $name .= $settings['suffix_word']; |
| 922 | } |
| 923 | |
| 924 | if ( in_array( $settings['words_order'], array( 'shape', 'sphere' ), true ) && '' !== $settings['text_transform'] ) { |
| 925 | |
| 926 | switch ( $settings['text_transform'] ) { |
| 927 | |
| 928 | case 'uppercase': |
| 929 | $name = strtoupper( $name ); |
| 930 | break; |
| 931 | |
| 932 | case 'lowercase': |
| 933 | $name = strtolower( $name ); |
| 934 | break; |
| 935 | |
| 936 | case 'capitalize': |
| 937 | $name = ucwords( $name ); |
| 938 | break; |
| 939 | |
| 940 | } |
| 941 | } |
| 942 | |
| 943 | if ( 'yes' === $settings['get_from_current'] ) { |
| 944 | $term->count = 1; |
| 945 | } |
| 946 | |
| 947 | $child_terms_count = 'yes' === $settings['show_parents_only'] ? $this->get_child_terms_count( $tax, $term_id ) : 0; |
| 948 | |
| 949 | $words_array[] = array( |
| 950 | $name, |
| 951 | $term->count + $child_terms_count, |
| 952 | get_term_link( $term_id, $tax ), |
| 953 | $full_name, |
| 954 | $term->count + $child_terms_count, |
| 955 | ); |
| 956 | |
| 957 | } |
| 958 | |
| 959 | $chart_settings = array( |
| 960 | 'wordsArr' => $words_array, |
| 961 | ); |
| 962 | |
| 963 | $this->add_render_attribute( |
| 964 | 'container', |
| 965 | array( |
| 966 | 'class' => array( |
| 967 | 'premium-tcloud-container', |
| 968 | 'premium-tcloud-' . $settings['words_order'], |
| 969 | ), |
| 970 | 'data-chart' => wp_json_encode( $chart_settings ), |
| 971 | ) |
| 972 | ); |
| 973 | |
| 974 | if ( in_array( $settings['words_order'], array( 'shape', 'sphere' ), true ) ) { |
| 975 | |
| 976 | $this->add_render_attribute( 'container', 'class', 'premium-tcloud-hidden' ); |
| 977 | |
| 978 | $this->add_render_attribute( |
| 979 | 'canvas', |
| 980 | array( |
| 981 | 'id' => 'premium-tcloud-canvas-' . $id, |
| 982 | 'class' => 'premium-tcloud-canvas', |
| 983 | 'width' => 1170, |
| 984 | 'height' => 760, |
| 985 | ) |
| 986 | ); |
| 987 | } |
| 988 | |
| 989 | $target = 'yes' === $settings['new_tab'] ? '_blank' : '_top'; |
| 990 | |
| 991 | if ( 'shape' !== $settings['words_order'] ) { |
| 992 | $this->add_render_attribute( 'term', 'class', 'premium-tcloud-term' ); |
| 993 | |
| 994 | if ( 'none' !== $settings['term_lq_effect'] ) { |
| 995 | $this->add_render_attribute( 'term', 'class', 'premium-con-lq__' . $settings['term_lq_effect'] ); |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | ?> |
| 1000 | |
| 1001 | <div <?php $this->print_render_attribute_string( 'container' ); ?>> |
| 1002 | |
| 1003 | <div class="premium-tcloud-canvas-container"> |
| 1004 | |
| 1005 | <?php if ( in_array( $settings['words_order'], array( 'shape', 'sphere' ), true ) ) : ?> |
| 1006 | <span class="font-loader"></span> |
| 1007 | <canvas <?php $this->print_render_attribute_string( 'canvas' ); ?>> |
| 1008 | </canvas> |
| 1009 | <?php endif; ?> |
| 1010 | |
| 1011 | |
| 1012 | <?php if ( 'shape' !== $settings['words_order'] ) : ?> |
| 1013 | |
| 1014 | <?php if ( 'sphere' === $settings['words_order'] ) : ?> |
| 1015 | <div id="<?php echo esc_attr( 'premium-tcloud-terms-container-' . $id ); ?>" class="premium-tcloud-terms-container"> |
| 1016 | <?php endif; ?> |
| 1017 | |
| 1018 | <?php foreach ( $words_array as $index => $word ) : ?> |
| 1019 | |
| 1020 | <?php if ( '' !== $word[0] ) : ?> |
| 1021 | |
| 1022 | <div class="premium-tcloud-term-wrap"> |
| 1023 | |
| 1024 | <span <?php $this->print_render_attribute_string( 'term' ); ?>> |
| 1025 | <a class="premium-tcloud-term-link" data-weight="<?php echo esc_attr( $word[1] ); ?>" href="<?php echo esc_url( $word[2] ); ?>" title="<?php echo esc_attr( $word[3] ); ?>" target="<?php echo esc_attr( $target ); ?>"><?php echo wp_kses_post( $word[0] ); ?><?php if ( in_array( $settings['words_order'], array( 'default', 'ribbon' ), true ) && 'yes' === $settings['show_posts_number'] ) : ?> |
| 1026 | <span class="premium-tcloud-number">(<?php echo wp_kses_post( $word[4] ); ?>)</span><?php endif; ?></a> |
| 1027 | </span> |
| 1028 | </div> |
| 1029 | <?php endif; ?> |
| 1030 | <?php endforeach; ?> |
| 1031 | |
| 1032 | <?php if ( 'sphere' === $settings['words_order'] ) : ?> |
| 1033 | </div> |
| 1034 | <?php endif; ?> |
| 1035 | <?php endif; ?> |
| 1036 | |
| 1037 | </div> |
| 1038 | |
| 1039 | </div> |
| 1040 | |
| 1041 | <?php |
| 1042 | } |
| 1043 | |
| 1044 | /** |
| 1045 | * Get Taxs |
| 1046 | * |
| 1047 | * Used to get terms. |
| 1048 | * |
| 1049 | * @access private |
| 1050 | * |
| 1051 | * @return object $taxs taxonomies. |
| 1052 | */ |
| 1053 | private function get_taxs( $term ) { |
| 1054 | |
| 1055 | $settings = $this->get_settings_for_display(); |
| 1056 | |
| 1057 | $args = array( |
| 1058 | 'number' => $settings['terms_number'], |
| 1059 | 'orderby' => $settings['order_by'], |
| 1060 | 'order' => $settings['order'], |
| 1061 | ); |
| 1062 | |
| 1063 | if ( 'yes' === $settings['show_parents_only'] ) { |
| 1064 | $args = array_merge( |
| 1065 | $args, |
| 1066 | array( |
| 1067 | 'parent' => 0, |
| 1068 | ) |
| 1069 | ); |
| 1070 | } |
| 1071 | |
| 1072 | // Get the terms based on filter source. |
| 1073 | if ( 'yes' === $settings['get_from_current'] ) { |
| 1074 | $taxs = wp_get_post_terms( get_the_ID(), $term, $args ); |
| 1075 | } else { |
| 1076 | |
| 1077 | $args = array_merge( |
| 1078 | $args, |
| 1079 | array( |
| 1080 | 'taxonomy' => $term, |
| 1081 | ) |
| 1082 | ); |
| 1083 | |
| 1084 | $taxs = get_terms( $args ); |
| 1085 | } |
| 1086 | |
| 1087 | if ( is_wp_error( $taxs ) ) { |
| 1088 | return array(); |
| 1089 | } |
| 1090 | |
| 1091 | return $taxs; |
| 1092 | } |
| 1093 | |
| 1094 | /** |
| 1095 | * Get Child Terms Count |
| 1096 | * |
| 1097 | * Used to get child terms count. |
| 1098 | * |
| 1099 | * @access private |
| 1100 | * |
| 1101 | * @return int $child_posts_count child terms count. |
| 1102 | */ |
| 1103 | private function get_child_terms_count( $tax, $id ) { |
| 1104 | |
| 1105 | $term_children = get_terms( |
| 1106 | array( |
| 1107 | 'taxonomy' => $tax, |
| 1108 | 'parent' => $id, |
| 1109 | 'hide_empty' => true, |
| 1110 | 'fields' => 'ids', |
| 1111 | ) |
| 1112 | ); |
| 1113 | |
| 1114 | if ( empty( $term_children ) ) { |
| 1115 | return 0; |
| 1116 | } |
| 1117 | |
| 1118 | $child_posts_count = 0; |
| 1119 | |
| 1120 | foreach ( $term_children as $child_id ) { |
| 1121 | |
| 1122 | $term = get_term( $child_id, $tax ); |
| 1123 | |
| 1124 | if ( $term && ! is_wp_error( $term ) ) { |
| 1125 | |
| 1126 | $child_posts_count += $term->count; |
| 1127 | |
| 1128 | } |
| 1129 | } |
| 1130 | |
| 1131 | return $child_posts_count; |
| 1132 | } |
| 1133 | } |
| 1134 |