| 1 |
<?php |
| 2 |
/** |
| 3 |
* The "Quick Link Creation" feature enables users to generate BetterLinks instantly while browsing online content, facilitating seamless sharing of branded URLs for blog posts or important links. |
| 4 |
* |
| 5 |
* @package BetterLinks/Create-Link-Externally |
| 6 |
* @since 1.9.2 |
| 7 |
*/ |
| 8 |
|
| 9 |
// @-collapse |
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
|
| 12 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound |
| 13 |
die( 'You are not allowed here.' ); |
| 14 |
} |
| 15 |
if ( empty( $prevent_unwanted_click ) ) { |
| 16 |
$link_title = ! empty( $results['link_title'] ) ? $results['link_title'] : '[No Title]'; |
| 17 |
$target_url = ! empty( $results['target_url'] ) ? $results['target_url'] : ''; |
| 18 |
$short_url = ! empty( $results['short_url'] ) ? $results['short_url'] : ''; |
| 19 |
$short_url = site_url( $short_url ); |
| 20 |
$encoded_short_url = rawurlencode( $short_url ); |
| 21 |
|
| 22 |
$nofollow = ! empty( $results['nofollow'] ) ? 'checked' : ''; |
| 23 |
$sponsored = ! empty( $results['sponsored'] ) ? 'checked' : ''; |
| 24 |
$param_forwarding = ! empty( $results['param_forwarding'] ) ? 'checked' : ''; |
| 25 |
$track_me = ! empty( $results['track_me'] ) ? 'checked' : ''; |
| 26 |
$redirect_type = ! empty( $results['redirect_type'] ) ? $results['redirect_type'] : '307'; |
| 27 |
$link_date = ! empty( $results['link_date'] ) ? gmdate( 'd F Y', strtotime( $results['link_date'] ) ) : ''; |
| 28 |
$category = ! empty( $results['cat_data'] ) ? sanitize_text_field( $results['cat_data']['term_name'] ) : ''; |
| 29 |
|
| 30 |
$social_share = ! empty( $initial_values['social_share'] ) ? $initial_values['social_share'] : false; |
| 31 |
$powered_by = ! empty( $initial_values['powered_by'] ) ? $initial_values['powered_by'] : false; |
| 32 |
$telegram = BETTERLINKS_PLUGIN_ROOT_URI . 'assets/images/telegram.png'; |
| 33 |
$copy_icon = BETTERLINKS_PLUGIN_ROOT_URI . 'assets/images/copy-icon-1.svg'; |
| 34 |
$redirect_types = array( |
| 35 |
'307' => '307', |
| 36 |
'301' => '301', |
| 37 |
'302' => '302', |
| 38 |
'cloak' => 'Cloaked', |
| 39 |
); |
| 40 |
|
| 41 |
// Toggle rows for the "Link Options" card. Rendering these from an array |
| 42 |
// keeps the markup flat and gives every row the same labelled state pill, |
| 43 |
// so on/off reads at a glance instead of as a run of coloured text. |
| 44 |
$link_options = array( |
| 45 |
array( |
| 46 |
'label' => __( 'No Follow', 'betterlinks' ), |
| 47 |
'state' => $nofollow, |
| 48 |
), |
| 49 |
array( |
| 50 |
'label' => __( 'Parameter Forwarding', 'betterlinks' ), |
| 51 |
'state' => $param_forwarding, |
| 52 |
), |
| 53 |
array( |
| 54 |
'label' => __( 'Tracking', 'betterlinks' ), |
| 55 |
'state' => $track_me, |
| 56 |
), |
| 57 |
array( |
| 58 |
'label' => __( 'Sponsored', 'betterlinks' ), |
| 59 |
'state' => $sponsored, |
| 60 |
), |
| 61 |
); |
| 62 |
} |
| 63 |
$betterlinks_logo = BETTERLINKS_PLUGIN_ROOT_URI . 'assets/images/full-logo.svg'; |
| 64 |
$betterlinks_mark = BETTERLINKS_PLUGIN_ROOT_URI . 'assets/images/logo-large.svg'; |
| 65 |
wp_register_style( 'betterlinks-cle', BETTERLINKS_ASSETS_URI . 'css/betterlinks-cle.css', array(), BETTERLINKS_VERSION ); |
| 66 |
wp_register_script( 'betterlinks-cle', BETTERLINKS_ASSETS_URI . 'js/betterlinks-cle.core.min.js', array( 'jquery', 'clipboard' ), BETTERLINKS_VERSION, true ); |
| 67 |
?> |
| 68 |
<!DOCTYPE html> |
| 69 |
<html lang="en"> |
| 70 |
<head> |
| 71 |
<meta charset="UTF-8"> |
| 72 |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 73 |
<title><?php esc_html_e( '🎉 Here is your Quick Link', 'betterlinks' ); ?></title> |
| 74 |
<link rel="preconnect" href="https://fonts.googleapis.com"> |
| 75 |
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
| 76 |
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet"> <?php // phpcs:ignore ?> |
| 77 |
<?php wp_print_styles( 'betterlinks-cle' ); ?> |
| 78 |
<?php wp_site_icon(); ?> |
| 79 |
</head> |
| 80 |
<body> |
| 81 |
<?php |
| 82 |
if ( ! empty( $prevent_unwanted_click ) ) { |
| 83 |
?> |
| 84 |
<div class="bl-cle"> |
| 85 |
<main class="bl-cle__main bl-cle__main--blocked"> |
| 86 |
<div class="bl-cle__brand"> |
| 87 |
<img src="<?php echo esc_url( $betterlinks_mark ); ?>" alt="BetterLinks" width="36" height="36" /> |
| 88 |
</div> |
| 89 |
<h1 class="bl-cle__title"><?php esc_html_e( 'Quick Link creation is unavailable for this URL', 'betterlinks' ); ?></h1> |
| 90 |
<p class="bl-cle__subtitle"><?php esc_html_e( 'This page can’t be shortened. Head back and try a different link.', 'betterlinks' ); ?></p> |
| 91 |
<div class="bl-cle__actions bl-cle__actions--center"> |
| 92 |
<a class="bl-cle__back" href="#" onclick="history.back(); return false;" title="<?php esc_attr_e( 'Go Back', 'betterlinks' ); ?>"> |
| 93 |
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 12H5M11 18l-6-6 6-6" /></svg> |
| 94 |
<?php esc_html_e( 'Go Back', 'betterlinks' ); ?> |
| 95 |
</a> |
| 96 |
</div> |
| 97 |
</main> |
| 98 |
<?php if ( ! empty( $powered_by ) ) { ?> |
| 99 |
<footer class="bl-cle__credit"> |
| 100 |
<span> |
| 101 |
<?php esc_html_e( 'Powered By', 'betterlinks' ); ?> |
| 102 |
<img src="<?php echo esc_url( $betterlinks_logo ); ?>" alt="BetterLinks" title="BetterLinks" /> |
| 103 |
</span> |
| 104 |
</footer> |
| 105 |
<?php } ?> |
| 106 |
</div> |
| 107 |
</body> |
| 108 |
</html> |
| 109 |
<?php |
| 110 |
exit; |
| 111 |
} |
| 112 |
?> |
| 113 |
<div id="confetti"></div> |
| 114 |
<div class="bl-cle"> |
| 115 |
<main class="bl-cle__main"> |
| 116 |
<header class="bl-cle__head"> |
| 117 |
<div class="bl-cle__brand"> |
| 118 |
<img src="<?php echo esc_url( $betterlinks_mark ); ?>" alt="BetterLinks" width="36" height="36" /> |
| 119 |
</div> |
| 120 |
<h1 class="bl-cle__title"><?php esc_html_e( '🎉 Here is your Quick Link', 'betterlinks' ); ?></h1> |
| 121 |
<p class="bl-cle__subtitle"><?php esc_html_e( 'Your branded short link is ready to copy and share.', 'betterlinks' ); ?></p> |
| 122 |
</header> |
| 123 |
|
| 124 |
<div class="bl-cle__urlbar"> |
| 125 |
<a class="bl-cle__url" href="<?php echo esc_url( $short_url ); ?>" target="_blank" rel="noopener" title="<?php echo esc_attr( $short_url ); ?>"> |
| 126 |
<?php echo esc_html( $short_url ); ?> |
| 127 |
</a> |
| 128 |
<div class="bl-cle__urlactions"> |
| 129 |
<button type="button" class="bl-cle__iconbtn btl-short-url-copy-button" data-clipboard-text="<?php echo esc_attr( $short_url ); ?>" title="<?php esc_attr_e( 'Copy link', 'betterlinks' ); ?>" aria-label="<?php esc_attr_e( 'Copy link', 'betterlinks' ); ?>"> |
| 130 |
<span class="icon"> |
| 131 |
<img width="16" height="16" src="<?php echo esc_url( $copy_icon ); ?>" alt="" /> |
| 132 |
<span class="bl-cle__copied" style="display: none;"> |
| 133 |
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 6 9 17l-5-5" /></svg> |
| 134 |
</span> |
| 135 |
</span> |
| 136 |
</button> |
| 137 |
<a class="bl-cle__iconbtn" href="<?php echo esc_url( $short_url ); ?>" target="_blank" rel="noopener" title="<?php esc_attr_e( 'Open link', 'betterlinks' ); ?>" aria-label="<?php esc_attr_e( 'Open link', 'betterlinks' ); ?>"> |
| 138 |
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5" /></svg> |
| 139 |
</a> |
| 140 |
</div> |
| 141 |
</div> |
| 142 |
|
| 143 |
<?php |
| 144 |
if ( ! empty( $initial_values['pro_enabled'] ) && ! empty( $social_share ) ) { |
| 145 |
?> |
| 146 |
<div class="bl-cle__share"> |
| 147 |
<span class="bl-cle__share-label"><?php esc_html_e( 'Share', 'betterlinks' ); ?></span> |
| 148 |
<div class="bl-cle__share-list"> |
| 149 |
<a class="bl-cle__share-btn" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo esc_attr( $encoded_short_url ); ?>" target="_blank" rel="noopener" title="<?php esc_attr_e( 'Share to Facebook', 'betterlinks' ); ?>"> |
| 150 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" aria-hidden="true"> |
| 151 |
<linearGradient id="awSgIinfw5_FS5MLHI~A9a_yGcWL8copNNQ_gr1" x1="6.228" x2="42.077" y1="4.896" y2="43.432" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#0d61a9"></stop><stop offset="1" stop-color="#16528c"></stop></linearGradient><path fill="url(#awSgIinfw5_FS5MLHI~A9a_yGcWL8copNNQ_gr1)" d="M42,40c0,1.105-0.895,2-2,2H8c-1.105,0-2-0.895-2-2V8c0-1.105,0.895-2,2-2h32 c1.105,0,2,0.895,2,2V40z"></path><path d="M25,38V27h-4v-6h4v-2.138c0-5.042,2.666-7.818,7.505-7.818c1.995,0,3.077,0.14,3.598,0.208 l0.858,0.111L37,12.224L37,17h-3.635C32.237,17,32,18.378,32,19.535V21h4.723l-0.928,6H32v11H25z" opacity=".05"></path><path d="M25.5,37.5v-11h-4v-5h4v-2.638c0-4.788,2.422-7.318,7.005-7.318c1.971,0,3.03,0.138,3.54,0.204 l0.436,0.057l0.02,0.442V16.5h-3.135c-1.623,0-1.865,1.901-1.865,3.035V21.5h4.64l-0.773,5H31.5v11H25.5z" opacity=".07"></path><path fill="#fff" d="M33.365,16H36v-3.754c-0.492-0.064-1.531-0.203-3.495-0.203c-4.101,0-6.505,2.08-6.505,6.819V22h-4v4 h4v11h5V26h3.938l0.618-4H31v-2.465C31,17.661,31.612,16,33.365,16z"></path> |
| 152 |
</svg> |
| 153 |
</a> |
| 154 |
<a class="bl-cle__share-btn" href="https://twitter.com/intent/tweet?url=<?php echo esc_attr( $encoded_short_url ); ?>" target="_blank" rel="noopener" title="<?php esc_attr_e( 'Share to X(Formerly Twitter)', 'betterlinks' ); ?>"> |
| 155 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" aria-hidden="true"> |
| 156 |
<path fill="#212121" fill-rule="evenodd" d="M38,42H10c-2.209,0-4-1.791-4-4V10c0-2.209,1.791-4,4-4h28 c2.209,0,4,1.791,4,4v28C42,40.209,40.209,42,38,42z" clip-rule="evenodd"></path><path fill="#fff" d="M34.257,34h-6.437L13.829,14h6.437L34.257,34z M28.587,32.304h2.563L19.499,15.696h-2.563 L28.587,32.304z"></path><polygon fill="#fff" points="15.866,34 23.069,25.656 22.127,24.407 13.823,34"></polygon><polygon fill="#fff" points="24.45,21.721 25.355,23.01 33.136,14 31.136,14"></polygon> |
| 157 |
</svg> |
| 158 |
</a> |
| 159 |
<a class="bl-cle__share-btn" href="https://www.linkedin.com/sharing/share-offsite/?url=<?php echo esc_attr( $encoded_short_url ); ?>" target="_blank" rel="noopener" title="<?php esc_attr_e( 'Share to Linkedin', 'betterlinks' ); ?>"> |
| 160 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" aria-hidden="true"> |
| 161 |
<path fill="#0288D1" d="M42,37c0,2.762-2.238,5-5,5H11c-2.761,0-5-2.238-5-5V11c0-2.762,2.239-5,5-5h26c2.762,0,5,2.238,5,5V37z"></path><path fill="#FFF" d="M12 19H17V36H12zM14.485 17h-.028C12.965 17 12 15.888 12 14.499 12 13.08 12.995 12 14.514 12c1.521 0 2.458 1.08 2.486 2.499C17 15.887 16.035 17 14.485 17zM36 36h-5v-9.099c0-2.198-1.225-3.698-3.192-3.698-1.501 0-2.313 1.012-2.707 1.99C24.957 25.543 25 26.511 25 27v9h-5V19h5v2.616C25.721 20.5 26.85 19 29.738 19c3.578 0 6.261 2.25 6.261 7.274L36 36 36 36z"></path> |
| 162 |
</svg> |
| 163 |
</a> |
| 164 |
<a class="bl-cle__share-btn" href="https://www.tumblr.com/widgets/share/tool/preview?url=<?php echo esc_attr( $encoded_short_url ); ?>" target="_blank" rel="noopener" title="<?php esc_attr_e( 'Share to Tumblr', 'betterlinks' ); ?>"> |
| 165 |
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" aria-hidden="true"> |
| 166 |
<path d="M48,8H16c-4.418,0-8,3.582-8,8v32c0,4.418,3.582,8,8,8h32c4.418,0,8-3.582,8-8V16C56,11.582,52.418,8,48,8z M41,44 c0,0-2,3-8,3c-5,0-6-4-6-8V29h-4v-4c4,0,6-4,6-8h4v7h7v5h-7v10c0,2,1,3,3.315,3C39,42,41,40,41,40V44z"></path> |
| 167 |
</svg> |
| 168 |
</a> |
| 169 |
<a class="bl-cle__share-btn" href="https://t.me/share/url?url=<?php echo esc_attr( $encoded_short_url ); ?>&text=<?php echo esc_attr( $link_title ); ?>" target="_blank" rel="noopener" title="<?php esc_attr_e( 'Share to Telegram', 'betterlinks' ); ?>"> |
| 170 |
<img src="<?php echo esc_url( $telegram ); ?>" alt="<?php esc_attr_e( 'Share to Telegram', 'betterlinks' ); ?>" /> |
| 171 |
</a> |
| 172 |
</div> |
| 173 |
</div> |
| 174 |
<?php |
| 175 |
} |
| 176 |
?> |
| 177 |
|
| 178 |
<section class="bl-cle__card"> |
| 179 |
<dl class="bl-cle__meta"> |
| 180 |
<dt><?php esc_html_e( 'Title', 'betterlinks' ); ?></dt> |
| 181 |
<dd class="bl-cle__meta-title" title="<?php echo esc_attr( $link_title ); ?>"><?php echo esc_html( $link_title ); ?></dd> |
| 182 |
<dt><?php esc_html_e( 'Main URL', 'betterlinks' ); ?></dt> |
| 183 |
<dd> |
| 184 |
<a class="bl-cle__meta-url" href="<?php echo esc_url( $target_url ); ?>" target="_blank" rel="noopener" title="<?php echo esc_attr( $target_url ); ?>"><?php echo esc_html( $target_url ); ?></a> |
| 185 |
</dd> |
| 186 |
</dl> |
| 187 |
</section> |
| 188 |
|
| 189 |
<section class="bl-cle__card"> |
| 190 |
<h2 class="bl-cle__card-title"><?php esc_html_e( 'Link Options', 'betterlinks' ); ?></h2> |
| 191 |
<ul class="bl-cle__options"> |
| 192 |
<?php foreach ( $link_options as $option ) { ?> |
| 193 |
<li class="bl-cle__option"> |
| 194 |
<span class="bl-cle__option-label"><?php echo esc_html( $option['label'] ); ?></span> |
| 195 |
<?php if ( 'checked' === $option['state'] ) { ?> |
| 196 |
<span class="bl-cle__pill bl-cle__pill--on"><?php esc_html_e( 'Active', 'betterlinks' ); ?></span> |
| 197 |
<?php } else { ?> |
| 198 |
<span class="bl-cle__pill bl-cle__pill--off"><?php esc_html_e( 'Disabled', 'betterlinks' ); ?></span> |
| 199 |
<?php } ?> |
| 200 |
</li> |
| 201 |
<?php } ?> |
| 202 |
<li class="bl-cle__option"> |
| 203 |
<span class="bl-cle__option-label"><?php esc_html_e( 'Redirect Type', 'betterlinks' ); ?></span> |
| 204 |
<span class="bl-cle__pill bl-cle__pill--info"><?php echo esc_html( isset( $redirect_types[ $redirect_type ] ) ? $redirect_types[ $redirect_type ] : $redirect_type ); ?></span> |
| 205 |
</li> |
| 206 |
<?php if ( ! empty( $category ) ) { ?> |
| 207 |
<li class="bl-cle__option"> |
| 208 |
<span class="bl-cle__option-label"><?php esc_html_e( 'Category', 'betterlinks' ); ?></span> |
| 209 |
<span class="bl-cle__pill bl-cle__pill--info"><?php echo esc_html( $category ); ?></span> |
| 210 |
</li> |
| 211 |
<?php } ?> |
| 212 |
</ul> |
| 213 |
</section> |
| 214 |
|
| 215 |
<div class="bl-cle__actions"> |
| 216 |
<a class="bl-cle__back" href="#" onclick="history.back(); return false;" title="<?php esc_attr_e( 'Go Back', 'betterlinks' ); ?>"> |
| 217 |
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M19 12H5M11 18l-6-6 6-6" /></svg> |
| 218 |
<?php esc_html_e( 'Go Back', 'betterlinks' ); ?> |
| 219 |
</a> |
| 220 |
<?php if ( ! empty( $link_date ) ) { ?> |
| 221 |
<span class="bl-cle__date"><?php esc_html_e( 'Created at', 'betterlinks' ); ?> <?php echo esc_html( $link_date ); ?></span> |
| 222 |
<?php } ?> |
| 223 |
</div> |
| 224 |
</main> |
| 225 |
|
| 226 |
<?php if ( ! empty( $powered_by ) ) { ?> |
| 227 |
<footer class="bl-cle__credit"> |
| 228 |
<span> |
| 229 |
<?php esc_html_e( 'Powered By', 'betterlinks' ); ?> |
| 230 |
<img src="<?php echo esc_url( $betterlinks_logo ); ?>" alt="BetterLinks" title="BetterLinks" /> |
| 231 |
</span> |
| 232 |
</footer> |
| 233 |
<?php } ?> |
| 234 |
</div> |
| 235 |
|
| 236 |
<?php wp_print_scripts( 'betterlinks-cle' ); ?> |
| 237 |
</body> |
| 238 |
</html> |
| 239 |
|