Gallery Custom Links - Version 2.0.5

Version Description

(2021-08-31) = * Update: Enhanced security and updated common librairies. * Info: If you like the plugin, your reviews are welcome here. Thank you :)

Download this release

Release Info

Developer TigrouMeow
Plugin Icon 128x128 Gallery Custom Links
Version 2.0.5
Comparing to
See all releases

Code changes from version 2.0.4 to 2.0.5

common/admin.php CHANGED
@@ -5,8 +5,8 @@ if ( !class_exists( 'MeowCommon_Admin' ) ) {
5
  class MeowCommon_Admin {
6
 
7
  public static $loaded = false;
8
- public static $version = "3.3";
9
- public static $admin_version = "3.3";
10
 
11
  public $prefix; // prefix used for actions, filters (mfrh)
12
  public $mainfile; // plugin main file (media-file-renamer.php)
@@ -136,7 +136,7 @@ if ( !class_exists( 'MeowCommon_Admin' ) ) {
136
  $html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
137
  checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
138
  $html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed. <b>Once activated, an option will be added in your General settings to display it again.</b></small>', $this->domain );
139
- echo $html;
140
  }
141
 
142
  function is_registered() {
@@ -149,14 +149,13 @@ if ( !class_exists( 'MeowCommon_Admin' ) ) {
149
  $html = ob_get_contents();
150
  ob_end_clean();
151
  $html = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $html );
152
- echo $html;
153
  }
154
 
155
  function admin_meow_apps() {
156
  echo "<div id='meow-common-dashboard'></div>";
157
-
158
  echo "<div style='display: none;' id='meow-common-phpinfo'>";
159
- echo $this->get_phpinfo();
160
  echo "</div>";
161
  }
162
 
5
  class MeowCommon_Admin {
6
 
7
  public static $loaded = false;
8
+ public static $version = "3.5";
9
+ public static $admin_version = "3.5";
10
 
11
  public $prefix; // prefix used for actions, filters (mfrh)
12
  public $mainfile; // plugin main file (media-file-renamer.php)
136
  $html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
137
  checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
138
  $html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed. <b>Once activated, an option will be added in your General settings to display it again.</b></small>', $this->domain );
139
+ echo wp_kses_post( $html );
140
  }
141
 
142
  function is_registered() {
149
  $html = ob_get_contents();
150
  ob_end_clean();
151
  $html = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $html );
152
+ echo wp_kses_post( $html );
153
  }
154
 
155
  function admin_meow_apps() {
156
  echo "<div id='meow-common-dashboard'></div>";
 
157
  echo "<div style='display: none;' id='meow-common-phpinfo'>";
158
+ echo wp_kses_post( $this->get_phpinfo() );
159
  echo "</div>";
160
  }
161
 
common/classes/rest.php CHANGED
@@ -6,12 +6,6 @@ class MeowCommon_Classes_Rest
6
  static public $instance = null;
7
 
8
  static public function init_once() {
9
- if ( !function_exists( 'wp_get_current_user' ) ) {
10
- return;
11
- }
12
- if ( !current_user_can( 'administrator' ) ) {
13
- return;
14
- }
15
  if ( !MeowCommon_Classes_Rest::$instance ) {
16
  MeowCommon_Classes_Rest::$instance = new self();
17
  }
@@ -22,28 +16,49 @@ class MeowCommon_Classes_Rest
22
  }
23
 
24
  function rest_api_init() {
 
 
 
25
  register_rest_route( $this->namespace, '/empty_request/', [
26
  'methods' => 'POST',
 
 
 
27
  'callback' => [ $this, 'empty_request' ]
28
  ]);
29
  register_rest_route( $this->namespace, '/file_operation/', [
30
  'methods' => 'POST',
 
 
 
31
  'callback' => [ $this, 'file_operation' ]
32
  ]);
33
  register_rest_route( $this->namespace, '/sql_request/', [
34
  'methods' => 'POST',
 
 
 
35
  'callback' => [ $this, 'sql_request' ]
36
  ]);
37
  register_rest_route( $this->namespace, '/error_logs/', [
38
  'methods' => 'POST',
 
 
 
39
  'callback' => [ $this, 'rest_error_logs' ]
40
  ]);
41
  register_rest_route( $this->namespace, '/all_settings/', [
42
  'methods' => 'GET',
 
 
 
43
  'callback' => [ $this, 'rest_all_settings' ]
44
  ]);
45
  register_rest_route( $this->namespace, '/update_option/', [
46
  'methods' => 'POST',
 
 
 
47
  'callback' => [ $this, 'rest_update_option' ]
48
  ]);
49
  }
@@ -70,22 +85,44 @@ class MeowCommon_Classes_Rest
70
  return new WP_REST_Response( [ 'success' => true, 'data' => $count ], 200 );
71
  }
