Plugin Directory

Changeset 1353774


Ignore:
Timestamp:
02/18/2016 10:08:50 PM (10 years ago)
Author:
pagefrog
Message:

bug fixes

Location:
pagefrog/trunk
Files:
5 added
3 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • pagefrog/trunk/README.txt

    r1349446 r1353774  
    218218
    219219== Changelog ==
     220= 1.0.5.1 =
     221*Release Date - February 18, 2016*
     222
     223* Assorted bug fixes
     224
     225
    220226= 1.0.5 =
    221227*Release Date - February 13, 2016*
     
    226232* Included support for facebook ads
    227233
     234
    228235= 1.0.4 =
    229236*Release Date - February 3, 2016*
  • pagefrog/trunk/admin/class-pagefrog-admin.php

    r1349446 r1353774  
    583583    public function pagefrog_set_post_status() {
    584584        if (!isset($_POST['fbia_status']) || !isset($_POST['amp_status']) || !isset($_POST['post_id'])) {
    585             wp_die('You must include both the AMP and Instant Articles status, as well as the post ID');
     585            $response = array(
     586                'status' => 'error',
     587                'message' => 'You must include both the AMP and Instant Articles status, as well as the post ID'
     588            );
     589            wp_send_json( $response );
     590            wp_exit();
    586591        }
    587592
     
    592597        $fbia_status = $_POST['fbia_status'];
    593598        $fbia_status_bool = false;
    594         if ($fbia_status == 'true') {
     599        if ( $fbia_status === 'true' || $fbia_status === true ) {
    595600            $fbia_status_bool = true;
    596         } else if ($fbia_status == 'false') {
     601        } else if ( $fbia_status === 'false' || $fbia_status === false ) {
    597602            $fbia_status_bool = false;
    598603        } else {
    599             wp_die('You must set Instant Articles status to true or false!');
     604            $response = array(
     605                'status' => 'error',
     606                'message' => 'You must set Instant Articles status to true or false!'
     607            );
     608            wp_send_json( $response );
     609            wp_exit();
    600610        }
    601611
     
    603613        $amp_status = $_POST['amp_status'];
    604614        $amp_status_bool = false;
    605         if ($amp_status == 'true') {
    606             $amp_status_bool = true;
    607         } else if ($amp_status == 'false') {
     615        if ( $amp_status === 'true' || $amp_status === true ) {
     616            $amp_status_bool = true && wp_amp_plugin_is_installed() && wp_amp_plugin_is_active();
     617        } else if ( $amp_status === 'false' || $amp_status === false ) {
    608618            $amp_status_bool = false;
    609619        } else {
    610             wp_die('You must set the AMP status to true or false!');
     620            $response = array(
     621                'status' => 'error',
     622                'message' => 'You must set the AMP status to true or false!'
     623            );
     624            wp_send_json( $response );
     625            wp_exit();
    611626        }
    612627
    613628        // save the statuses in the post metadata
    614629        $post_status = new PageFrog_PostStatus( $post_id );
     630
     631        if ( ! $post_status->is_valid_post() ) {
     632            $response = array(
     633                'status' => 'error',
     634                'message' => 'You must pass in a valid post.'
     635            );
     636            wp_send_json( $response );
     637            wp_exit();
     638        }
    615639        $post_status->set_fbia_status( $fbia_status_bool );
    616640        $post_status->set_amp_status( $amp_status_bool );
    617641
    618642        $response = array(
     643            'status' => 'ok',
    619644            'fbia_status' => $post_status->get_fbia_status(),
    620645            'amp_status' => $post_status->get_amp_status(),
     
    622647        );
    623648        wp_send_json( $response );
     649        wp_exit();
    624650    }
    625651
     
    646672        switch( $platform ) {
    647673            case 'amp': {
     674                if ( $enable && ( ! wp_amp_plugin_is_installed() || ! wp_amp_plugin_is_active() ) ) {
     675                    $response = array(
     676                        'status' => 'error',
     677                        'message' => 'You must install the WP Amp plugin before you can activate AMP pages. Please visit the PageFrog setup page to do that.',
     678                    );
     679                    wp_send_json( $response );
     680                    wp_exit();
     681                }
    648682                PageFrog_PostStatus::amp_set_all_published_posts( $enable );
    649683                break;
     
    830864                }
    831865            }
    832             $file = $pagefrog_path . 'admin/pagefrog-amp-template-styles.php';
     866            $file = $pagefrog_path . 'admin/partials/pagefrog-amp-template-styles.php';
    833867        } else if ( 'single' === $type ) {
    834868            $plugins = wp_get_active_and_valid_plugins();
     
    840874                }
    841875            }
    842             $file = $pagefrog_path . 'admin/pagefrog-amp-template-single.php';
     876            $file = $pagefrog_path . 'admin/partials/pagefrog-amp-template-single.php';
     877        } else if ( 'meta-author' === $type ) {
     878            $plugins = wp_get_active_and_valid_plugins();
     879            $pagefrog_path = dirname( plugin_dir_path( __FILE__ ) );
     880
     881            foreach ( $plugins as $plugin ) {
     882                if ( strpos( $plugin, 'pagefrog.php' ) !== false ) {
     883                    $pagefrog_path = plugin_dir_path( $plugin );
     884                }
     885            }
     886            $file = $pagefrog_path . 'admin/partials/pagefrog-amp-template-meta-author.php';
     887        } else if ( 'meta-taxonomy' === $type ) {
     888            $plugins = wp_get_active_and_valid_plugins();
     889            $pagefrog_path = dirname( plugin_dir_path( __FILE__ ) );
     890
     891            foreach ( $plugins as $plugin ) {
     892                if ( strpos( $plugin, 'pagefrog.php' ) !== false ) {
     893                    $pagefrog_path = plugin_dir_path( $plugin );
     894                }
     895            }
     896            $file = $pagefrog_path . 'admin/partials/pagefrog-amp-template-meta-taxonomy.php';
     897        } else if ( 'meta-time' === $type ) {
     898            $plugins = wp_get_active_and_valid_plugins();
     899            $pagefrog_path = dirname( plugin_dir_path( __FILE__ ) );
     900
     901            foreach ( $plugins as $plugin ) {
     902                if ( strpos( $plugin, 'pagefrog.php' ) !== false ) {
     903                    $pagefrog_path = plugin_dir_path( $plugin );
     904                }
     905            }
     906            $file = $pagefrog_path . 'admin/partials/pagefrog-amp-template-meta-time.php';
    843907        }
    844908
     
    910974
    911975function wp_amp_plugin_is_installed() {
     976    if ( isset( $GLOBALS['PRETEND_AMP_WP_IS_INSTALLED'] ) && $GLOBALS['PRETEND_AMP_WP_IS_INSTALLED'] === true ) {
     977        // for testing purposes
     978        return true;
     979    }
    912980    if ( ! function_exists( 'get_plugins' ) ) {
    913981        require_once ABSPATH . 'wp-admin/includes/plugin.php';
     
    918986
    919987function wp_amp_plugin_is_active() {
     988    if ( isset( $GLOBALS['PRETEND_AMP_WP_IS_ACTIVATED'] ) && $GLOBALS['PRETEND_AMP_WP_IS_ACTIVATED'] === true ) {
     989        // for testing purposes
     990        return true;
     991    }
    920992    return function_exists( 'amp_render' );
    921993}
  • pagefrog/trunk/admin/js/pagefrog-change-thickbox-text.js

    r1338828 r1353774  
    55            window.setTimeout(change_text, 500);
    66            jQuery('input[value="Insert into Post"]').attr('value', 'Choose Logo');
     7            jQuery('#tab-type_url').css({
     8              display: 'none'
     9            });
    710        })();
    811    });
  • pagefrog/trunk/admin/js/pagefrog-styling.js

    r1349446 r1353774  
    2020
    2121    // function to catch the uploaded logo
    22     window.send_to_editor = function (html, other_param) {
     22    window.send_to_editor = function (html) {
     23        if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
     24            console.log(html);
     25        }
    2326        var classes = '';
    2427        if (jQuery(html).prop('tagName').toLowerCase() == 'img') {
  • pagefrog/trunk/admin/pagefrog-post-metadata.php

    r1349446 r1353774  
    7474
    7575    /**
     76     * A boolean that indicates whether we are operating on a valid post or a random made-up id.
     77     *
     78     * @since   1.0.4.1
     79     * @access  private
     80     * @var     boolean     $valid_post     Whether or not the post is valid.
     81     */
     82    private $valid_post;
     83
     84
     85    /**
    7686     * Initialize the class and set any necessary properties.
    7787     *
     
    8191    function __construct( $post_id ) {
    8292        $this->post_id = $post_id;
     93        $this->valid_post = get_post_status( $post_id ) !== false;
    8394    }
    8495
     
    120131     */
    121132    public function set_fbia_status( $status ) {
    122         if ($status !== true && $status !== false) {
     133        if ( $status !== true && $status !== false ) {
    123134            // only allow booleans to be saved
    124135            return false;
    125         } else {
    126             add_post_meta( $this->post_id, self::FBIA_STATUS_KEY, $status, true ) or
    127                 update_post_meta( $this->post_id, self::FBIA_STATUS_KEY, $status );
    128             return true;
    129         }
     136        }
     137        if ( ! $this->valid_post ) {
     138            // only write to valid posts
     139            return false;
     140        }
     141
     142        add_post_meta( $this->post_id, self::FBIA_STATUS_KEY, $status, true ) or
     143            update_post_meta( $this->post_id, self::FBIA_STATUS_KEY, $status );
     144        return true;
    130145    }
    131146
     
    140155            // only allow booleans to be saved
    141156            return false;
    142         } else {
    143             add_post_meta( $this->post_id, self::AMP_STATUS_KEY, $status, true ) or
    144                 update_post_meta( $this->post_id, self::AMP_STATUS_KEY, $status );
    145             return true;
    146         }
     157        }
     158        if ( ! $this->valid_post ) {
     159            // only write to valid posts
     160            return false;
     161        }
     162
     163        $enabled = $status && wp_amp_plugin_is_installed() && wp_amp_plugin_is_active();
     164        add_post_meta( $this->post_id, self::AMP_STATUS_KEY, $status, true ) or
     165            update_post_meta( $this->post_id, self::AMP_STATUS_KEY, $status );
     166        return true;
     167    }
     168
     169    /**
     170     * A method to communicate to the outside world if the post is valid or no such post exists for the passed
     171     * in ID.
     172     *
     173     * @since   1.0.4.1
     174     */
     175    public function is_valid_post() {
     176        return $this->valid_post;
    147177    }
    148178
     
    194224    public static function amp_set_all_published_posts( $enabled ) {
    195225        $query = new WP_Query( array(
    196             'post_status' => 'publish'
     226            'post_status' => 'publish',
     227            'nopaging' => true
    197228        ) );
    198229        $posts = $query->get_posts();
     
    210241    public static function fbia_set_all_published_posts( $enabled ) {
    211242        $query = new WP_Query( array(
    212             'post_status' => 'publish'
     243            'post_status' => 'publish',
     244            'nopaging' => true
    213245        ) );
    214246        $posts = $query->get_posts();
  • pagefrog/trunk/pagefrog.php

    r1349446 r1353774  
    1616 * Plugin URI:        http://pagefrog.com/
    1717 * Description:       PageFrog is the mobile hub for your website. Manage your content across AMP, Facebook Instant Articles and Apple News.
    18  * Version:           1.0.5
     18 * Version:           1.0.5.1
    1919 * Author:            PageFrog Team
    2020 * Author URI:        http://pagefrog.com/
Note: See TracChangeset for help on using the changeset viewer.