コード例 #1
0
ファイル: frontend_only.inc.php プロジェクト: nerdhaus/avse
/**
 * Shortcode to show the thumbnail for a website.
 * 
 * Example with link for thumbnail: 
 * [stwthumb link="true"]http://www.shrinktheweb.com[/stwthumb]
 * 
 * Example with just thumbnail:
 * [stwthumb]http://www.wpdoctors.co.uk[/stwthumb]
 * 
 */
function STWWT_shortcode_showThumbnail($atts, $content)
{
    extract(shortcode_atts(array('size' => '', 'link' => '', 'full_length' => ''), $atts));
    // If link="true" appears in the shortcode, then add the link too.
    $showLink = false;
    if ($link == 'true') {
        $showLink = true;
    }
    // Check for a full length parameter. Completely ignore the parameter
    // if we don't have access to that parameter.
    $showFullLength = false;
    if ($full_length && STWWT_account_featuredAllowed('embedded_pro_full_length')) {
        $full_length = strtolower($full_length);
        if ($full_length == 'true') {
            $showFullLength = 'full';
        } else {
            $showFullLength = 'normal';
            // Allows for situation where user does not want a full length
        }
    }
    return STWWT_thumbnail_createThumbnail($content, $showLink, $size, $showFullLength);
}
コード例 #2
0
ファイル: stw-wp-thumbnails.php プロジェクト: nerdhaus/avse
/**
 * Creates a thumbnail for the specified URL and returns it.
 * 
 * @param String $url The URL of the thumbnail to create.
 * @param String $addLink If true, then add a clickable link to the thumbnail.
 * @param $showCustomSize If specified, then use the specified size for a thumbnail.
 * @param $showFullLength If 'full', show full length, if 'normal', force normal, if false, use default.
 * 
 * @return String The HTML for the thumbnail.
 */
function STWWT_thumbnail_createThumbnail($url, $addLink = false, $showCustomSize = false, $showFullLength = false)
{
    $allSettings = TidySettings_getSettings(STWWT_SETTINGS_KEY);
    $accountSettings = TidySettings_getSettings(STWWT_SETTINGS_KEY_ACCOUNT);
    // Common Defaults
    $args = array();
    $args["stwsize"] = $allSettings['stwwt_embedded_default_size'];
    $args["stwaccesskeyid"] = $allSettings['stwwt_access_id'];
    // Check if override for size is given.
    if ($showCustomSize) {
        // Check for standard STW size parameter (for free or paid accounts)
        $showCustomSize = strtolower($showCustomSize);
        if (in_array($showCustomSize, array('xlg', 'lg', 'sm', 'vsm', 'tny', 'mcr'))) {
            $args["stwsize"] = $showCustomSize;
        }
    }
    // #### Download and Cache Method
    // Settings for specifically fetching details
    $args["stwembed"] = 0;
    // We want XML data returned
    $args["stwu"] = $allSettings['stwwt_secret_id'];
    // Custom Size check - for numeric sizes
    if ($showCustomSize && preg_match('/^([0-9]+)$/', $showCustomSize, $matches) && STWWT_account_featuredAllowed('embedded_pro_custom_size')) {
        unset($args["stwsize"]);
        $args['stwxmax'] = $matches[1];
    }
    // ### Pro Settings (need to go before URL)
    // Inside page
    if ($allSettings['stwwt_embedded_pro_inside'] == 'enable' && STWWT_account_featuredAllowed('embedded_pro_inside')) {
        $args["stwinside"] = '1';
    }
    // Full Length feature allowed?
    if (STWWT_account_featuredAllowed('embedded_pro_full_length')) {
        if ('full' == $showFullLength || false == $showFullLength && 'enable' == $allSettings['stwwt_embedded_pro_full_length']) {
            $args["stwfull"] = '1';
            // Change size to match width of chosen thumbnail size.
            switch ($args['stwsize']) {
                case 'mcr':
                    $args['stwxmax'] = '75';
                    break;
                case 'tny':
                    $args['stwxmax'] = '90';
                    break;
                case 'vsm':
                    $args['stwxmax'] = '100';
                    break;
                case 'sm':
                    $args['stwxmax'] = '120';
                    break;
                case 'lg':
                    $args['stwxmax'] = '200';
                    break;
                case 'xlg':
                    $args['stwxmax'] = '320';
                    break;
            }
            unset($args['stwsize']);
            // Not needed if custom size
        }
    }
    // Quality
    if ($allSettings['stwwt_embedded_pro_custom_quality'] > 0 && STWWT_account_featuredAllowed('embedded_pro_custom_quality')) {
        $args["stwq"] = $allSettings['stwwt_embedded_pro_custom_quality'];
    }
    // URL (needs to be last)
    $args["stwurl"] = urlencode($url);
    // Finally do the request
    $thumbURL = STWWT_fetch_thumbnail($args);
    // Add link to website using the URL if requested
    if ($addLink) {
        // Class of nopopup is added to link to prevent auto mouseover from showing.
        $html = sprintf('<a href="%s" class="nopopup"><img src="%s" class="stw_thumbnail stw_embed" /></a>', $url, $thumbURL);
    } else {
        $html = sprintf('<img src="%s" class="stw_thumbnail stw_embed" />', $thumbURL);
    }
    return $html;
}
コード例 #3
0
ファイル: admin_only.inc.php プロジェクト: nerdhaus/avse
/**
 * Shows the usage guide on the documentation page.
 */
