funcion.php adsense100

โพสโดย : admin | วันที่ : 8 March 2012 |
หมวดหมู่ : หมวดหมู่1

<?php
require_once dirname( __FILE__ ) . ‘/includes/thaitheme-core/framework.php’;
require_once dirname( __FILE__ ) . ‘/includes/thaitheme-config/thaitheme-config.php’;
require_once dirname( __FILE__ ) . ‘/includes/thaitheme-core/inc/thaitheme-resizer.php’;
require_once dirname( __FILE__ ) . ‘/includes/thaitheme-widgets/thaitheme_widget_cat_list.php’;
//require_once dirname( __FILE__ ) . ‘/includes/related-posts-thumbnails.php’;

remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
add_filter( ‘wp_default_scripts’, ‘remove_jquery_migrate’ );
function remove_jquery_migrate($scripts){
if(is_home()){
$scripts->remove( ‘jquery’);
}
}

add_action ( ‘wp_footer’, ‘my_js_variables’ );
function my_js_variables(){ ?>
<script type=”text/javascript”>
/* <![CDATA[ */
var thaitheme_Js = {“thaitheme_Url”:<?php echo json_encode( get_stylesheet_directory_uri() ); ?>};
/* ]]> */
</script><?php
}

function insert_fb_in_head() {
global $post;
if ( !is_singular())
return;
if(!has_post_thumbnail( $post->ID )) {
$default_image=”http://9carthai.com/wp-content/themes/arras-e/thaitheme_wp/images/no-image.jpg”;
echo ‘<meta property=”og:image” content=”‘ . $default_image . ‘”/>’;
}
else{
$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘full’ );
echo ‘<meta property=”og:image” content=”‘ . esc_attr( $thumbnail_src[0] ) . ‘”>’;
echo ‘<meta property=”og:image:secure_url” content=”‘ . esc_attr( $thumbnail_src[0] ) . ‘” />’;
echo ‘<meta property=”og:image:type” content=”image/jpeg” />’;
echo ‘<meta property=”og:image:width” content=”400″ />’;
echo ‘<meta property=”og:image:height” content=”300″ />’;
}
echo ”
“;
}

add_action( ‘wp_head’, ‘insert_fb_in_head’, 5 );

function title_short($after = ”, $length) {
$mytitle = get_the_title();
if ( strlen($mytitle) > $length ) {
mb_internal_encoding(“utf8″);
$mytitle = mb_substr($mytitle,0,$length);
echo $mytitle . $after;
} else {
echo $mytitle;
}
}
function string_limit_words($string, $word_limit)
{
$words = explode(‘ ‘, $string, ($word_limit + 1));
if(count($words) > $word_limit)
array_pop($words);
return implode(‘ ‘, $words);
}
function excerpt($limit) {
$excerpt = explode(‘ ‘, get_the_excerpt(), $limit);
if (count($excerpt)>=$limit) {
array_pop($excerpt);
$excerpt = implode(” “,$excerpt).’…’;
} else {
$excerpt = implode(” “,$excerpt);
}
$excerpt = preg_replace(‘`\[[^\]]*\]`’,”,$excerpt);
return $excerpt;
}
function content($limit) {
$content = explode(‘ ‘, get_the_content(), $limit);
if (count($content)>=$limit) {
array_pop($content);
$content = implode(” “,$content).’…’;
} else {
$content = implode(” “,$content);
}
$content = preg_replace(‘/\[.+\]/’,”, $content);
$content = apply_filters(‘the_content’, $content);
$content = str_replace(‘]]>’, ‘]]&gt;’, $content);
return $content;
}

if ( function_exists( ‘add_theme_support’ ) ) { // Added in 2.9
add_theme_support( ‘post-thumbnails’ );
add_image_size( ‘property_poster’, 100, 80, true );
}

if ( !function_exists( ‘thaitheme__style2_pagination’ ) ) {
function thaitheme__style2_pagination($pages = ”, $range = 3)
{
$showitems = ($range * 2)+1;

global $paged;

if(empty($paged)) $paged = 1;

if($pages == ”)
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo “<div class=\”tt_pag_nav\”><span class=\”count_page\”>หน้า “.$paged.” ทั้งหมด “.$pages.” หน้า</span>”;

if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo “<a target=’_blank’ href='”.get_pagenum_link(1).”‘>หน้าแรก</a>”;

if($paged > 1 && $showitems < $pages) echo “<a target=’_blank’ href='”.get_pagenum_link($paged – 1).”‘> กลับ</a>”;
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? “<span class=\”current\”>”.$i.”</span>”:”<a target=’_blank’ href='”.get_pagenum_link($i).”‘ class=\”inactive\”>”.$i.”</a>”;
}
}
if ($paged < $pages && $showitems < $pages) echo “<a target=’_blank’ href=\””.get_pagenum_link($paged + 1).”\”>ถัดไป </a>”;

