| 1 |
<?php |
| 2 |
/** |
| 3 |
* The file that defines the core plugin class |
| 4 |
* |
| 5 |
* A class definition that includes attributes and functions used across both the |
| 6 |
* public-facing side of the site and the admin area. |
| 7 |
* |
| 8 |
* @link https://posimyth.com/ |
| 9 |
* @since 1.0.0 |
| 10 |
* |
| 11 |
* @package Wdesignkit |
| 12 |
* @subpackage Wdesignkit/includes |
| 13 |
*/ |
| 14 |
|
| 15 |
namespace wdkit\wdkit_datahooks; |
| 16 |
|
| 17 |
/**Exit if accessed directly.*/ |
| 18 |
if ( ! defined( 'ABSPATH' ) ) { |
| 19 |
exit; |
| 20 |
} |
| 21 |
|
| 22 |
if ( ! class_exists( 'Wdkit_Data_Hooks' ) ) { |
| 23 |
|
| 24 |
/** |
| 25 |
* Wdkit_Data_Hooks |
| 26 |
* |
| 27 |
* @since 1.0.0 |
| 28 |
*/ |
| 29 |
class Wdkit_Data_Hooks { |
| 30 |
|
| 31 |
/** |
| 32 |
* Member Variable |
| 33 |
* |
| 34 |
* @var instance |
| 35 |
*/ |
| 36 |
private static $instance; |
| 37 |
|
| 38 |
/** |
| 39 |
* Initiator |
| 40 |
*/ |
| 41 |
public static function get_instance() { |
| 42 |
if ( ! isset( self::$instance ) ) { |
| 43 |
self::$instance = new self(); |
| 44 |
} |
| 45 |
|
| 46 |
return self::$instance; |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Define the core functionality of the plugin. |
| 51 |
*/ |
| 52 |
public function __construct() { |
| 53 |
add_action( 'wdkit_admin_create_default', array( $this, 'wdkit_create_default' ), 10 ); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Create Default setting data in db |
| 58 |
* |
| 59 |
* @since 1.0.0 |
| 60 |
*/ |
| 61 |
public function wdkit_create_default() { |
| 62 |
|
| 63 |
$wkit_settings_panel = get_option( 'wkit_settings_panel', false ); |
| 64 |
if ( empty( $wkit_settings_panel ) ) { |
| 65 |
$settings_options = array( |
| 66 |
'builder' => true, |
| 67 |
'template' => true, |
| 68 |
'gutenberg_builder' => true, |
| 69 |
'elementor_builder' => true, |
| 70 |
'bricks_builder' => false, |
| 71 |
'debugger_mode' => false, |
| 72 |
); |
| 73 |
|
| 74 |
add_option( 'wkit_settings_panel', $settings_options ); |
| 75 |
} |
| 76 |
|
| 77 |
$wkit_builder = get_option( 'wkit_builder', false ); |
| 78 |
if ( empty( $wkit_builder ) ) { |
| 79 |
add_option( 'wkit_builder', array( 'WDesignKit' ), '', 'yes' ); |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* Check Error and Get Response Body Data |
| 85 |
* |
| 86 |
* @param string $super_global it is main party of array & file. |
| 87 |
* @param string $key it is static value for file and array key. |
| 88 |
* */ |
| 89 |
public static function get_super_global_value( $super_global, $key ) { |
| 90 |
if ( ! isset( $super_global[ $key ] ) ) { |
| 91 |
return null; |
| 92 |
} |
| 93 |
|
| 94 |
if ( $_FILES === $super_global ) { |
| 95 |
$super_global[ $key ]['name'] = sanitize_file_name( $super_global[ $key ]['name'] ); |
| 96 |
|
| 97 |
return $super_global[ $key ]; |
| 98 |
} |
| 99 |
|
| 100 |
return wp_kses_post_deep( wp_unslash( $super_global[ $key ] ) ); |
| 101 |
} |
| 102 |
|
| 103 |
/** |
| 104 |
* Check Error and Get Response Body Data |
| 105 |
* |
| 106 |
* @param string $data it is main party of array. |
| 107 |
* @param string $key it is static value for file and array key. |
| 108 |
* */ |
| 109 |
public static function sanitize_array_recursive( $data, $key ) { |
| 110 |
|
| 111 |
if ( is_array( $data[ $key ] ) ) { |
| 112 |
foreach ( $data[ $key ] as $index => $value ) { |
| 113 |
$data[ $index ] = self::sanitize_array_recursive( $value ); |
| 114 |
} |
| 115 |
|
| 116 |
return $data; |
| 117 |
} |
| 118 |
|
| 119 |
return sanitize_text_field( $data[ $key ] ); |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
Wdkit_Data_Hooks::get_instance(); |
| 124 |
} |