Helper.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PriyoMukul\WPNotice\Utils; |
| 4 | |
| 5 | trait Helper { |
| 6 | |
| 7 | public function is_installed( $plugin ){ |
| 8 | if ( ! function_exists( 'get_plugins' ) ) { |
| 9 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 10 | } |
| 11 | $plugins = get_plugins(); |
| 12 | |
| 13 | return isset( $plugins[ $plugin ] ) ? $plugins[ $plugin ] : false; |
| 14 | } |
| 15 | |
| 16 | /** |
| 17 | * Get current timestamp |
| 18 | * @return integer |
| 19 | */ |
| 20 | public function time(){ |
| 21 | return intval( current_time( 'timestamp' ) ); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Make timestamp for a number |
| 26 | * |
| 27 | * @param string $time |
| 28 | * @return void |
| 29 | */ |
| 30 | public function strtotime( $time = '+7 day' ){ |
| 31 | return intval( strtotime( date( 'r', $this->time() ) . " $time" ) ); |
| 32 | } |
| 33 | |
| 34 | public function date( $time ){ |
| 35 | return date( 'd-m-Y h:i:s', $time ); |
| 36 | } |
| 37 | } |