$59 GRAYBYTE WORDPRESS FILE MANAGER $62

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/home/bqrcodec/contact.malloca.com/wp-content/themes/hello-elementor/

HOME
Current File : /home/bqrcodec/contact.malloca.com/wp-content/themes/hello-elementor//functions.php
<?php
/**
 * Theme functions and definitions
 *
 * @package HelloElementor
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

define( 'HELLO_ELEMENTOR_VERSION', '2.7.1' );

if ( ! isset( $content_width ) ) {
	$content_width = 800; // Pixels.
}

if ( ! function_exists( 'hello_elementor_setup' ) ) {
	/**
	 * Set up theme support.
	 *
	 * @return void
	 */
	function hello_elementor_setup() {
		if ( is_admin() ) {
			hello_maybe_update_theme_version_in_db();
		}

		if ( apply_filters( 'hello_elementor_register_menus', true ) ) {
			register_nav_menus( [ 'menu-1' => esc_html__( 'Header', 'hello-elementor' ) ] );
			register_nav_menus( [ 'menu-2' => esc_html__( 'Footer', 'hello-elementor' ) ] );
		}

		if ( apply_filters( 'hello_elementor_post_type_support', true ) ) {
			add_post_type_support( 'page', 'excerpt' );
		}

		if ( apply_filters( 'hello_elementor_add_theme_support', true ) ) {
			add_theme_support( 'post-thumbnails' );
			add_theme_support( 'automatic-feed-links' );
			add_theme_support( 'title-tag' );
			add_theme_support(
				'html5',
				[
					'search-form',
					'comment-form',
					'comment-list',
					'gallery',
					'caption',
					'script',
					'style',
				]
			);
			add_theme_support(
				'custom-logo',
				[
					'height'      => 100,
					'width'       => 350,
					'flex-height' => true,
					'flex-width'  => true,
				]
			);

			/*
			 * Editor Style.
			 */
			add_editor_style( 'classic-editor.css' );

			/*
			 * Gutenberg wide images.
			 */
			add_theme_support( 'align-wide' );

			/*
			 * WooCommerce.
			 */
			if ( apply_filters( 'hello_elementor_add_woocommerce_support', true ) ) {
				// WooCommerce in general.
				add_theme_support( 'woocommerce' );
				// Enabling WooCommerce product gallery features (are off by default since WC 3.0.0).
				// zoom.
				add_theme_support( 'wc-product-gallery-zoom' );
				// lightbox.
				add_theme_support( 'wc-product-gallery-lightbox' );
				// swipe.
				add_theme_support( 'wc-product-gallery-slider' );
			}
		}
	}
}
add_action( 'after_setup_theme', 'hello_elementor_setup' );

function hello_maybe_update_theme_version_in_db() {
	$theme_version_option_name = 'hello_theme_version';
	// The theme version saved in the database.
	$hello_theme_db_version = get_option( $theme_version_option_name );

	// If the 'hello_theme_version' option does not exist in the DB, or the version needs to be updated, do the update.
	if ( ! $hello_theme_db_version || version_compare( $hello_theme_db_version, HELLO_ELEMENTOR_VERSION, '<' ) ) {
		update_option( $theme_version_option_name, HELLO_ELEMENTOR_VERSION );
	}
}

if ( ! function_exists( 'hello_elementor_scripts_styles' ) ) {
	/**
	 * Theme Scripts & Styles.
	 *
	 * @return void
	 */
	function hello_elementor_scripts_styles() {
		$min_suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

		if ( apply_filters( 'hello_elementor_enqueue_style', true ) ) {
			wp_enqueue_style(
				'hello-elementor',
				get_template_directory_uri() . '/style' . $min_suffix . '.css',
				[],
				HELLO_ELEMENTOR_VERSION
			);
		}

		if ( apply_filters( 'hello_elementor_enqueue_theme_style', true ) ) {
			wp_enqueue_style(
				'hello-elementor-theme-style',
				get_template_directory_uri() . '/theme' . $min_suffix . '.css',
				[],
				HELLO_ELEMENTOR_VERSION
			);
		}
	}
}
add_action( 'wp_enqueue_scripts', 'hello_elementor_scripts_styles' );

