function ninja_forms_feditor_load_js_css() { global $post; if (is_object($post)) { // Grab our settings from the get_settings function. It will return false if the user is unable to edit. $settings = ninja_forms_get_post_edit_settings($post->ID); } else { $settings = false; } if ($settings) { ninja_forms_feditor_display_js(''); ninja_forms_feditor_display_css(''); } }
function ninja_forms_process_post_delete() { global $post; if (isset($_REQUEST['ninja_forms_post_id']) and $_REQUEST['ninja_forms_post_id'] != '') { $post_id = $_REQUEST['ninja_forms_post_id']; } else { $post_id = $post->ID; } if (isset($_REQUEST['ninja_forms_redirect']) and $_REQUEST['ninja_forms_redirect'] != '') { $redirect = $_REQUEST['ninja_forms_redirect']; } else { $redirect = get_option('siteurl'); } $settings = ninja_forms_get_post_edit_settings($post_id); if ($settings['delete']) { do_action('ninja_forms_delete_post', $post_id); wp_delete_post($post_id); wp_redirect($redirect); exit; } }
function ninja_forms_check_post_edit() { global $post, $ninja_forms_append_page_form_id; /* echo "<pre>"; print_r( get_post_meta( $post->ID, 'your_image', true ) ); echo "</pre>"; */ // Make sure that we're on a single post or page and not in the admin. if (!is_admin() and (is_single() or is_page())) { // Grab our settings from the get_settings function. It will return false if the user is unable to edit. $settings = ninja_forms_get_post_edit_settings($post->ID); if ($settings) { // Check to see if the user has already clicked on the edit link. if (isset($_REQUEST['_ninja_forms_action']) and $_REQUEST['_ninja_forms_action'] == 'edit' and isset($_REQUEST['ninja_forms_post_id']) and $_REQUEST['ninja_forms_post_id'] == $post->ID) { $plugin_settings = get_option('ninja_forms_settings'); $feditor_settings = $plugin_settings['feditor']; $default_post_editor = $feditor_settings['_post_editor']; $default_page_editor = $feditor_settings['_page_editor']; // Get the form_id of our editor. If the default editors are selected, get the form_id of those. if ($settings['editor'] == '_post_editor') { $form_id = $default_post_editor; } else { if ($settings['editor'] == '_page_editor') { $form_id = $default_page_editor; } else { $form_id = $settings['editor']; } } // Set our global append form_id variable so that the append code knows which form to use. $ninja_forms_append_page_form_id = array($form_id); // Use the ninja_forms_field filter to set the default values of the appropriate fields to their post values. add_filter('ninja_forms_field', 'ninja_forms_feditor_post_default_values', 10, 2); // If we are using the default editors, check to see if any of the options have been disabled. // i.e. Should we be able to edit the title, content, categories, etc. if ($settings['editor'] == '_post_editor' or $settings['editor'] == '_page_editor') { if ($settings['edit_title'] == 1) { // We're editing the title, so clear it. add_filter('the_title', 'ninja_forms_post_clear_title', 10); } else { // We're not editing the title, so remove the title field from the display fields array. add_filter('ninja_forms_display_fields_array', 'ninja_forms_feditor_filter_title_field', 10, 2); } if ($settings['edit_content'] == 1) { // We're editing the content, so clear it. add_filter('the_content', 'ninja_forms_post_clear_content', 10); } else { // We're not editing the content, so remove the content field from the display fields array. add_filter('ninja_forms_display_fields_array', 'ninja_forms_feditor_filter_content_field', 10, 2); } if ($settings['edit_categories'] != 1) { // We're not editing categories, so remove the category field from the display fields array. add_filter('ninja_forms_display_fields_array', 'ninja_forms_feditor_filter_cat_field', 10, 2); } if ($settings['edit_tags'] != 1) { // We're not editing tags, so remove the tags field from the display fields array. add_filter('ninja_forms_display_fields_array', 'ninja_forms_feditor_filter_tags_field', 10, 2); } if ($settings['edit_status'] != 1) { // We're not editing status, so remove the status field from the display fields array. add_filter('ninja_forms_display_fields_array', 'ninja_forms_feditor_filter_status_field', 10, 2); } } else { // We're not using a default editor, so clear the title and post content. add_filter('the_title', 'ninja_forms_post_clear_title', 10); add_filter('the_content', 'ninja_forms_post_clear_content', 10); } // Add the content filter that will append the form to the page. add_filter('the_content', 'ninja_forms_append_to_page', 11); // Add the post ID to the HTML using the before fields hook. add_action('ninja_forms_display_after_fields', 'ninja_forms_add_post_id'); add_action('ninja_forms_display_after_field', 'ninja_forms_feditor_cancel_output'); } else { // We are clear to edit, display the edit link. add_filter('the_content', 'ninja_forms_post_edit_delete_link'); add_filter('edit_post_link', 'ninja_forms_remove_post_edit_link', 9999); } } } }