Plugin Directory

Changeset 728081


Ignore:
Timestamp:
06/18/2013 09:53:00 PM (13 years ago)
Author:
JD55
Message:

tagging version 1.1

Location:
chick-comic-embedder
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • chick-comic-embedder/tags/1.1/chick-comic-embedder.php

    r666029 r728081  
    11<?php
    2 /*
    3 Plugin Name: Chick Comic Embedder
    4 Plugin URI: http://dev.efieldguide.com/comic-embedder/
    5 Description: This plugin allows you to embed Jack Chick's great comics into your posts and pages using shortcode.
    6 Version: 1.0
    7 Author: J.D. Grimes
    8 Author URI: http://dev.efieldguide.com/
    9 License: GPL2
    10 */
    112
    12 /*  Copyright 2013  J.D. Grimes  (email : [email protected])
     3/**
     4 * @package Chick_Commic_Embedder
     5 * @author J.D. Grimes
     6 * @license GPLv2
     7 * @version 1.1
     8 *
     9 * Plugin Name: Chick Comic Embedder
     10 * Plugin URI: http://codesymphony.co/comic-embedder/
     11 * Version: 1.1
     12 * Author: J.D. Grimes
     13 * Author URI: http://codesymphony.co/
     14 * License: GPL2
     15 * Description: This plugin allows you to embed Jack Chick's great comics into your posts and pages using shortcode.
     16 *
     17 * ---------------------------------------------------------------------------------|
     18 * Copyright 2013  J.D. Grimes  (email : [email protected])
     19 *
     20 * This program is free software; you can redistribute it and/or modify
     21 * it under the terms of the GNU General Public License, version 2, as
     22 * published by the Free Software Foundation.
     23 *
     24 * This program is distributed in the hope that it will be useful,
     25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     27 * GNU General Public License for more details.
     28 *
     29 * You should have received a copy of the GNU General Public License
     30 * along with this program; if not, write to the Free Software
     31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     32 * ---------------------------------------------------------------------------------|
     33 *
     34 * Developers: for information on adding custom CSS styles, see developers.txt
     35 *
     36 * Let the symphony begin!
     37 */
    1338
    14     This program is free software; you can redistribute it and/or modify
    15     it under the terms of the GNU General Public License, version 2, as
    16     published by the Free Software Foundation.
     39/**
     40 * @const string The plugin's directory.
     41 */
     42define( 'CC_EMBEDDER_DIR', dirname( __FILE__ ) );
    1743
    18     This program is distributed in the hope that it will be useful,
    19     but WITHOUT ANY WARRANTY; without even the implied warranty of
    20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21     GNU General Public License for more details.
     44/**
     45 * Install the plugin.
     46 *
     47 * Adds default settings on activation if they don't already exist.
     48 *
     49 * @since 1.0
     50 */
     51function chickcomic_activation() {
    2252
    23     You should have received a copy of the GNU General Public License
    24     along with this program; if not, write to the Free Software
    25     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    26 */
    27 
    28 /****
    29  * Developers: for information on adding custom CSS styles, see developers.txt
    30  ****/
    31 
    32 /***** Activation *****/
    33 
    34 register_activation_hook( __FILE__, 'chickcomic_activation' );
    35 function chickcomic_activation()
    36 {
    37     /** Add Options **/
    3853    add_option( 'cce_default_comic', '1' );
    3954    add_option( 'cce_default_unavailable', 'random' );
    4055    add_option( 'cce_default_style', 'center' );
     56}
     57register_activation_hook( __FILE__, 'chickcomic_activation' );
    4158
    42     /*
    43      Enable custom styles.
    44      These files are not overwritten. We create them only if they don't already exist.
    45      This allows user's to add their own custom CSS style options.
    46     */
    47    
    48     if ( !stream_resolve_include_path( dirname( __FILE__ ) . '/custom-styles.php' ) )
    49     {
    50         $file = fopen( dirname( __FILE__ ) . '/custom-styles.php', 'w' );
    51         fwrite( $file, '<?php define( "CHICKCOMIC_CUSTOM_STYLES", FALSE ); /* Change this to "TRUE" to enable custom styles. */ ?>' );
    52         fclose( $file );
    53     }
    54    
    55     if ( !stream_resolve_include_path( dirname( __FILE__ ) . '/custom-styles.css' ) )
    56     {
    57         $file = fopen( dirname( __FILE__ ) . '/custom-styles.css', 'w' );
    58         fwrite( $file, '/* You can add your own custom CSS styles in this file. See developers.txt for more information. */' );
    59         fclose( $file );
    60     }
     59/**
     60 * Contains the shortcode functions.
     61 *
     62 * @since 1.0
     63 */
     64include_once( CC_EMBEDDER_DIR . '/shortcode.php' );
     65
     66/**
     67 * Enables the style preview page.
     68 *
     69 * @since 1.0
     70 */
     71include_once( CC_EMBEDDER_DIR . '/style-preview.php' );
     72
     73// Only load this on the admin side.
     74if ( is_admin() ) {
     75
     76    /**
     77     * Settings.
     78     *
     79     * @since 1.0
     80     */
     81    include_once( CC_EMBEDDER_DIR . '/options.php' );
    6182}
    62 
    63 /***** Includes *****/
    64 
    65 // Shortcode.
    66 include dirname( __FILE__ ) . '/shortcode.php';
    67 
    68 // Settings page.
    69 include dirname( __FILE__ ) . '/options.php';
    70 
    71 // Style preview page.
    72 include dirname( __FILE__ ) . '/style-preview.php';
    73 
    74 // Custom styles. Avoid giving an error when the plugin is being activated, and this file hasn't been created yet.
    75 if ( in_array( 'chick-comic-embedder/chick-comic-embedder.php', get_option( 'active_plugins' ) ) ) {
    76     include dirname( __FILE__ ) . '/custom-styles.php';
    77 }
    78 
    79 
    80 /***** Core Functions *****/
    8183
    8284/**
    8385 * Get all available comics.
    84  * @returns (array)  An array of all comics that are currently available.
     86 *
     87 * @since 1.0
     88 *
     89 * @return array All comics that are currently available.
    8590 */
    86 function cce_available_comics()
    87 {
     91function cce_available_comics() {
     92
    8893    return array(
    8994        // id => name
     
    99104/**
    100105 * Get available comic styles.
    101  * @returns (array)  An array of all available comic styles.
     106 *
     107 * @since 1.0
     108 *
     109 * @return array All available comic styles.
    102110 */
    103 function cce_available_styles()
    104 {
     111function cce_available_styles() {
     112
    105113    // Included styles.
    106114    $styles = array(
    107         'none' => 'None',
    108         'center' => 'Center',
    109         'wrap-left' => 'Wrap text (left)',
     115        'none'       => 'None',
     116        'center'     => 'Center',
     117        'wrap-left'  => 'Wrap text (left)',
    110118        'wrap-right' => 'Wrap text (right)',
    111         'inset-box' => 'Inset Box',
    112     ); 
     119        'inset-box'  => 'Inset Box',
     120    );
    113121
    114122    // Allow this to be filtered, so developers can add their own style options.
     
    116124}
    117125
     126/**
     127 * Enqueue the plugin's stylesheets.
     128 *
     129 * @since 1.0
     130 *
     131 * @action wp_enqueue_scripts
     132 */
     133function cce_enqueue_styles() {
    118134
    119 /***** Styles *****/
     135    wp_enqueue_style( 'cce_comics', plugins_url( 'styles.css', __FILE__ ) );
    120136
    121 function cce_enqueue_styles()
    122 {
    123     // Default styles.
    124     wp_register_style('cce_comics', plugins_url( 'styles.css', __FILE__ ) );
    125     wp_enqueue_style('cce_comics');
    126    
    127     // Custom styles.
    128     if ( defined( 'CHICKCOMIC_CUSTOM_STYLES' ) && ( 'CHICKCOMIC_CUSTOM_STYLES' == TRUE ) )
    129     {
    130         wp_register_style('cce_comics_custom', plugins_url( 'custom-styles.css', __FILE__ ) );
    131         wp_enqueue_style('cce_comics_custom');
    132     }
     137    // Let developers add their styles after these are registered.
     138    do_action( 'cce_after_styles_enqueue' );
    133139}
    134 add_action('wp_enqueue_scripts', 'cce_enqueue_styles');
    135 
    136 ?>
     140add_action( 'wp_enqueue_scripts', 'cce_enqueue_styles' );
  • chick-comic-embedder/tags/1.1/developers.txt

    r666029 r728081  
    1 /*********
    2  This file provides some information for developers who want to extend this plugin.
    3  For more info, visit http://dev.efieldguide.com/comic-embedder/
    4 *********/
     1This file provides some information for developers who want to extend this plugin.
     2For more info, visit http://codesymphony.co/comic-embedder/
    53
    6 /*****  Adding Styles  *****/
    74
    8 You can add your own styles to use on the comics.
    9 Simply create your CSS rules for a new class, and add them to custom-styles.css
    10 (That file won't be overwritten when the plugin is updated.)
     5== Adding Styles ==
     6
     7You can add your own styles to use on the comics. Simply create your CSS rules for a
     8new class, and add them to your child theme's style.css file. (If you aren't using a
     9child theme, see http://codex.wordpress.org/Child_Themes).
    1110
    1211For example:
    1312
    14 
    15 .chickcomic-container.my-cool-new-style-class{
    16  /* Your CSS styles here */
     13.chickcomic-container.my-cool-new-style-class {
     14    /* Your CSS styles here */
    1715}
    1816
    19 
    20 
    21 Then you can add your new style to the available styles by adding a filter for the styles in custom-styles.php.
    22 (That file won't be overwritten with the plugin is updated, either.)
     17Then you can add your new style to the available styles by adding a filter for the
     18styles in your child theme's functions.php file.
    2319
    2420For example:
    2521
    26 
    2722<?php
    2823
    29 // Make sure that this is in that file, or else your custom styles will not work.
    30 // By default, this is FALSE, and you should see 'define( "CHICKCOMIC_CUSTOM_STYLES", FALSE )' in the file before you edit it.
    31 // It is safe to remove that, just replace it with this.
     24/**
     25 * A new function for my cool styles.
     26 *
     27 * It needs to take one parameter; this is the array of styles.
     28 *
     29 * @filter chickcomic_styles_filter
     30 *
     31 * @param array $styles The array of styles.
     32 *
     33 * @return array An array of styles.
     34 */
     35function function_for_my_cool_styles( $styles ) {
    3236
    33 define( 'CHICKCOMIC_CUSTOM_STYLES', TRUE );
     37    /*
     38     * Add a new element to the array of styles.
     39     * Make sure that the [key] matches the new class you added in the CSS.
     40     * The value is the name of your style, and can be whatever you want.
     41     */
     42    $styles['my-cool-new-style-class'] = 'My Cool New Style';
    3443
    35 
    36 // Add a new function. It needs to take one parameter; this is the array of styles.
    37 
    38 function function_for_my_cool_styles( $styles )
    39 {
    40     // Add a new element to the array of styles.
    41     // Make sure that the [key] matches the new class you added in the CSS.
    42     // The value is the name of your style, and can be whatever you want.
    43    
    44     $styles['my-cool-new-style-class'] = 'My Cool New Style';
    45    
    4644    // If you don't return the $styles array, then no styles will work!
    47    
    4845    return $styles;
    4946}
    5047add_filter( 'chickcomic_styles_filter', 'function_for_my_cool_styles' );
    5148
    52 // ^^^^ We tell WordPress that we want add this function as a part of the chickcomic_styles_filter.
     49// ^^ Tell WordPress to add this function as a filter for the Chick Comic styles.
    5350
    5451?>
    5552
     53Now you will be able to use your style in the shortcode, and even set it as the
     54default on the settings page if you want. You can even preview it along with all the
     55other styles on the preview page!
     56
     57Additional info: http://codesymphony.co/comic-embedder/#custom-styles
    5658
    5759
    58 Now you will be able to use your style in the shortcode, and even set it as the default if you want, on the settings page.
    59 You can even preview it along with all the other styles on the preview page!
     60== Embeding Comics without shortcode ==
    6061
    61 Additional info: http://dev.efieldguide.com/comic-embedder/#custom-styles
    62 
    63 
    64 /*****  Embeding Comics without shortcode  *****/
    65 
    66 You can embed comics in posts and pages with the shortcode, but what if you want to do something else,
    67 like display a random comic in the footer of your website?
    68 You can do that using the display_chickcomic() function.
    69 This is the function that the shortcode uses to display the comics.
    70 The function takes the same three parameters as the shortcode, the only difference being that they must be in order:
     62You can embed comics in posts and pages with the shortcode, but what if you want to
     63do something else, like display a random comic in the footer of your website? You can
     64do that using the display_chickcomic() function. This is the function that the
     65shortcode uses to display the comics. The function takes the same three parameters as
     66the shortcode, the only difference being that they must be in order:
    7167
    72681. The id or title of a comic, or 'latest' or 'random'.
    73 2. What to display if the comic is unavailable: 'none', 'default', 'random'.
     692. What to display if the comic is unavailable: 'none', 'default', or 'random'.
    74703. What style to give the comic.
    7571
    76 As with the shortcode, these are all optional, and if they aren't set the defaults will be used.
    77 So you could call the function like this, with no parameters:
     72As with the shortcode, these are all optional, and if they aren't set the defaults
     73will be used. So you could call the function like this, with no parameters:
    7874
    7975display_chickcomic();
     
    8177Or will all parameters:
    8278
    83 display_chickcomic('1', 'none', 'inset-box');
     79display_chickcomic( '1', 'none', 'inset-box' );
    8480
    85 If you want to leave out a parameter, but set a later parameter, then just pass NULL:
     81If you want to leave out a parameter, but set a later parameter, then just pass null
     82in place of that parameter:
    8683
    87 display_chickcomic('random', NULL, 'inset-box');
     84display_chickcomic( 'random', null, 'inset-box' );
    8885
    89 You can use this function anywhere in your PHP code.
    90 The function returns a string, which you will have to echo() to display the comic.
     86You can use this function anywhere in your PHP code. The function returns a string,
     87which you will have to echo() to display the comic.
     88
    9189For example:
    9290
    9391echo( display_chickcomic() );
    9492
    95 Additional info: http://dev.efieldguide.com/comic-embedder/#developers
     93Additional info: http://codesymphony.co/comic-embedder/#developers
    9694
    9795
    98 /*****  Aditional Help  *****/
     96== Aditional Help ==
    9997
    100 If you need help, or have any questions, please see http://dev.efieldguide.com/comic-embedder/
    101 
     98If you need help, or have any questions, please see http://codesymphony.co/comic-embedder/
  • chick-comic-embedder/tags/1.1/options.php

    r666029 r728081  
    11<?php
    22
    3 /** Add Settings Page **/
    4 function chickcomic_settings_menu()
    5 {
     3/**
     4 * Settings.
     5 *
     6 * This plugin uses the Settings API to keep track of the settings.
     7 *
     8 * @package Chick_Comic_Embedder
     9 * @since 1.0
     10 */
     11
     12/**
     13 * Add the settings page to the admin menu.
     14 *
     15 * @since 1.0
     16 *
     17 * @action admin_menu
     18 */
     19function chickcomic_settings_menu() {
     20
    621    add_options_page(
    722        'Comic Settings',
     
    1126        'chickcomic_settings_page'
    1227    );
    13 
    1428}
    1529add_action( 'admin_menu', 'chickcomic_settings_menu' );
    1630
    17 /** Settings Page Content **/
    18 function chickcomic_settings_page()
    19 {
     31/**
     32 * Display the settings page.
     33 *
     34 * @since 1.0
     35 */
     36function chickcomic_settings_page() {
     37
    2038    ?>
    21    
     39
    2240    <div class="wrap">
    23 
    24      <?php screen_icon(); ?>
    25 
    26      <h2>Comic Settings</h2>
    27      <p>The three parameters of the [chickcomic] shortcode are optional. Here you can set the default values for these parameters. These settings can be overridden by using the paremeters in the shortcode. The values in [braces] are what you need to use in the shortcode. The exception is the comic titles, which can be used instead of the id numbers.</p>
    28      <p>Some examples:</p>
    29      <ul>
    30      <li>[chickcomic comic="This was your life"] will display the comic titled "This Was Your Life".</li>
    31      <li>[chickcomic comic="1"] will also display the comic "This Was Your Life."</li>
    32      <li>[chickcomic comic="random"] will display a random comic.</li>
    33      <li>[chickcomic comic="5" unavailable="none"] This will display the comic titled "Unloved". If that comic becomes unavailable, then the shortcode will display nothing.</li>
    34      </ul>
    35      <form method="post" action="options.php">
    36 
    37       <?php
    38      
    39       settings_fields( 'chickcomic_settings_group' );
    40       do_settings_sections( 'chick_comics' );
    41       submit_button();
    42      
    43       ?>
    44 
    45      </form>
     41        <?php screen_icon(); ?>
     42        <h2>Comic Settings</h2>
     43        <p>
     44            The three parameters of the <code>[chickcomic]</code> shortcode are optional. Here you can set the default values for these parameters.<br />
     45            These settings can be overridden by using the paremeters in the shortcode. The values in [braces] are what you need to use in the shortcode.<br />
     46            The exception is the comic titles, which can be used instead of the id numbers.
     47        </p>
     48        <p>Some examples:</p>
     49        <ul>
     50            <li><code>[chickcomic comic="This was your life"]</code> will display the comic titled "This Was Your Life".</li>
     51            <li><code>[chickcomic comic="1"]</code> will also display the comic "This Was Your Life."</li>
     52            <li><code>[chickcomic comic="random"]</code> will display a random comic.</li>
     53            <li><code>[chickcomic comic="5" unavailable="none"]</code> This will display the comic titled "Unloved". If that comic becomes unavailable, then the shortcode will display nothing.</li>
     54            <li><code>[chickcomic style="inset-box"]</code> This will display the default comic with the inset box style.</li>
     55        </ul>
     56        <form method="post" action="options.php">
     57
     58        <?php
     59            settings_fields( 'chickcomic_settings_group' );
     60            do_settings_sections( 'chick_comics' );
     61            submit_button();
     62        ?>
     63
     64        </form>
     65
     66        <br /><br />
     67        <i>For information on this plugin, see <a href="http://codesymphony.co/comic-embedder/">here</a>.</i>
    4668    </div>
    4769
     
    4971}
    5072
    51 /** Settings Initialization **/
    52 function chickcomic_settings_init()
    53 {
    54     // Default comic.
     73/**
     74 * Initialize settings.
     75 *
     76 * @since 1.0
     77 *
     78 * @action admin_init
     79 */
     80function chickcomic_settings_init() {
     81
     82    /*
     83     * Default comic.
     84     */
     85
    5586    add_settings_section(
    5687        'cce_default_comic_section',
     
    5990        'chick_comics'
    6091    );
     92
    6193    add_settings_field(
    6294        'cce_default_comic',
     
    6698        'cce_default_comic_section'
    6799    );
     100
    68101    register_setting( 'chickcomic_settings_group', 'cce_default_comic' );
    69    
    70     // Default unavailable action.
     102
     103    /*
     104     * Default unavailable action.
     105     */
     106
    71107    add_settings_section(
    72108        'cce_default_unavailable_section',
     
    75111        'chick_comics'
    76112    );
     113
    77114    add_settings_field(
    78115        'cce_default_unavailable',
     
    82119        'cce_default_unavailable_section'
    83120    );
     121
    84122    register_setting( 'chickcomic_settings_group', 'cce_default_unavailable' );
    85123
    86     // Default style.
     124    /*
     125     * Default style.
     126     */
     127
    87128    add_settings_section(
    88129        'cce_default_style_section',
     
    91132        'chick_comics'
    92133    );
     134
    93135    add_settings_field(
    94136        'cce_default_style',
     
    98140        'cce_default_style_section'
    99141    );
     142
    100143    register_setting( 'chickcomic_settings_group', 'cce_default_style' );
    101144}
    102145add_action( 'admin_init', 'chickcomic_settings_init' );
    103146
     147/**
     148 * Callback to display the default commic section description.
     149 *
     150 * @since 1.0
     151 */
    104152function cce_default_comic_section_callback() {
     153
    105154    echo( 'What comic should the shortcode display by default? You can choose a particular title, or have the shortcode display a random comic, or the latest comic. <a href="http://www.chick.com/cartoons/embed.asp" target="_blank">Preview the available comics on chick.com</a>' );
    106155}
    107156
     157/**
     158 * Callback to display the default commic unavailabe section description.
     159 *
     160 * @since 1.0
     161 */
    108162function cce_default_unavailable_section_callback() {
    109     echo( 'The available comics change every few months. (That is entirely outside of the plugin author\'s control). By default, what should be displayed if the comic specified in the shortcode is unavailable?' );
    110 }
    111 
     163
     164    echo( 'The available comics change occasionally. (That is entirely outside of the plugin author\'s control). By default, what should be displayed if the comic specified in the shortcode is unavailable?' );
     165}
     166
     167/**
     168 * Callback to display the default style section description.
     169 *
     170 * @since 1.0
     171 */
    112172function cce_default_style_section_callback() {
    113     echo( 'Choose a default style for the comics. <a href="'. site_url( '/?cce_preview_styles=1' ) .'" target="_blank">Preview the different styles</a>.' );
    114 }
    115 
    116 /** Default Comic Form Input **/
    117 function cce_default_comic_input()
    118 {
     173
     174    echo( 'Choose a default style for the comics. <a href="' . add_query_arg( 'cce_preview_styles', 1, site_url() ) . '" target="_blank">Preview the different styles</a>.' );
     175}
     176
     177/**
     178 * Display default comic form field.
     179 *
     180 * @since 1.0
     181 */
     182function cce_default_comic_input() {
     183
    119184    // Available comics.
    120185    $comics = cce_available_comics();
    121186    $comics['random'] = 'A Random Comic';
    122187    $comics['latest'] = 'The Latest Comic';
    123    
     188
    124189    // Current default.
    125190    $current = get_option( 'cce_default_comic' );
     
    128193    $html = '<select id="cce_default_comic" name="cce_default_comic">';
    129194
    130     foreach ($comics as $id => $title)
    131     {
    132         $html .= '<option value="'. $id .'"';
    133         if ($id == $current) $html .= ' selected="selected"';
    134         $html .= '>['. $id .'] '. $title .'</option>';
     195    foreach ( $comics as $id => $title ) {
     196
     197        $html .= '<option value="' . $id . '"';
     198        if ( $id == $current ) $html .= ' selected="selected"';
     199        $html .= '>[' . $id . '] ' . $title . '</option>';
    135200    }
    136    
     201
    137202    $html .= '</select>';
    138203
     
    140205}
    141206
    142 /** Default Comic Unavailable Form Input **/
    143 function cce_default_unavailable_input()
    144 {
     207/**
     208 * Display default comic unavailable form field.
     209 *
     210 * @since 1.0
     211 */
     212function cce_default_unavailable_input() {
     213
    145214    // Available options.
    146215    $options = array(
    147         'random' => 'Random Comic',
     216        'random'  => 'Random Comic',
    148217        'default' => 'Default Comic',
    149         'none' => 'Nothing',
    150     );
    151    
     218        'none'    => 'Nothing',
     219    );
     220
    152221    // Current default.
    153222    $current = get_option( 'cce_default_unavailable' );
    154    
     223
    155224    // Build <select> element.
    156225    $html = '<select id="cce_default_unavailable" name="cce_default_unavailable">';
    157226
    158     foreach ($options as $value => $text)
    159     {
    160         $html .= '<option value="'. $value .'"';
    161         if ($value == $current) $html .= ' selected="selected"';
    162         $html .= '>['. $value .'] '. $text .'</option>';
     227    foreach ( $options as $value => $text ) {
     228
     229        $html .= '<option value="' . $value . '"';
     230        if ( $value == $current ) $html .= ' selected="selected"';
     231        $html .= '>[' . $value . '] ' . $text . '</option>';
    163232    }
    164    
     233
    165234    $html .= '</select>';
    166235
    167     echo( $html ); 
    168 }
    169 
    170 /** Default Comic Style Form Input **/
    171 function cce_default_style_input()
    172 {
     236    echo( $html );
     237}
     238
     239/**
     240 * Display default style form field.
     241 *
     242 * @since 1.0
     243 */
     244function cce_default_style_input() {
     245
    173246    // Available options.
    174247    $options = cce_available_styles();
    175    
     248
    176249    // Current default.
    177250    $current = get_option( 'cce_default_style' );
    178    
     251
    179252    // Build <select> element.
    180253    $html = '<select id="cce_default_style" name="cce_default_style">';
    181254
    182     foreach ($options as $value => $name)
    183     {
    184         $html .= '<option value="'. $value .'"';
    185         if ($value == $current) $html .= ' selected="selected"';
    186         $html .= '>['. $value .'] '. $name .'</option>';
     255    foreach ( $options as $value => $name ) {
     256
     257        $html .= '<option value="' . $value . '"';
     258        if ( $value == $current ) $html .= ' selected="selected"';
     259        $html .= '>[' . $value . '] ' . $name . '</option>';
    187260    }
    188    
     261
    189262    $html .= '</select>';
    190263
    191     echo( $html ); 
    192 }
    193 
    194 ?>
     264    echo( $html );
     265}
  • chick-comic-embedder/tags/1.1/readme.txt

    r666370 r728081  
    1 === Plugin Name ===
     1=== Chick Comic Embedder ===
    22Contributors: JD55
    3 Donate link: http://dev.efieldguide.com/
     3Donate link: http://codesymphony.co/
    44Tags: comics, shortcode, comic, chick, tract
    55Requires at least: 2.7.0
    66Tested up to: 3.5.1
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3939== Changelog ==
    4040
     41= 1.1 =
     42* Removed support for the custom-styles.css and custom-styles.php files.
     43* Docblocked code and generally improved code formatting.
     44
    4145= 1.0 =
    4246* Initial release.
     
    4448== Upgrade Notice ==
    4549
     50= 1.1 =
     51**IMPORTANT!** If you are using the custom-styles.css and/or custom-styles.php files to customize this plugin, please move your code to a child theme **before** upgrading. Otherwise it will be overwritten.
     52
    4653= 1.0 =
    4754The initial release.
  • chick-comic-embedder/tags/1.1/shortcode.php

    r666029 r728081  
    11<?php
    22
    3 /** Register Shortcode **/
    4 function chickcomic_shortcode($atts)
    5 {
    6     extract( shortcode_atts( array(
    7         'comic' => get_option( 'cce_default_comic' ),
    8         'unavailable' => get_option( 'cce_default_unavailable' ),
    9         'style' => get_option( 'cce_default_style' ),
    10     ), $atts ) );
     3/**
     4 * Shortcode.
     5 *
     6 * This file contains the shortcode handler and the display_chickcomic() function.
     7 *
     8 * @package Chick_Commic_Embedder
     9 * @since 1.0
     10 */
     11
     12/**
     13 * Shortcode handler.
     14 *
     15 * @since 1.0
     16 *
     17 * @shortcode chickcomic
     18 *
     19 * @uses display_chickcomic() To get the commic.
     20 *
     21 * @param array $atts The shortcode atts.
     22 *
     23 * @return string HTML for a commic.
     24 */
     25function chickcomic_shortcode( $atts ) {
     26
     27    extract(
     28        shortcode_atts(
     29            array(
     30                'comic'       => get_option( 'cce_default_comic' ),
     31                'unavailable' => get_option( 'cce_default_unavailable' ),
     32                'style'       => get_option( 'cce_default_style' ),
     33            ),
     34            $atts
     35        )
     36    );
    1137
    1238    return display_chickcomic( $comic, $unavailable, $style );
     
    1541
    1642/**
    17  * Display a comic. (This is the function used by the shortcode.)
     43 * Get a comic to display.
    1844 *
    19  * @param $id (numeric|string)  The id of the comic | 'random' | 'latest' | The title of a comic.
    20  * @param $unavailable (string)  The action to take if the asked for comic is unavailable.
    21  * @param $style (string)  The HTML class to apply to the comic container element.
     45 * Despite it's unfortunate name, this function does not actually output anything,
     46 * but instead returns a string of HTML that can be used to display a commic.
    2247 *
    23  * @returns (string|bool)  The HTML for a comic (or FALSE on failure).
     48 * @param numeric|string $id The id or title of the comic or 'random' or 'latest'.
     49 * @param string $unavailable What to do if the requested comic is unavailable.
     50 * @param string $style The HTML class to apply to the comic container element.
     51 *
     52 * @return string|bool The HTML for a comic, or false if the comic is unavailable and
     53 *         $unavailable is set to 'none'.
    2454 */
    25 function display_chickcomic( $comic = NULL, $unavailable = NULL, $style = NULL )
    26 {
    27     // Get array of available comics.
     55function display_chickcomic( $comic = null, $unavailable = null, $style = null ) {
     56
     57    // Get the array of available comics.
    2858    $comics = cce_available_comics();
    2959
    3060    // If the $comic isn't set we use the default.
    31     if ( empty( $comic ) )
    32     {
     61    if ( empty( $comic ) ) {
     62
    3363        $comic = get_option( 'cce_default_comic' );
    34        
    35        // If it's set, but not a valid id...
    36     } elseif ( !isset( $comics[$comic] ) && $comic != 'random' && $comic != 'latest' ) {   
    37         // Check if it's a comic title. First capitalize the first letter of each word.
     64
     65     // If it's set, but not a valid id
     66    } elseif ( !isset( $comics[ $comic ] ) && $comic != 'random' && $comic != 'latest' ) {
     67
     68        // Check if it's a comic title. Capitalize the first letter of each word.
    3869        $comic = ucwords( strtolower( $comic ) );
    39         if ( in_array( $comic, $comics ) )
    40         {
     70
     71        if ( in_array( $comic, $comics ) ) {
     72
    4173            $comic = array_search( $comic, $comics );
    42            
    43            // If it's not, then the comic is unavailable.
     74
     75         // If it's not, then the comic is unavailable.
    4476        } else {
     77
    4578            // If $unavailble isn't set, we use the default.
    46             if ( empty( $unavailable ) ) {
     79            if ( empty( $unavailable ) )
    4780                $unavailable = get_option( 'cce_default_unavailable' );
    48             }
    49    
    50             switch( $unavailable )
    51             {
     81
     82            switch ( $unavailable ) {
     83
    5284                case 'random':
    53                     $comic = 'random'; break;
     85                    $comic = 'random';
     86                break;
     87
    5488                case 'default':
    55                     $comic = get_option( 'cce_default_comic' ); break;
     89                    $comic = get_option( 'cce_default_comic' );
     90                break;
     91
    5692                case 'none':
    57                     return FALSE;
     93                    return false;
     94
    5895                default:
    5996                    $comic = 'random';
     
    6299    }
    63100
    64     // If we are going to display a random comic, we pick a random one to display.
    65     if ( $comic == 'random' ) {
    66         $comic = array_rand( $comics );
    67     }
    68    
    69     // If we are going to display the latest comic.
    70     if ( $comic == 'latest' ) {
    71         $comic_file = 'preview';
    72     } else {
    73         $comic_file = 'tract_' . $comic;
    74     }
    75    
    76     // Checking what style to give the comic.
    77     $styles = cce_available_styles();
    78     if ( empty( $style ) ) {
    79         $style = get_option( 'cce_default_style' );
     101    switch ( $comic ) {
     102
     103        // If we are going to display the latest comic.
     104        case 'latest':
     105            $comic_file = 'preview';
     106        break;
     107
     108        // If we are going to display a random comic, pick a random one to display.
     109        case 'random':
     110            $comic = array_rand( $comics );
     111
     112        default:
     113            $comic_file = 'tract_' . $comic;
    80114    }
    81115
    82     // If we aren't going to give the comic a style.
    83     if ( $style == 'none' ) {
     116    // Get the available styles.
     117    $styles = cce_available_styles();
     118
     119    // If this one isn't value use the default.
     120    if ( ! isset( $styles[ $style ] ) && $style != 'none' )
     121        $style = get_option( 'cce_default_style' );
     122
     123    if ( 'none' == $style )
    84124        $style = '';
    85     }
    86    
     125
    87126    // Return the HTML for the comic.
    88     return '<div class="chickcomic-container '. $style .'">
    89         <object width="425" height="240">
    90         <param name="movie" value="http://media.chick.com/'. $comic_file .'.swf"></param>
    91         <param name="wmode" value="transparent"></param>
    92         <embed src="http://media.chick.com/'. $comic_file .'.swf" type="application/x-shockwave-flash" wmode="transparent" width="425" height="240"></embed>
    93         </object></div>';
     127    return '<div class="chickcomic-container ' . $style . '">
     128            <object width="425" height="240">
     129                <param name="movie" value="http://media.chick.com/' . $comic_file . '.swf"></param>
     130                <param name="wmode" value="transparent"></param>
     131                <embed src="http://media.chick.com/' . $comic_file . '.swf" type="application/x-shockwave-flash" wmode="transparent" width="425" height="240"></embed>
     132            </object>
     133        </div>';
    94134}
    95 
    96 ?>
  • chick-comic-embedder/tags/1.1/style-preview.php

    r666029 r728081  
    33/**
    44 * Enable a page where user's can preview all available styles.
     5 *
     6 * @package Chick_Comic_Embedder
     7 * @since 1.0
    58 */
    69
    7 // Add query var.
    8 function cce_style_query_var( $query_vars )
    9 {
     10/**
     11 * Add query var.
     12 *
     13 * @since 1.0
     14 *
     15 * @filter query_vars
     16 */
     17function cce_style_query_var( $query_vars ) {
     18
    1019    $query_vars[] = 'cce_preview_styles';
    1120    return $query_vars;
     
    1322add_filter( 'query_vars', 'cce_style_query_var' );
    1423
    15 // Process request.
    16 function cce_styles_parse_request( &$wp )
    17 {
    18     // If the style preview page is being requested...
    19     if ( array_key_exists( 'cce_preview_styles', $wp->query_vars ) )
    20     {
    21         // We load the custom template.
    22         include dirname( __FILE__ ) . '/styles-preview-template.php';
     24/**
     25 * Process request.
     26 *
     27 * @since 1.0
     28 *
     29 * @action parse_request
     30 */
     31function cce_styles_parse_request( &$wp ) {
     32
     33    // If the style preview page is being requested, load the custom template.
     34    if ( array_key_exists( 'cce_preview_styles', $wp->query_vars ) ) {
     35
     36        include( dirname( __FILE__ ) . '/styles-preview-template.php' );
    2337        exit();
    2438    }
    25    
     39
    2640    return;
    2741}
    2842add_action( 'parse_request', 'cce_styles_parse_request' );
    29 
    30 ?>
  • chick-comic-embedder/tags/1.1/styles-preview-template.php

    r666029 r728081  
    33/**
    44 * A custom page template used to display the page of all available comic styles.
     5 *
     6 * @package Chick_Commic_Embedder
     7 * @since 1.0
    58 */
    69
     
    811
    912?>
    10    
     13
    1114<div class="entry-content">
    1215    <h2>Chick Comic Styles</h2>
    1316    <br />
    14     <p>Preview all available styles for the Chick comics. You can also create your own styles. For more information, see <a href="http://dev.efieldguide.com/comic-embedder/#cusom-styles">here</a>, or read the developers.txt file included with the plugin.</p>
     17    <p>Preview all available styles for the Chick comics. You can also create your own styles. For more information, see <a href="http://codesymphony.co/comic-embedder/#cusom-styles">here</a>, or read the developers.txt file included with the plugin.</p>
    1518    <br />
    1619    <br />
    17    
     20
    1821    <?php
    19    
     22
    2023    $styles = cce_available_styles();
    21    
    22     $lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
    23    
    24     foreach ( $styles as $style => $name )
    25     {
    26         echo( '<h3>'. $name .'</h3><br />' );
    27         echo( $lorem . $lorem );
     24
     25    $lorem_ipsum = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
     26
     27    foreach ( $styles as $style => $name ) {
     28
     29        echo( '<h3>' . $name . '</h3><br />' );
     30        echo( $lorem_ipsum . $lorem_ipsum );
    2831        echo( display_chickcomic( '1', 'random', $style ) );
    29         echo( $lorem . $lorem . $lorem );
     32        echo( $lorem_ipsum . $lorem_ipsum . $lorem_ipsum );
    3033        echo( '<br /><br /><hr /><br />' );
    3134    }
    32    
     35
    3336    ?>
    3437
  • chick-comic-embedder/tags/1.1/styles.css

    r666029 r728081  
    1 .chickcomic-container{
    2  margin:15px;
    3  height:240px;
     1/**
     2 * Chick Comic Embedder styles.
     3 *
     4 * @package Chick_Comic_Embedder
     5 * @since 1.0
     6 */
     7
     8.chickcomic-container {
     9    margin: 15px;
     10    height: 240px;
    411}
    5 .chickcomic-container.center{
    6  margin:15px auto;
    7  width:425px;
     12
     13.chickcomic-container.center {
     14    margin: 15px auto;
     15    width: 425px;
    816}
    9 .chickcomic-container.inset-box{
    10  padding:20px;
    11  margin:50px 0px;
    12  box-shadow:0px 0px 10px rgb(0, 0, 0) inset;
     17
     18.chickcomic-container.inset-box {
     19    padding: 20px;
     20    margin: 50px 0px;
     21    box-shadow: 0px 0px 10px rgb(0, 0, 0) inset;
    1322}
    14 .chickcomic-container.inset-box object{
    15  margin:auto;
    16  display:block;
     23
     24.chickcomic-container.inset-box object {
     25    margin: auto;
     26    display: block;
    1727}
    18 .chickcomic-container.wrap-left{
    19  float:left;
    20  margin-left:0px;
     28
     29.chickcomic-container.wrap-left {
     30    float: left;
     31    margin-left: 0px;
    2132}
    22 .chickcomic-container.wrap-right{
    23  float:right;
    24  margin-right:0px;
     33
     34.chickcomic-container.wrap-right {
     35    float: right;
     36    margin-right: 0px;
    2537}
  • chick-comic-embedder/trunk/chick-comic-embedder.php

    r666029 r728081  
    11<?php
    2 /*
    3 Plugin Name: Chick Comic Embedder
    4 Plugin URI: http://dev.efieldguide.com/comic-embedder/
    5 Description: This plugin allows you to embed Jack Chick's great comics into your posts and pages using shortcode.
    6 Version: 1.0
    7 Author: J.D. Grimes
    8 Author URI: http://dev.efieldguide.com/
    9 License: GPL2
    10 */
    112
    12 /*  Copyright 2013  J.D. Grimes  (email : [email protected])
     3/**
     4 * @package Chick_Commic_Embedder
     5 * @author J.D. Grimes
     6 * @license GPLv2
     7 * @version 1.1
     8 *
     9 * Plugin Name: Chick Comic Embedder
     10 * Plugin URI: http://codesymphony.co/comic-embedder/
     11 * Version: 1.1
     12 * Author: J.D. Grimes
     13 * Author URI: http://codesymphony.co/
     14 * License: GPL2
     15 * Description: This plugin allows you to embed Jack Chick's great comics into your posts and pages using shortcode.
     16 *
     17 * ---------------------------------------------------------------------------------|
     18 * Copyright 2013  J.D. Grimes  (email : [email protected])
     19 *
     20 * This program is free software; you can redistribute it and/or modify
     21 * it under the terms of the GNU General Public License, version 2, as
     22 * published by the Free Software Foundation.
     23 *
     24 * This program is distributed in the hope that it will be useful,
     25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     27 * GNU General Public License for more details.
     28 *
     29 * You should have received a copy of the GNU General Public License
     30 * along with this program; if not, write to the Free Software
     31 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     32 * ---------------------------------------------------------------------------------|
     33 *
     34 * Developers: for information on adding custom CSS styles, see developers.txt
     35 *
     36 * Let the symphony begin!
     37 */
    1338
    14     This program is free software; you can redistribute it and/or modify
    15     it under the terms of the GNU General Public License, version 2, as
    16     published by the Free Software Foundation.
     39/**
     40 * @const string The plugin's directory.
     41 */
     42define( 'CC_EMBEDDER_DIR', dirname( __FILE__ ) );
    1743
    18     This program is distributed in the hope that it will be useful,
    19     but WITHOUT ANY WARRANTY; without even the implied warranty of
    20     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    21     GNU General Public License for more details.
     44/**
     45 * Install the plugin.
     46 *
     47 * Adds default settings on activation if they don't already exist.
     48 *
     49 * @since 1.0
     50 */
     51function chickcomic_activation() {
    2252
    23     You should have received a copy of the GNU General Public License
    24     along with this program; if not, write to the Free Software
    25     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    26 */
    27 
    28 /****
    29  * Developers: for information on adding custom CSS styles, see developers.txt
    30  ****/
    31 
    32 /***** Activation *****/
    33 
    34 register_activation_hook( __FILE__, 'chickcomic_activation' );
    35 function chickcomic_activation()
    36 {
    37     /** Add Options **/
    3853    add_option( 'cce_default_comic', '1' );
    3954    add_option( 'cce_default_unavailable', 'random' );
    4055    add_option( 'cce_default_style', 'center' );
     56}
     57register_activation_hook( __FILE__, 'chickcomic_activation' );
    4158
    42     /*
    43      Enable custom styles.
    44      These files are not overwritten. We create them only if they don't already exist.
    45      This allows user's to add their own custom CSS style options.
    46     */
    47    
    48     if ( !stream_resolve_include_path( dirname( __FILE__ ) . '/custom-styles.php' ) )
    49     {
    50         $file = fopen( dirname( __FILE__ ) . '/custom-styles.php', 'w' );
    51         fwrite( $file, '<?php define( "CHICKCOMIC_CUSTOM_STYLES", FALSE ); /* Change this to "TRUE" to enable custom styles. */ ?>' );
    52         fclose( $file );
    53     }
    54    
    55     if ( !stream_resolve_include_path( dirname( __FILE__ ) . '/custom-styles.css' ) )
    56     {
    57         $file = fopen( dirname( __FILE__ ) . '/custom-styles.css', 'w' );
    58         fwrite( $file, '/* You can add your own custom CSS styles in this file. See developers.txt for more information. */' );
    59         fclose( $file );
    60     }
     59/**
     60 * Contains the shortcode functions.
     61 *
     62 * @since 1.0
     63 */
     64include_once( CC_EMBEDDER_DIR . '/shortcode.php' );
     65
     66/**
     67 * Enables the style preview page.
     68 *
     69 * @since 1.0
     70 */
     71include_once( CC_EMBEDDER_DIR . '/style-preview.php' );
     72
     73// Only load this on the admin side.
     74if ( is_admin() ) {
     75
     76    /**
     77     * Settings.
     78     *
     79     * @since 1.0
     80     */
     81    include_once( CC_EMBEDDER_DIR . '/options.php' );
    6182}
    62 
    63 /***** Includes *****/
    64 
    65 // Shortcode.
    66 include dirname( __FILE__ ) . '/shortcode.php';
    67 
    68 // Settings page.
    69 include dirname( __FILE__ ) . '/options.php';
    70 
    71 // Style preview page.
    72 include dirname( __FILE__ ) . '/style-preview.php';
    73 
    74 // Custom styles. Avoid giving an error when the plugin is being activated, and this file hasn't been created yet.
    75 if ( in_array( 'chick-comic-embedder/chick-comic-embedder.php', get_option( 'active_plugins' ) ) ) {
    76     include dirname( __FILE__ ) . '/custom-styles.php';
    77 }
    78 
    79 
    80 /***** Core Functions *****/
    8183
    8284/**
    8385 * Get all available comics.
    84  * @returns (array)  An array of all comics that are currently available.
     86 *
     87 * @since 1.0
     88 *
     89 * @return array All comics that are currently available.
    8590 */
    86 function cce_available_comics()
    87 {
     91function cce_available_comics() {
     92
    8893    return array(
    8994        // id => name
     
    99104/**
    100105 * Get available comic styles.
    101  * @returns (array)  An array of all available comic styles.
     106 *
     107 * @since 1.0
     108 *
     109 * @return array All available comic styles.
    102110 */
    103 function cce_available_styles()
    104 {
     111function cce_available_styles() {
     112
    105113    // Included styles.
    106114    $styles = array(
    107         'none' => 'None',
    108         'center' => 'Center',
    109         'wrap-left' => 'Wrap text (left)',
     115        'none'       => 'None',
     116        'center'     => 'Center',
     117        'wrap-left'  => 'Wrap text (left)',
    110118        'wrap-right' => 'Wrap text (right)',
    111         'inset-box' => 'Inset Box',
    112     ); 
     119        'inset-box'  => 'Inset Box',
     120    );
    113121
    114122    // Allow this to be filtered, so developers can add their own style options.
     
    116124}
    117125
     126/**
     127 * Enqueue the plugin's stylesheets.
     128 *
     129 * @since 1.0
     130 *
     131 * @action wp_enqueue_scripts
     132 */
     133function cce_enqueue_styles() {
    118134
    119 /***** Styles *****/
     135    wp_enqueue_style( 'cce_comics', plugins_url( 'styles.css', __FILE__ ) );
    120136
    121 function cce_enqueue_styles()
    122 {
    123     // Default styles.
    124     wp_register_style('cce_comics', plugins_url( 'styles.css', __FILE__ ) );
    125     wp_enqueue_style('cce_comics');
    126    
    127     // Custom styles.
    128     if ( defined( 'CHICKCOMIC_CUSTOM_STYLES' ) && ( 'CHICKCOMIC_CUSTOM_STYLES' == TRUE ) )
    129     {
    130         wp_register_style('cce_comics_custom', plugins_url( 'custom-styles.css', __FILE__ ) );
    131         wp_enqueue_style('cce_comics_custom');
    132     }
     137    // Let developers add their styles after these are registered.
     138    do_action( 'cce_after_styles_enqueue' );
    133139}
    134 add_action('wp_enqueue_scripts', 'cce_enqueue_styles');
    135 
    136 ?>
     140add_action( 'wp_enqueue_scripts', 'cce_enqueue_styles' );
  • chick-comic-embedder/trunk/developers.txt

    r666029 r728081  
    1 /*********
    2  This file provides some information for developers who want to extend this plugin.
    3  For more info, visit http://dev.efieldguide.com/comic-embedder/
    4 *********/
     1This file provides some information for developers who want to extend this plugin.
     2For more info, visit http://codesymphony.co/comic-embedder/
    53
    6 /*****  Adding Styles  *****/
    74
    8 You can add your own styles to use on the comics.
    9 Simply create your CSS rules for a new class, and add them to custom-styles.css
    10 (That file won't be overwritten when the plugin is updated.)
     5== Adding Styles ==
     6
     7You can add your own styles to use on the comics. Simply create your CSS rules for a
     8new class, and add them to your child theme's style.css file. (If you aren't using a
     9child theme, see http://codex.wordpress.org/Child_Themes).
    1110
    1211For example:
    1312
    14 
    15 .chickcomic-container.my-cool-new-style-class{
    16  /* Your CSS styles here */
     13.chickcomic-container.my-cool-new-style-class {
     14    /* Your CSS styles here */
    1715}
    1816
    19 
    20 
    21 Then you can add your new style to the available styles by adding a filter for the styles in custom-styles.php.
    22 (That file won't be overwritten with the plugin is updated, either.)
     17Then you can add your new style to the available styles by adding a filter for the
     18styles in your child theme's functions.php file.
    2319
    2420For example:
    2521
    26 
    2722<?php
    2823
    29 // Make sure that this is in that file, or else your custom styles will not work.
    30 // By default, this is FALSE, and you should see 'define( "CHICKCOMIC_CUSTOM_STYLES", FALSE )' in the file before you edit it.
    31 // It is safe to remove that, just replace it with this.
     24/**
     25 * A new function for my cool styles.
     26 *
     27 * It needs to take one parameter; this is the array of styles.
     28 *
     29 * @filter chickcomic_styles_filter
     30 *
     31 * @param array $styles The array of styles.
     32 *
     33 * @return array An array of styles.
     34 */
     35function function_for_my_cool_styles( $styles ) {
    3236
    33 define( 'CHICKCOMIC_CUSTOM_STYLES', TRUE );
     37    /*
     38     * Add a new element to the array of styles.
     39     * Make sure that the [key] matches the new class you added in the CSS.
     40     * The value is the name of your style, and can be whatever you want.
     41     */
     42    $styles['my-cool-new-style-class'] = 'My Cool New Style';
    3443
    35 
    36 // Add a new function. It needs to take one parameter; this is the array of styles.
    37 
    38 function function_for_my_cool_styles( $styles )
    39 {
    40     // Add a new element to the array of styles.
    41     // Make sure that the [key] matches the new class you added in the CSS.
    42     // The value is the name of your style, and can be whatever you want.
    43    
    44     $styles['my-cool-new-style-class'] = 'My Cool New Style';
    45    
    4644    // If you don't return the $styles array, then no styles will work!
    47    
    4845    return $styles;
    4946}
    5047add_filter( 'chickcomic_styles_filter', 'function_for_my_cool_styles' );
    5148
    52 // ^^^^ We tell WordPress that we want add this function as a part of the chickcomic_styles_filter.
     49// ^^ Tell WordPress to add this function as a filter for the Chick Comic styles.
    5350
    5451?>
    5552
     53Now you will be able to use your style in the shortcode, and even set it as the
     54default on the settings page if you want. You can even preview it along with all the
     55other styles on the preview page!
     56
     57Additional info: http://codesymphony.co/comic-embedder/#custom-styles
    5658
    5759
    58 Now you will be able to use your style in the shortcode, and even set it as the default if you want, on the settings page.
    59 You can even preview it along with all the other styles on the preview page!
     60== Embeding Comics without shortcode ==
    6061
    61 Additional info: http://dev.efieldguide.com/comic-embedder/#custom-styles
    62 
    63 
    64 /*****  Embeding Comics without shortcode  *****/
    65 
    66 You can embed comics in posts and pages with the shortcode, but what if you want to do something else,
    67 like display a random comic in the footer of your website?
    68 You can do that using the display_chickcomic() function.
    69 This is the function that the shortcode uses to display the comics.
    70 The function takes the same three parameters as the shortcode, the only difference being that they must be in order:
     62You can embed comics in posts and pages with the shortcode, but what if you want to
     63do something else, like display a random comic in the footer of your website? You can
     64do that using the display_chickcomic() function. This is the function that the
     65shortcode uses to display the comics. The function takes the same three parameters as
     66the shortcode, the only difference being that they must be in order:
    7167
    72681. The id or title of a comic, or 'latest' or 'random'.
    73 2. What to display if the comic is unavailable: 'none', 'default', 'random'.
     692. What to display if the comic is unavailable: 'none', 'default', or 'random'.
    74703. What style to give the comic.
    7571
    76 As with the shortcode, these are all optional, and if they aren't set the defaults will be used.
    77 So you could call the function like this, with no parameters:
     72As with the shortcode, these are all optional, and if they aren't set the defaults
     73will be used. So you could call the function like this, with no parameters:
    7874
    7975display_chickcomic();
     
    8177Or will all parameters:
    8278
    83 display_chickcomic('1', 'none', 'inset-box');
     79display_chickcomic( '1', 'none', 'inset-box' );
    8480
    85 If you want to leave out a parameter, but set a later parameter, then just pass NULL:
     81If you want to leave out a parameter, but set a later parameter, then just pass null
     82in place of that parameter:
    8683
    87 display_chickcomic('random', NULL, 'inset-box');
     84display_chickcomic( 'random', null, 'inset-box' );
    8885
    89 You can use this function anywhere in your PHP code.
    90 The function returns a string, which you will have to echo() to display the comic.
     86You can use this function anywhere in your PHP code. The function returns a string,
     87which you will have to echo() to display the comic.
     88
    9189For example:
    9290
    9391echo( display_chickcomic() );
    9492
    95 Additional info: http://dev.efieldguide.com/comic-embedder/#developers
     93Additional info: http://codesymphony.co/comic-embedder/#developers
    9694
    9795
    98 /*****  Aditional Help  *****/
     96== Aditional Help ==
    9997
    100 If you need help, or have any questions, please see http://dev.efieldguide.com/comic-embedder/
    101 
     98If you need help, or have any questions, please see http://codesymphony.co/comic-embedder/
  • chick-comic-embedder/trunk/options.php

    r666029 r728081  
    11<?php
    22
    3 /** Add Settings Page **/
    4 function chickcomic_settings_menu()
    5 {
     3/**
     4 * Settings.
     5 *
     6 * This plugin uses the Settings API to keep track of the settings.
     7 *
     8 * @package Chick_Comic_Embedder
     9 * @since 1.0
     10 */
     11
     12/**
     13 * Add the settings page to the admin menu.
     14 *
     15 * @since 1.0
     16 *
     17 * @action admin_menu
     18 */
     19function chickcomic_settings_menu() {
     20
    621    add_options_page(
    722        'Comic Settings',
     
    1126        'chickcomic_settings_page'
    1227    );
    13 
    1428}
    1529add_action( 'admin_menu', 'chickcomic_settings_menu' );
    1630
    17 /** Settings Page Content **/
    18 function chickcomic_settings_page()
    19 {
     31/**
     32 * Display the settings page.
     33 *
     34 * @since 1.0
     35 */
     36function chickcomic_settings_page() {
     37
    2038    ?>
    21    
     39
    2240    <div class="wrap">
    23 
    24      <?php screen_icon(); ?>
    25 
    26      <h2>Comic Settings</h2>
    27      <p>The three parameters of the [chickcomic] shortcode are optional. Here you can set the default values for these parameters. These settings can be overridden by using the paremeters in the shortcode. The values in [braces] are what you need to use in the shortcode. The exception is the comic titles, which can be used instead of the id numbers.</p>
    28      <p>Some examples:</p>
    29      <ul>
    30      <li>[chickcomic comic="This was your life"] will display the comic titled "This Was Your Life".</li>
    31      <li>[chickcomic comic="1"] will also display the comic "This Was Your Life."</li>
    32      <li>[chickcomic comic="random"] will display a random comic.</li>
    33      <li>[chickcomic comic="5" unavailable="none"] This will display the comic titled "Unloved". If that comic becomes unavailable, then the shortcode will display nothing.</li>
    34      </ul>
    35      <form method="post" action="options.php">
    36 
    37       <?php
    38      
    39       settings_fields( 'chickcomic_settings_group' );
    40       do_settings_sections( 'chick_comics' );
    41       submit_button();
    42      
    43       ?>
    44 
    45      </form>
     41        <?php screen_icon(); ?>
     42        <h2>Comic Settings</h2>
     43        <p>
     44            The three parameters of the <code>[chickcomic]</code> shortcode are optional. Here you can set the default values for these parameters.<br />
     45            These settings can be overridden by using the paremeters in the shortcode. The values in [braces] are what you need to use in the shortcode.<br />
     46            The exception is the comic titles, which can be used instead of the id numbers.
     47        </p>
     48        <p>Some examples:</p>
     49        <ul>
     50            <li><code>[chickcomic comic="This was your life"]</code> will display the comic titled "This Was Your Life".</li>
     51            <li><code>[chickcomic comic="1"]</code> will also display the comic "This Was Your Life."</li>
     52            <li><code>[chickcomic comic="random"]</code> will display a random comic.</li>
     53            <li><code>[chickcomic comic="5" unavailable="none"]</code> This will display the comic titled "Unloved". If that comic becomes unavailable, then the shortcode will display nothing.</li>
     54            <li><code>[chickcomic style="inset-box"]</code> This will display the default comic with the inset box style.</li>
     55        </ul>
     56        <form method="post" action="options.php">
     57
     58        <?php
     59            settings_fields( 'chickcomic_settings_group' );
     60            do_settings_sections( 'chick_comics' );
     61            submit_button();
     62        ?>
     63
     64        </form>
     65
     66        <br /><br />
     67        <i>For information on this plugin, see <a href="http://codesymphony.co/comic-embedder/">here</a>.</i>
    4668    </div>
    4769
     
    4971}
    5072
    51 /** Settings Initialization **/
    52 function chickcomic_settings_init()
    53 {
    54     // Default comic.
     73/**
     74 * Initialize settings.
     75 *
     76 * @since 1.0
     77 *
     78 * @action admin_init
     79 */
     80function chickcomic_settings_init() {
     81
     82    /*
     83     * Default comic.
     84     */
     85
    5586    add_settings_section(
    5687        'cce_default_comic_section',
     
    5990        'chick_comics'
    6091    );
     92
    6193    add_settings_field(
    6294        'cce_default_comic',
     
    6698        'cce_default_comic_section'
    6799    );
     100
    68101    register_setting( 'chickcomic_settings_group', 'cce_default_comic' );
    69    
    70     // Default unavailable action.
     102
     103    /*
     104     * Default unavailable action.
     105     */
     106
    71107    add_settings_section(
    72108        'cce_default_unavailable_section',
     
    75111        'chick_comics'
    76112    );
     113
    77114    add_settings_field(
    78115        'cce_default_unavailable',
     
    82119        'cce_default_unavailable_section'
    83120    );
     121
    84122    register_setting( 'chickcomic_settings_group', 'cce_default_unavailable' );
    85123
    86     // Default style.
     124    /*
     125     * Default style.
     126     */
     127
    87128    add_settings_section(
    88129        'cce_default_style_section',
     
    91132        'chick_comics'
    92133    );
     134
    93135    add_settings_field(
    94136        'cce_default_style',
     
    98140        'cce_default_style_section'
    99141    );
     142
    100143    register_setting( 'chickcomic_settings_group', 'cce_default_style' );
    101144}
    102145add_action( 'admin_init', 'chickcomic_settings_init' );
    103146
     147/**
     148 * Callback to display the default commic section description.
     149 *
     150 * @since 1.0
     151 */
    104152function cce_default_comic_section_callback() {
     153
    105154    echo( 'What comic should the shortcode display by default? You can choose a particular title, or have the shortcode display a random comic, or the latest comic. <a href="http://www.chick.com/cartoons/embed.asp" target="_blank">Preview the available comics on chick.com</a>' );
    106155}
    107156
     157/**
     158 * Callback to display the default commic unavailabe section description.
     159 *
     160 * @since 1.0
     161 */
    108162function cce_default_unavailable_section_callback() {
    109     echo( 'The available comics change every few months. (That is entirely outside of the plugin author\'s control). By default, what should be displayed if the comic specified in the shortcode is unavailable?' );
    110 }
    111 
     163
     164    echo( 'The available comics change occasionally. (That is entirely outside of the plugin author\'s control). By default, what should be displayed if the comic specified in the shortcode is unavailable?' );
     165}
     166
     167/**
     168 * Callback to display the default style section description.
     169 *
     170 * @since 1.0
     171 */
    112172function cce_default_style_section_callback() {
    113     echo( 'Choose a default style for the comics. <a href="'. site_url( '/?cce_preview_styles=1' ) .'" target="_blank">Preview the different styles</a>.' );
    114 }
    115 
    116 /** Default Comic Form Input **/
    117 function cce_default_comic_input()
    118 {
     173
     174    echo( 'Choose a default style for the comics. <a href="' . add_query_arg( 'cce_preview_styles', 1, site_url() ) . '" target="_blank">Preview the different styles</a>.' );
     175}
     176
     177/**
     178 * Display default comic form field.
     179 *
     180 * @since 1.0
     181 */
     182function cce_default_comic_input() {
     183
    119184    // Available comics.
    120185    $comics = cce_available_comics();
    121186    $comics['random'] = 'A Random Comic';
    122187    $comics['latest'] = 'The Latest Comic';
    123    
     188
    124189    // Current default.
    125190    $current = get_option( 'cce_default_comic' );
     
    128193    $html = '<select id="cce_default_comic" name="cce_default_comic">';
    129194
    130     foreach ($comics as $id => $title)
    131     {
    132         $html .= '<option value="'. $id .'"';
    133         if ($id == $current) $html .= ' selected="selected"';
    134         $html .= '>['. $id .'] '. $title .'</option>';
     195    foreach ( $comics as $id => $title ) {
     196
     197        $html .= '<option value="' . $id . '"';
     198        if ( $id == $current ) $html .= ' selected="selected"';
     199        $html .= '>[' . $id . '] ' . $title . '</option>';
    135200    }
    136    
     201
    137202    $html .= '</select>';
    138203
     
    140205}
    141206
    142 /** Default Comic Unavailable Form Input **/
    143 function cce_default_unavailable_input()
    144 {
     207/**
     208 * Display default comic unavailable form field.
     209 *
     210 * @since 1.0
     211 */
     212function cce_default_unavailable_input() {
     213
    145214    // Available options.
    146215    $options = array(
    147         'random' => 'Random Comic',
     216        'random'  => 'Random Comic',
    148217        'default' => 'Default Comic',
    149         'none' => 'Nothing',
    150     );
    151    
     218        'none'    => 'Nothing',
     219    );
     220
    152221    // Current default.
    153222    $current = get_option( 'cce_default_unavailable' );
    154    
     223
    155224    // Build <select> element.
    156225    $html = '<select id="cce_default_unavailable" name="cce_default_unavailable">';
    157226
    158     foreach ($options as $value => $text)
    159     {
    160         $html .= '<option value="'. $value .'"';
    161         if ($value == $current) $html .= ' selected="selected"';
    162         $html .= '>['. $value .'] '. $text .'</option>';
     227    foreach ( $options as $value => $text ) {
     228
     229        $html .= '<option value="' . $value . '"';
     230        if ( $value == $current ) $html .= ' selected="selected"';
     231        $html .= '>[' . $value . '] ' . $text . '</option>';
    163232    }
    164    
     233
    165234    $html .= '</select>';
    166235
    167     echo( $html ); 
    168 }
    169 
    170 /** Default Comic Style Form Input **/
    171 function cce_default_style_input()
    172 {
     236    echo( $html );
     237}
     238
     239/**
     240 * Display default style form field.
     241 *
     242 * @since 1.0
     243 */
     244function cce_default_style_input() {
     245
    173246    // Available options.
    174247    $options = cce_available_styles();
    175    
     248
    176249    // Current default.
    177250    $current = get_option( 'cce_default_style' );
    178    
     251
    179252    // Build <select> element.
    180253    $html = '<select id="cce_default_style" name="cce_default_style">';
    181254
    182     foreach ($options as $value => $name)
    183     {
    184         $html .= '<option value="'. $value .'"';
    185         if ($value == $current) $html .= ' selected="selected"';
    186         $html .= '>['. $value .'] '. $name .'</option>';
     255    foreach ( $options as $value => $name ) {
     256
     257        $html .= '<option value="' . $value . '"';
     258        if ( $value == $current ) $html .= ' selected="selected"';
     259        $html .= '>[' . $value . '] ' . $name . '</option>';
    187260    }
    188    
     261
    189262    $html .= '</select>';
    190263
    191     echo( $html ); 
    192 }
    193 
    194 ?>
     264    echo( $html );
     265}
  • chick-comic-embedder/trunk/readme.txt

    r666370 r728081  
    1 === Plugin Name ===
     1=== Chick Comic Embedder ===
    22Contributors: JD55
    3 Donate link: http://dev.efieldguide.com/
     3Donate link: http://codesymphony.co/
    44Tags: comics, shortcode, comic, chick, tract
    55Requires at least: 2.7.0
    66Tested up to: 3.5.1
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3939== Changelog ==
    4040
     41= 1.1 =
     42* Removed support for the custom-styles.css and custom-styles.php files.
     43* Docblocked code and generally improved code formatting.
     44
    4145= 1.0 =
    4246* Initial release.
     
    4448== Upgrade Notice ==
    4549
     50= 1.1 =
     51**IMPORTANT!** If you are using the custom-styles.css and/or custom-styles.php files to customize this plugin, please move your code to a child theme **before** upgrading. Otherwise it will be overwritten.
     52
    4653= 1.0 =
    4754The initial release.
  • chick-comic-embedder/trunk/shortcode.php

    r666029 r728081  
    11<?php
    22
    3 /** Register Shortcode **/
    4 function chickcomic_shortcode($atts)
    5 {
    6     extract( shortcode_atts( array(
    7         'comic' => get_option( 'cce_default_comic' ),
    8         'unavailable' => get_option( 'cce_default_unavailable' ),
    9         'style' => get_option( 'cce_default_style' ),
    10     ), $atts ) );
     3/**
     4 * Shortcode.
     5 *
     6 * This file contains the shortcode handler and the display_chickcomic() function.
     7 *
     8 * @package Chick_Commic_Embedder
     9 * @since 1.0
     10 */
     11
     12/**
     13 * Shortcode handler.
     14 *
     15 * @since 1.0
     16 *
     17 * @shortcode chickcomic
     18 *
     19 * @uses display_chickcomic() To get the commic.
     20 *
     21 * @param array $atts The shortcode atts.
     22 *
     23 * @return string HTML for a commic.
     24 */
     25function chickcomic_shortcode( $atts ) {
     26
     27    extract(
     28        shortcode_atts(
     29            array(
     30                'comic'       => get_option( 'cce_default_comic' ),
     31                'unavailable' => get_option( 'cce_default_unavailable' ),
     32                'style'       => get_option( 'cce_default_style' ),
     33            ),
     34            $atts
     35        )
     36    );
    1137
    1238    return display_chickcomic( $comic, $unavailable, $style );
     
    1541
    1642/**
    17  * Display a comic. (This is the function used by the shortcode.)
     43 * Get a comic to display.
    1844 *
    19  * @param $id (numeric|string)  The id of the comic | 'random' | 'latest' | The title of a comic.
    20  * @param $unavailable (string)  The action to take if the asked for comic is unavailable.
    21  * @param $style (string)  The HTML class to apply to the comic container element.
     45 * Despite it's unfortunate name, this function does not actually output anything,
     46 * but instead returns a string of HTML that can be used to display a commic.
    2247 *
    23  * @returns (string|bool)  The HTML for a comic (or FALSE on failure).
     48 * @param numeric|string $id The id or title of the comic or 'random' or 'latest'.
     49 * @param string $unavailable What to do if the requested comic is unavailable.
     50 * @param string $style The HTML class to apply to the comic container element.
     51 *
     52 * @return string|bool The HTML for a comic, or false if the comic is unavailable and
     53 *         $unavailable is set to 'none'.
    2454 */
    25 function display_chickcomic( $comic = NULL, $unavailable = NULL, $style = NULL )
    26 {
    27     // Get array of available comics.
     55function display_chickcomic( $comic = null, $unavailable = null, $style = null ) {
     56
     57    // Get the array of available comics.
    2858    $comics = cce_available_comics();
    2959
    3060    // If the $comic isn't set we use the default.
    31     if ( empty( $comic ) )
    32     {
     61    if ( empty( $comic ) ) {
     62
    3363        $comic = get_option( 'cce_default_comic' );
    34        
    35        // If it's set, but not a valid id...
    36     } elseif ( !isset( $comics[$comic] ) && $comic != 'random' && $comic != 'latest' ) {   
    37         // Check if it's a comic title. First capitalize the first letter of each word.
     64
     65     // If it's set, but not a valid id
     66    } elseif ( !isset( $comics[ $comic ] ) && $comic != 'random' && $comic != 'latest' ) {
     67
     68        // Check if it's a comic title. Capitalize the first letter of each word.
    3869        $comic = ucwords( strtolower( $comic ) );
    39         if ( in_array( $comic, $comics ) )
    40         {
     70
     71        if ( in_array( $comic, $comics ) ) {
     72
    4173            $comic = array_search( $comic, $comics );
    42            
    43            // If it's not, then the comic is unavailable.
     74
     75         // If it's not, then the comic is unavailable.
    4476        } else {
     77
    4578            // If $unavailble isn't set, we use the default.
    46             if ( empty( $unavailable ) ) {
     79            if ( empty( $unavailable ) )
    4780                $unavailable = get_option( 'cce_default_unavailable' );
    48             }
    49    
    50             switch( $unavailable )
    51             {
     81
     82            switch ( $unavailable ) {
     83
    5284                case 'random':
    53                     $comic = 'random'; break;
     85                    $comic = 'random';
     86                break;
     87
    5488                case 'default':
    55                     $comic = get_option( 'cce_default_comic' ); break;
     89                    $comic = get_option( 'cce_default_comic' );
     90                break;
     91
    5692                case 'none':
    57                     return FALSE;
     93                    return false;
     94
    5895                default:
    5996                    $comic = 'random';
     
    6299    }
    63100
    64     // If we are going to display a random comic, we pick a random one to display.
    65     if ( $comic == 'random' ) {
    66         $comic = array_rand( $comics );
    67     }
    68    
    69     // If we are going to display the latest comic.
    70     if ( $comic == 'latest' ) {
    71         $comic_file = 'preview';
    72     } else {
    73         $comic_file = 'tract_' . $comic;
    74     }
    75    
    76     // Checking what style to give the comic.
    77     $styles = cce_available_styles();
    78     if ( empty( $style ) ) {
    79         $style = get_option( 'cce_default_style' );
     101    switch ( $comic ) {
     102
     103        // If we are going to display the latest comic.
     104        case 'latest':
     105            $comic_file = 'preview';
     106        break;
     107
     108        // If we are going to display a random comic, pick a random one to display.
     109        case 'random':
     110            $comic = array_rand( $comics );
     111
     112        default:
     113            $comic_file = 'tract_' . $comic;
    80114    }
    81115
    82     // If we aren't going to give the comic a style.
    83     if ( $style == 'none' ) {
     116    // Get the available styles.
     117    $styles = cce_available_styles();
     118
     119    // If this one isn't value use the default.
     120    if ( ! isset( $styles[ $style ] ) && $style != 'none' )
     121        $style = get_option( 'cce_default_style' );
     122
     123    if ( 'none' == $style )
    84124        $style = '';
    85     }
    86    
     125
    87126    // Return the HTML for the comic.
    88     return '<div class="chickcomic-container '. $style .'">
    89         <object width="425" height="240">
    90         <param name="movie" value="http://media.chick.com/'. $comic_file .'.swf"></param>
    91         <param name="wmode" value="transparent"></param>
    92         <embed src="http://media.chick.com/'. $comic_file .'.swf" type="application/x-shockwave-flash" wmode="transparent" width="425" height="240"></embed>
    93         </object></div>';
     127    return '<div class="chickcomic-container ' . $style . '">
     128            <object width="425" height="240">
     129                <param name="movie" value="http://media.chick.com/' . $comic_file . '.swf"></param>
     130                <param name="wmode" value="transparent"></param>
     131                <embed src="http://media.chick.com/' . $comic_file . '.swf" type="application/x-shockwave-flash" wmode="transparent" width="425" height="240"></embed>
     132            </object>
     133        </div>';
    94134}
    95 
    96 ?>
  • chick-comic-embedder/trunk/style-preview.php

    r666029 r728081  
    33/**
    44 * Enable a page where user's can preview all available styles.
     5 *
     6 * @package Chick_Comic_Embedder
     7 * @since 1.0
    58 */
    69
    7 // Add query var.
    8 function cce_style_query_var( $query_vars )
    9 {
     10/**
     11 * Add query var.
     12 *
     13 * @since 1.0
     14 *
     15 * @filter query_vars
     16 */
     17function cce_style_query_var( $query_vars ) {
     18
    1019    $query_vars[] = 'cce_preview_styles';
    1120    return $query_vars;
     
    1322add_filter( 'query_vars', 'cce_style_query_var' );
    1423
    15 // Process request.
    16 function cce_styles_parse_request( &$wp )
    17 {
    18     // If the style preview page is being requested...
    19     if ( array_key_exists( 'cce_preview_styles', $wp->query_vars ) )
    20     {
    21         // We load the custom template.
    22         include dirname( __FILE__ ) . '/styles-preview-template.php';
     24/**
     25 * Process request.
     26 *
     27 * @since 1.0
     28 *
     29 * @action parse_request
     30 */
     31function cce_styles_parse_request( &$wp ) {
     32
     33    // If the style preview page is being requested, load the custom template.
     34    if ( array_key_exists( 'cce_preview_styles', $wp->query_vars ) ) {
     35
     36        include( dirname( __FILE__ ) . '/styles-preview-template.php' );
    2337        exit();
    2438    }
    25    
     39
    2640    return;
    2741}
    2842add_action( 'parse_request', 'cce_styles_parse_request' );
    29 
    30 ?>
  • chick-comic-embedder/trunk/styles-preview-template.php

    r666029 r728081  
    33/**
    44 * A custom page template used to display the page of all available comic styles.
     5 *
     6 * @package Chick_Commic_Embedder
     7 * @since 1.0
    58 */
    69
     
    811
    912?>
    10    
     13
    1114<div class="entry-content">
    1215    <h2>Chick Comic Styles</h2>
    1316    <br />
    14     <p>Preview all available styles for the Chick comics. You can also create your own styles. For more information, see <a href="http://dev.efieldguide.com/comic-embedder/#cusom-styles">here</a>, or read the developers.txt file included with the plugin.</p>
     17    <p>Preview all available styles for the Chick comics. You can also create your own styles. For more information, see <a href="http://codesymphony.co/comic-embedder/#cusom-styles">here</a>, or read the developers.txt file included with the plugin.</p>
    1518    <br />
    1619    <br />
    17    
     20
    1821    <?php
    19    
     22
    2023    $styles = cce_available_styles();
    21    
    22     $lorem = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
    23    
    24     foreach ( $styles as $style => $name )
    25     {
    26         echo( '<h3>'. $name .'</h3><br />' );
    27         echo( $lorem . $lorem );
     24
     25    $lorem_ipsum = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
     26
     27    foreach ( $styles as $style => $name ) {
     28
     29        echo( '<h3>' . $name . '</h3><br />' );
     30        echo( $lorem_ipsum . $lorem_ipsum );
    2831        echo( display_chickcomic( '1', 'random', $style ) );
    29         echo( $lorem . $lorem . $lorem );
     32        echo( $lorem_ipsum . $lorem_ipsum . $lorem_ipsum );
    3033        echo( '<br /><br /><hr /><br />' );
    3134    }
    32    
     35
    3336    ?>
    3437
  • chick-comic-embedder/trunk/styles.css

    r666029 r728081  
    1 .chickcomic-container{
    2  margin:15px;
    3  height:240px;
     1/**
     2 * Chick Comic Embedder styles.
     3 *
     4 * @package Chick_Comic_Embedder
     5 * @since 1.0
     6 */
     7
     8.chickcomic-container {
     9    margin: 15px;
     10    height: 240px;
    411}
    5 .chickcomic-container.center{
    6  margin:15px auto;
    7  width:425px;
     12
     13.chickcomic-container.center {
     14    margin: 15px auto;
     15    width: 425px;
    816}
    9 .chickcomic-container.inset-box{
    10  padding:20px;
    11  margin:50px 0px;
    12  box-shadow:0px 0px 10px rgb(0, 0, 0) inset;
     17
     18.chickcomic-container.inset-box {
     19    padding: 20px;
     20    margin: 50px 0px;
     21    box-shadow: 0px 0px 10px rgb(0, 0, 0) inset;
    1322}
    14 .chickcomic-container.inset-box object{
    15  margin:auto;
    16  display:block;
     23
     24.chickcomic-container.inset-box object {
     25    margin: auto;
     26    display: block;
    1727}
    18 .chickcomic-container.wrap-left{
    19  float:left;
    20  margin-left:0px;
     28
     29.chickcomic-container.wrap-left {
     30    float: left;
     31    margin-left: 0px;
    2132}
    22 .chickcomic-container.wrap-right{
    23  float:right;
    24  margin-right:0px;
     33
     34.chickcomic-container.wrap-right {
     35    float: right;
     36    margin-right: 0px;
    2537}
Note: See TracChangeset for help on using the changeset viewer.