if ( ! function_exists( 'hello_elementor_register_elementor_locations' ) ) {
	/**
	 * Register Elementor Locations.
	 *
	 * @param ElementorPro\Modules\ThemeBuilder\Classes\Locations_Manager $elementor_theme_manager theme manager.
	 *
	 * @return void
	 */
	function hello_elementor_register_elementor_locations( $elementor_theme_manager ) {
		if ( apply_filters( 'hello_elementor_register_elementor_locations', true ) ) {
			$elementor_theme_manager->register_all_core_location();
		}
	}
}
add_action( 'elementor/theme/register_locations', 'hello_elementor_register_elementor_locations' );

if ( ! function_exists( 'hello_elementor_content_width' ) ) {
	/**
	 * Set default content width.
	 *
	 * @return void
	 */
	function hello_elementor_content_width() {
		$GLOBALS['content_width'] = apply_filters( 'hello_elementor_content_width', 800 );
	}
}
add_action( 'after_setup_theme', 'hello_elementor_content_width', 0 );

if ( is_admin() ) {
	require get_template_directory() . '/includes/admin-functions.php';
}

/**
 * If Elementor is installed and active, we can load the Elementor-specific Settings & Features
*/

// Allow active/inactive via the Experiments
require get_template_directory() . '/includes/elementor-functions.php';

/**
 * Include customizer registration functions
*/
function hello_register_customizer_functions() {
	if ( is_customize_preview() ) {
		require get_template_directory() . '/includes/customizer-functions.php';
	}
}
add_action( 'init', 'hello_register_customizer_functions' );

if ( ! function_exists( 'hello_elementor_check_hide_title' ) ) {
	/**
	 * Check hide title.
	 *
	 * @param bool $val default value.
	 *
	 * @return bool
	 */
	function hello_elementor_check_hide_title( $val ) {
		if ( defined( 'ELEMENTOR_VERSION' ) ) {
			$current_doc = Elementor\Plugin::instance()->documents->get( get_the_ID() );
			if ( $current_doc && 'yes' === $current_doc->get_settings( 'hide_title' ) ) {
				$val = false;
			}
		}
		return $val;
	}
}
add_filter( 'hello_elementor_page_title', 'hello_elementor_check_hide_title' );

/** Pro ID Shop item
 */
function display_pro_id_shop_items_shortcode($atts) {
		// Get the current post ID
		$current_post_id = get_the_ID();

		// Get the current post author ID
		$current_author_id = get_post_field('post_author', $current_post_id);

		// Create the query arguments
		$args = array(
				'post_type'      => 'pro-id-shop', // Change to your custom post type slug
				'posts_per_page' => -1, // Retrieve all posts
				'author'         => $current_author_id, // Filter by author ID
		);

		// Query Pro ID Shop posts by the current author
		$pro_id_shop_posts = new WP_Query($args);

		// Output variable
		$output = '';

		// Check if there are Pro ID Shop posts by the current author
		if ($pro_id_shop_posts->have_posts()) {
				while ($pro_id_shop_posts->have_posts()) {
						$pro_id_shop_posts->the_post();

						// Get post metadata
						$product_image = jet_engine()->listings->data->get_meta('product-image');
						$product_description = get_post_meta(get_the_ID(), 'product-description', true);

						// Append Pro ID Shop listing item content to the output
						$output .= '<div class="pro-id-shop-item">';
						
						if ($product_image) {
								$output .= '<img src="' . $product_image['url'] . '" alt="Product Image">';
						}

						$output .= '<p>Author: ' . get_the_author() . '</p>';
						$output .= '<h3>' . get_the_title() . '</h3>';
						$output .= '<p>' . $product_description . '</p>';
						$output .= '</div>';
				}
		}

		// Reset the query
		wp_reset_postdata();

		return $output;
}
add_shortcode('pro_id_shop_items', 'display_pro_id_shop_items_shortcode');



