Secure Copy Content Protection and Content Locking Shortcodes

Below, you’ll find a detailed guide on how to add the Secure Copy Content Protection and Content Locking Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Secure Copy Content Protection and Content Locking Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Secure Copy Content Protection and Content Locking Plugin and the shortcodes it provides:

Plugin Icon
Secure Copy Content Protection and Content Locking

"Secure Copy Content Protection and Content Locking is a robust WordPress plugin designed to safeguard your site's content from unauthorized copying or plagiarism, ensuring your intellectual property stays protected."

★★★★✩ (48) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • []
  • [ays_block_subscribe]
  • []
  • [ays_sccp_user_first_name]
  • [ays_sccp_user_last_name]
  • [ays_sccp_user_email]
  • [ays_sccp_user_roles]
  • [ays_sccp_user_display_name]
  • [ays_sccp_user_nickname]

Secure Copy Content Protection and Content Locking [ays_block] Shortcode

The Secure Copy Content Protection shortcode is a powerful tool that allows content blocking based on various parameters. The shortcode is: [ays_block]. The shortcode function ‘ays_block’ enforces content access restrictions based on user roles, password protection, and specific time frames. It also tracks user access count and implements session control for enhanced security. This shortcode is invaluable for websites that require content protection and user access control.

Shortcode: [null]

Parameters

Here is a list of all possible null shortcode parameters and attributes:

  • id – The unique identifier of the blocked content.
  • options – Contains various settings related to the block content.
  • bc_schedule_from – The starting time for the content block schedule.
  • bc_schedule_to – The ending time for the content block schedule.
  • pass_count – The number of times the password has been entered.
  • pass_limit – The maximum number of times the password can be entered.
  • user_role – The user role that has access to the blocked content.
  • password – The password required to access the blocked content.

Examples and Usage

Basic example – Securely display content by referencing the block ID

[ays_block id=1 /]

Advanced examples

Using the shortcode to display a block of content by referencing the block ID. The content will be shown only if the user has the correct password or if the user role matches the one specified in the block settings.

[ays_block id=2 /]

Using the shortcode to display a block of content by referencing the block ID. The content will be shown only if the user has the correct password. If the user does not have the correct password, a custom message will be displayed instead.

[ays_block id=3 /]

Using the shortcode to display a block of content by referencing the block ID. The content will be shown only if the user role matches the one specified in the block settings. If the user role does not match, a custom message will be displayed instead.