function STWWT_showPage_Documentation()
{
    $page = new PageBuilder(false);
    $page->showPageHeader(__('Shrink The Web - How to use the plugin', 'stwwt'), '70%');
    ?>
	
	<div class="stwwt_doc_wrap">
	<div class="stwwt_doc_title">
		<a name="embed"></a>	
		<h3>Embedded Screenshots - Shortcodes</h3>
	</div>
	<div id="stwwt_size_box">
		<p><b>Valid sizes for the size="xlg" option are:</b></p>
		<ul>
			<li><code>mcr</code> = Micro</li>
			<li><code>tny</code> = Tiny</li>
			<li><code>vsm</code> = Very Small</li>
			<li><code>sm</code> = Small</li>
			<li><code>lg</code> = Large</li>
			<li><code>xlg</code> = Extra Large</li>
		</ul>	
		</div>
		
		<p>The Shrink The Web embed code shows a thumbnail for any link you wrap in <code>[thumb][/thumb]</code> or <code>[stwthumb][/stwthumb]</code> tags. Any use of these tags is replaced
		with the thumbnail of the website included in the tags. </p>
		<p>The <code>link</code> attribute, which can be <code>true</code> (add a link) or <code>false</code> (don't add a link). The <code>size</code> attribute, which can <code>mcr</code>, <code>tny</code>, <code>vsm</code>, <code>sm</code>, <code>lg</code> or  <code>xlg</code>.</p>
		<dl class="stwwt_examples">
			<dt>1) [thumb]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail using the default thumbail size.</dd>
			
			<dt>2) [thumb link="true"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail using the default thumbail size , and also adds a link to the http://www.shrinktheweb.com URL. If you have a free account, the link is always added.</dd>
			
			<dt>3) [thumb link="true" size="xlg"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates an extra-large thumbnail <b>regardless</b> of the default thumbnail size. Also adds a link to the http://www.shrinktheweb.com URL. If you have a free account, the link is always added.</dd>
			
			<dt>4) [thumb size="sm"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a small thumbnail <b>regardless</b> of the default thumbnail size. </dd>
		</dl>
	</div>
	
	
	
	
	<div class="stwwt_doc_wrap">
	<div class="stwwt_doc_title">
		<a name="embed"></a>	
		<h3>Pro Feature - Full-Length Screenshots</h3>
	</div>
	
	<?php 
    if (STWWT_account_featuredAllowed('embedded_pro_full_length')) {
        ?>
		
		<p>The full length capture feature uses the <code>full_length</code> attribute, which can be <code>true</code> or <code>false</code>. This attribute works with any of the other attributes on this page. Here are some examples:</p>  
		<dl class="stwwt_examples">
			<dt>1) [thumb full_length="true"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail using the default thumbail size, but forces the display of a <b>full length</b> screenshot thumbnail even if the full-length setting is disabled globally.</dd>
			
			<dt>2) [thumb link="true" full_length="true"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail using the default thumbail size, as a full length thumbnail, and also adds a link to the http://www.shrinktheweb.com URL.</dd>
			
			<dt>3) [thumb full_length="false"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail using the default thumbail size, but forces the display of a <b>normal length</b> screenshot thumbnail even if the full-length setting is enabled globally.</dd>
			
			<dt>4) [thumb size="xlg" full_length="true"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates an extra large width thumbnail and forces the display of a <b>full length</b> screenshot thumbnail even if the full-length setting is disabled globally.</dd>
		</dl>
		
	<?php 
    } else {
        ?>
	
		<div class="stwwt_upgrade_required"><?php 
        echo STWWT_FEATURE_UPGRADE;
        ?>
</div>
	<?php 
    }
    ?>
	</div>
	
	
	
	
	<div class="stwwt_doc_wrap">
	<div class="stwwt_doc_title">
		<a name="embed"></a>	
		<h3>Pro Feature - Custom Size Screenshots</h3>
	</div>
	
	<?php 
    if (STWWT_account_featuredAllowed('embedded_pro_custom_size')) {
        ?>
		
		<p>The custom-size feature uses the <code>size</code> attribute, which can be  <code>mcr</code>,  <code>tny</code>,  <code>vsm</code>,  <code>sm</code>,  <code>lg</code>,  <code>xlg</code>, or a number e.g.  <code>500</code> or  <code>230</code>. This attribute works with any of the other attributes on this page. Here are some examples:</p>  
		<dl class="stwwt_examples">
			<dt>1) [thumb size="600" ]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail <b>600 pixels wide</b>, regardless of the global thumbnail size.</dd>
			
			<dt>2) [thumb size="340" ]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail <b>340 pixels wide</b>, regardless of the global thumbnail size.</dd>			
			
			<dt>3) [thumb]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail using the default thumbail size.</dd>
			
			<dt>4) [thumb size="lg"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail using the large thumbail size, regardless of the global thumbnail size.</dd>
			
			<dt>5) [thumb size="340"  link="true"]http://www.shrinktheweb.com[/thumb]</dt>
			<dd>Creates a thumbnail <b>340 pixels wide</b> and also adds a link to the http://www.shrinktheweb.com URL.</dd>
		</dl>
		
	<?php 
    } else {
        ?>
	
		<div class="stwwt_upgrade_required"><?php 
        echo STWWT_FEATURE_UPGRADE;
        ?>
</div>
	<?php 
    }
    ?>
	</div>

	
	<?php 
    $page->showPageFooter();
}