HEX
Server: Apache/2.4.65 (Debian)
System: Linux web6 5.10.0-36-amd64 #1 SMP Debian 5.10.244-1 (2025-09-29) x86_64
User: innocamp (1028)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /home/buildff/public_html/wp-content/plugins/pixfort-core/functions/header.php
<?php
/**
 * pixheader custom meta fields.
 */

/* ---------------------------------------------------------------------------
 * Create new post type
 * --------------------------------------------------------------------------- */
function pix_pixheader_post_type(){
	//$pixheader_item_slug = pix_get_option( 'pixheader-slug', 'pixheader-item' );
	$pixheader_item_slug = "pixheader-item";

	$labels = array(
		'name' 					=> __('Headers','pixfort-core'),
		'singular_name' 		=> __('Header item','pixfort-core'),
		'add_new' 				=> __('Add New Header','pixfort-core'),
		'add_new_item' 			=> __('Add New Header item','pixfort-core'),
		'edit_item' 			=> __('Edit Header item','pixfort-core'),
		'new_item' 				=> __('New Header item','pixfort-core'),
		'view_item' 			=> __('View Header item','pixfort-core'),
		'search_items' 			=> __('Search Header items','pixfort-core'),
		'not_found' 			=> __('No Header items found','pixfort-core'),
		'not_found_in_trash' 	=> __('No Header items found in Trash','pixfort-core'),
		'parent_item_colon' 	=> ''
	  );

	$args = array(
		'labels' 				=> $labels,
		// 'menu_icon'				=> 'dashicons-images-alt2',
		'public' 				=> true,
		'menu_icon' 				=> PIX_CORE_PLUGIN_URI .'functions/images/admin/header-icon.svg',
		'publicly_queryable' 	=> true,
		// 'menu_position' 		=> 3,
		'show_ui' 				=> true,
		'query_var' 			=> true,
		'capability_type' 		=> 'post',
		'hierarchical' 			=> false,
		'menu_position' 		=> null,
		'exclude_from_search' 	=> true,
		'rewrite' 				=> array( 'slug' => $pixheader_item_slug, 'with_front' => true ),
		'supports' 				=> array( 'title', 'page-attributes', 'revisions' ),
		// 'supports' 				=> array( 'title', 'editor', 'author', 'page-attributes' ),
	);

	register_post_type( 'pixheader', $args );


}
add_action( 'init', 'pix_pixheader_post_type' );