if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo “<a target=’_blank’ href='”.get_pagenum_link($pages).”‘>หน้าสุดท้าย</a>”;

echo “</div>\n”;
}
}
}

if ( !function_exists( ‘thaitheme_pagination’ ) ) {

function thaitheme_pagination() {

$prev_arrow = is_rtl() ? ‘ย้อนกลับ;’ : ‘ย้อนกลับ’;
$next_arrow = is_rtl() ? ‘ถัดไป’ : ‘ถัดไป’;

global $wp_query;
$total = $wp_query->max_num_pages;
$big = 999999999; // need an unlikely integer
if( $total > 1 ) {
if( !$current_page = get_query_var(‘paged’) )
$current_page = 1;
if( get_option(‘permalink_structure’) ) {
$format = ‘page/%#%/’;
} else {
$format = ‘&paged=%#%’;
}
echo paginate_links(array(
‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ),
‘format’ => $format,
‘current’ => max( 1, get_query_var(‘paged’) ),
‘total’ => $total,
‘mid_size’ => 3,
‘type’ => ‘list’,
‘prev_text’ => $prev_arrow,
‘next_text’ => $next_arrow,
) );
}
}

}

add_action( ‘widgets_init’, ‘thaitheme_widgets_init’ );
function thaitheme_widgets_init() {
register_sidebar(array(
‘name’ => ‘Sidebar’,
‘id’ => ‘widget-home’,
‘before_widget’ => ‘<aside class=”thaitheme_widget”>’,
‘after_widget’ => ‘</aside>’,
‘before_title’ => ‘<h2 class=”title”>’,
‘after_title’ => ‘</h2>’,
));
// register_sidebar(array(
// ‘name’ => ‘Sidebar หน้าบทความ’,
// ‘id’ => ‘widget-page’,
// ‘before_widget’ => ‘<aside class=”thaitheme_widget”>’,
// ‘after_widget’ => ‘</aside>’,
// ‘before_title’ => ‘<h2 class=”title”>’,
// ‘after_title’ => ‘</h2>’,
// ));
// register_sidebar(array(
// ‘name’ => ‘Sidebar หน้าหมวดหมู่’,
// ‘id’ => ‘widget-cat’,
// ‘before_widget’ => ‘<aside class=”thaitheme_widget”>’,
// ‘after_widget’ => ‘</aside>’,
// ‘before_title’ => ‘<h2 class=”title”>’,
// ‘after_title’ => ‘</h2>’,
// ));
}

function the_breadcrumb() {
echo ‘ ‘;
if (!is_front_page()) {
echo ‘<a class=”tt_bc_home” href=”‘;
echo get_option(‘home’);
echo ‘”> <i class=”fa fa-home”></i> หน้าหลัก’;
echo “</a><span> »</span> “;
if (is_category() || is_single()) {
the_category(‘ ‘);
if (is_single()) {
echo “<span> » </span>”;
the_title();
}
} elseif (is_page()) {
echo the_title();
}
}
else {
echo ‘Home’;
}
}
function add_menu_arrows($menu) {
$c=0;
$pos = strpos($menu,”</i>”);
while($pos !== false) {
$pos_next_a = strpos($menu,”</i>”,$pos + 1);
$pos_next_ul = strpos($menu,”<ul”,$pos + 1);
if($pos_next_a > $pos_next_ul && $pos_next_ul > 0) {
$insert_end = $pos + strlen(“<span>”);
$insert_start = strrpos($menu,”<i”,$insert_end-strlen($menu));
$insert_start = strpos($menu,”>”,$insert_start) + strlen(“>”);
$start = substr($menu,0,$insert_start);
$end = substr($menu,$insert_start);
$menu = $start.”<span>”.$end;
$start = substr($menu,0,$insert_end);
$end = substr($menu,$insert_end);
$menu = $start.”</span>”.$end;
$pos = $pos + strlen(“<span></span>”);
}
$pos = strpos($menu,”</i>”,$pos + 1);
}
return $menu;
}
function remove_objects($content)
{
$content = preg_replace(‘/\<div(.*?)\>(.*?)\<\/div\>/s’, ”, $content);
$content = preg_replace(‘/\<object(.*?)\>(.*?)\<\/object\>/s’, ”, $content);
return $content;
}

