Changeset 728081
- Timestamp:
- 06/18/2013 09:53:00 PM (13 years ago)
- Location:
- chick-comic-embedder
- Files:
-
- 16 edited
- 1 copied
-
tags/1.1 (copied) (copied from chick-comic-embedder/trunk)
-
tags/1.1/chick-comic-embedder.php (modified) (3 diffs)
-
tags/1.1/developers.txt (modified) (2 diffs)
-
tags/1.1/options.php (modified) (11 diffs)
-
tags/1.1/readme.txt (modified) (3 diffs)
-
tags/1.1/shortcode.php (modified) (3 diffs)
-
tags/1.1/style-preview.php (modified) (2 diffs)
-
tags/1.1/styles-preview-template.php (modified) (2 diffs)
-
tags/1.1/styles.css (modified) (1 diff)
-
trunk/chick-comic-embedder.php (modified) (3 diffs)
-
trunk/developers.txt (modified) (2 diffs)
-
trunk/options.php (modified) (11 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/shortcode.php (modified) (3 diffs)
-
trunk/style-preview.php (modified) (2 diffs)
-
trunk/styles-preview-template.php (modified) (2 diffs)
-
trunk/styles.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
chick-comic-embedder/tags/1.1/chick-comic-embedder.php
r666029 r728081 1 1 <?php 2 /*3 Plugin Name: Chick Comic Embedder4 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.07 Author: J.D. Grimes8 Author URI: http://dev.efieldguide.com/9 License: GPL210 */11 2 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 */ 13 38 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 */ 42 define( 'CC_EMBEDDER_DIR', dirname( __FILE__ ) ); 17 43 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 */ 51 function chickcomic_activation() { 22 52 23 You should have received a copy of the GNU General Public License24 along with this program; if not, write to the Free Software25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA26 */27 28 /****29 * Developers: for information on adding custom CSS styles, see developers.txt30 ****/31 32 /***** Activation *****/33 34 register_activation_hook( __FILE__, 'chickcomic_activation' );35 function chickcomic_activation()36 {37 /** Add Options **/38 53 add_option( 'cce_default_comic', '1' ); 39 54 add_option( 'cce_default_unavailable', 'random' ); 40 55 add_option( 'cce_default_style', 'center' ); 56 } 57 register_activation_hook( __FILE__, 'chickcomic_activation' ); 41 58 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 */ 64 include_once( CC_EMBEDDER_DIR . '/shortcode.php' ); 65 66 /** 67 * Enables the style preview page. 68 * 69 * @since 1.0 70 */ 71 include_once( CC_EMBEDDER_DIR . '/style-preview.php' ); 72 73 // Only load this on the admin side. 74 if ( is_admin() ) { 75 76 /** 77 * Settings. 78 * 79 * @since 1.0 80 */ 81 include_once( CC_EMBEDDER_DIR . '/options.php' ); 61 82 } 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 *****/81 83 82 84 /** 83 85 * 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. 85 90 */ 86 function cce_available_comics() 87 { 91 function cce_available_comics() { 92 88 93 return array( 89 94 // id => name … … 99 104 /** 100 105 * 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. 102 110 */ 103 function cce_available_styles() 104 { 111 function cce_available_styles() { 112 105 113 // Included styles. 106 114 $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)', 110 118 'wrap-right' => 'Wrap text (right)', 111 'inset-box' => 'Inset Box',112 ); 119 'inset-box' => 'Inset Box', 120 ); 113 121 114 122 // Allow this to be filtered, so developers can add their own style options. … … 116 124 } 117 125 126 /** 127 * Enqueue the plugin's stylesheets. 128 * 129 * @since 1.0 130 * 131 * @action wp_enqueue_scripts 132 */ 133 function cce_enqueue_styles() { 118 134 119 /***** Styles *****/ 135 wp_enqueue_style( 'cce_comics', plugins_url( 'styles.css', __FILE__ ) ); 120 136 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' ); 133 139 } 134 add_action('wp_enqueue_scripts', 'cce_enqueue_styles'); 135 136 ?> 140 add_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 *********/ 1 This file provides some information for developers who want to extend this plugin. 2 For more info, visit http://codesymphony.co/comic-embedder/ 5 3 6 /***** Adding Styles *****/7 4 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 7 You can add your own styles to use on the comics. Simply create your CSS rules for a 8 new class, and add them to your child theme's style.css file. (If you aren't using a 9 child theme, see http://codex.wordpress.org/Child_Themes). 11 10 12 11 For example: 13 12 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 */ 17 15 } 18 16 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.) 17 Then you can add your new style to the available styles by adding a filter for the 18 styles in your child theme's functions.php file. 23 19 24 20 For example: 25 21 26 27 22 <?php 28 23 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 */ 35 function function_for_my_cool_styles( $styles ) { 32 36 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'; 34 43 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 46 44 // If you don't return the $styles array, then no styles will work! 47 48 45 return $styles; 49 46 } 50 47 add_filter( 'chickcomic_styles_filter', 'function_for_my_cool_styles' ); 51 48 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. 53 50 54 51 ?> 55 52 53 Now you will be able to use your style in the shortcode, and even set it as the 54 default on the settings page if you want. You can even preview it along with all the 55 other styles on the preview page! 56 57 Additional info: http://codesymphony.co/comic-embedder/#custom-styles 56 58 57 59 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 == 60 61 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: 62 You can embed comics in posts and pages with the shortcode, but what if you want to 63 do something else, like display a random comic in the footer of your website? You can 64 do that using the display_chickcomic() function. This is the function that the 65 shortcode uses to display the comics. The function takes the same three parameters as 66 the shortcode, the only difference being that they must be in order: 71 67 72 68 1. The id or title of a comic, or 'latest' or 'random'. 73 2. What to display if the comic is unavailable: 'none', 'default', 'random'.69 2. What to display if the comic is unavailable: 'none', 'default', or 'random'. 74 70 3. What style to give the comic. 75 71 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:72 As with the shortcode, these are all optional, and if they aren't set the defaults 73 will be used. So you could call the function like this, with no parameters: 78 74 79 75 display_chickcomic(); … … 81 77 Or will all parameters: 82 78 83 display_chickcomic( '1', 'none', 'inset-box');79 display_chickcomic( '1', 'none', 'inset-box' ); 84 80 85 If you want to leave out a parameter, but set a later parameter, then just pass NULL: 81 If you want to leave out a parameter, but set a later parameter, then just pass null 82 in place of that parameter: 86 83 87 display_chickcomic( 'random', NULL, 'inset-box');84 display_chickcomic( 'random', null, 'inset-box' ); 88 85 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. 86 You can use this function anywhere in your PHP code. The function returns a string, 87 which you will have to echo() to display the comic. 88 91 89 For example: 92 90 93 91 echo( display_chickcomic() ); 94 92 95 Additional info: http:// dev.efieldguide.com/comic-embedder/#developers93 Additional info: http://codesymphony.co/comic-embedder/#developers 96 94 97 95 98 /***** Aditional Help *****/ 96 == Aditional Help == 99 97 100 If you need help, or have any questions, please see http://dev.efieldguide.com/comic-embedder/ 101 98 If you need help, or have any questions, please see http://codesymphony.co/comic-embedder/ -
chick-comic-embedder/tags/1.1/options.php
r666029 r728081 1 1 <?php 2 2 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 */ 19 function chickcomic_settings_menu() { 20 6 21 add_options_page( 7 22 'Comic Settings', … … 11 26 'chickcomic_settings_page' 12 27 ); 13 14 28 } 15 29 add_action( 'admin_menu', 'chickcomic_settings_menu' ); 16 30 17 /** Settings Page Content **/ 18 function chickcomic_settings_page() 19 { 31 /** 32 * Display the settings page. 33 * 34 * @since 1.0 35 */ 36 function chickcomic_settings_page() { 37 20 38 ?> 21 39 22 40 <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> 46 68 </div> 47 69 … … 49 71 } 50 72 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 */ 80 function chickcomic_settings_init() { 81 82 /* 83 * Default comic. 84 */ 85 55 86 add_settings_section( 56 87 'cce_default_comic_section', … … 59 90 'chick_comics' 60 91 ); 92 61 93 add_settings_field( 62 94 'cce_default_comic', … … 66 98 'cce_default_comic_section' 67 99 ); 100 68 101 register_setting( 'chickcomic_settings_group', 'cce_default_comic' ); 69 70 // Default unavailable action. 102 103 /* 104 * Default unavailable action. 105 */ 106 71 107 add_settings_section( 72 108 'cce_default_unavailable_section', … … 75 111 'chick_comics' 76 112 ); 113 77 114 add_settings_field( 78 115 'cce_default_unavailable', … … 82 119 'cce_default_unavailable_section' 83 120 ); 121 84 122 register_setting( 'chickcomic_settings_group', 'cce_default_unavailable' ); 85 123 86 // Default style. 124 /* 125 * Default style. 126 */ 127 87 128 add_settings_section( 88 129 'cce_default_style_section', … … 91 132 'chick_comics' 92 133 ); 134 93 135 add_settings_field( 94 136 'cce_default_style', … … 98 140 'cce_default_style_section' 99 141 ); 142 100 143 register_setting( 'chickcomic_settings_group', 'cce_default_style' ); 101 144 } 102 145 add_action( 'admin_init', 'chickcomic_settings_init' ); 103 146 147 /** 148 * Callback to display the default commic section description. 149 * 150 * @since 1.0 151 */ 104 152 function cce_default_comic_section_callback() { 153 105 154 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>' ); 106 155 } 107 156 157 /** 158 * Callback to display the default commic unavailabe section description. 159 * 160 * @since 1.0 161 */ 108 162 function 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 */ 112 172 function 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 */ 182 function cce_default_comic_input() { 183 119 184 // Available comics. 120 185 $comics = cce_available_comics(); 121 186 $comics['random'] = 'A Random Comic'; 122 187 $comics['latest'] = 'The Latest Comic'; 123 188 124 189 // Current default. 125 190 $current = get_option( 'cce_default_comic' ); … … 128 193 $html = '<select id="cce_default_comic" name="cce_default_comic">'; 129 194 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>'; 135 200 } 136 201 137 202 $html .= '</select>'; 138 203 … … 140 205 } 141 206 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 */ 212 function cce_default_unavailable_input() { 213 145 214 // Available options. 146 215 $options = array( 147 'random' => 'Random Comic',216 'random' => 'Random Comic', 148 217 'default' => 'Default Comic', 149 'none' => 'Nothing',150 ); 151 218 'none' => 'Nothing', 219 ); 220 152 221 // Current default. 153 222 $current = get_option( 'cce_default_unavailable' ); 154 223 155 224 // Build <select> element. 156 225 $html = '<select id="cce_default_unavailable" name="cce_default_unavailable">'; 157 226 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>'; 163 232 } 164 233 165 234 $html .= '</select>'; 166 235 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 */ 244 function cce_default_style_input() { 245 173 246 // Available options. 174 247 $options = cce_available_styles(); 175 248 176 249 // Current default. 177 250 $current = get_option( 'cce_default_style' ); 178 251 179 252 // Build <select> element. 180 253 $html = '<select id="cce_default_style" name="cce_default_style">'; 181 254 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>'; 187 260 } 188 261 189 262 $html .= '</select>'; 190 263 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 === 2 2 Contributors: JD55 3 Donate link: http:// dev.efieldguide.com/3 Donate link: http://codesymphony.co/ 4 4 Tags: comics, shortcode, comic, chick, tract 5 5 Requires at least: 2.7.0 6 6 Tested up to: 3.5.1 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 39 39 == Changelog == 40 40 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 41 45 = 1.0 = 42 46 * Initial release. … … 44 48 == Upgrade Notice == 45 49 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 46 53 = 1.0 = 47 54 The initial release. -
chick-comic-embedder/tags/1.1/shortcode.php
r666029 r728081 1 1 <?php 2 2 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 */ 25 function 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 ); 11 37 12 38 return display_chickcomic( $comic, $unavailable, $style ); … … 15 41 16 42 /** 17 * Display a comic. (This is the function used by the shortcode.)43 * Get a comic to display. 18 44 * 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. 22 47 * 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'. 24 54 */ 25 function display_chickcomic( $comic = NULL, $unavailable = NULL, $style = NULL )26 { 27 // Get array of available comics.55 function display_chickcomic( $comic = null, $unavailable = null, $style = null ) { 56 57 // Get the array of available comics. 28 58 $comics = cce_available_comics(); 29 59 30 60 // If the $comic isn't set we use the default. 31 if ( empty( $comic ) ) 32 { 61 if ( empty( $comic ) ) { 62 33 63 $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. 38 69 $comic = ucwords( strtolower( $comic ) ); 39 if ( in_array( $comic, $comics ) ) 40 { 70 71 if ( in_array( $comic, $comics ) ) { 72 41 73 $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. 44 76 } else { 77 45 78 // If $unavailble isn't set, we use the default. 46 if ( empty( $unavailable ) ) {79 if ( empty( $unavailable ) ) 47 80 $unavailable = get_option( 'cce_default_unavailable' ); 48 } 49 50 switch( $unavailable ) 51 { 81 82 switch ( $unavailable ) { 83 52 84 case 'random': 53 $comic = 'random'; break; 85 $comic = 'random'; 86 break; 87 54 88 case 'default': 55 $comic = get_option( 'cce_default_comic' ); break; 89 $comic = get_option( 'cce_default_comic' ); 90 break; 91 56 92 case 'none': 57 return FALSE; 93 return false; 94 58 95 default: 59 96 $comic = 'random'; … … 62 99 } 63 100 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; 80 114 } 81 115 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 ) 84 124 $style = ''; 85 } 86 125 87 126 // 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>'; 94 134 } 95 96 ?> -
chick-comic-embedder/tags/1.1/style-preview.php
r666029 r728081 3 3 /** 4 4 * Enable a page where user's can preview all available styles. 5 * 6 * @package Chick_Comic_Embedder 7 * @since 1.0 5 8 */ 6 9 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 */ 17 function cce_style_query_var( $query_vars ) { 18 10 19 $query_vars[] = 'cce_preview_styles'; 11 20 return $query_vars; … … 13 22 add_filter( 'query_vars', 'cce_style_query_var' ); 14 23 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 */ 31 function 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' ); 23 37 exit(); 24 38 } 25 39 26 40 return; 27 41 } 28 42 add_action( 'parse_request', 'cce_styles_parse_request' ); 29 30 ?> -
chick-comic-embedder/tags/1.1/styles-preview-template.php
r666029 r728081 3 3 /** 4 4 * A custom page template used to display the page of all available comic styles. 5 * 6 * @package Chick_Commic_Embedder 7 * @since 1.0 5 8 */ 6 9 … … 8 11 9 12 ?> 10 13 11 14 <div class="entry-content"> 12 15 <h2>Chick Comic Styles</h2> 13 16 <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> 15 18 <br /> 16 19 <br /> 17 20 18 21 <?php 19 22 20 23 $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 ); 28 31 echo( display_chickcomic( '1', 'random', $style ) ); 29 echo( $lorem . $lorem . $lorem );32 echo( $lorem_ipsum . $lorem_ipsum . $lorem_ipsum ); 30 33 echo( '<br /><br /><hr /><br />' ); 31 34 } 32 35 33 36 ?> 34 37 -
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; 4 11 } 5 .chickcomic-container.center{ 6 margin:15px auto; 7 width:425px; 12 13 .chickcomic-container.center { 14 margin: 15px auto; 15 width: 425px; 8 16 } 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; 13 22 } 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; 17 27 } 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; 21 32 } 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; 25 37 } -
chick-comic-embedder/trunk/chick-comic-embedder.php
r666029 r728081 1 1 <?php 2 /*3 Plugin Name: Chick Comic Embedder4 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.07 Author: J.D. Grimes8 Author URI: http://dev.efieldguide.com/9 License: GPL210 */11 2 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 */ 13 38 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 */ 42 define( 'CC_EMBEDDER_DIR', dirname( __FILE__ ) ); 17 43 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 */ 51 function chickcomic_activation() { 22 52 23 You should have received a copy of the GNU General Public License24 along with this program; if not, write to the Free Software25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA26 */27 28 /****29 * Developers: for information on adding custom CSS styles, see developers.txt30 ****/31 32 /***** Activation *****/33 34 register_activation_hook( __FILE__, 'chickcomic_activation' );35 function chickcomic_activation()36 {37 /** Add Options **/38 53 add_option( 'cce_default_comic', '1' ); 39 54 add_option( 'cce_default_unavailable', 'random' ); 40 55 add_option( 'cce_default_style', 'center' ); 56 } 57 register_activation_hook( __FILE__, 'chickcomic_activation' ); 41 58 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 */ 64 include_once( CC_EMBEDDER_DIR . '/shortcode.php' ); 65 66 /** 67 * Enables the style preview page. 68 * 69 * @since 1.0 70 */ 71 include_once( CC_EMBEDDER_DIR . '/style-preview.php' ); 72 73 // Only load this on the admin side. 74 if ( is_admin() ) { 75 76 /** 77 * Settings. 78 * 79 * @since 1.0 80 */ 81 include_once( CC_EMBEDDER_DIR . '/options.php' ); 61 82 } 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 *****/81 83 82 84 /** 83 85 * 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. 85 90 */ 86 function cce_available_comics() 87 { 91 function cce_available_comics() { 92 88 93 return array( 89 94 // id => name … … 99 104 /** 100 105 * 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. 102 110 */ 103 function cce_available_styles() 104 { 111 function cce_available_styles() { 112 105 113 // Included styles. 106 114 $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)', 110 118 'wrap-right' => 'Wrap text (right)', 111 'inset-box' => 'Inset Box',112 ); 119 'inset-box' => 'Inset Box', 120 ); 113 121 114 122 // Allow this to be filtered, so developers can add their own style options. … … 116 124 } 117 125 126 /** 127 * Enqueue the plugin's stylesheets. 128 * 129 * @since 1.0 130 * 131 * @action wp_enqueue_scripts 132 */ 133 function cce_enqueue_styles() { 118 134 119 /***** Styles *****/ 135 wp_enqueue_style( 'cce_comics', plugins_url( 'styles.css', __FILE__ ) ); 120 136 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' ); 133 139 } 134 add_action('wp_enqueue_scripts', 'cce_enqueue_styles'); 135 136 ?> 140 add_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 *********/ 1 This file provides some information for developers who want to extend this plugin. 2 For more info, visit http://codesymphony.co/comic-embedder/ 5 3 6 /***** Adding Styles *****/7 4 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 7 You can add your own styles to use on the comics. Simply create your CSS rules for a 8 new class, and add them to your child theme's style.css file. (If you aren't using a 9 child theme, see http://codex.wordpress.org/Child_Themes). 11 10 12 11 For example: 13 12 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 */ 17 15 } 18 16 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.) 17 Then you can add your new style to the available styles by adding a filter for the 18 styles in your child theme's functions.php file. 23 19 24 20 For example: 25 21 26 27 22 <?php 28 23 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 */ 35 function function_for_my_cool_styles( $styles ) { 32 36 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'; 34 43 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 46 44 // If you don't return the $styles array, then no styles will work! 47 48 45 return $styles; 49 46 } 50 47 add_filter( 'chickcomic_styles_filter', 'function_for_my_cool_styles' ); 51 48 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. 53 50 54 51 ?> 55 52 53 Now you will be able to use your style in the shortcode, and even set it as the 54 default on the settings page if you want. You can even preview it along with all the 55 other styles on the preview page! 56 57 Additional info: http://codesymphony.co/comic-embedder/#custom-styles 56 58 57 59 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 == 60 61 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: 62 You can embed comics in posts and pages with the shortcode, but what if you want to 63 do something else, like display a random comic in the footer of your website? You can 64 do that using the display_chickcomic() function. This is the function that the 65 shortcode uses to display the comics. The function takes the same three parameters as 66 the shortcode, the only difference being that they must be in order: 71 67 72 68 1. The id or title of a comic, or 'latest' or 'random'. 73 2. What to display if the comic is unavailable: 'none', 'default', 'random'.69 2. What to display if the comic is unavailable: 'none', 'default', or 'random'. 74 70 3. What style to give the comic. 75 71 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:72 As with the shortcode, these are all optional, and if they aren't set the defaults 73 will be used. So you could call the function like this, with no parameters: 78 74 79 75 display_chickcomic(); … … 81 77 Or will all parameters: 82 78 83 display_chickcomic( '1', 'none', 'inset-box');79 display_chickcomic( '1', 'none', 'inset-box' ); 84 80 85 If you want to leave out a parameter, but set a later parameter, then just pass NULL: 81 If you want to leave out a parameter, but set a later parameter, then just pass null 82 in place of that parameter: 86 83 87 display_chickcomic( 'random', NULL, 'inset-box');84 display_chickcomic( 'random', null, 'inset-box' ); 88 85 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. 86 You can use this function anywhere in your PHP code. The function returns a string, 87 which you will have to echo() to display the comic. 88 91 89 For example: 92 90 93 91 echo( display_chickcomic() ); 94 92 95 Additional info: http:// dev.efieldguide.com/comic-embedder/#developers93 Additional info: http://codesymphony.co/comic-embedder/#developers 96 94 97 95 98 /***** Aditional Help *****/ 96 == Aditional Help == 99 97 100 If you need help, or have any questions, please see http://dev.efieldguide.com/comic-embedder/ 101 98 If you need help, or have any questions, please see http://codesymphony.co/comic-embedder/ -
chick-comic-embedder/trunk/options.php
r666029 r728081 1 1 <?php 2 2 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 */ 19 function chickcomic_settings_menu() { 20 6 21 add_options_page( 7 22 'Comic Settings', … … 11 26 'chickcomic_settings_page' 12 27 ); 13 14 28 } 15 29 add_action( 'admin_menu', 'chickcomic_settings_menu' ); 16 30 17 /** Settings Page Content **/ 18 function chickcomic_settings_page() 19 { 31 /** 32 * Display the settings page. 33 * 34 * @since 1.0 35 */ 36 function chickcomic_settings_page() { 37 20 38 ?> 21 39 22 40 <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> 46 68 </div> 47 69 … … 49 71 } 50 72 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 */ 80 function chickcomic_settings_init() { 81 82 /* 83 * Default comic. 84 */ 85 55 86 add_settings_section( 56 87 'cce_default_comic_section', … … 59 90 'chick_comics' 60 91 ); 92 61 93 add_settings_field( 62 94 'cce_default_comic', … … 66 98 'cce_default_comic_section' 67 99 ); 100 68 101 register_setting( 'chickcomic_settings_group', 'cce_default_comic' ); 69 70 // Default unavailable action. 102 103 /* 104 * Default unavailable action. 105 */ 106 71 107 add_settings_section( 72 108 'cce_default_unavailable_section', … … 75 111 'chick_comics' 76 112 ); 113 77 114 add_settings_field( 78 115 'cce_default_unavailable', … … 82 119 'cce_default_unavailable_section' 83 120 ); 121 84 122 register_setting( 'chickcomic_settings_group', 'cce_default_unavailable' ); 85 123 86 // Default style. 124 /* 125 * Default style. 126 */ 127 87 128 add_settings_section( 88 129 'cce_default_style_section', … … 91 132 'chick_comics' 92 133 ); 134 93 135 add_settings_field( 94 136 'cce_default_style', … … 98 140 'cce_default_style_section' 99 141 ); 142 100 143 register_setting( 'chickcomic_settings_group', 'cce_default_style' ); 101 144 } 102 145 add_action( 'admin_init', 'chickcomic_settings_init' ); 103 146 147 /** 148 * Callback to display the default commic section description. 149 * 150 * @since 1.0 151 */ 104 152 function cce_default_comic_section_callback() { 153 105 154 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>' ); 106 155 } 107 156 157 /** 158 * Callback to display the default commic unavailabe section description. 159 * 160 * @since 1.0 161 */ 108 162 function 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 */ 112 172 function 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 */ 182 function cce_default_comic_input() { 183 119 184 // Available comics. 120 185 $comics = cce_available_comics(); 121 186 $comics['random'] = 'A Random Comic'; 122 187 $comics['latest'] = 'The Latest Comic'; 123 188 124 189 // Current default. 125 190 $current = get_option( 'cce_default_comic' ); … … 128 193 $html = '<select id="cce_default_comic" name="cce_default_comic">'; 129 194 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>'; 135 200 } 136 201 137 202 $html .= '</select>'; 138 203 … … 140 205 } 141 206 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 */ 212 function cce_default_unavailable_input() { 213 145 214 // Available options. 146 215 $options = array( 147 'random' => 'Random Comic',216 'random' => 'Random Comic', 148 217 'default' => 'Default Comic', 149 'none' => 'Nothing',150 ); 151 218 'none' => 'Nothing', 219 ); 220 152 221 // Current default. 153 222 $current = get_option( 'cce_default_unavailable' ); 154 223 155 224 // Build <select> element. 156 225 $html = '<select id="cce_default_unavailable" name="cce_default_unavailable">'; 157 226 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>'; 163 232 } 164 233 165 234 $html .= '</select>'; 166 235 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 */ 244 function cce_default_style_input() { 245 173 246 // Available options. 174 247 $options = cce_available_styles(); 175 248 176 249 // Current default. 177 250 $current = get_option( 'cce_default_style' ); 178 251 179 252 // Build <select> element. 180 253 $html = '<select id="cce_default_style" name="cce_default_style">'; 181 254 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>'; 187 260 } 188 261 189 262 $html .= '</select>'; 190 263 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 === 2 2 Contributors: JD55 3 Donate link: http:// dev.efieldguide.com/3 Donate link: http://codesymphony.co/ 4 4 Tags: comics, shortcode, comic, chick, tract 5 5 Requires at least: 2.7.0 6 6 Tested up to: 3.5.1 7 Stable tag: 1. 07 Stable tag: 1.1 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 39 39 == Changelog == 40 40 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 41 45 = 1.0 = 42 46 * Initial release. … … 44 48 == Upgrade Notice == 45 49 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 46 53 = 1.0 = 47 54 The initial release. -
chick-comic-embedder/trunk/shortcode.php
r666029 r728081 1 1 <?php 2 2 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 */ 25 function 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 ); 11 37 12 38 return display_chickcomic( $comic, $unavailable, $style ); … … 15 41 16 42 /** 17 * Display a comic. (This is the function used by the shortcode.)43 * Get a comic to display. 18 44 * 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. 22 47 * 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'. 24 54 */ 25 function display_chickcomic( $comic = NULL, $unavailable = NULL, $style = NULL )26 { 27 // Get array of available comics.55 function display_chickcomic( $comic = null, $unavailable = null, $style = null ) { 56 57 // Get the array of available comics. 28 58 $comics = cce_available_comics(); 29 59 30 60 // If the $comic isn't set we use the default. 31 if ( empty( $comic ) ) 32 { 61 if ( empty( $comic ) ) { 62 33 63 $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. 38 69 $comic = ucwords( strtolower( $comic ) ); 39 if ( in_array( $comic, $comics ) ) 40 { 70 71 if ( in_array( $comic, $comics ) ) { 72 41 73 $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. 44 76 } else { 77 45 78 // If $unavailble isn't set, we use the default. 46 if ( empty( $unavailable ) ) {79 if ( empty( $unavailable ) ) 47 80 $unavailable = get_option( 'cce_default_unavailable' ); 48 } 49 50 switch( $unavailable ) 51 { 81 82 switch ( $unavailable ) { 83 52 84 case 'random': 53 $comic = 'random'; break; 85 $comic = 'random'; 86 break; 87 54 88 case 'default': 55 $comic = get_option( 'cce_default_comic' ); break; 89 $comic = get_option( 'cce_default_comic' ); 90 break; 91 56 92 case 'none': 57 return FALSE; 93 return false; 94 58 95 default: 59 96 $comic = 'random'; … … 62 99 } 63 100 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; 80 114 } 81 115 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 ) 84 124 $style = ''; 85 } 86 125 87 126 // 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>'; 94 134 } 95 96 ?> -
chick-comic-embedder/trunk/style-preview.php
r666029 r728081 3 3 /** 4 4 * Enable a page where user's can preview all available styles. 5 * 6 * @package Chick_Comic_Embedder 7 * @since 1.0 5 8 */ 6 9 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 */ 17 function cce_style_query_var( $query_vars ) { 18 10 19 $query_vars[] = 'cce_preview_styles'; 11 20 return $query_vars; … … 13 22 add_filter( 'query_vars', 'cce_style_query_var' ); 14 23 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 */ 31 function 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' ); 23 37 exit(); 24 38 } 25 39 26 40 return; 27 41 } 28 42 add_action( 'parse_request', 'cce_styles_parse_request' ); 29 30 ?> -
chick-comic-embedder/trunk/styles-preview-template.php
r666029 r728081 3 3 /** 4 4 * A custom page template used to display the page of all available comic styles. 5 * 6 * @package Chick_Commic_Embedder 7 * @since 1.0 5 8 */ 6 9 … … 8 11 9 12 ?> 10 13 11 14 <div class="entry-content"> 12 15 <h2>Chick Comic Styles</h2> 13 16 <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> 15 18 <br /> 16 19 <br /> 17 20 18 21 <?php 19 22 20 23 $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 ); 28 31 echo( display_chickcomic( '1', 'random', $style ) ); 29 echo( $lorem . $lorem . $lorem );32 echo( $lorem_ipsum . $lorem_ipsum . $lorem_ipsum ); 30 33 echo( '<br /><br /><hr /><br />' ); 31 34 } 32 35 33 36 ?> 34 37 -
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; 4 11 } 5 .chickcomic-container.center{ 6 margin:15px auto; 7 width:425px; 12 13 .chickcomic-container.center { 14 margin: 15px auto; 15 width: 425px; 8 16 } 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; 13 22 } 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; 17 27 } 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; 21 32 } 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; 25 37 }
Note: See TracChangeset
for help on using the changeset viewer.