Changeset 1874793
- Timestamp:
- 05/15/2018 04:04:41 PM (8 years ago)
- Location:
- snappic/trunk
- Files:
-
- 9 edited
-
assets/css/snappic-welcome.css (modified) (1 diff)
-
assets/js/snappic-welcome.js (modified) (1 diff)
-
includes/admin/views/html-snappic-welcome.php (modified) (1 diff)
-
includes/class-snappic-admin-setup-wizard.php (modified) (1 diff)
-
includes/class-snappic-api-controller.php (modified) (4 diffs)
-
languages/snappic-for-woocommerce.pot (modified) (1 diff)
-
package.json (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
snappic-for-woocommerce.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
snappic/trunk/assets/css/snappic-welcome.css
r1715114 r1874793 237 237 top: 4px; 238 238 } 239 .permalink_error { 240 margin-top: 2em; 241 } 239 242 .subtitle{ 240 243 text-transform: uppercase; -
snappic/trunk/assets/js/snappic-welcome.js
r1715114 r1874793 12 12 $.ajax 13 13 ({ 14 url: snappic_for_woocommerce. permalink_url,14 url: snappic_for_woocommerce.ajaxurl, 15 15 type: 'post', 16 beforeSend: function ( xhr ) { 17 xhr.setRequestHeader( 'X-WP-Nonce', snappic_for_woocommerce.nonce ); 18 }, 19 success: function(result) 16 data: { 17 'action': 'snappic_update_permalinks', 18 'nonce': snappic_for_woocommerce.nonce 19 }, 20 success: function(response) 20 21 { 21 22 $_this.removeClass('loading').prop('disabled', true); 22 $slides.addClass( 'pick_plan' ); 23 if( response == 1 ) { 24 $slides.addClass( 'pick_plan' ); 25 } else { 26 $('#change_url_structure .permalink_error').slideDown(); 27 } 23 28 } 24 29 }); -
snappic/trunk/includes/admin/views/html-snappic-welcome.php
r1715114 r1874793 35 35 <div class="subtitle"><?php _e( 'THIS ALLOWS US TO SYNC UP WITH YOUR INVENTORY AND STOP SHOWING ADS FOR PRODUCTS ONCE THEY ARE OUT OF STOCK', 'snappic-for-woocommerce' );?></div> 36 36 <a href='#pick_plan' class="button-blue js-goto update-permalink" data-goto="pick_plan"><?php _e( 'Change and Continue', 'snappic-for-woocommerce' );?></a> 37 <div class="permalink_error" style="display:none;"><p><?php _e( 'Sorry, we were not able to update your permalinks at this time.', 'snappic-for-woocommerce' );?></p></div> 37 38 <div class="note"><?php _e( 'This won’t change how your website looks or any of your products', 'snappic-for-woocommerce' );?></div> 38 39 </div> -
snappic/trunk/includes/class-snappic-admin-setup-wizard.php
r1715114 r1874793 48 48 49 49 $l10n = array( 50 'nonce' => wp_create_nonce( ' wp_rest' ),51 ' permalink_url' => esc_url_raw( rest_url( 'wc/v1/snappic/store/update' )),50 'nonce' => wp_create_nonce( 'snappic_update' ), 51 'ajaxurl' => admin_url( 'admin-ajax.php' ), 52 52 ); 53 53 wp_localize_script( 'snappic-welcome', 'snappic_for_woocommerce ', $l10n ); -
snappic/trunk/includes/class-snappic-api-controller.php
r1715114 r1874793 32 32 ), 33 33 'schema' => array( $this, 'get_public_item_schema' ), 34 ) );35 36 register_rest_route( $this->namespace, '/' . $this->rest_base . '/update', array(37 array(38 'methods' => WP_REST_Server::EDITABLE,39 'callback' => array( $this, 'update_permalinks' ),40 'permission_callback' => array( $this, 'update_permalinks_permissions_check' ),41 )42 ) );43 44 register_rest_route( $this->namespace, '/' . $this->rest_base . '/signup', array(45 array(46 'methods' => WP_REST_Server::EDITABLE,47 'callback' => array( $this, 'get_signup_link' ),48 'permission_callback' => array( $this, 'update_permalinks_permissions_check' ),49 )50 34 ) ); 51 35 … … 102 86 * Makes sure the current user has access to WRITE the settings APIs. 103 87 * 104 * @since 3.0.0 88 * @since 1.0.0 89 * @deprecated 1.1.0 90 * 105 91 * @param WP_REST_Request $request Full data about the request. 106 92 * @return WP_Error|boolean 107 93 */ 108 public function update_permalinks_permissions_check( $request ) { 94 public function update_permalinks_permissions_check( $request ) { 95 _deprecated_function( 'WC_Free_Gift_Coupons::update_permalinks', '1.1.0', 'Snappic_Base::update_permalinks()' ); 109 96 if ( ! wc_rest_check_manager_permissions( 'settings', 'edit' ) ) { 110 97 return new WP_Error( 'woocommerce_rest_cannot_edit', __( 'Sorry, you cannot edit the permalinks.', 'snappic-for-woocommerce' ), array( 'status' => rest_authorization_required_code() ) ); … … 116 103 /** 117 104 * Check whether a given request has permission to read data. 105 * 106 * @since 1.0.0 107 * @deprecated 1.1.0 - process now occurs via AJAX callback, see Snappic_Base::update_permalinks() 118 108 * 119 109 * @param WP_REST_Request $request Full details about the request. … … 121 111 */ 122 112 public function update_permalinks( $request ) { 123 $data = array( 'status' => update_option( 'permalink_structure', "/%postname%/" ) ); 113 _deprecated_function( 'WC_Free_Gift_Coupons::update_permalinks', '1.1.0', 'Snappic_Base::update_permalinks()' ); 114 $data = array( 'status' => update_option( 'permalink_structure', "/%year%/%monthnum%/%postname%/" ) ); 124 115 flush_rewrite_rules(); 125 116 return rest_ensure_response( $data ); -
snappic/trunk/languages/snappic-for-woocommerce.pot
r1821537 r1874793 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Snappic for WooCommerce 1.0. 6\n"5 "Project-Id-Version: Snappic for WooCommerce 1.0.7\n" 6 6 "Report-Msgid-Bugs-To: " 7 7 "https://wordpress.org/support/plugin/snappic-for-woocommerce\n" -
snappic/trunk/package.json
r1821537 r1874793 2 2 "title": "Snapppic for WooCommerce", 3 3 "name": "snappic-for-woocommerce", 4 "version": "1.0. 6",4 "version": "1.0.7", 5 5 "description": "Snappic Integration", 6 6 "main": "Gruntfile.js", -
snappic/trunk/readme.txt
r1821537 r1874793 5 5 Requires at least: 4.7 6 6 Tested up to: 4.8 7 Stable tag: 1.0. 67 Stable tag: 1.0.7 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html -
snappic/trunk/snappic-for-woocommerce.php
r1821537 r1874793 15 15 16 16 class Snappic_Base { 17 const VERSION = '1.0. 6';17 const VERSION = '1.0.7'; 18 18 const REQUIRED_WOO = '3.1.0'; 19 19 … … 67 67 add_filter( 'rest_api_init', array( $this, 'add_api_resource' ) ); 68 68 69 // Ajax callback for updating permalinks 70 add_action( 'wp_ajax_snappic_update_permalinks', array( $this, 'update_permalinks' ) ); 71 69 72 /* 70 73 * Save routine workaround … … 284 287 285 288 unload_textdomain( 'snappic' ); 286 load_plugin_textdomain( 'snappic ', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );289 load_plugin_textdomain( 'snappic-for-woocommerce', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' ); 287 290 } 288 291 … … 339 342 } 340 343 344 345 /** 346 * Update the Permalinks via AJAX 347 * Using an AJAX callback is preferred to using a REST route because it ensures that the functions that write the HTACCESS are available. 348 * 349 * @return string json-encoded 350 */ 351 public function update_permalinks() { 352 353 global $wp_rewrite; 354 355 $permalink_structure = "/%postname%/"; 356 357 if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'snappic_update' ) ) { 358 wp_die(); 359 } 360 361 if ( ! current_user_can( 'manage_options' ) ) { 362 wp_die(); 363 } 364 365 $wp_rewrite->set_permalink_structure( $permalink_structure ); 366 flush_rewrite_rules(); 367 wp_die('1'); 368 369 } 370 371 341 372 /*-----------------------------------------------------------------------------------*/ 342 373 /* Helpers */
Note: See TracChangeset
for help on using the changeset viewer.