function pix_header_meta_add(){
	global $pix_header_meta_box;

	// Layouts ----------------------------------
	$layouts = array( 0 => '-- Theme Options --' );

	// Custom menu ------------------------------
	$aMenus = array( 0 => '-- Default --' );
	$oMenus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );

	if( is_array($oMenus) ){
		foreach( $oMenus as $menu ){
			$aMenus[$menu->term_id] = $menu->name;
		}
	}

	$pix_header_meta_box = array(
		'id' 		=> 'pix-meta-page',
		'title' 	=> __('PixFort Header Options','pixfort-core'),
		'page' 		=> 'pixheader',
		'post_types'	=> array('pixheader'),
		'context' 	=> 'normal',
		'priority' 	=> 'high',
		'fields'	=> array(

		
			array(
				'id' 		=> 'pix-header-drag',
				'type' 		=> 'header_drag',
				'title' 	=> __('Header builder', 'pixfort-core'),
			),

			array(
				'id' 		=> 'pix-header-style',
				'type' 		=> 'select',
				'title' 	=> __('Header Style', 'pixfort-core'),
				'sub_desc' 	=> __('Select Desktop header style.', 'pixfort-core'),
				'options' 	=> array(
					''			=> "Default",
					'default-full'			=> "Default (Full width)",
					'transparent'			=> "Transparent",
					'transparent-full'			=> "Transparent (Full width)",
					'boxed'					=> "Boxed",
					'boxed-full'			=> "Boxed (Full width)"
				),
			),

			array(
				'id' 		=> 'pix-enable-sticky',
				'type' 		=> 'select',
				'title' 	=> __('Enable Desktop sticky header', 'pixfort-core'),
				'options' 	=> array(
					'enable'			=> "Yes",
					'disable'			=> "No",
				),
				'std'		=> 'enable'
			),
			array(
				'id' 		=> 'pix-enable-mobile-sticky',
				'type' 		=> 'select',
				'title' 	=> __('Enable Mobile sticky header', 'pixfort-core'),
				'options' 	=> array(
					'enable'			=> "Yes",
					'disable'			=> "No",
				),
				'std'		=> 'disable'
			),

			array(
				'id'		=> 'is_secondary_font',
				'type'		=> 'switch',
				'title'		=> __('Use secondary font', 'pixfort-core'),
				'options'	=> array('1' => 'Yes', '0' => 'No'),
				'std'		=> '0'
			),


		),
	);


	add_meta_box($pix_header_meta_box['id'], $pix_header_meta_box['title'], 'pix_header_show_box', $pix_header_meta_box['page'], $pix_header_meta_box['context'], $pix_header_meta_box['priority']);
}
 add_action('admin_menu', 'pix_header_meta_add');

 function pix_header_show_box() {
	global $pix_header_meta_box, $post;

	// Use nonce for verification
	echo '<div id="pix-wrapper">';
		echo '<input type="hidden" name="pix_page_meta_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';



		echo '<table class="form-table">';
			echo '<tbody>';
			$bg_colors_no_custom = array(
				__("Transparent", 'pixfort-core')			=> "transparent",
				__("Primary", 'pixfort-core')				=> "primary",
				__("Primary Light", 'pixfort-core')			=> "primary-light",
				__("Primary Gradient", 'pixfort-core')		=> "gradient-primary",
				__("Primary Gradient Light", 'pixfort-core')		=> "gradient-primary-light",
				__("Secondary", 'pixfort-core')				=> "secondary",
				__("Secondary Light", 'pixfort-core')		=> "secondary-light",
				__("White", 'pixfort-core')					=> "white",
				__("Black", 'pixfort-core')					=> "black",
				__("Green", 'pixfort-core')					=> "green",
				__("Green Light", 'pixfort-core')			=> "green-light",
				__("Blue", 'pixfort-core')					=> "blue",
				__("Blue Light", 'pixfort-core')			=> "blue-light",
				__("Red", 'pixfort-core')					=> "red",
				__("Red Light", 'pixfort-core')				=> "red-light",
				__("Yellow", 'pixfort-core')				=> "yellow",
				__("Yellow Light", 'pixfort-core')			=> "yellow-light",
				__("Brown", 'pixfort-core')					=> "brown",
				__("Brown Light", 'pixfort-core')			=> "brown-light",
				__("Purple", 'pixfort-core')				=> "purple",
				__("Purple Light", 'pixfort-core')			=> "purple-light",
				__("Orange", 'pixfort-core')				=> "orange",
				__("Orange Light", 'pixfort-core')			=> "orange-light",
				__("Cyan", 'pixfort-core')					=> "cyan",
				__("Cyan Light", 'pixfort-core')			=> "cyan-light",
				__("Gray 1", 'pixfort-core')				=> "gray-1",
				__("Gray 2", 'pixfort-core')				=> "gray-2",
				__("Gray 3", 'pixfort-core')				=> "gray-3",
				__("Gray 4", 'pixfort-core')				=> "gray-4",
				__("Gray 5", 'pixfort-core')				=> "gray-5",
				__("Gray 6", 'pixfort-core')				=> "gray-6",
				__("Gray 7", 'pixfort-core')				=> "gray-7",
				__("Gray 8", 'pixfort-core')				=> "gray-8",
				__("Gray 9", 'pixfort-core')				=> "gray-9",
				__("Dark opacity 1", 'pixfort-core')		=> "dark-opacity-1",
				__("Dark opacity 2", 'pixfort-core')		=> "dark-opacity-2",
				__("Dark opacity 3", 'pixfort-core')		=> "dark-opacity-3",
				__("Dark opacity 4", 'pixfort-core')		=> "dark-opacity-4",
				__("Dark opacity 5", 'pixfort-core')		=> "dark-opacity-5",
				__("Dark opacity 6", 'pixfort-core')		=> "dark-opacity-6",
				__("Dark opacity 7", 'pixfort-core')		=> "dark-opacity-7",
				__("Dark opacity 8", 'pixfort-core')		=> "dark-opacity-8",
				__("Dark opacity 9", 'pixfort-core')		=> "dark-opacity-9",
				__("Light opacity 1", 'pixfort-core')		=> "light-opacity-1",
				__("Light opacity 2", 'pixfort-core')		=> "light-opacity-2",
				__("Light opacity 3", 'pixfort-core')		=> "light-opacity-3",
				__("Light opacity 4", 'pixfort-core')		=> "light-opacity-4",
				__("Light opacity 5", 'pixfort-core')		=> "light-opacity-5",
				__("Light opacity 6", 'pixfort-core')		=> "light-opacity-6",
				__("Light opacity 7", 'pixfort-core')		=> "light-opacity-7",
				__("Light opacity 8", 'pixfort-core')		=> "light-opacity-8",
				__("Light opacity 9", 'pixfort-core')		=> "light-opacity-9"
			);

			if(!pix_plugin_get_option('pix-disable-beta-features', false)){
				$test = new PixfortOptions();
				$test->initOptions(
					'meta',
					$post
				);
				
				$test->addOption(
					'pix-header-drag', 
					[
						'type' => 'header-builder',
						'label' => 'Header builder',
					]
				);
				$test->addOption(
					'pix-header-style', 
					[
						'type' => 'select',
						'label' => 'Header Style',
						'description' => 'Select Desktop header style.',
						'options' => array(
							''			=> "Default",
							'default-full'			=> "Default (Full width)",
							'transparent'			=> "Transparent",
							'transparent-full'			=> "Transparent (Full width)",
							'boxed'					=> "Boxed",
							'boxed-full'			=> "Boxed (Full width)"
						)
					]
				);
				if (defined('PIX_DEV')) {
					$test->addOption(
						'pix-enable-sticky', 
						[
							'type' => 'select',
							'label' => 'Enable Desktop sticky header',
							'default' => 'enable',
							'options' => array(
								'enable'			=> "Yes",
								'smart'			=> "Yes (Smart Sticky)",
								'disable'			=> "No"
								
								
							)
						]
					);
					$test->addOption(
						'pix-enable-mobile-sticky', 
						[
							'type' => 'select',
							'label' => 'Enable Mobile sticky header',
							'default' => 'disable',
							'options' => array(
								'enable'			=> "Yes",
								'smart'			=> "Yes (Smart Sticky)",
								'disable'			=> "No"
							)
						]
					);
				}else{
					$test->addOption(
						'pix-enable-sticky', 
						[
							'type' => 'select',
							'label' => 'Enable Desktop sticky header',
							'default' => 'enable',
							'options' => array(
								'enable'			=> "Yes",
								'disable'			=> "No"
								
								
							)
						]
					);
					$test->addOption(
						'pix-enable-mobile-sticky', 
						[
							'type' => 'select',
							'label' => 'Enable Mobile sticky header',
							'default' => 'disable',
							'options' => array(
								'enable'			=> "Yes",
								'disable'			=> "No"
							)
						]
					);
				}
				
				$test->addOption(
					'is_secondary_font', 
					[
						'label'	=> __('Use secondary font', 'pixfort-core'),
						'type' => 'checkbox'
					]
				);

				$test->loadOptionsData();
				?>
				<div style="width:100%;text-align:center;" class="pixfort_headerbuilder_loading"><img src="<?php echo PIX_IMG_PLACEHOLDER; ?>" /></div>
				<?php
				
				} else {
					foreach ($pix_header_meta_box['fields'] as $field) {
						$meta = get_post_meta($post->ID, $field['id'], true);
						if( ! key_exists('std', $field) ) $field['std'] = false;
						$meta = ( $meta || $meta==='0' ) ? $meta : stripslashes(htmlspecialchars(($field['std']), ENT_QUOTES ));
	
						pix_meta_field_input( $field, $meta );
	
					}
				}	
				

				
        
				echo '<div id="pixfort_options_builder"></div>';
				// echo '<input type="text" name="pixfort-options" id="pixfort-options" class="large-text" value="" >';

			echo '</tbody>';
		echo '</table>';

	echo '</div>';
}

