Changeset 1380986
- Timestamp:
- 03/29/2016 11:56:57 AM (10 years ago)
- Location:
- social-counters/trunk
- Files:
-
- 9 edited
-
counters/bitacoras.php (modified) (7 diffs)
-
counters/facebook.php (modified) (5 diffs)
-
counters/google-buzz.php (modified) (4 diffs)
-
counters/linkedin.php (modified) (2 diffs)
-
counters/meneame.php (modified) (7 diffs)
-
counters/tuenti.php (modified) (4 diffs)
-
counters/twitter.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
-
social-counters.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
social-counters/trunk/counters/bitacoras.php
r417895 r1380986 4 4 5 5 function social_counter__defaults__bitacoras( $defaults = array() ) { 6 6 7 7 $key = social_counter__bitacoras_key(); 8 8 if ( !empty($key) ) 9 9 $defaults[] = 'bitacoras'; 10 10 11 11 return $defaults; 12 12 } … … 16 16 function social_counters__admin_list__bitacoras( $codeExit = '', $postparam = false ) { 17 17 global $post; 18 18 19 19 $_post = ( $postparam ) ? $postparam : $post; 20 20 21 21 $key = social_counter__bitacoras_key(); 22 22 if ( $_post && !empty($key) ) { 23 23 return $codeExit . '<div class="misc-pub-section">Bitacoras: ' . social_counter__get('bitacoras', $_post, false) . '</div>'; 24 24 } 25 25 26 26 return $codeExit; 27 27 … … 32 32 function social_counter__get__bitacoras( $codeExit = '', $postparam = false, $linked = true ) { 33 33 global $post; 34 34 35 35 $_post = ( $postparam ) ? $postparam : $post; 36 36 37 37 $shared_counter = 0; 38 38 39 39 $key = social_counter__bitacoras_key(); 40 40 if ( $_post && !empty($key) ) { 41 41 42 42 $share_counter_meta = get_post_meta($_post->ID, '_shared_counter_bitacoras_v2', true); 43 44 if ( !is_single() && $share_counter_meta !== false ) {45 43 44 if ( !is_single() && !empty($share_counter_meta) && $share_counter_meta !== false ) { 45 46 46 $shared_counter = $share_counter_meta; 47 47 48 48 }else{ 49 49 50 50 if ( function_exists('json_decode') ) { 51 51 $post_url = apply_filters('social_counters_post_url_bitacoras', get_permalink($_post->ID), $_post); 52 52 $post_url = urlencode($post_url); 53 53 54 54 $url_request = 'http://api.bitacoras.com/anotacion/key/'. social_counter__bitacoras_key() .'/format/'. 'json' .'/url/{url}/'; 55 55 $url_request = str_replace('{url}', $post_url, $url_request); 56 57 $data = wp_remote_retrieve_body(wp_remote_get($url_request ));58 56 57 $data = wp_remote_retrieve_body(wp_remote_get($url_request, array('timeout' => 1,))); 58 59 59 if ( !empty($data) ) { 60 60 $data = json_decode($data); 61 61 62 62 if ( $data->status == 'success' ) { 63 63 $shared_counter = $data->data->votos; … … 65 65 } 66 66 } 67 67 68 68 update_post_meta($_post->ID, '_shared_counter_bitacoras_v2', $shared_counter); 69 69 70 70 } 71 71 } 72 72 73 73 $shared_counter = ( empty($shared_counter) ) ? 0 : $shared_counter; 74 74 75 75 $shared_counter = '<span>'.$shared_counter.'</span>'; 76 76 $shared_classes = 'social-counter social-counter-'. __('lang-dir', 'social-counters') .'-bitacoras'; … … 81 81 $shared_counter = '<span class="'. $shared_classes .'">'.$shared_counter.'</span>'; 82 82 } 83 83 84 84 return $codeExit . $shared_counter; 85 85 } … … 89 89 function social_counters__share_url__bitacoras( $postparam = false ) { 90 90 global $post; 91 91 92 92 $_post = ( $postparam ) ? $postparam : $post; 93 93 94 94 $key = social_counter__bitacoras_key(); 95 95 if ( $_post && !empty($key) ) { 96 96 97 97 $post_title = urlencode( apply_filters('social_counters__the_title', get_the_title($_post->ID)) ); 98 98 $url_string = urlencode( apply_filters('social_counters_share_url_bitacoras', get_permalink($_post->ID), $_post) ); 99 99 100 100 $bitacoras_url = 'http://bitacoras.com/anotaciones/' . $url_string . '/'; 101 101 102 102 return $bitacoras_url; 103 103 } 104 104 105 105 return "#ERROR"; 106 106 } … … 109 109 function social_counter__bitacoras_key() { 110 110 $bitacoras_key = ''; 111 111 112 112 if ( defined('SOCIAL_COUNTER__BITACORAS_KEY') ) 113 113 $bitacoras_key = SOCIAL_COUNTER__BITACORAS_KEY; 114 114 115 115 return $bitacoras_key; 116 116 } -
social-counters/trunk/counters/facebook.php
r532303 r1380986 12 12 function social_counters__admin_list__facebook( $codeExit = '', $postparam = false ) { 13 13 global $post; 14 14 15 15 $_post = ( $postparam ) ? $postparam : $post; 16 16 17 17 if ( $_post ) { 18 18 return $codeExit . '<div class="misc-pub-section">Facebook: ' . social_counter__get('facebook', $_post, false) . '</div>'; 19 19 } 20 20 21 21 return $codeExit; 22 22 … … 27 27 function social_counter__get__facebook( $codeExit = '', $postparam = false, $linked = true ) { 28 28 global $post; 29 29 30 30 $_post = ( $postparam ) ? $postparam : $post; 31 31 32 32 $shared_counter = 0; 33 33 34 34 if ( $_post ) { 35 35 36 36 $share_counter_meta = get_post_meta($_post->ID, '_shared_counter_facebook_v2', true); 37 38 if ( !is_single() && $share_counter_meta !== false ) {39 37 38 if ( !is_single() && !empty($share_counter_meta) && $share_counter_meta !== false ) { 39 40 40 $shared_counter = $share_counter_meta; 41 41 42 42 }else{ 43 43 44 44 if ( function_exists('json_decode') ) { 45 45 $post_url = apply_filters('social_counters_post_url_facebook', get_permalink($_post->ID), $_post); 46 $post_url = urlencode($post_url); 47 46 48 47 //$url_request = 'http://api.facebook.com/restserver.php?format=json&method=links.getStats&urls={url}'; 49 $url_request = 'http://graph.facebook.com/ ?id={url}';50 $url_request = str_replace('{url}', $post_url, $url_request);51 52 $data = wp_remote_retrieve_body(wp_remote_get($url_request ));53 48 $url_request = 'http://graph.facebook.com/'; 49 $url_request = add_query_arg('id', $post_url, $url_request); 50 51 $data = wp_remote_retrieve_body(wp_remote_get($url_request, array('timeout' => 1,))); 52 54 53 if ( !empty($data) ) { 55 54 $data = json_decode($data); … … 58 57 } 59 58 } 60 59 61 60 if ( $share_counter_meta ) 62 61 $shared_counter = ( is_numeric($shared_counter) && $shared_counter >= $share_counter_meta ) ? $shared_counter : $share_counter_meta; 63 62 64 63 update_post_meta($_post->ID, '_shared_counter_facebook_v2', $shared_counter); 65 64 66 65 } 67 66 } 68 67 69 68 $shared_counter = ( empty($shared_counter) ) ? 0 : $shared_counter; 70 69 71 70 $shared_counter = '<span>'.$shared_counter.'</span>'; 72 71 $shared_classes = 'social-counter social-counter-'. __('lang-dir', 'social-counters') .'-facebook'; … … 77 76 $shared_counter = '<span class="'. $shared_classes .'">'.$shared_counter.'</span>'; 78 77 } 79 78 80 79 return $codeExit . $shared_counter; 81 80 } … … 85 84 function social_counters__share_url__facebook( $postparam = false ) { 86 85 global $post; 87 86 88 87 $_post = ( $postparam ) ? $postparam : $post; 89 88 90 89 if ( $_post ) { 91 90 92 91 $post_title = urlencode( apply_filters('social_counters__the_title', get_the_title($_post->ID)) ); 93 92 $url_string = urlencode( apply_filters('social_counters_share_url_facebook', get_permalink($_post->ID), $_post) ); 94 93 95 94 $facebook_url = 'http://www.facebook.com/sharer.php?u=' . $url_string . '&t=' . $post_title .''; 96 95 97 96 return $facebook_url; 98 97 } 99 98 100 99 return "#ERROR"; 101 100 } -
social-counters/trunk/counters/google-buzz.php
r532303 r1380986 12 12 function social_counters__admin_list__gbuzz( $codeExit = '', $postparam = false ) { 13 13 global $post; 14 14 15 15 $_post = ( $postparam ) ? $postparam : $post; 16 16 17 17 if ( $_post ) { 18 18 return $codeExit . '<div class="misc-pub-section">Google Buzz: ' . social_counter__get('gbuzz', $_post, false) . '</div>'; 19 19 } 20 20 21 21 return $codeExit; 22 22 … … 27 27 function social_counters__get__gbuzz( $codeExit = '', $postparam = false, $linked = true ) { 28 28 global $post; 29 29 30 30 $_post = ( $postparam ) ? $postparam : $post; 31 31 32 32 $shared_counter = 0; 33 33 34 34 if ( $_post ) { 35 35 36 36 $share_counter_meta = get_post_meta($_post->ID, '_shared_counter_gbuzz_v2', true); 37 38 if ( !is_single() && $share_counter_meta !== false ) {39 37 38 if ( !is_single() && !empty($share_counter_meta) && $share_counter_meta !== false ) { 39 40 40 $shared_counter = $share_counter_meta; 41 41 42 42 }else{ 43 43 44 44 $post_url = apply_filters('social_counters_post_url_gbuzz', get_permalink($_post->ID), $_post); 45 45 $post_url = urlencode($post_url); 46 46 47 47 $url_request = 'http://www.google.com/buzz/api/buzzThis/buzzCounter?url={url}'; 48 48 $url_request = str_replace('{url}', $post_url, $url_request); 49 50 $data = trim(wp_remote_retrieve_body(wp_remote_get($url_request )));51 49 50 $data = trim(wp_remote_retrieve_body(wp_remote_get($url_request, array('timeout' => 1,)))); 51 52 52 if ( !empty($data) ) { 53 53 $data = str_replace('google_buzz_set_count({"http://', '', $data); 54 54 $data = str_replace('});', '', $data); 55 55 $data = explode(":", $data); 56 56 57 57 $shared_counter = trim($data[1]); 58 58 } 59 59 60 60 if ( $share_counter_meta ) 61 61 $shared_counter = ( is_numeric($shared_counter) && $shared_counter >= $share_counter_meta ) ? $shared_counter : $share_counter_meta; 62 62 63 63 update_post_meta($_post->ID, '_shared_counter_gbuzz_v2', $shared_counter); 64 64 65 65 } 66 66 } 67 67 68 68 $shared_counter = ( empty($shared_counter) ) ? 0 : $shared_counter; 69 69 70 70 $shared_counter = '<span>'.$shared_counter.'</span>'; 71 71 $shared_classes = 'social-counter social-counter-'. __('lang-dir', 'social-counters') .'-gbuzz'; … … 76 76 $shared_counter = '<span class="'. $shared_classes .'">'.$shared_counter.'</span>'; 77 77 } 78 78 79 79 return $codeExit . $shared_counter; 80 80 } … … 84 84 function social_counters__share_url__gbuzz( $postparam = false ) { 85 85 global $post; 86 86 87 87 $_post = ( $postparam ) ? $postparam : $post; 88 88 89 89 if ( $_post ) { 90 90 91 91 $post_title = urlencode( apply_filters('social_counters__the_title', get_the_title($_post->ID)) ); 92 92 $post_url = urlencode( apply_filters('social_counters_share_url_gbuzz', get_permalink($_post->ID), $_post) ); 93 94 $buzz_url = 'http://www.google.com/buzz/post?url='. $post_url .''; 95 93 94 $buzz_url = 'http://www.google.com/buzz/post'; 95 $buzz_url = add_query_arg('url', $post_url, $buzz_url); 96 96 97 return $buzz_url; 97 98 } 98 99 99 100 return "#ERROR"; 100 101 } -
social-counters/trunk/counters/linkedin.php
r532303 r1380986 36 36 $share_counter_meta = get_post_meta($_post->ID, '_shared_counter_linkedin_v2', true); 37 37 38 if ( !is_single() && $share_counter_meta !== false ) {38 if ( !is_single() && !empty($share_counter_meta) && $share_counter_meta !== false ) { 39 39 40 40 $shared_counter = $share_counter_meta; … … 107 107 $url_request .= $url_request_params; 108 108 109 $data = wp_remote_retrieve_body(wp_remote_get($url_request ));109 $data = wp_remote_retrieve_body(wp_remote_get($url_request, array('timeout' => 1,))); 110 110 111 111 $url_request_params = ''; -
social-counters/trunk/counters/meneame.php
r532303 r1380986 12 12 function social_counters__admin_list__meneame( $codeExit = '', $postparam = false ) { 13 13 global $post; 14 14 15 15 $_post = ( $postparam ) ? $postparam : $post; 16 16 17 17 if ( $_post ) { 18 18 return $codeExit . '<div class="misc-pub-section">Meneame: ' . social_counter__get('meneame', $_post, false) . '</div>'; 19 19 } 20 20 21 21 return $codeExit; 22 22 … … 27 27 function social_counter__get__meneame( $codeExit = '', $postparam = false, $linked = true ) { 28 28 global $post; 29 29 30 30 $_post = ( $postparam ) ? $postparam : $post; 31 31 32 32 $shared_counter = 0; 33 33 34 34 if ( $_post ) { 35 35 36 36 $share_counter_meta = get_post_meta($_post->ID, '_shared_counter_meneame_v2', true); 37 38 if ( !is_single() && $share_counter_meta !== false ) {39 37 38 if ( !is_single() && !empty($share_counter_meta) && $share_counter_meta !== false ) { 39 40 40 $shared_counter = $share_counter_meta; 41 41 42 42 }else{ 43 43 44 44 $post_url = apply_filters('social_counters_post_url_meneame', get_permalink($_post->ID), $_post); 45 45 $post_url = $post_url; //urlencode($post_url); 46 46 47 47 $url_request = 'http://meneame.net/api/url.php?all=1&url={url}'; 48 48 $url_request = str_replace('{url}', $post_url, $url_request); 49 50 $data = trim(wp_remote_retrieve_body(wp_remote_get($url_request )));51 49 50 $data = trim(wp_remote_retrieve_body(wp_remote_get($url_request, array('timeout' => 1,)))); 51 52 52 if ( !empty($data) ) { 53 53 $data_lines = explode("\n", trim($data)); 54 54 55 55 if ( sizeof($data_lines) >= 1 ) { 56 56 57 57 foreach ( $data_lines as $data_line ) { 58 58 $line = explode(" ", trim($data_line)); … … 61 61 } 62 62 } 63 63 64 64 } 65 65 } 66 66 67 67 if ( $share_counter_meta ) 68 68 $shared_counter = ( is_numeric($shared_counter) && $shared_counter >= $share_counter_meta ) ? $shared_counter : $share_counter_meta; 69 69 70 70 update_post_meta($_post->ID, '_shared_counter_meneame_v2', $shared_counter); 71 71 72 72 } 73 73 } 74 74 75 75 $shared_counter = ( empty($shared_counter) ) ? 0 : $shared_counter; 76 76 77 77 $shared_counter = '<span>'.$shared_counter.'</span>'; 78 78 $shared_classes = 'social-counter social-counter-'. __('lang-dir', 'social-counters') .'-meneame'; … … 83 83 $shared_counter = '<span class="'. $shared_classes .'">'.$shared_counter.'</span>'; 84 84 } 85 85 86 86 return $codeExit . $shared_counter; 87 87 } … … 91 91 function social_counters__share_url__meneame( $postparam = false ) { 92 92 global $post; 93 93 94 94 $_post = ( $postparam ) ? $postparam : $post; 95 95 96 96 if ( $_post ) { 97 97 $post_title = urlencode( apply_filters('social_counters__the_title', get_the_title($_post->ID)) ); 98 98 $url_string = urlencode( apply_filters('social_counters_share_url_meneame', get_permalink($_post->ID), $_post) ); 99 99 100 100 $meneame_url = 'http://meneame.net/submit.php?url=' . $url_string . '&title=' . $post_title .''; 101 101 102 102 return $meneame_url; 103 103 } 104 104 105 105 return "#ERROR"; 106 106 } … … 108 108 function social_counters__vote_url__meneame( $postparam = false ) { 109 109 global $post; 110 110 111 111 $_post = ( $postparam ) ? $postparam : $post; 112 112 113 113 $share_vote_url = '#'; 114 114 115 115 if ( $_post ) { 116 116 117 117 $share_vote_url_meta = get_post_meta($_post->ID, '_shared_vote_url_meneame', true); 118 118 119 119 if ( !is_single() && $share_vote_url_meta ) { 120 120 121 121 $share_vote_url = $share_vote_url_meta; 122 122 123 123 }else{ 124 124 125 125 $post_url = apply_filters('social_counters_post_url_meneame', get_permalink($_post->ID), $_post); 126 126 $post_url = $post_url; //urlencode($post_url); 127 127 128 128 $url_request = 'http://meneame.net/api/url.php?url={url}'; 129 129 $url_request = str_replace('{url}', $post_url, $url_request); 130 131 $data = trim(wp_remote_retrieve_body(wp_remote_get($url_request )));132 130 131 $data = trim(wp_remote_retrieve_body(wp_remote_get($url_request, array('timeout' => 1,)))); 132 133 133 if ( !empty($data) ) { 134 134 $data_lines = explode("\n", trim($data)); 135 135 136 136 if ( sizeof($data_lines) >= 1 ) { 137 137 138 138 foreach ( $data_lines as $data_line ) { 139 139 $line = explode(" ", trim($data_line)); … … 143 143 } 144 144 } 145 145 146 146 } 147 147 } 148 148 149 149 update_post_meta($_post->ID, '_shared_vote_url_meneame', $share_vote_url); 150 150 151 151 } 152 152 153 153 return $share_vote_url; 154 154 } 155 155 156 156 return "#ERROR"; 157 157 } -
social-counters/trunk/counters/tuenti.php
r391639 r1380986 12 12 function social_counters__admin_list__tuenti( $codeExit = '', $postparam = false ) { 13 13 global $post; 14 14 15 15 $_post = ( $postparam ) ? $postparam : $post; 16 16 17 17 if ( $_post ) { 18 18 return $codeExit . '<div class="misc-pub-section">Tuenti: ' . social_counter__get('tuenti', $_post, false) . '</div>'; 19 19 } 20 20 21 21 return $codeExit; 22 22 … … 27 27 function social_counter__get__tuenti( $codeExit = '', $postparam = false, $linked = true ) { 28 28 global $post; 29 29 30 30 $_post = ( $postparam ) ? $postparam : $post; 31 31 32 32 $shared_counter = ''; // <span>'.$shared_counter.'</span>'; 33 33 $shared_classes = 'social-counter social-counter-'. __('lang-dir', 'social-counters') .'-tuenti'; … … 38 38 $shared_counter = '<span class="'. $shared_classes .'">'.$shared_counter.'</span>'; 39 39 } 40 40 41 41 return $codeExit . $shared_counter; 42 42 } … … 46 46 function social_counters__share_url__tuenti( $postparam = false ) { 47 47 global $post; 48 48 49 49 $_post = ( $postparam ) ? $postparam : $post; 50 50 51 51 if ( $_post ) { 52 52 53 53 $url_string = apply_filters('social_counters_share_url_tuenti', get_permalink($_post->ID), $_post); 54 54 55 55 $post_title = apply_filters('social_counters__the_title', get_the_title($_post->ID)); 56 56 $post_title = substr($post_title, 0, 140 - ( 3 + ( strlen($pre_string) + strlen($url_string) + strlen($login_string) ) )); 57 58 $service_url = 'http://www.tuenti.com/share?url=' . urlencode($url_string); 59 57 58 $service_url = 'http://www.tuenti.com/share'; 59 $service_url = add_query_arg('url', $url_string, $service_url); 60 60 61 return $service_url; 61 62 } 62 63 63 64 return "#ERROR"; 64 65 } -
social-counters/trunk/counters/twitter.php
r532303 r1380986 12 12 function social_counters__admin_list__twitter( $codeExit = '', $postparam = false ) { 13 13 global $post; 14 14 15 15 $_post = ( $postparam ) ? $postparam : $post; 16 16 17 17 if ( $_post ) { 18 18 return $codeExit . '<div class="misc-pub-section">Twitter: ' . social_counter__get('twitter', $_post, false) . '</div>'; 19 19 } 20 20 21 21 return $codeExit; 22 22 … … 27 27 function social_counter__get__twitter( $codeExit = '', $postparam = false, $linked = true ) { 28 28 global $post; 29 29 30 30 $_post = ( $postparam ) ? $postparam : $post; 31 31 32 32 $shared_counter = 0; 33 33 34 34 if ( $_post ) { 35 35 36 36 $share_counter_meta = get_post_meta($_post->ID, '_shared_counter_twitter_v2', true); 37 38 if ( !is_single() && $share_counter_meta !== false ) {39 37 38 if ( !is_single() && !empty($share_counter_meta) && $share_counter_meta !== false ) { 39 40 40 $shared_counter = $share_counter_meta; 41 41 42 42 }else{ 43 43 44 44 $post_url = apply_filters('social_counters_post_url_twitter', get_permalink($_post->ID), $_post); 45 45 $post_url = urlencode($post_url); 46 46 47 47 // Search in TWEETMEME 48 48 // $shared_counter = social_counters__twitter__tweetmeme($post_url, $shared_counter); 49 49 // Search in TWITTER 50 50 $shared_counter = social_counters__twitter__twitter($post_url, $shared_counter); 51 51 52 52 if ( $share_counter_meta ) { 53 53 $shared_counter = ( is_numeric($shared_counter) && $shared_counter >= $share_counter_meta ) ? $shared_counter : $share_counter_meta; 54 54 } 55 55 56 56 update_post_meta($_post->ID, '_shared_counter_twitter_v2', $shared_counter); 57 57 } 58 58 } 59 59 60 60 $shared_counter = ( empty($shared_counter) ) ? 0 : $shared_counter; 61 61 62 62 $shared_counter = '<span>'.$shared_counter.'</span>'; 63 63 $shared_classes = 'social-counter social-counter-'. __('lang-dir', 'social-counters') .'-twitter'; … … 68 68 $shared_counter = '<span class="'. $shared_classes .'">'.$shared_counter.'</span>'; 69 69 } 70 70 71 71 return $codeExit . $shared_counter; 72 72 } … … 76 76 function social_counters__share_url__twitter( $postparam = false ) { 77 77 global $post; 78 78 79 79 $_post = ( $postparam ) ? $postparam : $post; 80 80 81 81 if ( $_post ) { 82 82 83 83 $pre_string = 'RT'; 84 84 $login_string = '@'. social_counters__twitter_user() .''; 85 85 $url_string = apply_filters('social_counters_share_url_twitter', get_permalink($_post->ID), $_post); 86 86 87 87 $post_title = apply_filters('social_counters__the_title', get_the_title($_post->ID)); 88 88 $post_title = substr($post_title, 0, 140 - ( 3 + ( strlen($pre_string) + strlen($url_string) + strlen($login_string) ) )); 89 90 $twitter_url = 'http://twitter.com/intent/tweet?text=' . urlencode($pre_string . ' ' . $login_string . ' ' . $post_title . ' ' .$url_string); 91 89 90 $twitter_url = 'http://twitter.com/intent/tweet'; 91 $twitter_url = add_query_arg('text', $pre_string . ' ' . $login_string . ' ' . $post_title . ' ' .$url_string, $twitter_url); 92 92 93 return $twitter_url; 93 94 } 94 95 95 96 return "#ERROR"; 96 97 } … … 99 100 function social_counters__twitter_user() { 100 101 $twitter_user = ''; 101 102 102 103 if ( defined('SOCIAL_COUNTER__TWITTER_USER') ) 103 104 $twitter_user = SOCIAL_COUNTER__TWITTER_USER; 104 105 105 106 if ( empty($twitter_user) && defined('SOCIAL_COUNTER_TWITTER_USER') ) 106 107 $twitter_user = SOCIAL_COUNTER_TWITTER_USER; 107 108 108 109 return $twitter_user; 109 110 } … … 121 122 122 123 function social_counters__twitter__tweetmeme( $post_url = '', $shared_counter = 0 ) { 123 124 124 125 if ( !empty($post_url) ) { 125 126 126 127 $url_request_params = '?url={url}'; 127 128 $url_request_params = str_replace('{url}', $post_url, $url_request_params); 128 129 129 130 $url_request = 'http://api.tweetmeme.com/url_info.php'; 130 131 $url_request .= $url_request_params; 131 132 $data = wp_remote_retrieve_body(wp_remote_get($url_request ));133 132 133 $data = wp_remote_retrieve_body(wp_remote_get($url_request, array('timeout' => 1))); 134 134 135 $url_request_params = ''; 135 136 if ( !empty($data) ) { 136 137 $data = unserialize($data); 137 138 138 139 if ( isset($data['status']) && $data['status'] == 'failure' ) { 139 140 $shared_counter = '<em title="'. $data['comment'] .'">0</em>'; … … 142 143 } 143 144 } 144 145 145 146 } 146 147 147 148 return $shared_counter; 148 149 } 149 150 150 151 function social_counters__twitter__twitter( $post_url = '', $shared_counter = 0 ) { 151 152 152 153 if ( !empty($post_url) ) { 153 154 154 155 $url_request_params = '?url={url}'; 155 156 $url_request_params = str_replace('{url}', $post_url, $url_request_params); 156 157 157 158 $url_request = 'http://urls.api.twitter.com/1/urls/count.json'; 158 159 $url_request .= $url_request_params; 159 160 $data = wp_remote_retrieve_body(wp_remote_get($url_request ));161 160 161 $data = wp_remote_retrieve_body(wp_remote_get($url_request, array('timeout' => 1,))); 162 162 163 $url_request_params = ''; 163 164 if ( !empty($data) && function_exists('json_decode') ) { 164 165 $data = json_decode($data); 165 166 166 167 if ( isset($data->count) && $data->count > $shared_counter ) 167 168 $shared_counter = $data->count; 168 169 } 169 170 170 171 } 171 172 172 173 return $shared_counter; 173 174 } -
social-counters/trunk/readme.txt
r532303 r1380986 3 3 Tags: social, social bookmarking, counter, twitter, facebook, google, meneame, tuenti, bitacoras.com 4 4 Requires at least: 2.9 5 Tested up to: 3.3.16 Stable tag: 2.2. 85 Tested up to: 4.4.1 6 Stable tag: 2.2.9 7 7 8 8 It allows to place social sharing links with counters (if available) to the most popular social networks: Menéame,Twitter,Facebook,... … … 51 51 52 52 == Changelog == 53 54 = 2.2.9 = 55 * Reduced requests timeout to 1 second. 56 * Various modifications. 53 57 54 58 = 2.2.8 = -
social-counters/trunk/social-counters.php
r532303 r1380986 4 4 Plugin URI: http://blogestudio.com/plugin/social-counters/ 5 5 Description: Get Counters from Social Webs 6 Version: 2.2. 86 Version: 2.2.9 7 7 Author: Alejandro Carravedo (Blogestudio) 8 8 Author URI: http://blogestudio.com … … 11 11 1.1.0 - Solucionado error con la cache de contador 12 12 - Solucionado error de conexion con Meneame. 13 13 14 14 1.2.0 - Cambiado sistema de cuento de Twitter por Tweetmeme, el primero obvia todo lo que no sea la URL concreta. (15.06.2010) 15 15 - Anyadida funcion "social_counter__twitter__login_string" para cambiar el usuario de ReTweet. 16 16 17 17 2.0.0 - Reprogramacion del plugin para funcionar por filtros y acciones, por ahora. 18 18 - ToDo: Funcionamiento por clases!! … … 22 22 2.1.0 - Anadido parametro para enviar el objecto POST a las funciones "the_" (postparam). 23 23 - Cambiado sistema de "share" en Twitter 24 24 25 25 2.1.1 - Cambiado sistema de contador en Twitter, ahora se usa el propio Twitter, no TweetMeMe 26 26 - Reparado contador de Facebook, ahora funciona con el Graph API, han quitado de sopetón los datos del REST API. 27 27 28 28 2.2.0 - Anadido el contador de "Bitacoras" 29 29 - Anadido el contador de "LinkedIn" … … 38 38 2.2.4 - Solucionado error con las URLs internas del plugin y el Domain Mapping 39 39 - Solucionado error con WPML y orden de carga del idioma. 40 40 41 41 2.2.5 - Cambio de version en el README!! 42 42 … … 46 46 47 47 2.2.8 - Cambio en el sistema de caché para acelerar la carga de las páginas. 48 48 49 2.2.9 - Reducidos los timeouts de las solicitudes a "1". 50 49 51 *** Configuraciones *** 50 52 SOCIAL_COUNTER__LOAD_CSS : Ponerlo a FALSE para que no cargue el estilo por defecto. … … 100 102 /* CSS Load */ 101 103 function social_counters__init() { 102 104 103 105 // Cargamos los idiomas 104 106 load_plugin_textdomain('social-counters', '', dirname( plugin_basename( __FILE__ ) ) .'/langs/'); 105 107 106 108 if ( SOCIAL_COUNTER__LOAD_CSS ) 107 109 wp_enqueue_style( 'social-counters', social_counters__url() .'css/social-counters.css', array(), '2.2.3', 'screen'); 108 110 109 111 } 110 112 add_action('init', 'social_counters__init'); … … 124 126 125 127 function the_social_counters__get( $social_counters = array(), $postparam = false ) { 126 128 127 129 $default_social_counters = apply_filters('social_counter__defaults', array()); 128 129 130 131 130 132 $social_counters = ( sizeof($social_counters) > 0 ) ? $social_counters : $default_social_counters; 131 133 132 134 $codeExit = ''; 133 135 foreach ( $social_counters as $social_counter ) { 134 136 $codeExit .= social_counter__get($social_counter, $postparam); 135 137 } 136 138 137 139 $mini_counters = ( defined('SOCIAL_COUNTER__LOAD_CSS_SMALL') ) ? SOCIAL_COUNTER__LOAD_CSS_SMALL : false; 138 140 139 141 $codeExit = ( !empty($codeExit) ) ? '<div class="social-counters'. ( $mini_counters ? ' social-counters-mini' : '' ) .'">'. $codeExit .'</div>' : ''; 140 142 141 143 return $codeExit; 142 144 } … … 149 151 150 152 function social_counter__get( $social_counter = '', $postparam = false, $linked = true ) { 151 153 152 154 $codeExit = apply_filters('social_counter__get__'.$social_counter, '', $postparam, $linked); 153 155 $codeExit = ( empty($codeExit) ) ? false : $codeExit; 154 156 155 157 return $codeExit; 156 158 } … … 158 160 159 161 function social_counters__the_title__filter( $title ) { 160 162 161 163 $title = str_replace( 162 164 array( … … 167 169 '"', // " 168 170 '&quot;', // " 169 171 170 172 '…' // ... 171 173 ), … … 177 179 '"', 178 180 '"', 179 181 180 182 '...', 181 183 ), 182 184 $title 183 185 ); 184 186 185 187 return $title; 186 188 }
Note: See TracChangeset
for help on using the changeset viewer.