function wpcom_infinite_scroll_custom_credits($credit)
{
    if (function_exists('wpcom_is_vip') && wpcom_is_vip()) {
        $credit = sprintf(__('Powered by <a href="%s" rel="generator">WordPress.com VIP</a>'), 'http://vip.wordpress.com?ref=is-footer');
    }
    return $credit;
}
 private function is_vip()
 {
     return function_exists('wpcom_is_vip') && wpcom_is_vip();
 }
 function load_theme_functions()
 {
     // bail if we've done this already (can happen when calling /batch endpoint)
     if (defined('REST_API_THEME_FUNCTIONS_LOADED')) {
         return;
     }
     define('REST_API_THEME_FUNCTIONS_LOADED', true);
     // the theme info we care about is found either within functions.php or one of the jetpack files.
     $function_files = array('/functions.php', '/inc/jetpack.compat.php', '/inc/jetpack.php', '/includes/jetpack.compat.php');
     $copy_dirs = array(get_template_directory());
     if (wpcom_is_vip()) {
         $copy_dirs[] = WP_CONTENT_DIR . '/themes/vip/plugins/';
     }
     // Is this a child theme? Load the child theme's functions file.
     if (get_stylesheet_directory() !== get_template_directory() && wpcom_is_child_theme()) {
         foreach ($function_files as $function_file) {
             if (file_exists(get_stylesheet_directory() . $function_file)) {
                 require_once get_stylesheet_directory() . $function_file;
             }
         }
         $copy_dirs[] = get_stylesheet_directory();
     }
     foreach ($function_files as $function_file) {
         if (file_exists(get_template_directory() . $function_file)) {
             require_once get_template_directory() . $function_file;
         }
     }
     // add inc/wpcom.php and/or includes/wpcom.php
     wpcom_load_theme_compat_file();
     // since the stuff we care about (CPTS, post formats, are usually on setup or init hooks, we want to load those)
     $this->copy_hooks('after_setup_theme', 'restapi_theme_after_setup_theme', $copy_dirs);
     /**
      * Fires functions hooked onto `after_setup_theme` by the theme for the purpose of the REST API.
      *
      * The REST API does not load the theme when processing requests.
      * To enable theme-based functionality, the API will load the '/functions.php',
      * '/inc/jetpack.compat.php', '/inc/jetpack.php', '/includes/jetpack.compat.php files
      * of the theme (parent and child) and copy functions hooked onto 'after_setup_theme' within those files.
      *
      * @module json-api
      *
      * @since 3.2.0
      */
     do_action('restapi_theme_after_setup_theme');
     $this->copy_hooks('init', 'restapi_theme_init', $copy_dirs);
     /**
      * Fires functions hooked onto `init` by the theme for the purpose of the REST API.
      *
      * The REST API does not load the theme when processing requests.
      * To enable theme-based functionality, the API will load the '/functions.php',
      * '/inc/jetpack.compat.php', '/inc/jetpack.php', '/includes/jetpack.compat.php files
      * of the theme (parent and child) and copy functions hooked onto 'init' within those files.
      *
      * @module json-api
      *
      * @since 3.2.0
      */
     do_action('restapi_theme_init');
 }
/**
 * Clear the sitemap cache when a sitemap action has changed
 * Add a job to the pings queue to send out update notifications
 *
 * @param int $post_id unique post identifier. not used.
 */