add_action( 'elementor_pro/forms/new_record', function( $record, $handler ) {
		$form_name = $record->get_form_settings( 'form_name' );
		if ( 'My Pro Form' === $form_name && 'my_pro_id' === get_post_type() ) {
				$referral_code = get_post_meta( get_the_ID(), 'referral_code', true );
				$submitted_code = $record->get_field( 'referral_code' )['value'];
				if ( $referral_code === $submitted_code ) {
						update_user_meta( get_current_user_id(), 'referral-code', $submitted_code );
						$record->add_hidden_field( 'demo-status', 'deactivate' );
				} else {
						$record->add_form_error( 'referral_code', 'Invalid referral code' );
						$record->set_status( ElementorPro\Modules\Forms\Classes\Record::STATUS_ERROR );
				}
		}
}, 10, 2 );




function generate_vcf_file($form_data) {
	// Get the form field values
	$name = $form_data['field_05ba870'];
	$phone = $form_data['phone_field_1'];
	$email = $form_data['email_field_1'];
	$website = $form_data['field_02975d1'];
	$image_url = $form_data['field_b5025ea'];

function get_vcard($first_name, $last_name, $email, $phone, $website, $image_url) {
		$vcard = "BEGIN:VCARD\r\n";
		$vcard .= "VERSION:3.0\r\n";
		$vcard .= "N:$last_name;$first_name;;;\r\n";
		$vcard .= "FN:$first_name $last_name\r\n";
		$vcard .= "EMAIL;TYPE=INTERNET:$email\r\n";
		$vcard .= "TEL;TYPE=CELL:$phone\r\n";
		if (!empty($website)) {
				$vcard .= "URL:$website\r\n";
		}
		$vcard .= "PHOTO;VALUE=URL;TYPE=JPEG:$image_url\r\n";
		$vcard .= "END:VCARD\r\n";
		return $vcard;
}

	// Save the vCard string to a file
	$filename = $name . '.vcf';
	$filepath = '/path/to/save/' . $filename;
	file_put_contents($filepath, $vcard);

	// Return the file path
	return $filepath;
}

function send_vcf_attachment($contact_form) {
	// Get the submitted form data
	$form_data = $_POST;
	
	// Generate the vCard file
	$filepath = generate_vcf_file($form_data);
	
	// Get the email address to send the attachment to
	$to = $form_data['email1'];
	
	// Create a new email message with the vCard file as an attachment
	$subject = 'Your vCard';
	$message = 'Please find your vCard attached.';
	$headers = array('Content-Type: text/vcard');
	$attachments = array($filepath);
	
	// Send the email
	wp_mail($to, $subject, $message, $headers, $attachments);
}
add_action('wpcf7_mail_sent', 'send_vcf_attachment');


function add_shortcode_to_login() {
		echo do_shortcode('[gtranslate]');
}
add_action('login_form', 'add_shortcode_to_login');


$result = add_role(
		'basic_pro_id_member',
		__( 'Basic Pro ID Member' ),
		array(
				'read' => true, // Allows the user to read posts and pages
				'edit_posts' => true, // Allows the user to edit their own posts
				'upload_files' => true, // Allows the user to upload files
				'edit_published_posts' => true, // Allows the user to edit their own published posts
				'publish_posts' => true, // Allows the user to publish their own posts
				'delete_published_posts' => true, // Allows the user to delete their own published posts
		)
);


//Auto add URL to Swift Performance warmup table
function add_my_pro_id_to_warmup_table($urls) {
		$post_type = 'my-pro-id';
		$args = array(
				'post_type' => $post_type,
				'post_status' => 'publish',
				'posts_per_page' => -1,
		);
		$posts = get_posts($args);
		foreach($posts as $post) {
				$urls[] = get_permalink($post->ID);
		}
		return $urls;
}
add_filter('swift_performance_warmup_table_add_url', 'add_my_pro_id_to_warmup_table');


function remove_url_from_warmup_table($post_id) {
		if(get_post_type($post_id) == 'my-pro-id') {
				$url = get_permalink($post_id);
				swift_performance_warmup_table_remove_url($url);
		}
}
add_action('wp_trash_post', 'remove_url_from_warmup_table');


//Only retain the best resolution single image file 
function delete_intermediate_image_sizes($sizes) {
		// Get the ID of the current attachment
		$attachment_id = get_the_ID();

		// Get the URL of the largest image size
		$largest_image_url = wp_get_attachment_image_src($attachment_id, 'full')[0];

		// Loop through each intermediate size and delete it if it's not the largest
		foreach ($sizes as $size => $value) {
				$intermediate_image_url = wp_get_attachment_image_src($attachment_id, $size)[0];
				if ($intermediate_image_url && $intermediate_image_url !== $largest_image_url) {
						unlink(str_replace(site_url(), ABSPATH, $intermediate_image_url));
				}
		}
}
add_filter('intermediate_image_sizes_advanced', 'delete_intermediate_image_sizes');







