Changeset 1353774
- Timestamp:
- 02/18/2016 10:08:50 PM (10 years ago)
- Location:
- pagefrog/trunk
- Files:
-
- 5 added
- 3 deleted
- 6 edited
-
README.txt (modified) (2 diffs)
-
admin/class-pagefrog-admin.php (modified) (9 diffs)
-
admin/class-pagefrog-styling.php (deleted)
-
admin/js/pagefrog-change-thickbox-text.js (modified) (1 diff)
-
admin/js/pagefrog-styling.js (modified) (1 diff)
-
admin/pagefrog-amp-template-single.php (deleted)
-
admin/pagefrog-amp-template-styles.php (deleted)
-
admin/pagefrog-post-metadata.php (modified) (6 diffs)
-
admin/partials/pagefrog-amp-template-meta-author.php (added)
-
admin/partials/pagefrog-amp-template-meta-taxonomy.php (added)
-
admin/partials/pagefrog-amp-template-meta-time.php (added)
-
admin/partials/pagefrog-amp-template-single.php (added)
-
admin/partials/pagefrog-amp-template-styles.php (added)
-
pagefrog.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
pagefrog/trunk/README.txt
r1349446 r1353774 218 218 219 219 == Changelog == 220 = 1.0.5.1 = 221 *Release Date - February 18, 2016* 222 223 * Assorted bug fixes 224 225 220 226 = 1.0.5 = 221 227 *Release Date - February 13, 2016* … … 226 232 * Included support for facebook ads 227 233 234 228 235 = 1.0.4 = 229 236 *Release Date - February 3, 2016* -
pagefrog/trunk/admin/class-pagefrog-admin.php
r1349446 r1353774 583 583 public function pagefrog_set_post_status() { 584 584 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(); 586 591 } 587 592 … … 592 597 $fbia_status = $_POST['fbia_status']; 593 598 $fbia_status_bool = false; 594 if ( $fbia_status == 'true') {599 if ( $fbia_status === 'true' || $fbia_status === true ) { 595 600 $fbia_status_bool = true; 596 } else if ( $fbia_status == 'false') {601 } else if ( $fbia_status === 'false' || $fbia_status === false ) { 597 602 $fbia_status_bool = false; 598 603 } 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(); 600 610 } 601 611 … … 603 613 $amp_status = $_POST['amp_status']; 604 614 $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 ) { 608 618 $amp_status_bool = false; 609 619 } 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(); 611 626 } 612 627 613 628 // save the statuses in the post metadata 614 629 $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 } 615 639 $post_status->set_fbia_status( $fbia_status_bool ); 616 640 $post_status->set_amp_status( $amp_status_bool ); 617 641 618 642 $response = array( 643 'status' => 'ok', 619 644 'fbia_status' => $post_status->get_fbia_status(), 620 645 'amp_status' => $post_status->get_amp_status(), … … 622 647 ); 623 648 wp_send_json( $response ); 649 wp_exit(); 624 650 } 625 651 … … 646 672 switch( $platform ) { 647 673 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 } 648 682 PageFrog_PostStatus::amp_set_all_published_posts( $enable ); 649 683 break; … … 830 864 } 831 865 } 832 $file = $pagefrog_path . 'admin/pa gefrog-amp-template-styles.php';866 $file = $pagefrog_path . 'admin/partials/pagefrog-amp-template-styles.php'; 833 867 } else if ( 'single' === $type ) { 834 868 $plugins = wp_get_active_and_valid_plugins(); … … 840 874 } 841 875 } 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'; 843 907 } 844 908 … … 910 974 911 975 function 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 } 912 980 if ( ! function_exists( 'get_plugins' ) ) { 913 981 require_once ABSPATH . 'wp-admin/includes/plugin.php'; … … 918 986 919 987 function 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 } 920 992 return function_exists( 'amp_render' ); 921 993 } -
pagefrog/trunk/admin/js/pagefrog-change-thickbox-text.js
r1338828 r1353774 5 5 window.setTimeout(change_text, 500); 6 6 jQuery('input[value="Insert into Post"]').attr('value', 'Choose Logo'); 7 jQuery('#tab-type_url').css({ 8 display: 'none' 9 }); 7 10 })(); 8 11 }); -
pagefrog/trunk/admin/js/pagefrog-styling.js
r1349446 r1353774 20 20 21 21 // 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 } 23 26 var classes = ''; 24 27 if (jQuery(html).prop('tagName').toLowerCase() == 'img') { -
pagefrog/trunk/admin/pagefrog-post-metadata.php
r1349446 r1353774 74 74 75 75 /** 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 /** 76 86 * Initialize the class and set any necessary properties. 77 87 * … … 81 91 function __construct( $post_id ) { 82 92 $this->post_id = $post_id; 93 $this->valid_post = get_post_status( $post_id ) !== false; 83 94 } 84 95 … … 120 131 */ 121 132 public function set_fbia_status( $status ) { 122 if ( $status !== true && $status !== false) {133 if ( $status !== true && $status !== false ) { 123 134 // only allow booleans to be saved 124 135 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; 130 145 } 131 146 … … 140 155 // only allow booleans to be saved 141 156 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; 147 177 } 148 178 … … 194 224 public static function amp_set_all_published_posts( $enabled ) { 195 225 $query = new WP_Query( array( 196 'post_status' => 'publish' 226 'post_status' => 'publish', 227 'nopaging' => true 197 228 ) ); 198 229 $posts = $query->get_posts(); … … 210 241 public static function fbia_set_all_published_posts( $enabled ) { 211 242 $query = new WP_Query( array( 212 'post_status' => 'publish' 243 'post_status' => 'publish', 244 'nopaging' => true 213 245 ) ); 214 246 $posts = $query->get_posts(); -
pagefrog/trunk/pagefrog.php
r1349446 r1353774 16 16 * Plugin URI: http://pagefrog.com/ 17 17 * 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 19 19 * Author: PageFrog Team 20 20 * Author URI: http://pagefrog.com/
Note: See TracChangeset
for help on using the changeset viewer.