ajax.php
3 weeks ago
install-notice.php
3 weeks ago
install-tracker.php
3 weeks ago
onboard-status.php
3 weeks ago
plugin-data-sender.php
1 year ago
plugin-installer.php
3 weeks ago
plugin-skin.php
1 year ago
plugin-status.php
4 years ago
utils.php
1 year ago
utils.php
89 lines
| 1 | <?php |
| 2 | namespace ElementsKit_Lite\Libs\Framework\Classes; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | class Utils { |
| 7 | |
| 8 | public static $instance = null; |
| 9 | private static $key = 'elementskit_options'; |
| 10 | |
| 11 | public static function get_dir() { |
| 12 | return \ElementsKit_Lite::lib_dir() . 'framework/'; |
| 13 | } |
| 14 | |
| 15 | public static function get_url() { |
| 16 | return \ElementsKit_Lite::lib_url() . 'framework/'; |
| 17 | } |
| 18 | |
| 19 | public function get_option( $key, $default = '' ) { |
| 20 | $data_all = get_option( self::$key ); |
| 21 | return ( isset( $data_all[ $key ] ) && $data_all[ $key ] != '' ) ? $data_all[ $key ] : $default; |
| 22 | } |
| 23 | |
| 24 | public function save_option( $key, $value = '' ) { |
| 25 | $data_all = get_option( self::$key, array() ); |
| 26 | $data_all[ $key ] = $value; |
| 27 | update_option( 'elementskit_options', $data_all ); |
| 28 | } |
| 29 | |
| 30 | public function get_settings( $key, $default = '' ) { |
| 31 | $data_all = $this->get_option( 'settings', array() ); |
| 32 | return ( isset( $data_all[ $key ] ) && $data_all[ $key ] != '' ) ? $data_all[ $key ] : $default; |
| 33 | } |
| 34 | |
| 35 | public function save_settings( $new_data = '' ) { |
| 36 | $data_old = $this->get_option( 'settings', array() ); |
| 37 | $data = array_merge( $data_old, $new_data ); |
| 38 | $this->save_option( 'settings', $data ); |
| 39 | } |
| 40 | |
| 41 | /* |
| 42 | -> this method used to check weather the widget active/deactive |
| 43 | -> this method takes two paramitter 1. widget name 2. Active/deactive hook |
| 44 | */ |
| 45 | public function is_widget_active_class( $widget_name, $pro_active ) { |
| 46 | if ( $pro_active ) { |
| 47 | return 'label-' . $widget_name . ' attr-panel-heading'; |
| 48 | } else { |
| 49 | return 'label-' . $widget_name . ' attr-panel-heading pro-disabled'; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | public function input( $input_options ) { |
| 54 | $defaults = array( |
| 55 | 'type' => null, |
| 56 | 'name' => '', |
| 57 | 'value' => '', |
| 58 | 'class' => '', |
| 59 | 'label' => '', |
| 60 | 'info' => '', |
| 61 | 'disabled' => '', |
| 62 | 'options' => array(), |
| 63 | ); |
| 64 | $input_options = array_merge( $defaults, $input_options ); |
| 65 | |
| 66 | if ( file_exists( self::get_dir() . 'controls/settings/' . $input_options['type'] . '.php' ) ) { |
| 67 | extract( $input_options ); |
| 68 | include self::get_dir() . 'controls/settings/' . $input_options['type'] . '.php'; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | public static function strify( $str ) { |
| 73 | return strtolower( preg_replace( '/[^A-Za-z0-9]/', '__', $str ) ); |
| 74 | } |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | public static function instance() { |
| 80 | if ( is_null( self::$instance ) ) { |
| 81 | |
| 82 | // Fire the class instance |
| 83 | self::$instance = new self(); |
| 84 | } |
| 85 | |
| 86 | return self::$instance; |
| 87 | } |
| 88 | } |
| 89 |