[ays_block id=4 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [null] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ays_block', array( $this, 'sccp_blockcont_generate_shortcode' ) );

Shortcode PHP function:

function sccp_blockcont_generate_shortcode( $atts, $content ) {
		wp_enqueue_style($this->plugin_name.'-block-content', plugin_dir_url(__FILE__) . 'css/block_content_public.css', array(), $this->version, 'all');
		global $wpdb;
		$id = esc_sql($atts['id']);
		$bc_table = esc_sql(SCCP_BLOCK_CONTENT);

		$sccp_result = $wpdb->get_row(
					    $wpdb->prepare( 'SELECT * FROM '. $bc_table .' WHERE id = %d',
					        $id
					    )
					);		
		$result = (array) $sccp_result;

		$sccp_wpdb_id = isset($result['id']) && $result['id'] != null ? absint( intval($result['id'])) : null;
		
		if ( !session_id() ) {
			session_start();
		}

		if ($result == null) {				
			return do_shortcode($content);
		}

		$options = json_decode($result['options'], true);
		$bc_schedule_from = isset($options['bc_schedule_from']) && !empty($options['bc_schedule_from']) ? strtotime($options['bc_schedule_from']) : false;
		$bc_schedule_to	  = isset($options['bc_schedule_to']) && !empty($options['bc_schedule_to']) ? strtotime($options['bc_schedule_to']) : false;
		$pass_count = isset($options['pass_count']) ? intval($options['pass_count']) : 0;
		$pass_limit = isset($options['pass_limit']) && ($options['pass_limit'] != 0 ) ? intval($options['pass_limit']) : 0;
		$pass_count = intval($pass_count);
		$pass_limit = intval($pass_limit);
		$not_expired = true;
		$current_time = strtotime(current_time( "Y:m:d H:i:s" ));

		if ($bc_schedule_from && $bc_schedule_to) {
			if ($bc_schedule_from < $current_time && $bc_schedule_to > $current_time) {
				$not_expired = true;
			}else{
				$not_expired = false;
			}
		}
		$check_session_id = isset($_SESSION['ays_bc_user'][$id]) ? $_SESSION['ays_bc_user'][$id] : false;

		if ($pass_count >= $pass_limit && $pass_limit != 0 && $check_session_id != true){				    
			return '';
		}else{
			if ($not_expired) {
				if (isset($options['user_role']) && !empty($options['user_role'])) {
					$role_check = true;
					$pass_check = false;
				}else{
					$pass_check = isset($result['password']) && !empty($result['password']) ? true : false;
					$role_check = false;
				}
				if ($role_check) {
					$user = wp_get_current_user();
					$user_role = isset($user->roles[0]) && !empty($user->roles[0]) ? $user->roles[0] : '';
					if (!is_user_logged_in() && $user_role == '') {
						$user_role = 'guest';
					}
					
					if (isset($options['user_role']) && !empty($options['user_role'])) {
						$check_role = $options['user_role'];

						if(in_array($user_role, $check_role)){
							$role_check = true;
						}else{
							$role_check = false;
						}	
					}

					if ($role_check == false) {				
						$con = '';
						return $con;
					}else{
						// ---------AV User role count-----------
						$bc_result_options = json_decode($result['options'], true);
						$user_role_count = isset($bc_result_options['user_role_count']) ? intval($bc_result_options['user_role_count']) : 0;
						$user_role_count = intval($user_role_count);
						$user_role_count++;

						$bc_options = array(
							'user_role'	 		 =>  $bc_result_options['user_role'],
							'pass_count'		 =>  $bc_result_options['pass_count'],
							'user_role_count'	 =>  $user_role_count,
							'pass_limit'		 =>  isset($bc_result_options['pass_limit']) ? $bc_result_options['pass_limit'] : 0,
							'bc_schedule_from'	 =>  $bc_result_options['bc_schedule_from'],
							'bc_schedule_to'	 =>  $bc_result_options['bc_schedule_to']
						);
						$bc_options = json_encode($bc_options);
						$table = esc_sql(SCCP_BLOCK_CONTENT);

						if ($sccp_wpdb_id != $id) {
							$wpdb->insert( $table,
						        array(
						            'options' 	=> $bc_options
						        ),
							    array( '%s' )
							);
						}else{
							$wpdb->update( $table,
						        array(
						            'options' 	=> $bc_options
						        ),
						        array( 'id' => $id ),
							    array( '%s' ),
							    array( '%d' )
							);
						}					

						return '<div>' . do_shortcode($content) . '</div>';
					}

				}elseif($pass_check){
					if ( !session_id() ) {
						session_start();
					}

					global $wpdb;
					$sccp_table = esc_sql(SCCP_TABLE);
					$sccp_result = $wpdb->get_row("SELECT * FROM " . $sccp_table . " WHERE id = 1", ARRAY_A);
					$sccp_data   = json_decode($sccp_result["options"], true);

					$bc_header_text = isset($sccp_data["bc_header_text"]) && !empty($sccp_data["bc_header_text"]) ? stripslashes($sccp_data["bc_header_text"]) : __('You need to Enter right password', $this->plugin_name);

					$bc_button_position = isset($sccp_data["sccp_bc_button_position"]) && $sccp_data["sccp_bc_button_position"] != '' ? $sccp_data["sccp_bc_button_position"] : 'next-to';

			        if (!isset($_SESSION['ays_bc_user'])) {
			        	$_SESSION['ays_bc_user'] = array();
			        }

			        if($bc_button_position == 'next-to'){
			        	$bc_button_style = 'display:flex; justify-content:center;';
			        }else{
			        	$bc_button_style = 'display:block;';
			        }

					$con = do_shortcode('<div class="conblock_div" id="conblock_div_id">
												<p class="conblock_block_para">' . $bc_header_text . '</p>
												<div class="conblock_icon">
													<img src="'.SCCP_PUBLIC_URL.'/images/lock.png" class="ays_sccp_lock" alt="Lock">
												</div>
												<form action="" method="post" class="conblock_block_form" style="'.$bc_button_style.'">
													<div class="ays_sccp_bc_form_fields">
														<input type="password" required name="pass_form" placeholder="'.__('Password').'">
													</div>
													<div class="ays_sccp_bc_form_fields">
													<input type="submit" name="sub_form_'.$id.'" value="'.__("Submit").'">
													</div>
												</form>
										</div>');
					if(isset($_SESSION['ays_bc_user'][$id]) && $_SESSION['ays_bc_user'][$id] == true) {
					    $con = '<div>' . do_shortcode($content) . '</div>';
					    return $con;
				    }

					$pass = $result['password'];
					if (isset($_POST['sub_form_'.$id.''])) {
						$check_pass = isset($_POST['pass_form']) && $_POST['pass_form'] == $pass ? true : false ;
						if ($check_pass) {
						// ---------AV Password count-----------					
							$bc_result_options = json_decode($result['options'], true);
							$pass_count++;
							$bc_options = array(
								'user_role'	 		 =>  $bc_result_options['user_role'],
								'pass_count'		 =>  $pass_count,
								'pass_limit'		 =>  isset($bc_result_options['pass_limit']) ? $bc_result_options['pass_limit'] : 0,
								'user_role_count'	 =>  $bc_result_options['user_role_count'],
								'bc_schedule_from'	 =>  $bc_result_options['bc_schedule_from'],
								'bc_schedule_to'	 =>  $bc_result_options['bc_schedule_to']
							);
							$bc_options = json_encode($bc_options);
							$table = esc_sql(SCCP_BLOCK_CONTENT);
							
							if ($sccp_wpdb_id != $id) {
								$wpdb->insert( $table,
							        array(
							            'options' 	=> $bc_options
							        ),
								    array( '%s' )
								);
							}else{
								$wpdb->update( $table,
							        array(
							            'options' 	=> $bc_options
							        ),
							        array( 'id' => $id ),
								    array( '%s' ),
								    array( '%d' )
								);
							}

							$_SESSION['ays_bc_user'][$id] = true;
						}else{
							$_SESSION['ays_bc_user'][$id] = false;
						}

						if ($_SESSION['ays_bc_user'][$id]) {
					        $con = '<div>' . do_shortcode($content) . '</div>';
				        }
					}

					return $con;

				}else{			
					return '<div>' . do_shortcode($content) . '</div>';
				}
			}else{
				return '';
			}
		}	
	}

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/class-secure-copy-content-protection-public.php

Secure Copy Content Protection and Content Locking [ays_block_subscribe] Shortcode

The Secure Copy Content Protection shortcode is used to generate a subscription form. This form is customizable and includes fields for email and name, with options to enable or disable these fields. The shortcode also includes style settings for the form, allowing for customization of text color, background color, button style, and more. The related PHP code defines the function that generates the shortcode. It first enqueues the necessary scripts and styles. Then, it retrieves the shortcode attributes and settings from the database. The function also includes code for handling form submissions, including saving subscriber data to the database and integration with MailChimp.

Shortcode: [ays_block_subscribe]

Parameters

Here is a list of all possible ays_block_subscribe shortcode parameters and attributes:

  • id – Unique identifier of the subscription form

Examples and Usage

Basic example – Displaying a block subscribe form by referencing the ID.

[ays_block_subscribe id=1 /]

Advanced example – Displaying a block subscribe form by referencing the ID and adding custom content within the shortcode. If the referenced ID is not found, the custom content will be displayed.

[ays_block_subscribe id=1]Oops! The subscription form could not be found. Please try again later.[/ays_block_subscribe]

PHP Function Code

In case you have difficulties debugging what causing issues with [ays_block_subscribe] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'ays_block_subscribe', array( $this, 'sccp_blocksubscribe_generate_shortcode' ) );

Shortcode PHP function:

function sccp_blocksubscribe_generate_shortcode( $atts, $content ) {
		wp_enqueue_style($this->plugin_name.'-block-subscribe', plugin_dir_url(__FILE__) . 'css/block_subscribe_public.css', array(), $this->version, 'all');
		wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/secure-copy-content-protection-public.js', array('jquery'), $this->version, false);
		global $wpdb;
	 	$sccp_settings = $this->settings;

		$id = (isset($atts['id']) && $atts['id'] != '') ? absint(intval(esc_sql($atts['id']))) : null;
		if (is_null($id)) {
            return '<p>' .$content. '</p>';
        }
		$subsql = "SELECT * FROM ".$wpdb->prefix."ays_sccp_block_subscribe WHERE id=".$id;
		$get_sub_res = $wpdb->get_results($subsql , "ARRAY_A"); 
		if(empty($get_sub_res)){
			return '<p>' .$content. '</p>';
		}
		$report_table = esc_sql($wpdb->prefix."ays_sccp_reports");

		$ays_sccp_table = esc_sql(SCCP_TABLE);
		$ays_sccp_result = $wpdb->get_row("SELECT * FROM " . $ays_sccp_table . " WHERE id = 1", ARRAY_A);
		$ays_sccp_data   = json_decode($ays_sccp_result["options"], true);

		// General Setting's Subscribe       
        $general_settings_subscribe = ($sccp_settings->ays_get_setting('subscribe') === false) ? json_encode(array()) : $sccp_settings->ays_get_setting('subscribe');
        $subscribe_settings = json_decode(stripcslashes($general_settings_subscribe), true);

        // Subscribe box width
        if(isset($subscribe_settings['sccp_sub_width']) && $subscribe_settings['sccp_sub_width'] != '' && absint( $subscribe_settings['sccp_sub_width'] ) > 0){
            if (isset($subscribe_settings['sccp_sub_width_by_percentage_px']) && $subscribe_settings['sccp_sub_width_by_percentage_px'] == 'percentage') {
                if (absint(intval($subscribe_settings['sccp_sub_width'])) > 100 ) {
                    $sub_width = 'max-width: 100%;';
                }else{
                    $sub_width = 'max-width: '. $subscribe_settings['sccp_sub_width'] . '%;';
                }
            }else{
                $sub_width = 'max-width: '. $subscribe_settings['sccp_sub_width'] . 'px;';
            }
        }else{
            $sub_width = 'max-width: fit-content;';
        }

        // Subscribe box text color
		$sub_text_color = (isset($subscribe_settings['sccp_sub_text_color']) && $subscribe_settings['sccp_sub_text_color'] != '') ? 'color:'.stripslashes( esc_attr($subscribe_settings['sccp_sub_text_color']) ).';' : 'color: #000;';

        // Subscribe description text color
		$sub_desc_text_color = (isset($subscribe_settings['sccp_sub_desc_text_color']) && $subscribe_settings['sccp_sub_desc_text_color'] != '') ? 'color:'.stripslashes( esc_attr($subscribe_settings['sccp_sub_desc_text_color']) ).';' : 'color: #000;';

        // Subscribe box background color
		$sub_bg_color = (isset($subscribe_settings['sccp_sub_bg_color']) && $subscribe_settings['sccp_sub_bg_color'] != '') ? 'background-color:'.stripslashes( esc_attr($subscribe_settings['sccp_sub_bg_color']) ).';' : 'background-color: #fff;';

		// Subscribe box title transformation
        $sub_title_transformation = (isset($subscribe_settings['sub_title_transformation']) && sanitize_text_field( $subscribe_settings['sub_title_transformation'] ) != "") ? sanitize_text_field( $subscribe_settings['sub_title_transformation'] ) : 'none';

		// Subscribe box title font size		
		$sub_title_size = isset($subscribe_settings['sccp_sub_title_size']) && $subscribe_settings['sccp_sub_title_size'] != '' && $subscribe_settings['sccp_sub_title_size'] != 0 ? 'font-size: '. absint( sanitize_text_field($subscribe_settings['sccp_sub_title_size']) ). 'px;' : '';

		// Subscribe box description font size		
		$sub_desc_size = isset($subscribe_settings['sccp_sub_desc_size']) && $subscribe_settings['sccp_sub_desc_size'] != '' && $subscribe_settings['sccp_sub_desc_size'] != 0 ? 'font-size: '. absint( sanitize_text_field($subscribe_settings['sccp_sub_desc_size']) ). 'px;' : '';
		

        // Subscribe button text
		$sub_button_text = (isset($subscribe_settings['sccp_sub_button_text']) && $subscribe_settings['sccp_sub_button_text'] != '') ? stripslashes( esc_attr($subscribe_settings['sccp_sub_button_text']) ) : __('Subscribe', $this->plugin_name);

		// Subscribe Add Icon image
		$sccp_sub_icon_image = isset($subscribe_settings["sub_icon_image"]) && !empty($subscribe_settings["sub_icon_image"]) ? $subscribe_settings["sub_icon_image"] : SCCP_PUBLIC_URL.'/images/email.png';

		// Subscribe Add BG image
		$sccp_sub_bg_image = isset($subscribe_settings["sub_bg_image"]) && !empty($subscribe_settings["sub_bg_image"]) ? 'background-image: url('.$subscribe_settings["sub_bg_image"].');' : '';

		// Subscribe Bg image positioning
		$sccp_sub_bg_image_position = (isset($subscribe_settings["sub_bg_image_position"]) && $subscribe_settings["sub_bg_image_position"] != '') ? 'background-position:'. $subscribe_settings["sub_bg_image_position"] .';' : "background-position:center center;";
		
		// Subscribe button style
		$subscribe_settings['enable_sub_btn_style'] = (isset($subscribe_settings['enable_sub_btn_style']) && $subscribe_settings['enable_sub_btn_style'] == 'on') ? 'on' : 'off'; 
		$ays_sccp_enable_sub_btn_style = (isset($subscribe_settings['enable_sub_btn_style']) && $subscribe_settings['enable_sub_btn_style'] == 'on') ? true : false;
		$ays_sccp_sub_btn_color = (isset($subscribe_settings['sub_btn_color']) && $subscribe_settings['sub_btn_color'] != '') ? stripslashes( esc_attr( $subscribe_settings['sub_btn_color'] ) ) : 'rgba(255,255,255,0)';
		$ays_sccp_sub_btn_text_color = (isset($subscribe_settings['sub_btn_text_color']) && $subscribe_settings['sub_btn_text_color'] != '') ? stripslashes( esc_attr( $subscribe_settings['sub_btn_text_color'] ) ) : '#000000';
		$sccp_sub_btn_color = $ays_sccp_enable_sub_btn_style ? 'background-color:'.$ays_sccp_sub_btn_color.';' : '';
		$sccp_sub_btn_text_color = $ays_sccp_enable_sub_btn_style ? 'color:'.$ays_sccp_sub_btn_text_color.';' : '';

		$ays_sccp_sub_btn_size = (isset($subscribe_settings['sub_btn_size']) && $subscribe_settings['sub_btn_size'] != '') ? stripslashes( esc_attr( $subscribe_settings['sub_btn_size'] ) ) : '14';
		$sccp_sub_btn_size = $ays_sccp_enable_sub_btn_style ? 'font-size:'.$ays_sccp_sub_btn_size.'px;' : '';

		$sub_mobile_btn_size = (isset($subscribe_settings['sub_mobile_btn_size']) && $subscribe_settings['sub_mobile_btn_size'] != '') ? stripslashes( esc_attr( $subscribe_settings['sub_mobile_btn_size'] ) ) : '14';
		$sccp_sub_mobile_btn_size = $ays_sccp_enable_sub_btn_style ? 'font-size:'.$sub_mobile_btn_size.'px !important;' : '';

		$ays_sccp_sub_btn_radius = (isset($subscribe_settings['sub_btn_radius']) && $subscribe_settings['sub_btn_radius'] != '') ? $subscribe_settings['sub_btn_radius'] : '3';

		$sccp_sub_btn_radius = $ays_sccp_enable_sub_btn_style ? 'border-radius:'.$ays_sccp_sub_btn_radius.'px;' : '';

		// Buttons border width
		$ays_sccp_sub_btn_border_width = (isset($subscribe_settings['sub_btn_border_width']) && $subscribe_settings['sub_btn_border_width'] != '') ? $subscribe_settings['sub_btn_border_width'] : '1';		

		$sccp_sub_btn_border_width = $ays_sccp_enable_sub_btn_style ? 'border-width:'.$ays_sccp_sub_btn_border_width.'px;' : '';

		// Buttons border style
		$ays_sccp_sub_btn_border_style = (isset($subscribe_settings['sub_btn_border_style']) && $subscribe_settings['sub_btn_border_style'] != '') ? $subscribe_settings['sub_btn_border_style'] : 'solid';

		// Container border style
		$sub_cont_border_style = (isset($subscribe_settings['sub_cont_border_style']) && $subscribe_settings['sub_cont_border_style'] != '') ? 'border-style: '. $subscribe_settings['sub_cont_border_style'] .';' : 'border-style: solid;';

		// Container border width
		$sub_cont_border_width = (isset($subscribe_settings['sub_cont_border_width']) && $subscribe_settings['sub_cont_border_width'] != '') ? 'border-width: '. $subscribe_settings['sub_cont_border_width'] .'px;': '';

		// Container input width
		$sub_cont_input_width = (isset($subscribe_settings['sub_cont_input_width']) && $subscribe_settings['sub_cont_input_width'] != '' && $subscribe_settings['sub_cont_input_width'] != 0) ? 'max-width: '. $subscribe_settings['sub_cont_input_width'] .'px;': '';

		$sccp_sub_btn_border_style = $ays_sccp_enable_sub_btn_style ? 'border-style:'.$ays_sccp_sub_btn_border_style : '';

		// Buttons border color
		$ays_sccp_sub_btn_border_color = (isset($subscribe_settings['sub_btn_border_color']) && $subscribe_settings['sub_btn_border_color'] != '') ? stripslashes( esc_attr( $subscribe_settings['sub_btn_border_color'] ) ) : '#000000';

		// Container border color
		$ays_sccp_sub_cont_border_color = (isset($subscribe_settings['sub_cont_border_color']) && $subscribe_settings['sub_cont_border_color'] != '') ? stripslashes( esc_attr( $subscribe_settings['sub_cont_border_color'] ) ) : '#000000';

		$sccp_sub_btn_border_color = $ays_sccp_enable_sub_btn_style ? 'border-color:'.$ays_sccp_sub_btn_border_color.';' : '';

		$sccp_sub_cont_border_color = 'border-color:'.$ays_sccp_sub_cont_border_color.';';

		// Buttons Left / Right padding
        $sccp_sub_btn_left_right_padding = '20px';
        if(isset($subscribe_settings['sub_btn_left_right_padding']) && $subscribe_settings['sub_btn_left_right_padding'] != ''){
            $sccp_sub_btn_left_right_padding = $subscribe_settings['sub_btn_left_right_padding'] . 'px';
        }

        // Buttons Top / Bottom padding
        $sccp_sub_btn_top_bottom_padding = '10px';
        if(isset($subscribe_settings['sub_btn_top_bottom_padding']) && $subscribe_settings['sub_btn_top_bottom_padding'] != ''){
            $sccp_sub_btn_top_bottom_padding = $subscribe_settings['sub_btn_top_bottom_padding'] . 'px';
        }

        $sccp_sub_btn_padding = $ays_sccp_enable_sub_btn_style ? 'padding:'.$sccp_sub_btn_top_bottom_padding.' '.$sccp_sub_btn_left_right_padding.';' : '';


        // Subscribe email placeholder text
		$sub_email_place_text = (isset($subscribe_settings['sccp_sub_email_place_text']) && $subscribe_settings['sccp_sub_email_place_text'] != '') ? stripslashes( esc_attr($subscribe_settings['sccp_sub_email_place_text']) ) : __('Type your email address', $this->plugin_name);

        // Subscribe name placeholder text
		$sub_name_place_text = (isset($subscribe_settings['sccp_sub_name_place_text']) && $subscribe_settings['sccp_sub_name_place_text'] != '') ? stripslashes( esc_attr($subscribe_settings['sccp_sub_name_place_text']) ) : __('Type your name', $this->plugin_name);

		// Subscribe box text alignment
        $sccp_sub_text_alignment = (isset($subscribe_settings['sccp_sub_text_alignment']) && sanitize_text_field( $subscribe_settings['sccp_sub_text_alignment'] ) != '') ? sanitize_text_field( $subscribe_settings['sccp_sub_text_alignment'] ) : 'center';

		$consub_div = 'style="'.$sub_width.' '.$sub_text_color.' '.$sub_bg_color.' '.$sub_cont_border_style.' '.$sub_cont_border_width.' '.$sccp_sub_cont_border_color.' '.$sccp_sub_bg_image.' '.$sccp_sub_bg_image_position.'"';

		$subs_to_view_header_text = isset($ays_sccp_data["subs_to_view_header_text"]) && !empty($ays_sccp_data["subs_to_view_header_text"]) ? stripslashes($ays_sccp_data["subs_to_view_header_text"]) : __('Subscribe', $this->plugin_name);

		$sub_block_button_position = isset($ays_sccp_data["sccp_sub_block_button_position"]) && $ays_sccp_data["sccp_sub_block_button_position"] != '' ? $ays_sccp_data["sccp_sub_block_button_position"] : 'next-to';

		if($sub_block_button_position == 'next-to'){
			$sub_block_button_style = 'display:flex; justify-content:center;';
			$sub_block_input_style = 'width:100%;';
		}else{
			$sub_block_button_style = 'display:block;';
			$sub_block_input_style = '';
		}

		foreach ( $get_sub_res as $key => $blocsubscribe ) { 
                $block_options = isset($blocsubscribe['options']) ? json_decode($blocsubscribe['options'], true) : array();
             
                $enable_block_sub_name_field = isset($block_options['enable_name_field']) && $block_options['enable_name_field'] == 'on' ? 'checked' : '';
             
                $enable_block_sub_desc_field = isset($block_options['enable_desc_field']) && $block_options['enable_desc_field'] == 'on' ? 'checked' : '';

                $enable_block_sub_desc_textarea = isset($block_options['enable_desc_textarea']) ? stripslashes( esc_attr( $block_options['enable_desc_textarea'] ) ) : '';
        }

        $block_sub_desc_field = '';
        if($enable_block_sub_desc_field == "checked"){
        	$block_sub_desc_field = '<p class="consub_para" style="text-align:'.$sccp_sub_text_alignment.';'.$sub_desc_text_color.' '.$sub_desc_size.'">'.$enable_block_sub_desc_textarea.'</p>';
        }

        $block_sub_name_field = '';
        if($enable_block_sub_name_field == "checked"){
        	$block_sub_name_field = '<div class="subscribe_form_email">
				<input type="text" class="ays_sccp_sb_name ays_sccp_sb_field" name="ays_sb_name_field_'.$id.'" placeholder="'.$sub_name_place_text.'" style="'.$sub_block_input_style.'">
			</div>';
        }            

        // General Setting's Options       
        $general_settings_options = ($sccp_settings->ays_get_setting('options') === false) ? json_encode(array()) : $sccp_settings->ays_get_setting('options');
        $settings_options = json_decode(stripcslashes($general_settings_options), true);

      	// Do not store IP adressess 
        $sccp_disable_user_ip = (isset($settings_options['sccp_disable_user_ip']) && $settings_options['sccp_disable_user_ip'] == 'on') ? true : false;
        
        if($sccp_disable_user_ip){
            $user_ip = '';
        }else{
            $user_ip = $this->sccp_get_user_ip();
        }
        
		$cookie_sub_val = '';
		$cookie_sub_name = '';

		$other_info = array();
		$con ='
			<style>
				@media screen and (max-width: 768px){
					.subscribe_form input[type="submit"]{
					    '.$sccp_sub_mobile_btn_size.'
					}
				}

				input.ays_sccp_sb_email.ays_sccp_sb_field[type="email"], 
				input.ays_sccp_sb_name.ays_sccp_sb_field[type="text"]{
					'.$sub_cont_input_width.'
				}

			</style>
			<div class="consub_div" id="consub_div_id" '. $consub_div .'>
				<p class="consub_para" style="text-transform:'.$sub_title_transformation.'; '.$sub_title_size.' text-align:'.$sccp_sub_text_alignment.';"> ' . $subs_to_view_header_text . '</p>
				<div class="consub_icon" style="justify-content:'.$sccp_sub_text_alignment.';">
					<img src="'.$sccp_sub_icon_image.'" class="ays_sccp_lock_sub" alt="Lock">
				</div>
				'. $block_sub_desc_field .'
				<form action="" class="ays_sb_form" method="post">
					<div class="subscribe_form" style="'.$sub_block_button_style.'">
					'.$block_sub_name_field . '
					<div class="subscribe_form_email">
						<input type="email" class="ays_sccp_sb_email ays_sccp_sb_field" required name="ays_sb_email_form_'.$id.'" placeholder="'.$sub_email_place_text.'" style="'.$sub_block_input_style.'">
					</div>
					<div class="subscribe_form_email">
						<input type="submit" style="'.$sccp_sub_btn_color.' '.$sccp_sub_btn_text_color.' '.$sccp_sub_btn_size.' '.$sccp_sub_btn_radius.' '.$sccp_sub_btn_padding.' '. $sccp_sub_btn_border_width.' '.$sccp_sub_btn_border_color.' '.$sccp_sub_btn_border_style.'" class="ays_sccp_sb_sbm ays_sccp_sb_field" name="subscribe_sub_'.$id.'" value="'.$sub_button_text.'">
					</div>
					</div>
				</form>
			</div>';		

		$cookie_sub_name = 'bs_email_'.$id;
		if (!isset($_COOKIE[$cookie_sub_name]) && isset($_POST['subscribe_sub_'.$id])) {
			$c_ip = file_get_contents("https://api.db-ip.com/v2/free/".$user_ip);
            $c_data = json_decode($c_ip,true);
            $sub_city = isset($c_data["city"]) && !empty($c_data["city"]) ? $c_data["city"].", " : '';
            $sub_country_name = isset($c_data["countryName"]) && !empty($c_data["countryName"]) ? $c_data["countryName"] : '';
            $sub_country = $sub_city.$sub_country_name;

			$cookie_sub_val = $_POST['ays_sb_email_form_'.$id];
			setcookie($cookie_sub_name, $cookie_sub_val, time()+(86400*365),"/");
			if(isset($_POST['ays_sb_email_form_'.$id])) {
				
				$check_email = $wpdb->get_row("SELECT * FROM " . $report_table . " WHERE subscribe_email = '".$_POST['ays_sb_email_form_'.$id]."' " , ARRAY_A);
				
				if ( $check_email === null ) {
				
					$sub_email = esc_sql($_POST['ays_sb_email_form_'.$id]);
					$sub_name = isset($_POST['ays_sb_name_field_'.$id]) ? esc_sql($_POST['ays_sb_name_field_'.$id]) : '';
					$wpdb->insert(
						$report_table,
						array(
							'subscribe_id'  	=> $id,
							'subscribe_email'  	=> $sub_email,
							'user_name'			=> $sub_name,
							'user_ip'    		=> $user_ip,
							'user_id'    		=> is_user_logged_in() ? wp_get_current_user()->ID : 0,
							'vote_date'  		=> current_time('Y-m-d G:i:s'),
							'other_info' 		=> json_encode($other_info),
							'user_address' 		=> $sub_country
						),
						array('%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')
					);

				}

				// MailChimp
				$styles_sql = "SELECT styles FROM ".$wpdb->prefix."ays_sccp WHERE id=1";
				$option = $wpdb->get_var($styles_sql);
				$options = json_decode($option, true);
				
				if (isset($options['enable_mailchimp']) && $options['enable_mailchimp'] == 'on') {
                    if (isset($options['mailchimp_list']) && $options['mailchimp_list'] != "") {

                        $sccp_settings = $this->settings;
                        $mailchimp_res = ($sccp_settings->ays_get_setting('mailchimp') === false) ? json_encode(array()) : $sccp_settings->ays_get_setting('mailchimp');
                        $mailchimp = json_decode($mailchimp_res, true);
                        $mailchimp_username = isset($mailchimp['username']) ? $mailchimp['username'] : '';
                        $mailchimp_api_key = isset($mailchimp['apiKey']) ? $mailchimp['apiKey'] : '';
                        $mailchimp_list = (isset($options['mailchimp_list'])) ? $options['mailchimp_list'] : '';				
                        $mailchimp_email = $sub_email;
						$enable_double_opt_in = (isset($options['sccp_enable_mailchimp_optin']) && $options['sccp_enable_mailchimp_optin'] == 'on') ? true : false;
                        $user_id = is_user_logged_in() ? wp_get_current_user()->ID : 0;
                        $mailchimp_fname = $user_id != 0 ? get_userdata($user_id)->data->display_name : "Guest";                        
                        if ($mailchimp_username != "" && $mailchimp_api_key != "") {
                            $args = array(
                                "email" => $mailchimp_email,
                                "fname" => $mailchimp_fname,
								"double_optin" => $enable_double_opt_in
                            );
                            $mresult = $this->ays_add_mailchimp_transaction($mailchimp_username, $mailchimp_api_key, $mailchimp_list, $args);
                        }
                    }
                }
				
				return do_shortcode('<p>' .$content . '</p>');
			}else{
				return do_shortcode($con);
			}
		}elseif(isset($_COOKIE[$cookie_sub_name])){
            return do_shortcode('<p>' .$content . '</p>');
        }
		return do_shortcode($con);
	}

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/class-secure-copy-content-protection-public.php

Secure Copy Content Protection and Content Locking [ays_sccp_subscribers_count] Shortcode

The Secure Copy Content Protection (SCCP) shortcode is designed to generate the count of subscribers. It uses the shortcode: [ays_sccp_subscribers_count]. This shortcode fetches the subscriber count related to the specific ID provided. If a null or zero value is entered, it returns an error message. The function also generates a unique ID for each instance, ensuring data accuracy.

Shortcode: [ays_sccp_subscribers_count]

Parameters

Here is a list of all possible null shortcode parameters and attributes:

  • id – Unique identifier for the specific form in use

Examples and Usage

Basic example – A shortcode to display the count of subscribers for a specific content protection. The ‘id’ parameter is used to specify the content protection.

[ays_sccp_subscribers_count id=1 /]

Advanced examples

1. Displaying the count of subscribers for multiple content protections by specifying their IDs. The shortcode will return the total count of subscribers for all specified content protections.

[ays_sccp_subscribers_count id="1,2,3" /]

2. Using the shortcode to display the count of subscribers for a specific content protection and altering the output with CSS. The ‘class’ parameter is used to assign a specific CSS class to the output.

[ays_sccp_subscribers_count id=1 class="my_custom_class" /]

Please note that the ‘id’ parameter is essential for the shortcode to work correctly. If the ‘id’ is not specified or the specified ‘id’ does not exist, the shortcode will return a message indicating that the shortcode was initialized incorrectly.

PHP Function Code

In case you have difficulties debugging what causing issues with [null] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('ays_sccp_subscribers_count', array($this, 'ays_generate_subscribers_count_method'));

Shortcode PHP function:

function ays_generate_subscribers_count_method( $attr ){

        $id = (isset($attr['id']) && $attr['id'] != '') ? absint( sanitize_text_field($attr['id']) ) : null;

        if (is_null($id) || $id == 0 ) {
            $passed_users_count_html = "<p class='wrong_shortcode_text' style='color:red;'>" . __('Wrong shortcode initialized', $this->plugin_name) . "</p>";
            return str_replace(array("\r\n", "\n", "\r"), "\n", $passed_users_count_html);
        }

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = $id . "-" . $unique_id;


        $passed_users_count_html = $this->ays_sccp_subscribers_count_html( $id );
        return str_replace(array("\r\n", "\n", "\r"), "\n", $passed_users_count_html);
    }

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/partials/class-secure-copy-content-protection-extra-shortcode.php

Secure Copy Content Protection and Content Locking [ays_sccp_user_first_name] Shortcode

The Secure Copy Content Protection (SCCP) shortcode is designed to generate the logged-in user’s first name. This shortcode calls the function ‘ays_generate_user_first_name_method’. It creates a unique ID for the session and checks if a user is logged in. If a user is logged in, it generates and returns the user’s first name. The output is formatted to remove any carriage return or line break characters.

Shortcode: [ays_sccp_user_first_name]

Examples and Usage

Basic example – A shortcode that displays the first name of the logged-in user.

[ays_sccp_user_first_name /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ays_sccp_user_first_name] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('ays_sccp_user_first_name', array($this, 'ays_generate_user_first_name_method'));

Shortcode PHP function:

function ays_generate_user_first_name_method(){

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = $unique_id;

        $user_first_name_html = "";
        if(is_user_logged_in()){
            $user_first_name_html = $this->ays_generate_user_first_name_html();
        }
        return str_replace(array("\r\n", "\n", "\r"), "\n", $user_first_name_html);
    }

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/partials/class-secure-copy-content-protection-extra-shortcode.php

Secure Copy Content Protection and Content Locking [ays_sccp_user_last_name] Shortcode

The Secure Copy Content Protection (SCCP) plugin shortcode is a tool that generates the last name of a logged-in user. This shortcode uses a unique identifier to create an HTML string containing the user’s last name. It only functions if the user is logged in, ensuring information privacy.

Shortcode: [ays_sccp_user_last_name]

Examples and Usage

Basic example – Secure Copy Content Protection plugin allows you to create a shortcode that generates the last name of the logged-in user. This is useful when you want to personalize your content based on the logged-in user.

[ays_sccp_user_last_name /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ays_sccp_user_last_name] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('ays_sccp_user_last_name', array($this, 'ays_generate_user_last_name_method'));

Shortcode PHP function:

function ays_generate_user_last_name_method(){

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = $unique_id;

        $user_last_name_html = "";
        if(is_user_logged_in()){
            $user_last_name_html = $this->ays_generate_user_last_name_html();
        }
        return str_replace(array("\r\n", "\n", "\r"), "\n", $user_last_name_html);
    }

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/partials/class-secure-copy-content-protection-extra-shortcode.php

Secure Copy Content Protection and Content Locking [ays_sccp_user_email] Shortcode

The Secure Copy Content Protection shortcode is a PHP function that generates a unique user email ID. It’s activated when a user logs in. The shortcode uses the ‘ays_generate_user_email_method’ function. It creates a unique ID for each user and checks if the user is logged in. If yes, it generates the user’s email HTML. The function also replaces all types of line breaks with “\n” to ensure consistency in the output.

Shortcode: [ays_sccp_user_email]

Examples and Usage

Basic example – The following example demonstrates a basic usage of the shortcode. It calls the ‘ays_sccp_user_email’ shortcode without any additional parameters or attributes.

[ays_sccp_user_email]

PHP Function Code

In case you have difficulties debugging what causing issues with [ays_sccp_user_email] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('ays_sccp_user_email', array($this, 'ays_generate_user_email_method'));

Shortcode PHP function:

function ays_generate_user_email_method(){

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = $unique_id;

        $user_email_html = "";
        if(is_user_logged_in()){
            $user_email_html = $this->ays_generate_user_email_html();
        }
        return str_replace(array("\r\n", "\n", "\r"), "\n", $user_email_html);
    }

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/partials/class-secure-copy-content-protection-extra-shortcode.php

Secure Copy Content Protection and Content Locking [ays_sccp_user_roles] Shortcode

The Secure Copy Content Protection (SCCP) shortcode is designed to generate unique user roles. It uses the ‘ays_sccp_user_roles’ shortcode to create a unique ID for each user. The PHP function ‘ays_generate_user_roles_method’ is called, which checks if the user is logged in. If the user is logged in, it generates an HTML string for the user’s email. The function returns this HTML string, ensuring any line breaks are standardized.

Shortcode: [ays_sccp_user_roles]

Examples and Usage

Basic Example – The following basic example demonstrates how to use the ays_sccp_user_roles shortcode without any additional parameters. This will generate the user roles based on the logged-in user.

[ays_sccp_user_roles /]

PHP Function Code

In case you have difficulties debugging what causing issues with [ays_sccp_user_roles] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('ays_sccp_user_roles', array($this, 'ays_generate_user_roles_method'));

Shortcode PHP function:

function ays_generate_user_roles_method(){

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = $unique_id;

        $user_email_html = "";
        if(is_user_logged_in()){
            $user_email_html = $this->ays_generate_user_roles_html();
        }
        return str_replace(array("\r\n", "\n", "\r"), "\n", $user_email_html);
    }

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/partials/class-secure-copy-content-protection-extra-shortcode.php

Secure Copy Content Protection and Content Locking [ays_sccp_user_display_name] Shortcode

The Secure Copy Content Protection plugin shortcode is designed to generate a unique user display name. This shortcode checks if a user is logged in. If true, it generates a unique ID for the user and replaces any line breaks in the user’s display name with a newline character.

Shortcode: [ays_sccp_user_display_name]

Examples and Usage

Basic example – Showcases the usage of the ‘ays_sccp_user_display_name’ shortcode without any additional parameters.

[ays_sccp_user_display_name]

PHP Function Code

In case you have difficulties debugging what causing issues with [ays_sccp_user_display_name] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('ays_sccp_user_display_name', array($this, 'ays_generate_user_display_name_method'));

Shortcode PHP function:

function ays_generate_user_display_name_method(){

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = $unique_id;

        $user_display_name_html = "";
        if(is_user_logged_in()){
            $user_display_name_html = $this->ays_generate_user_display_name_html();
        }
        return str_replace(array("\r\n", "\n", "\r"), "\n", $user_display_name_html);
    }

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/partials/class-secure-copy-content-protection-extra-shortcode.php

Secure Copy Content Protection and Content Locking [ays_sccp_user_nickname] Shortcode

The Secure Copy Content Protection shortcode is designed to generate a unique user nickname. It creates a unique ID for each user and checks if the user is logged in. This shortcode then returns the user’s nickname, replacing any line breaks with a single newline character. It’s a handy tool for personalizing content.

Shortcode: [ays_sccp_user_nickname]

Examples and Usage

Basic example – The shortcode is used to generate a unique nickname for a logged-in user.

[ays_sccp_user_nickname]

PHP Function Code

In case you have difficulties debugging what causing issues with [ays_sccp_user_nickname] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('ays_sccp_user_nickname', array($this, 'ays_generate_user_nickname_method'));

Shortcode PHP function:

function ays_generate_user_nickname_method(){

        $unique_id = uniqid();
        $this->unique_id = $unique_id;
        $this->unique_id_in_class = $unique_id;

        $user_nickname_html = "";
        if(is_user_logged_in()){
            $user_nickname_html = $this->ays_generate_user_nickname_html();
        }
        return str_replace(array("\r\n", "\n", "\r"), "\n", $user_nickname_html);
    }

Code file location:

secure-copy-content-protection/secure-copy-content-protection/public/partials/class-secure-copy-content-protection-extra-shortcode.php

Conclusion

Now that you’ve learned how to embed the Secure Copy Content Protection and Content Locking Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *