| 1 |
<?php |
| 2 |
/** |
| 3 |
* Helpers |
| 4 |
* |
| 5 |
* @package CTC |
| 6 |
* @since 5.0.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace CTC; |
| 10 |
|
| 11 |
use Elementor\Controls_Manager; |
| 12 |
use Elementor\Group_Control_Background; |
| 13 |
use Elementor\Group_Control_Typography; |
| 14 |
use Elementor\Group_Control_Border; |
| 15 |
use Elementor\Group_Control_Box_Shadow; |
| 16 |
|
| 17 |
/** |
| 18 |
* Helpers |
| 19 |
* |
| 20 |
* @since 5.0.0 |
| 21 |
*/ |
| 22 |
class Helpers { |
| 23 |
public static function get_svg_link_icon() { |
| 24 |
return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"> |
| 25 |
<path fill="#B6BEC6" d="M8.818 8.818l.128-.121a3 3 0 014.115.12l1.06 1.061-1.414 1.415-1.06-1.061-.088-.078a1 1 0 00-1.327.078l-4.95 4.95-.077.087a1 1 0 00.078 1.327l2.12 2.121.088.078a1 1 0 001.327-.078l2.122-2.121 1.414 1.414-2.122 2.121-.128.121a3 3 0 01-4.114-.12L3.868 18.01l-.12-.128a3 3 0 01.12-4.115l4.95-4.95zm4.95-4.95l.128-.121a3 3 0 014.114.12l2.122 2.122.12.128a3 3 0 01-.12 4.115l-4.95 4.95-.128.12a3 3 0 01-4.114-.12L9.879 14.12l1.414-1.414 1.06 1.06.088.078a1 1 0 001.327-.078l4.95-4.95.077-.087a1 1 0 00-.077-1.327l-2.122-2.12-.087-.079a1 1 0 00-1.327.078l-2.121 2.121-1.414-1.414 2.12-2.121z"> |
| 26 |
</path> |
| 27 |
</svg>'; |
| 28 |
} |
| 29 |
|
| 30 |
public static function get_svg_pinterest_icon() { |
| 31 |
return '<svg class="gUZ GjR U9O kVc" height="24" width="24" viewBox="0 0 24 24" aria-label="Pinterest" role="img"><path fill="#e60023" d="M0 12c0 5.123 3.211 9.497 7.73 11.218-.11-.937-.227-2.482.025-3.566.217-.932 1.401-5.938 1.401-5.938s-.357-.715-.357-1.774c0-1.66.962-2.9 2.161-2.9 1.02 0 1.512.765 1.512 1.682 0 1.025-.653 2.557-.99 3.978-.281 1.189.597 2.159 1.769 2.159 2.123 0 3.756-2.239 3.756-5.471 0-2.861-2.056-4.86-4.991-4.86-3.398 0-5.393 2.549-5.393 5.184 0 1.027.395 2.127.889 2.726a.36.36 0 0 1 .083.343c-.091.378-.293 1.189-.332 1.355-.053.218-.173.265-.4.159-1.492-.694-2.424-2.875-2.424-4.627 0-3.769 2.737-7.229 7.892-7.229 4.144 0 7.365 2.953 7.365 6.899 0 4.117-2.595 7.431-6.199 7.431-1.211 0-2.348-.63-2.738-1.373 0 0-.599 2.282-.744 2.84-.282 1.084-1.064 2.456-1.549 3.235C9.584 23.815 10.77 24 12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12"></path></svg>'; |
| 32 |
} |
| 33 |
|
| 34 |
public static function get_svg_linkedin_icon() { |
| 35 |
return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"> |
| 36 |
<path fill="#3277D4" fill-rule="evenodd" d="M21 5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2V5zm-2.5 8.2v5.3h-2.79v-4.93a1.4 1.4 0 00-1.4-1.4c-.77 0-1.39.63-1.39 1.4v4.93h-2.79v-8.37h2.79v1.11c.48-.78 1.47-1.3 2.32-1.3 1.8 0 3.26 1.46 3.26 3.26zM6.88 8.56a1.686 1.686 0 000-3.37 1.69 1.69 0 00-1.69 1.69c0 .93.76 1.68 1.69 1.68zm1.39 1.57v8.37H5.5v-8.37h2.77z" clip-rule="evenodd"></path> |
| 37 |
</svg>'; |
| 38 |
} |
| 39 |
|
| 40 |
public static function get_svg_twitter_icon() { |
| 41 |
return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"> |
| 42 |
<path fill="#4BA8F5" d="M22.92 6c-.77.35-1.6.58-2.46.69.88-.53 1.56-1.37 1.88-2.38-.83.5-1.75.85-2.72 1.05C18.83 4.5 17.72 4 16.46 4c-2.35 0-4.27 1.92-4.27 4.29 0 .34.04.67.11.98-3.56-.18-6.73-1.89-8.84-4.48-.37.63-.58 1.37-.58 2.15 0 1.49.75 2.81 1.91 3.56-.71 0-1.37-.2-1.95-.5v.03c0 2.08 1.48 3.82 3.44 4.21a4.22 4.22 0 01-1.93.07 4.28 4.28 0 004 2.98 8.521 8.521 0 01-5.33 1.84c-.34 0-.68-.02-1.02-.06C3.9 20.29 6.16 21 8.58 21c7.88 0 12.21-6.54 12.21-12.21 0-.19 0-.37-.01-.56.84-.6 1.56-1.36 2.14-2.23z"> |
| 43 |
</path> |
| 44 |
</svg>'; |
| 45 |
} |
| 46 |
|
| 47 |
public static function get_svg_whatsapp_icon() { |
| 48 |
return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 240 241.19" class="whatsapp"><path class="cls-1" fill="#25d366" d="M205,35.05A118.61,118.61,0,0,0,120.46,0C54.6,0,1,53.61,1,119.51a119.5,119.5,0,0,0,16,59.74L0,241.19l63.36-16.63a119.43,119.43,0,0,0,57.08,14.57h0A119.54,119.54,0,0,0,205,35.07v0ZM120.5,219A99.18,99.18,0,0,1,69.91,205.1l-3.64-2.17-37.6,9.85,10-36.65-2.35-3.76A99.37,99.37,0,0,1,190.79,49.27,99.43,99.43,0,0,1,120.49,219ZM175,144.54c-3-1.51-17.67-8.71-20.39-9.71s-4.72-1.51-6.75,1.51-7.72,9.71-9.46,11.72-3.49,2.27-6.45.76-12.63-4.66-24-14.84A91.1,91.1,0,0,1,91.25,113.3c-1.75-3-.19-4.61,1.33-6.07s3-3.48,4.47-5.23a19.65,19.65,0,0,0,3-5,5.51,5.51,0,0,0-.24-5.23C99,90.27,93,75.57,90.6,69.58s-4.89-5-6.73-5.14-3.73-.09-5.7-.09a11,11,0,0,0-8,3.73C67.48,71.05,59.75,78.3,59.75,93s10.69,28.88,12.19,30.9S93,156.07,123,169c7.12,3.06,12.68,4.9,17,6.32a41.18,41.18,0,0,0,18.8,1.17c5.74-.84,17.66-7.21,20.17-14.18s2.5-13,1.75-14.19-2.69-2.06-5.7-3.59l0,0Z"></path></svg>'; |
| 49 |
} |
| 50 |
|
| 51 |
public static function get_svg_facebook_icon() { |
| 52 |
return '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24"> |
| 53 |
<path fill="#425993" fill-rule="evenodd" d="M19 3H5a2 2 0 00-2 2v14a2 2 0 002 2h7v-7h-2v-3h2V8.5A3.5 3.5 0 0115.5 5H18v3h-2a1 1 0 00-1 1v2h3v3h-3v7h4a2 2 0 002-2V5a2 2 0 00-2-2z" clip-rule="evenodd"></path> |
| 54 |
</svg>'; |
| 55 |
} |
| 56 |
|
| 57 |
public static function get_svg_copy_icon() { |
| 58 |
return '<svg aria-hidden="true" focusable="false" role="img" class="copy-icon" viewBox="0 0 16 16" width="16" height="16" fill="currentColor"><path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path></svg>'; |
| 59 |
} |
| 60 |
|
| 61 |
public static function get_svg_checked_icon() { |
| 62 |
return '<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="check-icon" fill="currentColor"><path d="M13.78 4.22a.75.75 0 0 1 0 1.06l-7.25 7.25a.75.75 0 0 1-1.06 0L2.22 9.28a.751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018L6 10.94l6.72-6.72a.75.75 0 0 1 1.06 0Z"></path></svg>'; |
| 63 |
} |
| 64 |
|
| 65 |
public static function get_copy_button( $args = [] ) { |
| 66 |
$show_icon = isset( $args['show_icon'] ) ? $args['show_icon'] : 'yes'; |
| 67 |
$with_icon = 'yes' === $show_icon ? 'with-icon' : 'without-icon'; |
| 68 |
$as_raw = isset( $args['as_raw'] ) ? 'yes' : ''; |
| 69 |
$button_text = isset( $args['button_text'] ) |
| 70 |
? $args['button_text'] |
| 71 |
: ( isset( $args['copy_button_text'] ) ? $args['copy_button_text'] : esc_html__( 'Copy to Clipboard', 'ctc' ) ); |
| 72 |
$button_class = isset( $args['button_class'] ) ? $args['button_class'] : ''; |
| 73 |
$button_text_copied = isset( $args['button_text_copied'] ) |
| 74 |
? $args['button_text_copied'] |
| 75 |
: ( isset( $args['copy_button_text_copied'] ) ? $args['copy_button_text_copied'] : esc_html__( 'Copied!', 'ctc' ) ); |
| 76 |
$icon_direction = isset( $args['icon_direction'] ) ? $args['icon_direction'] : 'before'; |
| 77 |
|
| 78 |
ob_start(); |
| 79 |
?> |
| 80 |
<button class="ctc-block-copy ctc-<?php echo esc_attr( $with_icon ); ?>" copy-as-raw='<?php echo esc_html( $as_raw ); ?>' data-copied="<?php echo esc_html( $button_text_copied ); ?>"> |
| 81 |
<?php |
| 82 |
if ( 'before' === $icon_direction && 'yes' === $show_icon ) { |
| 83 |
echo self::get_svg_copy_icon(); |
| 84 |
echo self::get_svg_checked_icon(); |
| 85 |
} |
| 86 |
echo '<span class="ctc-button-text">' . esc_html( $button_text ) . '</span>'; |
| 87 |
if ( 'after' === $icon_direction && 'yes' === $show_icon ) { |
| 88 |
echo self::get_svg_copy_icon(); |
| 89 |
echo self::get_svg_checked_icon(); |
| 90 |
} |
| 91 |
?> |
| 92 |
</button> |
| 93 |
<?php |
| 94 |
return ob_get_clean(); |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Is shortcode used |
| 99 |
* |
| 100 |
* @param string $shortcode |
| 101 |
* @since 5.0.0 |
| 102 |
*/ |
| 103 |
public static function is_shortcode_used( $shortcode = '' ) { |
| 104 |
global $post; |
| 105 |
if ( ! $post ) { |
| 106 |
return false; |
| 107 |
} |
| 108 |
|
| 109 |
$found = false; |
| 110 |
if ( strpos( $post->post_content, '[' . $shortcode ) !== false ) { |
| 111 |
$found = true; |
| 112 |
} |
| 113 |
|
| 114 |
return $found; |
| 115 |
} |
| 116 |
|
| 117 |
/** |
| 118 |
* Get categories |
| 119 |
* |
| 120 |
* @since 5.0.0 |
| 121 |
*/ |
| 122 |
public static function get_categories() { |
| 123 |
return [ 'ctc', 'basic' ]; |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* Get common keywords |
| 128 |
* |
| 129 |
* @param array $keywords New keywords. |
| 130 |
* @since 5.0.0 |
| 131 |
*/ |
| 132 |
public static function get_keywords( $keywords = [] ) { |
| 133 |
$default = [ 'copy', 'paste', 'clipboard', 'copy clipboard', 'copy to clipboard', 'copy anything to clipboard' ]; |
| 134 |
|
| 135 |
return array_merge( $default, $keywords ); |
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* Register "Copy Content" Section |
| 140 |
* |
| 141 |
* @param object $self |
| 142 |
*/ |
| 143 |
public static function register_copy_content_section( $self, $args = [] ) { |
| 144 |
$self->start_controls_section( |
| 145 |
'copy_content_section', |
| 146 |
[ |
| 147 |
'label' => esc_html__( 'Content to Copy', 'ctc' ), |
| 148 |
] |
| 149 |
); |
| 150 |
|
| 151 |
if ( isset( $args['before_controls'] ) ) { |
| 152 |
foreach ( $args['before_controls'] as $control_id => $options ) { |
| 153 |
$self->add_control( $control_id, $options ); |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
$self->add_control( |
| 158 |
'have_selector', |
| 159 |
[ |
| 160 |
'label' => esc_html__( 'Have Selector?', 'ctc' ), |
| 161 |
'type' => Controls_Manager::SWITCHER, |
| 162 |
'label_on' => esc_html__( 'Yes', 'ctc' ), |
| 163 |
'label_off' => esc_html__( 'No', 'ctc' ), |
| 164 |
'return_value' => 'yes', |
| 165 |
'default' => 'no', |
| 166 |
] |
| 167 |
); |
| 168 |
|
| 169 |
$self->add_control( |
| 170 |
'selector', |
| 171 |
[ |
| 172 |
'label' => esc_html__( 'Selector', 'ctc' ), |
| 173 |
'type' => Controls_Manager::TEXT, |
| 174 |
'default' => '', |
| 175 |
'condition' => [ |
| 176 |
'have_selector' => 'yes', |
| 177 |
], |
| 178 |
] |
| 179 |
); |
| 180 |
|
| 181 |
$self->add_control( |
| 182 |
'copy_content', |
| 183 |
[ |
| 184 |
'label' => isset( $args['label'] ) ? $args['label'] : esc_html__( 'Enter Text that Copy to Clipboard', 'ctc' ), |
| 185 |
'type' => Controls_Manager::TEXTAREA, |
| 186 |
'default' => isset( $args['default'] ) ? $args['default'] : '', |
| 187 |
'rows' => 10, |
| 188 |
'condition' => [ |
| 189 |
'have_selector' => [ 'no', '' ], |
| 190 |
], |
| 191 |
] |
| 192 |
); |
| 193 |
|
| 194 |
if ( isset( $args['after_controls'] ) ) { |
| 195 |
foreach ( $args['after_controls'] as $control_id => $options ) { |
| 196 |
$self->add_control( $control_id, $options ); |
| 197 |
} |
| 198 |
} |
| 199 |
|
| 200 |
$self->end_controls_section(); |
| 201 |
} |
| 202 |
|
| 203 |
/** |
| 204 |
* Register "Copy Button" Section |
| 205 |
* |
| 206 |
* @param array $args |
| 207 |
* @param object $self |
| 208 |
*/ |
| 209 |
public static function register_copy_button_section( $self, $args = [] ) { |
| 210 |
$default = [ |
| 211 |
'button_text' => isset( $args['button_text'] ) ? $args['button_text'] : esc_html__( 'Copy to Clipboard', 'ctc' ), |
| 212 |
'button_text_copied' => isset( $args['button_text_copied'] ) ? $args['button_text_copied'] : esc_html__( 'Copied!', 'ctc' ), |
| 213 |
'show_icon' => 'yes', |
| 214 |
'icon_direction' => 'before', |
| 215 |
]; |
| 216 |
|
| 217 |
$self->start_controls_section( |
| 218 |
'copy_button_section', |
| 219 |
[ |
| 220 |
'label' => esc_html__( 'Copy Button', 'ctc' ), |
| 221 |
] |
| 222 |
); |
| 223 |
|
| 224 |
$self->add_control( |
| 225 |
'copy_button_text', |
| 226 |
[ |
| 227 |
'label' => esc_html__( 'Button Text', 'ctc' ), |
| 228 |
'type' => Controls_Manager::TEXT, |
| 229 |
'default' => $default['button_text'], |
| 230 |
] |
| 231 |
); |
| 232 |
|
| 233 |
$self->add_control( |
| 234 |
'copy_button_text_copied', |
| 235 |
[ |
| 236 |
'label' => esc_html__( 'After Copy Text', 'ctc' ), |
| 237 |
'type' => Controls_Manager::TEXT, |
| 238 |
'default' => $default['button_text_copied'], |
| 239 |
] |
| 240 |
); |
| 241 |
|
| 242 |
// Alignment. |
| 243 |
$self->add_responsive_control( |
| 244 |
'copy_button_align', |
| 245 |
[ |
| 246 |
'label' => esc_html__( 'Alignment', 'ctc' ), |
| 247 |
'type' => Controls_Manager::CHOOSE, |
| 248 |
'options' => [ |
| 249 |
'left' => [ |
| 250 |
'title' => esc_html__( 'Left', 'ctc' ), |
| 251 |
'icon' => 'eicon-text-align-left', |
| 252 |
], |
| 253 |
'center' => [ |
| 254 |
'title' => esc_html__( 'Center', 'ctc' ), |
| 255 |
'icon' => 'eicon-text-align-center', |
| 256 |
], |
| 257 |
'right' => [ |
| 258 |
'title' => esc_html__( 'Right', 'ctc' ), |
| 259 |
'icon' => 'eicon-text-align-right', |
| 260 |
], |
| 261 |
], |
| 262 |
'selectors' => [ |
| 263 |
'{{WRAPPER}} .ctc-block-actions' => 'text-align: {{VALUE}};', |
| 264 |
], |
| 265 |
] |
| 266 |
); |
| 267 |
|
| 268 |
// Show Icon. |
| 269 |
$self->add_control( |
| 270 |
'copy_show_icon', |
| 271 |
[ |
| 272 |
'label' => esc_html__( 'Show Icon', 'ctc' ), |
| 273 |
'type' => Controls_Manager::SWITCHER, |
| 274 |
'label_on' => esc_html__( 'Show', 'ctc' ), |
| 275 |
'label_off' => esc_html__( 'Hide', 'ctc' ), |
| 276 |
'return_value' => 'yes', |
| 277 |
'default' => 'yes', |
| 278 |
] |
| 279 |
); |
| 280 |
|
| 281 |
$self->add_control( |
| 282 |
'copy_icon_direction', |
| 283 |
[ |
| 284 |
'label' => esc_html__( 'Icon Direction', 'ctc' ), |
| 285 |
'type' => Controls_Manager::SELECT, |
| 286 |
'default' => 'before', |
| 287 |
'options' => [ |
| 288 |
'before' => esc_html__( 'Before', 'ctc' ), |
| 289 |
'after' => esc_html__( 'After', 'ctc' ), |
| 290 |
], |
| 291 |
'condition' => [ |
| 292 |
'copy_show_icon' => 'yes', |
| 293 |
], |
| 294 |
] |
| 295 |
); |
| 296 |
|
| 297 |
$self->add_responsive_control( |
| 298 |
'copy_icon_text_gap', |
| 299 |
[ |
| 300 |
'label' => esc_html__( 'Icon and Text Gap', 'ctc' ), |
| 301 |
'type' => Controls_Manager::SLIDER, |
| 302 |
'size_units' => [ 'px', 'em' ], |
| 303 |
'range' => [ |
| 304 |
'px' => [ |
| 305 |
'min' => 0, |
| 306 |
'max' => 100, |
| 307 |
], |
| 308 |
'em' => [ |
| 309 |
'min' => 0, |
| 310 |
'max' => 10, |
| 311 |
], |
| 312 |
], |
| 313 |
'selectors' => [ |
| 314 |
'{{WRAPPER}} .ctc-with-icon' => 'gap: {{SIZE}}{{UNIT}};', |
| 315 |
], |
| 316 |
'condition' => [ |
| 317 |
'copy_show_icon' => 'yes', |
| 318 |
], |
| 319 |
] |
| 320 |
); |
| 321 |
|
| 322 |
$self->end_controls_section(); |
| 323 |
} |
| 324 |
|
| 325 |
/** |
| 326 |
* Register "Copy Button Style" Section |
| 327 |
* |
| 328 |
* @param object $self |
| 329 |
*/ |
| 330 |
public static function register_copy_button_style_section( $self ) { |
| 331 |
self::register_style_section( |
| 332 |
$self, |
| 333 |
'Copy Button', |
| 334 |
'.ctc-block-copy', |
| 335 |
[ |
| 336 |
'text_align' => false, |
| 337 |
'normal_text_color' => [ |
| 338 |
'selectors' => [ |
| 339 |
'{{WRAPPER}} .ctc-block-copy' => 'color: {{VALUE}};', |
| 340 |
'{{WRAPPER}} .ctc-block-copy svg' => 'fill: {{VALUE}};', |
| 341 |
], |
| 342 |
], |
| 343 |
'hover_text_color' => [ |
| 344 |
'selectors' => [ |
| 345 |
'{{WRAPPER}} .ctc-block-copy:hover' => 'color: {{VALUE}};', |
| 346 |
'{{WRAPPER}} .ctc-block-copy:hover svg' => 'fill: {{VALUE}};', |
| 347 |
], |
| 348 |
], |
| 349 |
] |
| 350 |
); |
| 351 |
} |
| 352 |
|
| 353 |
/** |
| 354 |
* Render "Copy Button" |
| 355 |
* |
| 356 |
* @param object $self |
| 357 |
*/ |
| 358 |
public static function render_copy_button( $self ) { |
| 359 |
$button_text = $self->get_settings_for_display( 'copy_button_text' ); |
| 360 |
$button_text_copied = $self->get_settings_for_display( 'copy_button_text_copied' ); |
| 361 |
$show_icon = $self->get_settings_for_display( 'copy_show_icon' ); |
| 362 |
$icon_direction = $self->get_settings_for_display( 'copy_icon_direction' ); |
| 363 |
|
| 364 |
echo self::get_copy_button( |
| 365 |
[ |
| 366 |
'as_raw' => 'yes', |
| 367 |
'button_text' => $button_text, |
| 368 |
'button_text_copied' => $button_text_copied, |
| 369 |
'icon_direction' => $icon_direction, |
| 370 |
'show_icon' => $show_icon, |
| 371 |
] |
| 372 |
); |
| 373 |
} |
| 374 |
|
| 375 |
/** |
| 376 |
* Render "Copy Content" |
| 377 |
* |
| 378 |
* @param object $self |
| 379 |
* @param array $args |
| 380 |
*/ |
| 381 |
public static function render_copy_content( $self, $args = [] ) { |
| 382 |
$selection_target = ''; |
| 383 |
$content = isset( $args['content'] ) ? $args['content'] : $self->get_settings_for_display( 'copy_content' ); |
| 384 |
$have_selector = $self->get_settings_for_display( 'have_selector' ); |
| 385 |
if ( 'yes' === $have_selector ) { |
| 386 |
$selection_target = $self->get_settings_for_display( 'selector' ); |
| 387 |
} |
| 388 |
?> |
| 389 |
<textarea selection-target="<?php echo esc_attr( $selection_target ); ?>" class="ctc-copy-content" style="display: none;"><?php echo wp_kses_post( apply_shortcodes( $content ) ); ?></textarea> |
| 390 |
<?php |
| 391 |
} |
| 392 |
|
| 393 |
/** |
| 394 |
* Register "Get Pro" Section |
| 395 |
* |
| 396 |
* @param object $self |
| 397 |
* @param array $args |
| 398 |
*/ |
| 399 |
public static function register_pro_section( $self, $label ) { |
| 400 |
$id = str_replace( ' ', '-', $label ); |
| 401 |
$id = strtolower( $id ); |
| 402 |
|
| 403 |
$self->start_controls_section( |
| 404 |
$id . '_box', |
| 405 |
[ |
| 406 |
'label' => $label . ' (Pro)', |
| 407 |
'tab' => Controls_Manager::TAB_STYLE, |
| 408 |
] |
| 409 |
); |
| 410 |
|
| 411 |
// Buy pro. |
| 412 |
$self->add_control( |
| 413 |
$id . '_box_content', |
| 414 |
[ |
| 415 |
'type' => Controls_Manager::RAW_HTML, |
| 416 |
'raw' => '<div style="text-align: center;"><h2 style="font-weight: 600;margin: 0 0 10px 0;font-size: 14px;">Unlock Premium Features!</h2><p style="margin: 0 0 10px 0;">Upgrade to Clipboard Pro for enhanced functionality and exclusive benefits.</p><p style="margin: 0 0 10px 0;">Ready to level up your experience?</p><a href="https://clipboard.agency/#pricing" class="button button-primary" target="_blank">See Pricing Plans</a></div>', |
| 417 |
] |
| 418 |
); |
| 419 |
|
| 420 |
$self->end_controls_section(); |
| 421 |
} |
| 422 |
|
| 423 |
/** |
| 424 |
* Register "Get Pro" Sections |
| 425 |
* |
| 426 |
* @param object $self |
| 427 |
* @param array $labels |
| 428 |
*/ |
| 429 |
public static function register_pro_sections( $self, $labels = [] ) { |
| 430 |
foreach ( $labels as $label ) { |
| 431 |
self::register_pro_section( $self, $label ); |
| 432 |
} |
| 433 |
} |
| 434 |
|
| 435 |
/** |
| 436 |
* Register normal and hover styles. |
| 437 |
* |
| 438 |
* @param object $self |
| 439 |
* @param string $label |
| 440 |
* @param array $args |
| 441 |
*/ |
| 442 |
public static function register_style_section( $self, $label = '', $selector = '', $args = [] ) { |
| 443 |
$id = 'reusable-' . sanitize_title_with_dashes( $label ); |
| 444 |
|
| 445 |
$size = isset( $args['size'] ) ? $args['size'] : false; |
| 446 |
$text_decoration = isset( $args['text_decoration'] ) ? $args['text_decoration'] : false; |
| 447 |
$margin = isset( $args['margin'] ) ? $args['margin'] : true; |
| 448 |
$padding = isset( $args['padding'] ) ? $args['padding'] : true; |
| 449 |
$border = isset( $args['border'] ) ? $args['border'] : false; // Disabled. |
| 450 |
$border_radius = isset( $args['border_radius'] ) ? $args['border_radius'] : true; |
| 451 |
$background = isset( $args['background'] ) ? $args['background'] : false; // Disabled. |
| 452 |
$text_color = isset( $args['text_color'] ) ? $args['text_color'] : false; // Disabled. |
| 453 |
$typography = isset( $args['typography'] ) ? $args['typography'] : true; |
| 454 |
$text_align = isset( $args['text_align'] ) ? $args['text_align'] : true; |
| 455 |
$box_shadow = isset( $args['box_shadow'] ) ? $args['box_shadow'] : false; // Disabled. |
| 456 |
$tabs = isset( $args['tabs'] ) ? $args['tabs'] : true; |
| 457 |
$normal_background = isset( $args['normal_background'] ) ? $args['normal_background'] : true; |
| 458 |
$normal_text_color = isset( $args['normal_text_color'] ) ? $args['normal_text_color'] : true; |
| 459 |
$normal_typography = isset( $args['normal_typography'] ) ? $args['normal_typography'] : false; // Disabled. |
| 460 |
$normal_border = isset( $args['normal_border'] ) ? $args['normal_border'] : true; |
| 461 |
$normal_box_shadow = isset( $args['normal_box_shadow'] ) ? $args['normal_box_shadow'] : true; |
| 462 |
|
| 463 |
// Section. |
| 464 |
$self->start_controls_section( |
| 465 |
$id . '_style_section', |
| 466 |
[ |
| 467 |
'label' => $label, |
| 468 |
'tab' => Controls_Manager::TAB_STYLE, |
| 469 |
] |
| 470 |
); |
| 471 |
|
| 472 |
if ( $margin ) : |
| 473 |
$self->add_responsive_control( |
| 474 |
$id . '_margin', |
| 475 |
[ |
| 476 |
'label' => esc_html__( 'Margin', 'ctc' ), |
| 477 |
'type' => Controls_Manager::DIMENSIONS, |
| 478 |
'size_units' => [ 'px', 'em', '%' ], |
| 479 |
'selectors' => [ |
| 480 |
'{{WRAPPER}} ' . $selector => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 481 |
], |
| 482 |
] |
| 483 |
); |
| 484 |
endif; |
| 485 |
|
| 486 |
if ( $padding ) : |
| 487 |
$self->add_responsive_control( |
| 488 |
$id . '_padding', |
| 489 |
[ |
| 490 |
'label' => esc_html__( 'Padding', 'ctc' ), |
| 491 |
'type' => Controls_Manager::DIMENSIONS, |
| 492 |
'size_units' => [ 'px', 'em', '%' ], |
| 493 |
'selectors' => [ |
| 494 |
'{{WRAPPER}} ' . $selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 495 |
], |
| 496 |
] |
| 497 |
); |
| 498 |
endif; |
| 499 |
|
| 500 |
if ( $border ) : |
| 501 |
$border_selector = '{{WRAPPER}} ' . $selector; |
| 502 |
if ( isset( $args['border'] ) && is_array( $args['border'] ) ) { |
| 503 |
if ( isset( $args['border']['selector'] ) ) { |
| 504 |
$border_selector = $args['border']['selector']; |
| 505 |
} |
| 506 |
} |
| 507 |
$self->add_group_control( |
| 508 |
Group_Control_Border::get_type(), |
| 509 |
[ |
| 510 |
'name' => $id . '_border', |
| 511 |
'selector' => $border_selector, |
| 512 |
] |
| 513 |
); |
| 514 |
endif; |
| 515 |
|
| 516 |
if ( $border_radius ) : |
| 517 |
$self->add_responsive_control( |
| 518 |
$id . '_border_radius', |
| 519 |
[ |
| 520 |
'label' => esc_html__( 'Border Radius', 'ctc' ), |
| 521 |
'type' => Controls_Manager::DIMENSIONS, |
| 522 |
'size_units' => [ 'px', '%' ], |
| 523 |
'selectors' => [ |
| 524 |
'{{WRAPPER}} ' . $selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 525 |
], |
| 526 |
] |
| 527 |
); |
| 528 |
endif; |
| 529 |
|
| 530 |
if ( $background ) : |
| 531 |
$self->add_group_control( |
| 532 |
Group_Control_Background::get_type(), |
| 533 |
[ |
| 534 |
'name' => $id . '_background', |
| 535 |
'types' => [ 'classic', 'gradient', 'image', 'video' ], |
| 536 |
'selector' => '{{WRAPPER}} ' . $selector, |
| 537 |
] |
| 538 |
); |
| 539 |
endif; |
| 540 |
|
| 541 |
if ( $text_color ) : |
| 542 |
$self->add_control( |
| 543 |
$id . '_text_color', |
| 544 |
[ |
| 545 |
'label' => esc_html__( 'Text Color', 'ctc' ), |
| 546 |
'type' => Controls_Manager::COLOR, |
| 547 |
'selectors' => [ |
| 548 |
'{{WRAPPER}} ' . $selector => 'color: {{VALUE}};', |
| 549 |
], |
| 550 |
] |
| 551 |
); |
| 552 |
endif; |
| 553 |
|
| 554 |
if ( $typography ) : |
| 555 |
$self->add_group_control( |
| 556 |
Group_Control_Typography::get_type(), |
| 557 |
[ |
| 558 |
'name' => $id . '_typography', |
| 559 |
'selector' => '{{WRAPPER}} ' . $selector, |
| 560 |
] |
| 561 |
); |
| 562 |
endif; |
| 563 |
|
| 564 |
if ( $size ) : |
| 565 |
$size_label = esc_html__( 'Width', 'ctc' ); |
| 566 |
$size_selectors = [ |
| 567 |
'{{WRAPPER}} ' . $selector => 'width: {{SIZE}}{{UNIT}};', |
| 568 |
]; |
| 569 |
if ( isset( $args['size'] ) && is_array( $args['size'] ) ) { |
| 570 |
if ( isset( $args['size']['selectors'] ) ) { |
| 571 |
$size_selectors = $args['size']['selectors']; |
| 572 |
} |
| 573 |
if ( isset( $args['size']['label'] ) ) { |
| 574 |
$size_label = $args['size']['label']; |
| 575 |
} |
| 576 |
} |
| 577 |
|
| 578 |
$self->add_responsive_control( |
| 579 |
$id . '_size', |
| 580 |
[ |
| 581 |
'label' => $size_label, |
| 582 |
'type' => Controls_Manager::SLIDER, |
| 583 |
'size_units' => [ 'px', 'em', '%' ], |
| 584 |
'selectors' => $size_selectors, |
| 585 |
] |
| 586 |
); |
| 587 |
endif; |
| 588 |
|
| 589 |
if ( $text_decoration ) : |
| 590 |
$text_decoration_selectors = [ |
| 591 |
'{{WRAPPER}} ' . $selector => 'text-decoration: {{VALUE}};', |
| 592 |
]; |
| 593 |
if ( isset( $args['text_decoration'] ) && is_array( $args['text_decoration'] ) ) { |
| 594 |
if ( isset( $args['text_decoration']['selectors'] ) ) { |
| 595 |
$text_decoration_selectors = $args['text_decoration']['selectors']; |
| 596 |
} |
| 597 |
} |
| 598 |
|
| 599 |
$self->add_control( |
| 600 |
$id . '_text_decoration', |
| 601 |
[ |
| 602 |
'label' => esc_html__( 'Text Decoration', 'ctc' ), |
| 603 |
'type' => Controls_Manager::SELECT, |
| 604 |
'options' => [ |
| 605 |
'none' => esc_html__( 'None', 'ctc' ), |
| 606 |
'underline' => esc_html__( 'Underline', 'ctc' ), |
| 607 |
'overline' => esc_html__( 'Overline', 'ctc' ), |
| 608 |
'line-through' => esc_html__( 'Line Through', 'ctc' ), |
| 609 |
], |
| 610 |
'selectors' => $text_decoration_selectors, |
| 611 |
] |
| 612 |
); |
| 613 |
endif; |
| 614 |
|
| 615 |
if ( $text_align ) : |
| 616 |
$self->add_responsive_control( |
| 617 |
$id . '_text_align', |
| 618 |
[ |
| 619 |
'label' => esc_html__( 'Alignment', 'ctc' ), |
| 620 |
'type' => Controls_Manager::CHOOSE, |
| 621 |
'options' => [ |
| 622 |
'left' => [ |
| 623 |
'title' => esc_html__( 'Left', 'ctc' ), |
| 624 |
'icon' => 'eicon-text-align-left', |
| 625 |
], |
| 626 |
'center' => [ |
| 627 |
'title' => esc_html__( 'Center', 'ctc' ), |
| 628 |
'icon' => 'eicon-text-align-center', |
| 629 |
], |
| 630 |
'right' => [ |
| 631 |
'title' => esc_html__( 'Right', 'ctc' ), |
| 632 |
'icon' => 'eicon-text-align-right', |
| 633 |
], |
| 634 |
], |
| 635 |
'selectors' => [ |
| 636 |
'{{WRAPPER}} ' . $selector => 'text-align: {{VALUE}};', |
| 637 |
], |
| 638 |
] |
| 639 |
); |
| 640 |
endif; |
| 641 |
|
| 642 |
if ( $box_shadow ) : |
| 643 |
$self->add_group_control( |
| 644 |
Group_Control_Box_Shadow::get_type(), |
| 645 |
[ |
| 646 |
'name' => $id . '_box_shadow', |
| 647 |
'selector' => '{{WRAPPER}} ' . $selector, |
| 648 |
] |
| 649 |
); |
| 650 |
endif; |
| 651 |
|
| 652 |
if ( $tabs ) : |
| 653 |
// Tabs. |
| 654 |
$self->start_controls_tabs( |
| 655 |
$id . '_style_tabs' |
| 656 |
); |
| 657 |
|
| 658 |
// Normal. |
| 659 |
$self->start_controls_tab( |
| 660 |
$id . '_style_normal_tab', |
| 661 |
[ |
| 662 |
'label' => esc_html__( 'Normal', 'ctc' ), |
| 663 |
] |
| 664 |
); |
| 665 |
|
| 666 |
if ( $normal_background ) : |
| 667 |
$self->add_group_control( |
| 668 |
Group_Control_Background::get_type(), |
| 669 |
[ |
| 670 |
'name' => $id . '_normal_background', |
| 671 |
'types' => [ 'classic', 'gradient', 'image', 'video' ], |
| 672 |
'selector' => '{{WRAPPER}} ' . $selector, |
| 673 |
] |
| 674 |
); |
| 675 |
endif; |
| 676 |
|
| 677 |
if ( $normal_text_color ) : |
| 678 |
$normal_text_color_label = esc_html__( 'Text Color', 'ctc' ); |
| 679 |
$normal_text_color_selectors = [ |
| 680 |
'{{WRAPPER}} ' . $selector => 'color: {{VALUE}};', |
| 681 |
]; |
| 682 |
if ( isset( $args['normal_text_color'] ) && is_array( $args['normal_text_color'] ) ) { |
| 683 |
if ( isset( $args['normal_text_color']['selectors'] ) ) { |
| 684 |
$normal_text_color_selectors = $args['normal_text_color']['selectors']; |
| 685 |
} |
| 686 |
if ( isset( $args['normal_text_color']['label'] ) ) { |
| 687 |
$normal_text_color_label = $args['normal_text_color']['label']; |
| 688 |
} |
| 689 |
} |
| 690 |
$self->add_control( |
| 691 |
$id . '_normal_text_color', |
| 692 |
[ |
| 693 |
'label' => $normal_text_color_label, |
| 694 |
'type' => Controls_Manager::COLOR, |
| 695 |
'selectors' => $normal_text_color_selectors, |
| 696 |
] |
| 697 |
); |
| 698 |
endif; |
| 699 |
|
| 700 |
if ( $normal_typography ) : |
| 701 |
$self->add_group_control( |
| 702 |
Group_Control_Typography::get_type(), |
| 703 |
[ |
| 704 |
'name' => $id . '_normal_typography', |
| 705 |
'selector' => '{{WRAPPER}} ' . $selector, |
| 706 |
] |
| 707 |
); |
| 708 |
endif; |
| 709 |
|
| 710 |
if ( $normal_border ) : |
| 711 |
$self->add_group_control( |
| 712 |
Group_Control_Border::get_type(), |
| 713 |
[ |
| 714 |
'name' => $id . '_normal_border', |
| 715 |
'default' => 'red', |
| 716 |
'selector' => '{{WRAPPER}} ' . $selector, |
| 717 |
] |
| 718 |
); |
| 719 |
endif; |
| 720 |
|
| 721 |
if ( $normal_box_shadow ) : |
| 722 |
$self->add_group_control( |
| 723 |
Group_Control_Box_Shadow::get_type(), |
| 724 |
[ |
| 725 |
'name' => $id . '_normal_box_shadow', |
| 726 |
'selector' => '{{WRAPPER}} ' . $selector, |
| 727 |
] |
| 728 |
); |
| 729 |
endif; |
| 730 |
|
| 731 |
$self->end_controls_tab(); |
| 732 |
// Normal End. |
| 733 |
|
| 734 |
// Hover. |
| 735 |
$self->start_controls_tab( |
| 736 |
$id . '_style_hover_tab', |
| 737 |
[ |
| 738 |
'label' => esc_html__( 'Hover', 'ctc' ), |
| 739 |
] |
| 740 |
); |
| 741 |
|
| 742 |
if ( $normal_background ) : |
| 743 |
$self->add_group_control( |
| 744 |
Group_Control_Background::get_type(), |
| 745 |
[ |
| 746 |
'name' => $id . '_hover_background', |
| 747 |
'types' => [ 'classic', 'gradient', 'image', 'video' ], |
| 748 |
'selector' => '{{WRAPPER}} ' . $selector . ':hover', |
| 749 |
] |
| 750 |
); |
| 751 |
endif; |
| 752 |
|
| 753 |
if ( $normal_text_color ) : |
| 754 |
|
| 755 |
$hover_text_color_label = esc_html__( 'Text Color', 'ctc' ); |
| 756 |
$hover_text_color_selectors = [ |
| 757 |
'{{WRAPPER}} ' . $selector => 'color: {{VALUE}};', |
| 758 |
]; |
| 759 |
if ( isset( $args['hover_text_color'] ) && is_array( $args['hover_text_color'] ) ) { |
| 760 |
if ( isset( $args['hover_text_color']['selectors'] ) ) { |
| 761 |
$hover_text_color_selectors = $args['hover_text_color']['selectors']; |
| 762 |
} |
| 763 |
if ( isset( $args['hover_text_color']['label'] ) ) { |
| 764 |
$hover_text_color_label = $args['hover_text_color']['label']; |
| 765 |
} |
| 766 |
} |
| 767 |
|
| 768 |
$self->add_control( |
| 769 |
$id . '_hover_text_color', |
| 770 |
[ |
| 771 |
'label' => $hover_text_color_label, |
| 772 |
'type' => Controls_Manager::COLOR, |
| 773 |
'selectors' => $hover_text_color_selectors, |
| 774 |
] |
| 775 |
); |
| 776 |
endif; |
| 777 |
|
| 778 |
if ( $normal_border ) : |
| 779 |
$self->add_control( |
| 780 |
$id . '_hover_border', |
| 781 |
[ |
| 782 |
'label' => esc_html__( 'Border Color', 'ctc' ), |
| 783 |
'type' => Controls_Manager::COLOR, |
| 784 |
'selectors' => [ |
| 785 |
'{{WRAPPER}} ' . $selector . ':hover' => 'border-color: {{VALUE}};', |
| 786 |
], |
| 787 |
] |
| 788 |
); |
| 789 |
endif; |
| 790 |
|
| 791 |
if ( $normal_box_shadow ) : |
| 792 |
$self->add_group_control( |
| 793 |
Group_Control_Box_Shadow::get_type(), |
| 794 |
[ |
| 795 |
'name' => $id . '_hover_box_shadow', |
| 796 |
'selector' => '{{WRAPPER}} ' . $selector . ':hover', |
| 797 |
] |
| 798 |
); |
| 799 |
endif; |
| 800 |
|
| 801 |
$self->end_controls_tab(); |
| 802 |
// Hover End. |
| 803 |
|
| 804 |
$self->end_controls_tabs(); |
| 805 |
// Tabs. |
| 806 |
endif; |
| 807 |
|
| 808 |
$self->end_controls_section(); |
| 809 |
// Section End. |
| 810 |
} |
| 811 |
} |
| 812 |
|