/*-----------------------------------------------------------------------------------*/
/*	Save data when page is edited
/*-----------------------------------------------------------------------------------*/
function pix_header_save_data($post_id) {
	global $pix_header_meta_box;

	// verify nonce
	if( key_exists( 'pix_page_meta_nonce',$_POST ) ) {
		if ( ! wp_verify_nonce( $_POST['pix_page_meta_nonce'], basename(__FILE__) ) ) {
			return $post_id;
		}
	}

	// check autosave
	if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
		return $post_id;
	}

	// check permissions
	if ( (key_exists('post_type', $_POST)) && ('page' == $_POST['post_type']) ) {
		if (!current_user_can('edit_page', $post_id)) {
			return $post_id;
		}
	} elseif (!current_user_can('edit_post', $post_id)) {
		return $post_id;
	}

	// if(function_exists('pix_update_menus')){
	// 	pix_update_menus();
	// }
	// $menus = get_transient( 'pixfort_cached_menus' );
    // if($menus){
    //     foreach( $menus as $menu ) {
    //         delete_transient( $menu );
    //     }
    // }

	// check and save fields ( $pix_header_meta_box['fields'] )
	if(!empty($pix_header_meta_box)){
		foreach ( (array)$pix_header_meta_box['fields'] as $field ) {
			$old = get_post_meta($post_id, $field['id'], true);
			if( key_exists($field['id'], $_POST) ) {
				$new = $_POST[$field['id']];
			} else {
	//			$new = ""; // problem with "quick edit"
				if($field['type']=='switch'){
					$new = '0';
				}else{
					continue;
				}
			}

			if ( isset($new) && $new != $old) {
				update_post_meta($post_id, $field['id'], $new);
			} elseif (isset($new) && '' == $new && $old) {
				delete_post_meta($post_id, $field['id'], $old);
			}
		}
	}


}
add_action('save_post', 'pix_header_save_data', 1, 2 );




