Changeset 2172087
- Timestamp:
- 10/12/2019 06:52:20 AM (6 years ago)
- Location:
- social-rocket/trunk
- Files:
-
- 6 edited
-
admin/css/admin.css (modified) (1 diff)
-
includes/class-social-rocket-background-process.php (modified) (4 diffs)
-
includes/class-social-rocket-cron.php (modified) (1 diff)
-
includes/class-social-rocket.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
-
social-rocket.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
social-rocket/trunk/admin/css/admin.css
r2147131 r2172087 1608 1608 border-radius: 2px; 1609 1609 display: inline-block; 1610 font-size: 1 5px;1610 font-size: 12px; 1611 1611 line-height: 38px; 1612 1612 cursor: pointer; 1613 white-space: nowrap; 1613 1614 width: 90%; 1614 1615 } 1615 1616 .social-rocket-settings-networks-selector .social-rocket-button i { 1617 font-size: 15px; 1616 1618 padding: 5px 5px 4px; 1617 1619 margin: 7px 5px; 1618 1620 vertical-align: middle; 1621 } 1622 @media (max-width: 1365px) and (min-width: 782px) { 1623 .social-rocket-settings-networks-selector { 1624 width: 33.33333%; 1625 } 1626 } 1627 @media (max-width: 782px) and (min-width: 480px) { 1628 .social-rocket-settings-networks-selector { 1629 width: 33.33333%; 1630 } 1631 } 1632 @media (max-width: 480px) { 1633 .social-rocket-settings-networks-selector { 1634 width: 50%; 1635 } 1619 1636 } 1620 1637 -
social-rocket/trunk/includes/class-social-rocket-background-process.php
r2147131 r2172087 85 85 $SR = Social_Rocket::get_instance(); 86 86 87 $master_throttle = apply_filters( 'social_rocket_master_throttle', 1 ); 88 87 89 // Actions to perform 88 90 switch ( $item['task'] ) { … … 106 108 if ( $now - $last < $throttle ) { 107 109 // too soon. save this for later 108 $master_throttle = apply_filters( 'social_rocket_master_throttle', 1 );109 110 sleep( $master_throttle ); 110 111 return $item; … … 116 117 $success = $SR->update_share_count( $network, $id, $type, $url, $force ); 117 118 118 if ( ! $success ) { 119 if ( $success ) { 120 // finished, remove the item from the queue 121 $item = false; 122 } else { 119 123 // something went wrong. try again later 124 sleep( $master_throttle ); 120 125 return $item; 121 126 } … … 125 130 } 126 131 127 return false; 132 $item = apply_filters( 'social_rocket_background_process_task', $item ); 133 134 return $item; 128 135 } 129 136 -
social-rocket/trunk/includes/class-social-rocket-cron.php
r2089576 r2172087 34 34 $idle = $SR->background_processor->is_idle(); 35 35 36 if ( class_exists( 'Social_Rocket_Pro' ) ) {37 $SRP = Social_Rocket_Pro::get_instance();38 if ( ! $SRP->background_processor->is_idle() ) {39 $idle = false;40 }41 }42 43 36 if ( ! $idle ) { 44 37 return; -
social-rocket/trunk/includes/class-social-rocket.php
r2147131 r2172087 2082 2082 2083 2083 // %title% 2084 if ( $type === 'post' ) { 2085 $title = html_entity_decode( the_title_attribute( 'echo=0' ) ); 2086 } else { 2087 $title = html_entity_decode( wp_title( null, false ) ); 2088 } 2084 $title = $this->get_title( $id, $type, $url ); 2089 2085 $output = str_replace( '%title%', rawurlencode( $title ), $output ); 2090 2086 … … 2097 2093 2098 2094 return apply_filters( 'social_rocket_get_share_url', $output, $id, $type, $url, $network, $scope ); 2095 } 2096 2097 2098 public function get_title( $id = 0, $type = 'post', $url = '' ) { 2099 2100 if ( ! $id ) { 2101 $loc = $this->where_we_at(); 2102 $id = $loc['id']; 2103 $type = $loc['type'];; 2104 $url = $loc['url']; 2105 } 2106 2107 $title = ''; 2108 2109 if ( $type === 'post' ) { 2110 2111 // 1) check for Social Rocket setting 2112 $title = get_post_meta( $id, 'social_rocket_og_title', true ); 2113 2114 // 2) if nothing, check Yoast 2115 if ( ! $title && class_exists( 'WPSEO_OpenGraph' ) ) { 2116 $title = get_post_meta( $id, '_yoast_wpseo_opengraph-title', true ); 2117 } 2118 2119 // 3) if still nothing, use the title 2120 if ( ! $title ) { 2121 $title = get_the_title( $id ); 2122 } 2123 2124 } elseif ( $type === 'term' ) { 2125 2126 // 1) check for Social Rocket setting 2127 $title = get_term_meta( $id, 'social_rocket_og_title', true ); 2128 2129 // 2) if nothing, check Yoast 2130 if ( ! $title && class_exists( 'WPSEO_OpenGraph' ) ) { 2131 $title = get_term_meta( $id, '_yoast_wpseo_opengraph-title', true ); 2132 } 2133 2134 // 3) if still nothing, use the title 2135 if ( ! $title ) { 2136 $title = get_the_archive_title(); 2137 } 2138 2139 } else { 2140 2141 $title = wp_get_document_title(); 2142 2143 } 2144 2145 return $title; 2099 2146 } 2100 2147 … … 2695 2742 } 2696 2743 return $content . $this->insert_inline_buttons_item_content( false ); 2744 } 2745 2746 2747 2748 /* 2749 * Determine if current request is for some non-countable WordPress thing, like 2750 * an autosave, block renderer call, some rest api nonsense, etc. 2751 * 2752 * @since 1.2.2 2753 * 2754 * @return boolean Whether current request is non-countable. 2755 */ 2756 public function is_non_countable_request() { 2757 2758 // is an admin page, or an ajax request 2759 if ( is_admin() ) { 2760 return true; 2761 } 2762 2763 // for rest api calls, the following is based on an idea from 2764 // https://wordpress.stackexchange.com/questions/221202/does-something-like-is-rest-exist, 2765 // with some modifications: 2766 /** 2767 * Case #1: After WP_REST_Request initialisation 2768 * Case #2: Support "plain" permalink settings 2769 * Case #3: It can happen that WP_Rewrite is not yet initialized, 2770 * so do this (wp-settings.php) 2771 * Case #4: URL Path begins with wp-json/ (your REST prefix) 2772 * Also supports WP installations in subfolders 2773 */ 2774 if ( 2775 // (#1) 2776 ( defined( 'REST_REQUEST' ) && REST_REQUEST ) 2777 || 2778 // (#2) 2779 ( 2780 isset( $_GET['rest_route'] ) 2781 && strpos( trim( $_GET['rest_route'], '\\/' ), rest_get_url_prefix(), 0 ) === 0 2782 ) 2783 ) { 2784 return true; 2785 } 2786 // (#3) 2787 global $wp_rewrite; 2788 if ( $wp_rewrite === null ) { 2789 $wp_rewrite = new WP_Rewrite(); 2790 } 2791 // (#4) 2792 $rest_url = wp_parse_url( trailingslashit( rest_url() ) ); 2793 $current_url = wp_parse_url( add_query_arg( array() ) ); 2794 if ( strpos( $current_url['path'], $rest_url['path'], 0 ) === 0 ) { 2795 return true; 2796 } 2797 2798 return false; 2697 2799 } 2698 2800 … … 3573 3675 $data = $this->get_count_data( $id, $type ); 3574 3676 3575 if ( ! $force && is_admin() ) {3677 if ( ! $force && $this->is_non_countable_request() ) { 3576 3678 // don't get counts for admin pages 3577 3679 return $data; … … 3986 4088 $url = $url[0]; 3987 4089 4090 // now there is one and only one query argument we will put back, because 4091 // of WP's "plain" permalinks structure: 4092 if ( isset( $_REQUEST['p'] ) ) { 4093 $url = $url . '?p=' . $_REQUEST['p']; 4094 } 4095 3988 4096 // now figure out where we are within the WP universe... 3989 4097 $result = array( -
social-rocket/trunk/readme.txt
r2147131 r2172087 6 6 Tested up to: 5.2 7 7 Requires PHP: 5.5 8 Stable tag: 1.2. 18 Stable tag: 1.2.2 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 83 83 84 84 == Changelog == 85 = 1.2.2 = 86 * FIX: issue with share URL when using "plain" permalinks. 87 * FIX: don't try to get counts for autosaves, rest api calls, etc. 88 * UPDATE: minor CSS update. 89 85 90 = 1.2.1 = 86 91 * UPDATE: increased popup window height -
social-rocket/trunk/social-rocket.php
r2147131 r2172087 3 3 * Plugin Name: Social Rocket 4 4 * Description: Social Sharing... to the Moon! 5 * Version: 1.2. 15 * Version: 1.2.2 6 6 * Author: Social Rocket 7 7 * Author URI: http://wpsocialrocket.com/ … … 17 17 } 18 18 19 define( 'SOCIAL_ROCKET_VERSION', '1.2. 1' );19 define( 'SOCIAL_ROCKET_VERSION', '1.2.2' ); 20 20 define( 'SOCIAL_ROCKET_DBVERSION', '3' ); 21 21 define( 'SOCIAL_ROCKET_PATH', plugin_dir_path( __FILE__ ) );
Note: See TracChangeset
for help on using the changeset viewer.