rk'] ) {
$sharing_url = 'https://vkontakte.ru/share.php?url='. $args['url'] .'&title='. $args['title'] .'&description='. wp_trim_words( $args['text'], 250 ) .'&image='. $args['image'] .'/';
$network_title = esc_html__( 'vKontakte', 'wpr-addons' );
} elseif ( 'odnoklassniki' === $args['network'] ) {
$sharing_url = 'http://odnoklassniki.ru/dk?st.cmd=addShare&st.s=1&st._surl='. $args['url'];
$network_title = esc_html__( 'OdnoKlassniki', 'wpr-addons' );
} elseif ( 'get-pocket' === $args['network'] ) {
$sharing_url = 'https://getpocket.com/edit?url='. $args['url'];
$network_title = esc_html__( 'Pocket', 'wpr-addons' );
} elseif ( 'skype' === $args['network'] ) {
$sharing_url = 'https://web.skype.com/share?url='. $args['url'];
$network_title = esc_html__( 'Skype', 'wpr-addons' );
} elseif ( 'whatsapp' === $args['network'] ) {
if ( 'yes' === $args['show_whatsapp_title'] && 'yes' == $args['show_whatsapp_excerpt'] ) {
$sharing_url = 'https://api.whatsapp.com/send?text=*'. $args['title'] .'*%0a'. wp_strip_all_tags($args['text']) .'%0a'. $args['url'];
} else if ( 'yes' === $args['show_whatsapp_title'] ) {
$sharing_url = 'https://api.whatsapp.com/send?text=*'. $args['title'] .'*%0a'. $args['url'];
} else if ( 'yes' === $args['show_whatsapp_excerpt'] ) {
$sharing_url = 'https://api.whatsapp.com/send?text=*'. wp_strip_all_tags($args['text']) .'%0a'. $args['url'];
} else {
$sharing_url = 'https://api.whatsapp.com/send?text='. $args['url'];
}
$network_title = esc_html__( 'WhatsApp', 'wpr-addons' );
} elseif ( 'telegram' === $args['network'] ) {
$sharing_url = 'https://telegram.me/share/url?url='. $args['url'] .'&text='. $args['text'];
$network_title = esc_html__( 'Telegram', 'wpr-addons' );
} elseif ( 'delicious' === $args['network'] ) {
$sharing_url = 'https://del.icio.us/save?url='. $args['url'] .'&title={title}';
$network_title = esc_html__( 'Delicious', 'wpr-addons' );
} elseif ( 'envelope' === $args['network'] ) {
$sharing_url = 'mailto:?subject='. $args['title'] .'&body='. $args['url'];
$network_title = esc_html__( 'Email', 'wpr-addons' );
} elseif ( 'print' === $args['network'] ) {
$sharing_url = 'javascript:window.print()';
$network_title = esc_html__( 'Print', 'wpr-addons' );
} else {
$sharing_url = '';
$network_title = '';
}
$sharing_url = 'print' === $args['network'] ? $sharing_url : $sharing_url;
$output = '';
if ( '' !== $network_title ) {
$output .= '';
// Tooltip
$output .= 'yes' === $args['tooltip'] ? ''. esc_html( $network_title ) .'' : '';
// Category
if ( 'envelope' === $args['network'] || 'print' === $args['network'] ) {
$category = 'fas';
} else {
$category = 'fab';
}
// Icon
if ( 'yes' === $args['icons'] ) {
$output .= '';
}
// Label
if ( isset( $args['labels'] ) && 'yes' === $args['labels'] ) {
$label = isset( $args['custom_label'] ) && '' !== $args['custom_label'] ? $args['custom_label'] : $network_title;
$output .= ''. esc_html( $label ) .'';
}
$output .= '';
}
return $output;
}
/**
** Filter oEmbed Results
*/
public static function filter_oembed_results( $html ) {
// Filter
preg_match( '/<\/iframe>/isU', $html, $matches );
// Return URL
return $matches[1] .'&auto_play=true';
}
/**
** Get Post Custom Meta Keys
*/
public static function get_custom_meta_keys() { // needs ajaxifying
$data = [];
$options = [];
$merged_meta_keys = [];
$post_types = Utilities::get_custom_types_of( 'post', false );
foreach ( $post_types as $post_type_slug => $post_type_name ) {
$data[ $post_type_slug ] = [];
$posts = get_posts( [ 'post_type' => $post_type_slug, 'posts_per_page' => -1 ] );
foreach ( $posts as $key => $post ) {
$meta_keys = get_post_custom_keys( $post->ID );
if ( ! empty($meta_keys) ) {
for ( $i = 0; $i < count( $meta_keys ); $i++ ) {
if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) {
array_push( $data[$post_type_slug], $meta_keys[$i] );
}
}
}
}
$data[ $post_type_slug ] = array_unique( $data[ $post_type_slug ] );
}
foreach ( $data as $array ) {
$merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) );
}
// Rekey
$merged_meta_keys = array_values($merged_meta_keys);
for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) {
$options[ $merged_meta_keys[$i] ] = $merged_meta_keys[$i];
}
return [ $data, $options ];
}
/**
** Get Taxonomy Custom Meta Keys
*/
public static function get_custom_meta_keys_tax() { // needs ajaxifying
$data = [];
$options = [];
$merged_meta_keys = [];
$tax_types = Utilities::get_custom_types_of( 'tax', false );
foreach ( $tax_types as $taxonomy_slug => $post_type_name ) {
$data[ $taxonomy_slug ] = [];
$taxonomies = get_terms( $taxonomy_slug );
foreach ( $taxonomies as $key => $tax ) {
$meta_keys = get_term_meta( $tax->term_id );
$meta_keys = array_keys($meta_keys);
if ( ! empty($meta_keys) ) {
for ( $i = 0; $i < count( $meta_keys ); $i++ ) {
if ( '_' !== substr( $meta_keys[$i], 0, 1 ) ) {
array_push( $data[$taxonomy_slug], $meta_keys[$i] );
}
}
}
}
$data[ $taxonomy_slug ] = array_unique( $data[ $taxonomy_slug ] );
}
foreach ( $data as $array ) {
$merged_meta_keys = array_unique( array_merge( $merged_meta_keys, $array ) );
}
// Rekey
$merged_meta_keys = array_values($merged_meta_keys);
for ( $i = 0; $i < count( $merged_meta_keys ); $i++ ) {
$options[ $merged_meta_keys[$i] ] = $merged_meta_keys[$i];
}
return [ $data, $options ];
}
/**
** Get SVG Icons Array
*/
public static function get_svg_icons_array( $stack, $fa_icons ) {
$svg_icons = [];
if ( 'arrows' === $stack ) {
$svg_icons['svg-angle-1-left'] = esc_html__( 'Angle', 'wpr-addons' );
$svg_icons['svg-angle-2-left'] = esc_html__( 'Angle Bold', 'wpr-addons' );
$svg_icons['svg-angle-3-left'] = esc_html__( 'Angle Bold Round', 'wpr-addons' );
$svg_icons['svg-angle-4-left'] = esc_html__( 'Angle Plane', 'wpr-addons' );
$svg_icons['svg-arrow-1-left'] = esc_html__( 'Arrow', 'wpr-addons' );
$svg_icons['svg-arrow-2-left'] = esc_html__( 'Arrow Bold', 'wpr-addons' );
$svg_icons['svg-arrow-3-left'] = esc_html__( 'Arrow Bold Round', 'wpr-addons' );
$svg_icons['svg-arrow-4-left'] = esc_html__( 'Arrow Caret', 'wpr-addons' );
} elseif ( 'blockquote' === $stack ) {
$svg_icons['svg-blockquote-1'] = esc_html__( 'Blockquote Round', 'wpr-addons' );
$svg_icons['svg-blockquote-2'] = esc_html__( 'Blockquote ST', 'wpr-addons' );
$svg_icons['svg-blockquote-3'] = esc_html__( 'Blockquote BS', 'wpr-addons' );
$svg_icons['svg-blockquote-4'] = esc_html__( 'Blockquote Edges', 'wpr-addons' );
$svg_icons['svg-blockquote-5'] = esc_html__( 'Blockquote Quad', 'wpr-addons' );
} elseif ( 'sharing' === $stack ) {
// $svg_icons['svg-sharing-1'] = esc_html__( 'sharing 1', 'wpr-addons' );
// $svg_icons['svg-sharing-2'] = esc_html__( 'sharing 2', 'wpr-addons' );
}
// Merge FontAwesome and SVG icons
return array_merge( $fa_icons, $svg_icons );
}
/**
** Get SVG Icon
*/
public static function get_svg_icon( $icon, $dir ) {
$style_attr = '';
// Rotate Right
if ( 'right' === $dir ) {
$style_attr = 'style="transform: rotate(180deg); -webkit-transform: rotate(180deg);" ';
}
$icons = [
// Arrows
'svg-angle-1-left' => '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'svg-angle-2-left' => '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'svg-angle-3-left' => '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'svg-angle-4-left' => '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'svg-arrow-1-left' => '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'svg-arrow-2-left' => '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'svg-arrow-3-left' => '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
'svg-arrow-4-left' => '', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
// Blockquote
'svg-blockquote-1' => '',
'svg-blockquote-2' => '',
'svg-blockquote-3' => '',
'svg-blockquote-4' => '',
'svg-blockquote-5' => '',
// Sharing
'svg-sharing-1' => '',
'svg-sharing-2' => '',
];
return $icons[$icon];
}
/**
** Get WPR Icon
*/
public static function get_wpr_icon( $icon, $dir ) {
if ( false !== strpos( $icon, 'svg-' ) ) {
return Utilities::get_svg_icon( $icon, $dir );
} elseif ( false !== strpos( $icon, 'fa-' ) ) {
$dir = '' !== $dir ? '-'. $dir : '';
return wp_kses('', [
'i' => [
'class' => []
]
]);
} else {
return '';
}
}
/**
** Mailchimp AJAX Subscribe
*/
public static function ajax_mailchimp_subscribe() {
// API Key
$api_key = !empty(get_option('wpr_mailchimp_api_key')) && false != get_option('wpr_mailchimp_api_key') ? get_option('wpr_mailchimp_api_key') : ''; // GOGA
$api_key_sufix = explode( '-', $api_key )[1];
// List ID
$list_id = isset($_POST['listId']) ? sanitize_text_field(wp_unslash($_POST['listId'])) : '';
// Get Available Fileds (PHPCS - fields are sanitized later on input)
$available_fields = isset($_POST['fields']) ? $_POST['fields'] : []; // phpcs:ignore
wp_parse_str( $available_fields, $fields );
// Merge Additional Fields
$merge_fields = array(
'FNAME' => !empty( $fields['wpr_mailchimp_firstname'] ) ? sanitize_text_field($fields['wpr_mailchimp_firstname']) : '',
'LNAME' => !empty( $fields['wpr_mailchimp_lastname'] ) ? sanitize_text_field($fields['wpr_mailchimp_lastname']) : '',
'PHONE' => !empty ( $fields['wpr_mailchimp_phone_number'] ) ? sanitize_text_field($fields['wpr_mailchimp_phone_number']) : '',
);
// API URL
$api_url = 'https://'. $api_key_sufix .'.api.mailchimp.com/3.0/lists/'. $list_id .'/members/'. md5(strtolower(sanitize_text_field($fields['wpr_mailchimp_email'])));
// API Args
$api_args = [
'method' => 'PUT',
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'apikey '. $api_key,
],
'body' => json_encode([
'email_address' => sanitize_text_field($fields[ 'wpr_mailchimp_email' ]),
'status' => 'subscribed',
'merge_fields' => $merge_fields,
]),
];
// Send Request
$request = wp_remote_post( $api_url, $api_args );
if ( ! is_wp_error($request) ) {
$request = json_decode( wp_remote_retrieve_body($request) );
// Set Status
if ( ! empty($request) ) {
if ($request->status == 'subscribed') {
wp_send_json([ 'status' => 'subscribed' ]);
} else {
wp_send_json([ 'status' => $request->title ]);
}
}
}
}
/**
** Mailchimp - Get Lists
*/
public static function get_mailchimp_lists() {
$api_key = get_option('wpr_mailchimp_api_key', '');
$mailchimp_list = [
'def' => esc_html__( 'Select List', 'wpr-addons' )
];
if ( '' === $api_key ) {
return $mailchimp_list;
} else {
$url = 'https://'. substr( $api_key, strpos( $api_key, '-' ) + 1 ) .'.api.mailchimp.com/3.0/lists/';
$args = [ 'headers' => [ 'Authorization' => 'Basic ' . base64_encode( 'user:'. $api_key ) ] ];
$response = wp_remote_get( $url, $args );
$body = json_decode($response['body']);
if ( ! empty( $body->lists ) ) {
foreach ( $body->lists as $list ) {
$mailchimp_list[$list->id] = $list->name .' ('. $list->stats->member_count .')';
}
}
return $mailchimp_list;
}
}
// Needs further logic
public static function get_mailchimp_groups() {
$groups_array = ['def' => 'Select Group'];
foreach (self::get_mailchimp_lists() as $key => $value ) {
if ( 'def' === $key ) {
continue;
}
$audience = $key; // How to get settin
$api_key = get_option('wpr_mailchimp_api_key');
$url = 'https://'. substr( $api_key, strpos( $api_key, '-' ) + 1 ) .'.api.mailchimp.com/3.0/lists/'.$audience.'/interest-categories';
$args = [ 'headers' => [ 'Authorization' => 'Basic ' . base64_encode( 'user:'. $api_key ) ] ];
$response = wp_remote_get( $url, $args );
foreach ( json_decode($response['body'])->categories as $key => $value ) {
$group_name = $value->title;
$group_id = $value->id;
$url = 'https://'. substr( $api_key, strpos( $api_key, '-' ) + 1 ) .'.api.mailchimp.com/3.0/lists/'.$audience.'/interest-categories/'. $value->id .'/interests';
$args = [ 'headers' => [ 'Authorization' => 'Basic ' . base64_encode( 'user:'. $api_key ) ] ];
$response = wp_remote_get( $url, $args );
foreach (json_decode($response['body'])->interests as $key => $value ) {
// var_dump($group_name, $group_id);
// var_dump($group_name, $group_id, $value->id, $value->name);
$groups_array[$value->id] = $value->name;
}
}
}
return $groups_array;
}
/**
** WPR Animation Timings
*/
public static function wpr_animation_timings() {
$timing_functions = [
'ease-default' => 'Default',
'linear' => 'Linear',
'ease-in' => 'Ease In',
'ease-out' => 'Ease Out',
'pro-eio' => 'EI Out (Pro)',
'pro-eiqd' => 'EI Quad (Pro)',
'pro-eicb' => 'EI Cubic (Pro)',
'pro-eiqrt' => 'EI Quart (Pro)',
'pro-eiqnt' => 'EI Quint (Pro)',
'pro-eisn' => 'EI Sine (Pro)',
'pro-eiex' => 'EI Expo (Pro)',
'pro-eicr' => 'EI Circ (Pro)',
'pro-eibk' => 'EI Back (Pro)',
'pro-eoqd' => 'EO Quad (Pro)',
'pro-eocb' => 'EO Cubic (Pro)',
'pro-eoqrt' => 'EO Quart (Pro)',
'pro-eoqnt' => 'EO Quint (Pro)',
'pro-eosn' => 'EO Sine (Pro)',
'pro-eoex' => 'EO Expo (Pro)',
'pro-eocr' => 'EO Circ (Pro)',
'pro-eobk' => 'EO Back (Pro)',
'pro-eioqd' => 'EIO Quad (Pro)',
'pro-eiocb' => 'EIO Cubic (Pro)',
'pro-eioqrt' => 'EIO Quart (Pro)',
'pro-eioqnt' => 'EIO Quint (Pro)',
'pro-eiosn' => 'EIO Sine (Pro)',
'pro-eioex' => 'EIO Expo (Pro)',
'pro-eiocr' => 'EIO Circ (Pro)',
'pro-eiobk' => 'EIO Back (Pro)',
];
if ( wpr_fs()->can_use_premium_code() && defined('WPR_ADDONS_PRO_VERSION') ) {
$timing_functions = \WprAddonsPro\Includes\Controls\WPR_Control_Animations_Pro::wpr_animation_timings();
}
return $timing_functions;
}
public static function wpr_animation_timing_pro_conditions() {
return ['pro-eio','pro-eiqd','pro-eicb','pro-eiqrt','pro-eiqnt','pro-eisn','pro-eiex','pro-eicr','pro-eibk','pro-eoqd','pro-eocb','pro-eoqrt','pro-eoqnt','pro-eosn','pro-eoex','pro-eocr','pro-eobk','pro-eioqd','pro-eiocb','pro-eioqrt','pro-eioqnt','pro-eiosn','pro-eioex','pro-eiocr','pro-eiobk'];
}
/**
** WPR Library Button
*/
public static function wpr_library_buttons( $module, $controls_manager, $tutorial_url = '' ) {
if ( empty(get_option('wpr_wl_plugin_links')) ) {
if ( '' !== $tutorial_url ) {
$tutorial_link = ''. esc_html__( 'Watch Video Tutorial ', 'wpr-addons' ) .'';
} else {
$tutorial_link = '';
}
$module->add_control(
'wpr_library_buttons',
[
'raw' => ''. $tutorial_link,
'type' => $controls_manager,
]
);
}
}
/**
** Upgrade to Pro Notice
*/
public static function upgrade_pro_notice( $module, $controls_manager, $widget, $option, $condition = [] ) {
if ( wpr_fs()->can_use_premium_code() ) {
return;
}
$url = 'https://royal-elementor-addons.com/?ref=rea-plugin-panel-'. $widget .'-upgrade-pro#purchasepro';
$module->add_control(
$option .'_pro_notice',
[
'raw' => 'This option is available
in the Pro version and above.',
// 'raw' => 'This option is available
in the Pro version',
'type' => $controls_manager,
'content_classes' => 'wpr-pro-notice',
'condition' => [
$option => $condition,
]
]
);
}
public static function upgrade_expert_notice( $module, $controls_manager, $widget, $option, $condition = [] ) {
if ( wpr_fs()->is_plan( 'expert' ) ) {
return;
}
$url = 'https://royal-elementor-addons.com/?ref=rea-plugin-panel-'. $widget .'-upgrade-expert#purchasepro';
$module->add_control(
$option .'_expert_notice',
[
'raw' => 'This option is available
in the Expert version',
// 'raw' => 'This option is available
in the Pro version',
'type' => $controls_manager,
'content_classes' => 'wpr-pro-notice',
'condition' => [
$option => $condition,
]
]
);
}
/**
** Request Feature Section
*/
public static function wpr_add_section_request_feature( $module, $raw_html, $tab ) {
$module->start_controls_section(
'section_request_new_feature',
[
'label' => __( 'Request Feature', 'wpr-addons' ),
'tab' => $tab,
]
);
$module->add_control(
'request_new_feature',
[
'type' => $raw_html,
'raw' => __( 'Missing an Option, have a New Widget or any kind of Feature Idea? Please share it with us and lets discuss. Request New Feature ', 'wpr-addons' ),
]
);
$module->end_controls_section(); // End Controls Section
}
/**
** Pro Features List Section
*/
public static function pro_features_list_section( $module, $section, $type, $widget, $features ) {
if ( wpr_fs()->can_use_premium_code() ) {
return;
}
if ( '' === $section ) {
$module->start_controls_section(
'pro_features_section',
[
'label' => 'Pro Features ',
]
);
} else {
$module->start_controls_section(
'pro_features_section',
[
'label' => 'Pro Features ',
'tab' => $section,
]
);
}
$list_html = '';
for ($i=0; $i < count($features); $i++) {
$list_html .= ''. $features[$i] .'';
}
$module->add_control(
'pro_features_list',
[
'type' => $type,
'raw' => '
Get Pro version',
'content_classes' => 'wpr-pro-features-list',
]
);
$module->end_controls_section();
}
// Add two new functions for handling cookies
public function get_wishlist_from_cookie() {
if (isset($_COOKIE['wpr_wishlist'])) {
return json_decode(stripslashes($_COOKIE['wpr_wishlist']), true);
} else if ( isset($_COOKIE['wpr_wishlist_'. get_current_blog_id() .'']) ) {
return json_decode(stripslashes($_COOKIE['wpr_wishlist_'. get_current_blog_id() .'']), true);
}
return array();
}
// Client IP for form submission
public static function get_client_ip() {
$server_ip_keys = [
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_X_CLUSTER_CLIENT_IP',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'REMOTE_ADDR',
];
foreach ( $server_ip_keys as $key ) {
$value = self::_unstable_get_super_global_value( $_SERVER, $key );
if ( $value && filter_var( $value, FILTER_VALIDATE_IP ) ) {
return $value;
}
}
// Fallback local ip.
return '127.0.0.1';
}
// For get_client_ip
public static function _unstable_get_super_global_value( $super_global, $key ) {
if ( ! isset( $super_global[ $key ] ) ) {
return null;
}
if ( $_FILES === $super_global ) {
$super_global[ $key ]['name'] = sanitize_file_name( $super_global[ $key ]['name'] );
return $super_global[ $key ];
}
return wp_kses_post_deep( wp_unslash( $super_global[ $key ] ) );
}
/**
** Check for New Free Users
*/
public static function is_new_free_user() {
return !wpr_fs()->can_use_premium_code() && (intval(get_option('royal_elementor_addons_activation_time')) > 1649247746);
}
// public static function is_new_free_user2() {
// return !wpr_fs()->can_use_premium_code() && (intval(get_option('royal_elementor_addons_activation_time')) > 1670317149);
// }
// public static function is_old_pro_user_or_expert() {
// return wpr_fs()->is_plan( 'expert' ) || (wpr_fs()->is_plan( 'pro' ) && (intval(get_option('royal_elementor_addons_pro_activation_time')) < 1680264265));
// }
// public static function is_new_pro_user() {
// return wpr_fs()->is_plan( 'pro' ) && (intval(get_option('royal_elementor_addons_pro_activation_time')) > 1680264265);
// }
/**
** HTML Tags Whitelist
*/
public static function validate_html_tags_wl( $setting, $default, $tags_whitelist ) {
$value = $setting;
if ( ! in_array($value, $tags_whitelist) ) {
$value = $default;
}
return $value;
}
}