Sindbad~EG File Manager

Current Path : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/panel/metabox/
Upload File :
Current File : /var/www/html/wordpress_alg24news/wp-content/themes/newsbt-mobile/panel/metabox/page.php

<?php
/*
 * Security 	: blocking direct access
 * Source		: http://codex.wordpress.org/Theme_Development#Template_Files
*/
defined('ABSPATH') or die("Access Restricted");

$meta_box_page = array(
	'id' => 'mwp-meta-box-page',
	'title' => __( 'NewsBT - Metabox', MWP_TEXT_DOMAIN ),
	'page' => 'page',
	'context' => 'normal',
	'priority' => 'high',
	'fields' => array(
		array(
			'name' => __( 'Enable Ajax in Custom Archive template', MWP_TEXT_DOMAIN ),
			'desc' => '',
			'id' => 'archive_ajax_enable',
			'type' => 'checkbox',
			'std' => ''
		),
		array(
			'name' => __( 'Custom Archive template type Post per page', MWP_TEXT_DOMAIN ),
			'desc' => __( 'default is 10 post per page', MWP_TEXT_DOMAIN ),
			'id' => 'archive_post_per_page',
			'type' => 'text',
			'std' => '10'
		),
		array(
			'name' => __( 'SEO Title', MWP_TEXT_DOMAIN ),
			'desc' => __( 'A custom title that shows up in the title tag for this page.', MWP_TEXT_DOMAIN ),
			'id' => 'seo_page_title',
			'type' => 'text',
			'std' => ''
		),
		array(
			'name' => __( 'SEO description', MWP_TEXT_DOMAIN ),
			'desc' => __( 'The META description for this page. This will override any autogenerated descriptions', MWP_TEXT_DOMAIN ),
			'id' => 'seo_page_desc',
			'type' => 'textarea',
			'std' => ''
		),
		array(
			'name' => __( 'SEO Keywords', MWP_TEXT_DOMAIN ),
			'desc' => __( '(comma separated) comma separated list of your most important keywords for this page that will be written as META keywords', MWP_TEXT_DOMAIN ),
			'id' => 'seo_page_keywords',
			'type' => 'text',
			'std' => ''
		)
	)
);

add_action('admin_menu', 'mwp_add_box_page');

// Add meta box
function mwp_add_box_page() {
	global $meta_box_page;
	
	add_meta_box($meta_box_page['id'], $meta_box_page['title'], 'mwp_show_box_page', $meta_box_page['page'], $meta_box_page['context'], $meta_box_page['priority']);
}

// Callback function to show fields in meta box
function mwp_show_box_page() {
	global $meta_box_page, $post;
	
	// Use nonce for verification
	echo '<input type="hidden" name="mwp_meta_box_nonce_page" value="', wp_create_nonce(basename(__FILE__)), '" />';
	echo '<style type="text/css" >
	table.metabox span {font-size:13px;}
	table.metabox td input{margin-bottom:5px;}
	</style>';
	echo '<table class="form-table metabox">';

	foreach ($meta_box_page['fields'] as $field) {
		// get current post meta data

		$meta = get_post_meta($post->ID, $field['id'], true);
		echo '<tr>',
				'<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
				'<td>';
		switch ($field['type']) {
			case 'text':
				echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:50%" />',
					'<br /><span>', $field['desc'].'</span>';
				break;
			case 'textarea':
				echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>',
					'<br />', $field['desc'];
				break;
			case 'select':
				echo '<select name="', $field['id'], '" id="', $field['id'], '">';
				foreach ($field['options'] as $option) {
					echo '<option', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';
				}
				echo '</select>';
				break;
			case 'radio':
				foreach ($field['options'] as $option) {
					echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
				}
				break;
			case 'checkbox':
				echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
				break;
		}
		echo 	'<td>',
			'</tr>';
	}
	
	echo '</table>';
}

add_action('save_post', 'mwp_save_data_page');

// Save data from meta box
function mwp_save_data_page($post_id) {
	global $meta_box_page;
	
	// verify nonce
	if ( !isset($_POST['mwp_meta_box_nonce_page']) || !wp_verify_nonce( $_POST['mwp_meta_box_nonce_page'], basename(__FILE__) )) {
		return $post_id;
	}

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

	// check permissions
	if ('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;
	}
	
	foreach ($meta_box_page['fields'] as $field) {
		$old = get_post_meta($post_id, $field['id'], true);
		//$new = $_POST[$field['id']];
		$new = ( isset ( $_POST[$field['id']] ) === true ? $_POST[$field['id']] : '' );
		
		if ($new && $new != $old) {
			update_post_meta($post_id, $field['id'], $new);
		} elseif ('' == $new && $old) {
			delete_post_meta($post_id, $field['id'], $old);
		}
	}
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists