PluginProbe
TablePress – Tables in WordPress made easy / 3.2
TablePress – Tables in WordPress made easy v3.2
3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 2.4.4 All 44 releases
← All changes | classes/class-view.php +15 -87 trunk3.2 View file →
@@ -43,8 +43,15 @@
43 43 */
44 44 protected string $action = '';
45 45
46 46 /**
47 + * Instance of the Admin Page Helper Class, with necessary functions.
48 + *
49 + * @since 1.0.0
50 + */
51 + protected \TablePress_Admin_Page $admin_page;
52 +
53 + /**
47 54 * List of text boxes (similar to post boxes, but just with text and without extra functionality).
48 55 *
49 56 * @since 1.0.0
50 57 * @var array<string, array<string, array<string, mixed>>>
@@ -96,9 +103,9 @@
96 103 $common_content .= sprintf( __( 'Common questions are answered in the <a href="%s">FAQ</a>.', 'tablepress' ), 'https://tablepress.org/faq/' ) . '</p>';
97 104
98 105 if ( tb_tp_fs()->is_free_plan() ) {
99 106 $common_content .= '<p>'
100 - . sprintf( __( '<a href="%1$s">Support</a> is provided through the <a href="%2$s">WordPress Support Forums</a>.', 'tablepress' ), 'https://tablepress.org/support/', 'https://wordpress.org/support/plugin/tablepress' )
107 + . sprintf( __( '<a href="%1$s">Support</a> is provided through the <a href="%2$s">WordPress Support Forums</a>.', 'tablepress' ), 'https://tablepress.org/support/', 'https://wordpress.org/tags/tablepress' )
101 108 . ' '
102 109 . sprintf( __( 'Before asking for support, please carefully read the <a href="%s">Frequently Asked Questions</a>, where you will find answers to the most common questions, and search through the forums.', 'tablepress' ), 'https://tablepress.org/faq/' )
103 110 . '</p>';
104 111 $common_content .= '<p><strong>' . sprintf( __( 'More great features for you and your site’s visitors and priority email support are available with a Premium license plan of TablePress. <a href="%s">Go check them out!</a>', 'tablepress' ), 'https://tablepress.org/premium/?utm_source=plugin&utm_medium=textlink&utm_content=help-tab' ) . '</strong></p>';
@@ -154,16 +161,19 @@
154 161
155 162 // Set page title.
156 163 $GLOBALS['title'] = sprintf( __( '%1$s &lsaquo; %2$s', 'tablepress' ), $this->data['view_actions'][ $this->action ]['page_title'], 'TablePress' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
157 164
158 - add_filter( 'admin_footer_text', array( $this, 'add_admin_footer_text' ) );
159 -
160 - TablePress::enqueue_style( 'common', array( 'wp-components' ) );
165 + // Admin page helpers, like script/style loading, could be moved to view.
166 + $this->admin_page = TablePress::load_class( 'TablePress_Admin_Page', 'class-admin-page-helper.php', 'classes' );
167 + $this->admin_page->enqueue_style( 'common', array( 'wp-components' ) );
161 168 // RTL styles for the admin interface.
162 169 if ( is_rtl() ) {
163 - TablePress::enqueue_style( 'common-rtl', array( 'tablepress-common' ) );
170 + $this->admin_page->enqueue_style( 'common-rtl', array( 'tablepress-common' ) );
164 171 }
172 + $this->admin_page->enqueue_script( 'common', array( 'jquery-core', 'postbox' ) );
165 173
174 + $this->admin_page->add_admin_footer_text();
175 +
166 176 // Initialize WP feature pointers for TablePress.
167 177 $this->_init_wp_pointers();
168 178
169 179 // Necessary fields for all views.
@@ -533,34 +543,8 @@
533 543 return '';
534 544 }
535 545
536 546 /**
537 - * Adds a TablePress "Thank You" message to the admin footer content.
538 - *
539 - * @since 1.0.0
540 - * @since 3.3.0 This method was moved from the now-removed `TablePress_Admin_Page` class.
541 - *
542 - * @param string $content Current admin footer content.
543 - * @return string New admin footer content.
544 - */
545 - public function add_admin_footer_text( /* string */ $content ): string {
546 - // Don't use a type hint in the method declaration as many WordPress plugins use the `admin_footer_text` filter without returning a string.
547 -
548 - // Protect against other plugins not returning a string in their filter callbacks.
549 - if ( ! is_string( $content ) ) { // @phpstan-ignore function.alreadyNarrowedType (The `is_string()` check is needed as the input is coming from a filter hook.)
550 - $content = '';
551 - }
552 -
553 - /* translators: %s: URL to TablePress website */
554 - $content .= ' &bull; ' . sprintf( __( 'Thank you for using <a href="%s">TablePress</a>.', 'tablepress' ), 'https://tablepress.org/' );
555 - if ( tb_tp_fs()->is_free_plan() ) {
556 - /* translators: %s: URL to TablePress premium features */
557 - $content .= ' ' . sprintf( __( 'Take a look at the <a href="%s">Premium features</a>!', 'tablepress' ), 'https://tablepress.org/premium/?utm_source=plugin&utm_medium=textlink&utm_content=admin-footer' );
558 - }
559 - return $content;
560 - }
561 -
562 - /**
563 547 * Initializes the WP feature pointers for TablePress.
564 548 *
565 549 * @since 1.0.0
566 550 */
@@ -583,63 +567,7 @@
583 567 if ( $pointers_on_page ) {
584 568 wp_enqueue_style( 'wp-pointer' );
585 569 wp_enqueue_script( 'wp-pointer' );
586 570 }
587 - }
588 -
589 - /**
590 - * Prints the JavaScript code for a WP feature pointer.
591 - *
592 - * @since 1.0.0
593 - * @since 3.3.0 This method was moved from the now-removed `TablePress_Admin_Page` class.
594 - *
595 - * @param string $pointer_id The pointer ID.
596 - * @param string $selector The HTML elements, on which the pointer should be attached.
597 - * @param array<string, mixed> $args Arguments to be passed to the pointer JS (see wp-pointer.js).
598 - */
599 - public function print_wp_pointer_js( string $pointer_id, string $selector, array $args ): void {
600 - if ( empty( $pointer_id ) || empty( $selector ) || empty( $args['content'] ) ) {
601 - return;
602 - }
603 -
604 - $keyboard_shortcut = '';
605 - if ( 'tp33_edit_quick_navigation' === $pointer_id ) {
606 - $keyboard_shortcut = <<<JS
607 - content: options.content.replace( /%metaKey%/g, window?.navigator?.platform?.includes( 'Mac' ) ? wp.i18n._x( '⌘', 'keyboard shortcut modifier key on a Mac keyboard', 'tablepress' ) : wp.i18n._x( 'Ctrl+', 'keyboard shortcut modifier key on a non-Mac keyboard', 'tablepress' ) ),\n
608 - JS;
609 - }
610 -
611 - /*
612 - * Print JS code for the feature pointers, extended with event handling for opened/closed "Screen Options", so that pointers can
613 - * be repositioned. 210 ms is slightly slower than jQuery's "fast" value, to allow all elements to reach their original position.
614 - */
615 - ?>
616 -<script>
617 -( ( $ ) => {
618 - let options = <?php echo wp_json_encode( $args, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?>;
619 - if ( ! options ) {
620 - return;
621 - }
622 -
623 - options = {
624 - ...options,
625 - <?php echo $keyboard_shortcut; ?>
626 - close() {
627 - $.post( ajaxurl, {
628 - pointer: '<?php echo $pointer_id; ?>',
629 - action: 'dismiss-wp-pointer'
630 - } );
631 - $( this ).pointer( { 'disabled': true } );
632 - },
633 - };
634 -
635 - $( () => $( '<?php echo $selector; ?>' ).pointer( options ).pointer( 'open' ) );
636 -
637 - $( document ).on( 'screen:options:open screen:options:close', () => {
638 - setTimeout( () => $( '<?php echo $selector; ?>' ).pointer( 'reposition' ), 210 );
639 - } );
640 -} )( jQuery );
641 -</script>
642 - <?php
643 571 }
644 572
645 573 } // class TablePress_View