function wfu_ajax_action_edit_shortcode() { if (!current_user_can('manage_options')) { die; } if (!isset($_POST['upload_id']) || !isset($_POST['post_id']) || !isset($_POST['post_hash']) || !isset($_POST['shortcode_tag'])) { die; } //sanitize parameters $upload_id = sanitize_text_field($_POST['upload_id']); $post_id = wfu_sanitize_int($_POST['post_id']); $post_hash = wfu_sanitize_code($_POST['post_hash']); $shortcode_tag = wfu_sanitize_tag($_POST['shortcode_tag']); $data['post_id'] = $post_id; $data['post_hash'] = $post_hash; if (wfu_check_edit_shortcode($data)) { $post = get_post($data['post_id']); //get default value for uploadid $defs = wfu_attribute_definitions(); $default = ""; foreach ($defs as $key => $def) { if ($def['attribute'] == 'uploadid') { $default = $def['value']; break; } } //get page shortcodes $wfu_shortcodes = wfu_get_content_shortcodes($post, $shortcode_tag); //find the shortcodes' uploadid and the correct one $validkey = -1; foreach ($wfu_shortcodes as $key => $data) { $shortcode = trim(substr($data['shortcode'], strlen('[' . $shortcode_tag), -1)); $shortcode_attrs = wfu_shortcode_string_to_array($shortcode); if (array_key_exists('uploadid', $shortcode_attrs)) { $uploadid = $shortcode_attrs['uploadid']; } else { $uploadid = $default; } if ($uploadid == $upload_id) { $validkey = $key; break; } } if ($validkey == -1) { die; } $data_enc = wfu_safe_store_shortcode_data(wfu_encode_array_to_string($wfu_shortcodes[$validkey])); $url = site_url() . '/wp-admin/options-general.php?page=wordpress_file_upload&tag=' . $shortcode_tag . '&action=edit_shortcode&data=' . $data_enc; die("wfu_edit_shortcode:success:" . wfu_plugin_encode_string($url)); } else { die("wfu_edit_shortcode:check_page_obsolete:" . WFU_ERROR_PAGE_OBSOLETE); } }
function wfu_ajax_action_get_historylog_page() { if (!isset($_POST['token']) || !isset($_POST['page'])) { die; } check_ajax_referer('wfu-historylog-page', 'token'); if (!current_user_can('manage_options')) { die; } if (WFU_HISTORYLOG_TABLE_MAXROWS <= 0) { die; } $page = wfu_sanitize_int($_POST['page']); $rows = wfu_view_log($page, true); die('wfu_historylog_page_success:' . wfu_plugin_encode_string($rows)); }