72
 
73
- function rest_all_settings() {
74
- $settings = array(
75
- 'meowapps_hide_meowapps' => get_option( 'meowapps_hide_meowapps', false ),
76
- 'force_sslverify' => get_option( 'force_sslverify', false )
 
77
  );
78
- return new WP_REST_Response([ 'success' => true, 'data' => $settings ], 200 );
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
 
81
  function rest_update_option( $request ) {
82
  $params = $request->get_json_params();
83
  try {
84
- $result = update_option( $params['name'], $params['value'] );
85
- return new WP_REST_Response([ 'success' => $result ], 200 );
86
- }
 
 
 
 
 
 
 
 
 
87
  catch (Exception $e) {
88
- return new WP_REST_Response([ 'success' => false, 'message' => $e->getMessage() ], 500 );
89
  }
90
  }
91
 
6
  static public $instance = null;
7
 
8
  static public function init_once() {
 
 
 
 
 
 
9
  if ( !MeowCommon_Classes_Rest::$instance ) {
10
  MeowCommon_Classes_Rest::$instance = new self();
11
  }
16
  }
17
 
18
  function rest_api_init() {
19
+ if ( !current_user_can( 'administrator' ) ) {
20
+ return;
21
+ }
22
  register_rest_route( $this->namespace, '/empty_request/', [
23
  'methods' => 'POST',
24
+ 'permission_callback' => function () {
25
+ return current_user_can( 'administrator' );
26
+ },
27
  'callback' => [ $this, 'empty_request' ]
28
  ]);
29
  register_rest_route( $this->namespace, '/file_operation/', [
30
  'methods' => 'POST',
31
+ 'permission_callback' => function () {
32
+ return current_user_can( 'administrator' );
33
+ },
34
  'callback' => [ $this, 'file_operation' ]
35
  ]);
36
  register_rest_route( $this->namespace, '/sql_request/', [
37
  'methods' => 'POST',
38
+ 'permission_callback' => function () {
39
+ return current_user_can( 'administrator' );
40
+ },
41
  'callback' => [ $this, 'sql_request' ]
42
  ]);
43
  register_rest_route( $this->namespace, '/error_logs/', [
44
  'methods' => 'POST',
45
+ 'permission_callback' => function () {
46
+ return current_user_can( 'administrator' );
47
+ },
48
  'callback' => [ $this, 'rest_error_logs' ]
49
  ]);
50
  register_rest_route( $this->namespace, '/all_settings/', [
51
  'methods' => 'GET',
52
+ 'permission_callback' => function () {
53
+ return current_user_can( 'administrator' );
54
+ },
55
  'callback' => [ $this, 'rest_all_settings' ]
56
  ]);
57
  register_rest_route( $this->namespace, '/update_option/', [
58
  'methods' => 'POST',
59
+ 'permission_callback' => function () {
60
+ return current_user_can( 'administrator' );
61
+ },
62
  'callback' => [ $this, 'rest_update_option' ]
63
  ]);
64
  }
85
  return new WP_REST_Response( [ 'success' => true, 'data' => $count ], 200 );
86
  }
87
 
88
+ // List all the options with their default values.
89
+ function list_options() {
90
+ return array(
91
+ 'meowapps_hide_meowapps' => false,
92
+ 'force_sslverify' => false
93
  );
94
+ }
95
+
96
+ function get_all_options() {
97
+ $options = $this->list_options();
98
+ $current_options = array();
99
+ foreach ( $options as $option => $default ) {
100
+ $current_options[$option] = get_option( $option, $default );
101
+ }
102
+ return $current_options;
103
+ }
104
+
105
+ function rest_all_settings() {
106
+ return new WP_REST_Response( [ 'success' => true, 'data' => $this->get_all_options() ], 200 );
107
  }
108
 
109
  function rest_update_option( $request ) {
110
  $params = $request->get_json_params();
111
  try {
112
+ $name = $params['name'];
113
+ $options = $this->list_options();
114
+ if ( !array_key_exists( $name, $options ) ) {
115
+ return new WP_REST_Response([ 'success' => false, 'message' => 'This option does not exist.' ], 200 );
116
+ }
117
+ $value = is_bool( $params['value'] ) ? ( $params['value'] ? '1' : '' ) : $params['value'];
118
+ $success = update_option( $name, $value );
119
+ if ( !$success ) {
120
+ return new WP_REST_Response( [ 'success' => false, 'message' => 'Could not update option.' ], 200 );
121
+ }
122
+ return new WP_REST_Response( [ 'success' => true, 'data' => $value ], 200 );
123
+ }
124
  catch (Exception $e) {
125
+ return new WP_REST_Response( [ 'success' => false, 'message' => $e->getMessage() ], 500 );
126
  }
127
  }
