PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 104
Lasso Lite – Affiliate Link Manager & Product Displays v104
158 157 155 156 154 153 152 151 150 149 148 trunk 0.9.9 104 105 106 107 108 109 110 111 112 113 114 115 All 57 releases
← All changes | includes/class-simple-urls.php +3 -53 155104 View file →
@@ -4,11 +4,8 @@
4 4 *
5 5 * @package simple-urls
6 6 */
7 7
8 -use LassoLite\Classes\Enum;
9 -use LassoLite\Classes\Helper;
10 -
11 8 /**
12 9 * Simple URLs class.
13 10 */
14 11 class Simple_Urls {
@@ -35,18 +32,16 @@
35 32 /**
36 33 * Register Post Type.
37 34 */
38 35 public function register_post_type() {
39 - $menu_icon = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20" viewBox="0 0 100 100"><defs><clipPath id="b"><rect width="100" height="100"/></clipPath></defs><g id="a" clip-path="url(#b)"><g transform="translate(-72.918 -0.438)"><g transform="translate(90.918 0.437)"><path d="M60.056,20.152h0a8.093,8.093,0,0,0-8.244,8.172l.141,3.177c-.118,19.814-5.749,18.873-6.665,18.613V13.183A8.353,8.353,0,0,0,36.819,5h0a8.356,8.356,0,0,0-8.472,8.183V50.541c-7.743,2.007-6.385-20.85-6.385-20.85V21.736c0-4.586-4.435-8.292-9.19-8.292h0c-4.745,0-7.75,3.752-7.75,8.338l-.023,8C7.3,65.234,28.347,62,28.347,62l.011,11.943H45.3L45.29,61.962c21.954-.087,23.324-30.387,23.324-30.387V28.419A8.443,8.443,0,0,0,60.056,20.152Z" transform="translate(-5 -5)" fill="#fff"/><path d="M1.519,12.038c0,3.246,1.971,5.9,4.382,5.9H20.077c2.411,0,4.384-2.656,4.384-5.9L25.975,0H0Z" transform="translate(19.053 82.06)" fill="#fff"/></g><path d="M127.888,425.8H98.6a2.75,2.75,0,0,0-2.424,2.974v4.687a2.75,2.75,0,0,0,2.424,2.974h29.283a2.751,2.751,0,0,0,2.428-2.974v-4.687A2.751,2.751,0,0,0,127.888,425.8Z" transform="translate(9.715 -355.14)" fill="#fff"/></g></g></svg>';
40 36
41 37 $slug = 'surl';
42 - $get = Helper::GET();
43 38
44 39 $rewrite_slug_default = 'go';
45 40
46 41 $labels = array(
47 - 'name' => __( 'Lasso Lite', 'simple-urls' ), // phpcs:ignore
48 - 'singular_name' => __( 'URL', 'simple-urls' ), // phpcs:ignore
42 + 'name' => __( 'Simple URLs', 'simple-urls' ),
43 + 'singular_name' => __( 'URL', 'simple-urls' ),
49 44 'add_new' => __( 'Add New', 'simple-urls' ),
50 45 'add_new_item' => __( 'Add New URL', 'simple-urls' ),
51 46 'edit' => __( 'Edit', 'simple-urls' ),
52 47 'edit_item' => __( 'Edit URL', 'simple-urls' ),
@@ -63,9 +58,9 @@
63 58 2 => __( 'Custom field updated.', 'simple-urls' ),
64 59 3 => __( 'Custom field deleted.', 'simple-urls' ),
65 60 4 => __( 'URL updated.', 'simple-urls' ),
66 61 /* translators: %s: date and time of the revision */
67 - 5 => isset( $get['revision'] ) ? sprintf( __( 'Post restored to revision from %s', 'simple-urls' ), wp_post_revision_title( (int) $get['revision'], false ) ) : false, // phpcs:ignore
62 + 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Post restored to revision from %s', 'simple-urls' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, // phpcs:ignore
68 63 /* translators: %s: URL to view */
69 64 6 => __( 'URL updated. <a href="%s">View URL</a>', 'simple-urls' ),
70 65 7 => __( 'URL saved.', 'simple-urls' ),
71 66 8 => __( 'URL submitted.', 'simple-urls' ),
@@ -98,19 +93,11 @@
98 93 'slug' => $rewrite_slug,
99 94 'with_front' => false,
100 95 ),
101 96 'show_in_rest' => true,
102 - // WARNING | base64_encode() can be used to obfuscate code which is strongly discouraged.
103 - // Please verify that the function is used for benign reasons.
104 - // phpcs:ignore
105 - 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode( $menu_icon ),
106 97 )
107 98 );
108 99
109 - if ( ! $this->is_rewrite_url_added() ) {
110 - flush_rewrite_rules();
111 - }
112 -
113 100 }
114 101
115 102 /**
116 103 * Count and redirect function.
@@ -116,25 +103,8 @@
116 103 * Count and redirect function.
117 104 */
118 105 public function count_and_redirect() {
119 106
120 - $redirect_url = wp_unslash( $_SERVER['REDIRECT_URL'] ?? '' ); // phpcs:ignore
121 - $link = ! empty( $redirect_url ) ? $redirect_url : $_SERVER['QUERY_STRING'] ?? ''; // phpcs:ignore
122 -
123 - if ( strpos( $link, Enum::SLUG_CLOAK_FOLLOW_TWITTER ) !== false ) {
124 - update_option( Enum::FOLLOW_ON_TWITTER, true );
125 - wp_redirect( Enum::TWITTER_URL, 302 ); // phpcs:ignore
126 - }
127 -
128 - if ( strpos( $link, Enum::SLUG_CLOAK_SHARE_TWITTER ) !== false ) {
129 - update_option( Enum::SHARE_ON_TWITTER, true );
130 - wp_redirect( Enum::TWITTER_SHARE_URL, 302 ); // phpcs:ignore
131 - }
132 -
133 - if ( strpos( $link, Enum::SLUG_CLOAK_LASSO_REVIEW_URL ) !== false ) {
134 - update_option( Enum::LEAVE_A_REVIEW, true );
135 - wp_redirect( Enum::LASSO_REVIEW_URL, 302 ); // phpcs:ignore
136 - }
137 107 if ( ! is_singular( 'surl' ) ) {
138 108 return;
139 109 }
140 110
@@ -284,27 +254,7 @@
284 254 * @return bool if the url submitted is valid or not
285 255 */
286 256 public static function validate_url( $url ) {
287 257 return ( ( strpos( $url, 'http://' ) === 0 || strpos( $url, 'https://' ) === 0 ) && filter_var( $url, FILTER_VALIDATE_URL ) !== false );
288 - }
289 -
290 - /**
291 - * Check the plugin is already added rewrite url
292 - *
293 - * @return bool
294 - */
295 - private function is_rewrite_url_added() {
296 - $is_added = false;
297 - $rewrite_rules = get_option( 'rewrite_rules' );
298 - if ( ! empty( $rewrite_rules ) ) {
299 - foreach ( $rewrite_rules as $rewrite_key => $rewrite_rule ) {
300 - if ( strpos( $rewrite_key, 'go/[^/]' ) !== false ) {
301 - $is_added = true;
302 - break;
303 - }
304 - }
305 - }
306 -
307 - return $is_added;
308 258 }
309 259
310 260 }