| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +use LearnPress\Helpers\Template; | |
| 4 | + | |
| 3 | 5 | /** |
| 4 | 6 | * Class LP_Addon |
| 5 | 7 | */ |
| 6 | 8 | class LP_Addon { |
| @@ -8,51 +10,59 @@ | ||
| 8 | 10 | * Current version of addon. |
| 9 | 11 | * |
| 10 | 12 | * @var string |
| 11 | 13 | */ |
| 12 | - public $version = null; | |
| 13 | - | |
| 14 | + public $version = 0; | |
| 14 | 15 | /** |
| 15 | - * Learnpress require addon version | |
| 16 | - * Case: | |
| 16 | + * LearnPress require addon version | |
| 17 | 17 | * |
| 18 | 18 | * @var array |
| 19 | 19 | */ |
| 20 | 20 | private $lp_require_addon_version = '4.0.0'; |
| 21 | - | |
| 22 | 21 | /** |
| 23 | 22 | * Required version for current version of addon. |
| 24 | 23 | * |
| 25 | 24 | * @var string |
| 26 | 25 | */ |
| 27 | - public $require_version = null; | |
| 28 | - | |
| 26 | + public $require_version = 0; | |
| 29 | 27 | /** |
| 30 | - * Path to addon. | |
| 28 | + * Path to root file of addon. | |
| 31 | 29 | * |
| 32 | 30 | * @var string |
| 33 | 31 | */ |
| 34 | - public $plugin_file = null; | |
| 35 | - | |
| 32 | + public $plugin_file = ''; | |
| 36 | 33 | /** |
| 37 | - * Base addon. | |
| 34 | + * @var string folder path root of addon. | |
| 35 | + */ | |
| 36 | + public $plugin_folder_path = ''; | |
| 37 | + /** | |
| 38 | + * Root folder name addon. | |
| 38 | 39 | * |
| 39 | 40 | * @var string |
| 40 | 41 | */ |
| 41 | - public $plugin_base = null; | |
| 42 | - | |
| 42 | + public $plugin_folder_name = ''; | |
| 43 | 43 | /** |
| 44 | - * Addon textdomain name. | |
| 44 | + * Plugin base addon. | |
| 45 | 45 | * |
| 46 | + * @var string contain root folder path and root file of addon | |
| 47 | + */ | |
| 48 | + public $plugin_base = ''; | |
| 49 | + /** | |
| 50 | + * Base name addon. | |
| 51 | + * | |
| 52 | + * @var string root file name php of addon | |
| 53 | + */ | |
| 54 | + public $plugin_base_name = ''; | |
| 55 | + /** | |
| 56 | + * Addon text-domain name. | |
| 57 | + * | |
| 46 | 58 | * @var string |
| 47 | 59 | */ |
| 48 | 60 | public $text_domain = ''; |
| 49 | - | |
| 50 | 61 | /** |
| 51 | 62 | * @var null |
| 52 | 63 | */ |
| 53 | 64 | protected $_valid = null; |
| 54 | - | |
| 55 | 65 | /** |
| 56 | 66 | * Singleton instance of the addon. |
| 57 | 67 | * |
| 58 | 68 | * @var array |
| @@ -57,14 +67,12 @@ | ||
| 57 | 67 | * |
| 58 | 68 | * @var array |
| 59 | 69 | */ |
| 60 | 70 | public static $instances = array(); |
| 61 | - | |
| 62 | 71 | /** |
| 63 | 72 | * @var array |
| 64 | 73 | */ |
| 65 | 74 | protected static $_admin_notices = array(); |
| 66 | - | |
| 67 | 75 | /** |
| 68 | 76 | * @var string |
| 69 | 77 | */ |
| 70 | 78 | protected $_template_path = ''; |
| @@ -74,69 +82,15 @@ | ||
| 74 | 82 | /** |
| 75 | 83 | * LP_Addon constructor. |
| 76 | 84 | */ |
| 77 | 85 | public function __construct() { |
| 78 | - | |
| 86 | + $this->plugin_base = plugin_basename( $this->plugin_file ); | |
| 87 | + $this->plugin_base_name = basename( $this->plugin_file ); | |
| 88 | + $this->plugin_folder_path = dirname( $this->plugin_file ); | |
| 89 | + $this->plugin_folder_name = str_replace( array( '/', $this->plugin_base_name ), '', $this->plugin_base ); | |
| 79 | 90 | $this->_define_constants(); |
| 80 | - | |
| 81 | - // if ( ! $this->_check_version() ) { | |
| 82 | - // return; | |
| 83 | - // } | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * After all addons lp config by key "Require_LP_Version" can remove hook | |
| 87 | - */ | |
| 88 | - //add_action( 'plugins_loaded', array( $this, 'check_require_version_lp' ), - 9 ); | |
| 89 | - | |
| 90 | 91 | $this->_includes(); |
| 91 | - | |
| 92 | - add_action( 'init', array( $this, 'init' ) ); | |
| 93 | - } | |
| 94 | - | |
| 95 | - public static function admin_errors() { | |
| 96 | - if ( ! self::$_admin_notices ) { | |
| 97 | - return; | |
| 98 | - } | |
| 99 | - | |
| 100 | - foreach ( self::$_admin_notices as $notice ) { | |
| 101 | - ?> | |
| 102 | - <div class="error"><p><?php echo wp_kses_post( $notice ); ?></p></div> | |
| 103 | - <?php | |
| 104 | - } | |
| 105 | - } | |
| 106 | - | |
| 107 | - public function _plugin_links( $links ) { | |
| 108 | - if ( method_exists( $this, 'plugin_links' ) ) { | |
| 109 | - $plugin_links = call_user_func( array( $this, 'plugin_links' ) ); | |
| 110 | - | |
| 111 | - if ( is_callable( array( $this, 'plugin_links' ) ) && $plugin_links ) { | |
| 112 | - $links = array_merge( $links, $plugin_links ); | |
| 113 | - } | |
| 114 | - } | |
| 115 | - | |
| 116 | - return $links; | |
| 117 | - } | |
| 118 | - | |
| 119 | - /** | |
| 120 | - * Init | |
| 121 | - */ | |
| 122 | - public function init() { | |
| 123 | - // if ( ! $this->_check_version() ) { | |
| 124 | - // return; | |
| 125 | - // } | |
| 126 | - | |
| 127 | 92 | $this->load_text_domain(); |
| 128 | - | |
| 129 | - add_filter( | |
| 130 | - "plugin_action_links_{$this->get_plugin_slug()}", | |
| 131 | - array( | |
| 132 | - $this, | |
| 133 | - '_plugin_links', | |
| 134 | - ) | |
| 135 | - ); | |
| 136 | - | |
| 137 | - $this->_init_hooks(); | |
| 138 | - $this->_enqueue_assets(); | |
| 139 | 93 | } |
| 140 | 94 | |
| 141 | 95 | /** |
| 142 | 96 | * Define add-on constants. |
| @@ -141,9 +95,8 @@ | ||
| 141 | 95 | /** |
| 142 | 96 | * Define add-on constants. |
| 143 | 97 | */ |
| 144 | 98 | protected function _define_constants() { |
| 145 | - | |
| 146 | 99 | } |
| 147 | 100 | |
| 148 | 101 | /** |
| 149 | 102 | * Includes add-on files. |
| @@ -148,68 +101,11 @@ | ||
| 148 | 101 | /** |
| 149 | 102 | * Includes add-on files. |
| 150 | 103 | */ |
| 151 | 104 | protected function _includes() { |
| 152 | - | |
| 153 | 105 | } |
| 154 | 106 | |
| 155 | 107 | /** |
| 156 | - * Init add-on hooks. | |
| 157 | - */ | |
| 158 | - protected function _init_hooks() { | |
| 159 | - | |
| 160 | - } | |
| 161 | - | |
| 162 | - /** | |
| 163 | - * Enqueue scripts. | |
| 164 | - */ | |
| 165 | - protected function _enqueue_assets() { | |
| 166 | - | |
| 167 | - } | |
| 168 | - | |
| 169 | - /** | |
| 170 | - * Get plugin slug from plugin file. | |
| 171 | - * | |
| 172 | - * @return bool|string | |
| 173 | - */ | |
| 174 | - public function get_plugin_slug() { | |
| 175 | - if ( empty( $this->plugin_file ) ) { | |
| 176 | - return false; | |
| 177 | - } | |
| 178 | - | |
| 179 | - $dir = dirname( $this->plugin_file ); | |
| 180 | - $basename = basename( $dir ); | |
| 181 | - | |
| 182 | - return $basename . '/' . basename( $this->plugin_file ); | |
| 183 | - } | |
| 184 | - | |
| 185 | - /** | |
| 186 | - * Check required version of LP. | |
| 187 | - * | |
| 188 | - * @return bool|null | |
| 189 | - * @deprecated 4.0.0 | |
| 190 | - * @todo clean, remove code | |
| 191 | - */ | |
| 192 | - /*protected function _check_version() { | |
| 193 | - if ( null === $this->_valid ) { | |
| 194 | - $this->_valid = true; | |
| 195 | - | |
| 196 | - if ( $this->require_version ) { | |
| 197 | - if ( version_compare( $this->require_version, LEARNPRESS_VERSION, '>' ) ) { | |
| 198 | - add_action( 'admin_notices', array( $this, '_admin_notices' ) ); | |
| 199 | - | |
| 200 | - // Deactivate plugin . | |
| 201 | - deactivate_plugins( plugin_basename( $this->plugin_file ) ); | |
| 202 | - | |
| 203 | - $this->_valid = false; | |
| 204 | - } | |
| 205 | - } | |
| 206 | - } | |
| 207 | - | |
| 208 | - return $this->_valid; | |
| 209 | - }*/ | |
| 210 | - | |
| 211 | - /** | |
| 212 | 108 | * Check required version Addons. |
| 213 | 109 | * |
| 214 | 110 | * @return bool |
| 215 | 111 | */ |
| @@ -224,9 +120,9 @@ | ||
| 224 | 120 | add_action( 'admin_notices', array( $this, 'admin_notice_require_addon_version' ) ); |
| 225 | 121 | |
| 226 | 122 | // Deactivate plugin . |
| 227 | 123 | if ( ! empty( $this->plugin_base ) ) { |
| 228 | - deactivate_plugins( $this->plugin_base ); | |
| 124 | + //deactivate_plugins( $this->plugin_base ); | |
| 229 | 125 | } |
| 230 | 126 | } |
| 231 | 127 | |
| 232 | 128 | return $flag; |
| @@ -256,9 +152,9 @@ | ||
| 256 | 152 | add_action( 'admin_notices', array( $this, 'admin_notice_require_lp_version' ) ); |
| 257 | 153 | |
| 258 | 154 | // Deactivate plugin . |
| 259 | 155 | if ( ! empty( $this->plugin_base ) ) { |
| 260 | - deactivate_plugins( plugin_basename( $this->plugin_base ) ); | |
| 156 | + //deactivate_plugins( plugin_basename( $this->plugin_base ) ); | |
| 261 | 157 | } |
| 262 | 158 | } |
| 263 | 159 | |
| 264 | 160 | return $flag; |
| @@ -266,9 +162,18 @@ | ||
| 266 | 162 | |
| 267 | 163 | public function admin_notice_require_addon_version() { |
| 268 | 164 | ?> |
| 269 | 165 | <div class="notice notice-error"> |
| 270 | - <p><?php echo( '<strong>LearnPress version ' . LEARNPRESS_VERSION . ' require ' . $this->get_name() . '</strong> version ' . $this->lp_require_addon_version . ' or higher' ); ?></p> | |
| 166 | + <p> | |
| 167 | + <?php | |
| 168 | + printf( | |
| 169 | + wp_kses_post( __( '<strong>LearnPress version %1$s require %2$s</strong> version %3$s or higher', 'learnpress' ) ), | |
| 170 | + esc_html( LEARNPRESS_VERSION ), | |
| 171 | + esc_html( $this->get_name() ), | |
| 172 | + esc_html( $this->lp_require_addon_version ) | |
| 173 | + ); | |
| 174 | + ?> | |
| 175 | + </p> | |
| 271 | 176 | </div> |
| 272 | 177 | <?php |
| 273 | 178 | } |
| 274 | 179 | |
| @@ -280,11 +185,13 @@ | ||
| 280 | 185 | <div class="error"> |
| 281 | 186 | <p> |
| 282 | 187 | <?php |
| 283 | 188 | printf( |
| 284 | - __( | |
| 285 | - '<strong>%1$s</strong> add-on version %2$s requires <strong>LearnPress</strong> version %3$s or higher %4$s', | |
| 286 | - 'learnpress' | |
| 189 | + wp_kses_post( | |
| 190 | + __( | |
| 191 | + '<strong>%1$s</strong> add-on version %2$s requires <strong>LearnPress</strong> version %3$s or higher %4$s', | |
| 192 | + 'learnpress' | |
| 193 | + ) | |
| 287 | 194 | ), |
| 288 | 195 | esc_html( $this->get_name() ), |
| 289 | 196 | esc_html( $this->version ), |
| 290 | 197 | esc_html( $this->require_version ), |
| @@ -317,32 +224,11 @@ | ||
| 317 | 224 | if ( empty( $this->plugin_file ) ) { |
| 318 | 225 | return; |
| 319 | 226 | } |
| 320 | 227 | |
| 321 | - $plugin_path = dirname( $this->plugin_file ); | |
| 322 | - $plugin_folder = basename( $plugin_path ); | |
| 323 | - $text_domain = empty( $this->text_domain ) ? $plugin_folder : $this->text_domain; | |
| 324 | - $locale = apply_filters( 'plugin_locale', get_locale(), $plugin_folder ); | |
| 325 | - $domain_files = array(); | |
| 326 | - | |
| 327 | - if ( is_admin() ) { | |
| 328 | - $domain_files[] = WP_LANG_DIR . "/{$plugin_folder}/{$plugin_folder}-admin-{$locale}.mo"; | |
| 329 | - $domain_files[] = WP_LANG_DIR . "/plugins/{$plugin_folder}-admin-{$locale}.mo"; | |
| 330 | - } | |
| 331 | - | |
| 332 | - $domain_files[] = WP_CONTENT_DIR . "/plugins/{$plugin_folder}/languages/{$plugin_folder}-{$locale}.mo"; | |
| 333 | - $domain_files[] = WP_LANG_DIR . "/{$plugin_folder}/{$plugin_folder}-{$locale}.mo"; | |
| 334 | - | |
| 335 | - foreach ( $domain_files as $file ) { | |
| 336 | - if ( ! file_exists( $file ) ) { | |
| 337 | - continue; | |
| 338 | - } | |
| 339 | - | |
| 340 | - load_textdomain( $text_domain, $file ); | |
| 341 | - } | |
| 342 | - | |
| 228 | + $text_domain = empty( $this->text_domain ) ? $this->plugin_folder_name : $this->text_domain; | |
| 343 | 229 | if ( $text_domain ) { |
| 344 | - load_plugin_textdomain( $text_domain, false, plugin_basename( $plugin_path ) . '/languages' ); | |
| 230 | + load_plugin_textdomain( $text_domain, false, $this->plugin_folder_name . '/languages' ); | |
| 345 | 231 | } |
| 346 | 232 | } |
| 347 | 233 | |
| 348 | 234 | /** |
| @@ -347,15 +233,15 @@ | ||
| 347 | 233 | |
| 348 | 234 | /** |
| 349 | 235 | * Load Addon |
| 350 | 236 | * |
| 351 | - * @param $instance | |
| 352 | - * @param $path | |
| 237 | + * @param string $instance | |
| 238 | + * @param string $path | |
| 353 | 239 | * @param string $plugin_file |
| 354 | 240 | * |
| 355 | 241 | * @return void|mixed |
| 356 | 242 | */ |
| 357 | - public static function load( $instance, $path, $plugin_file = '' ) { | |
| 243 | + public static function load( string $instance = '', string $path = '', string $plugin_file = '' ) { | |
| 358 | 244 | $plugin_folder = ''; |
| 359 | 245 | |
| 360 | 246 | if ( $plugin_file ) { |
| 361 | 247 | $plugin_folder = dirname( $plugin_file ); |
| @@ -361,15 +247,17 @@ | ||
| 361 | 247 | $plugin_folder = dirname( $plugin_file ); |
| 362 | 248 | } |
| 363 | 249 | |
| 364 | 250 | if ( $plugin_folder ) { |
| 365 | - $path = "{$plugin_folder}/$path"; | |
| 251 | + $path = "$plugin_folder/$path"; | |
| 366 | 252 | } |
| 367 | 253 | |
| 368 | 254 | if ( ! file_exists( $path ) ) { |
| 369 | - self::$_admin_notices['add-on-file-no-exists'] = sprintf( | |
| 370 | - __( '%s plugin file does not exist.', 'learnpress' ), | |
| 371 | - $path | |
| 255 | + error_log( | |
| 256 | + sprintf( | |
| 257 | + __( '%s plugin file does not exist.', 'learnpress' ), | |
| 258 | + $path | |
| 259 | + ) | |
| 372 | 260 | ); |
| 373 | 261 | |
| 374 | 262 | return; |
| 375 | 263 | } |
| @@ -376,31 +264,30 @@ | ||
| 376 | 264 | |
| 377 | 265 | include_once $path; |
| 378 | 266 | $addon_instance = null; |
| 379 | 267 | |
| 380 | - if ( class_exists( $instance ) ) { | |
| 381 | - $addon_instance = null; | |
| 382 | - if ( is_callable( array( $instance, 'instance' ) ) ) { | |
| 383 | - $addon_instance = call_user_func( array( $instance, 'instance' ) ); | |
| 384 | - } else { | |
| 268 | + if ( ! array_key_exists( $instance, self::$instances ) ) { | |
| 269 | + if ( class_exists( $instance ) ) { | |
| 385 | 270 | $addon_instance = new $instance(); |
| 386 | 271 | } |
| 387 | - } | |
| 388 | 272 | |
| 389 | - if ( ! $addon_instance ) { | |
| 390 | - self::$_admin_notices['add-on-class-no-exists'] = sprintf( | |
| 391 | - __( '%s plugin class does not exist.', 'learnpress' ), | |
| 392 | - $instance | |
| 393 | - ); | |
| 273 | + if ( ! $addon_instance ) { | |
| 274 | + error_log( | |
| 275 | + sprintf( | |
| 276 | + __( '%s plugin class does not exist.', 'learnpress' ), | |
| 277 | + $instance | |
| 278 | + ) | |
| 279 | + ); | |
| 394 | 280 | |
| 395 | - return; | |
| 396 | - } | |
| 281 | + return; | |
| 282 | + } | |
| 397 | 283 | |
| 398 | - $addon_instance->plugin_file = $plugin_file; | |
| 284 | + $addon_instance->plugin_file = $plugin_file; | |
| 399 | 285 | |
| 400 | - self::$instances[ $instance ] = $addon_instance; | |
| 286 | + self::$instances[ $instance ] = $addon_instance; | |
| 287 | + } | |
| 401 | 288 | |
| 402 | - return $addon_instance; | |
| 289 | + return self::$instances[ $instance ]; | |
| 403 | 290 | } |
| 404 | 291 | |
| 405 | 292 | public function get_plugin_url( $sub = '/' ) { |
| 406 | 293 | return plugins_url( $sub, $this->plugin_file ); |
| @@ -406,52 +293,65 @@ | ||
| 406 | 293 | return plugins_url( $sub, $this->plugin_file ); |
| 407 | 294 | } |
| 408 | 295 | |
| 409 | 296 | /** |
| 410 | - * Get template path. | |
| 297 | + * Get content template of addon. | |
| 411 | 298 | * |
| 412 | - * @return string | |
| 299 | + * @param string $template_name | |
| 300 | + * @param array $args | |
| 301 | + * @param bool $include | |
| 302 | + * | |
| 303 | + * @since 3.0.0 | |
| 304 | + * @version 1.0.1 | |
| 413 | 305 | */ |
| 414 | - public function get_template_path() { | |
| 415 | - if ( empty( $this->_template_path ) ) { | |
| 416 | - $this->_template_path = learn_press_template_path() . '/addons/' . preg_replace( | |
| 417 | - '!^learnpress-!', | |
| 418 | - '', | |
| 419 | - dirname( $this->get_plugin_slug() ) | |
| 420 | - ); | |
| 306 | + public function get_template( string $template_name = '', array $args = [], bool $include = true ) { | |
| 307 | + // Check path file not extension php, will add extension .php | |
| 308 | + if ( ! preg_match( '/\.php$/', $template_name ) ) { | |
| 309 | + $template_name .= '.php'; | |
| 421 | 310 | } |
| 311 | + $default_path = $this->plugin_folder_path . "/templates/$template_name"; | |
| 312 | + $folder_name_rewrite = learn_press_template_path(); | |
| 313 | + $from_child_theme_path = sprintf( | |
| 314 | + '%s/%s/%s/%s/%s', | |
| 315 | + get_stylesheet_directory(), | |
| 316 | + $folder_name_rewrite, | |
| 317 | + 'addons', | |
| 318 | + str_replace( 'learnpress-', '', $this->plugin_folder_name ), | |
| 319 | + $template_name | |
| 320 | + ); | |
| 321 | + $from_theme_path = sprintf( | |
| 322 | + '%s/%s/%s/%s/%s', | |
| 323 | + get_template_directory(), | |
| 324 | + $folder_name_rewrite, | |
| 325 | + 'addons', | |
| 326 | + str_replace( 'learnpress-', '', $this->plugin_folder_name ), | |
| 327 | + $template_name | |
| 328 | + ); | |
| 422 | 329 | |
| 423 | - return $this->_template_path; | |
| 330 | + $path_load = $default_path; | |
| 331 | + if ( file_exists( $from_child_theme_path ) ) { | |
| 332 | + $path_load = $from_child_theme_path; | |
| 333 | + } elseif ( file_exists( $from_theme_path ) ) { | |
| 334 | + $path_load = $from_theme_path; | |
| 335 | + } | |
| 336 | + Template::instance( $include )->get_template( $path_load, $args ); | |
| 424 | 337 | } |
| 425 | 338 | |
| 426 | 339 | /** |
| 427 | - * Get content template of addon in theme or inside itself. | |
| 340 | + * Get content template of addon. | |
| 428 | 341 | * |
| 429 | 342 | * @param string $template_name |
| 430 | - * @param array $args | |
| 431 | - */ | |
| 432 | - public function get_template( $template_name, $args = array() ) { | |
| 433 | - learn_press_get_template( | |
| 434 | - $template_name, | |
| 435 | - $args, | |
| 436 | - $this->get_template_path(), | |
| 437 | - dirname( $this->plugin_file ) . '/templates/' | |
| 438 | - ); | |
| 439 | - } | |
| 440 | - | |
| 441 | - /** | |
| 442 | - * Locate template of addon in theme or inside itself. | |
| 343 | + * @param mixed $args | |
| 443 | 344 | * |
| 444 | - * @param string $template_name | |
| 445 | - * | |
| 446 | - * @return string | |
| 345 | + * @since 4.2.1 | |
| 346 | + * @version 1.0.1 | |
| 447 | 347 | */ |
| 448 | - public function locate_template( $template_name ) { | |
| 449 | - return learn_press_locate_template( | |
| 450 | - $template_name, | |
| 451 | - $this->get_template_path(), | |
| 452 | - dirname( $this->plugin_file ) . '/templates/' | |
| 453 | - ); | |
| 348 | + public function get_admin_template( string $template_name = '', $args = [] ) { | |
| 349 | + if ( ! preg_match( '/\.php$/', $template_name ) ) { | |
| 350 | + $template_name .= '.php'; | |
| 351 | + } | |
| 352 | + $template_path = "{$this->plugin_folder_path}/inc/admin/views/$template_name"; | |
| 353 | + Template::instance()->get_template( $template_path, $args ); | |
| 454 | 354 | } |
| 455 | 355 | |
| 456 | 356 | /** |
| 457 | 357 | * Output content of admin view file. |
| @@ -456,9 +356,9 @@ | ||
| 456 | 356 | /** |
| 457 | 357 | * Output content of admin view file. |
| 458 | 358 | * |
| 459 | 359 | * @param string $view |
| 460 | - * @param array $args | |
| 360 | + * @param array $args | |
| 461 | 361 | * |
| 462 | 362 | * @since x.x.x |
| 463 | 363 | */ |
| 464 | 364 | public function admin_view( $view, $args = array() ) { |
| @@ -466,28 +366,13 @@ | ||
| 466 | 366 | learn_press_admin_view( $view, $args ); |
| 467 | 367 | } |
| 468 | 368 | |
| 469 | 369 | /** |
| 470 | - * Get content of admin view file. | |
| 471 | - * | |
| 472 | - * @param string $view | |
| 473 | - * @param array $args | |
| 474 | - * | |
| 475 | - * @return string | |
| 476 | - * @since x.x.x | |
| 370 | + * @deprecated 4.2.0, wishlist v4.0.8 still use | |
| 477 | 371 | */ |
| 478 | - public function admin_view_content( $view, $args = array() ) { | |
| 479 | - ob_start(); | |
| 480 | - $this->admin_view( $view, $args ); | |
| 481 | - | |
| 482 | - return ob_get_clean(); | |
| 483 | - } | |
| 484 | - | |
| 485 | - /** | |
| 486 | - * @return mixed | |
| 487 | - */ | |
| 488 | 372 | public static function instance() { |
| 489 | - $name = self::_get_called_class(); | |
| 373 | + return new static(); | |
| 374 | + /*$name = self::_get_called_class(); | |
| 490 | 375 | if ( false === $name ) { |
| 491 | 376 | return false; |
| 492 | 377 | } |
| 493 | 378 | |
| @@ -494,15 +379,16 @@ | ||
| 494 | 379 | if ( empty( self::$instances[ $name ] ) ) { |
| 495 | 380 | self::$instances[ $name ] = new $name(); |
| 496 | 381 | } |
| 497 | 382 | |
| 498 | - return self::$instances[ $name ]; | |
| 383 | + return self::$instances[ $name ];*/ | |
| 499 | 384 | } |
| 500 | 385 | |
| 501 | 386 | /** |
| 502 | 387 | * @return bool|string |
| 388 | + * @deprecated 4.2.0 | |
| 503 | 389 | */ |
| 504 | - protected static function _get_called_class() { | |
| 390 | + /*protected static function _get_called_class() { | |
| 505 | 391 | if ( function_exists( 'get_called_class' ) ) { |
| 506 | 392 | return get_called_class(); |
| 507 | 393 | } |
| 508 | 394 | |
| @@ -516,8 +402,6 @@ | ||
| 516 | 402 | return false; |
| 517 | 403 | } |
| 518 | 404 | |
| 519 | 405 | return $backtrace[2]['args'][0]; |
| 520 | - } | |
| 406 | + }*/ | |
| 521 | 407 | } |
| 522 | - | |
| 523 | -add_action( 'admin_notices', array( 'LP_Addon', 'admin_errors' ) ); | |