Last active
June 4, 2022 13:01
-
-
Save wolfcoder/0f30d530ee204fdc96827706c5de23e8 to your computer and use it in GitHub Desktop.
add_action( 'wp_ajax_vap_setting_dellastsync', array( $this, 'vap_setting_dellastsync' ) ); call function wp admin plugin through ajax jquery https://prnt.sc/zskgPlNPVRu_
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 get_option('vap_lastsync'); | |
| echo json_encode( array( 'success' => true , 'data' => get_option('rentalist_setting')) ); | |
| wp_die(); | |
| } | |
| } | |
| global $vap_settings; | |
| $vap_settings = new VAP_Settings(); | |
| } | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://prnt.sc/zskgPlNPVRu_ call from postman insertinng cookie in header and body form-data ; action -> function to call in wp admin