PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
← All changes | inc/templates/abstract-template.php +55 -49 4.1.74.4.8 View file →
@@ -70,51 +70,55 @@
70 70 * @param string $tag
71 71 * @param string $function_to_remove - '*' will remove all methods.
72 72 * @param int $priority
73 73 *
74 - * Ex: Remove for text: LP()->template( 'course' )->remove( 'learn-press/course-content-summary', array( '<div class="course-detail-info"> <div class="lp-content-area"> <div class="course-info-left">', 'course-info-left-open' ), 10 );
74 + * Ex: Remove for text: LearnPress::instance()->template( 'course' )->remove( 'learn-press/course-content-summary', array( '<div class="course-detail-info"> <div class="lp-content-area"> <div class="course-info-left">', 'course-info-left-open' ), 10 );
75 75 */
76 76 public function remove( $tag, $function_to_remove, $priority = 10 ) {
77 77 global $wp_filter;
78 78
79 - if ( is_array( $function_to_remove ) ) {
80 - if ( empty( $wp_filter[ $tag ] ) ) {
81 - return;
82 - }
79 + try {
80 + if ( is_array( $function_to_remove ) ) {
81 + if ( empty( $wp_filter[ $tag ] ) ) {
82 + return;
83 + }
83 84
84 - $callbacks = $wp_filter[ $tag ]->callbacks;
85 - if ( ! $callbacks ) {
86 - return;
87 - }
88 -
89 - $priorities = array_keys( $callbacks );
90 -
91 - foreach ( $priorities as $priority1 ) {
92 -
93 - if ( $priority !== '*' && $priority !== $priority1 ) {
94 - continue;
85 + $callbacks = $wp_filter[ $tag ]->callbacks;
86 + if ( ! $callbacks ) {
87 + return;
95 88 }
96 89
97 - if ( empty( $callbacks[ $priority1 ] ) ) {
98 - continue;
99 - }
90 + $priorities = array_keys( $callbacks );
100 91
101 - foreach ( $callbacks[ $priority1 ] as $callback ) {
92 + foreach ( $priorities as $priority1 ) {
102 93
103 - if ( ! $callback['function'][0] instanceof LP_Template_Callback ) {
94 + if ( $priority !== '*' && $priority !== $priority1 ) {
104 95 continue;
105 96 }
106 97
107 - if ( $callback['function'][0]->get_args() !== $function_to_remove[1] ) {
98 + if ( empty( $callbacks[ $priority1 ] ) ) {
108 99 continue;
109 100 }
110 101
111 - remove_action( $tag, $callback['function'], $priority1 );
102 + foreach ( $callbacks[ $priority1 ] as $callback ) {
103 +
104 + if ( ! $callback['function'][0] instanceof LP_Template_Callback ) {
105 + continue;
106 + }
107 +
108 + if ( $callback['function'][0]->get_args() !== $function_to_remove[1] ) {
109 + continue;
110 + }
111 +
112 + remove_action( $tag, $callback['function'], $priority1 );
113 + }
112 114 }
115 +
116 + return;
117 +
113 118 }
119 + } catch ( Throwable $e ) {
114 120
115 - return;
116 -
117 121 }
118 122
119 123 /**
120 124 * $function_to_remove === '*' will remove all functions hooked into a hook
@@ -156,9 +160,9 @@
156 160 * @return void
157 161 *
158 162 * @author Nhamdv <email@email.com>
159 163 *
160 - * Ex: LP()->template( 'course' )->remove_callback( 'learn-press/course-content-summary', 'single-course/title', 10 );
164 + * Ex: LearnPress::instance()->template( 'course' )->remove_callback( 'learn-press/course-content-summary', 'single-course/title', 10 );
161 165 *
162 166 */
163 167 public static function remove_callback( $tag, $function, $priority ) {
164 168 global $wp_filter;
@@ -166,45 +170,47 @@
166 170 if ( empty( $wp_filter[ $tag ] ) ) {
167 171 return;
168 172 }
169 173
170 - $callbacks = $wp_filter[ $tag ]->callbacks;
174 + try {
175 + $callbacks = $wp_filter[ $tag ]->callbacks;
171 176
172 - if ( ! $callbacks ) {
173 - return;
174 - }
175 -
176 - $priorities = array_keys( $callbacks );
177 -
178 - foreach ( $priorities as $priority1 ) {
179 -
180 - if ( $priority !== '*' && $priority !== $priority1 ) {
181 - continue;
177 + if ( ! $callbacks ) {
178 + return;
182 179 }
183 180
184 - if ( empty( $callbacks[ $priority1 ] ) ) {
185 - continue;
186 - }
181 + $priorities = array_keys( $callbacks );
187 182
188 - foreach ( $callbacks[ $priority1 ] as $callback ) {
183 + foreach ( $priorities as $priority1 ) {
189 184
190 - if ( ! $callback['function'][0] instanceof LP_Template_Callback ) {
185 + if ( $priority !== '*' && $priority !== $priority1 ) {
191 186 continue;
192 187 }
193 188
194 - if ( $callback['function'][1] !== 'callback' ) {
189 + if ( empty( $callbacks[ $priority1 ] ) ) {
195 190 continue;
196 191 }
197 192
198 - if ( $callback['function'][0]->get_template() !== $function ) {
199 - continue;
193 + foreach ( $callbacks[ $priority1 ] as $callback ) {
194 +
195 + if ( ! $callback['function'][0] instanceof LP_Template_Callback ) {
196 + continue;
197 + }
198 +
199 + if ( $callback['function'][1] !== 'callback' ) {
200 + continue;
201 + }
202 +
203 + if ( $callback['function'][0]->get_template() !== $function ) {
204 + continue;
205 + }
206 +
207 + remove_action( $tag, $callback['function'], $priority1 );
200 208 }
201 -
202 - remove_action( $tag, $callback['function'], $priority1 );
203 209 }
210 + } catch ( Throwable $e ) {
211 + error_log( __METHOD__ . ': ' . $e->getMessage() );
204 212 }
205 -
206 - return;
207 213 }
208 214
209 215 /**
210 216 * @return LP_Template