128
 
common/classes/rest_license.php CHANGED
@@ -8,19 +8,22 @@ class MeowCommon_Classes_Rest_License
8
  public function __construct( &$licenser ) {
9
  $this->licenser = $licenser;
10
  $this->namespace = "meow-licenser/{$licenser->prefix}/v1";
11
- if ( !current_user_can( 'administrator' ) ) {
12
- return;
13
- }
14
  add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
15
  }
16
 
17
  function rest_api_init() {
18
  register_rest_route( $this->namespace, '/get_license/', [
19
  'methods' => 'POST',
 
 
 
20
  'callback' => [ $this, 'get_license' ]
21
  ]);
22
  register_rest_route( $this->namespace, '/set_license/', [
23
  'methods' => 'POST',
 
 
 
24
  'callback' => [ $this, 'set_license' ]
25
  ]);
26
  }
8
  public function __construct( &$licenser ) {
9
  $this->licenser = $licenser;
10
  $this->namespace = "meow-licenser/{$licenser->prefix}/v1";
 
 
 
11
  add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
12
  }
13
 
14
  function rest_api_init() {
15
  register_rest_route( $this->namespace, '/get_license/', [
16
  'methods' => 'POST',
17
+ 'permission_callback' => function () {
18
+ return current_user_can( 'administrator' );
19
+ },
20
  'callback' => [ $this, 'get_license' ]
21
  ]);
22
  register_rest_route( $this->namespace, '/set_license/', [
23
  'methods' => 'POST',
24
+ 'permission_callback' => function () {
25
+ return current_user_can( 'administrator' );
26
+ },
27
  'callback' => [ $this, 'set_license' ]
28
  ]);
29
  }
common/classes/updater.php CHANGED
@@ -217,7 +217,9 @@ class MeowCommon_Classes_Updater {
217
  // build a plugin list row, with update notification
218
  $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
219
  # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
220
- echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
 
 
221
  echo '<td colspan="3" class="plugin-update colspanchange">';
222
  echo '<div class="update-message notice inline notice-warning notice-alt">';
223
 
@@ -504,7 +506,7 @@ class MeowCommon_Classes_Updater {
504
  'edd_action' => 'get_version',
505
  'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
506
  'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
507
- 'slug' => $_REQUEST['slug'],
508
  'author' => $data['author'],
509
  'url' => home_url(),
510
  'beta' => ! empty( $data['beta'] )
217
  // build a plugin list row, with update notification
218
  $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
219
  # <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
220
+ echo '<tr class="plugin-update-tr" id="' . esc_html( $this->slug ) .
221
+ '-update" data-slug="' . esc_attr( $this->slug ) . '" data-plugin="' .
222
+ esc_html( $this->slug . '/' . $file ) . '">';
223
  echo '<td colspan="3" class="plugin-update colspanchange">';
224
  echo '<div class="update-message notice inline notice-warning notice-alt">';
225
 
506
  'edd_action' => 'get_version',
507
  'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
508
  'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
509
+ 'slug' => sanitize_text_field( $_REQUEST['slug'] ),
510
  'author' => $data['author'],
511
  'url' => home_url(),
512
  'beta' => ! empty( $data['beta'] )
common/helpers.php CHANGED
@@ -171,9 +171,11 @@ if ( !class_exists( 'MeowCommon_Helpers' ) ) {
171
  }
172
  }
173
 
174
- if ( MeowCommon_Helpers::is_rest() ) {
175
- ini_set( 'display_errors', 0 );
176
- }
 
 
177
  }
178
 
179
  ?>
171
  }
172
  }
173
 
174
+ // Asked by WP Security Team to remove this.
175
+
176
+ // if ( MeowCommon_Helpers::is_rest() ) {
177
+ // ini_set( 'display_errors', 0 );
178
+ // }
179
  }
180
 
181
  ?>