//add icon for menu have submenu
class thaitheme_Walker_nav_menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat(“\t”, $depth);
$output .= “\n$indent<i class=\”fa fa-angle-down\”></i><div class=\”shows_btn\”><i class=\”fa fa-angle-down\”></i></div><ul class=\”sub-menu\”>\n”;
}
}

function register_my_menus() {
if ( function_exists( ‘register_nav_menus’ ) ) {
register_nav_menus(
array( ‘menu_top’ => __( ‘Menu Top’ ))
);

}
}
add_action( ‘init’, ‘register_my_menus’ );
function thaitheme_postimage($width,$height) {
$scriptpath = get_bloginfo(‘template_directory’);
$attachments = get_children(array(‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’));
$img = array_shift($attachments);
$imagelink = wp_get_attachment_image_src(get_post_thumbnail_id(), ‘full’);
$thumb = $imagelink[0];
$image = aq_resize( $thumb, $width, $height, true );
global $thaitheme_option;
$thumb_df = $thaitheme_option[‘thaitheme_uppic_default’][‘url’];
if($image==”) {
$image_df = aq_resize( $thumb_df, $width, $height, true );
echo ‘<img width=”‘.$width.'” height=”‘.$height.'” src=”‘.$image_df.’?v=1.0″ alt=””>’;
}else {
echo ‘<img src=”‘.$image.’?v=1.0″ width=”‘.$width.'” height=”‘.$height.'” alt=””>’;
}
}

add_action(‘admin_menu’, ‘remove_menus’, 102);
function remove_menus()
{
global $submenu;
remove_submenu_page ( ‘themes.php’, ‘theme-editor.php’ );
}

