Plugin Directory

Changeset 875742


Ignore:
Timestamp:
03/15/2014 02:18:55 AM (12 years ago)
Author:
somatic
Message:

new metabox button data "save-back" option which redirects back to referring page immediately after save

File:
1 edited

Legend:

Unmodified
Added
Removed
  • somatic-framework/trunk/inc/somaMetaboxes.php

    r790352 r875742  
    77        add_action( 'add_meta_boxes_post', array(__CLASS__, 'add_boxes'), 10, 1 );      // use our somatic metabox rendering for core post type
    88        add_action( 'add_meta_boxes_page', array(__CLASS__, 'add_boxes'), 10, 1 );      // use our somatic metabox rendering for core page type
     9        add_filter( 'redirect_post_location', array(__CLASS__, 'redirect_post_location' ), 20, 2 );
    910    }
    1011
     
    1415    }
    1516
     17    // modify redirect behavior after post saving
     18    function redirect_post_location($location, $pid) {
     19        if (soma_fetch_index($_POST, 'save_and_go_back')) {
     20            $location = soma_fetch_index($_POST, 'referredby');
     21        }
     22        return $location;
     23    }
    1624
    1725    static $data = array();             // container for other plugins and themes to store custom metabox and field data - SHOULD WE STORE THIS IN THE DB INSTEAD???
     
    8492    id          - (when data is taxonomy, this id must match the taxonomy slug!)
    8593    type        - (see below)
    86     data        - meta, taxonomy, core, p2p, attachment, [save, link (only buttons)]
     94    data        - meta, taxonomy, core, p2p, attachment, [save, save-back, link (only buttons)]
    8795    options     - array of name => value pairs
    8896    once        - only allows data to be set one time, then becomes readonly
     
    10041012                // ----------------------------------------------------------------------------------------------------------------------------- //
    10051013                case 'button':
    1006                     if ($field['data'] == 'save') {
     1014                    if ($field['data'] == ( 'save' || 'save-back' ) ) {
    10071015                        if ($meta_box['always-publish'] || $meta_box['publish']) {
    10081016                            echo '<input type="hidden" name="post_status" id="post_status" value="publish" />';
     1017                        }
     1018                        if ($field['data'] == 'save-back') {
     1019                            echo '<input type="hidden" name="save_and_go_back" value="1">';                                     // additional var to redirect back to referring page, detected by redirect_post_location() function
    10091020                        }
    10101021                        submit_button( $field['options']['label'], 'clicker', 'save', false, array( 'id' => $field["id"]));     // outputs generic submit button
Note: See TracChangeset for help on using the changeset viewer.