function manualupdatemyproid_shortcode() {
	ob_start();
	?>
	<form method="post" enctype="multipart/form-data">
		<table>
			<tr>
				<td>URLs:</td>
				<td><textarea name="urls"></textarea></td>
			</tr>
			<tr>
				<td>Họ tên:</td>
				<td><input type="text" name="name"></td>
			</tr>
			<tr>
				<td>Avatar1:</td>
				<td><?php wp_nonce_field(plugin_basename(__FILE__), 'avatar1_nonce'); ?><input type="file" name="avatar1"></td>
			</tr>
			<tr>
				<td>Cover Image:</td>
				<td><?php wp_nonce_field(plugin_basename(__FILE__), 'cover_image_nonce'); ?><input type="file" name="cover-image"></td>
			</tr>
			<tr>
				<td>Phone:</td>
				<td><input type="text" name="phone"></td>
			</tr>
			<tr>
				<td>Email:</td>
				<td><input type="text" name="email"></td>
			</tr>
			<tr>
				<td>Color:</td>
				<td><input type="color" name="color"></td>
			</tr>
			<tr>
				<td>Address:</td>
				<td><input type="text" name="address"></td>
			</tr>
			<tr>
				<td>Organization:</td>
				<td><input type="text" name="organization"></td>
			</tr>
			<tr>
				<td>Logocongty:</td>
				<td><?php wp_nonce_field(plugin_basename(__FILE__), 'logocongty_nonce'); ?><input type="file" name="logocongty"></td>
			</tr>
			<tr>
				<td>Job Title:</td>
				<td><input type="text" name="jobtitle"></td>
			</tr>
			<tr>
				<td>Gioi Thieu:</td>
				<td><textarea name="gioi-thieu"></textarea></td>
			</tr>
			<tr>
				<td>Zalo:</td>
				<td><input type="text" name="zalo"></td>
			</tr>
			<tr>
				<td>WhatsApp:</td>
				<td><input type="text" name="whatsapp"></td>
			</tr>
			<tr>
				<td>Telegram:</td>
				<td><input type="text" name="telegram"></td>
			</tr>
			<tr>
				<td>Giao dien:</td>
				<td>
					<label><input type="radio" name="giao-dien" value="1"> 1</label>
					<label><input type="radio" name="giao-dien" value="2"> 2</label>
				</td>
			</tr>
			<tr>
				<td>Website:</td>
				<td><input type="text" name="website"></td>
			</tr>
			<tr>
				<td>Gallery:</td>
				<td><?php wp_nonce_field(plugin_basename(__FILE__), 'gallery_nonce'); ?><input type="file" name="gallery[]" multiple></td>
			</tr>
			<tr>
				<td>Facebook:</td>
				<td><input type="text" name="facebook"></td>
			</tr>
			<tr>
				<td>Shopee:</td>
				<td><input type="text" name="shopee"></td>
			</tr>
			<tr>
				<td>Youtube:</td>
				<td><input type="text" name="youtube"></td>
			</tr>
			<tr>
				<td>Discord:</td>
				<td><input type="text" name="discord"></td>
			</tr>
			<tr>
				<td>Bank1:</td>
				<td><input type="text" name="bank1"></td>
			</tr>
			<tr>
				<td>Bankacc1:</td>
				<td><input type="text" name="bankacc1"></td>
			</tr>
			<tr>
				<td>Bank QR Code 1:</td>
				<td><?php wp_nonce_field(plugin_basename(__FILE__), 'bankqr1_nonce'); ?><input type="file" name="bank-qr-1"></td>
			</tr>
			<tr>
				<td>Video 1:</td>
				<td><input type="text" name="video1"></td>
			</tr>
			<tr>
				<td>Video 2:</td>
				<td><input type="text" name="video2"></td>
			</tr>
			<tr>
				<td>Video 3:</td>
				<td><input type="text" name="video3"></td>
			</tr>
			<tr>
				<td>Demo Status:</td>
				<td>
					<label><input type="checkbox" name="demo-status[]" value="activate"> Activate</label>
					<label><input type="checkbox" name="demo-status[]" value="deactivate"> Deactivate</label>
				</td>
			</tr>
			<tr>
				<td>Referral Email:</td>
				<td><input type="text" name="referral-email"></td>
			</tr>
			<tr>
				<td>Language:</td>
				<td>
					<label><input type="radio" name="language" value="Vietnamese"> Vietnamese</label>
					<label><input type="radio" name="language" value="English"> English</label>
				</td>
			</tr>
			<tr>
				<td>Hotline:</td>
				<td>
					<label><input type="radio" name="hotline" value="0965784668"> 0965784668</label>
					<label><input type="radio" name="hotline" value="0343824688"> 0343824688</label>
				</td>
			</tr>
			<tr>
				<td colspan="2"><input type="submit" name="update_post" value="Update Post"></td>
			</tr>
		</table>
	</form>
	<?php
	return ob_get_clean();
}
add_shortcode('manualupdatemyproid_form', 'manualupdatemyproid_shortcode');