// Revisions options
function pix_save_revisions( $post_id ) {

	// Check if it's a revision
	$parent_id = wp_is_post_revision( $post_id );

	// If is revision
	if ( $parent_id ) {
		if ( 'pixheader' === get_post_type( (int) $parent_id ) ) {
			global $pix_header_meta_box;
			// Get the saved data
			$parent = get_post( $parent_id );
			if(!empty($pix_header_meta_box)){
				foreach ( (array)$pix_header_meta_box['fields'] as $field ) {
					$details = get_post_meta( $parent->ID, $field['id'], true );
					// If data exists and is an array, add to revision
					if ( !empty( $details ) ) {
						add_metadata( 'post', $post_id, $field['id'], $details );
					}
				}
			}
			
		}

	}

}
add_action( 'save_post', 'pix_save_revisions' );



function pix_header_restore_revision( $post_id, $revision_id ) {
	if ( 'pixheader' === get_post_type( (int) $post_id ) ) {
		$post     = get_post( $post_id );
		$revision = get_post( $revision_id );
		global $pix_header_meta_box;
		if(!empty($pix_header_meta_box)){
			foreach ( (array)$pix_header_meta_box['fields'] as $field ) {
				$pix_meta_revision  = get_metadata( 'post', $revision->ID, $field['id'], true );
				if ( false !== $pix_meta_revision ){
					update_post_meta( $post_id, $field['id'], $pix_meta_revision );
				} else {
					delete_post_meta( $post_id, $field['id'] );
				}
			}
		}
	}
}
add_action( 'wp_restore_post_revision', 'pix_header_restore_revision', 10, 2 );


// function pix_header_revision_fields( $fields ) {

// 	$fields['pix-header-drag'] = __('Header builder', 'pix-opts');
// 	return $fields;

