Premmerce Permalink Manager for WooCommerce - Version 2.1.1

Version Description

Release Date: Jul 31, 2018

  • Fixed cyrillic slugs
  • Fixed WPML language url trailing slash
  • Fixed AMP redirects
  • Fixed tag permalinks updates
Download this release

Release Info

Developer premmerce
Plugin Icon 128x128 Premmerce Permalink Manager for WooCommerce
Version 2.1.1
Comparing to
See all releases

Code changes from version 2.1 to 2.1.1

assets/admin/css/style.css CHANGED
@@ -18,5 +18,4 @@
18
 
19
  .flex-label input[type="radio"] {
20
  margin-top: 1px;
21
- }
22
- ґ
18
 
19
  .flex-label input[type="radio"] {
20
  margin-top: 1px;
21
+ }
 
freemius/assets/css/admin/common.css CHANGED
@@ -1,2 +1,2 @@
1
  .theme-browser .theme .fs-premium-theme-badge{position:absolute;top:10px;right:0;background:#71ae00;color:#fff;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);font-size:1.1em}#iframe{line-height:0;font-size:0}.fs-full-size-wrapper{margin:40px 0 -65px -20px}@media (max-width: 600px){.fs-full-size-wrapper{margin:0 0 -65px -10px}}
2
- .fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;top:100%;bottom:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}div.fs-notice.updated,div.fs-notice.success,div.fs-notice.promotion{display:block !important}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;-moz-box-shadow:0 2px 2px rgba(6,113,6,0.3);-webkit-box-shadow:0 2px 2px rgba(6,113,6,0.3);box-shadow:0 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}.fs-secure-notice a.fs-security-proof{color:green;text-decoration:none}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 600px){.fs-secure-notice{display:none}}@media screen and (max-width: 500px){#fs_promo_tab{display:none}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}.fs-submenu-item.pricing.upgrade-mode{color:greenyellow}.fs-submenu-item.pricing.trial-mode{color:#83e2ff}#adminmenu .update-plugins.fs-trial{background-color:#00b9eb}.fs-ajax-spinner{border:0;width:20px;height:20px;margin-right:5px;vertical-align:sub;display:inline-block;background:url("../../../../../../../wp-admin/images/wpspin_light-2x.gif");background-size:contain}.wrap.fs-section h2{text-align:left}
1
  .theme-browser .theme .fs-premium-theme-badge{position:absolute;top:10px;right:0;background:#71ae00;color:#fff;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);font-size:1.1em}#iframe{line-height:0;font-size:0}.fs-full-size-wrapper{margin:40px 0 -65px -20px}@media (max-width: 600px){.fs-full-size-wrapper{margin:0 0 -65px -10px}}
2
+ .fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;top:100%;bottom:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}div.fs-notice.updated,div.fs-notice.success,div.fs-notice.promotion{display:block !important}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;-moz-box-shadow:0 2px 2px rgba(6,113,6,0.3);-webkit-box-shadow:0 2px 2px rgba(6,113,6,0.3);box-shadow:0 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}.fs-secure-notice a.fs-security-proof{color:green;text-decoration:none}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 600px){.fs-secure-notice{display:none}}@media screen and (max-width: 500px){#fs_promo_tab{display:none}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}.fs-submenu-item.pricing.upgrade-mode{color:greenyellow}.fs-submenu-item.pricing.trial-mode{color:#83e2ff}#adminmenu .update-plugins.fs-trial{background-color:#00b9eb}.fs-ajax-spinner{border:0;width:20px;height:20px;margin-right:5px;vertical-align:sub;display:inline-block;background:url("/wp-admin/images/wpspin_light-2x.gif");background-size:contain}.wrap.fs-section h2{text-align:left}
freemius/assets/scss/admin/common.scss CHANGED
@@ -207,7 +207,7 @@ span.fs-submenu-item.fs-sub:before
207
  margin-right: 5px;
208
  vertical-align: sub;
209
  display: inline-block;
210
- background: url('../../../../../../../wp-admin/images/wpspin_light-2x.gif');
211
  background-size: contain;
212
  }
213
 
207
  margin-right: 5px;
208
  vertical-align: sub;
209
  display: inline-block;
210
+ background: url('/wp-admin/images/wpspin_light-2x.gif');
211
  background-size: contain;
212
  }
213
 
freemius/includes/class-freemius.php CHANGED
@@ -1348,7 +1348,10 @@
1348
  add_action( 'make_ham_blog', array( &$this, '_after_site_reactivated_callback' ) );
1349
  }
1350
 
1351
- if ( $this->is_theme() && self::is_customizer() ) {
 
 
 
1352
  // Register customizer upsell.
1353
  add_action( 'customize_register', array( &$this, '_customizer_register' ) );
1354
  }
@@ -1488,13 +1491,6 @@
1488
  array( &$this, '_submit_uninstall_reason_action' )
1489
  );
1490
 
