Plugin Directory

Changeset 1105500


Ignore:
Timestamp:
03/04/2015 10:52:48 PM (11 years ago)
Author:
RylanH
Message:

Hook for swapping out navbar, do not store null post_meta for Storyform and non-Storyform posts

Location:
storyform/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • storyform/trunk/class-storyform-admin-meta-box.php

    r1092850 r1105500  
    5858            </select>
    5959            <div class="storyform-post-options">
    60                 <div class="storyform-input-group">
     60                <div class="storyform-input-group storyform-improve">
    6161                    <progress class="storyform-improve-progress storyform-improve-low" value="1" max="4" ></progress><span class="storyform-improve-text storyform-improve-low"><span class="storyform-improve-count">0</span> post recommendation(s)</span>
    6262                    <ul class="storyform-improve-items">
     
    192192        $template = ( $template == 'pthemedefault' ) ? null: $template;
    193193        $name = sanitize_text_field( strtolower( $_POST['post_name'] ) );
    194         $layout_type = sanitize_text_field( strtolower( $_POST['storyform-layout-type'] ) );
    195         $use_featured_image = $_POST['storyform-use-featured-image'] === 'on';
     194        $layout_type = $template ? sanitize_text_field( strtolower( $_POST['storyform-layout-type'] ) ) : null;
     195        $use_featured_image = $template ? isset( $_POST['storyform-use-featured-image'] ) && $_POST['storyform-use-featured-image'] === 'on' : true;
    196196        $ab = isset( $_POST['storyform-ab'] );
    197197       
  • storyform/trunk/class-storyform-options.php

    r1092850 r1105500  
    4040
    4141    /**
    42      * Gets the Storyform template for a give Post Id or Post name. Id is preferred
    43      *
    44      */
    45     function get_template_for_post( $post_id, $post_name ) {
    46         return get_post_meta( $post_id, $this->meta_name, true );
    47     }
    48 
    49     /**
    5042     * Gets whether template should be Storyform A/B tested
    5143     *
     
    6052     */
    6153    function update_ab_for_post( $post_id, $value ) {
    62         update_post_meta( $post_id, $this->ab_name, $value );
     54        $this->update_post_meta( $post_id, $this->ab_name, $value );
    6355    }
    6456
     
    7264
    7365    /**
     66     * Gets the Storyform template for a give Post Id or Post name. Id is preferred
     67     *
     68     */
     69    function get_template_for_post( $post_id, $post_name ) {
     70        return get_post_meta( $post_id, $this->meta_name, true );
     71    }
     72
     73    /**
    7474     * Sets the options array
    7575     *
    7676     */
    7777    function update_template_for_post( $post_id, $post_name, $template ) {
    78         update_post_meta( $post_id, $this->meta_name, $template );
     78        $this->update_post_meta( $post_id, $this->meta_name, $template );   
    7979    }
    8080
     
    8585    function update_layout_type_for_post( $post_id, $value ){
    8686        if($value !== 'ordered' && $value !== 'slideshow' && $value !== 'freeflow'){
     87            delete_post_meta( $post_id, $this->layout_type_name );
    8788            return false;
    8889        }
     
    110111    function update_use_featured_image_for_post( $post_id, $value ){
    111112        // Invert so our default is true
    112         update_post_meta( $post_id, $this->featured_image_name, !$value );
     113        $this->update_post_meta( $post_id, $this->featured_image_name, !$value );
    113114    }
    114115
     
    142143
    143144    public function update_crop_area_for_attachment( $attachment_id, $value ){
    144         update_post_meta( $attachment_id, $this->crop_name, $value);
     145        $this->update_post_meta( $attachment_id, $this->crop_name, $value);
    145146    }
    146147
     
    150151
    151152    public function update_caption_area_for_attachment( $attachment_id, $value ){
    152         update_post_meta( $attachment_id, 'storyform_text_overlay_areas', $value);
     153        $this->update_post_meta( $attachment_id, 'storyform_text_overlay_areas', $value);
    153154    }
    154155
     
    501502        return $functions;
    502503    }
     504
     505    protected function update_post_meta( $post_id, $meta_key, $meta_value ){
     506        if( !$meta_value ){
     507            delete_post_meta( $post_id, $meta_key );
     508        } else {
     509            update_post_meta( $post_id, $meta_key, $meta_value );
     510        }
     511    }
    503512}
  • storyform/trunk/class-storyform.php

    r1095524 r1105500  
    100100    }
    101101
     102    /**
     103     * Loads our navbar template and allows for it to be overridden.
     104     *
     105     */
     106    public static function navbar_template() {
     107        $navbar_template = dirname( __FILE__ ) . '/navbar.php';
     108        /**
     109         * Filter the path to the navbar template file used for the navbar
     110         *
     111         *
     112         * @param string $navbar_template The path to the navbar template file.
     113         */
     114        $include = apply_filters( 'storyform_navbar_template', $navbar_template );
     115        if( file_exists( $include ) ){
     116            require ( $include );
     117        } else {
     118            require( dirname( __FILE__ ) . '/theme/navbar.php' );   
     119        }
     120    }
     121
    102122
    103123    /**
  • storyform/trunk/media/storyform-media.js

    r1092850 r1105500  
    140140    }
    141141    function checkImprovements(){
     142        if(!jQuery('.storyform-improve').length){
     143            return;
     144        }
     145
    142146        var items = 0;
    143147       
  • storyform/trunk/theme/single-storyform.php

    r1052107 r1105500  
    6161           
    6262    </article>
    63     <?php require( dirname( __FILE__ ) . '/navbar.php' ); ?>
     63    <?php Storyform::navbar_template() ?>
    6464    <div class="primary-content">
    6565        <div class="magazine" data-win-control="Controls.FlipView">
Note: See TracChangeset for help on using the changeset viewer.