1 | <?php |
||
14 | class Renderer { |
||
15 | /** |
||
16 | * Initialization. |
||
17 | */ |
||
18 | 102 | public function __construct() { |
|
23 | |||
24 | /** |
||
25 | * Print unconfigured notices to admins. |
||
26 | * Print reserved slug warnings. |
||
27 | * Print entry approval notice. |
||
28 | * |
||
29 | * @param \GV\Template_Context $gravityview The $gravityview template object. |
||
30 | * |
||
31 | * @return void |
||
32 | 35 | */ |
|
33 | 35 | public static function maybe_print_notices( $gravityview = null ) { |
|
46 | 35 | ||
47 | 35 | /** |
|
48 | * Print notice warning admins that "Show only approved" is enabled |
||
49 | * |
||
50 | 35 | * @since 2.9.5 |
|
51 | * |
||
52 | 35 | * @param \GV\Template_Context $gravityview The $gravityview template object. |
|
53 | 35 | * |
|
54 | * @return void |
||
55 | 35 | */ |
|
56 | 35 | private static function maybe_print_entry_approval_notice( $gravityview ) { |
|
57 | |||
58 | if ( $gravityview->entries && $gravityview->entries->count() ) { |
||
59 | return; |
||
60 | 35 | } |
|
61 | |||
62 | if ( $gravityview->request->is_search() ) { |
||
63 | return; |
||
64 | } |
||
65 | |||
66 | // "Show Only Approved" is not enabled. |
||
67 | if ( ! $gravityview->view->settings->get( 'show_only_approved', 0 ) ) { |
||
68 | 35 | return; |
|
69 | } |
||
70 | 35 | ||
71 | // If "Show all entries to administrators" is enabled, approval status isn't the issue. |
||
72 | 35 | if ( $gravityview->view->settings->get( 'admin_show_all_statuses', 0 ) ) { |
|
73 | 1 | return; |
|
74 | } |
||
75 | 1 | ||
76 | 1 | // Don't show when no entries are being displayed due to "Hide View data until search is performed". |
|
77 | 1 | if ( $gravityview->view->settings->get( 'hide_until_searched', 0 ) ) { |
|
78 | return; |
||
79 | 1 | } |
|
80 | |||
81 | 1 | $current_user = wp_get_current_user(); |
|
82 | $user_meta_key = '_gv_dismissed_entry_approval_notice' . $gravityview->view->ID; |
||
|
|||
83 | |||
84 | if ( isset( $_GET['gv-dismiss'] ) && wp_verify_nonce( $_GET['gv-dismiss'], 'dismiss' ) ) { |
||
85 | add_user_meta( $current_user->ID, $user_meta_key, 1 ); // Prevent user from seeing this again for this View |
||
86 | return; |
||
87 | } |
||
88 | 35 | ||
89 | // The user has already dismissed the notice |
||
90 | if ( get_user_meta( $current_user->ID, $user_meta_key, true ) ) { |
||
91 | return; |
||
92 | 35 | } |
|
93 | 10 | ||
94 | 10 | $form = $gravityview->view->form; |
|
95 | 10 | ||
96 | if ( ! $form ) { |
||
97 | 27 | return; |
|
98 | 27 | } |
|
99 | 27 | ||
100 | $count = \GFAPI::count_entries( $gravityview->view->form->ID, array( |
||
101 | 'status' => 'active', |
||
102 | 35 | 'field_filters' => array( |
|
103 | 35 | array( |
|
104 | 35 | 'key' => 'is_approved', |
|
105 | 28 | 'operator' => 'isnot', |
|
106 | 'value' => \GravityView_Entry_Approval_Status::APPROVED, |
||
107 | ), |
||
108 | 7 | ), |
|
109 | 7 | ) ); |
|
110 | 7 | ||
111 | 7 | $notice_title = _n( |
|
112 | esc_html__( 'There is an unapproved entry that is not being shown.', 'gravityview' ), |
||
113 | 7 | esc_html__( 'There are %s unapproved entries that are not being shown.', 'gravityview' ), |
|
114 | 7 | $count |
|
115 | ); |
||
116 | 7 | ||
117 | 7 | $float_dir = is_rtl() ? 'left' : 'right'; |
|
118 | $hide_link = sprintf( '<a href="%s" style="float: ' . $float_dir . '; font-size: 1rem" role="button">%s</a>', esc_url( wp_nonce_url( add_query_arg( array( 'notice' => 'no_entries_' . $gravityview->view->ID ) ), 'dismiss', 'gv-dismiss' ) ), esc_html__( 'Hide this notice', 'gravityview' ) ); |
||
119 | |||
120 | $message_strings = array( |
||
121 | '<h3>' . sprintf( $notice_title, number_format_i18n( $count ) ) . $hide_link . '</h3>', |
||
122 | esc_html__( 'The "Show only approved entries" setting is enabled, so only entries that have been approved are displayed.', 'gravityview' ), |
||
123 | sprintf( '<a href="%s">%s</a>', 'https://docs.gravityview.co/article/490-entry-approval-gravity-forms', esc_html__( 'Learn about entry approval.', 'gravityview' ) ), |
||
124 | "\n\n", |
||
125 | sprintf( esc_html_x( '%sEdit the View settings%s or %sApprove entries%s', 'Replacements are HTML links', 'gravityview' ), '<a href="' . esc_url( get_edit_post_link( $gravityview->view->ID, false ) ) . '" style="font-weight: bold;">', '</a>', '<a href="' . esc_url( admin_url( 'admin.php?page=gf_entries&id=' . $gravityview->view->form->ID ) ) . '" style="font-weight: bold;">', '</a>' ), |
||
126 | "\n\n", |
||
127 | sprintf( '<img alt="%s" src="%s" style="padding: 10px 0; max-width: 550px;" />', esc_html__( 'Show only approved entries', 'gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/entry-approval.png', GRAVITYVIEW_FILE ) ) ), |
||
128 | "\n\n", |
||
129 | esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ), |
||
130 | ); |
||
131 | |||
132 | $notice = wpautop( implode( ' ', $message_strings ) ); |
||
133 | |||
134 | echo \GVCommon::generate_notice( $notice, 'warning', 'edit_gravityview', $gravityview->view->ID ); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * Check empty configuration. |
||
139 | * |
||
140 | * @since 2.9.5 |
||
141 | * |
||
142 | * @param \GV\Template_Context $gravityview The $gravityview template object. |
||
143 | * |
||
144 | * @return void |
||
145 | */ |
||
146 | private static function maybe_print_configuration_notice( $gravityview ) { |
||
181 | |||
182 | /** |
||
183 | * Print reserved slug warnings, if they exist. |
||
184 | * |
||
185 | * @since 2.9.5 |
||
186 | * |
||
187 | * @param Template_Context $gravityview The $gravityview template object. |
||
188 | * |
||
189 | * @return void |
||
190 | */ |
||
191 | private static function maybe_print_reserved_slugs_notice( $gravityview ) { |
||
236 | |||
237 | /** |
||
238 | * Warn about legacy template being used. |
||
239 | * |
||
240 | * Generate a callback that shows which legacy template was at fault. |
||
241 | * Used in gravityview_before. |
||
242 | * |
||
243 | * @param \GV\View $view The view we're looking at. |
||
244 | * @param string $path The path of the offending template. |
||
245 | * |
||
246 | * @return \Callable A closure used in the filter. |
||
247 | */ |
||
248 | public function legacy_template_warning( $view, $path ) { |
||
253 | } |
||
254 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.