Plugin Directory

Changeset 535687


Ignore:
Timestamp:
04/24/2012 06:06:36 PM (14 years ago)
Author:
itscoolreally
Message:

achieved full 1.0 release of Ribbon Maker

Location:
ribbon-maker
Files:
2 added
6 edited
14 copied

Legend:

Unmodified
Added
Removed
  • ribbon-maker/tags/1.0/readme.txt

    r535518 r535687  
    55Requires at Least: 3.0.0
    66Tested Up To: 3.3.2
    7 Stable tag: 0.1
     7Stable tag: 1.0
    88
    99Make your own ribbon now without waiting for a plugin designer to do it for you.
     
    1111== Description ==
    1212
    13 A ribbon creation plugin that will allow you to generate your own ribbons in real time. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.
     13A ribbon creation plugin that will allow you to generate your own ribbons in real time. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. You can also control the visibility of the of ribbon so you don't have to deactivate when it is not in use. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.
    1414
    1515== Installation ==
     
    2424
    2525== Changelog ==
     26= 1.0 =
     27Cropping has been achieved. Also added a radio button to control the visibility of the ribbon. Ribbon generates only during the configuration and not constantly as in v0.1. Added a preview of the ribbon, so you can view it before you make it active.
    2628
    2729= 0.1 =
     
    4749
    4850== Upgrade Notice ==
     51= 1.0 =
     52Now with cropping, ribbon hiding on demand, and preview.
     53
     54= 0.1 =
    4955Considered to be an upgrade for anyone having a static ribbon created by another ribbon plugin.
    5056
     
    5258This plugin requires the GD image library in your PHP 5.x installation to be enabled and fully operational.
    5359== TODO ==
    54 1. Dynamically resample the image (crop) so that it is properly clipped appears nicely on your blog. -- Needed to Achieve Release 1.0
    55 2. Add an option that you can use to turn off cropping.
    56 3. Fix transparency issue.
    57 4. Allow you to create multiple ribbons.
    58 5. Allow you to have multiple ribbons on a page.
    59 6. Allow ribbons to be scheduled.
     601. Give you more control of how the ribbon graphic looks.
     612. Fix transparency issue.
     623. Allow you to create multiple ribbons.
     634. Allow you to have multiple ribbons on a page.
     645. Allow ribbons to be scheduled.
  • ribbon-maker/tags/1.0/readme.txt~

    r535518 r535687  
    55Requires at Least: 3.0.0
    66Tested Up To: 3.3.2
    7 Stable tag: 0.1
     7Stable tag: 1.0
    88
    99Make your own ribbon now without waiting for a plugin designer to do it for you.
     
    1111== Description ==
    1212
    13 A ribbon creation plugin that will allow you to generate your own ribbons in real time. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.
     13A ribbon creation plugin that will allow you to generate your own ribbons in real time. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. You can also control the visibility of the of ribbon so you don't have to deactivate when it is not in use. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.
    1414
    1515== Installation ==
     
    2020
    2121== Screenshots ==
    22 1. Here's how the ribbon will appear on your website. Will link to the http://www.avaaz.org/en/stop_cispa/ website.
     221. The configuration screen found under Tools -> Ribbon Maker
     232. Here's how the ribbon will appear on your website.
    2324
    2425== Changelog ==
     26= 1.0 =
     27Cropping has been achieved. Also added a radio button to control the visibility of the ribbon. Ribbon generates only during the configuration and not constantly as in v0.1
    2528
    2629= 0.1 =
     
    4649
    4750== Upgrade Notice ==
     51= 1.0 =
     52Now with cropping and ribbon hiding on demand.
     53
     54= 0.1 =
    4855Considered to be an upgrade for anyone having a static ribbon created by another ribbon plugin.
    4956
     
    5158This plugin requires the GD image library in your PHP 5.x installation to be enabled and fully operational.
    5259== TODO ==
    53 1. Dynamically resample the image (crop) so that it is properly clipped appears nicely on your blog. -- Needed to Achieve Release 1.0
    54 2. Add an option that you can use to turn off cropping.
    55 3. Fix transparency issue.
    56 4. Allow you to create multiple ribbons.
    57 5. Allow you to have multiple ribbons on a page.
    58 6. Allow ribbons to be scheduled.
     601. Give you more control of how the ribbon graphic looks.
     612. Fix transparency issue.
     623. Allow you to create multiple ribbons.
     634. Allow you to have multiple ribbons on a page.
     645. Allow ribbons to be scheduled.
  • ribbon-maker/tags/1.0/ribbon-maker.php

    r535518 r535687  
    55Description: When activated, this plugin will put a ribbon of your design, message and custom link on the top right corner of your website.
    66Author: Al Lamb
    7 Version: 0.1
     7Version: 1.0
    88License: GPLv2
    99Author URI: http://bowierocks.com
     
    1212function ribbon_maker_admin() {
    1313    add_submenu_page( 'tools.php', 'Ribbon Maker Settings', 'Ribbon Maker', 10, __FILE__, 'ribbon_maker_admin_menu' );
     14}
     15
     16function ribbon_maker_isChecked($test,$string) {
     17  if($test==$string) return "checked";
     18  return "";
    1419}
    1520
     
    3439        $str = strtr( $_POST['ribbon_maker_fgcolor'], array( '"' => '"', '\\' => '', '\'' => ''' ) );
    3540        $ribbon_maker .= update_option( 'ribbon_maker_fgcolor', $str );
     41        $str = strtr( $_POST['ribbon_maker_active'], array( '"' => '"', '\\' => '', '\'' => ''' ) );
     42        $ribbon_maker .= update_option( 'ribbon_maker_active', $str );
    3643        if ( $ribbon_maker )
    3744            echo('<div class="updated"><p><strong>Your setting have been saved.</strong></p></div>');
    3845        else
    3946            echo('<div class="error"><p><strong>Your setting have not been saved.</strong></p></div>');
     47        ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
    4048    }
    4149
     50    echo "<hr>Ribbon Preview: <img valign='top' src='".plugins_url("ribbon_maker_ribbon.png",__FILE__)."'><br>";
    4251    echo('
    4352        <form action="" method="post">
     
    6372        <tr><td>User Vertical Offset<br/><span class="ribbon_maker_hint">Enter a positive number to push the ribbon down, negative for up. Suggest 28 to offset the USER bar.</span></td>
    6473<td><input type="text" name="ribbon_maker_user_offset" size="5" maxlength=5 value="'.get_option( 'ribbon_maker_user_offset','0' ).'"></td>
     74</tr>
     75        <tr><td>Make Ribbon Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will be visible on your blog.</span></td>
     76<td><input type="radio" name="ribbon_maker_active" value="active" '.ribbon_maker_isChecked('active',get_option('ribbon_maker_active')).'></td>
     77</tr>
     78        <tr><td>Make Ribbon In-Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will NOT be visible on your blog.</span></td>
     79<td><input type="radio" name="ribbon_maker_active" value="inactive" '.ribbon_maker_isChecked('inactive',get_option('ribbon_maker_active')).'></td>
    6580</tr>
    6681        <hr />
     
    114129  $text_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($fgcolor,"red"), (int)ribbon_maker_get_color($fgcolor,"green"), (int)ribbon_maker_get_color($fgcolor,"blue"));
    115130
     131  imagesetthickness($im,2);
    116132  imageline($im, 0,2,$width,2,$draw_color);
    117133
     134  imagesetthickness($im,1);
    118135  imagefilledrectangle($im,0,4,$width,$height-5,$draw_color);
    119136
     137  imagesetthickness($im,2);
    120138  imageline($im, 0,$height-3,$width,$height-3,$draw_color);
    121139
     140  imagesetthickness($im,1);
    122141  imagestring ($im, $font, ImageFontWidth($font)*2, 3,  $string, $text_color);
    123142
    124143  $new_img = imagerotate ($im, 360-45, 0);
    125144
    126   imagecolortransparent($new_img,$back);
     145  //now we shall try and crop the image, increase its dpi and thus make the ribbon flush
     146  //all in one go
     147  imagedestroy ($im);
     148  $newWidth=imagesx($new_img)-ImageFontWidth($font);
     149  $newHeight=imagesy($new_img)-ImageFontHeight($font);
     150  $im = imagecreatetruecolor($newWidth,$newHeight);
     151 
     152  /*
     153  bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
     154  */
     155  imagecopyresampled($im,$new_img,0,0,0,ImageFontHeight($font),$newWidth,$newHeight,imagesx($new_img)-ImageFontWidth($font)*2,imagesy($new_img)-ImageFontHeight($font));
    127156
     157  imagecolortransparent($im,$back);
    128158
    129   imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     159  //imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     160  imagepng ($im,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     161  imagedestroy ($new_img);
    130162  imagedestroy ($im);
    131   imagedestroy ($new_img);
    132163}
    133164
    134165function render_ribbon_maker() {
    135     if(is_admin_bar_showing())
    136       $offset = get_option("ribbon_maker_admin_offset");
    137     else
    138       $offset = get_option("ribbon_maker_user_offset");
    139    
    140     ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
     166  if(get_option("ribbon_maker_active")=="active") {
     167      if(is_admin_bar_showing())
     168        $offset = get_option("ribbon_maker_admin_offset");
     169      else
     170        $offset = get_option("ribbon_maker_user_offset");
     171     
     172  //    ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
    141173
    142     $img = plugins_url('ribbon_maker_ribbon.png',__FILE__);
     174      $img = plugins_url('ribbon_maker_ribbon.png',__FILE__);
    143175
    144     echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>";
     176      echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>";
     177  }
    145178}
    146179
  • ribbon-maker/tags/1.0/ribbon-maker.php~

    r535518 r535687  
    55Description: When activated, this plugin will put a ribbon of your design, message and custom link on the top right corner of your website.
    66Author: Al Lamb
    7 Version: 0.1
     7Version: 1.0
    88License: GPLv2
    99Author URI: http://bowierocks.com
     
    1212function ribbon_maker_admin() {
    1313    add_submenu_page( 'tools.php', 'Ribbon Maker Settings', 'Ribbon Maker', 10, __FILE__, 'ribbon_maker_admin_menu' );
     14}
     15
     16function ribbon_maker_isChecked($test,$string) {
     17  if($test==$string) return "checked";
     18  return "";
    1419}
    1520
     
    3439        $str = strtr( $_POST['ribbon_maker_fgcolor'], array( '"' => '&#34;', '\\' => '', '\'' => '&#39;' ) );
    3540        $ribbon_maker .= update_option( 'ribbon_maker_fgcolor', $str );
     41        $str = strtr( $_POST['ribbon_maker_active'], array( '"' => '&#34;', '\\' => '', '\'' => '&#39;' ) );
     42        $ribbon_maker .= update_option( 'ribbon_maker_active', $str );
    3643        if ( $ribbon_maker )
    3744            echo('<div class="updated"><p><strong>Your setting have been saved.</strong></p></div>');
    3845        else
    3946            echo('<div class="error"><p><strong>Your setting have not been saved.</strong></p></div>');
     47        ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
    4048    }
    4149
     50    echo "<hr>Ribbon Preview: <img valign='top' src='".plugins_url("ribbon_maker_ribbon.png",__FILE__)."'><br>";
    4251    echo('
    4352        <form action="" method="post">
     
    6372        <tr><td>User Vertical Offset<br/><span class="ribbon_maker_hint">Enter a positive number to push the ribbon down, negative for up. Suggest 28 to offset the USER bar.</span></td>
    6473<td><input type="text" name="ribbon_maker_user_offset" size="5" maxlength=5 value="'.get_option( 'ribbon_maker_user_offset','0' ).'"></td>
     74</tr>
     75        <tr><td>Make Ribbon Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will be visible on your blog.</span></td>
     76<td><input type="radio" name="ribbon_maker_active" value="active" '.ribbon_maker_isChecked('active',get_opton('ribbon_maker_active')).'></td>
     77</tr>
     78        <tr><td>Make Ribbon In-Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will NOT be visible on your blog.</span></td>
     79<td><input type="radio" name="ribbon_maker_active" value="inactive" '.ribbon_maker_isChecked('inactive',get_opton('ribbon_maker_active')).'></td>
    6580</tr>
    6681        <hr />
     
    110125  $im = imagecreatetruecolor ($width,$height);
    111126 
    112   $back = imagecolorallocate($im, (int)18, (int)52, (int)86);
     127  $back = imagecolorallocate($im, 0,0,0);
    113128  $draw_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($bgcolor,"red"), (int)ribbon_maker_get_color($bgcolor,"green"), (int)ribbon_maker_get_color($bgcolor,"blue"));
    114129  $text_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($fgcolor,"red"), (int)ribbon_maker_get_color($fgcolor,"green"), (int)ribbon_maker_get_color($fgcolor,"blue"));
    115130
     131  imagesetthickness($im,2);
    116132  imageline($im, 0,2,$width,2,$draw_color);
    117133
     134  imagesetthickness($im,1);
    118135  imagefilledrectangle($im,0,4,$width,$height-5,$draw_color);
    119136
     137  imagesetthickness($im,2);
    120138  imageline($im, 0,$height-3,$width,$height-3,$draw_color);
    121139
     140  imagesetthickness($im,1);
    122141  imagestring ($im, $font, ImageFontWidth($font)*2, 3,  $string, $text_color);
    123142
    124143  $new_img = imagerotate ($im, 360-45, 0);
    125144
    126   imagecolortransparent($new_img,$back);
     145  //now we shall try and crop the image, increase its dpi and thus make the ribbon flush
     146  //all in one go
     147  imagedestroy ($im);
     148  $newWidth=imagesx($new_img)-ImageFontWidth($font);
     149  $newHeight=imagesy($new_img)-ImageFontHeight($font);
     150  $im = imagecreatetruecolor($newWidth,$newHeight);
     151 
     152  /*
     153  bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
     154  */
     155  imagecopyresampled($im,$new_img,0,0,0,ImageFontHeight($font),$newWidth,$newHeight,imagesx($new_img)-ImageFontWidth($font)*2,imagesy($new_img)-ImageFontHeight($font));
    127156
     157  imagecolortransparent($im,$back);
    128158
    129   imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     159  //imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     160  imagepng ($im,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     161  imagedestroy ($new_img);
    130162  imagedestroy ($im);
    131   imagedestroy ($new_img);
    132163}
    133164
    134165function render_ribbon_maker() {
    135     if(is_admin_bar_showing())
    136       $offset = get_option("ribbon_maker_admin_offset");
    137     else
    138       $offset = get_option("ribbon_maker_user_offset");
    139    
    140     ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
     166  if(get_option("ribbon_maker_active")=="active") {
     167      if(is_admin_bar_showing())
     168        $offset = get_option("ribbon_maker_admin_offset");
     169      else
     170        $offset = get_option("ribbon_maker_user_offset");
     171     
     172  //    ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
    141173
    142     $img = plugins_url('ribbon_maker_ribbon.png',__FILE__);
     174      $img = plugins_url('ribbon_maker_ribbon.png',__FILE__);
    143175
    144     echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>";
     176      echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>";
     177  }
    145178}
    146179
  • ribbon-maker/trunk/readme.txt

    r535518 r535687  
    55Requires at Least: 3.0.0
    66Tested Up To: 3.3.2
    7 Stable tag: 0.1
     7Stable tag: 1.0
    88
    99Make your own ribbon now without waiting for a plugin designer to do it for you.
     
    1111== Description ==
    1212
    13 A ribbon creation plugin that will allow you to generate your own ribbons in real time. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.
     13A ribbon creation plugin that will allow you to generate your own ribbons in real time. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. You can also control the visibility of the of ribbon so you don't have to deactivate when it is not in use. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.
    1414
    1515== Installation ==
     
    2424
    2525== Changelog ==
     26= 1.0 =
     27Cropping has been achieved. Also added a radio button to control the visibility of the ribbon. Ribbon generates only during the configuration and not constantly as in v0.1. Added a preview of the ribbon, so you can view it before you make it active.
    2628
    2729= 0.1 =
     
    4749
    4850== Upgrade Notice ==
     51= 1.0 =
     52Now with cropping, ribbon hiding on demand, and preview.
     53
     54= 0.1 =
    4955Considered to be an upgrade for anyone having a static ribbon created by another ribbon plugin.
    5056
     
    5258This plugin requires the GD image library in your PHP 5.x installation to be enabled and fully operational.
    5359== TODO ==
    54 1. Dynamically resample the image (crop) so that it is properly clipped appears nicely on your blog. -- Needed to Achieve Release 1.0
    55 2. Add an option that you can use to turn off cropping.
    56 3. Fix transparency issue.
    57 4. Allow you to create multiple ribbons.
    58 5. Allow you to have multiple ribbons on a page.
    59 6. Allow ribbons to be scheduled.
     601. Give you more control of how the ribbon graphic looks.
     612. Fix transparency issue.
     623. Allow you to create multiple ribbons.
     634. Allow you to have multiple ribbons on a page.
     645. Allow ribbons to be scheduled.
  • ribbon-maker/trunk/readme.txt~

    r535518 r535687  
    55Requires at Least: 3.0.0
    66Tested Up To: 3.3.2
    7 Stable tag: 0.1
     7Stable tag: 1.0
    88
    99Make your own ribbon now without waiting for a plugin designer to do it for you.
     
    1111== Description ==
    1212
    13 A ribbon creation plugin that will allow you to generate your own ribbons in real time. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.
     13A ribbon creation plugin that will allow you to generate your own ribbons in real time. They have all of the features of the static ribbons you have enjoyed so far with the exception that you can set the Message, the Link, the Link Title (hover message), toolbar offset, no toolbar offset, the background color and the foreground color. You can also control the visibility of the of ribbon so you don't have to deactivate when it is not in use. The background color is the color of the shapes that make up the ribbon and the foreground color is the color of the text.
    1414
    1515== Installation ==
     
    2020
    2121== Screenshots ==
    22 1. Here's how the ribbon will appear on your website. Will link to the http://www.avaaz.org/en/stop_cispa/ website.
     221. The configuration screen found under Tools -> Ribbon Maker
     232. Here's how the ribbon will appear on your website.
    2324
    2425== Changelog ==
     26= 1.0 =
     27Cropping has been achieved. Also added a radio button to control the visibility of the ribbon. Ribbon generates only during the configuration and not constantly as in v0.1
    2528
    2629= 0.1 =
     
    4649
    4750== Upgrade Notice ==
     51= 1.0 =
     52Now with cropping and ribbon hiding on demand.
     53
     54= 0.1 =
    4855Considered to be an upgrade for anyone having a static ribbon created by another ribbon plugin.
    4956
     
    5158This plugin requires the GD image library in your PHP 5.x installation to be enabled and fully operational.
    5259== TODO ==
    53 1. Dynamically resample the image (crop) so that it is properly clipped appears nicely on your blog. -- Needed to Achieve Release 1.0
    54 2. Add an option that you can use to turn off cropping.
    55 3. Fix transparency issue.
    56 4. Allow you to create multiple ribbons.
    57 5. Allow you to have multiple ribbons on a page.
    58 6. Allow ribbons to be scheduled.
     601. Give you more control of how the ribbon graphic looks.
     612. Fix transparency issue.
     623. Allow you to create multiple ribbons.
     634. Allow you to have multiple ribbons on a page.
     645. Allow ribbons to be scheduled.
  • ribbon-maker/trunk/ribbon-maker.php

    r535518 r535687  
    55Description: When activated, this plugin will put a ribbon of your design, message and custom link on the top right corner of your website.
    66Author: Al Lamb
    7 Version: 0.1
     7Version: 1.0
    88License: GPLv2
    99Author URI: http://bowierocks.com
     
    1212function ribbon_maker_admin() {
    1313    add_submenu_page( 'tools.php', 'Ribbon Maker Settings', 'Ribbon Maker', 10, __FILE__, 'ribbon_maker_admin_menu' );
     14}
     15
     16function ribbon_maker_isChecked($test,$string) {
     17  if($test==$string) return "checked";
     18  return "";
    1419}
    1520
     
    3439        $str = strtr( $_POST['ribbon_maker_fgcolor'], array( '"' => '&#34;', '\\' => '', '\'' => '&#39;' ) );
    3540        $ribbon_maker .= update_option( 'ribbon_maker_fgcolor', $str );
     41        $str = strtr( $_POST['ribbon_maker_active'], array( '"' => '&#34;', '\\' => '', '\'' => '&#39;' ) );
     42        $ribbon_maker .= update_option( 'ribbon_maker_active', $str );
    3643        if ( $ribbon_maker )
    3744            echo('<div class="updated"><p><strong>Your setting have been saved.</strong></p></div>');
    3845        else
    3946            echo('<div class="error"><p><strong>Your setting have not been saved.</strong></p></div>');
     47        ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
    4048    }
    4149
     50    echo "<hr>Ribbon Preview: <img valign='top' src='".plugins_url("ribbon_maker_ribbon.png",__FILE__)."'><br>";
    4251    echo('
    4352        <form action="" method="post">
     
    6372        <tr><td>User Vertical Offset<br/><span class="ribbon_maker_hint">Enter a positive number to push the ribbon down, negative for up. Suggest 28 to offset the USER bar.</span></td>
    6473<td><input type="text" name="ribbon_maker_user_offset" size="5" maxlength=5 value="'.get_option( 'ribbon_maker_user_offset','0' ).'"></td>
     74</tr>
     75        <tr><td>Make Ribbon Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will be visible on your blog.</span></td>
     76<td><input type="radio" name="ribbon_maker_active" value="active" '.ribbon_maker_isChecked('active',get_option('ribbon_maker_active')).'></td>
     77</tr>
     78        <tr><td>Make Ribbon In-Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will NOT be visible on your blog.</span></td>
     79<td><input type="radio" name="ribbon_maker_active" value="inactive" '.ribbon_maker_isChecked('inactive',get_option('ribbon_maker_active')).'></td>
    6580</tr>
    6681        <hr />
     
    114129  $text_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($fgcolor,"red"), (int)ribbon_maker_get_color($fgcolor,"green"), (int)ribbon_maker_get_color($fgcolor,"blue"));
    115130
     131  imagesetthickness($im,2);
    116132  imageline($im, 0,2,$width,2,$draw_color);
    117133
     134  imagesetthickness($im,1);
    118135  imagefilledrectangle($im,0,4,$width,$height-5,$draw_color);
    119136
     137  imagesetthickness($im,2);
    120138  imageline($im, 0,$height-3,$width,$height-3,$draw_color);
    121139
     140  imagesetthickness($im,1);
    122141  imagestring ($im, $font, ImageFontWidth($font)*2, 3,  $string, $text_color);
    123142
    124143  $new_img = imagerotate ($im, 360-45, 0);
    125144
    126   imagecolortransparent($new_img,$back);
     145  //now we shall try and crop the image, increase its dpi and thus make the ribbon flush
     146  //all in one go
     147  imagedestroy ($im);
     148  $newWidth=imagesx($new_img)-ImageFontWidth($font);
     149  $newHeight=imagesy($new_img)-ImageFontHeight($font);
     150  $im = imagecreatetruecolor($newWidth,$newHeight);
     151 
     152  /*
     153  bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
     154  */
     155  imagecopyresampled($im,$new_img,0,0,0,ImageFontHeight($font),$newWidth,$newHeight,imagesx($new_img)-ImageFontWidth($font)*2,imagesy($new_img)-ImageFontHeight($font));
    127156
     157  imagecolortransparent($im,$back);
    128158
    129   imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     159  //imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     160  imagepng ($im,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     161  imagedestroy ($new_img);
    130162  imagedestroy ($im);
    131   imagedestroy ($new_img);
    132163}
    133164
    134165function render_ribbon_maker() {
    135     if(is_admin_bar_showing())
    136       $offset = get_option("ribbon_maker_admin_offset");
    137     else
    138       $offset = get_option("ribbon_maker_user_offset");
    139    
    140     ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
     166  if(get_option("ribbon_maker_active")=="active") {
     167      if(is_admin_bar_showing())
     168        $offset = get_option("ribbon_maker_admin_offset");
     169      else
     170        $offset = get_option("ribbon_maker_user_offset");
     171     
     172  //    ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
    141173
    142     $img = plugins_url('ribbon_maker_ribbon.png',__FILE__);
     174      $img = plugins_url('ribbon_maker_ribbon.png',__FILE__);
    143175
    144     echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>";
     176      echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>";
     177  }
    145178}
    146179
  • ribbon-maker/trunk/ribbon-maker.php~

    r535518 r535687  
    55Description: When activated, this plugin will put a ribbon of your design, message and custom link on the top right corner of your website.
    66Author: Al Lamb
    7 Version: 0.1
     7Version: 1.0
    88License: GPLv2
    99Author URI: http://bowierocks.com
     
    1212function ribbon_maker_admin() {
    1313    add_submenu_page( 'tools.php', 'Ribbon Maker Settings', 'Ribbon Maker', 10, __FILE__, 'ribbon_maker_admin_menu' );
     14}
     15
     16function ribbon_maker_isChecked($test,$string) {
     17  if($test==$string) return "checked";
     18  return "";
    1419}
    1520
     
    3439        $str = strtr( $_POST['ribbon_maker_fgcolor'], array( '"' => '&#34;', '\\' => '', '\'' => '&#39;' ) );
    3540        $ribbon_maker .= update_option( 'ribbon_maker_fgcolor', $str );
     41        $str = strtr( $_POST['ribbon_maker_active'], array( '"' => '&#34;', '\\' => '', '\'' => '&#39;' ) );
     42        $ribbon_maker .= update_option( 'ribbon_maker_active', $str );
    3643        if ( $ribbon_maker )
    3744            echo('<div class="updated"><p><strong>Your setting have been saved.</strong></p></div>');
    3845        else
    3946            echo('<div class="error"><p><strong>Your setting have not been saved.</strong></p></div>');
     47        ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
    4048    }
    4149
     50    echo "<hr>Ribbon Preview: <img valign='top' src='".plugins_url("ribbon_maker_ribbon.png",__FILE__)."'><br>";
    4251    echo('
    4352        <form action="" method="post">
     
    6372        <tr><td>User Vertical Offset<br/><span class="ribbon_maker_hint">Enter a positive number to push the ribbon down, negative for up. Suggest 28 to offset the USER bar.</span></td>
    6473<td><input type="text" name="ribbon_maker_user_offset" size="5" maxlength=5 value="'.get_option( 'ribbon_maker_user_offset','0' ).'"></td>
     74</tr>
     75        <tr><td>Make Ribbon Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will be visible on your blog.</span></td>
     76<td><input type="radio" name="ribbon_maker_active" value="active" '.ribbon_maker_isChecked('active',get_opton('ribbon_maker_active')).'></td>
     77</tr>
     78        <tr><td>Make Ribbon In-Active<br/><span class="ribbon_maker_hint">If checked, the Ribbon will NOT be visible on your blog.</span></td>
     79<td><input type="radio" name="ribbon_maker_active" value="inactive" '.ribbon_maker_isChecked('inactive',get_opton('ribbon_maker_active')).'></td>
    6580</tr>
    6681        <hr />
     
    110125  $im = imagecreatetruecolor ($width,$height);
    111126 
    112   $back = imagecolorallocate($im, (int)18, (int)52, (int)86);
     127  $back = imagecolorallocate($im, 0,0,0);
    113128  $draw_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($bgcolor,"red"), (int)ribbon_maker_get_color($bgcolor,"green"), (int)ribbon_maker_get_color($bgcolor,"blue"));
    114129  $text_color = imagecolorallocate ($im, (int)ribbon_maker_get_color($fgcolor,"red"), (int)ribbon_maker_get_color($fgcolor,"green"), (int)ribbon_maker_get_color($fgcolor,"blue"));
    115130
     131  imagesetthickness($im,2);
    116132  imageline($im, 0,2,$width,2,$draw_color);
    117133
     134  imagesetthickness($im,1);
    118135  imagefilledrectangle($im,0,4,$width,$height-5,$draw_color);
    119136
     137  imagesetthickness($im,2);
    120138  imageline($im, 0,$height-3,$width,$height-3,$draw_color);
    121139
     140  imagesetthickness($im,1);
    122141  imagestring ($im, $font, ImageFontWidth($font)*2, 3,  $string, $text_color);
    123142
    124143  $new_img = imagerotate ($im, 360-45, 0);
    125144
    126   imagecolortransparent($new_img,$back);
     145  //now we shall try and crop the image, increase its dpi and thus make the ribbon flush
     146  //all in one go
     147  imagedestroy ($im);
     148  $newWidth=imagesx($new_img)-ImageFontWidth($font);
     149  $newHeight=imagesy($new_img)-ImageFontHeight($font);
     150  $im = imagecreatetruecolor($newWidth,$newHeight);
     151 
     152  /*
     153  bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h )
     154  */
     155  imagecopyresampled($im,$new_img,0,0,0,ImageFontHeight($font),$newWidth,$newHeight,imagesx($new_img)-ImageFontWidth($font)*2,imagesy($new_img)-ImageFontHeight($font));
    127156
     157  imagecolortransparent($im,$back);
    128158
    129   imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     159  //imagepng ($new_img,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     160  imagepng ($im,plugin_dir_path(__FILE__)."ribbon_maker_ribbon.png");//this actually writes out the image!
     161  imagedestroy ($new_img);
    130162  imagedestroy ($im);
    131   imagedestroy ($new_img);
    132163}
    133164
    134165function render_ribbon_maker() {
    135     if(is_admin_bar_showing())
    136       $offset = get_option("ribbon_maker_admin_offset");
    137     else
    138       $offset = get_option("ribbon_maker_user_offset");
    139    
    140     ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
     166  if(get_option("ribbon_maker_active")=="active") {
     167      if(is_admin_bar_showing())
     168        $offset = get_option("ribbon_maker_admin_offset");
     169      else
     170        $offset = get_option("ribbon_maker_user_offset");
     171     
     172  //    ribbon_maker_create_ribbon(get_option('ribbon_maker_message'),get_option('ribbon_maker_bgcolor'),get_option('ribbon_maker_fgcolor'));
    141173
    142     $img = plugins_url('ribbon_maker_ribbon.png',__FILE__);
     174      $img = plugins_url('ribbon_maker_ribbon.png',__FILE__);
    143175
    144     echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>";
     176      echo "<a target='_blank' class='ribbon-maker' href='". get_option("ribbon_maker_url")."' title='".get_option("ribbon_maker_title")."'><img src='{$img}' alt='Ribbon Maker' style='position: fixed; top: {$offset}px; right: 0; z-index: 100000; cursor: pointer;' /></a>";
     177  }
    145178}
    146179
Note: See TracChangeset for help on using the changeset viewer.