function wfu_ajax_action_save_shortcode() { if (!current_user_can('manage_options')) { die; } if (!isset($_POST['shortcode']) || !isset($_POST['shortcode_original']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_position']) || !isset($_POST['shortcode_tag'])) { die; } //sanitize parameters $shortcode = wfu_sanitize_code($_POST['shortcode']); $shortcode_original = wfu_sanitize_code($_POST['shortcode_original']); $post_id = wfu_sanitize_int($_POST['post_id']); $post_hash = wfu_sanitize_code($_POST['post_hash']); $shortcode_position = wfu_sanitize_int($_POST['shortcode_position']); $shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']); if ($_POST['post_id'] == "") { die; } else { $data['post_id'] = $post_id; $data['post_hash'] = $post_hash; $data['shortcode'] = wfu_plugin_decode_string($shortcode_original); $data['position'] = $shortcode_position; if (!wfu_check_edit_shortcode($data)) { die("wfu_save_shortcode:fail:post_modified"); } else { $new_shortcode = "[" . $shortcode_tag . " " . wfu_plugin_decode_string($shortcode) . "]"; if (wfu_replace_shortcode($data, $new_shortcode)) { $post = get_post($post_id); $hash = hash('md5', $post->post_content); die("wfu_save_shortcode:success:" . $hash); } else { die("wfu_save_shortcode:fail:post_update_failed"); } } } }
function wfu_ajax_action_save_shortcode() { if (!current_user_can('manage_options')) { die; } if (!isset($_POST['shortcode']) || !isset($_POST['shortcode_original']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_position']) || !isset($_POST['shortcode_tag']) || !isset($_POST['widget_id'])) { die; } //sanitize parameters $shortcode = wfu_sanitize_code($_POST['shortcode']); $shortcode_original = wfu_sanitize_code($_POST['shortcode_original']); $post_id = wfu_sanitize_int($_POST['post_id']); $post_hash = wfu_sanitize_code($_POST['post_hash']); $shortcode_position = wfu_sanitize_int($_POST['shortcode_position']); $shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']); $widget_id = sanitize_text_field($_POST['widget_id']); if ($post_id == "" && $widget_id == "") { die; } else { $data['post_id'] = $post_id; $data['post_hash'] = $post_hash; $data['shortcode'] = wfu_plugin_decode_string($shortcode_original); $data['position'] = $shortcode_position; if ($post_id != "" && !wfu_check_edit_shortcode($data)) { die("wfu_save_shortcode:fail:post_modified"); } else { if ($widget_id == "") { $new_shortcode = "[" . $shortcode_tag . " " . wfu_plugin_decode_string($shortcode) . "]"; if (wfu_replace_shortcode($data, $new_shortcode)) { $post = get_post($post_id); $hash = hash('md5', $post->post_content); die("wfu_save_shortcode:success:" . $hash); } else { die("wfu_save_shortcode:fail:post_update_failed"); } } else { $widget_obj = wfu_get_widget_obj_from_id($widget_id); if ($widget_obj === false) { die("wfu_save_shortcode:fail:post_update_failed"); } $widget_sidebar = is_active_widget(false, $widget_id, "wordpress_file_upload_widget"); if (!$widget_sidebar) { die("wfu_save_shortcode:fail:post_update_failed"); } $widget_obj->update_external(wfu_plugin_decode_string($shortcode)); $hash = $data['post_hash']; die("wfu_save_shortcode:success:" . $hash); } } } }
function wfu_delete_shortcode($data) { //check if user is allowed to perform this action if (!current_user_can('manage_options')) { return false; } $res = true; if (isset($_POST['submit'])) { if ($_POST['submit'] == "Delete") { $res = wfu_replace_shortcode($data, ''); } } return $res; }
function wfu_ajax_action_save_shortcode() { if (!current_user_can('manage_options')) { die; } if (!isset($_POST['shortcode']) || !isset($_POST['shortcode_original']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_position'])) { die; } if ($_POST['post_id'] == "") { $plugin_options = wfu_decode_plugin_options(get_option("wordpress_file_upload_options")); $new_plugin_options['version'] = '1.0'; $new_plugin_options['shortcode'] = $plugin_options['shortcode']; $new_plugin_options['hashfiles'] = $plugin_options['hashfiles']; $new_plugin_options['basedir'] = $plugin_options['basedir']; $encoded_options = wfu_encode_plugin_options($new_plugin_options); update_option("wordpress_file_upload_options", $encoded_options); die("wfu_save_shortcode:success:"); } else { $data['post_id'] = $_POST['post_id']; $data['post_hash'] = $_POST['post_hash']; $data['shortcode'] = wfu_plugin_decode_string($_POST['shortcode_original']); $data['position'] = $_POST['shortcode_position']; if (!wfu_check_edit_shortcode($data)) { die("wfu_save_shortcode:fail:post_modified"); } else { $new_shortcode = "[wordpress_file_upload " . wfu_plugin_decode_string($_POST['shortcode']) . "]"; if (wfu_replace_shortcode($data, $new_shortcode)) { $post = get_post($_POST['post_id']); $hash = hash('md5', $post->post_content); die("wfu_save_shortcode:success:" . $hash); } else { die("wfu_save_shortcode:fail:post_update_failed"); } } } }