404 to 301 - Version 3.0.0.1

Version Description

(25/06/2018) = Bug Fixes

  • Using template_redirect hook for redirect instead of wp hook.
  • Fixed an issue with do_action in Freemius SDK.
Download this release

Release Info

Developer joelcj91
Plugin Icon 128x128 404 to 301
Version 3.0.0.1
Comparing to
See all releases

Code changes from version 3.0.0 to 3.0.0.1

404-to-301.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /**
3
- * Plugin Name: 404 to 301
4
  * Plugin URI: https://duckdev.com/products/404-to-301/
5
  * Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
6
- * Version: 3.0.0
7
  * Author: Joel James
8
  * Author URI: https://duckdev.com/
9
  * Donate link: https://paypal.me/JoelCJ
@@ -63,7 +63,7 @@ if ( ! class_exists( 'JJ_404_to_301' ) ) :
63
  'JJ4T3_DIR' => plugin_dir_path( __FILE__ ),
64
  'JJ4T3_URL' => plugin_dir_url( __FILE__ ),
65
  'JJ4T3_BASE_FILE' => __FILE__,
66
- 'JJ4T3_VERSION' => '3.0.0',
67
  'JJ4T3_DB_VERSION' => '11.0',
68
  'JJ4T3_TABLE' => $GLOBALS['wpdb']->prefix . '404_to_301',
69
  // Set who all can access plugin settings.
@@ -157,4 +157,4 @@ if ( ! class_exists( 'JJ_404_to_301' ) ) :
157
  // Signal that SDK was initiated.
158
  do_action( 'jj4t3_fs_loaded' );
159
 
160
- endif; // End if class_exists check.
1
  <?php
2
  /**
3
+ * Plugin Name: 404 to 301 - Redirect, Log and Notify 404 Errors
4
  * Plugin URI: https://duckdev.com/products/404-to-301/
5
  * Description: Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.
6
+ * Version: 3.0.0.1
7
  * Author: Joel James
8
  * Author URI: https://duckdev.com/
9
  * Donate link: https://paypal.me/JoelCJ
63
  'JJ4T3_DIR' => plugin_dir_path( __FILE__ ),
64
  'JJ4T3_URL' => plugin_dir_url( __FILE__ ),
65
  'JJ4T3_BASE_FILE' => __FILE__,
66
+ 'JJ4T3_VERSION' => '3.0.0.1',
67
  'JJ4T3_DB_VERSION' => '11.0',
68
  'JJ4T3_TABLE' => $GLOBALS['wpdb']->prefix . '404_to_301',
69
  // Set who all can access plugin settings.
157
  // Signal that SDK was initiated.
158
  do_action( 'jj4t3_fs_loaded' );
159
 
160
+ endif; // End if class_exists check.
README.md CHANGED
@@ -1,6 +1,6 @@
1
  > ####WARNING: This latest version is not live yet. Use with caution!
2
 
3
- # [404 to 301](https://wordpress.org/plugins/404-to-301) - No more 404 errors!
4
 
5
  Automatically redirect all 404 errors to any page using 301 redirect to boost your SEO in WordPress. This plugin also can log all 404 erros and list it to you. Also you can optionally get email alerts on 404 errors!
6
 
@@ -9,7 +9,7 @@ Automatically redirect all 404 errors to any page using 301 redirect to boost yo
9
  <strong>Contributors:</strong> <a href="https://github.com/joel-james/">Joel James</a>, <a href="https://github.com/gaiusmathew/">Gaius Mathew</a><br/>
10
  <strong>Requires at least:</strong> WordPress 3.0<br/>
11
  <strong>Tested up to:</strong> WordPress 4.9<br/>
12
- <strong>Stable tag:</strong> 3.0.0<br/>
13
 
14
  <h4>Important Links and Documentation</h4>
15
 
1
  > ####WARNING: This latest version is not live yet. Use with caution!
2
 
3
+ # [404 to 301](https://wordpress.org/plugins/404-to-301) - Redirect, Log and Notify 404 Errors
4
 
5
  Automatically redirect all 404 errors to any page using 301 redirect to boost your SEO in WordPress. This plugin also can log all 404 erros and list it to you. Also you can optionally get email alerts on 404 errors!
6
 
9
  <strong>Contributors:</strong> <a href="https://github.com/joel-james/">Joel James</a>, <a href="https://github.com/gaiusmathew/">Gaius Mathew</a><br/>
10
  <strong>Requires at least:</strong> WordPress 3.0<br/>
11
  <strong>Tested up to:</strong> WordPress 4.9<br/>
12
+ <strong>Stable tag:</strong> 3.0.0.1<br/>
13
 
14
  <h4>Important Links and Documentation</h4>
15
 
composer.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name" : "joel-james/404-to-301",
3
- "version" : "3.0.0",
4
  "description": "Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.",
5
  "homepage" : "https://dclwp.com/",
6
  "license" : "GPL-2.0+",
1
  {
2
  "name" : "joel-james/404-to-301",
3
+ "version" : "3.0.0.1",
4
  "description": "Automatically redirect all <strong>404 errors</strong> to any page using <strong>301 redirect for SEO</strong>. You can <strong>redirect and log</strong> every 404 errors. No more 404 errors in Webmaster tool.",
5
  "homepage" : "https://dclwp.com/",
6
  "license" : "GPL-2.0+",
includes/public/class-jj4t3-404-actions.php CHANGED
@@ -92,7 +92,7 @@ class JJ4T3_404_Actions extends JJ4T3_404_Data {
92
  parent::__construct();
93
 
94
  // Main filter that handles 404.
95
- add_filter( 'wp', array( $this, 'handle_404' ) );
96
  }
97
 
98
  /**
92
  parent::__construct();
93
 
94
  // Main filter that handles 404.
95
+ add_filter( 'template_redirect', array( $this, 'handle_404' ) );
96
  }
97
 
98
  /**
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === 404 to 301 ===
2
  Contributors: joelcj91,duckdev
3
  Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo redirect, error redirect, 404 seo, custom 404 page
4
  Donate link: https://www.paypal.me/JoelCJ
5
  Requires at least: 3.5
6
  Tested up to: 4.9
7
- Stable tag: 3.0.0
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -128,6 +128,12 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://duckdev.com
128
 
129
  == Changelog ==
130
 
 
 
 
 
 
 
131
  = 3.0.0 (20/06/2018) =
132
  **New Features**
133
 
@@ -373,7 +379,8 @@ Bug reports for 404 to 301 are always welcome. [Report here](https://duckdev.com
373
 
374
  == Upgrade Notice ==
375
 
376
- = 3.0.0 (21/11/2016) =
377
  **Bug Fixes**
378
 
379
- - New features and improvements.
 
1
+ === 404 to 301 - Redirect, Log and Notify 404 Errors ===
2
  Contributors: joelcj91,duckdev
3
  Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo redirect, error redirect, 404 seo, custom 404 page
4
  Donate link: https://www.paypal.me/JoelCJ
5
  Requires at least: 3.5
6
  Tested up to: 4.9
7
+ Stable tag: 3.0.0.1
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
128
 
129
  == Changelog ==
130
 
131
+ = 3.0.0.1 (25/06/2018) =
132
+ **Bug Fixes**
133
+
134
+ - Using template_redirect hook for redirect instead of wp hook.
135
+ - Fixed an issue with do_action in Freemius SDK.
136
+
137
  = 3.0.0 (20/06/2018) =
138
  **New Features**
139
 
379
 
380
  == Upgrade Notice ==
381
 
382
+ = 3.0.0.1 (25/06/2018) =
383
  **Bug Fixes**
384
 
385
+ - Using template_redirect hook for redirect instead of wp hook.
386
+ - Fixed an issue with do_action in Freemius SDK.
vendor/freemius/.github/ISSUE_TEMPLATE.md DELETED
@@ -1,29 +0,0 @@
1
- **Actual Behavior**:
2
- - `What is the issue? (*)`
3
- - `What is the expected behavior?`
4
-
5
- **Versions**: (*)
6
- - `Freemius SDK Version:`
7
- - `WordPress Version:`
8
- - `PHP Version:`
9
-
10
- **Plugin / Theme**: (*)
11
- - `Name:`
12
- - `Slug:`
13
- - `Freemius ID:`
14
-
15
- **Additional Information**:
16
- - `Browser Type: (*)`
17
- - `Browser Version: (*)`
18
- - `OS: (*)`
19
- - `Stack Traces:`
20
-
21
- ----
22
- **Note:** `(*)` indicates required information. Without this information, your issue may be auto-closed.
23
-
24
- > You can find your Freemius SDK version at `/freemius/start.php`
25
-
26
- > You can find your Freemius product ID in the Freemius dashboard: `SETTINGS -> INTEGRATION`.
27
-
28
- > Do not modify the titles or questions. Simply add your responses to the ends of the questions.
29
- Add more lines if needed.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/freemius/includes/class-freemius.php CHANGED
@@ -1488,13 +1488,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 +3954,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(
@@ -14756,13 +14756,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 +14795,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 +14822,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 +14852,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' ) &&
@@ -14869,7 +14885,7 @@
14869
  'pricing',
14870
  'Freemius::_clean_admin_content_section',
14871
  WP_FS__LOWEST_PRIORITY,
14872
- $show_pricing,
14873
  $pricing_class
14874
  );
14875
  }
@@ -15937,7 +15953,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 +16421,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 +16749,7 @@
16733
  'trial_promotion',
16734
  'trial_expired',
16735
  'activation_complete',
 
16736
  ) );
16737
  break;
16738
  case 'changed':
@@ -18515,7 +18532,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 +18622,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 +19373,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 +19393,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
 
@@ -20633,9 +20666,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 +20850,28 @@
20819
  }
20820
 
20821
  #endregion
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20822
  }
1488
  array( &$this, '_submit_uninstall_reason_action' )
1489
  );
1490
 
 
 
 
 
 
 
 
1491
  if ( ! $this->is_addon() || $this->is_parent_plugin_installed() ) {
1492
  if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
1493
  ( $this->is_theme() && self::is_themes_page() )
3954
 
3955
  $this->parse_settings( $plugin_info );
3956
 
3957
+ if ( is_admin() && $this->is_theme() && $this->is_premium() && ! $this->has_active_valid_license() ) {
3958
+ $this->add_ajax_action(
3959
+ 'delete_theme_update_data',
3960
+ array( &$this, '_delete_theme_update_data_action' )
3961
+ );
3962
+ }
3963
+
3964
  if ( ! self::is_ajax() ) {
3965
  if ( ! $this->is_addon() || $this->is_only_premium() ) {
3966
  add_action(
14756
  private function add_submenu_items() {
14757
  $this->_logger->entrance();
14758
 
14759
+ $is_activation_mode = $this->is_activation_mode();
14760
+
14761
  if ( $this->is_addon() ) {
14762
  // No submenu items for add-ons.
14763
  $add_submenu_items = false;
14764
  } else if ( $this->is_free_wp_org_theme() && ! fs_is_network_admin() ) {
14765
  // Also add submenu items when running in a free .org theme so the tabs will be visible.
14766
  $add_submenu_items = true;
14767
+ } else if ( $is_activation_mode && ! $this->is_free_wp_org_theme() ) {
14768
  $add_submenu_items = false;
14769
  } else if ( fs_is_network_admin() ) {
14770
  /**
14795
  $this->is_submenu_item_visible( 'affiliation' )
14796
  );
14797
  }
14798
+ }
14799
 
14800
+ if ( $add_submenu_items ||
14801
+ ( $is_activation_mode &&
14802
+ $this->is_only_premium() &&
14803
+ $this->is_admin_page( 'account' ) &&
14804
+ fs_request_is_action( $this->get_unique_affix() . '_sync_license' )
14805
+ )
14806
+ ) {
14807
  if ( ! WP_FS__DEMO_MODE && $this->is_registered() ) {
14808
  $show_account = (
14809
  $this->is_submenu_item_visible( 'account' ) &&
14822
  'account',
14823
  array( &$this, '_account_page_load' ),
14824
  WP_FS__DEFAULT_PRIORITY,
14825
+ ( $add_submenu_items && $show_account )
14826
  );
14827
  }
14828
+ }
14829
 
14830
+ if ( $add_submenu_items ) {
14831
  // Add contact page.
14832
  $this->add_submenu_item(
14833
  $this->get_text_inline( 'Contact Us', 'contact-us' ),
14852
  $this->is_submenu_item_visible( 'addons' )
14853
  );
14854
  }
14855
+ }
14856
 
14857
+ if ( $add_submenu_items ||
14858
+ ( $is_activation_mode && $this->is_only_premium() && $this->is_admin_page( 'pricing' ) )
14859
+ ) {
14860
  if ( ! WP_FS__DEMO_MODE ) {
14861
  $show_pricing = (
14862
  $this->is_submenu_item_visible( 'pricing' ) &&
14885
  'pricing',
14886
  'Freemius::_clean_admin_content_section',
14887
  WP_FS__LOWEST_PRIORITY,
14888
+ ( $add_submenu_items && $show_pricing ),
14889
  $pricing_class
14890
  );
14891
  }
15953
  /**
15954
  * @since 1.2.3 When running in DEV mode, retrieve pending plans as well.
15955
  */