function colabs_list_comments($comment, $args, $depth) {
$GLOBALS[‘comment’] = $comment;
$GLOBALS[‘comment_depth’] = $depth;
?>

<li <?php comment_class(); ?>>
<div id=”comment-<?php comment_ID(); ?>” class=”comment-entry”>
<?php if ( $comment->comment_approved == ‘0’ ) : ?>
<em class=”comment-awaiting-moderation”><?php _e( ‘Your comment is awaiting moderation.’, ‘colabsthemes’ ); ?></em>
<?php endif; ?>

<div class=”comment-avatar”>
<?php commenter_link() ?>
</div>

<div class=”comment-content”>
<div class=”comment-meta”>
<span class=”comment-author”><?php echo get_comment_author_link(); ?></span>
<time><i class=”fa fa-calendar”></i> &nbsp;<?php printf( __( ‘%1$s’, ‘colabsthemes’ ), get_comment_date() ) ?> &nbsp;&nbsp;&nbsp;&nbsp;<i class=”fa fa-clock-o”></i>&nbsp;<?php comment_time(‘H:i’); ?></time>
</div>
<div class=”comment-text entry-content”>
<?php comment_text(); ?>
</div>
<?php
comment_reply_link(
array_merge(
$args,
array(
‘reply_text’ => __( ‘ตอบ’, ‘colabsthemes’ ),
‘depth’ => $depth,
‘max_depth’ => $args[‘max_depth’]
)
)
);
?>
</div>
</div>

<?php }
function commenter_link() {
$commenter = get_comment_author_link();
if ( ereg( ‘<a[^>]* class=[^>]+>’, $commenter ) ) {
$commenter = ereg_replace( ‘(<a[^>]* class=[\'”]?)’, ‘\\1url ‘ , $commenter );
} else {
$commenter = ereg_replace( ‘(<a )/’, ‘\\1class=”url “‘ , $commenter );
}
$avatar_email = get_comment_author_email();
$avatar = str_replace( “class=’avatar”, “class=’photo avatar”, get_avatar( $avatar_email, 64 ) );
echo $avatar;
} // end commenter_link
function custom_pings($comment, $args, $depth) {
$GLOBALS[‘comment’] = $comment;
?>
<li id=”comment-<?php comment_ID() ?>” <?php comment_class() ?>>
<div class=”comment-author”><?php printf(__(‘By %1$s on %2$s at %3$s’, ‘colabsthemes’),
get_comment_author_link(),
get_comment_date(),
get_comment_time() );
edit_comment_link(__(‘Edit’, ‘colabsthemes’), ‘ <span class=”meta-sep”>|</span> <span class=”edit-link”>’, ‘</span>’); ?></div>
<?php if ($comment->comment_approved == ‘0’) _e(‘\t\t\t\t\t<span class=”unapproved”>Your trackback is awaiting moderation.</span>\n’, ‘colabsthemes’) ?>
<div class=”comment-content”>
<?php comment_text() ?>
</div>
<?php } // end custom_pings

function colabs_list_comments_front($comment, $args, $depth) {
$GLOBALS[‘comment’] = $comment;
$GLOBALS[‘comment_depth’] = $depth;
?>

<li <?php comment_class(); ?>>
<div id=”comment-<?php comment_ID(); ?>” class=”comment-entry”>
<?php if ( $comment->comment_approved == ‘0’ ) : ?>
<em class=”comment-awaiting-moderation”><?php _e( ‘Your comment is awaiting moderation.’, ‘colabsthemes’ ); ?></em>
<?php endif; ?>

<div class=”comment-author”>
<?php commenter_link() ?>
</div>

<div class=”comment-content”>
<p>
<span class=”author-name”><?php echo get_comment_author_link(); ?></span>
<span class=”comment-meta”><?php printf( __( ‘%1$s’, ‘colabsthemes’ ), get_comment_date() ) ?></span>
</p>

<?php comment_text(); ?>
</div>
<?php echo colabs_get_comment_reply_link( array_merge( $args, array(
‘reply_text’ => __( ‘ตอบ’, ‘colabsthemes’ ),
‘depth’ => $depth,
‘max_depth’ => $args[‘max_depth’]
) ) ); ?><br />
</div>

<?php }
function colabs_get_comment_reply_link($args = array(), $comment = null, $post = null) {
global $user_ID;

$defaults = array(‘add_below’ => ‘comment’, ‘respond_id’ => ‘respond’, ‘reply_text’ => __(‘ตอบ’,’colabsthemes’),
‘login_text’ => __(‘เข้าสู่ระบบเพื่อ ตอบ’,’colabsthemes’), ‘depth’ => 0, ‘before’ => ”, ‘after’ => ”);

$args = wp_parse_args($args, $defaults);

if ( 0 == $args[‘depth’] || $args[‘max_depth’] <= $args[‘depth’] )
return;

extract($args, EXTR_SKIP);

$comment = get_comment($comment);
if ( empty($post) )
$post = $comment->comment_post_ID;
$post = get_post($post);

if ( !comments_open($post->ID) )
return false;

$link = ”;

if ( get_option(‘comment_registration’) && !$user_ID )
$link = ‘<a rel=”nofollow” class=”comment-reply-login” href=”‘ . esc_url( wp_login_url( get_permalink() ) ) . ‘”>’ . $login_text . ‘</a>’;
else
$link = “<a class=’comment-reply-link’ href='”. get_permalink($post->ID).”?replytocom”.$comment->comment_ID . “#” . $respond_id . “‘ onclick=’return addComment.moveForm(\”$add_below-$comment->comment_ID\”, \”$comment->comment_ID\”, \”$respond_id\”, \”$post->ID\”)’>$reply_text</a>”;
return apply_filters(‘comment_reply_link’, $before . $link . $after, $args, $comment, $post);
}
function remove_recent_comments_style() {
global $wp_widget_factory;
remove_action( ‘wp_head’, array( $wp_widget_factory->widgets[‘WP_Widget_Recent_Comments’], ‘recent_comments_style’ ) );
}
add_action( ‘widgets_init’, ‘remove_recent_comments_style’ );

function adsense_post2() {
return ‘<iframe width=”560″ height=”315″ src=”https://www.youtube.com/embed/FAnOkWliLpY” frameborder=”0″ allow=”accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture” allowfullscreen></iframe>

<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– CONDONAYOO LAST POST 300X250 –>
<ins class=”adsbygoogle”
style=”display:inline-block;width:300px;height:250px”
data-ad-client=”ca-pub-2344260622254998″
data-ad-slot=”3058065659″></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– CONDONAYOO LAST POST 300X250 –>
<ins class=”adsbygoogle”
style=”display:inline-block;width:300px;height:250px”
data-ad-client=”ca-pub-2344260622254998″
data-ad-slot=”3058065659″></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>’;
}
add_shortcode( ‘adsense100’, ‘adsense_post2’ );

function adsense300_post() {
return ‘<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– CONDONAYOO LAST POST 300X250 –>
<ins class=”adsbygoogle”
style=”display:inline-block;width:300px;height:250px”
data-ad-client=”ca-pub-2344260622254998″
data-ad-slot=”3058065659″></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– CONDONAYOO LAST POST 300X250 –>
<ins class=”adsbygoogle”
style=”display:inline-block;width:300px;height:250px”
data-ad-client=”ca-pub-2344260622254998″
data-ad-slot=”3058065659″></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>’;
}
add_shortcode( ‘adsense300’, ‘adsense300_post’ );