HEX
Server: Apache
System: Linux c119.dattaweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: c1190199 (57165)
PHP: 7.4.33
Disabled: mail, system, shell, exec, system_exec, shell_exec, mysql_pconnect, passthru, popen, proc_open, proc_close, proc_nice, proc_terminate, proc_get_status, escapeshellarg, escapeshellcmd, eval, dl, imap_mail, libvirt_connect, gnupg_init, unsetenv, apache_setenv, pcntl_exec, 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_getpriority, pcntl_setpriority, pcntl_async_signals, opcache_get_status, opcache_reset, opcache_get_configuration
Upload Files
File: /home/c1190199/public_html/wp-content/wptouch-data/extensions/mobile-content/mobile-content.php
<?php
define( 'MOBILE_CONTENT_VERSION', '1.0' );
add_action( 'add_meta_boxes', 'wptouch_addon_mobile_admin_init' );
add_action( 'save_post', 'wptouch_addon_save_mobile_content' );
add_action( 'the_posts', 'wptouch_addon_show_mobile_content', 1 );
add_filter( 'wptouch_addon_options', 'wptouch_addon_mobile_content_options' );
add_filter( 'wptouch_setting_defaults_addons', 'wptouch_addon_mobile_content_settings_defaults' );

function wptouch_addon_mobile_admin_init() {
	$settings = wptouch_get_settings( ADDON_SETTING_DOMAIN );
	if ( !$settings->enable_mobile_content ) {
		return;
	}

	$screens = array( 'post', 'page' );

	foreach( $screens as $screen ) {
		add_meta_box(
			'mobile-content-area',
			__( 'WPtouch Alternate Mobile Content', 'wptouch-pro' ),
			'wptouch_admin_render_meta_box',
			$screen,
			'normal',
			'high'
		);
	}
}

function wptouch_addon_mobile_content_settings_defaults( $settings ) {
	$settings->enable_mobile_content = true;

	return $settings;
}

function wptouch_addon_mobile_content_options( $page_options ) {
	wptouch_add_page_section(
		WPTOUCH_PRO_ADMIN_ADDON_OPTIONS,
		__( 'Mobile Content', 'wptouch-pro' ),
		'addons-mobile-content',
		array(
			wptouch_add_setting(
				'checkbox',
				'enable_mobile_content',
				__( 'Enable mobile content display', 'wptouch-pro' ),
				'',
				WPTOUCH_SETTING_BASIC,
				'3.1'
			)
		),
		$page_options,
		ADDON_SETTING_DOMAIN
	);

	return $page_options;
}

function wptouch_addon_get_mobile_content( $post_ID ) {
	$content = get_post_meta( $post_ID, '_wptouch_addon_mobile_content', true );

	return $content;
}

function wptouch_admin_render_meta_box( $post ) {
	wp_nonce_field( plugin_basename( __FILE__ ), 'wptouch_addon_mobile_nonce' );

	$content = wptouch_addon_get_mobile_content( $post->ID );
	wp_editor( $content, 'mobile-content-editor' );
}

function wptouch_addon_save_mobile_content( $post_id ) {
	// First we need to check if the current user is authorised to do this action.
	if ( isset($_POST['post_type']) && 'page' == $_REQUEST['post_type'] ) {
		if ( ! current_user_can( 'edit_page', $post_id ) ) {
			return;
		}
	} else {
		if ( ! current_user_can( 'edit_post', $post_id ) ) {
			return;
		}
	}

	// Secondly we need to check if the user intended to change this value.
	if ( ! isset( $_POST['wptouch_addon_mobile_nonce'] ) || ! wp_verify_nonce( $_POST['wptouch_addon_mobile_nonce'], plugin_basename( __FILE__ ) ) ) {
		return;
	}

	$post_ID = $_POST[ 'post_ID' ];
	$content = $_POST[ 'mobile-content-editor' ];

	delete_post_meta( $post_ID, '_wptouch_addon_mobile_content' );
	add_post_meta( $post_ID, '_wptouch_addon_mobile_content', $content, true );
}

function wptouch_addon_show_mobile_content( $posts ) {
	$settings = wptouch_get_settings( ADDON_SETTING_DOMAIN );
	if ( !$settings->enable_mobile_content ) {
		return $posts;
	}

	if ( !is_admin() && wptouch_is_mobile_theme_showing() ) {
		foreach ( $posts as $enumerator => $post ) {
			if ( $mobile_content = wptouch_addon_get_mobile_content( $post->ID ) ) {
				$posts[ $enumerator ]->post_content = $mobile_content;
			}
		}
	}

	return $posts;
}