function manualupdatemyproid_update_post() {
	
	global $wpdb;
	
	if (isset($_POST['update_post'])) {
		$urls = explode("\n", sanitize_textarea_field($_POST['urls']));
		$name = sanitize_text_field($_POST['name']);
		$avatar1 = isset($_FILES['avatar1']) ? $_FILES['avatar1'] : null;
		$cover_image = isset($_FILES['cover-image']) ? $_FILES['cover-image'] : null;
		$phone = sanitize_text_field($_POST['phone']);
		$email = sanitize_email($_POST['email']);
		$color = sanitize_hex_color($_POST['color']);
		$address = sanitize_text_field($_POST['address']);
		$organization = sanitize_text_field($_POST['organization']);
		$logocongty = isset($_FILES['logocongty']) ? $_FILES['logocongty'] : null;
		$jobtitle = sanitize_text_field($_POST['jobtitle']);
		$gioi_thieu = sanitize_textarea_field($_POST['gioi-thieu']);
		$zalo = sanitize_text_field($_POST['zalo']);
		$whatsapp = sanitize_text_field($_POST['whatsapp']);
		$telegram = sanitize_text_field($_POST['telegram']);
		$demo_status = $_POST['demo-status'];
		$referral_email = sanitize_email($_POST['referral-email']);
		$language = sanitize_text_field($_POST['language']);
		$hotline = sanitize_text_field($_POST['hotline']);

		foreach ($urls as $url) {
			$post_id = url_to_postid($url);

			$post_id = (int) $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='" . esc_url( $url ) . "'" );

			if ( $post_id ) {
				
				require_once( ABSPATH . 'wp-admin/includes/image.php' );
		require_once( ABSPATH . 'wp-admin/includes/file.php' );
		require_once( ABSPATH . 'wp-admin/includes/media.php' );

		if ( ! is_null( $avatar1 ) ) {
			$file_id = media_handle_upload( 'avatar1', 0 );

			if( ! is_wp_error( $file_id ) ) {
				$avatar = array(
					'id'  => $file_id,
					'url' => wp_get_attachment_image_url( $file_id, 'full' ),
				);
						
						update_post_meta($post_id, 'avatar1', $avatar);
			}
		}

		if ( ! is_null( $cover_image ) ) {
			$file_id = media_handle_upload( 'cover-image', 0 );

			if( ! is_wp_error( $file_id ) ) {
				$file = array(
					'id'  => $file_id,
					'url' => wp_get_attachment_image_url( $file_id, 'full' )
				);
						
						update_post_meta($post_id, 'cover-image', $file);
			}
		}

		if ( ! is_null( $logocongty ) ) {
			$file_id = media_handle_upload( 'logocongty', 0 );

			if( ! is_wp_error( $file_id ) ) {
				$file = array(
					'id'  => $file_id,
					'url' => wp_get_attachment_image_url( $file_id, 'full' )
				);
						
						update_post_meta($post_id, 'logocongty', $file);
			}
		}

		if ( isset( $_FILES['gallery'] ) && ! empty( $_FILES['gallery'] ) ) {
			$original_files = $_FILES['gallery'];

			$files = $_FILES["gallery"];

			$gallery_files = array();
			$index = 0;
			foreach ($files['name'] as $key => $value) {
				if ($files['name'][$key]) {
					$file = array(
		                'name' => $files['name'][$key],
		                'type' => $files['type'][$key],
		                'tmp_name' => $files['tmp_name'][$key],
		                'error' => $files['error'][$key],
		                'size' => $files['size'][$key]
		            );

		            $_FILES = array("upload_file" => $file);

		            $file_id = media_handle_upload( 'upload_file', 0 );
		            if ( ! is_wp_error( $file_id ) ) {
			            $gallery_files[ 'item-' . $index ] = array(
			            	'id' => $file_id,
			            	'url' => wp_get_attachment_image_url( $file_id )
			            );
		            	$index++;
		            } 
				}
			}

			if ( ! empty( $gallery_files ) ) {
				update_post_meta( $post_id, 'gallery', $gallery_files );
			}
		}

				if ( ! empty( $phone ) ) {
					update_post_meta( $post_id, 'phone', $phone );
				}
				
				if ( ! empty( $name ) ) {
					update_post_meta( $post_id, 'name', $name );
				}
				
				if ( ! empty( $email ) ) {
					update_post_meta( $post_id, 'email', $email );
				}
				
				if ( ! empty( $color ) ) {
					update_post_meta( $post_id, 'color', $color );
				}
				
				if ( ! empty( $address ) ) {
					update_post_meta( $post_id, 'address', $address );
				}
				
				if ( ! empty( $organization ) ) {
					update_post_meta( $post_id, 'organization', $organization );
				}
				
				if ( ! empty( $jobtitle ) ) {
					update_post_meta( $post_id, 'jobtitle', $jobtitle );
				}
				
				if ( ! empty( $gioi_thieu ) ) {
					update_post_meta( $post_id, 'gioi-thieu', $gioi_thieu );
				}
				
				if ( ! empty( $zalo ) ) {
					update_post_meta( $post_id, 'zalo', $zalo );
				}
				
				if ( ! empty( $whatsapp ) ) {
					update_post_meta( $post_id, 'whatsapp', $whatsapp );
				}
				
				if ( ! empty( $telegram ) ) {
					update_post_meta( $post_id, 'telegram', $telegram );
				}
				
				if ( ! empty( $demo_status ) ) {

					if ( is_array( $demo_status ) ) {
						if ( in_array( 'activate', $demo_status ) ) {
							update_post_meta($post_id, 'demo-status', array( 'activate' => 'true', 'deactivate' => 'false' ) );
						} else {
							update_post_meta($post_id, 'demo-status', array( 'activate' => 'false', 'deactivate' => 'true' ) );
						}
					}

					update_post_meta( $post_id, 'demo status', $demo_status );
				}
				
				if ( ! empty( $referral_email ) ) {
					update_post_meta( $post_id, 'referral-email', $referral_email );
				}
				
				if ( ! empty( $language ) ) {
					update_post_meta( $post_id, 'language', strtolower( $language) );
				}
				
				if ( ! empty( $hotline ) ) {
					update_post_meta( $post_id, 'hotline', $hotline );
				}
			}
		}
	}
}
add_action('init', 'manualupdatemyproid_update_post');




