Created
June 17, 2016 02:54
-
-
Save gmmedia/f30c052636475bb4f30eb049c186ec78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 1. --> Wordpress Settings // | |
// 2. --> SHORTCODES // | |
// 3. --> Plugin Settings // | |
// 4. --> Theme Settings // | |
// 1. --> Wordpress Settings // | |
// Remove junk from head | |
remove_action('wp_head', 'rsd_link'); | |
remove_action('wp_head', 'wp_generator'); | |
remove_action('wp_head', 'feed_links', 2); | |
remove_action('wp_head', 'feed_links_extra', 3); | |
remove_action('wp_head', 'index_rel_link'); | |
remove_action('wp_head', 'wlwmanifest_link'); | |
remove_action('wp_head', 'wp_shortlink_wp_head'); | |
remove_action('template_redirect', 'wp_shortlink_header', 11); | |
remove_action('wp_head', 'start_post_rel_link', 10, 0); | |
remove_action('wp_head', 'parent_post_rel_link', 10, 0); | |
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); | |
// Disable_emojis | |
function disable_emojis() { | |
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' ); | |
remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); | |
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); | |
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); | |
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); | |
} | |
add_action( 'init', 'disable_emojis' ); | |
function disable_emojis_tinymce( $plugins ) { | |
if ( is_array( $plugins ) ) { | |
return array_diff( $plugins, array( 'wpemoji' ) ); | |
} else { | |
return array(); | |
} | |
} | |
// Disable self ping | |
function disable_self_trackback( &$links ) { | |
foreach ( $links as $l => $link ) | |
if ( 0 === strpos( $link, get_option( 'home' ) ) ) | |
unset($links[$l]); | |
} | |
add_action( 'pre_ping', 'disable_self_trackback' ); | |
// Last-modified header output | |
add_action('template_redirect', 'add_last_modified_header'); | |
function add_last_modified_header($headers) | |
{ | |
header("Last-Modified: " . get_the_modified_time("D, d M Y H:i:s")); | |
} | |
// Login Logo | |
function j0e_loginlogo() { | |
echo '<style type="text/css"> | |
h1 a { | |
background-image: url(https://j0e.org/wp-content/uploads/2014/09/logo.png) !important; | |
width: 213px !important; | |
height: 97px !important; | |
background-size: 213px 97px!important; | |
} | |
</style>'; | |
} | |
add_action('login_head', 'j0e_loginlogo'); | |
// Article last modified | |
function j0e_change_date($content) { | |
if ( is_single() && get_post_type() == 'post' ) { | |
$artikel_erstellt = get_the_date('U'); | |
$artikel_aktualisiert = get_post_modified_time('U'); | |
// Nur ausgeben, wenn Aktualisierung älter als einen Tag ist | |
if (($artikel_aktualisiert - $artikel_erstellt ) > 86400) | |
{ | |
$content = '<p><em>Artikel wurde aktualisiert am ' . get_the_modified_date('d.m.Y') . '</em></p>' . $content; | |
} | |
} | |
return $content; | |
} | |
add_filter('the_content', 'j0e_change_date'); | |
// Add featured image to RSS feed | |
function j0e_imagetoRSS($content) { | |
global $post; | |
if ( has_post_thumbnail( $post->ID ) ){ | |
$content = ' | |
<p>' . get_the_post_thumbnail( $post->ID, 'full', array( 'style' => 'max-width: 100%; height: auto; margin-bottom: 10px;' ) ) . '</p> | |
' . $content; | |
} | |
return $content; | |
} | |
add_filter('the_excerpt_rss', 'j0e_imagetoRSS'); | |
add_filter('the_content_feed', 'j0e_imagetoRSS'); | |
// Add more buttons to the html editor | |
function j0e_add_quicktags() { | |
if (wp_script_is('quicktags')){ | |
?> | |
<script type="text/javascript"> | |
var j0e_toc = '<div id="j0e_toc">\r\n'; | |
j0e_toc += '<span>Inhaltsverzeichnis</span>\r\n'; | |
j0e_toc += '<ul>\r\n'; | |
j0e_toc += ' <li></li>\r\n'; | |
j0e_toc += ' <li></li>\r\n'; | |
j0e_toc += '</ul>\r\n'; | |
j0e_toc += '</div>\r\n'; | |
QTags.addButton( 'eg_h2', 'h2', '<h2>', '</h2>', 'h2', 'Header 2', 1); | |
QTags.addButton( 'eg_h3', 'h3', '<h3>', '</h3>', 'h3', 'Header 3', 2); | |
QTags.addButton( 'eg_Adsense', 'Adsense', '[adinserter block="1"]', '', 'sam', 'Adsense', 201 ); | |
QTags.addButton( 'eg_Adsense336', 'Adsense336', '[adinserter block="2"]', '', 'sam336', 'Adsense336', 202 ); | |
QTags.addButton( 'eg_Rabatt', 'Rabatt', '<div class="rabatt"> Rabatt Code: <div class="rabatt-code">DER-RABATT-CODE</div></div>', '', 'rabatt', 'Rabatt Code', 203 ); | |
QTags.addButton( 'eg_Rating', 'Rating', '[produkttest title="" rating="5"]', '', 'rating', 'Rating', 204 ); | |
QTags.addButton( 'eg_box', 'Box', '<div class="j0e_box">', '</div>', 'box', 'Box', 206 ); | |
QTags.addButton( 'eg_TOC', 'TOC', j0e_toc, '', 'toc', 'TOC', 207 ); | |
QTags.addButton( 'eg_Button', 'Button', '<p style="text-align:center"><a class="et_pb_button" href="https://j0e.org/tipp/Divi" rel="nofollow" target="_blank">', '</a></p>', 'button', 'Button', 208 ); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'admin_print_footer_scripts', 'j0e_add_quicktags' ); | |
// 1. --> Wordpress Settings End // | |
// 2. --> SHORTCODES // | |
// Blog Statistic Shortcode | |
function j0e_stats(){ | |
$num_users = count_users(); | |
$num_users = $num_users['total_users']; | |
$num_tags = wp_count_terms('post_tag'); | |
$num_pages = wp_count_posts( 'page' ); | |
$num_pages = $num_pages->publish; | |
$num_posts = wp_count_posts( 'post' ); | |
$num_posts = $num_posts->publish; | |
$num_cats = wp_count_terms('category'); | |
$num_comm = get_comment_count(); | |
$num_comm = $num_comm['approved']; | |
$str = '<ul>'; | |
$str .= '<li>Benutzer: ' . $num_users . '</li>'; | |
$str .= '<li>Tags: ' . $num_tags . '</li>'; | |
$str .= '<li>Seiten: ' . $num_pages . '</li>'; | |
$str .= '<li>Beiträge: ' . $num_posts . '</li>'; | |
$str .= '<li>Kategorien: ' . $num_cats . '</li>'; | |
$str .= '<li>Kommentare: ' . $num_comm . '</li>'; | |
$str .= '</ul>'; | |
return $str; | |
} | |
add_shortcode( 'mystats', 'j0e_stats' ); | |
// Produkt Review Shortcode | |
function j0e_produkttest( $atts ){ | |
extract( shortcode_atts( array( | |
'title' => get_the_title(), | |
'rating' => '5', | |
), $atts ) ); | |
if (!$title) { | |
$title = get_the_title(); | |
} | |
$str = '<div class="produkttest" itemscope itemtype="http://schema.org/Review">'; | |
$str = $str . '<span itemprop="itemReviewed" itemscope itemtype="http://schema.org/Thing">'; | |
$str = $str . '<span itemprop="name"><strong>'.$title.'</strong></span>'; | |
$str = $str . '</span> wurde von '; | |
$str = $str . '<span itemprop="author" itemscope itemtype="http://schema.org/Person">'; | |
$str = $str . '<span itemprop="name">'.get_the_author().'</span>'; | |
$str = $str . '</span> am'; | |
$str = $str . '<meta itemprop="datePublished" content="'.get_the_date('Y-m-d').'"> '.get_the_date('d.m.Y').' getestet.<br />'; | |
$str = $str . '<span itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating">'; | |
$str = $str . 'Bewertung: <span itemprop="ratingValue">'.$rating.'</span>'; | |
$str = $str . '</span> von 5 Sternen'; | |
$str = $str . '</div>'; | |
return $str; | |
} | |
add_shortcode( 'produkttest', 'j0e_produkttest' ); | |
// App 360 Grad Animation Shortcode | |
function j0e_grad360( $atts ){ | |
extract( shortcode_atts( array( | |
'image' => 'https://j0e.org/files/2014/05/img-01.jpg', | |
'images' => 'https://j0e.org/files/2014/05/img-##.jpg', | |
'clockwise' => 'true', | |
'speed' => '0.1', | |
'von' => '1', | |
'bis' => '28', | |
'responsive' => 'true', | |
), $atts ) ); | |
$str = '<script src="http://code.vostrel.cz/jquery.reel-bundle.js"></script>'; | |
$str = $str . '<img src="'.$image.'" width="710" height="472"'; | |
$str = $str . 'data-images="'.$images.'|'.$von.'..'.$bis.'"'; | |
$str = $str . 'class="reel"'; | |
$str = $str . 'id="image"'; | |
$str = $str . 'data-cw="'.$clockwise.'"'; | |
$str = $str . 'data-speed="'.$speed.'"'; | |
$str = $str . 'data-responsive="'.$responsive.'">'; | |
return $str; | |
} | |
add_shortcode( 'grad360', 'j0e_grad360' ); | |
// --> SHORTCODES End | |
// 3. --> Plugin Settings // | |
// Jetpack Twitter Card Anpassung | |
function tweakjp_custom_twitter_site( $og_tags ) { | |
$og_tags['twitter:site'] = '@j0e_org'; | |
$og_tags['twitter:card'] = 'summary_large_image'; | |
return $og_tags; | |
} | |
add_filter( 'jetpack_open_graph_tags', 'tweakjp_custom_twitter_site', 11 ); | |
// Facebook author- & publisher Open Graph-tags | |
if ( ! function_exists('additional_opengraph_tags') ) { | |
function additional_opengraph_tags() { | |
if ( is_single() and ! is_page()) { | |
?> | |
<meta property="article:publisher" content="https://www.facebook.com/j0e.org" /> | |
<meta property="article:author" content="https://www.facebook.com/jochen.gererstorfer" /> | |
<?php | |
} | |
} | |
add_action('wp_head', 'additional_opengraph_tags'); | |
} | |
// Override Jetpack's default OpenGraph image. | |
add_filter( 'jetpack_open_graph_image_default', function() { | |
return 'https://j0e.org/wp-content/uploads/2016/04/j0e-org.jpg'; | |
}); | |
// 3. --> Plugin Settings End // | |
// 4. --> Theme Settings // | |
// Divi Add tags to blogposts | |
add_filter( 'the_content', 'j0e_divi_add_tags', 1 ); | |
function j0e_divi_add_tags( $content ) { | |
if ( is_single() ) { | |
$mytags=""; | |
$posttags = get_the_tags(); | |
if ($posttags) { | |
foreach($posttags as $tag) { | |
$mytags.= '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name . '</a> '; | |
} | |
} | |
$content = sprintf( | |
'%s <div id="mytag">Tags: %s</div>', | |
$content, | |
$mytags | |
); | |
} | |
return $content; | |
} | |
// Divi Remove the "project" custom post type in Divi | |
if ( ! function_exists( 'et_pb_register_posttypes' ) ) : | |
function et_pb_register_posttypes() { | |
global $wp_post_types; | |
if ( isset( $wp_post_types[ $post_type ] ) ) { | |
unset( $wp_post_types[ $post_type ] ); | |
return true; | |
} | |
return false; | |
} | |
endif; | |
// Divi Remove Google Fonts | |
function j0e_dequeue_google_fonts() { | |
wp_dequeue_style( 'divi-fonts' ); | |
} | |
add_action( 'wp_enqueue_scripts', 'j0e_dequeue_google_fonts', 20 ); | |
// add .et_pb_lightbox_image clss to content images | |
add_filter('the_content', 'divi_add_lightbox'); | |
function divi_add_lightbox($content) { | |
global $post; | |
$pattern ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i"; | |
$replacement = '<a$1href=$2$3.$4$5 class="et_pb_lightbox_image" title="'.$post->post_title.'"$6>'; | |
$content = preg_replace($pattern, $replacement, $content); | |
return $content; | |
} | |
// 4. --> Theme Settings End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello
The remove Project CPT function conflicts with Divi 3.11.x. You should be aware of using it
Brst regards
Ciro