@@ -690,24 +690,79 @@ function my_seo_plugin_head() {
690690*/
691691
692692 $ meta_description = get_post_meta ($ post ->ID , 'ez-meta-desc ' , true );
693- if (!empty ($ meta_description )) {
693+ if (!empty ($ meta_description ))
694694 echo '<meta name="description" content=" ' . esc_attr ($ meta_description ) . '"> ' ;
695- }
695+
696696
697697 $ meta_keywords = get_post_meta ($ post ->ID , 'ez-meta-keywords ' , true );
698- if (!empty ($ meta_keywords )) {
698+ if (!empty ($ meta_keywords ))
699699 echo '<meta name="keywords" content=" ' . esc_attr ($ meta_keywords ) . '"> ' ;
700- }
700+
701701
702702 $ meta_categories = get_post_meta ($ post ->ID , 'ez-meta-categories ' , true );
703- if (!empty ($ meta_categories )) {
703+ if (!empty ($ meta_categories ))
704704 echo '<meta name="categories" content=" ' . esc_attr ($ meta_categories ) . '"> ' ;
705- }
705+
706706
707707 $ meta_tags = get_post_meta ($ post ->ID , 'ez-meta-tags ' , true );
708- if (!empty ($ meta_tags )) {
708+ if (!empty ($ meta_tags ))
709709 echo '<meta name="tags" content=" ' . esc_attr ($ meta_tags ) . '"> ' ;
710+
711+ // handle social twitter/opengraph/facebook/whatever
712+ $ social_title = get_post_meta ($ post ->ID , 'ez-meta-title ' , true );
713+ $ social_desc = get_post_meta ($ post ->ID , 'ez-meta-desc ' , true );
714+
715+ if (!empty ($ social_title ))
716+ echo '<meta property="og:title" content=" ' . esc_attr ($ social_title ) . '"> ' ;
717+ else
718+ echo '<meta property="og:title" content=" ' . esc_attr ($ post ->post_title ) . '"> ' ;
719+
720+ if (!empty ($ social_desc ))
721+ echo '<meta property="og:description" content=" ' . esc_attr ($ social_desc ) . '"> ' ;
722+ else
723+ echo '<meta property="og:description" content=" ' . esc_attr ($ post ->post_excerpt ) . '"> ' ;
724+
725+ // handle twitter
726+ if (!empty ($ social_title ))
727+ echo '<meta name="twitter:title" content=" ' . esc_attr ($ social_title ) . '"> ' ;
728+ else
729+ echo '<meta name="twitter:title" content=" ' . esc_attr ($ post ->post_title ) . '"> ' ;
730+
731+ if (!empty ($ social_desc ))
732+ echo '<meta name="twitter:description" content=" ' . esc_attr ($ social_desc ) . '"> ' ;
733+ else
734+ echo '<meta name="twitter:description" content=" ' . esc_attr ($ post ->post_excerpt ) . '"> ' ;
735+
736+ /*
737+ // handle image (use wp. to get image)
738+
739+ if (!empty($social_image)) {
740+ echo '<meta property="og:image" content="' . esc_attr($social_image) . '">';
741+ echo '<meta name="twitter:image" content="' . esc_attr($social_image) . '">';
742+ }
743+
744+ // handle url
745+ $social_url = wp.get_permalink($post->ID);
746+ if (!empty($social_url)) {
747+ echo '<meta property="og:url" content="' . esc_attr($social_url) . '">';
748+ echo '<meta name="twitter:url" content="' . esc_attr($social_url) . '">';
749+ }
750+
751+ // handle site name
752+
753+ // $social_site_name = get_post_meta($post->ID, 'ez-meta-site-name', true);
754+ $social_site_name = get_bloginfo('name');
755+ if (!empty($social_site_name)) {
756+ echo '<meta property="og:site_name" content="' . esc_attr($social_site_name) . '">';
710757 }
758+
759+ // handle type
760+ $social_type = wp.get_post_type($post->ID);
761+ if (!empty($social_type)) {
762+ echo '<meta property="og:type" content="' . esc_attr($social_type) . '">';
763+ }
764+
765+ */
711766
712767
713768 }
0 commit comments