common/img/contact-form-block.png ADDED
Binary file
common/img/kinsta.png DELETED
Binary file
common/img/meow-analytics.png ADDED
Binary file
common/img/meowapps.png DELETED
Binary file
common/img/stackpath.png DELETED
Binary file
common/licenser.php CHANGED
@@ -43,7 +43,7 @@ if ( !class_exists( 'MeowCommon_Licenser' ) ) {
43
 
44
  function retry_validation() {
45
  if ( isset( $_POST[$this->prefix . '_pro_serial'] ) ) {
46
- $serial = $_POST[$this->prefix . '_pro_serial'];
47
  $this->validate_pro( $serial );
48
  }
49
  }
43
 
44
  function retry_validation() {
45
  if ( isset( $_POST[$this->prefix . '_pro_serial'] ) ) {
46
+ $serial = sanitize_text_field( $_POST[$this->prefix . '_pro_serial'] );
47
  $this->validate_pro( $serial );
48
  }
49
  }
common/releases.txt CHANGED
@@ -1,6 +1,13 @@
1
  Releases of the Meow Commmon has to be carefully made, and version_compare
2
  should be used when big changes are made.
3
 
 
 
 
 
 
 
 
4
  = 3.3 (2020/12/19) =
5
  * is_cornerstone_builder()
6
  * is_pagebuilder_request()
1
  Releases of the Meow Commmon has to be carefully made, and version_compare
2
  should be used when big changes are made.
3
 
4
+ = 3.5 (2021/08/31) =
5
+ * Better security.
6
+ * New images.
7
+
8
+ = 3.4 (2021/08/05) =
9
+ * Sanitize and escaping.
10
+
11
  = 3.3 (2020/12/19) =
12
  * is_cornerstone_builder()
13
  * is_pagebuilder_request()
gallery-custom-links.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Gallery Custom Links
4
  Plugin URI: https://meowapps.com
5
  Description: Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
6
- Version: 2.0.4
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: gallery-custom-links
@@ -14,7 +14,7 @@ http://www.opensource.org/licenses/mit-license.php
14
  http://www.gnu.org/licenses/gpl.html
15
  */
16
 
17
- define( 'MGCL_VERSION', '2.0.4' );
18
  define( 'MGCL_PREFIX', 'mgcl' );
19
  define( 'MGCL_DOMAIN', 'gallery-custom-links' );
20
  define( 'MGCL_ENTRY', __FILE__ );
3
  Plugin Name: Gallery Custom Links
4
  Plugin URI: https://meowapps.com
5
  Description: Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
6
+ Version: 2.0.5
7
  Author: Jordy Meow
8
  Author URI: https://meowapps.com
9
  Text Domain: gallery-custom-links
14
  http://www.gnu.org/licenses/gpl.html
15
  */
16
 
17
+ define( 'MGCL_VERSION', '2.0.5' );
18
  define( 'MGCL_PREFIX', 'mgcl' );
19
  define( 'MGCL_DOMAIN', 'gallery-custom-links' );
20
  define( 'MGCL_ENTRY', __FILE__ );
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: TigrouMeow
3
  Tags: custom, links, gallery, gutenberg
4
  Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a950f61832f
5
  Requires at least: 5.0
6
- Tested up to: 5.7.2
7
  Requires PHP: 7.0
8
- Stable tag: 2.0.4
9
 
10
  Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
11
 
@@ -42,9 +42,12 @@ Replace all the files. Nothing else to do.
42
 
43
  == Changelog ==
44
 
 
 
 
 
45
  = 2.0.4 (2021-07-05) =
46
  * Update: Refresh the UI libraries and common librairies to ensure compatibility with other plugins.
47
- * Info: If you like the plugin, your reviews are welcome [here](https://wordpress.org/support/plugin/gallery-custom-links/reviews/?rate=5#new-post). Thank you and Happy Summer Holidays! :)
48
 
49
  = 2.0.3 (2021-03-01) =
50
  * Update: New Meow Common (which is needed for compatibility with other plugins).
3
  Tags: custom, links, gallery, gutenberg
4
  Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a950f61832f
5
  Requires at least: 5.0
6
+ Tested up to: 5.8
7
  Requires PHP: 7.0
8
+ Stable tag: 2.0.5
9
 
10
  Gallery Custom Links allows you to link images from galleries to a specified URL. Tested with WordPress Gallery, Gutenberg, the Meow Gallery and others.
11
 
42
 
43
  == Changelog ==
44
 
45
+ = 2.0.5 (2021-08-31) =
46
+ * Update: Enhanced security and updated common librairies.
47
+ * Info: If you like the plugin, your reviews are welcome [here](https://wordpress.org/support/plugin/gallery-custom-links/reviews/?rate=5#new-post). Thank you :)
48
+
49
  = 2.0.4 (2021-07-05) =
50
  * Update: Refresh the UI libraries and common librairies to ensure compatibility with other plugins.
 
51
 
52
  = 2.0.3 (2021-03-01) =
53
  * Update: New Meow Common (which is needed for compatibility with other plugins).