function sitemap_handle_update($post_id)
{
    if (defined('WPCOM_SKIP_DEFAULT_SITEMAP') && WPCOM_SKIP_DEFAULT_SITEMAP) {
        return;
    }
    global $current_blog;
    wp_cache_delete(sitemap_cache_key(), 'sitemap');
    if (defined('WP_IMPORTING') && WP_IMPORTING) {
        return;
    }
    if (!function_exists('queue_pings_job')) {
        return;
    }
    $data = new stdClass();
    $data->sitemap_uri = sitemap_uri();
    $data->sitemap_endpoints = sitemap_endpoints();
    $data->origin_ip = $_SERVER['REMOTE_ADDR'];
    $data->blog_id = $current_blog->blog_id;
    $data->post_id = $post_id;
    queue_pings_job($data, 'sitemap', (int) wpcom_is_vip(), 2);
}
/**
 * Returns the URL to an image resized and cropped to the given dimensions.
 *
 * You can use this image URL directly -- it's cached and such by our servers.
 * Please use this function to generate the URL rather than doing it yourself as
 * this function uses staticize_subdomain() makes it serve off our CDN network.
 *
 * Somewhat contrary to the function's name, it can be used for ANY image URL, hosted by us or not.
 * So even though it says "remote", you can use it for attachments hosted by us, etc.
 *
 * @link http://vip.wordpress.com/documentation/image-resizing-and-cropping/ Image Resizing And Cropping
 * @param string $url The raw URL to the image (URLs that redirect are currently not supported with the exception of http://foobar.wordpress.com/files/ type URLs)
 * @param int $width The desired width of the final image
 * @param int $height The desired height of the final image
 * @param bool $escape Optional. If true (the default), the URL will be run through esc_url(). Set this to false if you need the raw URL.
 * @return string
 */
function wpcom_vip_get_resized_remote_image_url($url, $width, $height, $escape = true)
{
    $width = (int) $width;
    $height = (int) $height;
    if (!function_exists('wpcom_is_vip') || !wpcom_is_vip()) {
        return $escape ? esc_url($url) : $url;
    }
    // Photon doesn't support redirects, so help it out by doing http://foobar.wordpress.com/files/ to http://foobar.files.wordpress.com/
    if (function_exists('new_file_urls')) {
        $url = new_file_urls($url);
    }
    $thumburl = jetpack_photon_url($url, array('resize' => array($width, $height)));
    return $escape ? esc_url($thumburl) : $thumburl;
}
 /**
  * Are we on WordPress.com VIP or somewhere else?
  *
  * Not everyone is using the new loader yet (vip-init.php) so this checks
  * both the new method (constant) and the legacy method (function).
  *
  * @return bool True if on WP.com VIP, false if not.
  */
 public function is_wpcom_vip()
 {
     return defined('WPCOM_IS_VIP_ENV') && WPCOM_IS_VIP_ENV || function_exists('wpcom_is_vip') && wpcom_is_vip();
 }
 public static function get_http_api()
 {
     if (function_exists('wpcom_is_vip') && wpcom_is_vip()) {
         $lift_http = new Lift_HTTP_WP_VIP();
     } else {
         $lift_http = new Lift_HTTP_WP();
     }
     return $lift_http;
 }
 static function isWPcom()
 {
     return isset($_GET['gettyTestWPcomIsVip']) || function_exists('wpcom_is_vip') && wpcom_is_vip();
 }
