Changeset 518932
- Timestamp:
- 03/14/2012 02:50:07 PM (14 years ago)
- Location:
- network-publisher/trunk
- Files:
-
- 2 edited
-
networkpub.php (modified) (21 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
network-publisher/trunk/networkpub.php
r517263 r518932 4 4 Plugin URI: http://wordpress.org/extend/plugins/network-publisher/ 5 5 Description: Automatically publish your blog posts to multiple Social Networks including Twitter, Facebook Profile, Facebook Pages, LinkedIn, MySpace, Yammer, Yahoo, Identi.ca, and <a href="http://www.linksalpha.com/networks" target="_blank">more</a>. Click <a href="http://help.linksalpha.com/networks/getting-started">here</a> for instructions. Email us at post@linksalpha.com if you have any queries. 6 Version: 5.0 6 Version: 5.0.1 7 7 Author: LinksAlpha 8 8 Author URI: http://www.linksalpha.com … … 41 41 define('NETWORKPUB_SOCIAL_NETWORKS', __('Social Networks')); 42 42 define('NETWORKPUB_SOCIAL_NETWORK', __('Social Network')); 43 define('NETWORKPUB_PLUGIN_VERSION', '5.0 ');43 define('NETWORKPUB_PLUGIN_VERSION', '5.0.1'); 44 44 45 45 $networkpub_settings['api_key'] = array('label'=>'API Key:', 'type'=>'text', 'default'=>''); … … 110 110 $options['networkpub_metatags_facebook'] = 1; 111 111 } 112 if(!array_key_exists('networkpub_lang_facebook', $options)) { 113 $options['networkpub_lang_facebook'] = 'en_US'; 114 } 115 if(!array_key_exists('networkpub_facebook_page_type', $options)) { 116 $options['networkpub_facebook_page_type'] = 'article'; 117 } 118 if(!array_key_exists('networkpub_facebook_app_id', $options)) { 119 $options['networkpub_facebook_app_id'] = ''; 120 } 112 121 if(!array_key_exists('networkpub_metatags_googleplus', $options)) { 113 122 $options['networkpub_metatags_googleplus'] = 1; 123 } 124 if(!array_key_exists('networkpub_googleplus_page_type', $options)) { 125 $options['networkpub_googleplus_page_type'] = 'Article'; 126 } 127 if(!array_key_exists('networkpub_custom_field_image', $options)) { 128 $options['networkpub_custom_field_image'] = ''; 114 129 } 115 130 update_option(NETWORKPUB_WIDGET_NAME_INTERNAL, $options); … … 560 575 $networkpub_metatags_facebook = 0; 561 576 } 562 networkpub_update_option('networkpub_metatags_facebook', $networkpub_metatags_facebook); 577 if(array_key_exists('networkpub_lang_facebook', $_POST)) { 578 $networkpub_lang_facebook = $_POST['networkpub_lang_facebook']; 579 } else { 580 $networkpub_lang_facebook = 'en_US'; 581 } 582 if(array_key_exists('networkpub_facebook_page_type', $_POST)) { 583 $networkpub_facebook_page_type = $_POST['networkpub_facebook_page_type']; 584 } else { 585 $networkpub_facebook_page_type = 'article'; 586 } 587 if(array_key_exists('networkpub_facebook_app_id', $_POST)) { 588 $networkpub_facebook_app_id = $_POST['networkpub_facebook_app_id']; 589 } else { 590 $networkpub_facebook_app_id = ''; 591 } 592 networkpub_update_option('networkpub_metatags_facebook', $networkpub_metatags_facebook); 593 networkpub_update_option('networkpub_lang_facebook', $networkpub_lang_facebook); 594 networkpub_update_option('networkpub_facebook_page_type', $networkpub_facebook_page_type); 595 networkpub_update_option('networkpub_facebook_app_id', $networkpub_facebook_app_id); 563 596 } elseif ($_POST['networkpub_form_type'] == 'networkpub_metatags_googleplus') { 564 597 if(array_key_exists('networkpub_metatags_googleplus', $_POST)) { … … 567 600 $networkpub_metatags_googleplus = 0; 568 601 } 602 if(array_key_exists('networkpub_googleplus_page_type', $_POST)) { 603 $networkpub_googleplus_page_type = $_POST['networkpub_googleplus_page_type']; 604 } else { 605 $networkpub_googleplus_page_type = 'Article'; 606 } 569 607 networkpub_update_option('networkpub_metatags_googleplus', $networkpub_metatags_googleplus); 608 networkpub_update_option('networkpub_googleplus_page_type', $networkpub_googleplus_page_type); 609 } elseif ($_POST['networkpub_form_type'] == 'networkpub_custom_field_image') { 610 if(array_key_exists('networkpub_custom_field_image', $_POST)) { 611 $networkpub_custom_field_image = $_POST['networkpub_custom_field_image']; 612 } else { 613 $networkpub_custom_field_image = ''; 614 } 615 networkpub_update_option('networkpub_custom_field_image', $networkpub_custom_field_image); 570 616 } 571 617 } … … 623 669 $networkpub_metatags_facebook = 'checked'; 624 670 } 671 //Facebook Lang 672 if(array_key_exists('networkpub_lang_facebook', $options)) { 673 $networkpub_lang_facebook = $options['networkpub_lang_facebook']; 674 } else { 675 $networkpub_metatags_facebook = 'en_US'; 676 } 677 //Facebook Type 678 if(array_key_exists('networkpub_facebook_page_type', $options)) { 679 $networkpub_facebook_page_type = $options['networkpub_facebook_page_type']; 680 } else { 681 $networkpub_facebook_page_type = 'article'; 682 } 683 //Facebook APP Id 684 if(array_key_exists('networkpub_facebook_app_id', $options)) { 685 $networkpub_facebook_app_id = $options['networkpub_facebook_app_id']; 686 } else { 687 $networkpub_facebook_app_id = ''; 688 } 625 689 //Google Plus Metatags 626 690 if(array_key_exists('networkpub_metatags_googleplus', $options)) { … … 634 698 $networkpub_metatags_googleplus = 'checked'; 635 699 } 700 //Google Plus Page Type 701 if(array_key_exists('networkpub_googleplus_page_type', $options)) { 702 $networkpub_googleplus_page_type = $options['networkpub_googleplus_page_type']; 703 } else { 704 $networkpub_googleplus_page_type = 'Article'; 705 } 706 //Custom Field Image 707 if(array_key_exists('networkpub_custom_field_image', $options)) { 708 $networkpub_custom_field_image = $options['networkpub_custom_field_image']; 709 } else { 710 $networkpub_custom_field_image = ''; 711 } 636 712 } else { 637 713 $networkpub_enable = 'checked'; … … 639 715 $networkpub_mixed_mode_alert_show = 'checked'; 640 716 $networkpub_metatags_facebook = 'checked'; 717 $networkpub_lang_facebook = 'en_US'; 718 $networkpub_facebook_page_type = 'article'; 719 $networkpub_facebook_app_id = ''; 641 720 $networkpub_metatags_googleplus = 'checked'; 642 } 721 $networkpub_googleplus_page_type = 'Article'; 722 $networkpub_custom_field_image = ''; 723 } 724 //FB Langs 725 $fb_langs = networkpub_fb_langs(); 726 $fb_langs_options = ''; 727 asort($fb_langs ); 728 foreach($fb_langs as $key=>$val) { 729 if($networkpub_lang_facebook == $key) { 730 $fb_langs_options = $fb_langs_options.'<option value="'.htmlentities($key).'" selected>'.htmlentities($val).'</option>'; 731 } else{ 732 $fb_langs_options = $fb_langs_options.'<option value="'.htmlentities($key).'">'.htmlentities($val).'</option>'; 733 } 734 } 735 $facebook_page_type = array('article'=>__('Article'), 'blog'=>__('Blog'), 'book'=>__('Book'), 'profile'=>__('External Profile'), 'video.movie'=>__('Movie'), 'video.episode'=>__('TV Episode'), 'video.tv_show'=>__('TV Show'), 'video.other'=>__('Video'), 'website'=>__('Website')); 736 $facebook_page_type_options = ''; 737 foreach($facebook_page_type as $key=>$val) { 738 if($networkpub_facebook_page_type == $key) { 739 $facebook_page_type_options = $facebook_page_type_options.'<option value="'.htmlentities($key).'" selected>'.htmlentities($val).'</option>'; 740 } else{ 741 $facebook_page_type_options = $facebook_page_type_options.'<option value="'.htmlentities($key).'">'.htmlentities($val).'</option>'; 742 } 743 } 744 //Google Plus 745 $googleplus_page_type = array('Article'=>__('Article'), 'Blog'=>__('Blog'), 'Book'=>__('Book'), 'Event'=>__('Event'), 'LocalBusiness'=>__('Local Business'), 'Organization'=>__('Organization'), 'Person'=>__('Person'), 'Product'=>__('Product'), 'Review'=>__('Review')); 746 $googleplus_page_type_options = ''; 747 foreach($googleplus_page_type as $key=>$val) { 748 if($networkpub_googleplus_page_type == $key) { 749 $googleplus_page_type_options = $googleplus_page_type_options.'<option value="'.htmlentities($key).'" selected>'.htmlentities($val).'</option>'; 750 } else{ 751 $googleplus_page_type_options = $googleplus_page_type_options.'<option value="'.htmlentities($key).'">'.htmlentities($val).'</option>'; 752 } 753 } 754 //Mixed mode 643 755 networkpub_mixed_mode(); 756 //HTML 644 757 $html = ' 645 758 <div id="networkpub_msg"></div> … … 788 901 <div style="padding:40px 0px 0px 0px;"> 789 902 <div class="networkpublisher_header"> 790 <strong>'.__(' Add Facebook Open Graph Metatags to web pages').'</strong>903 <strong>'.__('Facebook Open Graph Metatags and Locale').'</strong> 791 904 </div> 792 905 <div class="networkpublisher_content_box"> … … 796 909 <input type="checkbox" id="networkpub_metatags_facebook" name="networkpub_metatags_facebook" '.$networkpub_metatags_facebook.' /><label for="networkpub_metatags_facebook"> '.__('Check this box if you want Facebook Open Graph Metatags added to your pages. ').' <a target="_blank" href="http://help.linksalpha.com/wordpress-plugin-network-publisher/metatags">'.__('Click Here').'</a> '.__('to learn more.').'</label> 797 910 </div> 798 <div style="padding-top:5px;"> 911 <div style="padding:10px 0px;"> 912 <div style="width:220px;float:left;"> 913 <select name="networkpub_lang_facebook" id="networkpub_lang_facebook"> 914 '.$fb_langs_options.' 915 </select> 916 </div> 917 <div style="float:left;width:400px;"> 918 <label for="networkpub_lang_facebook">'.__('Facebook Locale').'</label> 919 </div> 920 <br style="clear:both;"/> 921 </div> 922 <div style="padding:10px 0px;"> 923 <div style="width:120px;float:left;"> 924 <select name="networkpub_facebook_page_type" id="networkpub_facebook_page_type"> 925 '.$facebook_page_type_options.' 926 </select> 927 </div> 928 <div style="float:left;width:400px;"> 929 <label for="networkpub_facebook_page_type">'.__('Page Type').'</label> 930 </div> 931 <br style="clear:both;"/> 932 </div> 933 <div style="padding:10px 0px;"> 934 <div style="width:120px;float:left;"> 935 <input style="width:110px" type="text" name="networkpub_facebook_app_id" id="networkpub_facebook_app_id" value="'.$networkpub_facebook_app_id.'" /> 936 </div> 937 <div style="float:left;width:400px;"> 938 <label for="networkpub_facebook_app_id">'.__('Facebook App ID').'</label> 939 </div> 940 <br style="clear:both;"/> 941 </div> 942 <div> 799 943 <input type="hidden" name="networkpub_form_type" value="networkpub_metatags_facebook" /> 800 944 <input type="submit" name="submit" class="button-primary" value="'.__('Update').'" /> … … 806 950 <div style="padding:40px 0px 0px 0px;"> 807 951 <div class="networkpublisher_header"> 808 <strong>'.__(' Add Google Plus Metatags to web pages').'</strong>952 <strong>'.__('Google Plus Metatags and Page Type').'</strong> 809 953 </div> 810 954 <div class="networkpublisher_content_box"> … … 814 958 <input type="checkbox" id="networkpub_metatags_googleplus" name="networkpub_metatags_googleplus" '.$networkpub_metatags_googleplus.' /><label for="networkpub_metatags_googleplus"> '.__('Check this box if you want Google Plus Metatags added to your pages. ').' <a target="_blank" href="http://help.linksalpha.com/wordpress-plugin-network-publisher/metatags">'.__('Click Here').'</a> '.__('to learn more.').'</label> 815 959 </div> 816 <div style="padding-top:5px;"> 960 <div style="padding:10px 0px;"> 961 <div style="width:120px;float:left;"> 962 <select name="networkpub_googleplus_page_type" id="networkpub_googleplus_page_type"> 963 '.$googleplus_page_type_options.' 964 </select> 965 </div> 966 <div style="float:left;width:400px;"> 967 <label for="networkpub_googleplus_page_type">'.__('Page Type').'</label> 968 </div> 969 <br style="clear:both;"/> 970 </div> 971 <div> 817 972 <input type="hidden" name="networkpub_form_type" value="networkpub_metatags_googleplus" /> 973 <input type="submit" name="submit" class="button-primary" value="'.__('Update').'" /> 974 </div> 975 </form> 976 </div> 977 </div> 978 </div> 979 <div style="padding:40px 0px 0px 0px;"> 980 <div class="networkpublisher_header"> 981 <strong>'.__('Image URL from Custom Field').'</strong> 982 </div> 983 <div class="networkpublisher_content_box"> 984 <div style="padding-bottom:10px;"> 985 <form action="" method="post"> 986 <div style="padding:10px 0px 0px 0px;"> 987 <div style="width:220px;float:left;"> 988 <input style="width:210px;" type="text" name="networkpub_custom_field_image" id="networkpub_custom_field_image" value="'.$networkpub_custom_field_image.'" /> 989 </div> 990 <div style="float:left;width:400px;"> 991 <label for="networkpub_custom_field_image">'.__('Custom Field Name').'</label> 992 </div> 993 <br style="clear:both;"/> 994 </div> 995 <div style="padding:3px 0px 10px 0px;color:gray;"> 996 '.__('If your posts store images in a custom field, input the name of the custom field here. Please note that the custom field should contain direct url to the image. If this is not the case, please contact').' <a href="http://support.linksalpha.com">'.__('LinksAlpha Support').'</a> 997 </div> 998 <div> 999 <input type="hidden" name="networkpub_form_type" value="networkpub_custom_field_image" /> 818 1000 <input type="submit" name="submit" class="button-primary" value="'.__('Update').'" /> 819 1001 </div> … … 1455 1637 1456 1638 1639 function networkpub_fb_langs() { 1640 $langs = array(); 1641 $response_full = networkpub_http_post("http://www.facebook.com/translations/FacebookLocales.xml", array()); 1642 $response_code = $response_full[0]; 1643 if ($response_code == 200) { 1644 preg_match_all('/<locale>\s*<englishName>([^<]+)<\/englishName>\s*<codes>\s*<code>\s*<standard>.+?<representation>([^<]+)<\/representation>/s', utf8_decode($response_full[1]), $langslist, PREG_PATTERN_ORDER); 1645 foreach ($langslist[1] as $key=>$val) { 1646 $langs[$langslist[2][$key]] = $val; 1647 } 1648 } else { 1649 $langs['default'] = "Default"; 1650 } 1651 return $langs; 1652 } 1653 1654 1457 1655 function networkpub_add_metatags() { 1458 1656 $options = get_option(NETWORKPUB_WIDGET_NAME_INTERNAL); … … 1488 1686 } 1489 1687 $og_desc = networkpub_prepare_text($og_desc); 1490 //Type 1491 $og_type = 'article'; 1688 //Facebook Page Type 1689 if(!empty($options['networkpub_facebook_page_type'])) { 1690 $og_type = $options['networkpub_facebook_page_type']; 1691 } else { 1692 $og_type = 'article'; 1693 } 1492 1694 } else { 1493 1695 //Title … … 1501 1703 $og_desc = networkpub_prepare_text($og_desc); 1502 1704 //Type 1503 $og_type = "blog";1705 $og_type = 'website'; 1504 1706 } 1505 //Locale 1506 $og_locale = 'en_US'; 1507 //FB App id 1508 $og_fb_app_id = '188707654478'; 1707 //Facebook Locale 1708 if(!empty($options['networkpub_lang_facebook'])) { 1709 $og_locale = $options['networkpub_lang_facebook']; 1710 } else { 1711 $og_locale = 'en_US'; 1712 } 1713 //Facebook App ID 1714 if(!empty($options['networkpub_facebook_app_id'])) { 1715 $og_fb_app_id = $options['networkpub_facebook_app_id']; 1716 } else { 1717 $og_fb_app_id = ''; 1718 } 1719 //Google Plus Page Type 1720 if(!empty($options['networkpub_googleplus_page_type'])) { 1721 $og_type_google = $options['networkpub_googleplus_page_type']; 1722 } else { 1723 $og_type_google = 'Article'; 1724 } 1509 1725 //Show tags 1510 1726 if($networkpub_metatags_facebook) { … … 1512 1728 } 1513 1729 if($networkpub_metatags_googleplus) { 1514 networkpub_build_meta_googleplus($og_title, $og_link_image, $og_desc, $og_type );1730 networkpub_build_meta_googleplus($og_title, $og_link_image, $og_desc, $og_type_google); 1515 1731 } 1516 1732 return; … … 1519 1735 1520 1736 function networkpub_build_meta_facebook($og_site_name, $og_title, $og_link, $og_link_image, $og_desc, $og_type, $og_locale, $og_fb_app_id) { 1521 $opengraph_meta = "\n<meta property=\"og:site_name\" content=\"" . $og_site_name . "\" />"; 1522 $opengraph_meta .= "\n<meta property=\"og:title\" content=\"" . $og_title . "\" />"; 1523 $opengraph_meta .= "\n<meta property=\"og:url\" content=\"" . $og_link . "\" />"; 1524 $opengraph_meta .= "\n<meta property=\"og:image\" content=\"" . $og_link_image . "\" />"; 1525 $opengraph_meta .= "\n<meta property=\"og:description\" content=\"" . $og_desc . "\" />"; 1526 $opengraph_meta .= "\n<meta property=\"og:type\" content=\"". $og_type ."\" />"; 1527 $opengraph_meta .= "\n<meta property=\"og:locale\" content=\"" . $og_locale . "\" />"; 1528 $opengraph_meta .= "\n<meta property=\"fb:app_id\" content=\"" . $og_fb_app_id . "\" />"; 1737 $opengraph_meta = ''; 1738 if($og_site_name) { 1739 $opengraph_meta .= "\n<meta property=\"og:site_name\" content=\"" . $og_site_name . "\" />"; 1740 } 1741 if($og_title) { 1742 $opengraph_meta .= "\n<meta property=\"og:title\" content=\"" . $og_title . "\" />"; 1743 } 1744 if($og_link) { 1745 $opengraph_meta .= "\n<meta property=\"og:url\" content=\"" . $og_link . "\" />"; 1746 } 1747 if($og_link_image) { 1748 $opengraph_meta .= "\n<meta property=\"og:image\" content=\"" . $og_link_image . "\" />"; 1749 } 1750 if($og_desc) { 1751 $opengraph_meta .= "\n<meta property=\"og:description\" content=\"" . $og_desc . "\" />"; 1752 } 1753 if($og_type) { 1754 $opengraph_meta .= "\n<meta property=\"og:type\" content=\"". $og_type ."\" />"; 1755 } 1756 if($og_locale) { 1757 $opengraph_meta .= "\n<meta property=\"og:locale\" content=\"" . $og_locale . "\" />"; 1758 } 1759 if($og_fb_app_id) { 1760 $opengraph_meta .= "\n<meta property=\"fb:app_id\" content=\"" . $og_fb_app_id . "\" />"; 1761 } 1529 1762 echo "\n<!-- Facebook Open Graph metatags added by WordPress plugin - Network Publisher. Get it at: http://wordpress.org/extend/plugins/network-publisher/ -->" . $opengraph_meta . "\n<!-- End Facebook Open Graph metatags-->\n"; 1530 1763 } … … 1532 1765 1533 1766 function networkpub_build_meta_googleplus($og_title, $og_link_image, $og_desc, $og_type) { 1534 $opengraph_meta = "\n<meta itemprop=\"name\" content=\"" . $og_title . "\" />"; 1535 $opengraph_meta .= "\n<meta itemprop=\"image\" content=\"" . $og_link_image . "\" />"; 1536 $opengraph_meta .= "\n<meta itemprop=\"description\" content=\"" . $og_desc . "\" />"; 1767 $opengraph_meta = ''; 1768 if($og_title) { 1769 $opengraph_meta = "\n<meta itemprop=\"name\" content=\"" . $og_title . "\" />"; 1770 } 1771 if($og_link_image) { 1772 $opengraph_meta .= "\n<meta itemprop=\"image\" content=\"" . $og_link_image . "\" />"; 1773 } 1774 if($og_desc) { 1775 $opengraph_meta .= "\n<meta itemprop=\"description\" content=\"" . $og_desc . "\" />"; 1776 } 1537 1777 echo "\n<!-- Google Plus metatags added by WordPress plugin - Network Publisher. Get it at: http://wordpress.org/extend/plugins/network-publisher/ -->" . $opengraph_meta . "\n<!-- End Google Plus metatags-->\n"; 1538 1778 } … … 1552 1792 return ; 1553 1793 } 1554 1555 1794 if($networkpub_metatags_facebook) { 1556 1795 $attr .= " xmlns:og=\"http://opengraphprotocol.org/schema/\""; … … 1559 1798 } 1560 1799 if($networkpub_metatags_googleplus) { 1561 $networkpub_metatags_googleplus_page_type = 'Article'; 1562 $attr .= " itemscope itemtype=\"http://schema.org/".$networkpub_metatags_googleplus_page_type."\""; 1800 //Type 1801 if(!empty($options['networkpub_googleplus_page_type'])) { 1802 $og_type = $options['networkpub_googleplus_page_type']; 1803 } else { 1804 $og_type = 'Article'; 1805 } 1806 $attr .= " itemscope itemtype=\"http://schema.org/".$og_type."\""; 1563 1807 } 1564 1808 return $attr; … … 1616 1860 1617 1861 function networkpub_thumbnail_link($post_id, $post_content) { 1862 $options = get_option(NETWORKPUB_WIDGET_NAME_INTERNAL); 1863 if(is_array($options)) { 1864 if(!empty($options['networkpub_custom_field_image'])) { 1865 $networkpub_custom_field_image = $options['networkpub_custom_field_image']; 1866 $post_data_custom = get_post_custom( $post_id, ARRAY_A ); 1867 if(!empty($post_data_custom[$networkpub_custom_field_image])) { 1868 if(is_array($post_data_custom[$networkpub_custom_field_image])) { 1869 return $post_data_custom[$networkpub_custom_field_image][0]; 1870 } 1871 } 1872 } 1873 } 1618 1874 if(function_exists('get_post_thumbnail_id') and function_exists('wp_get_attachment_image_src')) { 1619 1875 $src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'medium'); -
network-publisher/trunk/readme.txt
r516893 r518932 4 4 Requires at least: 1.0.0 5 5 Tested up to: 3.3.1 6 Stable tag: 5.0 6 Stable tag: 5.0.1 7 7 8 8 == Description == … … 77 77 == Changelog == 78 78 79 = 5.0.1 = 80 * Added options for Facebook Language, Facebook/Google Post Type, Facebook App ID, Image from Custom Field. 81 79 82 = 5.0 = 80 83 * Added support for Facebook and Google Plus metatags
Note: See TracChangeset
for help on using the changeset viewer.