| @@ -1,0 +1,51 @@ | ||
| 1 | +<?php | |
| 2 | +namespace Templately; | |
| 3 | + | |
| 4 | +class Helper { | |
| 5 | + /** | |
| 6 | + * Get installed WordPress Plugin List | |
| 7 | + * @return void | |
| 8 | + */ | |
| 9 | + public static function get_plugins(){ | |
| 10 | + if( ! function_exists( 'get_plugins' ) ) { | |
| 11 | + require_once \ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 12 | + } | |
| 13 | + return \get_plugins(); | |
| 14 | + } | |
| 15 | + /** | |
| 16 | + * Get views for front-end display | |
| 17 | + * | |
| 18 | + * @param string $name it will be file name only from the views folder. | |
| 19 | + * @param mixed $data | |
| 20 | + * @return void | |
| 21 | + */ | |
| 22 | + public static function views( $name, $data = null ){ | |
| 23 | + $helper = self::class; | |
| 24 | + $file = TEMPLATELY_PATH . $name . '.php'; | |
| 25 | + if( \is_readable( $file ) ) { | |
| 26 | + include_once $file; | |
| 27 | + } | |
| 28 | + } | |
| 29 | + /** | |
| 30 | + * Send JSON Error | |
| 31 | + * | |
| 32 | + * @param mixed $data | |
| 33 | + * @param int $status_code | |
| 34 | + * @return void | |
| 35 | + */ | |
| 36 | + public static function send_error( $data = null, $status_code = null ) { | |
| 37 | + \wp_send_json_error( $data, $status_code ); | |
| 38 | + \wp_die(); | |
| 39 | + } | |
| 40 | + /** | |
| 41 | + * Send JSON Success | |
| 42 | + * | |
| 43 | + * @param mixed $data | |
| 44 | + * @param int $status_code | |
| 45 | + * @return void | |
| 46 | + */ | |
| 47 | + public static function send_success( $data = null, $status_code = null ) { | |
| 48 | + \wp_send_json_success( $data, $status_code ); | |
| 49 | + \wp_die(); | |
| 50 | + } | |
| 51 | +} | |