Changeset 1992790
- Timestamp:
- 12/12/2018 01:35:27 PM (7 years ago)
- Location:
- lipsumator
- Files:
-
- 10 added
- 6 edited
-
tags/1.0 (added)
-
tags/1.0/README.txt (added)
-
tags/1.0/css (added)
-
tags/1.0/css/highlight.css (added)
-
tags/1.0/css/settings-page.css (added)
-
tags/1.0/inc (added)
-
tags/1.0/inc/LoremIpsum.php (added)
-
tags/1.0/inc/options.php (added)
-
tags/1.0/inc/shortcode.php (added)
-
tags/1.0/lipsumator.php (added)
-
trunk/README.txt (modified) (1 diff)
-
trunk/css/highlight.css (modified) (1 diff)
-
trunk/inc/LoremIpsum.php (modified) (3 diffs)
-
trunk/inc/options.php (modified) (6 diffs)
-
trunk/inc/shortcode.php (modified) (3 diffs)
-
trunk/lipsumator.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lipsumator/trunk/README.txt
r1978629 r1992790 4 4 Tags: placeholder, lorem 5 5 Requires at least: 3.0.1 6 Tested up to: 4.9.86 Tested up to: 5.0.0 7 7 Requires PHP: 5.2.4 8 8 License: GPL2 -
lipsumator/trunk/css/highlight.css
r1978629 r1992790 1 .lorem-ipsum-highlight > *{2 background-color: rgba(240, 6, 222, 0.7);1 .lorem-ipsum-highlight { 2 background-color: rgba(240, 6, 222, 0.7) !important; 3 3 } -
lipsumator/trunk/inc/LoremIpsum.php
r1978629 r1992790 169 169 $sentences = array(); 170 170 for ($i = 0; $i < $count; $i++) { 171 $sentences[] = $this->wordsArray($this->gauss( 24.46, 5.08));171 $sentences[] = $this->wordsArray($this->gauss(16, 6.08)); 172 172 } 173 173 $this->punctuate($sentences); … … 216 216 $paragraphs = array(); 217 217 for ($i = 0; $i < $count; $i++) { 218 $paragraphs[] = $this->sentences($this->gauss( 5.8, 1.93));218 $paragraphs[] = $this->sentences($this->gauss(3.8, 1.5)); 219 219 } 220 220 return $this->output($paragraphs, $tags, $array, "\n\n"); … … 250 250 private function shuffle() 251 251 { 252 if ($this->first) { 253 $this->first = array_slice($this->words, 0, 8); 254 $this->words = array_slice($this->words, 8); 255 shuffle($this->words); 256 $this->words = $this->first + $this->words; 257 $this->first = false; 258 } else { 259 shuffle($this->words); 260 } 252 shuffle($this->words); 261 253 } 262 254 /** -
lipsumator/trunk/inc/options.php
r1978629 r1992790 31 31 // register a new field in the "lipsumator_section_settings" section, inside the "lipsumator" page 32 32 add_settings_field( 33 'lipsumator_ field_pill', // as of WP 4.6 this value is used only internally33 'lipsumator_highlight_checkbox', // as of WP 4.6 this value is used only internally 34 34 // use $args' label_for to populate the id inside the callback 35 __(' Highlight', 'lipsumator'),36 'lipsumator_ field_pill_cb',35 __('Active Highlighting', 'lipsumator'), 36 'lipsumator_highlight_checkbox_cb', 37 37 'lipsumator', 38 38 'lipsumator_section_settings', 39 39 [ 40 'label_for' => 'lipsumator_ field_pill',40 'label_for' => 'lipsumator_highlight_checkbox', 41 41 'class' => 'lipsumator_row', 42 42 'lipsumator_custom_data' => 'custom', 43 43 ] 44 44 ); 45 46 45 47 } 46 48 … … 63 65 { 64 66 ?> 65 <div id="<?php echo esc_attr($args['id']); ?>"> 66 <p><?php esc_html_e('Lipsumator makes it easy to mock up page layouts with temporary text. When it is time to insert the final content you can turn on the "Highlight mode" to easily make sure you dont leave any placeholder text when the site goes live.', 'lipsumator'); ?></p> 67 <hr/> 68 <h3><?php esc_html_e('Syntax', 'lipsumator'); ?></h3> 69 <p><?php esc_html_e('Example:', 'lipsumator'); ?></p> 70 <pre> 71 <code>[lipsumator type="s" count="1" tag="h1"]</code> 67 <div id="<?php echo esc_attr($args['id']); ?>"> 68 <p> 69 <?php esc_html_e('Lipsumator makes it easy to mock up page layouts with temporary text. When it is time to insert the final content you can turn on the "Highlight mode" to easily make sure you dont leave any placeholder text when the site goes live.', 'lipsumator'); ?> 70 </p> 71 <hr /> 72 <h3> 73 <?php esc_html_e('Syntax', 'lipsumator'); ?> 74 </h3> 75 <p> 76 <?php esc_html_e('Example:', 'lipsumator'); ?> 77 </p> 78 <pre> 79 <code>[lipsumator w=3 t=h1]</code> 72 80 </pre> 73 81 74 <h4><?php esc_html_e('Type', 'lipsumator'); ?></h4> 75 <p><?php esc_html_e('This is defining the type of placeholder content you want to generate. It accepts one of 3 arguments:', 'lipsumator'); ?></p> 76 <ul> 77 <li><code><?php esc_html_e('w', 'lipsumator'); ?></code>: <?php esc_html_e('Generate single words.', 'lipsumator'); ?></li> 78 <li><code><?php esc_html_e('s', 'lipsumator'); ?></code>: <?php esc_html_e('Generate sentences.', 'lipsumator'); ?></li> 79 <li><code><?php esc_html_e('p', 'lipsumator'); ?></code>: <?php esc_html_e('Generate paragraphs.', 'lipsumator'); ?></li> 80 </ul> 81 82 <h4><?php esc_html_e('Count', 'lipsumator'); ?></h4> 83 <p><?php esc_html_e('The count argument indicates the number of words, sentences or paragraphs you generate, based on the type argument.', 'lipsumator'); ?></p> 84 85 <h4><?php esc_html_e('Tag', 'lipsumator'); ?></h4> 86 <p><?php esc_html_e('Tag defines the type of element tag you want to wrap your generated placeholder content in. Words and sentences are wrapt into a single tag. Paragraphs are wrapt individually.', 'lipsumator'); ?></p> 87 <hr/> 82 <h4> 83 <?php esc_html_e('Type', 'lipsumator'); ?> 84 </h4> 85 <p> 86 <?php esc_html_e('Use "w", "s" and "p" to define the type of content you want to generate. Whatever number you specify dictates the amount of words, sentences etc. you generate.', 'lipsumator'); ?> 87 </p> 88 <ul> 89 <li><code> 90 <?php esc_html_e('w', 'lipsumator'); ?></code>: 91 <?php esc_html_e('Generates words.', 'lipsumator'); ?> 92 </li> 93 <li><code> 94 <?php esc_html_e('s', 'lipsumator'); ?></code>: 95 <?php esc_html_e('Generates sentences.', 'lipsumator'); ?> 96 </li> 97 <li><code> 98 <?php esc_html_e('p', 'lipsumator'); ?></code>: 99 <?php esc_html_e('Generates paragraphs.', 'lipsumator'); ?> 100 </li> 101 </ul> 102 103 <h4> 104 <?php esc_html_e('Tag', 'lipsumator'); ?> <code> 105 <?php esc_html_e('t', 'lipsumator'); ?></code>: 106 </h4> 107 <p> 108 <?php esc_html_e('Tag is defined as "t" and defines the type of element tag you want to wrap your generated placeholder content in. Words and sentences are wrapt into a single tag. Paragraphs are wrapt individually. If you dont define anything, the generated content will not be wrapped at all.', 'lipsumator'); ?> 109 </p> 110 <hr /> 88 111 </div> 89 <?php112 <?php 90 113 } 91 114 … … 93 116 { 94 117 ?> 95 <p id="<?php echo esc_attr($args['id']); ?>"><?php //esc_html_e('Settings.', 'lipsumator'); ?></p> 96 <?php 118 <p id="<?php echo esc_attr($args['id']); ?>"> 119 <?php //esc_html_e('Settings.', 'lipsumator'); ?> 120 </p> 121 <?php 97 122 } 98 123 … … 105 130 // the "class" key value is used for the "class" attribute of the <tr> containing the field. 106 131 // you can add custom key value pairs to be used inside your callbacks. 107 function lipsumator_ field_pill_cb($args)132 function lipsumator_highlight_checkbox_cb($args) 108 133 { 109 134 // get the value of the setting we've registered with register_setting() 110 135 $options = get_option('lipsumator_options'); 111 136 // output the field ?> 112 <input type="checkbox" name="lipsumator_options[highlight]" value="1"<?php checked( 1 == $options['highlight'] ); ?> /> 113 <p class="description"> 114 <?php esc_html_e('Highlights all Lorem ipsum text. This is usefull when changing the placeholder text for the final content. The highlighting makes it less likely that you will miss something.', 'lipsumator'); ?> 115 </p> 116 <?php 117 } 137 <input type="checkbox" 138 name="lipsumator_options[highlight]" 139 value="1" 140 <?php 141 checked( 142 1==$options['highlight'] 143 ); 144 ?> /> 145 <p class="description"> 146 <?php esc_html_e('Highlights all Lorem ipsum text. This is usefull when changing the placeholder text for the final content. The highlighting makes it less likely that you will miss something.', 'lipsumator'); ?> 147 </p> 148 <?php 149 } 150 118 151 119 152 /** … … 159 192 // show error/update messages 160 193 settings_errors('lipsumator_messages'); ?> 161 <div class="wrap"> 162 <h1><?php echo esc_html(get_admin_page_title()); ?></h1> 163 <form action="options.php" method="post"> 164 <?php 194 <div class="wrap"> 195 <h1> 196 <?php echo esc_html(get_admin_page_title()); ?> 197 </h1> 198 <form action="options.php" 199 method="post"> 200 <?php 165 201 // output security fields for the registered setting "lipsumator" 166 202 settings_fields('lipsumator'); … … 170 206 // output save settings button 171 207 submit_button('Save Settings'); ?> 172 </form> 173 </div> 174 <?php 175 } 176 208 </form> 209 </div> 210 <?php 211 } -
lipsumator/trunk/inc/shortcode.php
r1978629 r1992790 3 3 function lipsumator_func($atts) 4 4 { 5 6 5 // Attributes 7 6 $atts = shortcode_atts( 8 7 array( 9 'type' => 's', 10 'count' => '1', 11 'tag' => 'p', 8 'w' => '', 9 's' => '', 10 'p' => '', 11 't' => '', 12 12 ), 13 13 $atts … … 16 16 $lipsum = new joshtronic\LoremIpsum(); 17 17 18 switch ($atts['type']) { 19 case 'p': 20 $output = $lipsum->paragraphs($atts['count'], $atts['tag']); 21 break; 22 case 's': 23 $output = $lipsum->sentences($atts['count'], $atts['tag']); 24 break; 25 case 'w': 26 $output = $lipsum->words($atts['count']); 27 $output = '<' . $atts['tag'] . '>' . $output . '</' . $atts['tag'] . '>'; 28 break; 29 default: 30 $output = sprintf('<pre>Error! "' . $atts['type'] . '" ' . __('is not a valid type. Use "p","s" or "w".', 'lipsumator') . '</pre>'); 31 break; 18 if ($atts['w'] !== '') { 19 $output = $lipsum->words($atts['w']); 20 if ($atts['t'] !== '' ) { 21 $output = '<' . $atts['t'] . '>' . ucfirst($output) . '</' . $atts['t'] . '>'; 22 } 23 } elseif ($atts['s'] !== '') { 24 $output = $lipsum->sentences($atts['s'], $atts['t']); 25 } elseif ($atts['p'] !== '') { 26 $output = $lipsum->paragraphs($atts['p'], $atts['t']); 27 } else { 28 $output = $lipsum->paragraphs('1', $atts['t']); 32 29 } 33 30 … … 40 37 } 41 38 42 //$output = wpautop($output);43 44 39 return $output; 45 40 -
lipsumator/trunk/lipsumator.php
r1978629 r1992790 4 4 Plugin URI: https://norsemedia.dk/plugins/lipsumator/ 5 5 Description: Lorem ipsum shortcode 6 Version: 1. 0.06 Version: 1.5.0 7 7 Author: Norse Media 8 8 Author URI: https://norsemedia.dk/ … … 24 24 $plugin_url = plugin_dir_url( __FILE__ ); 25 25 $options = get_option('lipsumator_options'); 26 if ( isset($options['highlight']) && has_shortcode( $post->post_content, 'lipsum')) {26 if ( isset($options['highlight']) ) { 27 27 wp_enqueue_style( 'lipsumator', $plugin_url . 'css/highlight.css' ); 28 28 }
Note: See TracChangeset
for help on using the changeset viewer.