--- a/url-shortify/lite/includes/Admin.php
+++ b/url-shortify/lite/includes/Admin.php
@@ -200,6 +200,7 @@
'usParams',
[
'ajaxurl' => admin_url( 'admin-ajax.php' ),
+ 'security' => wp_create_nonce( KC_US_AJAX_SECURITY ),
]
);
@@ -224,6 +225,7 @@
'usParams',
[
'ajaxurl' => admin_url( 'admin-ajax.php' ),
+ 'security' => wp_create_nonce( KC_US_AJAX_SECURITY ),
]
);
--- a/url-shortify/lite/includes/Admin/DB/DB.php
+++ b/url-shortify/lite/includes/Admin/DB/DB.php
@@ -82,6 +82,13 @@
public $links_tags;
/**
+ * @var Object|Favorites_Links
+ *
+ * @since 1.12.2
+ */
+ public $favorites_links;
+
+ /**
* constructor.
*
* @since 1.0.0
@@ -98,5 +105,6 @@
$this->api_keys = new API_Keys();
$this->tags = new Tags();
$this->links_tags = new Links_Tags();
+ $this->favorites_links = new Favorites_Links();
}
}
--- a/url-shortify/lite/includes/Admin/DB/Favorites_Links.php
+++ b/url-shortify/lite/includes/Admin/DB/Favorites_Links.php
@@ -0,0 +1,87 @@
+<?php
+
+namespace KaizenCodersURL_ShortifyAdminDB;
+
+use KaizenCodersURL_ShortifyHelper;
+
+class Favorites_Links extends Base_DB {
+ public function __construct() {
+ global $wpdb;
+ parent::__construct();
+
+ $this->table_name = $wpdb->prefix . 'kc_us_favorites_links';
+
+ $this->primary_key = 'id';
+ }
+
+ /**
+ * Get columns and formats
+ *
+ * @since 1.12.2
+ */
+ public function get_columns() {
+ return [
+ 'id' => '%d',
+ 'link_id' => '%d',
+ 'user_id' => '%d',
+ 'created_at' => '%s',
+ ];
+ }
+
+ /**
+ * Get default column values
+ *
+ * @since 1.12.2
+ */
+ public function get_column_defaults() {
+ return [
+ 'link_id' => null,
+ 'user_id_id' => null,
+ 'created_at' => Helper::get_current_date_time(),
+ ];
+ }
+
+ /**
+ * @param $user_id
+ * @param $link_id
+ *
+ * @return bool|int|mysqli_result|null
+ */
+ public function toggle_favorite( $user_id, $link_id ) {
+ global $wpdb;
+
+ $where = $wpdb->prepare( "user_id = %d AND link_id = %d", $user_id, $link_id );
+
+ // Check if it exists
+ $is_exists = $wpdb->get_var( "SELECT id FROM {$this->table_name} WHERE $where" );
+
+ if ( ! empty( $is_exists ) ) {
+ return $this->delete_by_condition( $where );
+ } else {
+ return $this->insert(
+ [
+ 'user_id' => absint( $user_id ),
+ 'link_id' => absint( $link_id ),
+ ],
+ );
+ }
+ }
+
+ /**
+ * Get User Favorites Links.
+ *
+ * @param $user_id
+ *
+ * @return array
+ */
+ public function get_by_user_id( $user_id ) {
+ global $wpdb;
+
+ $where = $wpdb->prepare( "user_id = %d", absint( $user_id ) );
+
+ $results = $this->get_columns_by_condition( [ 'link_id' ], $where );
+
+ return wp_list_pluck( $results, 'link_id' );
+ }
+
+}
No newline at end of file
--- a/url-shortify/lite/includes/Admin/Links_Table.php
+++ b/url-shortify/lite/includes/Admin/Links_Table.php
@@ -320,11 +320,29 @@
$url = esc_url( $item['url'] );
$name = stripslashes( $item['name'] );
$slug = $item['slug'];
+ $star_html = '';
+
+ if ( US()->is_pro() ) {
+ $user_id = get_current_user_id();
+
+ $user_favorites = US()->db->favorites_links->get_by_user_id( $user_id );
+ $is_starred = in_array( $link_id, $user_favorites );
+
+ $starred_class = $is_starred ? 'starred' : '';
+ $star_icon = $is_starred ? '<span class="dashicons dashicons-star-filled"></span>' : '<span class="dashicons dashicons-star-empty"></span>';
+ $tooltip = $is_starred ? __( 'Remove from Favorites', 'url-shortify' ) : __( 'Add to Favorites', 'url-shortify' );
+
+ $star_html = sprintf(
+ '<span class="us-star-toggle cursor-pointer mr-2 %s" data-id="%d" title="%s">%s</span>',
+ $starred_class, $link_id, $tooltip, $star_icon
+ );
+ }
$short_link = esc_attr( Helper::get_short_link( $slug, $item ) );
- $title = sprintf( '<span class="flex w-full"><img class="h-6 w-6 mr-2" style="min-width: 1.5rem;" src="https://www.google.com/s2/favicons?domain=%s" title="%s"/><strong>%s</strong></span>',
- $url, $url, $name );
+ // Injected $star_html as the first %s in the sprintf statement
+ $title = sprintf( '<span class="flex w-full">%s<img class="h-6 w-6 mr-2" style="min-width: 1.5rem;" src="https://www.google.com/s2/favicons?domain=%s" title="%s"/><strong>%s</strong></span>',
+ $star_html, $url, $url, $name );
$actions = [
'edit' => sprintf( __( '<a href="%s" class="text-indigo-600">Edit</a>', 'url-shortify' ),
--- a/url-shortify/lite/includes/Install.php
+++ b/url-shortify/lite/includes/Install.php
@@ -95,6 +95,10 @@
'1.11.5' => [
'kc_us_update_1115_create_tags_tables',
],
+
+ '1.12.2' => [
+ 'kc_us_update_1122_create_favorites_links_table',
+ ]
];
/**
@@ -581,6 +585,7 @@
$tables .= self::get_191_schema( $collate );
$tables .= self::get_195_schema( $collate );
$tables .= self::get_1115_schema( $collate );
+ $tables .= self::get_1122_schema( $collate );
return $tables;
}
@@ -1005,4 +1010,25 @@
) $collate;
";
}
+
+ /**
+ * Create User Favorites Links Table.
+ *
+ * @since 1.12.2
+ */
+ public static function get_1122_schema( $collate = '' ) {
+ global $wpdb;
+ return "
+ CREATE TABLE `{$wpdb->prefix}kc_us_favorites_links` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `user_id` bigint(20) unsigned NOT NULL,
+ `link_id` bigint(20) unsigned NOT NULL,
+ `created_at` datetime DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (id),
+ UNIQUE KEY user_link (user_id, link_id),
+ KEY user_id (user_id),
+ KEY link_id (link_id)
+ ) $collate;
+ ";
+ }
}
--- a/url-shortify/lite/includes/Promo.php
+++ b/url-shortify/lite/includes/Promo.php
@@ -62,7 +62,11 @@
if ( in_array( $option_name, $valid_options ) ) {
if ( isset( $_GET['redirect_to'] ) && ! empty( $_GET['redirect_to'] ) ) {
$redirect_to = esc_url_raw( $_GET['redirect_to'] );
- wp_redirect( $redirect_to );
+ if( $this->is_valid_redirect_to( $redirect_to ) ) {
+ wp_redirect( $redirect_to );
+ } else {
+ wp_safe_redirect( US()->get_pricing_url() );
+ }
} elseif ( 'lifetime' === sanitize_text_field( Helper::get_data( $_GET, 'billing_cycle', '' ) ) ) {
wp_safe_redirect( US()->get_pricing_url( 'lifetime' ) );
} elseif ( (boolean) Helper::get_data( $_GET, 'landing', false ) ) {
@@ -81,6 +85,39 @@
}
/**
+ * Get Valid Redirect To URLs.
+ *
+ * @return string[]
+ *
+ * @since 1.12.2
+ */
+ public function get_valid_redirect_to() {
+ return [
+ US()->get_pricing_url(),
+ US()->get_landing_page_url(),
+ 'https://kaizencoders.com/url-shortify',
+ 'https://kaizencoders.com',
+ 'https://kaizencoders.com/magic-link',
+ 'https://kaizencoders.com/logify',
+ 'https://kaizencoders.com/update-urls',
+ ];
+ }
+
+ /**
+ * Is Valid Redirect To URL.
+ *
+ * @param string $url
+ *
+ * @return bool
+ *
+ * @since 1.12.2
+ */
+ public function is_valid_redirect_to( $url ) {
+ $valid_urls = $this->get_valid_redirect_to();
+ return in_array( $url, $valid_urls, true );
+ }
+
+ /**
* Handle promotions activity.
*
* @since 1.5.12.2
--- a/url-shortify/lite/includes/Uninstall.php
+++ b/url-shortify/lite/includes/Uninstall.php
@@ -51,6 +51,8 @@
$wpdb->prefix . 'kc_us_domains',
$wpdb->prefix . 'kc_us_utm_presets',
$wpdb->prefix . 'kc_us_tracking_pixels',
+ $wpdb->prefix . 'kc_us_tags',
+ $wpdb->prefix . 'kc_us_favorites_links',
];
foreach ( $tables as $table ) {
--- a/url-shortify/lite/includes/Upgrade/update-functions.php
+++ b/url-shortify/lite/includes/Upgrade/update-functions.php
@@ -339,4 +339,9 @@
/**************** 1.11.5 *******************/
function kc_us_update_1115_create_tags_tables() {
Install::create_tables( '1.11.5' );
+}
+
+/**************** 1.12.2 *******************/
+function kc_us_update_1122_create_favorites_links_table() {
+ Install::create_tables( '1.12.2' );
}
No newline at end of file
--- a/url-shortify/url-shortify.php
+++ b/url-shortify/url-shortify.php
@@ -15,7 +15,7 @@
* Plugin Name: URL Shortify
* Plugin URI: https://kaizencoders.com/url-shortify
* Description: URL Shortify helps you beautify, manage, share & cloak any links on or off of your WordPress website. Create links that look how you want using your own domain name!
- * Version: 1.12.1
+ * Version: 1.12.2
* Author: KaizenCoders
* Author URI: https://kaizencoders.com/
* Tested up to: 6.9
@@ -45,7 +45,7 @@
* @since 1.0.0
*/
if ( ! defined( 'KC_US_PLUGIN_VERSION' ) ) {
- define( 'KC_US_PLUGIN_VERSION', '1.12.1' );
+ define( 'KC_US_PLUGIN_VERSION', '1.12.2' );
}
/**
--- a/url-shortify/vendor/composer/installed.php
+++ b/url-shortify/vendor/composer/installed.php
@@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'kaizen-coders/url-shortify',
- 'pretty_version' => '1.12.1',
- 'version' => '1.12.1.0',
- 'reference' => '0e2bd359ee1ba31d7be0516ae9858f073a94e348',
+ 'pretty_version' => '1.12.2',
+ 'version' => '1.12.2.0',
+ 'reference' => '9d5e414e56f9087e0f1c758955b50bcdfc2ffb7b',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -20,9 +20,9 @@
'dev_requirement' => false,
),
'kaizen-coders/url-shortify' => array(
- 'pretty_version' => '1.12.1',
- 'version' => '1.12.1.0',
- 'reference' => '0e2bd359ee1ba31d7be0516ae9858f073a94e348',
+ 'pretty_version' => '1.12.2',
+ 'version' => '1.12.2.0',
+ 'reference' => '9d5e414e56f9087e0f1c758955b50bcdfc2ffb7b',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),