function export_userdata_shortcode() {
    ob_start();
    ?>
    <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
        <input type="hidden" name="action" value="export_user_data">
        <input type="submit" name="submit" value="Xuất dữ liệu thẻ">
    </form>
    <?php
    return ob_get_clean();
}
add_shortcode( 'export_userdata', 'export_userdata_shortcode' );


function export_user_data() {
    if ( ! is_user_logged_in() ) {
        wp_die( 'Access denied.' );
    }
    
    $user_id = get_current_user_id();
    $filename = 'userdata_' . $user_id . '.csv';
    header( 'Content-Type: text/csv' );
    header( 'Content-Disposition: attachment; filename=' . $filename );
    $output = fopen( 'php://output', 'w' );
    
    $args = array(
        'post_type' => 'my-pro-id',
        'post_status' => 'publish',
        'author' => $user_id,
        'posts_per_page' => -1,
    );
    $query = new WP_Query( $args );
    
    $meta_keys = array();
    $rows = array();
    
    while ( $query->have_posts() ) {
        $query->the_post();
        $meta = get_post_meta( get_the_ID() );
        foreach ( $meta as $key => $value ) {
            if ( ! in_array( $key, $meta_keys ) ) {
                $meta_keys[] = $key;
            }
        }
        $row = array( get_the_title() );
        foreach ( $meta_keys as $key ) {
            $row[] = isset( $meta[ $key ][0] ) ? $meta[ $key ][0] : '';
        }
        $rows[] = $row;
    }
    
    fputcsv( $output, array_merge( array( 'Title' ), $meta_keys ) );
    foreach ( $rows as $row ) {
        fputcsv( $output, $row );
    }
    
    fclose( $output );
    wp_reset_postdata();
    exit;
}
add_action( 'admin_post_export_user_data', 'export_user_data' );



function login_notification( $user_login, $user ) {
    $user_roles = $user->roles;
    if ( in_array( 'administrator', $user_roles ) ) {
        wp_mail( 'daominhhai129@gmail.com', 'Login Notification', 'Someone with administrator role just logged in to your WordPress site.' );
    }
}
add_action( 'wp_login', 'login_notification', 10, 2 );


function export_permalinks_shortcode() {
    $user_id = get_current_user_id();
    $args = array(
        'post_type' => 'my-pro-id',
        'post_status' => 'publish',
        'author' => $user_id,
        'numberposts' => -1,
    );
    $posts = get_posts($args);
    $permalink_list = '';
    foreach ($posts as $post) {
        $permalink_list .= get_permalink($post->ID) . "\n";
    }
    $file_path = WP_CONTENT_DIR . '/uploads/permalink_list.txt';
    file_put_contents($file_path, $permalink_list);
    $button_html = '<a href="' . site_url() . '/wp-content/uploads/permalink_list.txt" download class="export-permalinks-btn">Xuất links</a>';
    return $button_html;
}
add_shortcode('export_permalinks', 'export_permalinks_shortcode');


function export_names_shortcode() {
    $user_id = get_current_user_id();
    $args = array(
        'post_type' => 'my-pro-id',
        'post_status' => 'publish',
        'author' => $user_id,
        'numberposts' => -1,
    );
    $posts = get_posts($args);
    $name_list = '';
    foreach ($posts as $post) {
        $name_list .= get_post_meta($post->ID, 'name', true) . "\n";
    }
    $file_path = WP_CONTENT_DIR . '/uploads/name_list.txt';
    file_put_contents($file_path, $name_list);
    $button_html = '<a href="' . site_url() . '/wp-content/uploads/name_list.txt" download class="export-names-btn">Xuất tên</a>';
    return $button_html;
}
add_shortcode('export_names', 'export_names_shortcode');


function export_permalinks_with_name_shortcode() {
    $user_id = get_current_user_id();
    $args = array(
        'post_type' => 'my-pro-id',
        'post_status' => 'publish',
        'author' => $user_id,
        'numberposts' => -1,
        'meta_query' => array(
            array(
                'key' => 'name',
                'value' => '',
                'compare' => '!=',
            ),
        ),
    );
    $posts = get_posts($args);
    $permalink_list = '';
    foreach ($posts as $post) {
        $permalink_list .= get_permalink($post->ID) . "\n";
    }
    $file_path = WP_CONTENT_DIR . '/uploads/permalink_list_with_name.txt';
    file_put_contents($file_path, $permalink_list);
    $button_html = '<a href="' . site_url() . '/wp-content/uploads/permalink_list_with_name.txt" download class="export-permalinks-with-name-btn">Xuất links nếu có tên</a>';
    return $button_html;
}
add_shortcode('export_permalinks_with_name', 'export_permalinks_with_name_shortcode');


