WordPress.org

Plugin Directory

Changeset 671858


Ignore:
Timestamp:
02/22/13 19:18:50 (14 months ago)
Author:
joedolson
Message:

Minor update. Code updates. 1.2.6

Location:
wp-post-styling
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp-post-styling/trunk/readme.txt

    r576791 r671858  
    44Tags: css, post, page, custom, css, admin, mobile, print, design 
    55Requires at least: 2.5 
    6 Tested up to: 3.4.1 
     6Tested up to: 3.5.1 
    77Stable tag: trunk 
    88 
     
    3131 
    3232== Changelog == 
     33 
     34= 1.2.6 = 
     35 
     36* Miscellaneous wpdb changes, updated coding style.  
     37* Use of wpdb->prepare where appropriate. 
     38* Minor style changes. 
     39* Added plug-in page header image. 
     40* Fixed a couple PHP notices 
    3341 
    3442= 1.2.5 = 
  • wp-post-styling/trunk/styles.css

    r576791 r671858  
    1 #wp-post-styling {margin: 0 15px;} 
     1#wp-post-styling {margin: 0 15px;}  
    22#wp-post-styling fieldset {margin: 0;padding:0;border: none;} 
    33#wp-post-styling legend {font-weight: 700;} 
     
    1111#wp-post-styling .resources form{margin: 0;} 
    1212#wp-style-library {width: 100%;} 
    13 #wp-style-library tr {background: #eaf3fa;} 
    14 #wp-style-library tr.odd {background: none;} 
    15 #wp-style-library td, #wp-style-library th {padding: 3px;} 
    16 #wp-style-library th {border: 1px solid #d9e2f9;} 
    17 #wp-style-library .delete a {background: #a00;color: #fff;padding: 2px 8px;font-size: .8em;border: 1px solid #fff;border-radius: 8px;text-decoration: none;} 
    18 #wp-style-library .delete { text-align: center;} 
    19 #wp-style-library .delete:hover, #wp-style-library .delete:focus {border: 1px solid #999;background: #b11;} 
     13#wp-style-library tr.odd {background: #fafafa;} 
     14#wp-style-library .delete a {color: red; text-decoration: none;} 
     15#wp-style-library .delete a:hover, #wp-style-library .delete a:focus { text-decoration: underline; } 
    2016.post-styling-entries { clear: both; } 
  • wp-post-styling/trunk/wp-post-styling-manager.php

    r576791 r671858  
    2020    }  
    2121    if ( isset($_POST['submit-type']) && $_POST['submit-type'] == 'library' ) { 
    22         if ( (($_POST[ 'jd_style_library_name' ] == "") || ($_POST[ 'jd_style_library_css' ] == "") || ($_POST[ 'jd_style_library_type' ] == "")) && !isset($_POST['delete_style']) ) { 
     22        if ( ( ( !isset( $_POST['jd_style_library_name'] ) || $_POST[ 'jd_style_library_name' ] == "") ||  
     23                ( !isset( $_POST['jd_style_library_css'] ) || $_POST[ 'jd_style_library_css' ] == "") ||  
     24                ( !isset( $_POST['jd_style_library_type'] ) || $_POST[ 'jd_style_library_type' ] == "")) && !isset($_POST['delete_style']) ) { 
    2325        $message = "<ul>"; 
    2426            if ( $_POST[ 'jd_style_library_name' ] == "" ) { 
     
    8991 
    9092<div class="resources"> 
     93<p> 
     94<a href="https://twitter.com/intent/tweet?screen_name=joedolson&text=WP%20Post%20Styling%20is%20great%20-%20Thanks!" class="twitter-mention-button" data-size="large" data-related="joedolson">Tweet to @joedolson</a> 
     95<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 
     96</p> 
    9197<ul> 
    9298<li><a href="http://www.joedolson.com/articles/wp-post-styling/"><?php _e("Get Support",'wp-post-styling'); ?></a></li> 
    9399<li><a href="http://www.joedolson.com/articles/bugs/"><?php _e("Report a bug",'wp-post-styling'); ?></a></li> 
    94 <li><a href="http://wordpress.org/extend/plugins/profile/joedolson"><?php _e("Check out my other plug-ins",'wp-post-styling'); ?></a></li> 
     100<li><a href="http://profiles.wordpress.org/joedolson"><?php _e("Check out my other plug-ins",'wp-post-styling'); ?></a></li> 
    95101<li><form action="https://www.paypal.com/cgi-bin/webscr" method="post"> 
    96102<div> 
  • wp-post-styling/trunk/wp-post-styling.php

    r576791 r671858  
    44Plugin URI: http://www.joedolson.com/articles/wp-post-styling/ 
    55Description: Allows you to define custom styles for any specific post or page on your WordPress site. Helps reduce clutter in your stylesheet. 
    6 Version: 1.2.5 
     6Version: 1.2.6 
    77Author: Joseph Dolson 
    88Author URI: http://www.joedolson.com/ 
    99*/ 
    10 /*  Copyright 2008-2012  Joseph C Dolson  (email : wp-post-styling@joedolson.com) 
     10/*  Copyright 2008-2013  Joseph C Dolson  (email : wp-post-styling@joedolson.com) 
    1111 
    1212    This program is free software; you can redistribute it and/or modify 
     
    5858    jd_fix_post_style_meta(); 
    5959} 
    60 $version = '1.2.5'; 
     60$version = '1.2.6'; 
    6161update_option( 'wp_post_styling_version',$version ); 
    6262 
     
    7171function insert_new_library_style( $name, $css, $type) { 
    7272    global $wpdb; 
    73     $name = $wpdb->escape($name); 
    74     $css = $wpdb->escape($css); 
    75     $type = $wpdb->escape($type); 
    7673    $table_name = $wpdb->prefix . "post_styling_library"; 
    77     $query = "INSERT INTO `$table_name` (`name`,`css`,`type`) 
    78         VALUES ('$name','$css','$type')"; 
    79         $results = $wpdb->query($query); 
     74    $query = "INSERT INTO $table_name (`name`,`css`,`type`) VALUES ('%s','%s','%s')"; 
     75        $results = $wpdb->query( $wpdb->prepare($query, $name, $css, $type ) ); 
     76    if ($results) { 
     77        return TRUE; 
     78    } else { 
     79        return FALSE; 
     80    } 
     81}    
     82     
     83function update_library_style( $id, $name, $css, $type) { 
     84    global $wpdb; 
     85    $table_name = $wpdb->prefix . "post_styling_library"; 
     86    $query = "UPDATE $table_name SET `name`='%s',`css`='%s',`type`='%s' WHERE `id`=%d"; 
     87        $results = $wpdb->query( $wpdb->prepare($query, $name, $css, $type, $id ) ); 
     88    if ($results) { 
     89        return TRUE; 
     90    } else { 
     91        return FALSE; 
     92    } 
     93}    
     94 
     95function delete_library_style( $id ) { 
     96    global $wpdb; 
     97    $table_name = $wpdb->prefix . "post_styling_library"; 
     98    $query = "DELETE FROM $table_name WHERE id=$id"; 
     99        $results = $wpdb->query( $query ); 
    80100    if ($results) { 
    81101    return TRUE; 
     
    83103    return FALSE; 
    84104    } 
    85 }    
    86      
    87 function update_library_style( $id, $name, $css, $type) { 
    88     global $wpdb; 
    89     $name = $wpdb->escape($name); 
    90     $css = $wpdb->escape($css); 
    91     $type = $wpdb->escape($type); 
    92     $table_name = $wpdb->prefix . "post_styling_library"; 
    93     $query = "UPDATE `$table_name` SET `name`='$name',`css`='$css',`type`='$type' WHERE `id`=$id"; 
    94         $results = $wpdb->query($query); 
    95     if ($results) { 
    96     return TRUE; 
    97     } else { 
    98     return FALSE; 
    99     } 
    100 }    
    101  
    102 function delete_library_style( $id ) { 
    103     global $wpdb; 
    104     $table_name = $wpdb->prefix . "post_styling_library"; 
    105     $query = "DELETE FROM `$table_name` WHERE `id`=$id"; 
    106         $results = $wpdb->query($query); 
    107     if ($results) { 
    108     return TRUE; 
    109     } else { 
    110     return FALSE; 
    111     } 
    112105}        
    113106     
     
    116109    $post_styling_db_version = "1.0";    
    117110    $table_name = $wpdb->prefix . "post_styling_library"; 
    118     if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ) { 
    119111    $sql = "CREATE TABLE " . $table_name . " ( 
    120112      id mediumint(9) NOT NULL AUTO_INCREMENT, 
     
    123115      type VARCHAR(32) NOT NULL, 
    124116      UNIQUE KEY id (id) 
    125     );"; 
    126     require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
    127     dbDelta($sql); 
     117    );";     
     118    if ( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ) { 
     119        require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
     120        dbDelta($sql); 
    128121    }    
    129122    add_option( "post_styling_db_version", $post_styling_db_version );   
    130123    $installed_ver = get_option( "post_styling_db_version" ); 
    131124    if ( $installed_ver != $post_styling_db_version ) { 
    132     $sql = "CREATE TABLE " . $table_name . " ( 
    133       id mediumint(9) NOT NULL AUTO_INCREMENT, 
    134       name tinytext NOT NULL, 
    135       css text NOT NULL, 
    136       type VARCHAR(32) NOT NULL, 
    137       UNIQUE KEY id (id) 
    138     );"; 
    139       //require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
    140     require_once(ABSPATH . 'wp-admin/includes/upgrade.php');  
    141     dbDelta($sql); 
    142     update_option( "post_styling_db_version", $post_styling_db_version ); 
     125        require_once(ABSPATH . 'wp-admin/includes/upgrade.php');  
     126        dbDelta($sql); 
     127        update_option( "post_styling_db_version", $post_styling_db_version ); 
    143128    } 
    144129}    
    145130 
    146 function jd_post_style_library_selector($current="screen") { 
    147     // select library items from database where library is print 
     131function jd_post_style_library_selector($library="screen") { 
     132    // select library items from database where library is $library 
    148133    global $wpdb; 
    149134    $prefix = $wpdb->prefix; 
     
    152137        "SELECT `name`, `css` 
    153138        FROM `$dbtable` 
    154         WHERE `type` = '$current' 
     139        WHERE `type` = '$library' 
    155140        ORDER BY name ASC 
    156141        "); 
     
    166151     
    167152function jd_post_style_data($id,$datatype) { 
    168     // select library items from database where library is print 
    169     global $wpdb; 
    170     $prefix = $wpdb->prefix; 
    171     $dbtable = $prefix . 'post_styling_library'; 
    172     $results = $wpdb->get_results( 
    173         "SELECT `$datatype` 
    174         FROM `$dbtable` 
    175         WHERE `id` = '$id' 
    176         "); 
     153    // select library items from database where datatype is $datatype 
     154    global $wpdb; 
     155    $dbtable = $wpdb->prefix . 'post_styling_library'; 
     156    $datatype = esc_sql($datatype); 
     157    $id = (int) $id; 
     158    $results = $wpdb->get_results( "SELECT $datatype FROM $dbtable WHERE id = $id" ); 
    177159    if (count($results)) { 
    178160        foreach ($results as $result) { 
    179             return $result->$datatype; 
     161            return $result->{$datatype}; 
    180162        } 
    181163    }        
     
    185167    // select all library items from database  
    186168    global $wpdb; 
    187     $table = "<table id=\"wp-style-library\" summary=\"".__('Listing of CSS patterns in the Style Library.','wp-post-styling')."\"> 
     169    $table = "<table id=\"wp-style-library\" class=\"widefat\" summary=\"".__('Listing of CSS patterns in the Style Library.','wp-post-styling')."\"> 
    188170<thead>\n<tr>\n <th scope=\"col\">".__('Name','wp-post-styling')."</th>\n   <th scope=\"col\">".__('Styles','wp-post-styling')."</th>\n <th scope=\"col\">".__('Type','wp-post-styling')."</th>\n   <th>".__('Delete','wp-post-styling')."</th>\n</tr>\n</thead> 
    189171<tbody>\n"; 
    190172    $table_end = "</tbody>\n</table>"; 
    191     $prefix = $wpdb->prefix; 
    192     $dbtable = $prefix . 'post_styling_library'; 
     173    $dbtable = $wpdb->prefix . 'post_styling_library'; 
    193174    $results = $wpdb->get_results( 
    194175        "SELECT `id`, `name`, `css`, `type` 
     
    271252    <label for="jd_post_styling_screen_library"><?php _e('Custom Screen Style Library','wp-post-styling'); ?></label><br /><select id="jd_post_styling_screen_library" name="jd_post_styling_screen_library"> 
    272253    <option value="none">Select library style</option> 
    273     <?php 
    274     jd_post_style_library_selector("screen"); 
    275     ?> 
     254    <?php jd_post_style_library_selector("screen"); ?> 
    276255    </select> 
    277256    </p> 
     
    285264    <label for="jd_post_styling_mobile_library"><?php _e('Custom Mobile Style Library','wp-post-styling'); ?></label><br /><select id="jd_post_styling_mobile_library" name="jd_post_styling_mobile_library"> 
    286265    <option value="none">Select library style</option> 
    287     <?php 
    288     jd_post_style_library_selector("mobile"); 
    289     ?>   
     266    <?php jd_post_style_library_selector("mobile"); ?>   
    290267    </select> 
    291268    </p> 
     
    299276    <label for="jd_post_styling_print_library"><?php _e('Custom Print Style Library','wp-post-styling'); ?></label><br /><select id="jd_post_styling_print_library" name="jd_post_styling_print_library"> 
    300277    <option value="none">Select library style</option> 
    301     <?php 
    302     jd_post_style_library_selector("print"); 
    303     ?> 
     278    <?php jd_post_style_library_selector("print"); ?> 
    304279    </select> 
    305280    </p>     
    306281    <?php } ?> 
    307      
    308282    <p><a target="__blank" href="http://www.joedolson.com/articles/wp-post-styling/"><?php _e('Get Support', 'wp-post-styling') ?></a> &raquo; 
    309283</p> 
Note: See TracChangeset for help on using the changeset viewer.