Plugin Directory

Changeset 1031311


Ignore:
Timestamp:
11/23/2014 07:40:25 PM (11 years ago)
Author:
ethanhackett
Message:

Thanks to alfred_j_kwack's PR, added text color picking and slide transparency via the admin.

Location:
post-tiles
Files:
84 added
3 edited

Legend:

Unmodified
Added
Removed
  • post-tiles/trunk/post-tiles.css

    r1030862 r1031311  
    5454    padding: 5px 10px;
    5555    margin-bottom: 0;
     56    list-style: none;
     57}
     58.tile-colors {
     59  width: 100%;
     60  margin-top: 20px;
     61  margin-bottom: 20px;
     62  border: 1px solid rgba(0, 0, 0, 0.12);
     63  border-radius: 5px;
     64}
     65.tile-colors thead {
     66  background-color: rgba(0, 0, 0, 0.04);
     67  color: rgba(0, 0, 0, 0.47);
     68}
     69.tile-colors th {
     70  line-height: 26px;
     71}
     72.tile-colors input {
     73  width: auto;
     74}
     75.tile-colors td {
     76  padding: 5px;
    5677}
    5778.tc-note {
     
    247268    padding: 4px 10px !important;
    248269}
     270li.featured-image.static-over a {
     271    top: 0;
     272}
    249273li.featured-image.up a {
    250274    top: 100%;
     
    259283    left: 105%;
    260284}
    261 li.featured-image.fade a {
     285li.featured-image.fade a,
     286li.featured-image.static-hide a {
    262287    left: 105%;
    263288    display: none;
  • post-tiles/trunk/post-tiles.php

    r1030970 r1031311  
    55Description: This plugin displays recent posts as tiles. Posts can choose categories by id and numbeer of posts to display. Example shortcode: [post-tiles] or [post-tiles categories='1,2,4,10' posts='8' excerpt='18'].
    66Author: Ethan Hackett
    7 Version: 1.4.5
     7Version: 1.4.6
    88Author URI: http://www.posttiles.com
    99
     
    4747
    4848    // Registers Non Category Related Settings (it's outside the categories loop)
     49    register_setting( 'tc-plugin-settings', 'posttile-transparency');
    4950    register_setting( 'tc-plugin-settings', 'category-key');
    5051    register_setting( 'tc-plugin-settings', 'category-key-jquery');
     
    6566    foreach($categories as $category) {
    6667        // Get category slug incase of special characters
    67         $cat_slug = "cat_".$category->slug;
     68        $cat_slug = $category->slug;
    6869        // Creates a registered setting for each category.
    69         register_setting('tc-plugin-settings', $cat_slug);
     70        register_setting('tc-plugin-settings', "cat_bg_".$cat_slug);
     71        register_setting('tc-plugin-settings', "cat_tx_".$cat_slug);
    7072    }
    7173}
     
    8789    // Get the plugin Url to attatch CSS and images etc.
    8890    $plugin_url = plugins_url()."/post-tiles";
    89     wp_enqueue_style( 'post-tiles', $plugin_url.'/post-tiles.css' );
     91    wp_enqueue_style( 'post-tiles', $plugin_url.'/post-tiles.css', false, filemtime( plugin_dir_path( __FILE__ ).'/post-tiles.css' ), 'all' );
    9092    wp_enqueue_script('post-tiles', $plugin_url.'/post-tiles.js' );
    9193
     
    105107        <div id='example-post'><div id='example-tile'><big>Example Post Title Here</big></div>Example post excerpt displayed below the title.</div>
    106108    </div>
    107     <form method='POST' action='options.php'><div id='category-list'><h3>Pick Your Cutom Tile Colors:</h3><em>1.) Click inside each of the category inputs. <br/>2.) Next use the color picker on the left to select the color for that categories tiles.<br/>3.) Save Your Changes</em><ul>";
     109    <form method='POST' action='options.php'><div id='category-list'><h3>Pick Your Cutom Tile Colors:</h3><em>1.) Click inside each of the category inputs. <br/>2.) Next use the color picker on the left to select the color for that categories tiles.<br/>3.) Save Your Changes</em><table class='tile-colors' cellspacing='0' cellpadding='0'><thead><tr><th>Category</th><th>Background</th><th>Text</th></thead><tbody>";
    108110
    109111
     
    112114
    113115    // Retrieve additional options before the categories loop
     116    $posttile_transparency = get_option('posttile-transparency');
     117    if(empty($posttile_transparency)){
     118        $posttile_transparency = "100%";
     119    }
    114120    $show_key = get_option('category-key');
    115121    if(empty($show_key)){
     
    169175    //Loops through each category and displays color inputs.
    170176    foreach($categories as $category) {
    171         $cat_var = "cat_".$category->name;
    172         $cat_slug = "cat_".$category->slug;
     177        $cat_bg_var = "cat_bg_".$category->name;
     178        $cat_tx_var = "cat_tx_".$category->name;
     179        $cat_slug = $category->slug;
    173180        // Make lowercase
    174         $cat_var = strtolower($cat_var);
    175         $cat_var = str_replace(" ", "_", $cat_var);
     181        $cat_bg_var = strtolower($cat_bg_var);
     182        $cat_bg_var = str_replace(" ", "_", $cat_bg_var);
     183        $cat_tx_var = strtolower($cat_tx_var);
     184        $cat_tx_var = str_replace(" ", "_", $cat_tx_var);
    176185        $cat = $category->name;
    177186        $id = $category->cat_ID;
    178187        // Retrieves option value
    179         $cat_var_value = get_option($cat_slug);
     188        $cat_bg_var_value = get_option("cat_bg_".$cat_slug);
     189        $cat_tx_var_value = get_option("cat_tx_".$cat_slug);
    180190        // Checks the value to see if it's empty. If it is use default.
    181         if (empty($cat_var_value)){
    182             $cat_var_value = "#afe2f8";
     191        if (empty($cat_bg_var_value)){
     192            $cat_bg_var_value = "#afe2f8";
    183193        }
     194        if (empty($cat_tx_var_value)){
     195            $cat_tx_var_value = "#ffffff";
     196        }
    184197
    185198        // Echo out each list Category Name > Id > Input
    186         echo "<li><strong>".$cat." </strong> <em>(".$id.")</em>
    187         <input type='text' class='colorwell' name='".$cat_slug."' value='".$cat_var_value."' />
    188         </li>";
     199        echo "<tr><td><strong>".$cat." </strong> <em>(".$id.")</em></td>
     200        <td><input title='Category background color' type='text' class='colorwell background' name='cat_bg_".$cat_slug."' value='".$cat_bg_var_value."' /></td><td><input title='Category text color'  type='text' class='colorwell text' name='cat_tx_".$cat_slug."' value='".$cat_tx_var_value."' />
     201        </td></tr>";
    189202    }
    190203
    191204    ?>
     205    </tbody>
     206    </table>
     207    <li class='category-key-list-item'>
     208      <div class='category-key-radio'>
     209          <select name="posttile-transparency" id="posttile-transparency">
     210            <?php for ($i=0;$i<96;$i+=5): ?>
     211            <option value="<?php echo $i/100 ?>" <?php if($posttile_transparency == $i/100) echo 'selected="selected"'; ?> ><?php echo $i ?>%</option>
     212            <?php endfor; ?>
     213                <option value="0" <?php if($posttile_transparency == 0) echo 'selected="selected"'; ?> >100%</option>
     214          </select>
     215      </div>
     216      <div class='category-key-admin'>
     217          <strong>Tile Trasnparency</strong>
     218          <br/>
     219          <small><em>Pick from one of the transparency levels.</em></small>
     220          <!-- An alert that this feature requires jQuery be turned on -->
     221          <?php if($show_key_jquery == 'false') echo '<br/><small class="attention"><em><strong>ATTENTION:</strong> This featured requires jQuery be turned on</em></small>'; ?>
     222      </div>
     223    </li>
     224
    192225    <li class='category-key-list-item'>
    193226      <strong><big>Layout</big></strong>
     
    288321    <li class='category-key-list-item'>
    289322      <div class='category-key-radio'>
    290           <select name="animation-style" id="animation-style">
     323          <select name="animation-style" id="animation-style">static-over
     324            <option value="static-over" <?php if($animation_style == 'static-over') echo 'selected="selected"'; ?>>Static Overlay (no jQuery required)</option>
     325            <option value="static-hide" <?php if($animation_style == 'static-hide') echo 'selected="selected"'; ?>>Static No Overlay (no jQuery required)</option>
    291326            <option value="up" <?php if($animation_style == 'up') echo 'selected="selected"'; ?>>Slide Up</option>
    292327            <option value="down" <?php if($animation_style == 'down') echo 'selected="selected"'; ?>>Slide Down</option>
     
    301336          <small><em>Pick from one of the preselected animations</em></small>
    302337          <!-- An alert that this feature requires jQuery be turned on -->
    303           <?php if($show_key_jquery == 'false') echo '<br/><small class="attention"><em><strong>ATTENTION:</strong> This featured requires jQuery be turned on</em></small>'; ?>
     338          <?php if($show_key_jquery == 'false') echo '<br/><small class="attention"><em><strong>ATTENTION:</strong> This feature may require jQuery be turned on</em></small>'; ?>
    304339      </div>
    305340    </li>
     
    402437       if(empty($animation_style)){
    403438          $animation_style = "up";
     439       }
     440
     441       // Retrieves The Tile Trasnparency
     442       $posttile_transparency = get_option('posttile-transparency');
     443       if(empty($posttile_transparency)){
     444          $posttile_transparency = "100";
    404445       }
    405446
     
    539580          // Recovering Saved Color Values
    540581          // Define the Settings for recording
    541           $cat_var = "cat_".$category_slug;
     582          $cat_bg_var = "cat_bg_".$category_slug;
     583          $cat_tx_var = "cat_tx_".$category_slug;
    542584          // Make lowercase
    543585          //$cat_var_value = strtolower($cat_var);
    544586          //$cat_var = str_replace(" ", "_", $cat_var);
    545587          // Retrieve the option "hexadecimal value" for this category
    546           $cat_var_value = get_option($cat_var);
     588          $cat_bg_var_value = get_option($cat_bg_var);
     589          $cat_tx_var_value = get_option($cat_tx_var);
    547590          // Checks the value to see if it's empty. If it is use default.
    548           if (empty($cat_var_value)){
    549             $cat_var_value = "#afe2f8";
     591          if (empty($cat_bg_var_value)){
     592            $cat_bg_var_value = "#afe2f8";
     593          }
     594          if (empty($cat_tx_var_value)){
     595            $cat_tx_var_value = "#ffffff";
    550596          }
    551597
     
    561607          // Reset featured image bottom border fix
    562608          // There's a margin issue on responsive so this fixes the bottom gap with border
    563           $featured_border = "border-bottom: 3px solid ".$cat_var_value.";border-right: 2px solid ".$cat_var_value.";";
     609          $featured_border = "border-bottom: 3px solid ".$cat_bg_var_value.";border-right: 2px solid ".$cat_bg_var_value.";";
    564610          // If there is a featured image.
    565611          if ($featured_images_key == "true") {
     
    569615                  // Strip featured image down to the url.
    570616                  $url = $thumb['0'];
    571                   $featured_style = "style='background: url(".$url.") no-repeat center center; background-size: cover;' class='featured-image ".$animation_style." ".$cat_var."'";
     617                  $featured_style = "style='background: url(".$url.") no-repeat center center; background-size: cover;' class='featured-image ".$animation_style." ".$cat_bg_var."'";
    572618              } else {
    573                   $featured_style = "class='".$cat_var."'";
     619                  $featured_style = "class='".$cat_bg_var."'";
    574620              }
    575621          }
    576622          // Each output creates the li > link > title > exerpt
    577           $output .= "<li ".$featured_style." class='".$cat_var."' id='".$theID."'><a href='$temp_link' class='".$cat_var."' style='background-color: $cat_var_value; $featured_border'><h3>$temp_title </h3>$temp_excerpt</a></li>\n";
     623          $rgbColor = hex2rgb($cat_bg_var_value);
     624          $rgba_value = "rgba(".$rgbColor[0].",".$rgbColor[1].",".$rgbColor[2].",".$posttile_transparency.")";
     625          $output .= "<li ".$featured_style." class='".$cat_bg_var."' id='".$theID."'><a href='$temp_link' class='".$cat_bg_var."' style='background-color: $rgba_value; color: $cat_tx_var_value; $featured_border'><h3 style='color: $cat_tx_var_value;'>$temp_title </h3>$temp_excerpt</a></li>\n";
    578626          // Each output_key creates a li > category color block > category name
    579627
     
    616664            foreach($categories as $category) {
    617665                    // Set's category names
    618                     $cat_var = $category->name;
     666                    $cat_bg_var = $category->name;
    619667                    // Sets the slug
    620668                    $cat_slug = $category->slug;
    621669                    // Cleans up category names that have spaces
    622                     $cat_var_key = "cat_".$cat_slug;
     670                    $cat_bg_var_key = "cat_bg_".$cat_slug;
    623671                    // Get's the category options which are the hexadecimal colors
    624                     $cat_var_key_val = get_option($cat_var_key);
     672                    $cat_bg_var_key_val = get_option($cat_bg_var_key);
    625673                    // loops through the each category and prints them
    626                     $key_items .= "<a href='#' class='key' id='".$cat_var_key."' style='background-color:".$cat_var_key_val.";'>".$cat_var."</a>\n";
     674                    $key_items .= "<a href='#' class='key' id='".$cat_bg_var_key."' style='background-color:".$cat_bg_var_key_val.";'>".$cat_bg_var."</a>\n";
    627675            }
    628676
     
    644692function post_tiles_stylesheet() {
    645693    $plugin_url = plugins_url()."/post-tiles";
     694    wp_enqueue_style( 'post-tiles', $plugin_url.'/post-tiles.css', false, filemtime( plugin_dir_path( __FILE__ ).'/post-tiles.css' ), 'all' );
    646695    wp_enqueue_style( 'post-tiles', $plugin_url.'/post-tiles.css' );
    647696//  wp_enqueue_script('post-tiles', $plugin_url.'/post-tiles-frontend.js' );
    648697}
     698// Adds tranformations from Hex to RGB color
     699// Example: hex2rgb("#cc0")
     700// Returns: Array ( [0] => 204 [1] => 204 [2] => 0 )
     701// Source: http://bavotasan.com/2011/convert-hex-color-to-rgb-using-php/
     702function hex2rgb($hex) {
     703   $hex = str_replace("#", "", $hex);
     704
     705   if(strlen($hex) == 3) {
     706      $r = hexdec(substr($hex,0,1).substr($hex,0,1));
     707      $g = hexdec(substr($hex,1,1).substr($hex,1,1));
     708      $b = hexdec(substr($hex,2,1).substr($hex,2,1));
     709   } else {
     710      $r = hexdec(substr($hex,0,2));
     711      $g = hexdec(substr($hex,2,2));
     712      $b = hexdec(substr($hex,4,2));
     713   }
     714   $rgb = array($r, $g, $b);
     715   //return implode(",", $rgb); // returns the rgb values separated by commas
     716   return $rgb; // returns an array with the rgb values
     717}
    649718?>
  • post-tiles/trunk/readme.txt

    r1030970 r1031311  
    55Requires at least: 3.0
    66Tested up to: 4.0.0
    7 Stable tag: 1.4.5
     7Stable tag: 1.4.6
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2323*NOTE:* The category id numbers are listed below, next to the category names. You can use both the categories and posts attributes **Example: [post-tiles categories='1,2,4' posts='8' excerpt='18']**
    2424
    25 Version 1.4.3
     25Version 1.4.6
    2626
    2727== Installation ==
     
    4545
    4646== Changelog ==
     47
     48= 1.4.6 =
     49* Thanks to alfred_j_kwack's PR, added text color picking and slide transparency via the admin.
    4750
    4851= 1.4.5 =
Note: See TracChangeset for help on using the changeset viewer.