/** * Extracts the data from the raw XML into a useful Array that the plugin can use to * check which features are enabled or disabled. * * @param String $rawXML The raw XML from STW * @return Array The account details as an array. */ private function extractAccountDetails($rawXML) { $accountDetails = array(); $raw_Status = false; $raw_AccountLevel = false; // Use SimpleXML if we have it. if (!extension_loaded('simplexml')) { // Load XML into DOM object $dom = new DOMDocument(); $dom->loadXML($rawXML); $xml = simplexml_import_dom($dom); $xmlLayout = 'http://www.shrinktheweb.com/doc/stwacctresponse.xsd'; // Pull response codes from XML feed $raw_Status = (string) $xml->children($xmlLayout)->Response->Status->StatusCode; // Request valid or not $raw_AccountLevel = (string) $xml->children($xmlLayout)->Response->Account_Level->StatusCode; // Account level // Features $accountDetails['embedded_pro_inside'] = (string) $xml->children($xmlLayout)->Response->Inside_Pages->StatusCode; // Inside Pages $accountDetails['embedded_pro_full_length'] = (string) $xml->children($xmlLayout)->Response->Full_Length->StatusCode; // Full Length $accountDetails['embedded_pro_custom_size'] = (string) $xml->children($xmlLayout)->Response->Custom_Size->StatusCode; // Custom Size $accountDetails['embedded_pro_refresh_on_demand'] = (string) $xml->children($xmlLayout)->Response->Refresh_OnDemand->StatusCode; // Refresh On Demand $accountDetails['embedded_pro_custom_delay'] = (string) $xml->children($xmlLayout)->Response->Custom_Delay->StatusCode; // Custom Delay $accountDetails['embedded_pro_custom_quality'] = (string) $xml->children($xmlLayout)->Response->Custom_Quality->StatusCode; // Custom Quality $accountDetails['embedded_pro_custom_messages'] = (string) $xml->children($xmlLayout)->Response->Custom_Messages->StatusCode; // Custom Quality $accountDetails['embedded_pro_custom_resolution'] = (string) $xml->children($xmlLayout)->Response->Custom_Resolution->StatusCode; // Custom Resolution } else { $raw_Status = STWSettingsForm::xml_getLegacyResponse('Status', $rawXML); $raw_AccountLevel = STWSettingsForm::xml_getLegacyResponse('Account_Level', $rawXML); // Features $accountDetails['embedded_pro_inside'] = STWSettingsForm::xml_getLegacyResponse('Inside_Pages', $rawXML); // Inside Pages $accountDetails['embedded_pro_full_length'] = STWSettingsForm::xml_getLegacyResponse('Full_Length', $rawXML); // Full Length $accountDetails['embedded_pro_custom_size'] = STWSettingsForm::xml_getLegacyResponse('Custom_Size', $rawXML); // Custom Size $accountDetails['embedded_pro_refresh_on_demand'] = STWSettingsForm::xml_getLegacyResponse('Refresh_OnDemand', $rawXML); // Refresh On Demand $accountDetails['embedded_pro_custom_delay'] = STWSettingsForm::xml_getLegacyResponse('Custom_Delay', $rawXML); // Custom Delay $accountDetails['embedded_pro_custom_quality'] = STWSettingsForm::xml_getLegacyResponse('Custom_Quality', $rawXML); // Custom Quality $accountDetails['embedded_pro_custom_messages'] = STWSettingsForm::xml_getLegacyResponse('Custom_Messages', $rawXML); // Custom Quality $accountDetails['embedded_pro_custom_resolution'] = STWSettingsForm::xml_getLegacyResponse('Custom_Resolution', $rawXML); // Custom Resolution } // ### Convert all details into an actual validated array // Success or fail, plus account type. if ($raw_Status == 'Success') { // Convert account number to a string. switch ($raw_AccountLevel) { case 1: $accountDetails['account_type'] = 'basic'; break; case 2: $accountDetails['account_type'] = 'plus'; break; default: $accountDetails['account_type'] = 'free'; break; } } else { $accountDetails['account_type'] = 'invalid'; } // All done and standardised. return $accountDetails; }
/** * Function that shows the settings page. */ function STWWT_showPage_Settings() { /** * Constant: Documentation on how the mouseover bubble works. */ define('STWWT_DESC_MOUSEOVER', ' <p><img src="' . STWWT_plugin_getPluginPath() . 'img/stw_bubble_example.png" class="stwwt_settings_bubble_example"/> The Shrink The Web mouseover bubble shows a thumbnail of the website when hovered over a link on your WordPress website. This gives website visitors a preview of the link before they visit the website you link to.</p> <p>If the "<b>Automatic</b>" is selected below, all external links will show ShrinkTheWeb preview bubbles. Use <code>class="nopopup"</code> to disable popup bubble for a specific link.</p> <p>If the "<b>Manual</b>" method is selected below, then you choose which links get a preview bubble by adding <code>class="stwpopup"</code> to any link where you want to show them.</p> <div class="stwwt_clear"></div> '); /** * Constant: Documentation on how the embedded code works. */ define('STWWT_DESC_EMBEDDED', ' <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. <a href="admin.php?page=stwwt_documentation#embed">See some examples on the documentation page</a>. '); /** * Constant: Documentation on how the pro features work. */ define('STWWT_DESC_EMBEDDED_PRO', ' <p>The following features <b>require an upgraded account</b>. You can find more details on the <a href="https://www.shrinktheweb.com/auth/order-page" target="_blank">Shrink The Web Upgrade Page</a>.</p> <p>These settings are <b>global</b>, so they apply to <b>all thumbnails</b> on your website. Some of these settings have a per-thumbnail override, so please read <a href="admin.php?page=stwwt_documentation">the documentation</a> on how to apply these settings to specific thumbnails.</p> '); $page = new PageBuilder(true); $page->showPageHeader(__('Shrink The Web - Website Thumbnails - Settings', 'stwwt'), '70%'); $page->openPane('stw_settings_main', 'Thumbnail Settings'); $settingDetails = array('stwwt_break_main' => array('type' => 'break', 'html' => STWWT_forms_createBreakHTML('Account Settings')), 'stwwt_access_id' => array('label' => 'Access Key Id', 'type' => 'text', 'required' => true, 'cssclass' => 'stwwt_access_id', 'desc' => 'Your Shrink The Web <b>access</b> key. You can find this within your <a href="http://www.shrinktheweb.com/auth/stw-lobby" target="_blank">STW Account Details</a>.', 'validate' => array('type' => 'string', 'regexp' => '/^[A-Za-z0-9]{12,20}$/', 'error' => 'Your STW access key should only contain numbers and letters, and it\'s about 15 characters long.')), 'stwwt_secret_id' => array('label' => 'Secret Key Id', 'type' => 'text', 'required' => true, 'cssclass' => 'stwwt_access_id', 'desc' => 'Your Shrink The Web <b>secret</b> key. You can find this within your <a href="http://www.shrinktheweb.com/auth/stw-lobby" target="_blank">STW Account Details</a>.', 'validate' => array('type' => 'string', 'regexp' => '/^[A-Za-z0-9]{5,10}$/', 'error' => 'Your STW access key should only contain numbers and letters, and it\'s about 5 characters long.')), 'stwwt_account_level' => array('label' => 'Your STW Account Level', 'type' => 'custom', 'html' => false, 'desc' => 'If you change any aspects of your Shrink The Web account (such as upgrades), click on the <b>Save All Settings</b> button below to re-load what features you can use.'), 'stwwt_break_embedded' => array('type' => 'break', 'html' => STWWT_forms_createBreakHTML('Screenshot Settings', 'Save ALL Settings') . '<div class="stwwt_description">' . STWWT_DESC_EMBEDDED . '</div>'), 'stwwt_shortcode' => array('label' => 'Shortcode Syntax', 'type' => 'radio', 'data' => array('stwthumb' => '<b>[stwthumb]</b>', 'thumb' => '[thumb]'), 'default' => 'thumb'), 'stwwt_embedded_default_size' => array('label' => 'Default Screenshot Size', 'type' => 'select', 'data' => array('mcr' => 'Micro (75x56)', 'tny' => 'Tiny (90x68)', 'vsm' => 'Very Small (100x75)', 'sm' => 'Small (120x90)', 'lg' => 'Large (200x150)', 'xlg' => 'Extra Large (320x200)'), 'desc' => 'The size of the thumbnail shown by the thumbnail shortcode.', 'default' => 'lg'), 'stwwt_embedded_cache_length' => array('label' => 'Cache Length in Days', 'type' => 'select', 'data' => array('3' => '3 Days', '7' => '7 Days (recommended)', '10' => '10 Days', '14' => '14 Days', '21' => '21 Days', '30' => '30 Days'), 'desc' => 'How long you want to cache the thumbnails for.', 'account_level' => array('basic', 'plus'), 'account_denied_msg' => STWWT_ACCOUNT_UPGRADE, 'default' => 7), 'stwwt_break_embedded_pro' => array('type' => 'break', 'html' => STWWT_forms_createBreakHTML('PRO Feature Settings', 'Save ALL Settings') . '<div class="stwwt_description">' . STWWT_DESC_EMBEDDED_PRO . '</div>'), 'stwwt_embedded_pro_inside' => array('label' => 'Inside Pages Capture', 'type' => 'radio', 'data' => array('enable' => '<b>Enabled</b>', 'disable' => 'Disabled'), 'account_feature' => 'embedded_pro_inside', 'account_denied_msg' => STWWT_FEATURE_UPGRADE, 'default' => 'disable'), 'stwwt_embedded_pro_full_length' => array('label' => 'Full-length Page Captures', 'type' => 'radio', 'data' => array('enable' => '<b>Enabled</b>', 'disable' => 'Disabled'), 'account_feature' => 'embedded_pro_full_length', 'account_denied_msg' => STWWT_FEATURE_UPGRADE, 'default' => 'disable'), 'stwwt_embedded_pro_custom_quality' => array('label' => 'Custom Thumbnail Quality', 'type' => 'select', 'data' => STWWT_getQualityList(), 'desc' => 'If you want to customise the thumbnail image quality, then you can select a quality value between 1% and 100%. A value of <b>1% is the lowest quality</b>, and <b>100% is the best quality</b>.', 'account_feature' => 'embedded_pro_custom_quality', 'account_denied_msg' => STWWT_FEATURE_UPGRADE), 'stwwt_break_bubble' => array('type' => 'break', 'html' => STWWT_forms_createBreakHTML('Mouseover Bubble Settings', 'Save ALL Settings') . '<div class="stwwt_description">' . STWWT_DESC_MOUSEOVER . '</div>'), 'stwwt_bubble_method' => array('label' => 'Preview Bubbles Show Method', 'type' => 'select', 'data' => array('disable' => 'Disabled', 'automatic' => 'Automatic', 'manual' => 'Manual'), 'default' => 'disable'), 'stwwt_bubble_size' => array('label' => 'Preview Bubbles Thumbnail Size', 'type' => 'select', 'data' => array('sm' => 'Small (120x90)', 'lg' => 'Large (200x150)', 'xlg' => 'Extra Large (320x200)'), 'desc' => 'The size of the thumbnail shown in the preview bubble when a website visitor hovers over a link.', 'default' => 'lg')); // Show main settings form $settings = new STWSettingsForm($settingDetails, STWWT_SETTINGS_KEY, 'stwwt_settings'); $settings->setSaveButtonLabel('Save ALL Settings'); $settings->show(); // #### Support section $page->showPageMiddle('27%'); $yes = sprintf('<img src="%simg/icon_%s.png" />', STWWT_plugin_getPluginPath(), 'tick'); $no = sprintf('<img src="%simg/icon_%s.png" />', STWWT_plugin_getPluginPath(), 'cross'); // Feature check $accountSettings = TidySettings_getSettings(STWWT_SETTINGS_KEY_ACCOUNT); if ($accountSettings) { $page->openPane('stw_settings_support', 'Your Account Features'); ?> <table id="stwwt_feature_comp"> <thead> <tr> <th>Feature</th> <th>Your Account</th> </tr> </thead> <tbody> <?php // Now show the features unset($accountSettings['account_type']); // So we can just loop through settings. foreach ($accountSettings as $settingName => $enabled) { switch ($settingName) { case 'embedded_pro_inside': printf('<tr><th>%s</th><td>%s</td></tr>', 'Inside Pages Capture', 1 == $enabled ? $yes : $no); break; case 'embedded_pro_full_length': printf('<tr><th>%s</th><td>%s</td></tr>', 'Full Length Capture', 1 == $enabled ? $yes : $no); break; case 'embedded_pro_custom_size': printf('<tr><th>%s</th><td>%s</td></tr>', 'Custom Sizes', 1 == $enabled ? $yes : $no); break; case 'embedded_pro_custom_quality': printf('<tr><th>%s</th><td>%s</td></tr>', 'Custom Quality', 1 == $enabled ? $yes : $no); break; // Don't show feature // Don't show feature default: break; } } ?> </tbody> </table> <?php $page->closePane(); } // end of your feature list $page->openPane('stw_settings_support', 'Get a STW Account...'); ?> <div id="stwwt_signup"> <a href="http://www.shrinktheweb.com/user/register" target="_blank"> <img src="http://www.shrinktheweb.com/uploads/stw-banners/shrinktheweb-234x60.gif" alt="Website Thumbnail Provider" class="stwwt_settings_banner" width="234" height="60" alt="Register for a free account with Shrink The Web"> </a> <div class="stwwt_settings_banner_text"> <span>Need an account?</span> <a href="http://www.shrinktheweb.com/user/register" target="_blank" class="button-primary">Register for FREE</a> </div> </div> <?php $page->closePane(); // Support $page->openPane('stw_settings_support', 'Help & Support'); ?> <p>If you've got a problem with the plugin, please follow the following steps.</p> <ol> <li>Check the <a href="http://wordpress.org/extend/plugins/shrinktheweb-website-preview-plugin/faq/" target="_blank">Frequently Asked Questions</a> on WordPress.org. Your issue might already be answered or resolved.</li> <li>Check the <a href="http://wordpress.org/tags/shrinktheweb-website-preview-plugin?forum_id=10" target="_blank">plugin support forum</a> on WordPress.org. Someone might have had the same issue, and fixed it already.</li> <li>If you think the problem is a <b>plugin problem</b>, please raise the problem in the <a href="http://wordpress.org/tags/shrinktheweb-website-preview-plugin?forum_id=10" target="_blank">plugin support forum</a> on WordPress.org, including <b>as much detail as possible</b>, including any <b>error messages</b>.</li> <li>If you think the problem is a <b>STW or STW account problem</b>, please raise the problem in the <a href="http://www.shrinktheweb.com/forum" target="_blank">STW support forum</a>, including <b>as much detail as possible</b>, including any <b>error messages</b>.</li> </ol> <br/> <div class="stwwt_title">A word about the plugin authors...</div> <p>This plugin and the <a href="http://www.shrinktheweb.com" target="_blank">Shrink The Web</a> service has been developed and is provided by <a href="http://www.neosys.net/profile.htm" target="_blank">Neosys Consulting, Inc.</a></p> <?php $page->closePane(); $page->showPageFooter(); }