PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.2
Jetpack – WP Security, Backup, Speed, & Growth v16.2
16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 All 503 releases
← All changes | modules/shortlinks.php +14 -6 12.9.516.2 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 /**
3 3 * Module Name: WP.me Shortlinks
4 - * Module Description: Generates shorter links using the wp.me domain.
4 + * Module Description: Share short, easy-to-remember links to your posts and pages.
5 5 * Sort Order: 8
6 6 * First Introduced: 1.1
7 7 * Requires Connection: Yes
8 8 * Auto Activate: No
@@ -12,8 +12,12 @@
12 12 *
13 13 * @package automattic/jetpack
14 14 */
15 15
16 +if ( ! defined( 'ABSPATH' ) ) {
17 + exit( 0 );
18 +}
19 +
16 20 add_filter( 'pre_get_shortlink', 'wpme_get_shortlink_handler', 1, 4 );
17 21
18 22 if ( ! function_exists( 'wpme_dec2sixtwo' ) ) {
19 23 /**
@@ -32,11 +36,11 @@
32 36 $num = abs( $num );
33 37 }
34 38
35 39 for ( $t = floor( log10( $num ) / log10( 62 ) ); $t >= 0; $t-- ) {
36 - $a = floor( $num / pow( 62, $t ) );
37 - $out = $out . substr( $index, $a, 1 );
38 - $num = $num - ( $a * pow( 62, $t ) );
40 + $a = (int) floor( $num / pow( 62, $t ) );
41 + $out .= substr( $index, $a, 1 );
42 + $num -= $a * pow( 62, $t );
39 43 }
40 44
41 45 return $out;
42 46 }
@@ -170,9 +174,10 @@
170 174 *
171 175 * @return string
172 176 */
173 177 function wpme_rest_get_shortlink( $object ) {
174 - return wpme_get_shortlink( $object['id'], array() );
178 + $object_id = $object['id'] ?? 0;
179 + return wpme_get_shortlink( $object_id, array() );
175 180 }
176 181
177 182 // Add shortlinks to the REST API Post response.
178 183 add_action( 'rest_api_init', 'wpme_rest_register_shortlinks' );
@@ -180,8 +185,11 @@
180 185 /**
181 186 * Set the Shortlink Gutenberg extension as available.
182 187 */
183 188 function wpme_set_extension_available() {
184 - Jetpack_Gutenberg::set_extension_available( 'jetpack/shortlinks' );
189 + Jetpack_Gutenberg::set_extension_available( 'shortlinks' );
185 190 }
186 191
187 192 add_action( 'init', 'wpme_set_extension_available' );
193 +
194 +require_once __DIR__ . '/shortlinks/abilities/class-shortlinks-abilities.php';
195 +\Automattic\Jetpack\Plugin\Abilities\Shortlinks_Abilities::init();