1491
- if ( $this->is_theme() && $this->is_premium() && ! $this->has_active_valid_license() ) {
1492
- $this->add_ajax_action(
1493
- 'delete_theme_update_data',
1494
- array( &$this, '_delete_theme_update_data_action' )
1495
- );
1496
- }
1497
-
1498
  if ( ! $this->is_addon() || $this->is_parent_plugin_installed() ) {
1499
  if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
1500
  ( $this->is_theme() && self::is_themes_page() )
@@ -3961,6 +3957,13 @@
3961
 
3962
  $this->parse_settings( $plugin_info );
3963
 
 
 
 
 
 
 
 
3964
  if ( ! self::is_ajax() ) {
3965
  if ( ! $this->is_addon() || $this->is_only_premium() ) {
3966
  add_action(
@@ -6192,19 +6195,21 @@
6192
  }
6193
 
6194
  if ( $this->is_plugin_new_install() || $this->is_only_premium() ) {
6195
- // Show notice for new plugin installations.
6196
- $this->_admin_notices->add(
6197
- sprintf(
6198
- $this->get_text_inline( 'You are just one step away - %s', 'you-are-step-away' ),
6199
- sprintf( '<b><a href="%s">%s</a></b>',
6200
- $this->get_activation_url( array(), ! $this->is_delegated_connection() ),
6201
- sprintf( $this->get_text_x_inline( 'Complete "%s" Activation Now',
6202
- '%s - plugin name. As complete "PluginX" activation now', 'activate-x-now' ), $this->get_plugin_name() )
6203
- )
6204
- ),
6205
- '',
6206
- 'update-nag'
6207
- );
 
 
6208
  } else {
6209
  if ( $this->should_add_sticky_optin_notice() ) {
6210
  $this->add_sticky_optin_admin_notice();
@@ -14756,13 +14761,15 @@
14756
  private function add_submenu_items() {
14757
  $this->_logger->entrance();
14758
 
 
 
14759
  if ( $this->is_addon() ) {
14760
  // No submenu items for add-ons.
14761
  $add_submenu_items = false;
14762
  } else if ( $this->is_free_wp_org_theme() && ! fs_is_network_admin() ) {
14763
  // Also add submenu items when running in a free .org theme so the tabs will be visible.
14764
  $add_submenu_items = true;
14765
- } else if ( $this->is_activation_mode() && ! $this->is_free_wp_org_theme() ) {
14766
  $add_submenu_items = false;
14767
  } else if ( fs_is_network_admin() ) {
14768
  /**
@@ -14793,7 +14800,15 @@
14793
  $this->is_submenu_item_visible( 'affiliation' )
14794
  );
14795
  }
 
14796
 
 
 
 
 
 
 
 
14797
  if ( ! WP_FS__DEMO_MODE && $this->is_registered() ) {
14798
  $show_account = (
14799
  $this->is_submenu_item_visible( 'account' ) &&
@@ -14812,10 +14827,12 @@
14812
  'account',
14813
  array( &$this, '_account_page_load' ),
14814
  WP_FS__DEFAULT_PRIORITY,
14815
- $show_account
14816
  );
14817
  }
 
14818
 
 
14819
  // Add contact page.
14820
  $this->add_submenu_item(
14821
  $this->get_text_inline( 'Contact Us', 'contact-us' ),
@@ -14840,7 +14857,11 @@
14840
  $this->is_submenu_item_visible( 'addons' )
14841
  );
14842
  }
 
14843
 
 
 
 
14844
  if ( ! WP_FS__DEMO_MODE ) {
14845
  $show_pricing = (
14846
  $this->is_submenu_item_visible( 'pricing' ) &&
@@ -14862,14 +14883,14 @@
14862
 
14863
  // Add upgrade/pricing page.
14864
  $this->add_submenu_item(
14865
- $pricing_cta_text . '&nbsp;&nbsp;' . ( is_rtl() ? '&#x2190;' : '&#x27a4;' ),
14866
  array( &$this, '_pricing_page_render' ),
14867
  $this->get_plugin_name() . ' &ndash; ' . $this->get_text_x_inline( 'Pricing', 'noun', 'pricing' ),
14868
  'manage_options',
14869
  'pricing',
14870
  'Freemius::_clean_admin_content_section',
14871
  WP_FS__LOWEST_PRIORITY,
14872
- $show_pricing,
14873
  $pricing_class
14874
  );
14875
  }
@@ -15937,7 +15958,7 @@
15937
  /**
15938
  * @since 1.2.3 When running in DEV mode, retrieve pending plans as well.
15939
  */
15940
- $result = $api->get( "/plugins/{$this->_module_id}/plans.json?show_pending=" . ( $this->has_secret_key() ? 'true' : 'false' ), true );
15941
 
15942
  if ( $this->is_api_result_object( $result, 'plans' ) && is_array( $result->plans ) ) {
15943
  for ( $i = 0, $len = count( $result->plans ); $i < $len; $i ++ ) {
@@ -16405,7 +16426,7 @@
16405
  $this->_update_licenses( $licenses, $addon->id );
16406
 
16407
  if ( ! $this->is_addon_installed( $addon->id ) && FS_License_Manager::has_premium_license( $licenses ) ) {
16408
- $plans_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$addon_id}/plans.json" );
16409
 
16410
  if ( ! isset( $plans_result->error ) ) {
16411
  $plans = array();
@@ -16733,6 +16754,7 @@
16733
  'trial_promotion',
16734
  'trial_expired',
16735
  'activation_complete',
 
16736
  ) );
16737
  break;
16738
  case 'changed':
@@ -17570,19 +17592,21 @@
17570
 
17571
  $api = $this->get_api_site_or_plugin_scope();
17572
 
 
 
17573
  /**
17574
  * @since 1.2.1
17575
  *
17576
  * If there's a cached version of the add-ons and not asking
17577
  * for a flush, just use the currently stored add-ons.
17578
  */
17579
- if ( ! $flush && $api->is_cached( '/addons.json?enriched=true' ) ) {
17580
  $addons = self::get_all_addons();
17581
 
17582
  return $addons[ $this->_plugin->id ];
17583
  }
17584
 
17585
- $result = $api->get( '/addons.json?enriched=true', $flush );
17586
 
17587
  $addons = array();
17588
  if ( $this->is_api_result_object( $result, 'plugins' ) &&
@@ -18398,9 +18422,9 @@
18398
  $vars = array( 'id' => $this->_module_id );
18399
 
18400
  if ( 'true' === fs_request_get( 'checkout', false ) ) {
18401
- fs_require_once_template( 'checkout.php', $vars );
18402
  } else {
18403
- fs_require_once_template( 'pricing.php', $vars );
18404
  }
18405
  }
18406
 
@@ -18515,7 +18539,9 @@
18515
  * @return FS_Api
18516
  */
18517
  private function get_current_or_network_user_api_scope( $flush = false ) {
18518
- if ( ! $this->_is_network_active || isset( $this->_user ) ) {
 
 
18519
  return $this->get_api_user_scope( $flush );
18520
  }
18521
 
@@ -18603,9 +18629,19 @@
18603
  * @author Vova Feldman (@svovaf)
18604
  * @since 1.0.9
18605
  *
18606
- * @param $plans
18607
  */
18608
  function _check_for_trial_plans( $plans ) {
 
 
 
 
 
 
 
 
 
 
18609
  $this->_storage->has_trial_plan = FS_Plan_Manager::instance()->has_trial_plan( $plans );
18610
  }
18611
 
@@ -19344,14 +19380,16 @@
19344
  * @param array $request
19345
  * @param int $success_cache_expiration
19346
  * @param int $failure_cache_expiration
 
19347
  *
19348
  * @return WP_Error|array
19349
  */
19350
- private static function safe_remote_post(
19351
  &$url,
19352
  $request,
19353
  $success_cache_expiration = 0,
19354
- $failure_cache_expiration = 0
 
19355
  ) {
19356
  $should_cache = ($success_cache_expiration + $failure_cache_expiration > 0);
19357
 
@@ -19362,7 +19400,9 @@
19362
  false;
19363
 
19364
  if ( false === $response ) {
19365
- self::enrich_request_for_debug( $url, $request );
 
 
19366
 
19367
  $response = wp_remote_post( $url, $request );
19368
 
@@ -20117,6 +20157,10 @@
20117
  $icon_found = false;
20118
  $local_path = fs_normalize_path( "{$img_dir}/{$this->_slug}.png" );
20119
 
 
 
 
 
20120
  $have_write_permissions = ( 'direct' === get_filesystem_method( array(), fs_normalize_path( $img_dir ) ) );
20121
 
20122
  /**
@@ -20633,9 +20677,7 @@
20633
  * @since 2.1.0
20634
  */
20635
  function _maybe_add_gdpr_optin_ajax_handler() {
20636
- if ( $this->is_activation_mode() ) {
20637
- $this->add_ajax_action( 'fetch_is_marketing_required_flag_value', array( &$this, '_fetch_is_marketing_required_flag_value_ajax_action' ) );
20638
- }
20639
 
20640
  if ( FS_GDPR_Manager::instance()->is_opt_in_notice_shown() ) {
20641
  $this->add_gdpr_optin_ajax_handler_and_style();
@@ -20819,4 +20861,28 @@
20819
  }
20820
 
20821
  #endregion
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20822
  }
1348
  add_action( 'make_ham_blog', array( &$this, '_after_site_reactivated_callback' ) );
1349
  }
1350
 
1351
+ if ( $this->is_theme() &&
1352
+ self::is_customizer() &&
1353
+ $this->apply_filters( 'show_customizer_upsell', true )
1354
+ ) {
1355
  // Register customizer upsell.
1356
  add_action( 'customize_register', array( &$this, '_customizer_register' ) );
1357
  }
1491
  array( &$this, '_submit_uninstall_reason_action' )
1492
  );
1493
 
 
 
 
 
 
 
 
1494
  if ( ! $this->is_addon() || $this->is_parent_plugin_installed() ) {
1495
  if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
1496
  ( $this->is_theme() && self::is_themes_page() )
3957
 
3958
  $this->parse_settings( $plugin_info );
3959
 
3960
+ if ( is_admin() && $this->is_theme() && $this->is_premium() && ! $this->has_active_valid_license() ) {
3961
+ $this->add_ajax_action(
3962
+ 'delete_theme_update_data',
3963
+ array( &$this, '_delete_theme_update_data_action' )
3964
+ );
3965
+ }
3966
+
3967
  if ( ! self::is_ajax() ) {
3968
  if ( ! $this->is_addon() || $this->is_only_premium() ) {
3969
  add_action(
6195
  }
6196
 
6197
  if ( $this->is_plugin_new_install() || $this->is_only_premium() ) {
6198
+ if ( ! $this->_anonymous_mode ) {
6199
+ // Show notice for new plugin installations.
6200
+ $this->_admin_notices->add(
6201
+ sprintf(
6202
+ $this->get_text_inline( 'You are just one step away - %s', 'you-are-step-away' ),
6203
+ sprintf( '<b><a href="%s">%s</a></b>',
6204
+ $this->get_activation_url( array(), ! $this->is_delegated_connection() ),
6205
+ sprintf( $this->get_text_x_inline( 'Complete "%s" Activation Now',
6206
+ '%s - plugin name. As complete "PluginX" activation now', 'activate-x-now' ), $this->get_plugin_name() )
6207
+ )
6208
+ ),
6209
+ '',
6210
+ 'update-nag'
6211
+ );
6212
+ }
6213
  } else {
6214
  if ( $this->should_add_sticky_optin_notice() ) {
6215
  $this->add_sticky_optin_admin_notice();
14761
  private function add_submenu_items() {
14762
  $this->_logger->entrance();
14763
 
14764
+ $is_activation_mode = $this->is_activation_mode();
14765
+
14766
  if ( $this->is_addon() ) {
14767
  // No submenu items for add-ons.
14768
  $add_submenu_items = false;
14769
  } else if ( $this->is_free_wp_org_theme() && ! fs_is_network_admin() ) {
14770
  // Also add submenu items when running in a free .org theme so the tabs will be visible.
14771
  $add_submenu_items = true;
14772
+ } else if ( $is_activation_mode && ! $this->is_free_wp_org_theme() ) {
14773
  $add_submenu_items = false;
14774
  } else if ( fs_is_network_admin() ) {
14775
  /**
14800
  $this->is_submenu_item_visible( 'affiliation' )
14801
  );
14802
  }
14803
+ }
14804
 
14805
+ if ( $add_submenu_items ||
14806
+ ( $is_activation_mode &&
14807
+ $this->is_only_premium() &&
14808
+ $this->is_admin_page( 'account' ) &&
14809
+ fs_request_is_action( $this->get_unique_affix() . '_sync_license' )
14810
+ )
14811
+ ) {
14812
  if ( ! WP_FS__DEMO_MODE && $this->is_registered() ) {
14813
  $show_account = (
14814
  $this->is_submenu_item_visible( 'account' ) &&
14827
  'account',
14828
  array( &$this, '_account_page_load' ),
14829
  WP_FS__DEFAULT_PRIORITY,
14830
+ ( $add_submenu_items && $show_account )
14831
  );
14832
  }
14833
+ }
14834
 
14835
+ if ( $add_submenu_items ) {
14836
  // Add contact page.
14837
  $this->add_submenu_item(
14838
  $this->get_text_inline( 'Contact Us', 'contact-us' ),
14857
  $this->is_submenu_item_visible( 'addons' )
14858
  );
14859
  }
14860
+ }
14861
 
14862
+ if ( $add_submenu_items ||
14863
+ ( $is_activation_mode && $this->is_only_premium() && $this->is_admin_page( 'pricing' ) )
14864
+ ) {
14865
  if ( ! WP_FS__DEMO_MODE ) {
14866
  $show_pricing = (
14867
  $this->is_submenu_item_visible( 'pricing' ) &&
14883
 
14884
  // Add upgrade/pricing page.
14885
  $this->add_submenu_item(
14886
+ $pricing_cta_text . '&nbsp;&nbsp;' . ( is_rtl() ? $this->get_text_x_inline( '&#x2190;', 'ASCII arrow left icon', 'symbol_arrow-left' ) : $this->get_text_x_inline( '&#x27a4;', 'ASCII arrow right icon', 'symbol_arrow-right' ) ),
14887
  array( &$this, '_pricing_page_render' ),
14888
  $this->get_plugin_name() . ' &ndash; ' . $this->get_text_x_inline( 'Pricing', 'noun', 'pricing' ),
14889
  'manage_options',
14890
  'pricing',
14891
  'Freemius::_clean_admin_content_section',
14892
  WP_FS__LOWEST_PRIORITY,
14893
+ ( $add_submenu_items && $show_pricing ),
14894
  $pricing_class
14895
  );
14896
  }
15958
  /**
15959
  * @since 1.2.3 When running in DEV mode, retrieve pending plans as well.
15960
  */
15961
+ $result = $api->get( $this->add_show_pending( "/plugins/{$this->_module_id}/plans.json" ), true );
15962
 
15963
  if ( $this->is_api_result_object( $result, 'plans' ) && is_array( $result->plans ) ) {
15964
  for ( $i = 0, $len = count( $result->plans ); $i < $len; $i ++ ) {
16426
  $this->_update_licenses( $licenses, $addon->id );
16427
 
16428
  if ( ! $this->is_addon_installed( $addon->id ) && FS_License_Manager::has_premium_license( $licenses ) ) {
16429
+ $plans_result = $this->get_api_site_or_plugin_scope()->get( $this->add_show_pending( "/addons/{$addon_id}/plans.json" ) );
16430
 
16431
  if ( ! isset( $plans_result->error ) ) {
16432
  $plans = array();
16754
  'trial_promotion',
16755
  'trial_expired',
16756
  'activation_complete',
16757
+ 'license_expired',
16758
  ) );
16759
  break;
16760
  case 'changed':
17592
 
17593
  $api = $this->get_api_site_or_plugin_scope();
17594
 
17595
+ $path = $this->add_show_pending( '/addons.json?enriched=true' );
17596
+
17597
  /**
17598
  * @since 1.2.1
17599
  *
17600
  * If there's a cached version of the add-ons and not asking
17601
  * for a flush, just use the currently stored add-ons.
17602
  */
17603
+ if ( ! $flush && $api->is_cached( $path ) ) {
17604
  $addons = self::get_all_addons();
17605
 
17606
  return $addons[ $this->_plugin->id ];
17607
  }
17608
 
17609
+ $result = $api->get( $path, $flush );
17610
 
17611
  $addons = array();
17612
  if ( $this->is_api_result_object( $result, 'plugins' ) &&
18422
  $vars = array( 'id' => $this->_module_id );
18423
 
18424
  if ( 'true' === fs_request_get( 'checkout', false ) ) {
18425
+ echo $this->apply_filters( 'templates/checkout.php', fs_get_template( 'checkout.php', $vars ) );
18426
  } else {
18427
+ echo $this->apply_filters( 'templates/pricing.php', fs_get_template( 'pricing.php', $vars ) );
18428
  }
18429
  }
18430
 
18539
  * @return FS_Api
18540
  */
18541
  private function get_current_or_network_user_api_scope( $flush = false ) {
18542
+ if ( ! $this->_is_network_active ||
18543
+ ( isset( $this->_user ) && $this->_user instanceof FS_User )
18544
+ ) {
18545
  return $this->get_api_user_scope( $flush );
18546
  }
18547
 
18629
  * @author Vova Feldman (@svovaf)
18630
  * @since 1.0.9
18631
  *
18632
+ * @param FS_Plugin_Plan[] $plans
18633
  */
18634
  function _check_for_trial_plans( $plans ) {
18635
+ /**
18636
+ * For some reason core's do_action() flattens arrays when it has a single object item. Therefore, we need to restructure the array as expected.
18637
+ *
18638
+ * @author Vova Feldman (@svovaf)
18639
+ * @since 2.1.2
18640
+ */
18641
+ if ( ! is_array( $plans ) && is_object( $plans ) ) {
18642
+ $plans = array( $plans );
18643
+ }
18644
+
18645
  $this->_storage->has_trial_plan = FS_Plan_Manager::instance()->has_trial_plan( $plans );
18646
  }
18647
 
19380
  * @param array $request
19381
  * @param int $success_cache_expiration
19382
  * @param int $failure_cache_expiration
19383
+ * @param bool $maybe_enrich_request_for_debug
19384
  *
19385
  * @return WP_Error|array
19386
  */
19387
+ static function safe_remote_post(
19388
  &$url,
19389
  $request,
19390
  $success_cache_expiration = 0,
19391
+ $failure_cache_expiration = 0,
19392
+ $maybe_enrich_request_for_debug = true
19393
  ) {
19394
  $should_cache = ($success_cache_expiration + $failure_cache_expiration > 0);
19395
 
19400
  false;
19401
 
19402
  if ( false === $response ) {
19403
+ if ( $maybe_enrich_request_for_debug ) {
19404
+ self::enrich_request_for_debug( $url, $request );
19405
+ }
19406
 
19407
  $response = wp_remote_post( $url, $request );
19408
 
20157
  $icon_found = false;
20158
  $local_path = fs_normalize_path( "{$img_dir}/{$this->_slug}.png" );
20159
 
20160
+ if ( ! function_exists( 'get_filesystem_method' ) ) {
20161
+ require_once ABSPATH . 'wp-admin/includes/file.php';
20162
+ }
20163
+
20164
  $have_write_permissions = ( 'direct' === get_filesystem_method( array(), fs_normalize_path( $img_dir ) ) );
20165
 
20166
  /**
20677
  * @since 2.1.0
20678
  */
20679
  function _maybe_add_gdpr_optin_ajax_handler() {
20680
+ $this->add_ajax_action( 'fetch_is_marketing_required_flag_value', array( &$this, '_fetch_is_marketing_required_flag_value_ajax_action' ) );
 
 
20681
 
20682
  if ( FS_GDPR_Manager::instance()->is_opt_in_notice_shown() ) {
20683
  $this->add_gdpr_optin_ajax_handler_and_style();
20861
  }
20862
 
20863
  #endregion
20864
+
20865
+ #----------------------------------------------------------------------------------
20866
+ #region Helper
20867
+ #----------------------------------------------------------------------------------
20868
+
20869
+ /**
20870
+ * If running with a secret key, assume it's the developer and show pending plans as well.
20871
+ *
20872
+ * @author Vova Feldman (@svovaf)
20873
+ * @since 2.1.2
20874
+ *
20875
+ * @param string $path
20876
+ *
20877
+ * @return string
20878
+ */
20879
+ function add_show_pending( $path ) {
20880
+ if ( ! $this->has_secret_key() ) {
20881
+ return $path;
20882
+ }
20883
+
20884
+ return $path . ( false !== strpos( $path, '?' ) ? '&' : '?' ) . 'show_pending=true';
20885
+ }
20886
+
20887
+ #endregion
20888
  }
freemius/includes/class-fs-plugin-updater.php CHANGED
@@ -29,6 +29,11 @@
29
  * @since 1.1.8.1
30
  */
31
  private $_update_details;
 
 
 
 
 
32
 
33
  #--------------------------------------------------------------------------------
34
  #region Singleton
@@ -324,6 +329,46 @@
324
  (array) $this->_update_details;
325
  }
326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  return $transient_data;
328
  }
329
 
@@ -508,6 +553,138 @@
508
  return $res;
509
  }
510
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
511
  /**
512
  * Updates information on the "View version x.x details" page with custom data.
513
  *
29
  * @since 1.1.8.1
30
  */
31
  private $_update_details;
32
+ /**
33
+ * @var array
34
+ * @since 2.1.2
35
+ */
36
+ private $_translation_updates;
37
 
38
  #--------------------------------------------------------------------------------
39
  #region Singleton
329
  (array) $this->_update_details;
330
  }
331
 
332
+ $slug = $this->_fs->get_slug();
333
+
334
+ if ( $this->_fs->is_org_repo_compliant() && $this->_fs->is_freemium() ) {
335
+ if ( ! isset( $this->_translation_updates ) ) {
336
+ $this->_translation_updates = array();
337
+
338
+ if ( current_user_can( 'update_languages' ) ) {
339
+ $translation_updates = $this->fetch_wp_org_module_translation_updates( $module_type, $slug );
340
+ if ( ! empty( $translation_updates ) ) {
341
+ $this->_translation_updates = $translation_updates;
342
+ }
343
+ }
344
+ }
345
+
346
+ if ( ! empty( $this->_translation_updates ) ) {
347
+ $all_translation_updates = ( isset( $transient_data->translations ) && is_array( $transient_data->translations ) ) ?
348
+ $transient_data->translations :
349
+ array();
350
+
351
+ $current_plugin_translation_updates_map = array();
352
+ foreach ( $all_translation_updates as $key => $translation_update ) {
353
+ if ( $module_type === ( $translation_update['type'] . 's' ) && $slug === $translation_update['slug'] ) {
354
+ $current_plugin_translation_updates_map[ $translation_update['language'] ] = $translation_update;
355
+ unset( $all_translation_updates[ $key ] );
356
+ }
357
+ }
358
+
359
+ foreach ( $this->_translation_updates as $translation_update ) {
360
+ $lang = $translation_update['language'];
361
+ if ( ! isset( $current_plugin_translation_updates_map[ $lang ] ) ||
362
+ version_compare( $translation_update['version'], $current_plugin_translation_updates_map[ $lang ]['version'], '>' )
363
+ ) {
364
+ $current_plugin_translation_updates_map[ $lang ] = $translation_update;
365
+ }
366
+ }
367
+
368
+ $transient_data->translations = array_merge( $all_translation_updates, array_values( $current_plugin_translation_updates_map ) );
369
+ }
370
+ }
371
+
372
  return $transient_data;
373
  }
374
 
553
  return $res;
554
  }
555
 
556
+ /**
557
+ * Fetches module translation updates from wordpress.org.
558
+ *
559
+ * @author Leo Fajardo (@leorw)
560
+ * @since 2.1.2
561
+ *
562
+ * @param string $module_type
563
+ * @param string $slug
564
+ *
565
+ * @return array|null
566
+ */
567
+ private function fetch_wp_org_module_translation_updates( $module_type, $slug ) {
568
+ $plugin_data = $this->_fs->get_plugin_data();
569
+
570
+ $locales = array_values( get_available_languages() );
571
+ $locales = apply_filters( "{$module_type}_update_check_locales", $locales );
572
+ $locales = array_unique( $locales );
573
+
574
+ $plugin_basename = $this->_fs->get_plugin_basename();
575
+ if ( 'themes' === $module_type ) {
576
+ $plugin_basename = str_replace( '-premium', '', $plugin_basename );
577
+ }
578
+
579
+ global $wp_version;
580
+
581
+ $request_args = array(
582
+ 'timeout' => 15,
583
+ 'body' => array(
584
+ "{$module_type}" => json_encode(
585
+ array(
586
+ "{$module_type}" => array(
587
+ $plugin_basename => array(
588
+ 'Name' => trim( str_replace( '(Premium)', '', $plugin_data['Name'] ) ),
589
+ 'Author' => $plugin_data['Author'],
590
+ )
591
+ )
592
+ )
593
+ ),
594
+ 'translations' => json_encode( $this->get_installed_translations( $module_type, $slug ) ),
595
+ 'locale' => json_encode( $locales )
596
+ ),
597
+ 'user-agent' => ( 'WordPress/' . $wp_version . '; ' . home_url( '/' ) )
598
+ );
599
+
600
+ $url = "http://api.wordpress.org/{$module_type}/update-check/1.1/";
601
+ if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
602
+ $url = set_url_scheme( $url, 'https' );
603
+ }
604
+
605
+ $raw_response = Freemius::safe_remote_post(
606
+ $url,
607
+ $request_args,
608
+ WP_FS__TIME_24_HOURS_IN_SEC,
609
+ WP_FS__TIME_12_HOURS_IN_SEC,
610
+ false
611
+ );
612
+
613
+ if ( is_wp_error( $raw_response ) ) {
614
+ return null;
615
+ }
616
+
617
+ $response = json_decode( wp_remote_retrieve_body( $raw_response ), true );
618
+
619
+ if ( ! is_array( $response ) ) {
620
+ return null;
621
+ }
622
+
623
+ if ( ! isset( $response['translations'] ) || empty( $response['translations'] ) ) {
624
+ return null;
625
+ }
626
+
627
+ return $response['translations'];
628
+ }
629
+
630
+ /**
631
+ * @author Leo Fajardo (@leorw)
632
+ * @since 2.1.2
633
+ *
634
+ * @param string $module_type
635
+ * @param string $slug
636
+ *
637
+ * @return array
638
+ */
639
+ private function get_installed_translations( $module_type, $slug ) {
640
+ if ( function_exists( 'wp_get_installed_translations' ) ) {
641
+ return wp_get_installed_translations( $module_type );
642
+ }
643
+
644
+ $dir = "/{$module_type}";
645
+
646
+ if ( ! is_dir( WP_LANG_DIR . $dir ) )
647
+ return array();
648
+
649
+ $files = scandir( WP_LANG_DIR . $dir );
650
+ if ( ! $files )
651
+ return array();
652
+
653
+ $language_data = array();
654
+
655
+ foreach ( $files as $file ) {
656
+ if ( 0 !== strpos( $file, $slug ) ) {
657
+ continue;
658
+ }
659
+
660
+ if ( '.' === $file[0] || is_dir( WP_LANG_DIR . "{$dir}/{$file}" ) ) {
661
+ continue;
662
+ }
663
+
664
+ if ( substr( $file, -3 ) !== '.po' ) {
665
+ continue;
666
+ }
667
+
668
+ if ( ! preg_match( '/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match ) ) {
669
+ continue;
670
+ }
671
+
672
+ if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files ) ) {
673
+ continue;
674
+ }
675
+
676
+ list( , $textdomain, $language ) = $match;
677
+
678
+ if ( '' === $textdomain ) {
679
+ $textdomain = 'default';
680
+ }
681
+
682
+ $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "{$dir}/{$file}" );
683
+ }
684
+
685
+ return $language_data;
686
+ }
687
+
688
  /**
689
  * Updates information on the "View version x.x details" page with custom data.
690
  *
freemius/includes/customizer/class-fs-customizer-upsell-control.php CHANGED
@@ -59,7 +59,7 @@
59
  $this->fs->get_upgrade_url();
60
 
61
  // Load features.
62
- $pricing = $this->fs->get_api_plugin_scope()->get( 'pricing.json' );
63
 
64
  if ( $this->fs->is_api_result_object( $pricing, 'plans' ) ) {
65
  // Add support features.
59
  $this->fs->get_upgrade_url();
60
 
61
  // Load features.
62
+ $pricing = $this->fs->get_api_plugin_scope()->get( $this->fs->add_show_pending( "pricing.json" ) );
63
 
64
  if ( $this->fs->is_api_result_object( $pricing, 'plans' ) ) {
65
  // Add support features.
freemius/includes/fs-plugin-info-dialog.php CHANGED
@@ -101,7 +101,7 @@
101
  $has_features = false;
102
  $plans = false;
103
 
104
- $result = $this->_fs->get_api_plugin_scope()->get( "/addons/{$selected_addon->id}/pricing.json?type=visible" );
105
 
106
  if ( ! isset( $result->error ) ) {
107
  $plans = $result->plans;
@@ -165,6 +165,8 @@
165
  // Plugin is missing, not on Freemius nor WP.org.
166
  $data->wp_org_missing = true;
167
  }
 
 
168
  } else {
169
  $data->wp_org_missing = false;
170
 
@@ -183,12 +185,7 @@
183
 
184
  // Fetch as much as possible info from local files.
185
  $plugin_local_data = $this->_fs->get_plugin_data();
186
- $data->name = $selected_addon->title;
187
  $data->author = $plugin_local_data['Author'];
188
- $view_vars = array( 'plugin' => $selected_addon );
189
- $data->sections = array(
190
- 'description' => fs_get_template( '/plugin-info/description.php', $view_vars ),
191
- );
192
 
193
  if ( ! empty( $selected_addon->info->banner_url ) ) {
194
  $data->banners = array(
@@ -217,6 +214,12 @@
217
  }
218
  }
219
 
 
 
 
 
 
 
220
  if ( $has_pricing ) {
221
  // Add plans to data.
222
  $data->plans = $plans;
@@ -950,7 +953,7 @@
950
  </li>
951
  <?php
952
  }
953
- if ( ! empty( $api->slug ) && empty( $api->is_wp_org_compliant ) ) {
954
  ?>
955
  <li><a target="_blank"
956
  href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php fs_esc_html_echo_inline( 'WordPress.org Plugin Page', 'wp-org-plugin-page', $api->slug ) ?>
@@ -1094,7 +1097,7 @@
1094
  echo "</div>\n"; // #plugin-information-scrollable
1095
  echo "<div id='$tab-footer'>\n";
1096
 
1097
- if ( ! empty( $api->checkout_link ) ) {
1098
  echo $this->get_checkout_cta( $api );
1099
  }
1100
 
101
  $has_features = false;
102
  $plans = false;
103
 
104
+ $result = $this->_fs->get_api_plugin_scope()->get( $this->_fs->add_show_pending( "/addons/{$selected_addon->id}/pricing.json?type=visible" ) );
105
 
106
  if ( ! isset( $result->error ) ) {
107
  $plans = $result->plans;
165
  // Plugin is missing, not on Freemius nor WP.org.
166
  $data->wp_org_missing = true;
167
  }
168
+
169
+ $data->fs_missing = ( ! $has_free_plan || $data->wp_org_missing );
170
  } else {
171
  $data->wp_org_missing = false;
172
 
185
 
186
  // Fetch as much as possible info from local files.
187
  $plugin_local_data = $this->_fs->get_plugin_data();
 
188
  $data->author = $plugin_local_data['Author'];
 
 
 
 
189
 
190
  if ( ! empty( $selected_addon->info->banner_url ) ) {
191
  $data->banners = array(
214
  }
215
  }
216
 
217
+ $data->name = $selected_addon->title;
218
+ $view_vars = array( 'plugin' => $selected_addon );
219
+ $data->sections = array(
220
+ 'description' => fs_get_template( '/plugin-info/description.php', $view_vars ),
221
+ );
222
+
223
  if ( $has_pricing ) {
224
  // Add plans to data.
225
  $data->plans = $plans;
953
  </li>
954
  <?php
955
  }
956
+ if ( ! empty( $api->slug ) && true == $api->is_wp_org_compliant ) {
957
  ?>
958
  <li><a target="_blank"
959
  href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php fs_esc_html_echo_inline( 'WordPress.org Plugin Page', 'wp-org-plugin-page', $api->slug ) ?>
1097
  echo "</div>\n"; // #plugin-information-scrollable
1098
  echo "<div id='$tab-footer'>\n";
1099
 
1100
+ if ( $api->has_paid_plan && ! empty( $api->checkout_link ) ) {
1101
  echo $this->get_checkout_cta( $api );
1102
  }
1103
 
freemius/start.php CHANGED
@@ -15,7 +15,7 @@
15
  *
16
  * @var string
17
  */
18
- $this_sdk_version = '2.1.1';
19
 
20
  #region SDK Selection Logic --------------------------------------------------------------------
21
 
15
  *
16
  * @var string
17
  */
18
+ $this_sdk_version = '2.1.2';
19
 
20
  #region SDK Selection Logic --------------------------------------------------------------------
21
 
freemius/templates/account/partials/addon.php CHANGED
@@ -61,7 +61,7 @@
61
  $plan = $fs_addon->get_plan();
62
  $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
63
  $is_paid_trial = $fs_addon->is_paid_trial();
64
- $show_upgrade = ( ! $is_paying && ! $is_paid_trial && ! $fs_addon->_has_premium_license() );
65
  $is_current_license_expired = is_object( $license ) && $license->is_expired();
66
  }
67
  ?>
@@ -220,7 +220,7 @@
220
  }
221
 
222
  if ( 0 == count( $buttons ) ) {
223
- if ( $fs_addon->is_premium() ) {
224
  $fs_addon->_add_license_activation_dialog_box();
225
 
226
  $buttons[] = fs_ui_get_action_button(
61
  $plan = $fs_addon->get_plan();
62
  $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
63
  $is_paid_trial = $fs_addon->is_paid_trial();
64
+ $show_upgrade = ( $fs_addon->has_paid_plan() && ! $is_paying && ! $is_paid_trial && ! $fs_addon->_has_premium_license() );
65
  $is_current_license_expired = is_object( $license ) && $license->is_expired();
66
  }
67
  ?>
220
  }
221
 
222
  if ( 0 == count( $buttons ) ) {
223
+ if ( $show_upgrade && $fs_addon->is_premium() ) {
224
  $fs_addon->_add_license_activation_dialog_box();
225
 
226
  $buttons[] = fs_ui_get_action_button(
freemius/templates/add-ons.php CHANGED
@@ -55,7 +55,7 @@
55
  $has_free_plan = false;
56
  $has_paid_plan = false;
57
 
58
- $result = $fs->get_api_plugin_scope()->get( "/addons/{$addon->id}/pricing.json?type=visible" );
59
  if ( ! isset( $result->error ) ) {
60
  $plans = $result->plans;
61
 
@@ -89,6 +89,10 @@
89
 
90
  }
91
  }
 
 
 
 
92
  }
93
  ?>
94
  <li class="fs-card fs-addon" data-slug="<?php echo $addon->slug ?>">
55
  $has_free_plan = false;
56
  $has_paid_plan = false;
57
 
58
+ $result = $fs->get_api_plugin_scope()->get( $fs->add_show_pending( "/addons/{$addon->id}/pricing.json?type=visible" ) );
59
  if ( ! isset( $result->error ) ) {
60
  $plans = $result->plans;
61
 
89
 
90
  }
91
  }
92
+
93
+ if ( ! $has_paid_plan && ! $has_free_plan ) {
94
+ continue;
95
+ }
96
  }
97
  ?>
98
  <li class="fs-card fs-addon" data-slug="<?php echo $addon->slug ?>">
freemius/templates/checkout.php CHANGED
@@ -121,7 +121,7 @@
121
 
122
  $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
123
 
124
- if ( is_object( $fs_user ) ) {
125
  $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
126
  $fs_user,
127
  $timestamp,
@@ -233,7 +233,7 @@
233
  // passed via query string or hard coded into the child page, it depends on your needs).
234
  src = base_url + '/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
235
  // Append the i-frame into the DOM.
236
- frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/i' + 'frame>')
237
  .appendTo('#frame');
238
 
239
  FS.PostMessage.init(base_url, [frame[0]]);
121
 
122
  $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
123
 
124
+ if ( is_object( $fs_user ) && $fs_user->is_verified() ) {
125
  $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
126
  $fs_user,
127
  $timestamp,
233
  // passed via query string or hard coded into the child page, it depends on your needs).
234
  src = base_url + '/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
235
  // Append the i-frame into the DOM.
236
+ frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>')
237
  .appendTo('#frame');
238
 
239
  FS.PostMessage.init(base_url, [frame[0]]);
freemius/templates/connect.php CHANGED
@@ -718,11 +718,14 @@
718
  // Redirect to the "Account" page and sync the license.
719
  window.location.href = resultObj.next_page;
720
  } else {
 
 
721
  // Show error.
722
  $('.fs-content').prepend('<p class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</p>');
723
-
724
- resetLoadingMode();
725
  }
 
 
 
726
  }
727
  });
728
 
718
  // Redirect to the "Account" page and sync the license.
719
  window.location.href = resultObj.next_page;
720
  } else {
721
+ resetLoadingMode();
722
+
723
  // Show error.
724
  $('.fs-content').prepend('<p class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</p>');
 
 
725
  }
726
+ },
727
+ error: function () {
728
+ resetLoadingMode();
729
  }
730
  });
731
 
freemius/templates/contact.php CHANGED
@@ -98,7 +98,7 @@
98
  src = base_url + '/contact/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
99
 
100
  // Append the i-frame into the DOM.
101
- frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/i' + 'frame>')
102
  .appendTo('#frame');
103
 
104
  FS.PostMessage.init(base_url);
98
  src = base_url + '/contact/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
99
 
100
  // Append the i-frame into the DOM.
101
+ frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>')
102
  .appendTo('#frame');
103
 
104
  FS.PostMessage.init(base_url);
freemius/templates/pricing.php CHANGED
@@ -127,7 +127,7 @@
127
  src = base_url + '/pricing/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
128
 
129
  // Append the I-frame into the DOM.
130
- frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/i' + 'frame>')
131
  .appendTo('#frame');
132
 
133
  FS.PostMessage.init(base_url, [frame[0]]);
127
  src = base_url + '/pricing/?<?php echo http_build_query( $query_params ) ?>#' + encodeURIComponent(document.location.href),
128
 
129
  // Append the I-frame into the DOM.
130
+ frame = $('<i' + 'frame " src="' + src + '" width="100%" height="' + frame_height + 'px" scrolling="no" frameborder="0" style="background: transparent; width: 1px; min-width: 100%;"><\/i' + 'frame>')
131
  .appendTo('#frame');
132
 
133
  FS.PostMessage.init(base_url, [frame[0]]);
freemius/templates/tabs.php CHANGED
@@ -26,7 +26,11 @@
26
  foreach ( $menu_items as $priority => $items ) {
27
  foreach ( $items as $item ) {
28
  if ( ! $item['show_submenu'] ) {
29
- if ( ! $is_free_wp_org_theme || ! $fs->is_submenu_item_visible( $item['menu_slug'], true ) ) {
 
 
 
 
30
  continue;
31
  }
32
  }
26
  foreach ( $menu_items as $priority => $items ) {
27
  foreach ( $items as $item ) {
28
  if ( ! $item['show_submenu'] ) {
29
+ $submenu_name = ('wp-support-forum' === $item['menu_slug']) ?
30
+ 'support' :
31
+ $item['menu_slug'];
32
+
33
+ if ( ! $is_free_wp_org_theme || ! $fs->is_submenu_item_visible( $submenu_name, true ) ) {
34
  continue;
35
  }
36
  }
premmerce-url-manager.php CHANGED
@@ -11,7 +11,7 @@ use Premmerce\UrlManager\UrlManagerPlugin;
11
  * Plugin Name: WooCommerce Permalink Manager
12
  * Plugin URI: https://premmerce.com/woocommerce-permalink-manager-remove-shop-product-product-category-url/
13
  * Description: Premmerce WooCommerce Permalink Manager allows you to change WooCommerce permalink and remove product and product_category slugs from the URL.
14
- * Version: 2.1
15
  * Author: premmerce
16
  * Author URI: https://premmerce.com/
17
  * License: GPL-2.0+
@@ -24,27 +24,29 @@ use Premmerce\UrlManager\UrlManagerPlugin;
24
  */
25
 
26
  // If this file is called directly, abort.
27
- if(!defined('WPINC')){
28
- die;
29
  }
30
 
31
- if(!function_exists('premmerce_wpm_fs')){
32
 
33
- call_user_func(function(){
34
 
35
- require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';
36
 
37
- require_once plugin_dir_path(__FILE__) . '/freemius.php';
 
 
38
 
39
- $main = new UrlManagerPlugin(__FILE__);
40
 
41
- register_activation_hook(__FILE__, [$main, 'activate']);
42
 
43
- register_deactivation_hook(__FILE__, [$main, 'deactivate']);
44
 
45
- register_uninstall_hook(__FILE__, [UrlManagerPlugin::class, 'uninstall']);
46
 
47
- $main->run();
48
 
49
- });
50
  }
11
  * Plugin Name: WooCommerce Permalink Manager
12
  * Plugin URI: https://premmerce.com/woocommerce-permalink-manager-remove-shop-product-product-category-url/
13
  * Description: Premmerce WooCommerce Permalink Manager allows you to change WooCommerce permalink and remove product and product_category slugs from the URL.
14
+ * Version: 2.1.1
15
  * Author: premmerce
16
  * Author URI: https://premmerce.com/
17
  * License: GPL-2.0+
24
  */
25
 
26
  // If this file is called directly, abort.
27
+ if ( ! defined('WPINC')) {
28
+ die;
29
  }
30
 
31
+ if ( ! function_exists('premmerce_wpm_fs')) {
32
 
33
+ call_user_func(function () {
34
 
35
+ require_once plugin_dir_path(__FILE__) . 'vendor/autoload.php';
36
 
37
+ #premmerce_clear
38
+ require_once plugin_dir_path(__FILE__) . '/freemius.php';
39
+ #/premmerce_clear
40
 
41
+ $main = new UrlManagerPlugin(__FILE__);
42
 
43
+ register_activation_hook(__FILE__, [$main, 'activate']);
44
 
45
+ register_deactivation_hook(__FILE__, [$main, 'deactivate']);
46
 
47
+ register_uninstall_hook(__FILE__, [UrlManagerPlugin::class, 'uninstall']);
48
 
49
+ $main->run();
50
 
51
+ });
52
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: premmerce
3
  Tags: woocommerce url, remove product, remove product_category, woocommerce permalink, woocommerce, woocommerce seo
4
  Requires at least: 4.8
5
  Tested up to: 4.9.6
6
- Stable tag: 2.1
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -170,5 +170,15 @@ Release Date: Jun 22, 2018
170
  * Removed freemius menu subitems
171
  * Updated premmerce SDK
172
 
 
 
 
 
 
 
 
 
 
 
173
 
174
 
3
  Tags: woocommerce url, remove product, remove product_category, woocommerce permalink, woocommerce, woocommerce seo
4
  Requires at least: 4.8
5
  Tested up to: 4.9.6
6
+ Stable tag: 2.1.1
7
  Requires PHP: 5.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
170
  * Removed freemius menu subitems
171
  * Updated premmerce SDK
172
 
173
+ = 2.1.1 =
174
+
175
+ Release Date: Jul 31, 2018
176
+
177
+ * Fixed cyrillic slugs
178
+ * Fixed WPML language url trailing slash
179
+ * Fixed AMP redirects
180
+ * Fixed tag permalinks updates
181
+
182
+
183
 
184
 
src/Admin/Admin.php CHANGED
@@ -46,6 +46,11 @@ class Admin
46
  'created_product_cat',
47
  'edited_product_cat',
48
  'delete_product_cat',
 
 
 
 
 
49
  'update_option_' . Settings::OPTIONS,
50
  ];
51
 
@@ -55,19 +60,22 @@ class Admin
55
 
56
  add_action('shutdown', [$this, 'flush']);
57
 
58
- add_action('admin_menu', [$this, 'addMenuPage']);
59
- add_action('admin_menu', [$this, 'addFullPack'], 100);
60
 
61
  add_action('admin_init', [$this->settings, 'register']);
62
 
63
  add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']);
64
 
65
- add_action('admin_notices', array($this, 'renderAdminBanner'));
66
 
 
 
 
67
  add_action('wp_ajax_premmerce_url_manager_ignore_banner', array($this, 'ignoreAdminBanner'));
 
68
 
69
 
70
  }
 
71
 
72
  /**
73
  * Show Banner
@@ -94,7 +102,7 @@ class Admin
94
  die;
95
 
96
  }
97
-
98
 
99
  /**
100
  * Add submenu to premmerce menu page
@@ -136,6 +144,7 @@ class Admin
136
  }
137
  }
138
 
 
139
  public function addFullPack()
140
  {
141
  global $submenu;
@@ -157,6 +166,7 @@ class Admin
157
  ];
158
  }
159
  }
 
160
 
161
  /**
162
  * Options page
@@ -169,6 +179,7 @@ class Admin
169
 
170
  $tabs['settings'] = __('Settings', 'premmerce-url-manager');
171
 
 
172
  if (function_exists('premmerce_wpm_fs')) {
173
  if (premmerce_wpm_fs()->is_registered()) {
174
  $tabs['account'] = __('Account', 'premmerce-url-manager');
@@ -176,6 +187,8 @@ class Admin
176
  $tabs['contact'] = __('Contact Us', 'premmerce-url-manager');
177
  $tabs['pricing'] = __('Pricing', 'premmerce-url-manager');
178
  }
 
 
179
 
180
  $this->fileManager->includeTemplate('admin/main.php', [
181
  'settings' => $this->settings,
@@ -194,14 +207,16 @@ class Admin
194
  UrlManagerPlugin::VERSION);
195
 
196
  }
197
-
198
-
199
  if ($this->isBannerActive()) {
200
- wp_enqueue_script('premmerce-permalink-banner-script', $this->fileManager->locateAsset('admin/js/banner.js'),
 
201
  ['jquery'], UrlManagerPlugin::VERSION);
202
- wp_enqueue_style('premmerce-permalink-banner-style', $this->fileManager->locateAsset('admin/css/banner.css'), [],
 
203
  UrlManagerPlugin::VERSION);
204
  }
 
205
  }
206
 
207
 
@@ -224,12 +239,14 @@ class Admin
224
  }
225
  }
226
 
 
227
  public function isBannerActive()
228
  {
229
- $user = wp_get_current_user();
230
- $user_id = $user->ID;
231
 
232
  return ! get_user_meta($user_id, self::META_IGNORE_BANNER, true);
233
 
234
  }
 
235
  }
46
  'created_product_cat',
47
  'edited_product_cat',
48
  'delete_product_cat',
49
+
50
+ 'created_product_tag',
51
+ 'edited_product_tag',
52
+ 'delete_product_tag',
53
+
54
  'update_option_' . Settings::OPTIONS,
55
  ];
56
 
60
 
61
  add_action('shutdown', [$this, 'flush']);
62
 
 
 
63
 
64
  add_action('admin_init', [$this->settings, 'register']);
65
 
66
  add_action('admin_enqueue_scripts', [$this, 'enqueueScripts']);
67
 
68
+ add_action('admin_menu', [$this, 'addMenuPage']);
69
 
70
+ #premmerce_clear
71
+ add_action('admin_menu', [$this, 'addFullPack'], 100);
72
+ add_action('admin_notices', array($this, 'renderAdminBanner'));
73
  add_action('wp_ajax_premmerce_url_manager_ignore_banner', array($this, 'ignoreAdminBanner'));
74
+ #/premmerce_clear
75
 
76
 
77
  }
78
+ #premmerce_clear
79
 
80
  /**
81
  * Show Banner
102
  die;
103
 
104
  }
105
+ #/premmerce_clear
106
 
107
  /**
108
  * Add submenu to premmerce menu page
144
  }
145
  }
146
 
147
+ #premmerce_clear
148
  public function addFullPack()
149
  {
150
  global $submenu;
166
  ];
167
  }
168
  }
169
+ #/premmerce_clear
170
 
171
  /**
172
  * Options page
179
 
180
  $tabs['settings'] = __('Settings', 'premmerce-url-manager');
181
 
182
+ #premmerce_clear
183
  if (function_exists('premmerce_wpm_fs')) {
184
  if (premmerce_wpm_fs()->is_registered()) {
185
  $tabs['account'] = __('Account', 'premmerce-url-manager');
187
  $tabs['contact'] = __('Contact Us', 'premmerce-url-manager');
188
  $tabs['pricing'] = __('Pricing', 'premmerce-url-manager');
189
  }
190
+ #/premmerce_clear
191
+
192
 
193
  $this->fileManager->includeTemplate('admin/main.php', [
194
  'settings' => $this->settings,
207
  UrlManagerPlugin::VERSION);
208
 
209
  }
210
+ #premmerce_clear
 
211
  if ($this->isBannerActive()) {
212
+ wp_enqueue_script('premmerce-permalink-banner-script',
213
+ $this->fileManager->locateAsset('admin/js/banner.js'),
214
  ['jquery'], UrlManagerPlugin::VERSION);
215
+ wp_enqueue_style('premmerce-permalink-banner-style',
216
+ $this->fileManager->locateAsset('admin/css/banner.css'), [],
217
  UrlManagerPlugin::VERSION);
218
  }
219
+ #/premmerce_clear
220
  }
221
 
222
 
239
  }
240
  }
241
 
242
+ #premmerce_clear
243
  public function isBannerActive()
244
  {
245
+ $user = wp_get_current_user();
246
+ $user_id = $user->ID;
247
 
248
  return ! get_user_meta($user_id, self::META_IGNORE_BANNER, true);
249
 
250
  }
251
+ #/premmerce_clear
252
  }
src/Frontend/Frontend.php CHANGED
@@ -25,6 +25,7 @@ class Frontend
25
  if ( !empty($options['canonical']) ) {
26
  add_action( 'wp_head', [ $this, 'addCanonical' ] );
27
  }
 
28
  }
29
 
30
  /**
25
  if ( !empty($options['canonical']) ) {
26
  add_action( 'wp_head', [ $this, 'addCanonical' ] );
27
  }
28
+ #/premmerce_clear
29
  }
30
 
31
  /**
src/PermalinkListener.php CHANGED
@@ -27,6 +27,7 @@ class PermalinkListener
27
  'product' => ( isset( $options['product'] ) ? $options['product'] : '' ),
28
  ];
29
  $this->taxonomyOptions['product_cat'] = ( isset( $options['category'] ) ? $options['category'] : '' );
 
30
  }
31
 
32
  /**
@@ -63,7 +64,8 @@ class PermalinkListener
63
  if ( empty($this->taxonomyOptions[$taxonomy]) ) {
64
  return $link;
65
  }
66
- return user_trailingslashit( home_url( $this->buildTermPath( $term, $this->isHierarchical( $this->taxonomyOptions[$taxonomy] ) ) ) );
 
67
  }
68
 
69
  /**
@@ -162,13 +164,14 @@ class PermalinkListener
162
 
163
  private function buildTermPath( $term, $hierarchical )
164
  {
165
- $slug = $term->slug;
 
166
 
167
  if ( $hierarchical && $term->parent ) {
168
  $ancestors = get_ancestors( $term->term_id, 'product_cat' );
169
  foreach ( $ancestors as $ancestor ) {
170
  $ancestor_object = get_term( $ancestor, 'product_cat' );
171
- $slug = $ancestor_object->slug . '/' . $slug;
172
  }
173
  }
174
 
27
  'product' => ( isset( $options['product'] ) ? $options['product'] : '' ),
28
  ];
29
  $this->taxonomyOptions['product_cat'] = ( isset( $options['category'] ) ? $options['category'] : '' );
30
+ #/premmerce_clear
31
  }
32
 
33
  /**
64
  if ( empty($this->taxonomyOptions[$taxonomy]) ) {
65
  return $link;
66
  }
67
+ $isHierarchical = $this->isHierarchical( $this->taxonomyOptions[$taxonomy] );
68
+ return home_url( user_trailingslashit( $this->buildTermPath( $term, $isHierarchical ) ) );
69
  }
70
 
71
  /**
164
 
165
  private function buildTermPath( $term, $hierarchical )
166
  {
167
+ //urldecode used here to fix copied url via ctrl+c
168
+ $slug = urldecode( $term->slug );
169
 
170
  if ( $hierarchical && $term->parent ) {
171
  $ancestors = get_ancestors( $term->term_id, 'product_cat' );
172
  foreach ( $ancestors as $ancestor ) {
173
  $ancestor_object = get_term( $ancestor, 'product_cat' );
174
+ $slug = urldecode( $ancestor_object->slug ) . '/' . $slug;
175
  }
176
  }
177
 
src/Updater.php CHANGED
@@ -1,12 +1,11 @@
1
  <?php namespace Premmerce\UrlManager;
2
 
3
- use Premmerce\UrlManager\Admin\Admin;
4
  use Premmerce\UrlManager\Admin\Settings;
5
 
6
  class Updater
7
  {
8
 
9
- const CURRENT_VERSION = '2.0';
10
 
11
  const DB_OPTION = 'premmerce_permalink_manager_db_version';
12
 
1
  <?php namespace Premmerce\UrlManager;
2
 
 
3
  use Premmerce\UrlManager\Admin\Settings;
4
 
5
  class Updater
6
  {
7
 
8
+ const CURRENT_VERSION = '2.1.1';
9
 
10
  const DB_OPTION = 'premmerce_permalink_manager_db_version';
11
 
src/UrlManagerPlugin.php CHANGED
@@ -16,7 +16,7 @@ class UrlManagerPlugin
16
 
17
  const DOMAIN = 'premmerce-url-manager';
18
 
19
- const VERSION = '2.1';
20
 
21
  /**
22
  * @var FileManager
16
 
17
  const DOMAIN = 'premmerce-url-manager';
18
 
19
+ const VERSION = '2.1.1';
20
 
21
  /**
22
  * @var FileManager
views/admin/section/additional.php CHANGED
@@ -4,7 +4,9 @@ if ( !defined( 'WPINC' ) ) {
4
  die;
5
  }
6
  use Premmerce\UrlManager\Admin\Settings ;
 
7
  $free = true;
 
8
  ?>
9
 
10
  <table class="form-table">
4
  die;
5
  }
6
  use Premmerce\UrlManager\Admin\Settings ;
7
+ #premmerce_clear
8
  $free = true;
9
+ #/premmerce_clear
10
  ?>
11
 
12
  <table class="form-table">