15956
+ $result = $api->get( $this->add_show_pending( "/plugins/{$this->_module_id}/plans.json" ), true );
15957
 
15958
  if ( $this->is_api_result_object( $result, 'plans' ) && is_array( $result->plans ) ) {
15959
  for ( $i = 0, $len = count( $result->plans ); $i < $len; $i ++ ) {
16421
  $this->_update_licenses( $licenses, $addon->id );
16422
 
16423
  if ( ! $this->is_addon_installed( $addon->id ) && FS_License_Manager::has_premium_license( $licenses ) ) {
16424
+ $plans_result = $this->get_api_site_or_plugin_scope()->get( $this->add_show_pending( "/addons/{$addon_id}/plans.json" ) );
16425
 
16426
  if ( ! isset( $plans_result->error ) ) {
16427
  $plans = array();
16749
  'trial_promotion',
16750
  'trial_expired',
16751
  'activation_complete',
16752
+ 'license_expired',
16753
  ) );
16754
  break;
16755
  case 'changed':
18532
  * @return FS_Api
18533
  */
18534
  private function get_current_or_network_user_api_scope( $flush = false ) {
18535
+ if ( ! $this->_is_network_active ||
18536
+ ( isset( $this->_user ) && $this->_user instanceof FS_User )
18537
+ ) {
18538
  return $this->get_api_user_scope( $flush );
18539
  }
18540
 
18622
  * @author Vova Feldman (@svovaf)
18623
  * @since 1.0.9
18624
  *
18625
+ * @param FS_Plugin_Plan[] $plans
18626
  */
18627
  function _check_for_trial_plans( $plans ) {
18628
+ /**
18629
+ * 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.
18630
+ *
18631
+ * @author Vova Feldman (@svovaf)
18632
+ * @since 2.1.2
18633
+ */
18634
+ if ( ! is_array( $plans ) && is_object( $plans ) ) {
18635
+ $plans = array( $plans );
18636
+ }
18637
+
18638
  $this->_storage->has_trial_plan = FS_Plan_Manager::instance()->has_trial_plan( $plans );
18639
  }
18640
 
19373
  * @param array $request
19374
  * @param int $success_cache_expiration
19375
  * @param int $failure_cache_expiration
19376
+ * @param bool $maybe_enrich_request_for_debug
19377
  *
19378
  * @return WP_Error|array
19379
  */
19380
+ static function safe_remote_post(
19381
  &$url,
19382
  $request,
19383
  $success_cache_expiration = 0,
19384
+ $failure_cache_expiration = 0,
19385
+ $maybe_enrich_request_for_debug = true
19386
  ) {
19387
  $should_cache = ($success_cache_expiration + $failure_cache_expiration > 0);
19388
 
19393
  false;
19394
 
19395
  if ( false === $response ) {
19396
+ if ( $maybe_enrich_request_for_debug ) {
19397
+ self::enrich_request_for_debug( $url, $request );
19398
+ }
19399
 
19400
  $response = wp_remote_post( $url, $request );
19401
 
20666
  * @since 2.1.0
20667
  */
20668
  function _maybe_add_gdpr_optin_ajax_handler() {
20669
+ $this->add_ajax_action( 'fetch_is_marketing_required_flag_value', array( &$this, '_fetch_is_marketing_required_flag_value_ajax_action' ) );
 
 
20670
 
20671
  if ( FS_GDPR_Manager::instance()->is_opt_in_notice_shown() ) {
20672
  $this->add_gdpr_optin_ajax_handler_and_style();
20850
  }
20851
 
20852
  #endregion
20853
+
20854
+ #----------------------------------------------------------------------------------
20855
+ #region Helper
20856
+ #----------------------------------------------------------------------------------
20857
+
20858
+ /**
20859
+ * If running with a secret key, assume it's the developer and show pending plans as well.
20860
+ *
20861
+ * @author Vova Feldman (@svovaf)
20862
+ * @since 2.1.2
20863
+ *
20864
+ * @param string $path
20865
+ *
20866
+ * @return string
20867
+ */
20868
+ function add_show_pending( $path ) {
20869
+ if ( ! $this->has_secret_key() ) {
20870
+ return $path;
20871
+ }
20872
+
20873
+ return $path . ( false !== strpos( $path, '?' ) ? '&' : '?' ) . 'show_pending=true';
20874
+ }
20875
+
20876
+ #endregion
20877
  }
vendor/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
  *
vendor/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.
vendor/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
 
vendor/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(
vendor/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 ?>">
vendor/freemius/templates/checkout.php CHANGED
@@ -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]]);
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]]);
vendor/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);
vendor/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]]);