function iva_import_ob() { global $wpdb; $ob_import_filename = isset($_POST['ob_import']) ? $_POST['ob_import'] : ''; $theme_options_txt = get_template_directory_uri() . '/framework/admin/options_backup/' . $ob_import_filename; if (isset($theme_options_txt)) { global $iva_of_options; $theme_options_txt = wp_remote_get($theme_options_txt); $options_data = unserialize(base64_decode($theme_options_txt['body'])); update_option('atp_template_option_values', $options_data); // update theme options if (count($options_data) > 1) { update_option_values($iva_of_options, $options_data); } } exit; }
function atp_ajax_callback() { global $wpdb, $iva_options; // this is how you get access to the database $save_type = $_POST['type']; // Save type = U P L A O D if ($save_type == 'upload') { $clickedID = $_POST['data']; // Acts as the name $filename = $_FILES[$clickedID]; $filename['name'] = preg_replace('/[^a-zA-Z0-9._\\-]/', '', $filename['name']); $override['test_form'] = false; $override['action'] = 'wp_handle_upload'; $uploaded_file = wp_handle_upload($filename, $override); $upload_tracking[] = $clickedID; update_option($clickedID, $uploaded_file['url']); if (!empty($uploaded_file['error'])) { echo 'Upload Error: ' . $uploaded_file['error']; } else { echo $uploaded_file['url']; } // Response exit; } elseif ($save_type == 'image_reset') { $id = $_POST['data']; // Acts as the name //global $wpdb; $query = "DELETE FROM {$wpdb->options} WHERE option_name LIKE '{$id}'"; $wpdb->query($query); } elseif ($save_type == 'advance_options') { $data = $_POST['data']; parse_str($data, $output); /** * check whether import process initiated, * if yes then pull the values from atp_template_option_values in submitted form */ if ($output['atp_template_option_values'] != '') { $output = unserialize(base64_decode($output['atp_template_option_values'])); update_option('atp_template_option_values', $output); //updates the atp_template_option_values option value in wp_options table } if (count($output) > 1) { update_option_values($iva_options, $output); } } elseif ($save_type == 'options' or $save_type == 'framework') { $data = $_POST['data']; $import_process_initiated = false; //to identify whether saving/updating the settings, this becomes true when action performed through advance options parse_str($data, $output); update_option_values($iva_options, $output); $output['atp_template_option_values'] = ''; //remove the content of atp_template_option_values update_option('atp_template_option_values', $output); //updates the atp_template_option_values option value die; } }
} else { delete_post_meta($post['ID'], 'download'); } return $post; } add_filter("attachment_fields_to_save", "atp_media_save_custom_fields", null, 2); } /*** * code that executes when theme is being activated */ if (is_admin() && isset($_GET['activated']) && $pagenow == 'themes.php' && get_option('atp_default_template_option_values', 'defaultoptionsnotexists') == 'defaultoptionsnotexists') { $default_option_values = ''; //add default values for the theme options add_option('atp_default_template_option_values', $default_option_values, '', 'yes'); atp_options(); update_option_values($iva_options, unserialize(base64_decode($default_option_values))); } $option_posts_per_page = get_option('posts_per_page'); if (!function_exists('iva_modify_posts_per_page')) { //add_action( 'init', 'iva_modify_posts_per_page', 0); function iva_modify_posts_per_page() { add_filter('option_posts_per_page', 'my_option_posts_per_page'); } } if (!function_exists('my_option_posts_per_page')) { function my_option_posts_per_page($value) { global $option_posts_per_page; if (is_tax('artist_cat') || is_tax('genre') || is_tax('label') || is_tax('events_cat')) { return 4;