Plugin Directory

Changeset 1424465


Ignore:
Timestamp:
05/26/2016 04:12:30 AM (10 years ago)
Author:
RylanH
Message:

Fixing insecure sites not being able to insert media

Location:
storyform/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • storyform/trunk/class-storyform-editor-page.php

    r1404257 r1424465  
    2020        add_action( 'wp_ajax_storyform_get_publish_url', array( $this, 'storyform_get_publish_url' ) );
    2121        add_action( 'wp_ajax_storyform_delete_post', array( $this, 'storyform_delete_post' ) );
    22         add_action( 'wp_ajax_storyform_get_post_types', array( $this, 'storyform_get_post_types' ) );   
     22        add_action( 'wp_ajax_storyform_get_post_types', array( $this, 'storyform_get_post_types' ) );
    2323        add_action( 'wp_ajax_storyform_get_media_sizes', array( $this, 'storyform_get_media_sizes' ) );
    24         add_action( 'wp_ajax_storyform_redirect_admin_edit', array( $this, 'storyform_redirect_admin_edit' ) ); 
     24        add_action( 'wp_ajax_storyform_redirect_admin_edit', array( $this, 'storyform_redirect_admin_edit' ) );
    2525    }
    2626
     
    4141
    4242        add_submenu_page(
    43             'storyform-editor', 
    44             'Add new Storyform', 
    45             'Add new', 
    46             'publish_posts', 
     43            'storyform-editor',
     44            'Add new Storyform',
     45            'Add new',
     46            'publish_posts',
    4747            'storyform-editor'
    4848        );
    4949
    5050        add_submenu_page(
    51             null, 
    52             'Publish post', 
    53             'Publish post', 
    54             'publish_posts', 
     51            null,
     52            'Publish post',
     53            'Publish post',
     54            'publish_posts',
    5555            'storyform-publish-post',
    5656            array( $this, 'storyform_publish_post' )
     
    7474        if( $remove && $post_id ){
    7575            if ( ! wp_verify_nonce( $nonce, 'storyform-post-nonce' ) ) {
    76                 die( 'Invalid Nonce' ); 
     76                die( 'Invalid Nonce' );
    7777            }
    78             Storyform_Options::get_instance()->delete_template_for_post( $post_id );   
     78            Storyform_Options::get_instance()->delete_template_for_post( $post_id );
    7979            wp_redirect( get_edit_post_link( $post_id, '&' ) );
    8080            die();
     
    106106
    107107        $ajax_nonce = wp_create_nonce( "storyform-post-nonce" );
    108        
    109         $hostname = Storyform_API::get_instance()->get_secure_hostname();
     108
     109        $hostname = Storyform_API::get_instance()->get_hostname();
    110110
    111111        $preview = Storyform_Options::get_instance()->get_preview_next_version();
     
    122122            $options = Storyform_Options::get_instance();
    123123            if( !$options->get_template_for_post( $post_id ) ){
    124                 $options->update_template_for_post( $post_id, 'Puget' );   
     124                $options->update_template_for_post( $post_id, 'Puget' );
    125125            }
    126126
     
    132132            $url .= '&preview=true';
    133133        }
    134        
     134
    135135        ?>
    136136        <script>
     
    146146        check_ajax_referer( 'storyform-post-nonce' );
    147147        $id =  sanitize_text_field( $_POST['id'] );
    148        
     148
    149149        // Setup main loop to establish is_single() + is_page() for the_content filters to read
    150150        $wp_query = new WP_Query( array( 'p' => $id, 'post_type' => 'any' ) );
     
    176176        $data['byline'] = get_userdata( $data['post_author'])->display_name;
    177177        $data['display_date'] = get_the_date( get_option('date_format'), $data );
    178        
     178
    179179        echo json_encode( $data );
    180        
    181         die(); 
     180
     181        die();
    182182    }
    183183
     
    193193        add_filter( 'pre_option_use_balanceTags', array( $this, 'avoid_balance_tags' ) );
    194194        kses_remove_filters();
    195        
     195
    196196        $post = array(
    197197          'post_content'   => $content,
     
    201201          'post_excerpt'   => $excerpt,
    202202          'post_type'      => $post_type,
    203         ); 
     203        );
    204204        $ID = wp_insert_post( $post );
    205205
     
    208208        $options->update_template_for_post( $ID, $template );
    209209        if( $horizontal ){
    210             $options->update_horizontal_for_post( $ID, $horizontal );       
     210            $options->update_horizontal_for_post( $ID, $horizontal );
    211211        }
    212212
     
    245245            if( count( $revisions ) > 4 ){
    246246                for( $i = 4; $i < count( $revisions ); $i++ ){
    247                     wp_delete_post( $revisions[ $i ]->ID ); 
     247                    wp_delete_post( $revisions[ $i ]->ID );
    248248                }
    249249
     
    254254                $post['post_title']     = $revision['post_title'];
    255255                $post['post_excerpt']   = $revision['post_excerpt'];
    256             } 
     256            }
    257257
    258258        } else {
     
    271271        if( isset( $_POST['post_type'] )){
    272272            $post['post_type'] = sanitize_text_field( $_POST['post_type'] );
    273         } 
     273        }
    274274
    275275        if( isset( $post['ID'] ) ){
     
    349349    public function storyform_publish_post(){
    350350        if( !isset( $_GET['_wpnonce'] ) || !isset( $_GET['id'] ) || !isset( $_GET['name'] ) ) {
    351             die( 'Invalid parameters. Nonce, id and name required' ); 
     351            die( 'Invalid parameters. Nonce, id and name required' );
    352352        }
    353353
     
    357357
    358358        if ( ! wp_verify_nonce( $nonce, 'storyform-post-nonce' ) ) {
    359             die( 'Invalid Nonce' ); 
    360         }       
     359            die( 'Invalid Nonce' );
     360        }
    361361
    362362        add_filter( 'pre_option_use_balanceTags', array( $this, 'avoid_balance_tags' ) );
     
    366366        $post_obj = get_post( $id );
    367367        if( !$post_obj ){
    368             die( 'Cannot find post with id: ' . $id ); 
     368            die( 'Cannot find post with id: ' . $id );
    369369        }
    370370
     
    397397            die( 'Unable to update post with changes' );
    398398        }
    399        
     399
    400400        wp_publish_post( $id );
    401401
     
    420420    public function storyform_get_post_types(){
    421421        check_ajax_referer( 'storyform-post-nonce' );
    422         $post_types = get_post_types(); 
     422        $post_types = get_post_types();
    423423        $types = array();
    424424        $ignore = array( 'attachment', 'revision', 'nav_menu_item' );
     
    440440            $img_url = wp_get_attachment_url( $id );
    441441            $img_url_basename = wp_basename( $img_url );
    442            
     442
    443443            $sizes = array();
    444444
     
    448448            }
    449449            $fullAspect = $full[1] / $full[2];
    450            
     450
    451451            // VIP doesn't store multiple sizes, it generates them on the fly, so we just generate URLs
    452452            if( function_exists( 'wpcom_vip_get_resized_attachment_url' ) ){
    453                 $szs = array( 
     453                $szs = array(
    454454                    array( 'width' => 320,  'height' => round( 320 / $fullAspect ) ),
    455455                    array( 'width' => 667,  'height' => round( 667 / $fullAspect ) ),
     
    476476
    477477                        // Only use scaled images not cropped images (pixel rounding can occur, thus the 0.01)
    478                         if( $aspect > $fullAspect + 0.01 || $aspect < $fullAspect - 0.01) { 
     478                        if( $aspect > $fullAspect + 0.01 || $aspect < $fullAspect - 0.01) {
    479479                            continue;
    480480                        }
    481                        
     481
    482482                        array_push( $sizes, array( 'url' => $url, 'width' => $width, 'height' => $height ) );
    483483                    }
     
    486486            $id_sizes[$id] = $sizes;
    487487        }
    488        
     488
    489489
    490490        echo json_encode( $id_sizes );
     
    499499            'url' => get_edit_post_link( $id, '&' )
    500500        );
    501        
     501
    502502
    503503        echo json_encode( $array );
  • storyform/trunk/class-storyform-settings-page.php

    r1404257 r1424465  
    274274                StoryformWidgets.init({
    275275                    environment: '<?php echo $storyform_plugin_identifier . " wordpress-" . $wp_version ?>',
    276                     hostname: '<?php echo Storyform_Api::get_instance()->get_secure_hostname()?>'
     276                    hostname: '<?php echo Storyform_Api::get_instance()->get_hostname()?>'
    277277                }).then(function(){
    278278                    var dashboard = StoryformWidgets.getControlForElement(document.querySelector('.storyform-settings-dashboard'));
    279279                    dashboard.addSite(site);
    280280                    jQuery.post(ajaxurl, { action : 'storyform_save_site_registered', _ajax_nonce: '<?php echo $ajax_nonce_site_registered; ?>' });
    281                    
     281
    282282
    283283                    var getAppKey = function(){
     
    293293                                });
    294294                            }
    295                         }); 
     295                        });
    296296                    }
    297297
    298298                    dashboard.addEventListener('refresh', getAppKey, false);
    299299                    getAppKey();
    300                    
     300
    301301                });
    302302
     
    316316        $appKey =  sanitize_text_field( $_POST['app_key'] );
    317317        Storyform_Options::get_instance()->update_application_key( $appKey );
    318         die(); 
     318        die();
    319319    }
    320320
     
    326326        check_ajax_referer( 'storyform-site-registered-save-nonce' );
    327327        Storyform_Options::get_instance()->update_site_registered( '1' );
    328         die(); 
     328        die();
    329329    }
    330330
     
    336336        check_ajax_referer( 'storyform-reset-all-nonce' );
    337337        Storyform_Options::get_instance()->reset_all();
    338         die(); 
     338        die();
    339339    }
    340340
     
    344344    public function print_section_navigation()
    345345    {
    346        
     346
    347347        $options = Storyform_Options::get_instance();
    348348        $width = $options->get_navigation_width();
     
    369369    <div class="storyform-navigation clearfix">
    370370        <div class="storyform-navigation-settings clearfix">
    371             <div class="storyform-navigation-group storyform-logo-color">   
     371            <div class="storyform-navigation-group storyform-logo-color">
    372372                <div class="storyform-input-label">Logo</div>
    373373                <div class="storyform-input-group">
     
    375375                    <a href="#" class="button storyform-select-logo" data-uploader-title="Select logo" data-uploader-button-text="Select" title="Add Media">Select logo</a>
    376376                </div>
    377                
     377
    378378                <div class="storyform-input-label">Colors</div>
    379379                <div class="storyform-input-group storyform-navigation-color">
     
    383383                </div>
    384384            </div>
    385            
    386             <div class="storyform-navigation-group">   
     385
     386            <div class="storyform-navigation-group">
    387387                <div class="storyform-input-label">Width</div>
    388388                <div class="storyform-input-group">
     
    390390                    <label><input type="radio" id="storyform-navigation-width-full" class="storyform-navigation-width" name="storyform_settings[storyform_navigation_width]" value="full" <?php echo $width_full ?> />Full width</label>
    391391                </div>
    392    
     392
    393393                <div class="storyform-input-label">Links</div>
    394394                <div class="storyform-input-group">
     
    406406                </div>
    407407            </div>
    408                
    409             <div class="storyform-navigation-group">   
     408
     409            <div class="storyform-navigation-group">
    410410                <div class="storyform-input-label">Border bottom</div>
    411411                <div class="storyform-input-group">
     
    424424                    <input type="checkbox" id="storyform-navigation-title" class="storyform-navigation-title" name="storyform_settings[storyform_navigation_title]" <?php echo $title ?> /><label for="storyform-navigation-title">Display post title</label>
    425425                </div>
    426                
     426
    427427                <div class="storyform-input-label">Controls</div>
    428428                <div class="storyform-input-group">
     
    437437            </div>
    438438        </div>
    439        
     439
    440440        <div class="storyform-navigation-preview">
    441441            <div class="storyform-browser">
     
    509509                    %s
    510510                </label>
    511                 </div>', 
     511                </div>',
    512512                esc_attr( $handle ),
    513513                esc_attr( $handle ),
    514514                $selected ? 'checked' : '',
    515                 $description 
     515                $description
    516516            );
    517517        }
     
    571571                    %s
    572572                </label>
    573                 </div>', 
     573                </div>',
    574574                esc_attr( $function['name'] ),
    575575                esc_attr( $function['name'] ),
    576576                $function['selected'] ? 'checked' : '',
    577                 $description 
     577                $description
    578578            );
    579579        }
     
    593593            var storyformAjaxNonce = '<?php echo $ajax_nonce; ?>';
    594594        </script>
    595         <?php   
     595        <?php
    596596    }
    597597
     
    616616                $refFunc = new ReflectionClass( $object_parts[0] );
    617617            } else {
    618                 $refFunc = new ReflectionFunction( $id );   
     618                $refFunc = new ReflectionFunction( $id );
    619619            }
    620620        } catch (Exception $e){
     
    630630            return 'WordPress';
    631631        }
    632        
     632
    633633        return $plugin_dir;
    634634    }
  • storyform/trunk/config.php

    r1404257 r1424465  
    2424            return '//static.storyform.co';
    2525        }
    26     }
    27    
    28     function get_secure_hostname(){
    29         return 'https://storyform.co';
    3026    }
    3127
     
    5652            $version = $this->version;
    5753        }
    58         return $this->get_static_hostname() . '/v' . $version . '/js/scroll-analytics.js';   
     54        return $this->get_static_hostname() . '/v' . $version . '/js/scroll-analytics.js';
    5955    }
    6056
  • storyform/trunk/storyform.php

    r1404257 r1424465  
    55Plugin Name:  Storyform
    66Plugin URI:   http://storyform.co/docs/wordpress
    7 Version:      0.6.13
     7Version:      0.6.14
    88Description:  Plugin to enable Storyform on select posts. Works with both SEO and non-SEO permalinks.
    99Author:       Storyform
     
    1313
    1414global $storyform_version;
    15 $storyform_version = '0.6.13'; // The plugin version
     15$storyform_version = '0.6.14'; // The plugin version
    1616
    1717require_once( dirname( __FILE__ ) . '/config.php');
     
    3636    load_plugin_textdomain( Storyform_Api::get_instance()->get_textdomain(), false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    3737}
    38 add_action( 'init', 'storyform_init' ); 
     38add_action( 'init', 'storyform_init' );
    3939
    4040Storyform_Admin_Meta_Box::init();
     
    5151    if( Storyform::template_in_use() ) {
    5252        add_theme_support( 'automatic-feed-links' ); // Add RSS feed links to <head> for posts and comments.
    53         show_admin_bar( false ); 
     53        show_admin_bar( false );
    5454    }
    5555
     
    8181if ( ! function_exists( 'storyform_layout_type' ) ) :
    8282function storyform_layout_type() {
    83     return Storyform_Options::get_instance()->get_layout_type_for_post( get_the_ID() ); 
     83    return Storyform_Options::get_instance()->get_layout_type_for_post( get_the_ID() );
    8484}
    8585endif; // storyform_setup
Note: See TracChangeset for help on using the changeset viewer.