Plugin Directory

Changeset 450398


Ignore:
Timestamp:
10/12/2011 08:18:13 PM (14 years ago)
Author:
danielbwilson
Message:

Creating 1.5.0 beta

Location:
cleanprint-lt/branches/1.5.0b
Files:
1 added
3 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • cleanprint-lt/branches/1.5.0b/cleanprint.php

    r278480 r450398  
    44Plugin URI: http://www.formatdynamics.com
    55Description: Brings print functionality to your blog
    6 Version: 1.0.1
     6Version: 1.5.0
    77Author: Format Dynamics
    88Author URI: http://www.formatdynamics.com
     
    1212   include_once( ABSPATH . WPINC. '/class-http.php' );
    1313
    14 
    15 $singleColumnTemplate = 107;
    16 $doubleColumnTemplate = 108;
    17 $defaultDivId         = 2434;
    18 $cleanPrintCcgUrl     = 'http://cache-01.cleanprint.net/cp/ccg';
    19 $defaultLogoUrl       = 'http://cache-01.cleanprint.net/media/2434/1229027745109_699.jpg';
    20 $cleanPrintUrl        = 'http://cleanprint.net/cp/t';
    2114
    2215$pluginName           = 'cleanprint-lt';
     
    2720$defaultLocalBtnUrl   = plugins_url($defaultPrintBtnImg);
    2821$defaultVipBtnUrl     = get_bloginfo('template_directory') . '/plugins/' . $defaultPrintBtnImg;
    29 $defaultButtonUrl     = function_exists(wpcom_is_vip) ? $defaultVipBtnUrl : $defaultLocalBtnUrl;
    30 $cpProxyUrl           = 'index.php?' . $pluginAttr . '=' . $pluginName . '&' . $printAttr . '=1';
     22$publisherKey         = 'wpdefault15';
     23$cleanprintUrl        = 'http://cache-02.cleanprint.net/cpf/cleanprint';
     24$blackButtonUrl       = 'http://cache-02.cleanprint.net/media/pfviewer/images/CleanPrintBtn_black.png';
     25$whiteButtonUrl       = 'http://cache-02.cleanprint.net/media/pfviewer/images/CleanPrintBtn_white.png';
     26$opaqueButtonUrl      = 'http://cache-02.cleanprint.net/media/pfviewer/images/CleanPrintBtn_transparent.png';
     27$textButtonUrl        = 'http://cache-02.cleanprint.net/media/pfviewer/images/CleanPrintBtn_text.png';
    3128$readmeTxt            = $pluginName . '/readme.txt';
    3229$readmeLocalUrl       = plugins_url($readmeTxt);
     
    4138   global $pluginName;
    4239?>
    43     <script language="javascript">
    44        // Visually and functionally enables/disables the printSpec controls
    45        function enableIt(enabled) {
    46           var div   = document.getElementById("printSpecControls");
    47           var radio = document.getElementById("plugin_printSpecId");
    48 
    49           if (enabled) {
    50              div.style.color     = "";
    51              div.style.fontStyle = "";
    52              radio.disabled      = false;
    53           } else {
    54              div.style.color     = "gray";
    55              div.style.fontStyle = "italic";
    56              radio.disabled      = true;
    57           }
    58        }
    59 
    60        // Examines the activation key text field and enables/disables printSpec if set
    61        function checkIt(node) {
    62           enableIt(node.value.length==0);
    63        }
    64     </script>
    65     <div class="wrap">
    66         <div id="icon-options-general" class="icon32"><br /></div>
    67         <h2>CleanPrint Settings</h2>
    68         <form action="options.php" method="post">
    69             <?php settings_fields     ($optionsName); ?>
    70             <?php do_settings_sections($pluginName); ?>
    71 
    72             <input name="Submit" type="submit" value="Save Changes" />
    73         </form>
    74     </div>
     40    <div class="wrap">
     41        <div id="icon-options-general" class="icon32"><br /></div>
     42        <h2>CleanPrint Settings</h2>
     43        <form action="options.php" method="post">
     44            <?php settings_fields     ($optionsName); ?>
     45            <?php do_settings_sections($pluginName); ?>
     46
     47            <input name="Submit" type="submit" value="Save Changes" />
     48        </form>
     49    </div>
    7550<?php
    7651}
    77 
    78 
    79 // This function takes an activation key and returns an array of divisionID and printSpecID (or null)
    80 function parseActivationKey($theKey){
    81     $rv = explode("-", $theKey);
    82     if(count($rv) != 2){
    83         return null;
    84     }
    85     if(!is_numeric($rv[0]) || !is_numeric($rv[1])){
    86         return null;
    87     }
    88     return $rv;
    89 }
    90 
    9152
    9253
     
    9455function echoSectionText() {
    9556?>
    96     The CleanPrint plugin can be configured to print in either a single or double column format
    97     using a custom header and print button images.  If an activation key is used, the key
    98     itself defines the column format thus disabling the choice.
    99 
    100     <p>If a header or print button image URL is provided it should be fully qualified.  Header images
    101     should be 660x40 otherwise they will be altered to fit the page.  Print buttons should be small.
     57    Provided is the ability to use a variety of print buttons styles or your own button. 
     58    If Google Analytics is enabled for your site you also have the ability to track print activity (**The site must contain Google Analytic for tracking to function**). 
    10259<?php
    103 }
    104 
    105 
    106 // WP callback for handling the printSpec (single/double column) option
    107 function echoPrintSpecSetting() {
    108     global $optionsName;
    109     global $singleColumnTemplate;
    110     global $doubleColumnTemplate;
    111     global $defaultDivId;
    112    
    113     $options              = get_option($optionsName);
    114 
    115     $printSpecId          = $options['printSpecId'];
    116     $activationKey        = $options['activationKey'];
    117 
    118     $doubleChecked        = $printSpecId==$doubleColumnTemplate;
    119     $singleChecked        = !$doubleChecked;
    120     $hasActivation        = !empty($activationKey);
    121     $keys                 = parseActivationKey($activationKey);
    122     $divId                = empty($keys) ? $defaultDivId                                                  : $keys[0];
    123     $printSpecId          = empty($keys) ? $singleChecked ? $singleColumnTemplate : $doubleColumnTemplate : $keys[1];
    124 
    125     $disabledAttr         = $hasActivation ? "disabled='disabled'" : "";
    126     $singleCheckedAttr    = $singleChecked ? "checked='checked'"   : "";
    127     $doubleCheckedAttr    = $doubleChecked ? "checked='checked'"   : "";
    128 
    129     printf( "<div id='printSpecControls'>\n");
    130     printf( "<input type='radio' id='plugin_printSpecId' name='%s[printSpecId]' value='%s' %s %s />", $optionsName, $singleColumnTemplate, $disabledAttr, $singleCheckedAttr);
    131     printf( "Single Column<br />\n");
    132 
    133     printf( "<input type='radio' id='plugin_printSpecId' name='%s[printSpecId]' value='%s' %s %s />", $optionsName, $doubleColumnTemplate, $disabledAttr, $doubleCheckedAttr);
    134     printf( "Double Column<br />\n");
    135 
    136     printf( "</div>\n");
    137     printf( "<script>enableIt(%s)</script>\n", $hasActivation ? "false" : "true");
    138 }
    139 
    140 
    141 // WP callback for handling the Logo URL (default/custom) option
    142 function echoLogoUrlSetting() {
    143     global $optionsName;
    144     global $defaultLogoUrl;
    145    
    146     $options        = get_option($optionsName);
    147     $logoUrl        = $options['logoUrl'];
    148     $customChecked  = isset($logoUrl) && $logoUrl!=$defaultLogoUrl;
    149     $defaultChecked = !$customChecked;
    150     $defaultGravity = "center";
    151 
    152     printf( "<input type='radio' id='plugin_logoUrl' name='%s[logoUrl]' value='%s' %s />", $optionsName, $defaultLogoUrl, $defaultChecked?"checked='checked'":"");
    153     printf( "Default<br />\n");
    154 
    155     printf( "<input type='radio' id='plugin_logoUrl' name='%s[logoUrl]' value='custom' %s />", $optionsName, $customChecked ?"checked='checked'":"");
    156     printf( "Custom:");
    157     printf( "<input type='text'  id='plugin_logoUrl' name='%s[customLogo]' value='%s' /><br>\n", $optionsName, $customChecked ? $logoUrl : "");
    158     printf( "<img width='100%%' src='%s'>", $customChecked ? $logoUrl : $defaultLogoUrl);
    15960}
    16061
     
    16364function echoButtonUrlSetting() {
    16465    global $optionsName;
    165     global $defaultButtonUrl;
     66    global $blackButtonUrl;
     67    global $whiteButtonUrl;
     68    global $opaqueButtonUrl;
     69    global $textButtonUrl;
    16670    global $readmeUrl;
    16771   
    168     $options        = get_option($optionsName);
    169     $buttonUrl      = $options['buttonUrl'];
    170     $defaultChecked = !isset($buttonUrl) || $buttonUrl==$defaultButtonUrl;
    171     $noneChecked    =  isset($buttonUrl) && $buttonUrl=='none';
    172     $customChecked  = $defaultChecked==false && $noneChecked==false;
    173 
    174     printf( "<input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='%s' %s />", $optionsName, $defaultButtonUrl, $defaultChecked?"checked='checked'":"");
    175     printf( "Default<br />\n");
    176 
    177     printf( "<input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='none' %s />", $optionsName, $noneChecked ?"checked='checked'":"");
    178     printf( "Remove (see <a href='%s' target='_wpinst'>installation</a> instructions)<br />", $readmeUrl);
    179    
    180     printf( "<input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='custom'  %s />", $optionsName, $customChecked ?"checked='checked'":"");
    181     printf( "Custom:");
    182     printf( "<input type='' name='%s[customButton]' value='%s' /><br>\n", $optionsName, $customChecked ? $buttonUrl : "");
    183     printf( "<img src='%s' %s>",
    184         $customChecked ? $buttonUrl : $defaultButtonUrl,
    185         $noneChecked   ? "style='opacity:0.25;filter:alpha(opacity=25);'" : "");
    186 }
    187 
    188 
    189 // WP callback for handling the activation key option, setting an key disables the printSpec controls
    190 function echoActivationKeySetting() {
    191     global $optionsName;
    192    
    193     $options       = get_option($optionsName);
    194     $activationKey = $options['activationKey'];
    195 
    196     printf( "<input type='text' id='plugin_activationKey' name='%s[activationKey]' value='%s' onKeyUp='checkIt(this)' />", $optionsName, $activationKey);
    197 }
    198 
    199 
    200 function proxyCleanPrint() {
    201     global $cleanPrintUrl;
    202 
    203     // Remove PHP's double quoted strings
    204     $body = array();
    205     foreach ($_POST as $key=>$value) {
    206         $body[$key] = stripslashes($value);
    207     }
    208 
    209     $http   = new WP_Http();       
    210     $result = $http->request( $cleanPrintUrl, array('method'=>'POST', 'body'=>$body) );
    211        
    212     // Check for anything catastrophic.         
    213     if (isset($result->errors)) {
    214         header("HTTP/1.0 404 Script Error");
    215         error_log("proxyCleanUrl: ".$result->errors);
    216         return;
    217     }
    218 
    219     $response = $result['response'];
    220     $code     = $response['code'];
    221     $message  = $response['message'];   
    222        
    223     // Look for error responses
    224     if ($code != 200) {     
    225         header("HTTP/1.0 ". $code ." Script Error");
    226         error_log( sprintf("proxyCleanUrl: %d,%s", $code, $message) );
    227         return;
    228     }
    229        
    230     echo $result['body'];
    231 }
    232 
    233 
    234 function pluginParseRequest($wp) {
    235     global $pluginName;
    236     global $pluginAttr;
    237     global $printAttr;
    238    
    239     $params = $wp->query_vars;
    240     if (array_key_exists($pluginAttr,$params) && $params[$pluginAttr] == $pluginName) {
    241         // The only param we support is print
    242         if (array_key_exists($printAttr,$params)) {
    243             proxyCleanPrint();
    244             exit;
    245         }
    246     }
    247 }
    248 
     72    $options        = get_option($optionsName);
     73    $buttonUrl      = $options['buttonUrl'];
     74    $blackChecked   = !isset($buttonUrl) || $buttonUrl==$blackButtonUrl;
     75    $whiteChecked   =  $buttonUrl==$whiteButtonUrl;
     76    $opaqueChecked  =  $buttonUrl==$opaqueButtonUrl;
     77    $textChecked    =  $buttonUrl==$textButtonUrl;
     78    $removeChecked  =  $buttonUrl=='none';
     79    $customChecked  =  $blackChecked==false && $whiteChecked==false && $opaqueChecked==false && $textChecked==false && $removeChecked==false;
     80
     81    printf( "<input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='%s' %s />", $optionsName, $blackButtonUrl, ($blackChecked?"checked='checked'":""));
     82    printf( " <img src='$blackButtonUrl'><br />\n");
     83
     84    printf( "<input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='%s' %s />", $optionsName, $whiteButtonUrl, ($whiteChecked?"checked='checked'":""));
     85    printf( "<img src='$whiteButtonUrl'><br />\n");
     86
     87    printf( "<input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='%s' %s />", $optionsName, $opaqueButtonUrl, ($opaqueChecked?"checked='checked'":""));
     88    printf( " <img src='$opaqueButtonUrl'><br />\n");
     89
     90    printf( "<input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='%s' %s />", $optionsName, $textButtonUrl, ($textChecked?"checked='checked'":""));
     91    printf( " <img src='$textButtonUrl'><br />\n");
     92   
     93    printf( "<input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='custom' %s />", $optionsName, ($customChecked ?"checked='checked'":""));
     94    printf( "Custom:");
     95    printf( "<input type='' name='%s[customButton]' value='%s' /><br>\n", $optionsName, $customChecked ? $buttonUrl : "");
     96   
     97    printf( "<br /><input type='radio' id='plugin_buttonUrl' name='%s[buttonUrl]' value='none' %s />", $optionsName, $removeChecked ?"checked='checked'":"");
     98    printf( "Remove (see <a href='%s' target='_wpinst'>installation</a> instructions)<br />", $readmeUrl);
     99    //  printf( "<img id='btnImg' src='%s' %s>",
     100    //  $customChecked ? $buttonUrl : $blackButtonUrl,
     101    //  $noneChecked   ? "style='opacity:0.25;filter:alpha(opacity=25);'" : "");
     102}
     103
     104// WP callback for handling button placement
     105function echoButtonPlacement() {
     106    global $optionsName;
     107   
     108    $options         = get_option($optionsName);
     109    $ButtonPlacement = $options['ButtonPlacement'];
     110    $trChecked  = !isset($ButtonPlacement) || $ButtonPlacement=="tr";
     111    $tlChecked  = $ButtonPlacement=="tl";
     112    $blChecked  = $ButtonPlacement=="bl";
     113    $brChecked  = $ButtonPlacement=="br";
     114   
     115    printf( "<input type='radio' id='plugin_buttonplacement' name='%s[ButtonPlacement]' value='tl' %s />", $optionsName, $tlChecked ?"checked='checked'":"");
     116    printf( "Top Left<br />\n");
     117
     118    printf( "<input type='radio' id='plugin_buttonplacement' name='%s[ButtonPlacement]' value='tr' %s />", $optionsName, $trChecked  ?"checked='checked'":"");
     119    printf( "Top Right<br />\n");
     120   
     121    printf( "<input type='radio' id='plugin_buttonplacement' name='%s[ButtonPlacement]' value='bl' %s />", $optionsName, $blChecked  ?"checked='checked'":"");
     122    printf( "Bottom Left<br />\n");
     123   
     124    printf( "<input type='radio' id='plugin_buttonplacement' name='%s[ButtonPlacement]' value='br' %s />", $optionsName, $brChecked  ?"checked='checked'":"");
     125    printf( "Bottom Right<br />\n");
     126}
     127
     128// WP callback for handling the Google Analytics option
     129function echoGASetting() {
     130    global $optionsName;
     131   
     132    $options         = get_option($optionsName);
     133    $GASetting       = $options['GASetting'];
     134    $disabledChecked = !isset($GASetting) || $GASetting=="false";
     135    $enabledChecked  = $GASetting;
     136   
     137    printf( "<input type='radio' id='plugin_gaOption' name='%s[GASetting]' value='true' %s />", $optionsName, $enabledChecked?"checked='checked'":"");
     138    printf( "Enabled<br />\n");
     139
     140    printf( "<input type='radio' id='plugin_gaOption' name='%s[GASetting]' value='false' %s />", $optionsName, $disabledChecked ?"checked='checked'":"");
     141    printf( "Disabled\n");
     142}
    249143
    250144function pluginQueryVars($vars) {
    251     global $pluginAttr;
    252     global $printAttr;
    253        
    254     array_push($vars, $printAttr,$pluginAttr);
     145    global $pluginAttr;
     146    global $printAttr;
     147       
     148    array_push($vars, $printAttr,$pluginAttr);
    255149    return $vars;
    256150}
     
    259153// Clean up the DB properties
    260154function sanitizeSettings($options) {
    261    global $defaultLogoUrl;
    262    global $defaultButtonUrl;
     155   global $blackuttonUrl;
     156   global $whiteButtonUrl;
     157   global $opaqueButtonUrl;
     158   global $textButtonUrl;
    263159   
    264    $logoUrl      = $options['logoUrl'];
    265    $customLogo   = $options['customLogo'];
    266    $buttonUrl    = $options['buttonUrl'];
    267    $customButton = $options['customButton'];
    268 
    269 
    270    if (isset($logoUrl) && $logoUrl!=$defaultLogoUrl) {
    271       $options['logoUrl'] = $customLogo;
    272    }
    273 
    274    if (isset($buttonUrl) && $buttonUrl!=$defaultButtonUrl && $buttonUrl!="none") {
     160   $buttonUrl       = $options['buttonUrl'];
     161   $customButton    = $options['customButton'];
     162   $GASetting       = $options['GASetting'];
     163   $ButtonPlacement = $options['ButtonPlacement'];
     164
     165   if (isset($buttonUrl) && $buttonUrl=="custom") {
    275166      $options['buttonUrl'] = $customButton;
    276167   }
    277168
    278    unset($options['customLogo']);
    279169   unset($options['customButton']);
    280 
     170   
    281171   return $options;
    282172}
     
    292182// WP callback for initializing the options menu
    293183function initCleanPrintAdmin() {
    294     global $pluginName;
    295     global $pluginFile;
    296     global $optionsName;
    297    
    298     register_setting       ($optionsName, $optionsName, 'sanitizeSettings');
    299     register_uninstall_hook($pluginFile, 'addCleanPrintUninstallHook');
    300 
    301     add_settings_section   ('plugin_main', '',      'echoSectionText',    $pluginName);
    302     add_settings_field     ('plugin_printSpecId',   'Column format',      'echoPrintSpecSetting',     $pluginName, 'plugin_main');
    303     add_settings_field     ('plugin_logoUrl',       'Header image',       'echoLogoUrlSetting',       $pluginName, 'plugin_main');
    304     add_settings_field     ('plugin_buttonUrl',     'Print button image', 'echoButtonUrlSetting',     $pluginName, 'plugin_main');
    305     add_settings_field     ('plugin_activationKey', 'Activation key',     'echoActivationKeySetting', $pluginName, 'plugin_main');
    306 }
    307 
    308 
    309 // Adds the CleanPrint button to the page
    310 function addCleanPrintButton() {
    311     global $optionsName;
    312     global $defaultButtonUrl;
    313            
    314     $options        = get_option($optionsName);
    315     $buttonUrl      = $options['buttonUrl'];
    316     $defaultChecked = !isset($buttonUrl) || $buttonUrl==$defaultButtonUrl;
    317     $noneChecked    =  isset($buttonUrl) && $buttonUrl=="none";
    318     $customChecked  = $defaultChecked==false && $noneChecked==false;
    319        
    320     if (!$noneChecked) {
    321         return sprintf("<br /><a href='#' onclick='FDCPUrl();return false;'><img src='%s'></a>", $customChecked ? $buttonUrl : $defaultButtonUrl);
    322     }
    323     return '';
    324 }
    325 
     184    global $pluginName;
     185    global $pluginFile;
     186    global $optionsName;
     187   
     188    register_setting       ($optionsName, $optionsName, 'sanitizeSettings');
     189    register_uninstall_hook($pluginFile, 'addCleanPrintUninstallHook');
     190
     191    add_settings_section   ('plugin_main', '',      'echoSectionText',    $pluginName);
     192    add_settings_field     ('plugin_buttonUrl',     'Print button image', 'echoButtonUrlSetting',     $pluginName, 'plugin_main');
     193    add_settings_field     ('plugin_buttonplacement',      'Button Placement',   'echoButtonPlacement',      $pluginName, 'plugin_main');
     194    add_settings_field     ('plugin_gaOption',      'Google analytics',   'echoGASetting',            $pluginName, 'plugin_main');
     195}
    326196
    327197// Add the hooks for print functionality
    328 function addCleanPrintContentTags($content = '') {
    329     if (is_single()) {
    330         //single post content selection tags
    331         //select title and other elements preceding post body
    332         $content .= '<span class="fdPrintIncludeParentsPreviousSiblings"></span>';
    333 
    334         //if title and other elements aren't sized correctly in printout, comment out previous line and un-comment out next line
    335         //$content .= '<span class="fdPrintIncludeParentsPreviousSiblingssChildren"></span>';
    336 
    337         //grab all the nodes of the post body
    338         $content .= '<span class="fdPrintIncludeParentsChildren"></span>';
    339 
    340         //uncomment out next line if to include node immediately following the post node. Uncomment out line after that for all nodes following post node. Only uncomment out one at a time.
    341         //$content .= '<span class="fdPrintIncludeParentsNextSibling"></span>';
    342         //$content .= '<span class="fdPrintIncludeParentsNextSiblings"></span>';
    343 
    344         //if item exist after the post body that belong in the printout, comment out the next line
    345         $content .= '<span class="fdPrintExcludeNextSiblings"></span>';
    346         $content .= addCleanPrintButton();
    347 
    348     } else {
    349         //Multiple blog posts on the page
    350         //select title and other elements preceding post body
    351         $content .= '<span class="fdPrintIncludeParentsPreviousSiblings"></span>';
    352 
    353         //if title and other elements aren't sized correctly in printout, comment out previous line and un-comment out next line
    354         //$content .= '<span class="fdPrintIncludeParentsPreviousSiblingssChildren"></span>';
    355 
    356         //grab all the nodes of the post body
    357         $content .= '<span class="fdPrintIncludeParentsChildren"></span>';
    358         //uncomment out next line if to include node immediately following the post node. Uncomment out line after that for all nodes following post node. Only uncomment out one at a time.
    359         //$content .= '<span class="fdPrintIncludeParentsNextSibling"></span>';
    360         //$content .= '<span class="fdPrintIncludeParentsNextSiblings"></span>';
    361 
    362         //if item exist after the post body that don't belong in the printout, uncomment out the next line
    363         //$content ,= '<span class="fdPrintExcludeNextSiblings"></span>';
    364     }
    365 
    366     return $content;
     198function addCleanPrintContentTags($content) {
     199   
     200    global $optionsName;
     201    global $blackButtonUrl;
     202           
     203    $options        = get_option($optionsName);
     204    $buttonUrl      = $options['buttonUrl'];
     205    $nothingChecked = !isset($buttonUrl);
     206    $removeChecked  =  isset($buttonUrl) && $buttonUrl=="none";
     207    $ButtonPlacement = $options['ButtonPlacement'];
     208    $width          = '100%';
     209       
     210    if ($nothingChecked) {
     211        $buttonUrl = $blackButtonUrl;
     212    }
     213
     214    if ($removeChecked) {
     215
     216    } else if ($ButtonPlacement=="tl") {
     217        $content = sprintf("<a href='.' onClick='CleanPrint(); return false' class='button' title='Print page'><img src='%s'></a><br />%s", $buttonUrl, $content);
     218    } else if ($ButtonPlacement=="tr") {
     219        $content = sprintf("<div style='text-align: right;'><a href='.' onClick='CleanPrint(); return false' class='button' title='Print page'><img src='%s'></a></div><br />%s", $buttonUrl, $content);
     220    } else if($ButtonPlacement=="bl") {
     221        $content = sprintf("%s<br /><a href='.' onClick='CleanPrint(); return false' class='button' title='Print page'><img src='%s'></a>", $content, $buttonUrl); 
     222    } else {
     223        $content = sprintf("%s<br /><div style='text-align: right;'><a href='.' onClick='CleanPrint(); return false' class='button' title='Print page'><img src='%s'></a></div>", $content, $buttonUrl);   
     224    }
     225    return $content;
    367226}
    368227
     
    371230function addCleanPrintScript() {
    372231    global $optionsName;
    373     global $singleColumnTemplate;
    374     global $doubleColumnTemplate;
    375     global $defaultDivId;
    376     global $cleanPrintCcgUrl;
    377     global $defaultLogoUrl;
    378     global $cpProxyUrl;
    379    
    380     if (is_single()) {
    381         $options              = get_option($optionsName);
    382         $printSpecId          = $options['printSpecId'];
    383         $logoUrl              = $options['logoUrl'];
    384         $gravity              = $options['gravity'];
    385         $doubleChecked        = $printSpecId==$doubleColumnTemplate;
    386         $activationKey        = $options['activationKey'];
    387         $hasActivation        = !empty($activationKey);
    388         $enabled              = $hasActivation ? " disabled='disabled'" : "";
    389         $singleChecked        = !$doubleChecked;
    390         $keys                 = parseActivationKey($activationKey);
    391         $divId                = empty($keys) ? $defaultDivId : $keys[0];
    392         $printSpecId          = empty($keys) ? $singleChecked ? $singleColumnTemplate : $doubleColumnTemplate: $keys[1];
    393         $customChecked        = isset($logoUrl) && $logoUrl!="default";
    394 
    395         if (!isset($gravity)) $gravity = "center";
    396 
     232    global $cleanprintUrl;
     233    global $publisherKey;
     234   
     235    $options              = get_option($optionsName);
     236    $GASetting            = $options['GASetting'];
     237    $gravity              = $options['gravity'];
     238
     239    if (!isset($gravity)) $gravity = "center";
     240   
    397241        printf( "<script type='text/javascript'>\n");
    398         printf( "   var cpProxyUrl = '%s';\n", $cpProxyUrl);
    399         printf( "   var cpLogoUrl  = '%s';\n", $customChecked ? $logoUrl : $defaultLogoUrl);
    400         printf( "   var cpGravity  = '%s';\n", $gravity);  // Gravity is currently unsetable but still required
    401         printf( "</script>\n");
    402         printf( "<script type='text/javascript' src='%s?divId=%s&ps=%s' name='cleanprintloader'></script>\n", $cleanPrintCcgUrl, $divId, $printSpecId);
    403     }
    404 }
     242        printf( "   function CleanPrint() {");
     243        printf( "   CleanPrintPrintHtml();\n");
     244        if ($GASetting=="true") {
     245            printf( "   _gaq.push(['_trackEvent', 'CleanPrint', 'Print']);\n");
     246        }
     247        printf( "   }");
     248        printf( "</script>\n");
     249   
     250    printf( "<script language='javascript' type='text/javascript' src='%s?key=%s'></script>\n", $cleanprintUrl, $publisherKey);
     251       
     252}
     253
    405254
    406255
    407256// Add the Settings menu link to the plugin page
    408257function addCleanPrintActions($links, $file) {
    409     global $pluginName;
     258    global $pluginName;
    410259    global $pluginFile;
    411260   
    412261    if ($file == $pluginFile) {
    413         $links[] = sprintf("<a href='options-general.php?page=%s'>Settings</a>", $pluginName);
    414     }
    415     return $links;
     262        $links[] = sprintf("<a href='options-general.php?page=%s'>Settings</a>", $pluginName);
     263    }
     264    return $links;
    416265}
    417266
     
    420269function addCleanPrintUninstallHook() {
    421270    // cannot use the global, chicken/egg problem
    422     delete_option('CleanPrintAdminOptions');
     271    delete_option('CleanPrintAdminOptions');
    423272}
    424273
     
    428277add_action('admin_menu',          'addCleanPrintAdminMenu');
    429278add_action('wp_head',             'addCleanPrintScript', 1);
    430 add_action('parse_request',       'pluginParseRequest');
    431279
    432280// Filters
  • cleanprint-lt/branches/1.5.0b/readme.txt

    r268630 r450398  
    66Tested up to: 3.0
    77Stable tag: /trunk/
    8 
    9 The CleanPrint plugin for WordPress provides paginated, magazine-like output when readers print your posts, allowing logos, comics and print ads. 
     8 
    109
    1110== Description ==
    12 The CleanPrint plugin for WordPress dynamically creates print-optimized content when users print your blog posts. It creates paginated output that allows you to:
    13 *   Provide the reader with only the content that is relevant on the printed page, improving the user's experience and saving paper and ink
    14 *   Place a custom logo on the top of each page
    15 *   Place a custom print button within each page
    16 *   Flow content into multiple columns, increasing readability
    17 *   Optionally include print advertisements in your printed posts, earning you money when people print your content
     11The CleanPrint plugin for WordPress dynamically optimizes content for output to print, PDF and email. With CleanPrint your readers can:
     12*   Remove images
     13*   Remove text
     14*   Change font size
     15*   Add notes to printout
     16*   Save paper, ink, money and the environment
    1817
    19 The printed content of your site will resemble a magazine page, lending a professional look to your printed blog posts.
     18By installing CleanPrint for WordPress you provide the reader with output control, improving their experience on your site.
    2019
    21 The single post view adds a print button to the bottom of each post, showing users that these pages are optimized for print.
     20The single post view adds a print button to each post, showing users that these pages are optimized for print, PDF and email.
    2221
    23 Please note that not all themes will produce perfect printouts with this plugin.
     22Please note that not all themes will produce perfect printouts with this plugin. You can test your content at http://cpf.cleanprint.net/cpf/instructions.html.
    2423
    2524== Installation ==
    2625
    27 1. Download the CleanPrint plugin to your local machine from the Format Dynamics website:
    28    * http://www.formatdynamics.com/cp-light-download.html     
    29 2. Log into your WordPress installation as an administrator.
    30 3. On the navigation on the left hand side, click Plugins, then Add New from the menu.
    31 4. Enable the CleanPrint plugin
    32 5. Visit the CleanPrint Settings for printing options
     261. Log into your WordPress installation as an administrator.
     272. On the navigation on the left hand side, click Plugins, then Add New from the menu.
     283. Enable the CleanPrint plugin
     294. Visit the CleanPrint Settings for options
    3330
    3431Print Button Removal
    3532
    36 1. Disable the Print button via the 'none' option in the CleanPrint Settings page.
     331. Disable the Print button via the 'Remove' option in the CleanPrint Settings page.
    37342. Insert a hyperlink into your page as per the example below:
    38    * &lt;a href='#' onclick='FDCPUrl();return false;'&gt;Print&lt;/a&gt;
     35   * <a href='.' onClick='CleanPrint(); return false' class='button' title='Print page'>Print</a>
    3936
    40 == Screenshots ==
     37Below are paths to each of our standard buttons.
    4138
    42 1. Double column printout
    43 2. Single column printout
     39    Black Button       : http://cache-02.cleanprint.net/media/pfviewer/images/CleanPrintBtn_black.png
     40    White Button       : http://cache-02.cleanprint.net/media/pfviewer/images/CleanPrintBtn_white.png
     41    Transparent Button : http://cache-02.cleanprint.net/media/pfviewer/images/CleanPrintBtn_transparent.png
     42    Text Button        : http://cache-02.cleanprint.net/media/pfviewer/images/CleanPrintBtn_text.png
    4443
    4544== Advertising ==
    46 To enable print advertisements, you will need to join the Format Dynamics PrintNetwork, an ad network specializing in digital print advertising.  To sign up, go to the signup page at https://services.formatdynamics.com/signup
     45
     46Stay tuned!
Note: See TracChangeset for help on using the changeset viewer.