// }
// add_filter( '_wp_post_revision_fields', 'pix_header_revision_fields' );

// function pix_header_revision_field( $value, $field ) {

// 	global $revision;
// 	var_dump($field);
// 	var_dump(get_metadata( 'post', $revision->ID, $field, true ));
// 	return (string) get_metadata( 'post', $revision->ID, $field, true );

// }
// add_filter( '_wp_post_revision_field_pix-header-drag', 'pix_header_revision_field', 10, 2 );




// add_filter( '_wp_post_revision_fields', 'add_own_fields', 10, 2 );
// function add_my_own_fields( $fields, $post ) {
// 	if ( 'pixheader' === $post['post_type'] || 'revision' === $post['post_type'] && 'pixheader' === get_post_type( (int) $post['post_parent'] ) ) {
// 		$fields['pix-header-drag'] = __( 'Header Builder', 'pixfort-core' );
// 		$fields['pix-header-style'] = __( 'Select Desktop header style', 'pixfort-core' );
// 		$fields['pix-enable-sticky'] = __( 'Enable Desktop sticky header', 'pixfort-core' );
// 		$fields['pix-enable-mobile-sticky'] = __( 'Enable Mobile sticky header', 'pixfort-core' );
// 		$fields['is_secondary_font'] = __( 'Use secondary font', 'pixfort-core' );
// 	}
// }

// add_action( 'save_post_revision', function ( int $post_id, WP_Post $post ) {
//     if ( ! $post->post_parent || 'pixheader' !== get_post_type( $post->post_parent ) ) {
//         // The parent post is not of our "mycpt" type, exit
//         return;
//     }
//     // This is the original post
//     $parent = get_post( $post->post_parent );
//     // Run security and sanity checks here
//     // ...
	
//     // Save the data
//     // ...
// 	// check and save fields ( $pix_header_meta_box['fields'] )
// 	if(!empty($pix_header_meta_box)){
// 		foreach ( (array)$pix_header_meta_box['fields'] as $field ) {
// 			$old = get_post_meta($parent->ID, $field['id'], true);
// 			$new = get_post_meta($post_id, $field['id'], true);
// 			// if( key_exists($field['id'], $_POST) ) {
// 			// 	$new = $_POST[$field['id']];
// 			// } else {
// 			// 	if($field['type']=='switch'){
// 			// 		$new = '0';
// 			// 	}else{
// 			// 		continue;
// 			// 	}
// 			// }

// 			if ( isset($new) && $new != $old) {
// 				update_post_meta($post_id, $field['id'], $new);
// 			} elseif ('' == $new && $old) {
// 				delete_post_meta($post_id, $field['id'], $old);
// 			}
// 		}
// 	}


// }, 10, 2 );

// add_filter( 'wp_insert_post_data', function ( array $data ) {
//     if ( 'revision' === $data['post_type'] ) {
//         $parent = get_post( $data['post_parent'] );
//         if ( $parent && 'pixheader' === $parent->post_type ) {
//             // Get all the metadata - you need to implement this
//             $metadata                      = array(
// 				'pix-header-drag'	=> get_post_meta($parent->ID, 'pix-header-drag' , true)
// 			);
//             $data['post_content_filtered'] = wp_slash( (string) wp_json_encode( $metadata, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) );
//         }
//     }
//     return $data;
// } );

// add_action( 'wp_restore_post_revision', function ( int $post_id, int $revision_id ) {
//     $post     = get_post( $post_id );
//     $revision = get_post( $revision_id );
//     if ( $post && $revision && 'pixheader' === $post->post_type && $revision->post_content_filtered ) {
//         $meta = json_decode( $revision->post_content_filtered, true );
//         if ( is_array( $meta ) ) {
// 			if(!empty($meta['pix-header-drag'])){
// 				update_post_meta($post_id, 'pix-header-drag', $meta['pix-header-drag']);
// 			}
//         }
//     }
// }, 10, 2 );



