← All changes
|
includes/endpoints/class-charitable-endpoints.php
+44
-18
1.7.0.9
→
1.8.13
View file →
| @@ -3,12 +3,12 @@ | ||
| 3 | 3 | * The endpoint registry class, providing a clean way to access details about individual endpoints. |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Endpoints |
| 6 | 6 | * @author David Bisset |
| 7 | - * @copyright Copyright (c) 2022, WP Charitable LLC | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.5.0 |
| 10 | - * @version 1.6.56 | |
| 10 | + * @version 1.8.9.1 | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -91,8 +91,9 @@ | ||
| 91 | 91 | |
| 92 | 92 | if ( $this->endpoint_exists( $endpoint_id ) ) { |
| 93 | 93 | charitable_get_deprecated()->doing_it_wrong( |
| 94 | 94 | __METHOD__, |
| 95 | + /* translators: %s: endpoint id */ | |
| 95 | 96 | sprintf( __( 'Endpoint %s has already been registered.', 'charitable' ), $endpoint_id ), |
| 96 | 97 | '1.5.0' |
| 97 | 98 | ); |
| 98 | 99 | |
| @@ -193,9 +194,10 @@ | ||
| 193 | 194 | charitable_get_deprecated()->doing_it_wrong( |
| 194 | 195 | __METHOD__, |
| 195 | 196 | sprintf( |
| 196 | 197 | /* translators: %s: endpoint id */ |
| 197 | - __( 'Endpoint %s has not been registered.', 'charitable' ), $endpoint | |
| 198 | + __( 'Endpoint %s has not been registered.', 'charitable' ), | |
| 199 | + $endpoint | |
| 198 | 200 | ), |
| 199 | 201 | '1.5.0' |
| 200 | 202 | ); |
| 201 | 203 | |
| @@ -226,8 +228,9 @@ | ||
| 226 | 228 | if ( $this->get_endpoint( $endpoint_id )->is_cacheable() ) { |
| 227 | 229 | return; |
| 228 | 230 | } |
| 229 | 231 | |
| 232 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound -- DONOTCACHEPAGE is a third-party constant used by caching plugins (WP Super Cache, etc.) for compatibility. | |
| 230 | 233 | define( 'DONOTCACHEPAGE', true ); |
| 231 | 234 | |
| 232 | 235 | /** |
| 233 | 236 | * Fire action to note that the current page should not be cached. |
| @@ -251,9 +254,10 @@ | ||
| 251 | 254 | public function block_404_on_endpoints( $not_a_404 ) { |
| 252 | 255 | if ( false !== $this->get_current_endpoint() ) { |
| 253 | 256 | $not_a_404 = true; |
| 254 | 257 | } else { |
| 255 | - /* Some endpoints will return false at this point since | |
| 258 | + /* | |
| 259 | + Some endpoints will return false at this point since | |
| 256 | 260 | * it's so early, so we unset the class property to make |
| 257 | 261 | * sure they are tested again later on. |
| 258 | 262 | */ |
| 259 | 263 | unset( $this->current_endpoint ); |
| @@ -391,10 +395,12 @@ | ||
| 391 | 395 | * When using a block theme, dynamically generated pages like the donation receipt |
| 392 | 396 | * page are interpreted as using the home template. The following workaround inserts |
| 393 | 397 | * page.php as the primary template for these page. |
| 394 | 398 | * |
| 395 | - * @since since | |
| 399 | + * @param mixed $templates The list of templates. | |
| 396 | 400 | * |
| 401 | + * @since 1.6.55 | |
| 402 | + * | |
| 397 | 403 | * @return mixed |
| 398 | 404 | */ |
| 399 | 405 | public function home_template_hierarchy( $templates ) { |
| 400 | 406 | $current_endpoint = $this->get_current_endpoint(); |
| @@ -493,12 +499,12 @@ | ||
| 493 | 499 | * Add a "Charitable" menus meta box. |
| 494 | 500 | * |
| 495 | 501 | * @since 1.6.29 |
| 496 | 502 | * |
| 497 | - * @param object $object The meta box object | |
| 503 | + * @param object $object The meta box object. | |
| 498 | 504 | * @return object |
| 499 | 505 | */ |
| 500 | - public function add_endpoints_menu_meta_box( $object ) { | |
| 506 | + public function add_endpoints_menu_meta_box( $object ) { // phpcs:ignore | |
| 501 | 507 | add_meta_box( |
| 502 | 508 | 'add-charitable-endpoints', |
| 503 | 509 | __( 'Charitable', 'charitable' ), |
| 504 | 510 | [ $this, 'endpoints_menu_meta_box' ], |
| @@ -530,14 +536,19 @@ | ||
| 530 | 536 | ?> |
| 531 | 537 | <div id="charitable" class="categorydiv"> |
| 532 | 538 | <ul id="charitable-tabs" class="charitable-tabs add-menu-item-tabs"> |
| 533 | 539 | <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
| 534 | - <a class="nav-tab-link" data-type="tabs-panel-charitable-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url( add_query_arg( 'charitable-tab', 'all', remove_query_arg( $removed_args ) ) ); ?>#tabs-panel-charitable-all"> | |
| 535 | - <?php _e( 'View All', 'charitable' ); ?> | |
| 540 | + <a class="nav-tab-link" data-type="tabs-panel-charitable-all" href=" | |
| 541 | + <?php | |
| 542 | + if ( $nav_menu_selected_id ) { | |
| 543 | + echo esc_url( add_query_arg( 'charitable-tab', 'all', remove_query_arg( $removed_args ) ) );} | |
| 544 | + ?> | |
| 545 | + #tabs-panel-charitable-all"> | |
| 546 | + <?php esc_html_e( 'View All', 'charitable' ); ?> | |
| 536 | 547 | </a> |
| 537 | 548 | </li><!-- /.tabs --> |
| 538 | 549 | </ul> |
| 539 | - <div id="tabs-panel-charitable-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"> | |
| 550 | + <div id="tabs-panel-charitable-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>"> | |
| 540 | 551 | <ul id="charitable-checklist-all" class="categorychecklist form-no-clear"> |
| 541 | 552 | <?php |
| 542 | 553 | echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints ), 0, (object) array( 'walker' => $walker ) ); |
| 543 | 554 | ?> |
| @@ -544,9 +555,21 @@ | ||
| 544 | 555 | </ul> |
| 545 | 556 | </div><!-- /.tabs-panel --> |
| 546 | 557 | <p class="button-controls wp-clearfix"> |
| 547 | 558 | <span class="list-controls"> |
| 548 | - <a href="<?php echo esc_url( add_query_arg( array( 'charitable-tab' => 'all', 'selectall' => 1, ), remove_query_arg( $removed_args ) ) ); ?>#charitable" class="select-all"><?php _e( 'Select All', 'charitable' ); ?></a> | |
| 559 | + <a href=" | |
| 560 | + <?php | |
| 561 | + echo esc_url( | |
| 562 | + add_query_arg( | |
| 563 | + array( | |
| 564 | + 'charitable-tab' => 'all', | |
| 565 | + 'selectall' => 1, | |
| 566 | + ), | |
| 567 | + remove_query_arg( $removed_args ) | |
| 568 | + ) | |
| 569 | + ); | |
| 570 | + ?> | |
| 571 | + #charitable" class="select-all"><?php esc_html_e( 'Select All', 'charitable' ); ?></a> | |
| 549 | 572 | </span> |
| 550 | 573 | <span class="add-to-menu"> |
| 551 | 574 | <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu', 'charitable' ); ?>" name="add-charitable-menu-item" id="submit-charitable" /> |
| 552 | 575 | <span class="spinner"></span> |
| @@ -628,8 +651,9 @@ | ||
| 628 | 651 | /** |
| 629 | 652 | * Return the current endpoint. |
| 630 | 653 | * |
| 631 | 654 | * @since 1.5.0 |
| 655 | + * @version 1.8.9.1 | |
| 632 | 656 | * |
| 633 | 657 | * @return string|false String if we're on one of our endpoints. False otherwise. |
| 634 | 658 | */ |
| 635 | 659 | public function get_current_endpoint() { |
| @@ -641,15 +665,17 @@ | ||
| 641 | 665 | foreach ( $endpoint_ids as $endpoint_id ) { |
| 642 | 666 | |
| 643 | 667 | /* Sanity check to ensure the endpoint was properly registered. */ |
| 644 | 668 | if ( ! isset( $this->endpoints[ $endpoint_id ] ) ) { |
| 645 | - error_log( | |
| 646 | - sprintf( | |
| 647 | - /* translators: %s: endpoint id */ | |
| 648 | - __( 'Endpoint %s was incorrectly registered.', 'charitable' ), | |
| 649 | - $endpoint_id | |
| 650 | - ) | |
| 651 | - ); | |
| 669 | + if ( charitable_is_debug() ) { | |
| 670 | + error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log | |
| 671 | + sprintf( | |
| 672 | + /* translators: %s: endpoint id */ | |
| 673 | + __( 'Endpoint %s was incorrectly registered.', 'charitable' ), | |
| 674 | + $endpoint_id | |
| 675 | + ) | |
| 676 | + ); | |
| 677 | + } | |
| 652 | 678 | |
| 653 | 679 | continue; |
| 654 | 680 | } |
| 655 | 681 | |