admin section general setting and pege post restrict to access

0
233

function karishmagautam_customize_register( $wp_customize ) {
$wp_customize->get_setting( ‘blogname’ )->transport         = ‘postMessage’;
$wp_customize->get_setting( ‘blogdescription’ )->transport  = ‘postMessage’;
$wp_customize->get_setting( ‘header_textcolor’ )->transport = ‘postMessage’;
}
add_action( ‘customize_register’, ‘karishmagautam_customize_register’ );

function register_fields()
{
register_setting(‘general’, ‘hmetatitle’, ‘esc_attr’);
add_settings_field(‘hmetatitle’, ‘<label for=”hmetatitle”>’.__(‘Meta Title’ , ‘hmetatitle’ ).'</label>’ , ‘print_hmetatitle’, ‘general’);

register_setting(‘general’, ‘hkeyword’, ‘esc_attr’);
add_settings_field(‘hkeyword’, ‘<label for=”hkeyword”>’.__(‘Meta Keyword’ , ‘hkeyword’ ).'</label>’ , ‘print_hkeyword’, ‘general’);

register_setting(‘general’, ‘hdescription’, ‘esc_attr’);
add_settings_field(‘blogdesc’, ‘<label for=”hdescription”>’.__(‘Meta Description’ , ‘hdescription’ ).'</label>’ , ‘print_hdescription’, ‘general’);

}

function print_hmetatitle()
{
$value = get_option( ‘hmetatitle’, ” );
echo ‘<input type=”text” id=”hmetatitle” class=”regular-text code” name=”hmetatitle” value=”‘ . $value . ‘” />’;
}
function print_hkeyword()
{
$value = get_option( ‘hmetatitle’, ” );
echo ‘<input type=”text” id=”hkeyword” class=”regular-text code” name=”hkeyword” value=”‘ . $value . ‘” />’;
}
function print_hdescription()
{
$value = get_option( ‘hdescription’, ” );
echo ‘<input type=”text” id=”hdescription” class=”regular-text code” name=”hdescription” value=”‘ . $value . ‘” />’;
}

add_filter(‘admin_init’, ‘register_fields’);

/**
* Enqueue Javascript postMessage handlers for the Customizer.
*
* Binds JavaScript handlers to make the Customizer preview
* reload changes asynchronously.
*
* @since Twenty Thirteen 1.0
*/
function karishmagautam_customize_preview_js() {
wp_enqueue_script( ‘karishmagautam-customizer’, get_template_directory_uri() . ‘/js/theme-customizer.js’, array( ‘customize-preview’ ), ‘20141120’, true );
}
add_action( ‘customize_preview_init’, ‘karishmagautam_customize_preview_js’ );

function str_stop($string, $max_length)
{
$string = strip_tags($string);
if (strlen($string) > $max_length){
$string = substr($string, 0, $max_length);
$pos = strrpos($string, ” “);
if($pos === false) {
return substr($string, 0, $max_length).”..”;
}
return substr($string, 0, $pos).”..”;
}else{
return $string;
}
}

function restrict_post_deletion($post_ID){
$user = get_current_user_id();
$restricted_users = array(1);
$restricted_pages = array(2,8,10,12,14,22,24,38,161);
if(in_array($user, $restricted_users) && in_array($post_ID, $restricted_pages)){
echo “You are not authorized to delete this page. Go Back &raquo; <a href=”.$_SERVER[‘HTTP_REFERER’].”>Click Here</a>”;
exit;
}
}
add_action(‘trash_post’, ‘restrict_post_deletion’, 10, 1);
add_action(‘delete_post’, ‘restrict_post_deletion’, 10, 1);
add_action(‘wp_trash_post’, ‘restrict_post_deletion’, 10, 1);
add_action(‘before_delete_post’, ‘restrict_post_deletion’, 10, 1);

/*add_action(‘wp_trash_post’, ‘prevent_post_deletion’);
function prevent_post_deletion($postid){
$protected_post_id = 12;
if ($postid == $protected_post_id) {
exit(‘The page you were trying to delete is protected.’);
}
}*/

add_filter(‘gettext’, ‘translate_text’);
function translate_text($translated) {
$translated = str_ireplace(‘Soliloquy’, ‘Top Slider’, $translated);
return $translated;
}

add_filter(‘gettext’, ‘translate_text2’);
function translate_text2($translated2) {
$translated2 = str_ireplace(‘Slideshow’, ‘banners’, $translated2);
return $translated2;
}