//Copy Zalo Button
function copy_zalo_phone_shortcode() {
    ob_start();
    global $post;
    $zaloFix2 = get_post_meta($post->ID, 'zalo-fix-2', true);
    ?>
    <button class="copy-zalo-phone-button" onclick="copyZaloPhone(this)"
            data-zalo-fix-2="<?php echo esc_attr($zaloFix2); ?>">
        COPY SỐ ĐIỆN THOẠI ZALO
    </button>

    <script>
    function copyZaloPhone(button) {
        var zaloPhone = '';
        var metaKey = 'zalo-fix-2';
        var metaValue = button.getAttribute('data-' + metaKey);
        if (metaValue) {
            zaloPhone += metaValue;
        }

        // Create a temporary textarea to hold the zalo phone number
        var tempTextArea = document.createElement('textarea');
        tempTextArea.style.position = 'absolute';
        tempTextArea.style.left = '-9999px';
        tempTextArea.value = zaloPhone;
        document.body.appendChild(tempTextArea);
        tempTextArea.select();
        document.execCommand('copy');
        document.body.removeChild(tempTextArea);

        // Optionally provide a visual feedback to the user
        button.textContent = 'Đã sao chép!';
        setTimeout(function() {
            button.textContent = 'COPY SỐ ĐIỆN THOẠI ZALO';
        }, 3000);
    }
    </script>
    <?php
    return ob_get_clean();
}
add_shortcode('copy_zalo_phone', 'copy_zalo_phone_shortcode');


// Disable WordPress Administration Email verification Screen 
add_filter( 'admin_email_check_interval', '__return_false' );


/**
 * BC:
 * In v2.7.0 the theme removed the `hello_elementor_body_open()` from `header.php` replacing it with `wp_body_open()`.
 * The following code prevents fatal errors in child themes that still use this function.
 */
if ( ! function_exists( 'hello_elementor_body_open' ) ) {
	function hello_elementor_body_open() {
		wp_body_open();
	}
}


//update bulk my pro ids

add_action("jet-form-builder/custom-action/update_all_proids_bulk", function ($request) {
    $user_id = get_current_user_id();
    $args = array(
        'post_type' => 'my-pro-id',
        'posts_per_page' => -1,
        'author' => $user_id
    );
    $query = new WP_Query($args);
   $valsneedtoupdate = array(
    'language' => $request['ngon_ngu'],
    'giao-dien' => $request['giao_dien'],
    'tab-options' => $request['tab-options'],
    'organization' => $request['_organization'],
    'website' => $request['_website'],
    'company_logo' => $request['company_logo'],
    'avatar1' => $request['avatar1'],
    'cover-image' => $request['_cover_image'],
    'content' => $request['_content'],
    'address' => $request['address'],
    'address_text' => $request['address_text'],
    'gioi_thieu' => $request['gioi_thieu'],
    'album_anh' => $request['album_anh'],
    'color' => $request['_color'],
    'facebook' => $request['facebook'],
    'instagram' => $request['instagram'],
    'youtube' => $request['youtube'],
    'tiktok1' => $request['tiktok1'],
    'shopee' => $request['shopee'],
	'whatsapp' => $request['whatsapp'],
    'linkedin' => $request['linkedin'],
    'video1' => $request['video1'],
    'video2' => $request['video2'],
    'video3' => $request['video3']
   );
    while ($query->have_posts()) {
        $query->the_post();
        $post_id = get_the_ID();
        foreach ($valsneedtoupdate as $key => $value) {
            update_post_meta($post_id, $key, $value);
        }
    }
    
    foreach ($valsneedtoupdate as $key => $value) {
        update_user_meta($user_id, $key, $value);
    }

    wp_reset_postdata();



    return true;
}, 10, 1);

Current_dir [ WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
19 Mar 2026 3.30 AM
bqrcodec / bqrcodec
0755
assets
--
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0755
includes
--
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0755
template-parts
--
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0755
classic-editor.css
0.743 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
classic-editor.min.css
0.377 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
comments.php
1.597 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
customizer.css
0.978 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
customizer.min.css
0.798 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
editor.css
0.548 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
editor.min.css
0.455 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
footer.php
0.643 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
functions.php
28.646 KB
12 Mar 2024 12.55 PM
bqrcodec / bqrcodec
0644
header.php
1.37 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
index.php
0.977 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
readme.txt
13.098 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
screenshot.png
108.219 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
sidebar.php
0.265 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
style.css
12.067 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
style.min.css
5.61 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
theme.css
15.001 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644
theme.min.css
11.997 KB
29 Jan 2024 10.33 AM
bqrcodec / bqrcodec
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF