| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <?php
- ###################### Date Modified ######################
- function daw_post_columns_data( $column, $post_id ) {
- switch ( $column ) {
- case 'modified':
- $m_orig = get_post_field( 'post_modified', $post_id, 'raw' );
- $m_stamp = strtotime( $m_orig );
- $modified = date('Y/m/d', $m_stamp );
- $modr_id = get_post_meta( $post_id, '_edit_last', true );
- echo '<p class="mod-date">';
- echo '<em>'.$modified.'</em>';
- echo '</p>';
- break;
- }
- }
- add_action ( 'manage_posts_custom_column', 'daw_post_columns_data', 10, 2 );
- add_filter ( 'manage_edit-post_columns', 'daw_post_columns_display');
- function daw_post_columns_display( $columns ) {
- $columns['modified'] = 'Last Modified';
- return $columns;
- }
- function daw_last_modified_column_register_sortable( $columns ) {
- $columns['modified'] = 'post_modified';
- return $columns;
- }
- add_filter( "manage_edit-post_sortable_columns", "daw_last_modified_column_register_sortable" );
- add_filter( "manage_edit-page_sortable_columns", "daw_last_modified_column_register_sortable" );
-
- remove_action('wp_head', 'index_rel_link' );
- remove_action('wp_head', 'rel_canonical');
- remove_action('wp_head', 'start_post_rel_link', 10);
- remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10);
- remove_action('wp_head', 'wp_shortlink_wp_head', 10);
- remove_action('wp_head', 'parent_post_rel_link', 10);
- remove_action('wp_head', 'rsd_link');
- remove_action('wp_head', 'wlwmanifest_link');
- remove_action('wp_head', 'wp_generator');
- remove_action('wp_head', 'feed_links_extra', 3 );
- remove_action('wp_head', 'feed_links', 2 );
- remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
- remove_action('wp_head', 'wp_oembed_add_host_js', 10);
- function dw_remove_wp_ver_css_js( $src ) {
- if ( strpos( $src, 'ver=' ) )
- $src = remove_query_arg( 'ver', $src );
- return $src;
- }
- add_filter( 'style_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
- add_filter( 'script_loader_src', 'dw_remove_wp_ver_css_js', 9999 );
- add_filter( 'xmlrpc_enabled', '__return_false' );
- add_filter( 'wp_headers', 'disable_x_pingback' );
- function disable_x_pingback( $headers ) {
- unset( $headers['X-Pingback'] );
- return $headers;
- }
- function disable_emojis_tinymce( $plugins ) {
- if ( is_array( $plugins ) ) {
- return array_diff( $plugins, array( 'wpemoji' ) );
- } else {
- return array();
- }
- }
- 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_filter( 'emoji_svg_url', '__return_false' );
- }
- add_action( 'init', 'disable_emojis' );
- function custom_excerpt_length( $length ) {
- return 20;
- }
- add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
- add_filter('wp_mail_from', 'dw_fromemail');
- function dw_fromemail($email) {
- $wpfrom = get_option('admin_email');
- return $wpfrom;
- }
- add_filter('wp_mail_from_name', 'dw_fromname');
- function dw_fromname($email){
- $wpfrom = get_option('blogname');
- return $wpfrom;
- }
- add_filter( 'embed_oembed_html', 'dw_oembed_filter', 10, 4 ) ;
- function dw_oembed_filter($html, $url, $attr, $post_ID) {
- $return = '<div class="video-container">'.$html.'</div>';
- $return = str_replace('frameborder="0" allowfullscreen', 'style="border:none"', $return);
- return $return;
- }
- add_filter( 'embed_oembed_html', 'dw_embed_oembed_html' );
- function dw_embed_oembed_html( $html ) {
- return preg_replace( '@src="https?:@', 'src="', $html );
- }
- function dw_deliver_form_mail() {
- if ( isset( $_POST['dw-contact'] ) ) {
- $fname = sanitize_text_field( $_POST["dw-fname"] );
- $lname = sanitize_text_field( $_POST["dw-lname"] );
- $email = sanitize_email( $_POST["dw-email"] );
- $subject = sanitize_text_field( $_POST["dw-org"] );
- $message = esc_textarea( $_POST["dw-message"] );
- $to = get_option( 'admin_email' );
- $headers = "From: $fname $lname <$email>" . "\r\n";
- if ( wp_mail( $to, $subject, $message, $headers ) ) {
- echo '<div class="alert alert-success" role="alert">';
- echo '<p>Thank you. I will be in touch.</p>';
- echo '</div>';
- }
- else {
- echo '<div class="alert alert-danger" role="alert">';
- echo '<p>Error, please try again</p>';
- echo '</div>';
- }
- }
- }
- add_shortcode('dwsearch', 'get_search_form');
- function doctype_opengraph($output) {
- return $output . '
- xmlns:og="http://opengraphprotocol.org/schema/"
- xmlns:fb="http://www.facebook.com/2008/fbml"';
- }
- add_filter('language_attributes', 'doctype_opengraph');
- function dw_opengraph() {
- global $post;
- if (is_single()) {
- if (has_post_thumbnail($post->ID)) {
- $img_src = wp_get_attachment_image_src(get_post_thumbnail_id( $post->ID ), 'full'); $img_src = $img_src[0];
- } elseif ( metadata_exists( 'post', get_the_ID(), 'featured_image_url' ) ){
- $img_src = get_post_meta( get_the_ID(), 'featured_image_url', true );
- } else {
- $img_src = get_stylesheet_directory_uri() . '/img/opengraph_image.jpg';
- }
- if($excerpt = $post->post_excerpt) {
- $excerpt = strip_tags($post->post_excerpt);
- $excerpt = str_replace("", "'", $excerpt);
- } else {
- $excerpt = get_bloginfo('description');
- }
- ?>
- <meta property="og:title" content="<?php echo the_title(); ?>"/>
- <meta property="og:description" content="<?php echo $excerpt; ?>"/>
- <meta property="og:type" content="article"/>
- <meta property="og:url" content="<?php echo the_permalink(); ?>"/>
- <meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/>
- <meta property="og:image" content="<?php echo $img_src; ?>"/>
- <meta property="fb:app_id" content="203136806559589" />
- <meta name="twitter:site" content="@windhamdavid">
- <meta name="twitter:creator" content="@windhamdavid">
- <meta name="twitter:title" content="<?php echo the_title(); ?>">
- <meta name="twitter:description" content="<?php echo $excerpt; ?>">
- <meta name="twitter:image" content="<?php echo $img_src; ?>">
- <?php
- } else {
- return;
- }
- $content = do_shortcode( apply_filters( 'the_content', $post->post_content ) );
- $media_url = get_post_meta( get_the_ID(), 'media', true );
- $media = get_media_embedded_in_content( $content );
- if( !empty($media) ) {
- $video_url = $media[0];
- ?>
- <meta property="og:video" content="<?php echo $media_url; ?>" />
- <meta property="og:video:secure_url" content="<?php echo $media_url; ?>" />
- <meta property="og:video:width" content="1280" />
- <meta property="og:video:height" content="720" />
- <meta property="og:video:type" content="video/mp4" />
- <meta name="twitter:card" content="player">
- <meta name="twitter:player" content="<?php echo get_permalink();?>container/" />
- <meta name="twitter:player:width" content="1280" />
- <meta name="twitter:player:height" content="720" />
- <meta name="twitter:player:stream" content="<?php echo $media_url; ?>" />
- <meta name="twitter:player:stream:content_type" content="video/mp4" />
- <?php
- } else {
- ?>
- <meta name="twitter:card" content="summary_large_image">
- <?php
- }
- }
- add_action('wp_head', 'dw_opengraph', 5);
- function dw_read_container_endpoint(){
- add_rewrite_endpoint( 'container', EP_PERMALINK);
- }
- add_action( 'init', 'dw_read_container_endpoint' );
- function dw_read_container_template( $template = '' ) {
- global $wp_query;
- if( ! array_key_exists( 'container', $wp_query->query_vars ) ) return $template;
- $template = locate_template( 'single-container.php' );
- return $template;
- }
- add_filter( 'single_template', 'dw_read_container_template' );
- function dw_video_embed( $attr, $content='' ) {
- if ( ! isset( $attr['poster'] ) && has_post_thumbnail() ) {
- $poster = get_post_meta( get_the_ID(), 'media-poster', true );
- $attr['poster'] = $poster;
- }
- return wp_video_shortcode( $attr, $content );
- }
- add_shortcode( 'video', 'dw_video_embed' );
- ?>
|