Changeset 591175
- Timestamp:
- 08/28/2012 02:21:28 AM (13 years ago)
- Location:
- globalfeed/trunk
- Files:
-
- 6 edited
-
admin/pages/admin_presentation.php (modified) (2 diffs)
-
admin/pages/style.css (modified) (1 diff)
-
event_scheduler_interfaces/wp-schedule-interface.php (modified) (2 diffs)
-
feeds/mb_facebook/mb_facebook.php (modified) (2 diffs)
-
mb_globalfeed.php (modified) (8 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
globalfeed/trunk/admin/pages/admin_presentation.php
r582062 r591175 27 27 $settings['media_display_mode'] = (isset($_POST['presentation-media_display_mode']) && $_POST['presentation-media_display_mode'] == 'on') ? 'embed' : 'smart'; 28 28 $settings['theme_show_avatar'] = isset($_POST['presentation-theme_show_avatar']) && $_POST['presentation-theme_show_avatar'] == 'on'; 29 $settings['autodetect_link_open_new_window'] = (isset($_POST['presentation-autodetect_link_open_new_window']) && $_POST['presentation-autodetect_link_open_new_window'] == 'on'); 29 30 } 30 31 ?> … … 40 41 <p><label for="presentation-theme_show_avatar"><input type="checkbox" <?php echo $settings['theme_show_avatar'] ? 'checked="checked"' : ''; ?> id="presentation-theme_show_avatar" name="presentation-theme_show_avatar" /> Show avatar in GlobalFeed themes</label></p> 41 42 <p><label for="presentation-media_display_mode"><input type="checkbox" <?php echo $settings['media_display_mode'] == 'embed' ? 'checked="checked"' : ''; ?> id="presentation-media_display_mode" name="presentation-media_display_mode" /> Embed media in post content (images, videos etc..)</label></p> 43 <p><label for="presentation-autodetect_link_open_new_window"><input type="checkbox" <?php echo $settings['autodetect_link_open_new_window'] ? 'checked="checked"' : ''; ?> id="presentation-autodetect_link_open_new_window" name="presentation-autodetect_link_open_new_window" /> Open GlobalFeed-generated links in a new window</label></p> 42 44 43 45 <input type="submit" value="Save Settings" /> -
globalfeed/trunk/admin/pages/style.css
r577487 r591175 137 137 margin: 0px 20px 20px 0px; 138 138 padding: 5px 10px 10px; 139 width: 500px; 140 display:inline; 141 display:inline-block; 139 } 140 141 @media screen and (min-width: 960px) { 142 .optgrp { 143 max-width: 500px; 144 width: 100%; 145 display:inline; 146 display:inline-block; 147 } 148 } 149 150 @media screen and (min-width: 960px) { 151 .optgrp { 152 display:block; 153 } 142 154 } 143 155 -
globalfeed/trunk/event_scheduler_interfaces/wp-schedule-interface.php
r582062 r591175 18 18 19 19 add_filter($this->hook_name, array( &$this, 'do_scheduled_action'), 1, 3); 20 21 //$globalfeed->print_debug_info($this->get_scheduled_events()); 20 22 } 21 23 … … 92 94 $mb_globalfeed->print_debug_info($action); 93 95 94 if ( !class_exists($caller) || method_exists($caller, $action))96 if ( !class_exists($caller) || !method_exists($caller, $action)) 95 97 return; 96 98 97 $mb_globalfeed->print_debug_info(call_user_func( array( &$$caller, $action ), $args ) );99 $mb_globalfeed->print_debug_info(call_user_func( array( &$$caller, $action ), $args ) ); 98 100 } 99 101 -
globalfeed/trunk/feeds/mb_facebook/mb_facebook.php
r582062 r591175 776 776 else 777 777 $globalfeed->print_debug_info ($img); 778 778 $globalfeed->print_debug_info($update); 779 779 $post_args['meta']['link'] = $update->link; 780 780 $content_args['media_format'] = 'image'; … … 783 783 case 'status' : 784 784 $post_args['post_format'] = 'status'; 785 if (isset($update->story) && isset($update->story_tags) && !isset($update->actions)) {786 $update->actions = array();787 // This is a story... Perform a bit of introspection to figure out how to link to it.788 foreach ($update->story_tags as $key => $value) {789 $graph_url = "https://graph.facebook.com/{$value[0]->id}?access_token={$access_token}&metadata=1";790 $introspect = wp_remote_get($graph_url);791 792 if (is_wp_error($introspect))793 return false;794 795 $introspect = json_decode($introspect['body']);796 $globalfeed->print_debug_info($introspect, 'mb_facebook');797 if ( isset($introspect->type) ) {798 $action_name = 'View ' . ucwords($introspect->type);799 800 $obj = new stdClass();801 switch ($type) {802 case 'user':803 $obj->name = $action_name;804 $obj->link = "https://facebook.com/{$value[0]->id}";805 break;806 default:807 $obj->name = $action_name;808 $obj->link = "https://facebook.com/{$type}/{$value[0]->id}";809 break;810 }811 812 $update->actions[] = $obj;813 }814 }815 816 }817 785 break; 818 786 default : 819 787 $post_args['post_format'] = 'status'; 820 788 break; 789 } 790 791 // If this object has story attributes, parse them 792 if (isset($update->story) && isset($update->story_tags) ) { 793 if ( !isset($update->actions) ) 794 $update->actions = array(); 795 796 // This is a story... Perform a bit of introspection to figure out how to link to it. 797 foreach ($update->story_tags as $key => $value) { 798 $value = $value[0]; 799 // Detect the object type 800 $type = ''; 801 if ( isset($value->type) ) { 802 $type = $value->type; 803 } else { 804 $graph_url = "https://graph.facebook.com/{$value[0]->id}?access_token={$access_token}&metadata=1"; 805 $introspect = wp_remote_get($graph_url); 806 807 if (is_wp_error($introspect)) 808 return false; 809 $introspect = json_decode($introspect['body']); 810 $type = $introspect->type; 811 //$globalfeed->print_debug_info($introspect, 'mb_facebook'); 812 } 813 814 if ( !empty($type) ) { 815 $action_name = 'View ' . ucwords($type); 816 817 $obj = new stdClass(); 818 switch ($type) { 819 case 'user': 820 $obj->name = $action_name; 821 $obj->link = "https://facebook.com/{$value->id}"; 822 break; 823 default: 824 $obj->name = $action_name; 825 $obj->link = "https://facebook.com/{$type}/{$value->id}"; 826 break; 827 } 828 829 // Now that we know the type, check and see if we should add a link to this object in the content 830 if ( !isset($content_args['links']) ) 831 $content_args['links'] = array(); 832 833 $content_args['links'][$obj->link] = $value; 834 835 $update->actions[] = $obj; 836 } 837 } 821 838 } 822 839 -
globalfeed/trunk/mb_globalfeed.php
r582062 r591175 268 268 'widget_skin' => 'fb', // The GlobalFeed sking to use on widgets. 269 269 'plugin_update_interval' => 600, // The default for how often feeds update 270 'autodetect_link_open_new_window' => true, 270 271 'plugin_update_intervals' => array( 271 272 'Ten Minutes' => '600', … … 1007 1008 if ( !empty($feeds) ) { 1008 1009 foreach ( $feeds as $slug => &$feed ) { 1009 $this->print_debug_info($feed);1010 1010 if ( !isset($feed['autoload']) || $feed['autoload'] !== false ) 1011 1011 require_once($feed['file_path']); … … 1500 1500 'link' => '', // If set for images, the image will be wrapped in a link tag. 1501 1501 'link_text' => '', // The text that appears for the link. Will appear as the title attribute for images. 1502 'link_target' => '_blank', // The links' target attribute.1502 'link_target' => ($this->settings['autodetect_link_open_new_window'] ? '_blank' : ''), // The links' target attribute. 1503 1503 'css' => '', // CSS Classes to add to the element 1504 1504 'height' => '', // The height of the produced element … … 1572 1572 1573 1573 if ( in_array('url', $types) ) { 1574 $pattern = '/ (ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:\.\?+=&%@!\-\/]))?([^“�«»„])/u';1574 $pattern = '/[^\'"](ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:\.\?+=&%@!\-\/]))?([^“�«»„])[^\'"]/u'; 1575 1575 $text = implode(' ',preg_replace_callback( $pattern, array( &$this, '_replace_link_callback'), explode(' ', $text))); 1576 1576 } … … 1590 1590 } 1591 1591 1592 /** 1593 * Embeds custom links given either the offset and length of the text to 1594 * be linked to or the text to be replaced to create the link. 1595 * 1596 * @param str $content The content to have links added 1597 * @param array $links An array of links to be added, with the link url as the key 1598 */ 1599 function embed_links( $content, $links ) { 1600 $c_offset = 0; 1601 foreach ($links as $url => $args) { 1602 $args = (array) $args; 1603 if ( isset($args['offset']) && isset($args['length']) ) { 1604 $this->print_debug_info($args); 1605 $args['offset'] = (int) $args['offset']; $args['length'] = (int) $args['length']; 1606 $link = "<a href='{$url}'" . ($this->settings['autodetect_link_open_new_window'] ? " target='_blank'" : "") . ">" . substr($content, $c_offset + $args['offset'], $args['length']) . "</a>"; 1607 1608 $content = substr($content, 0, $c_offset + $args['offset']) . $link . substr($content, $c_offset + $args['offset'] + $args['length']); 1609 $c_offset += strlen($link) - $args['length']; 1610 } else if ( isset($args['name']) ) { 1611 1612 } 1613 } 1614 1615 return $content; 1616 } 1617 1592 1618 /** 1593 1619 * Used by detect_content_links as the callback for link creation to avoid … … 1597 1623 */ 1598 1624 private function _replace_link_callback ( $matches ) { 1599 return '<a href="' .$matches[0]. '" target="_blank">'. $matches[0] . '</a>';1625 return '<a href="' .$matches[0]. '"' . ($this->settings['autodetect_link_open_new_window'] ? ' target="_blank">' : '>') . $matches[0] . '</a>'; 1600 1626 } 1601 1627 1602 1628 private function _replace_twitter_user_callback( $matches ) { 1603 1629 $ins = substr($matches[0],1); 1604 return "<a href='http://twitter.com/$ins' class='twitter_user' target='_blank'>@<span>$ins</span></a>";1630 return "<a href='http://twitter.com/$ins' class='twitter_user'" . ($this->settings['autodetect_link_open_new_window'] ? " target='_blank'" : "") . ">@<span>$ins</span></a>"; 1605 1631 } 1606 1632 1607 1633 private function _replace_twitter_hashtag_callback( $matches ) { 1608 return "<a href='http://twitter.com/#!/search/" . urlencode($matches[0]) . "' class='twitter_hashtag' target='_blank'>#<span>" . substr($matches[0],1) . "</span></a>";1634 return "<a href='http://twitter.com/#!/search/" . urlencode($matches[0]) . "' class='twitter_hashtag'" . ($this->settings['autodetect_link_open_new_window'] ? " target='_blank'" : "") . ">#<span>" . substr($matches[0],1) . "</span></a>"; 1609 1635 } 1610 1636 … … 1624 1650 1625 1651 // First check if there is a set word limit 1626 if ( $args['word_count'] !== false ) {1652 if ( isset($args['character_count']) && $args['word_count'] !== false ) { 1627 1653 $words = explode(' ', $content); 1628 1654 $content = implode(' ', array_slice($words, 0, $args['word_count'])); … … 1630 1656 1631 1657 // Now check if there is a set character limit 1632 if ( $args['character_count'] !== false && count($content) > $args['character_count'] )1658 if ( isset($args['character_count']) && $args['character_count'] !== false && count($content) > $args['character_count'] ) 1633 1659 // Get the position of the last space within the character limit and cut the string 1634 1660 $content = substr($content, 0, strrpos(substr($content, 0, $args['character_count']), ' ')); 1635 1661 1662 // Check if we need to embed custom links 1663 if ( isset($args['links']) && is_array($args['links']) ) 1664 $content = $this->embed_links($content, $args['links']); 1665 1636 1666 // Check if we have to detect content links 1637 if ( $args['detect_content_links'] )1667 if ( isset($args['detect_content_links']) && $args['detect_content_links'] ) 1638 1668 $content = $this->detect_content_links ($content); 1639 1669 1640 1670 // Now check if we're to embed content 1641 if ( $args['include_media'] && $this->media_display_mode() == 'embed' && isset($args['media_format']) && isset($args['media_info']))1671 if ( isset($args['include_media']) && $args['include_media'] && $this->media_display_mode() == 'embed' && isset($args['media_format']) && isset($args['media_info'])) 1642 1672 $content = $this->embed_media_item($content, $args['media_format'], $args['media_info']); 1643 1673 -
globalfeed/trunk/readme.txt
r582062 r591175 89 89 == Changelog == 90 90 91 = 0.1.3 = 92 - Added GlobalFeed option to open GlobalFeed-generated links in a new window. 93 - Fixed an issue that stopped GlobalFeed from updating automatically in certain hosting environments. 94 91 95 = 0.1.2 = 92 96 - MB RSS can be pointed to a webpage and will attempt to automatically discover its RSS feeds, and will then prompt the user if more than one feed is found.
Note: See TracChangeset
for help on using the changeset viewer.