= 2 ) ? '
'. $list['title'] .'
' : '';
foreach ( $list['icons'] as $icon ) {
echo '';
}
}
} else {
echo ''. esc_html__( 'No data provided by developer', 'bittumb' ) .'
';
}
wp_send_json_success( array( 'content' => ob_get_clean() ) );
} else {
wp_send_json_error( array( 'error' => esc_html__( 'Error: Nonce verification has failed. Please try again.', 'bittumb' ) ) );
}
}
add_action( 'wp_ajax_csf-get-icons', 'csf_get_icons' );
}
/**
*
* Export
*
* @since 1.0.0
* @version 1.0.0
*
*/
if( ! function_exists( 'csf_export' ) ) {
function csf_export() {
if( ! empty( $_GET['export'] ) && ! empty( $_GET['nonce'] ) && wp_verify_nonce( $_GET['nonce'], 'csf_backup_nonce' ) ) {
header('Content-Type: application/json');
header('Content-disposition: attachment; filename=backup-'. gmdate( 'd-m-Y' ) .'.json');
header('Content-Transfer-Encoding: binary');
header('Pragma: no-cache');
header('Expires: 0');
echo json_encode( get_option( wp_unslash( $_GET['export'] ) ) );
}
die();
}
add_action( 'wp_ajax_csf-export', 'csf_export' );
}
/**
*
* Import Ajax
*
* @since 1.0.0
* @version 1.0.0
*
*/
if( ! function_exists( 'csf_import_ajax' ) ) {
function csf_import_ajax() {
if( ! empty( $_POST['import_data'] ) && ! empty( $_POST['unique'] ) && ! empty( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'csf_backup_nonce' ) ) {
$import_data = json_decode( wp_unslash( trim( $_POST['import_data'] ) ), true );
if( is_array( $import_data ) ) {
update_option( wp_unslash( $_POST['unique'] ), wp_unslash( $import_data ) );
wp_send_json_success();
}
}
wp_send_json_error( array( 'error' => esc_html__( 'Error: Nonce verification has failed. Please try again.', 'bittumb' ) ) );
}
add_action( 'wp_ajax_csf-import', 'csf_import_ajax' );
}
/**
*
* Reset Ajax
*
* @since 1.0.0
* @version 1.0.0
*
*/
if( ! function_exists( 'csf_reset_ajax' ) ) {
function csf_reset_ajax() {
if( ! empty( $_POST['unique'] ) && ! empty( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'csf_backup_nonce' ) ) {
delete_option( wp_unslash( $_POST['unique'] ) );
wp_send_json_success();
}
wp_send_json_error( array( 'error' => esc_html__( 'Error: Nonce verification has failed. Please try again.', 'bittumb' ) ) );
}
add_action( 'wp_ajax_csf-reset', 'csf_reset_ajax' );
}
/**
*
* Chosen Ajax
*
* @since 1.0.0
* @version 1.0.0
*
*/
if( ! function_exists( 'csf_chosen_ajax' ) ) {
function csf_chosen_ajax() {
if( ! empty( $_POST['term'] ) && ! empty( $_POST['type'] ) && ! empty( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'csf_chosen_ajax_nonce' ) ) {
$capability = apply_filters( 'csf_chosen_ajax_capability', 'manage_options' );
if( current_user_can( $capability ) ) {
$type = $_POST['type'];
$term = $_POST['term'];
$query_args = ( ! empty( $_POST['query_args'] ) ) ? $_POST['query_args'] : array();
$options = CSF_Fields::field_data( $type, $term, $query_args );
wp_send_json_success( $options );
} else {
wp_send_json_error( array( 'error' => esc_html__( 'You do not have required permissions to access.', 'bittumb' ) ) );
}
} else {
wp_send_json_error( array( 'error' => esc_html__( 'Error: Nonce verification has failed. Please try again.', 'bittumb' ) ) );
}
}
add_action( 'wp_ajax_csf-chosen', 'csf_chosen_ajax' );
}
/**
*
* Set icons for wp dialog
*
* @since 1.0.0
* @version 1.0.0
*
*/
if( ! function_exists( 'csf_set_icons' ) ) {
function csf_set_icons() {
?>