Example #9
0
 /**
  * Detects if the site is being accesed by a supported device and acts accordingly
  *
  * @return void
  * @author Armando Sosa
  */
 function setup()
 {
     add_filter('admin_menu', array($this, 'createMenu'));
     $this->setThemeOptions();
     $is_disabled = is_padpressed_disabled();
     if ($is_disabled) {
         return;
     }
     if (isset($_GET['padpressed_opt']) && $_GET['padpressed_opt'] === 'nay') {
         $this->optout = true;
     }
     if (!is_admin() && $this->isMobileAndSupported() && !$this->optout || $this->development) {
         $this->isMobile = true;
         $themePath = PADPRESS_PLUGIN_DIR . '/themes/' . $this->theme;
         if (!defined('PADPRESS_THEME_DIR')) {
             define('PADPRESS_THEME_DIR', $themePath);
         }
         if (function_exists('wpcom_is_vip') && wpcom_is_vip()) {
             require_once get_template_directory() . '/functions.php';
         }
         if (file_exists($themePath)) {
             add_filter('theme_root', array($this, 'themeRoot'));
             add_filter('theme_root_uri', array($this, 'themeRootUrl'));
             add_filter('template', array($this, 'setTheme'));
             add_filter('stylesheet', array($this, 'setStylesheet'));
             add_filter('show_admin_bar', '__return_false');
         }
         // Disable Custom CSS
         remove_action('init', 'safecss_init');
         remove_filter('stylesheet_uri', 'safecss_style_filter');
         // Disable Admin bar
         remove_action('init', 'wpcom_adminbar_init');
         remove_action('wp_footer', 'wpcom_adminbar_render', 1000);
         remove_action('wp_footer', 'admin_bar_query_debug_list');
         remove_action('wp_head', 'wpcom_adminbar_css');
     } else {
         add_filter('wp_head', 'hashbang_redirect');
     }
 }
    private function print_options_page($options, $plugin_integrations)
    {
        $default_encryption_key_warrning = '';
        if ($options['encryption_key'] == $this->shoutem_default_options['encryption_key']) {
            $default_encryption_key_warrning = '<p>*Currently, the default encryption key is set. Leaving default encryption key could lead to compromised security of site. Change encryption key!</p>';
        }
        ?>
			<div class="wrap">
  				<div id="icon-options-general" class="icon32"><br /></div>
  				<h2><?php 
        esc_html_e('Shoutem API Settings');
        ?>
</h2>
  				<script type="text/javascript">
  					//Tnx for password generator to: Xhanch Studio http://xhanch.com
  					function gen_numb(min, max){
		                return (Math.floor(Math.random() * (max - min)) + min);
		            }

		            function gen_chr(num, lwr, upr, oth, ext){
		                var num_chr = "0123456789";
		                var lwr_chr = "abcdefghijklmnopqrstuvwxyz";
		                var upr_chr = lwr_chr.toUpperCase();
		                var oth_chr = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
		                var sel_chr = ext;

		                if(num == true)
		                    sel_chr += num_chr;
		                if(lwr == true)
		                    sel_chr += lwr_chr;
		                if(upr == true)
		                    sel_chr += upr_chr;
		                if(oth == true)
		                    sel_chr += oth_chr;
		                return sel_chr.charAt(gen_numb(0, sel_chr.length));
		            }

		            function gen_pass(len, ext, bgn_num, bgn_lwr, bgn_upr, bgn_oth,
		                flw_num, flw_lwr, flw_upr, flw_oth){
		                var res = "";

		                if(len > 0){
		                    res += gen_chr(bgn_num, bgn_lwr, bgn_upr, bgn_oth, ext);
		                    for(var i=1;i<len;i++)
		                        res += gen_chr(flw_num, flw_lwr, flw_upr, flw_oth, ext);
		                    return res;
		                }
		            }
  					var generate_random_encryption_key_on_click = function() {
        					var encryption_key_element = document.getElementById('shoutem_api_encryption_key_input');
        					encryption_key_element.setAttribute('value',gen_pass(16,true,true,true,false,true,true,true,false));
        			}
  				</script>

    			<form action="options-general.php?page=shoutem-api" method="post">
    				<?php 
        wp_nonce_field('update-options');
        ?>
    				<table class="form-table">
      					<tr valign="top">
        				<th scope="row"><?php 
        esc_html_e('Shoutem api encryption key');
        ?>
</th>
        				<td><input type="text" id="shoutem_api_encryption_key_input" name="encryption_key" value="<?php 
        echo htmlentities($options['encryption_key']);
        ?>
" size="15" />
        				<input class="button-primary" type="button" name="generate_random_encryption_key" onClick="generate_random_encryption_key_on_click();" value="<?php 
        esc_attr_e('Generate');
        ?>
" />
        				</td>
        				<tr valign="top">
        				<th scope="row"><?php 
        esc_html_e('Cache expiration');
        ?>
Cache expiration</th>
        				<td><input type="text" id="shoutem_api_cache_expiration_input" name="cache_expiration" value="<?php 
        echo htmlentities($options['cache_expiration']);
        ?>
" size="15" />
        				<?php 
        esc_html_e('seconds (0 dissables caching)');
        ?>
        				</td>
        				<tr valign="top">
        				<th scope="row"><?php 
        esc_html_e('Lead image custom field regex');
        ?>
</th>
        				<td><input type="text" name="lead_img_custom_field_regex" value="<?php 
        echo htmlentities($options['lead_img_custom_field_regex']);
        ?>
" size="15" />
        				</tr>
        				<tr valign="top">
        				<th scope="row"><?php 
        esc_html_e('Include featured/thumbnail post image');
        ?>
</th>
        				<td>
        				<input type="hidden" name="include_featured_image" value="false" />
        				<input type="checkbox" name="include_featured_image" value="true" <?php 
        echo $options['include_featured_image'] ? "checked=\"yes\"" : "";
        ?>
 />
        				</td>
        				</tr>

        				<tr valign="top">
        				<th scope="row"><?php 
        esc_html_e('Comments provider');
        ?>
</th>
        				<td>
        				<input type="radio" name="comments_provider" value="wordpress" <?php 
        echo !$options['enable_fb_commentable'] && $options['enable_wp_commentable'] ? "checked" : "";
        ?>
> <?php 
        esc_html_e('Wordpress Comments');
        ?>
 <br />
        				<input type="radio" name="comments_provider" value="facebook" <?php 
        echo $options['enable_fb_commentable'] && !$options['enable_wp_commentable'] ? "checked" : "";
        ?>
> <?php 
        esc_html_e('Facebook Comments');
        ?>
 <br />
        				<input type="radio" name="comments_provider" value="wordpress_facebook" <?php 
        echo $options['enable_fb_commentable'] && $options['enable_wp_commentable'] ? "checked" : "";
        ?>
> <?php 
        esc_html_e('Facebook and Wordpress Comments');
        ?>
 <br />
        				</td>
        				</tr>

    				</table>
    				<?php 
        echo $default_encryption_key_warrning;
        ?>
    				<p class="submit">
				    	<input type="submit" class="button-primary" value="<?php 
        esc_attr_e('Save Changes');
        ?>
" />
				    </p>
    			</form>
    			<div class="clear"></div>
    			<?php 
        if (!function_exists('wpcom_is_vip') || !wpcom_is_vip()) {
            ?>
    			<h4><?php 
            esc_html_e('ShoutEm automatically integrates with the following plugins:');
            ?>
</h4>
    			<table class="widefat">
    				<thead>
    					<tr>
    						<th class="manage-column"><?php 
            esc_html_e('Plugin');
            ?>
</th>
    						<th class="manage-column"><?php 
            esc_html_e('Integration Status');
            ?>
</th>
    						<th class="manage-column"><?php 
            esc_html_e('Integration Description');
            ?>
</th>
    					</tr>
    				</thead>
    					<?php 
            foreach ($plugin_integrations as $plugin_integration) {
                ?>
    						<tr>
    							<td class="plugin-title">
    							<?php 
                if ($plugin_integration['plugin_link']) {
                    $link = esc_url($plugin_integration['plugin_link']);
                    echo "<a href=\"{$link}\" target=\"_blank\">" . htmlentities($plugin_integration['plugin_name']) . "</a>";
                } else {
                    echo htmlentities($plugin_integration['plugin_name']);
                }
                ?>
    							</td>
    							<td><?php 
                $plugin_integration['integration_ok'] ? esc_html_e('OK') : esc_html_e('Not Integrated, check if the plugin is installed and active');
                ?>
</td>
    							<td class="desc"><?php 
                echo htmlentities($plugin_integration['integration_desc']);
                ?>
</td>
    						</tr>
    					<?php 
            }
            ?>
    			</table>
	    		<?php 
        }
        ?>
    		</div>
		<?php 
    }