add_filter( '_wp_post_revision_fields', function ( array $fields, array $post ) {
    if ( 'pixheader' === $post['post_type'] || 'revision' === $post['post_type'] && 'pixheader' === get_post_type( (int) $post['post_parent'] ) ) {
        global $pix_header_meta_box;
		if(!empty($pix_header_meta_box)){
			foreach ( (array)$pix_header_meta_box['fields'] as $field ) {
				$fields[$field['id']] = __( $field['title'], 'pixfort-core' );
			}
		}
		
        // $fields['post_content_filtered'] = __( 'Internal metadata', 'myplugin' );
    }
	// $fields['pix-header-drag'] = __( 'Header Builder', 'myplugin' );
    return $fields;
}, 10, 2 );
add_filter( '_wp_post_revision_field_pix-header-drag', 'myplugin_wp_post_revision_field_for_diff', 10, 3 );
add_filter( '_wp_post_revision_field_pix-header-style', 'myplugin_wp_post_revision_field_for_diff', 10, 3 );
add_filter( '_wp_post_revision_field_pix-enable-sticky', 'myplugin_wp_post_revision_field_for_diff', 10, 3 );
add_filter( '_wp_post_revision_field_pix-enable-mobile-sticky', 'myplugin_wp_post_revision_field_for_diff', 10, 3 );
add_filter( '_wp_post_revision_field_is_secondary_font', 'myplugin_wp_post_revision_field_for_diff', 10, 3 );
function myplugin_wp_post_revision_field_for_diff( $value, string $field, WP_Post $compare_from ): string {
    if ( ! empty( $compare_from->post_content_filtered ) ) {
		// var_dump($compare_from);
		global $revision;
		return (string) get_metadata( 'post', $revision->ID, $field, true );

        // $meta = json_decode( $compare_from->post_content_filtered, true );
        // if ( is_array( $meta ) ) {
        //     return (string) ( $meta[ $field ] ?? '' );
        // }
    }
    return (string) $value;
}



/*-----------------------------------------------------------------------------------*/
/*	Styles & scripts
/*-----------------------------------------------------------------------------------*/

function pix_edit_form_after_editor() {
	wp_enqueue_style( 'pix-meta', PIX_CORE_PLUGIN_URI. 'functions/css/pixbuilder.css', false, PLUGIN_VERSION, 'all');
	wp_enqueue_style( 'pix-header-builder', PIX_CORE_PLUGIN_URI. 'functions/css/pixHeaderBuilder.css', false, PLUGIN_VERSION, 'all');
	wp_enqueue_style( 'pix-header-confirm', PIX_CORE_PLUGIN_URI. 'functions/css/jquery-confirm.min.css', false, PLUGIN_VERSION, 'all');
    wp_enqueue_style( 'pix-meta2', PIX_CORE_PLUGIN_URI. 'functions/pixbuilder.css', false, PLUGIN_VERSION, 'all');

	wp_enqueue_style( 'wp-color-picker' );
	wp_enqueue_script( 'pix-admin-confirm', PIX_CORE_PLUGIN_URI . 'functions/js/jquery-confirm.min.js', array('jquery'), PLUGIN_VERSION, true );
	wp_enqueue_script( 'pix-admin-header', PIX_CORE_PLUGIN_URI . 'functions/js/pixHeaderBuilder.js', array('jquery','jquery-ui-droppable','jquery-ui-draggable', 'jquery-ui-sortable', 'wp-color-picker'), PLUGIN_VERSION, true );
	$icons = vc_iconpicker_type_pixicons( array() );
	wp_localize_script( 'pix-admin-header', 'plugin_header_object', array(
	    'PIX_CORE_PLUGIN_URI' => PIX_CORE_PLUGIN_URI,
	    'PIX_ICONS' => $icons,
	));
	
}
add_action('edit_form_after_editor', 'pix_edit_form_after_editor');

// Yoast SEO Plugin fix
function my_remove_wp_seo_meta_box() {
	remove_meta_box('wpseo_meta', 'pixheader', 'normal');
}
add_action('add_meta_boxes', 'my_remove_wp_seo_meta_box', 100);


?>