admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'shopnotify_nonce' ),
)
);
}
/**
* Add admin menu.
*/
public function add_admin_menu() {
add_menu_page(
__( 'ShopNotify', 'shopnotify' ),
__( 'ShopNotify', 'shopnotify' ),
'manage_options',
'shopnotify',
array( $this, 'admin_page' ),
'dashicons-whatsapp',
25
);
add_submenu_page(
'shopnotify',
__( 'Home', 'shopnotify' ),
__( 'Home', 'shopnotify' ),
'manage_options',
'shopnotify',
array( $this, 'admin_page' )
);
add_submenu_page(
'shopnotify',
__( 'Abandoned Carts', 'shopnotify' ),
__( 'Abandoned Carts', 'shopnotify' ),
'manage_options',
'shpn-carts',
array( $this, 'load_abandoned_carts' )
);
add_submenu_page(
'shopnotify',
__( 'Settings', 'shopnotify' ),
__( 'Settings', 'shopnotify' ),
'manage_options',
'shpn-settings',
array( $this, 'load_settings' )
);
add_submenu_page(
'shopnotify',
__( 'Whatsapp Setup', 'shopnotify' ),
__( 'Whatsapp Setup', 'shopnotify' ),
'manage_options',
'shpn-whatsapp-setup',
array( $this, 'load_whatsapp_setup' )
);
add_submenu_page(
'shopnotify',
__( 'Whatsapp Templates', 'shopnotify' ),
__( 'Whatsapp Templates', 'shopnotify' ),
'manage_options',
'shpn-whatsapp-templates',
array( $this, 'load_whatsapp_templates' )
);
}
/**
* Admin page.
*/
public function admin_page() {
?>
user_email;
$site_url = get_site_url();
$feedback_url = 'https://tally.so/r/mOBxja?email=' . $user_email . '&domain=' . $site_url;
?>
Feadback
prepare_items();
$list_table->process_bulk_action();
$nonce = wp_create_nonce( 'shpn_abandoned_carts_nonce' );
$nonce_text = 'nonce=' . $nonce;
$insights = $list_table->get_insights();
?>
'number',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'abandoned_carts_settings',
'shopnotify_first_notification_timeout',
array(
'type' => 'number',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'abandoned_carts_settings',
'shopnotify_second_notification_timeout',
array(
'type' => 'number',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'abandoned_carts_settings',
'shopnotify_third_notification_timeout',
array(
'type' => 'number',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'abandoned_carts_settings',
'shopnotify_delete_cart_after_timeout',
array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'abandoned_carts_settings',
'shopnotify_cart_deletion_timeout',
array(
'type' => 'number',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'license_activation_settings',
'shpn_whatsapp_license_key',
array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'shopnotify_shpn_templates',
'shopnotify_first_shpn_template',
array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'shopnotify_shpn_templates',
'shopnotify_second_shpn_template',
array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
register_setting(
'shopnotify_shpn_templates',
'shopnotify_third_shpn_template',
array(
'type' => 'string',
'sanitize_callback' => 'sanitize_text_field',
'default' => NULL,
)
);
}
/**
* Load Whatsapp setting
*/
public function load_whatsapp_setup() {
$license_key = get_option( 'shpn_whatsapp_license_key', '' );
$license_status = get_option( 'shpn_whatsapp_license_status', 'inactive' );
?>
' . esc_html( $component['text'] ) . '';
} elseif ( 'BODY' === $component['type'] ) {
$preview .= '' . esc_html( $component['text'] ) . '
';
} elseif ( 'BUTTONS' === $component['type'] ) {
$preview .= '';
}
}
$name = wp_get_current_user()->display_name;
$site_name = get_bloginfo( 'name' );
$preview = str_replace( '{{name}}', $name, $preview );
$preview = str_replace( '{{store_name}}', $site_name, $preview );
$previews[ $template['name'] ] = $preview;
}
wp_localize_script( 'shopnotify-script', 'whatsappNotificationTemplates', $previews );
?>
$license_key,
'action' => $license_action,
'moodle_site_url' => get_site_url(), // need to change this to moodle site url.
);
$response = wp_remote_post(
'https://edwp.edwiser.org/wp-json/edwp/v1/license/',
array(
'body' => wp_json_encode( $args ),
'timeout' => 100,
)
);
if ( is_wp_error( $response ) ) {
wp_send_json_error( 'Error: ' . $response->get_error_message() );
}
$response_body = json_decode( wp_remote_retrieve_body( $response ) );
if ( isset( $response_body->activated ) && 1 === (int) $response_body->activated ) {
update_option( 'shpn_whatsapp_license_key', $license_key );
update_option( 'shpn_whatsapp_license_status', 'active' );
wp_send_json_success( 'License activated successfully.' );
} elseif ( isset( $response_body->reset ) && 1 === (int) $response_body->reset ) {
update_option( 'shpn_whatsapp_license_status', 'inactive' );
wp_send_json_success( 'License deactivated successfully.' );
} else {
wp_send_json_error( 'Error: ' . $response_body->error );
}
}
}
}