Created
June 8, 2022 05:40
-
-
Save wolfcoder/9f42f24647c23f32671b65e841ca204f to your computer and use it in GitHub Desktop.
setting class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if( !class_exists ( 'VAP_Settings' ) ) { | |
| class VAP_Settings { | |
| function __construct(){ | |
| add_action( "vap_save_settings", array( $this, "vap_save_settings_func" ), 10 , 1 ); | |
| add_action( 'wp_ajax_vap_setting_dellastsync', array( $this, 'vap_setting_dellastsync' ) ); | |
| } | |
| function vap_display_settings( ) { | |
| if( file_exists( VAP_INCLUDES_DIR . "vap_settings.view.php" ) ) { | |
| include_once( VAP_INCLUDES_DIR . "vap_settings.view.php" ); | |
| } | |
| } | |
| function vap_default_setting_option() { | |
| return array( | |
| 'vap_api_url' => '', | |
| 'vap_api_key' => '', | |
| 'vap_project_id' => '', | |
| 'vap_append_post' => 1, | |
| 'vap_auto_publish' => '', | |
| ); | |
| } | |
| function vap_save_settings_func( $params = array() ) { | |
| if( isset( $params['vap_setting'] ) && $params['vap_setting'] != '') { | |
| unset( $params['vap_setting'] ); | |
| unset( $params['vap_setting_save'] ); | |
| update_option('vap_setting', $params); | |
| $_SESSION['vap_cfg_msg_status'] = true; | |
| $_SESSION['vap_cfg_msg'] = 'Settings updated successfully.'; | |
| } | |
| } | |
| function vap_get_settings_func( ) { | |
| $ncm_default_general_option = $this->vap_default_setting_option(); | |
| $ncm_setting_option = get_option( 'vap_setting' ); | |
| return shortcode_atts( $ncm_default_general_option, $ncm_setting_option ); | |
| } | |
| function vap_setting_dellastsync() { | |
| update_option('vap_lastsync', array( | |
| 'timestamp' => 0, | |
| 'category' => 0, | |
| 'page' => 1, | |
| )); | |
| echo json_encode( array( 'success' => true ) ); | |
| wp_die(); | |
| } | |
| } | |
| global $vap_settings; | |
| $vap_settings = new VAP_Settings(); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment