Plugin Directory

Changeset 1992790


Ignore:
Timestamp:
12/12/2018 01:35:27 PM (7 years ago)
Author:
norsemedia
Message:

Update to version 1.5

Location:
lipsumator
Files:
10 added
6 edited

Legend:

Unmodified
Added
Removed
  • lipsumator/trunk/README.txt

    r1978629 r1992790  
    44Tags: placeholder, lorem
    55Requires at least: 3.0.1
    6 Tested up to: 4.9.8
     6Tested up to: 5.0.0
    77Requires PHP: 5.2.4
    88License: 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;
    33}
  • lipsumator/trunk/inc/LoremIpsum.php

    r1978629 r1992790  
    169169        $sentences = array();
    170170        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));
    172172        }
    173173        $this->punctuate($sentences);
     
    216216        $paragraphs = array();
    217217        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));
    219219        }
    220220        return $this->output($paragraphs, $tags, $array, "\n\n");
     
    250250    private function shuffle()
    251251    {
    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);
    261253    }
    262254    /**
  • lipsumator/trunk/inc/options.php

    r1978629 r1992790  
    3131    // register a new field in the "lipsumator_section_settings" section, inside the "lipsumator" page
    3232    add_settings_field(
    33         'lipsumator_field_pill', // as of WP 4.6 this value is used only internally
     33        'lipsumator_highlight_checkbox', // as of WP 4.6 this value is used only internally
    3434        // 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',
    3737        'lipsumator',
    3838        'lipsumator_section_settings',
    3939        [
    40             'label_for' => 'lipsumator_field_pill',
     40            'label_for' => 'lipsumator_highlight_checkbox',
    4141            'class' => 'lipsumator_row',
    4242            'lipsumator_custom_data' => 'custom',
    4343        ]
    4444    );
     45
     46
    4547}
    4648 
     
    6365{
    6466    ?>
    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=&quot;s&quot; count=&quot;1&quot; tag=&quot;h1&quot;]</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>
    7280</pre>
    7381
    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 />
    88111</div>
    89  <?php
     112<?php
    90113}
    91114
     
    93116{
    94117    ?>
    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
    97122}
    98123 
     
    105130// the "class" key value is used for the "class" attribute of the <tr> containing the field.
    106131// you can add custom key value pairs to be used inside your callbacks.
    107 function lipsumator_field_pill_cb($args)
     132function lipsumator_highlight_checkbox_cb($args)
    108133{
    109134    // get the value of the setting we've registered with register_setting()
    110135    $options = get_option('lipsumator_options');
    111136    // 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
    118151 
    119152/**
     
    159192    // show error/update messages
    160193 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
    165201 // output security fields for the registered setting "lipsumator"
    166202 settings_fields('lipsumator');
     
    170206    // output save settings button
    171207    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  
    33function lipsumator_func($atts)
    44{
    5 
    65    // Attributes
    76    $atts = shortcode_atts(
    87        array(
    9             'type' => 's',
    10             'count' => '1',
    11             'tag' => 'p',
     8            'w' => '',
     9            's' => '',
     10            'p' => '',
     11            't' => '',
    1212        ),
    1313        $atts
     
    1616    $lipsum = new joshtronic\LoremIpsum();
    1717
    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']);
    3229    }
    3330
     
    4037    }
    4138
    42     //$output = wpautop($output);
    43 
    4439    return $output;
    4540
  • lipsumator/trunk/lipsumator.php

    r1978629 r1992790  
    44Plugin URI:   https://norsemedia.dk/plugins/lipsumator/
    55Description:  Lorem ipsum shortcode
    6 Version:      1.0.0
     6Version:      1.5.0
    77Author:       Norse Media
    88Author URI:   https://norsemedia.dk/
     
    2424    $plugin_url = plugin_dir_url( __FILE__ );
    2525    $options = get_option('lipsumator_options');
    26     if ( isset($options['highlight']) && has_shortcode( $post->post_content, 'lipsum') ) {
     26    if ( isset($options['highlight']) ) {
    2727        wp_enqueue_style( 'lipsumator', $plugin_url . 'css/highlight.css' );
    2828    }
Note: See TracChangeset for help on using the changeset viewer.