Plugin Directory

Changeset 689936


Ignore:
Timestamp:
04/01/2013 10:14:16 AM (13 years ago)
Author:
lrnz
Message:

New Version with new shortcode: accordion

Location:
shortcodify/trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • shortcodify/trunk/lang/shortcodify-de_DE.po

    r666057 r689936  
    99"Content-Type: text/plain; charset=UTF-8\n"
    1010"Content-Transfer-Encoding: 8bit\n"
    11 "PO-Revision-Date: 2013-02-11 00:24+0100\n"
     11"PO-Revision-Date: 2013-02-10 22:26+0100\n"
    1212"Last-Translator: Arne Lorenz <me@arnelorenz.de>\n"
    1313"Language-Team: Arne Lorenz <me@arnelorenz.de>\n"
     
    1818#: shortcodify.php:78
    1919msgid "Bookmarks"
    20 msgstr "Links"
     20msgstr ""
    2121
    2222#: shortcodify.php:196
    2323msgid "Shortcodify Menu"
    24 msgstr "Shortcodify Menü"
     24msgstr ""
    2525
    2626#: shortcodify.php:235
    2727msgid "Add this widget to an other textfield with [widget]"
    28 msgstr "Dieses Widget lässt sich mit [widget] an beliebiger Stelle einfügen."
     28msgstr ""
    2929
    3030#: shortcodify.php:301 shortcodify.php:342
     
    3838#: shortcodify.php:332
    3939msgid "Whoops! There was a problem with the data you posted. Please try again."
    40 msgstr "Ups, da gab es ein Problem beim Speichern. Tut mir leid"
     40msgstr ""
    4141
    4242#: shortcodify.php:339
     
    5454#: shortcodify.php:347
    5555msgid "Create widget-shortcode"
    56 msgstr "Erzeugt einen Widget-Shortcode "
     56msgstr ""
    5757
    5858#: shortcodify.php:350
    5959msgid "Creates a widget-area for a shortcode. Use it with [widget] "
    6060msgstr ""
    61 "Erzeugt einen Widget-Bereich für einen Shortcode. Nutzbar über [widget]"
    6261
    6362#: shortcodify.php:353
     
    130129#. Plugin Name of the plugin/theme
    131130msgid "Shortcodify"
    132 msgstr "Shortcodify"
     131msgstr ""
    133132
    134133#. #-#-#-#-#  plugin.pot (Shortcodify 1.0.0)  #-#-#-#-#
     
    137136#. Author URI of the plugin/theme
    138137msgid "http://www.arnelorenz.de/"
    139 msgstr "http://www.arnelorenz.de/"
     138msgstr ""
    140139
    141140#. Description of the plugin/theme
     
    145144#. Author of the plugin/theme
    146145msgid "Arne Lorenz"
    147 msgstr "Arne Lorenz"
     146msgstr ""
  • shortcodify/trunk/readme.txt

    r666069 r689936  
    3131*   `[random] Text1 Text2 [/random]` - returns only one of included areas (seperated by linebreak or whatever)
    3232*   `[menu]` - adds a new menu to the nav-menus of WordPress. This shortcode inserts the content to the page for sitemaps or sitelist.
     33*   `[accordion]` - adds a jQueryIU accordion to the page
     34*   `[section]` - adds a section to the accordion. Use it inside the `[accordion]` shortcode.
    3335*   A few more useful shortcodes
    3436
     
    3638Please send me a request!
    3739
    38 Version: trunk
     40Version: 1.2.0
    3941
    4042== Installation ==
     
    45474. Use the shortcodes in tiny-field.
    4648
    47 Version: trunk
    4849
    4950== Frequently asked questions ==
  • shortcodify/trunk/shortcodify.php

    r666218 r689936  
    1010*/
    1111/*
    12 Version: TRUNK --> Set version number HERE
     12Version: 1.3.0
    1313
    1414Author URI: http://www.arnelorenz.de/
     
    2525         * @var string The plugin version
    2626         */
    27         var $version = '1.0.0';
    28         var $version = 'TRUNK';
     27        var $version = '1.3.0';
    2928        /**
    3029         * @var string The options string name for this plugin
     
    139138                $this->useMenus();
    140139            }
    141         }
    142        
    143         //function wrap_shortcode_func($atts, $content= NULL)
    144 
     140           
     141            // To use a accordion
     142            if($this->options['sc_accordion'])
     143            {
     144                $this->useAccordion();
     145            }
     146        }
     147       
     148        /*
     149            Function for small shortcode handling
     150            instead of: function wrap_shortcode_func($atts, $content= NULL)
     151        */
    145152        public function __call($name, $argumente) {
     153            // for calling the widget functions
     154            if(substr($name, 0, 12) == 'createWidget'){
     155                $parts = explode('-', $name);
     156                $name = $parts[0];
     157                $number = $parts[1];
     158            }
     159           
    146160            $atts = $argumente[0];
    147161            $content = $argumente[1];
     
    172186                case 'random':
    173187                    if( isset( $atts['trennzeichen'] ) ) $trenner = $atts['trennzeichen'];
     188                    elseif( isset( $atts['separator'] ) ) $trenner = $atts['separator'];
    174189                    else {$trenner = PHP_EOL;}
    175190                   
     
    178193                    $rtn = '<span class="wrap_shortcode random">'.do_shortcode( $content[ $rnd ] ).'</span>';
    179194                break;
     195                case 'createWidget':
     196                    $html = $this->getWidgetContent('Shortcodify '.$number);
     197                    return '<div class="shortcodify_widget sc_w'.$number.'">'.$html.'</div>';
     198                break;
    180199                default:
    181200                    $rtn = $content;
     
    187206            add_action( 'widgets_init', array(&$this, 'shortcodify_widgets_init') );
    188207            add_shortcode( 'widget', array(&$this, 'createWidget') );
    189         }
     208            for ($i=1; $i<= $this->options['sc_widget_number']+1; $i++){
     209                // i dont know how to give this function-call an parameter :(
     210                // so i use this _call method
     211                add_shortcode( 'widget'.$i, array(&$this, 'createWidget-'.$i ) );
     212            }
     213        }
     214       
     215        function useAccordion(){
     216            //Register with hook 'wp_enqueue_scripts', which can be used for front end CSS and JavaScript
     217            add_action( 'wp_enqueue_scripts', array(&$this,'loadCss') );
     218            add_action( 'wp_enqueue_scripts', array(&$this,'loadJs') );
     219            add_shortcode( 'accordion', array(&$this, 'createAccordion') );
     220            add_shortcode( 'section', array(&$this, 'createAccordionSection') );
     221        }
     222        function loadJs() {
     223            wp_enqueue_script('jquery');
     224            wp_enqueue_script('jquery-ui-accordion');
     225            wp_enqueue_script(
     226                'shortcodify',
     227                plugins_url('/js/shortcodify.js', __FILE__),
     228                array('jquery'),
     229                false,
     230                true
     231            );
     232        }
     233        /**
     234         * Enqueue plugin style-file
     235         */
     236        function loadCss() {
     237            // Respects SSL, Style.css is relative to the current file
     238            // this css changes some font-sizes etc. :(
     239            //wp_register_style( 'jquery-ui-default', 'http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css' );
     240            //wp_enqueue_style( 'jquery-ui-default' );
     241            // we use this
     242            wp_register_style( 'shortcodify', plugins_url('css/shortcodify.css', __FILE__) );
     243            wp_enqueue_style( 'shortcodify' );
     244        }
    190245       
    191246        function useMenus(){
     
    209264        }       
    210265       
    211         function createWidget() {
    212             $html = $this->getWidgetContent('Shortcodify');
    213             return '<div class="shortcodify_widget">'.$html.'</div>';
     266        function createWidget($number) {
     267            $html = $this->getWidgetContent('Shortcodify '.$number);
     268            return '<div class="shortcodify_widget sc_w'.$number.'">'.$html.'</div>';
    214269        }   
    215270       
     
    224279        }
    225280
    226         //adds a widget Area
    227         /**
    228          * Register our sidebars and widgetized areas.
     281        function createAccordion($atts, $content = NULL){
     282            //$atts['link']
     283            if(isset($atts['type'])) $name = $atts['type'];
     284            else $name = 'no-auto';
     285           
     286            $ausgabe = trim($content);
     287            //preg_match_all('/\[section\].*\[\/section\]/', $content, $ausgabe);
     288           
     289            // remove whitespace at beginning
     290            $ausgabe = preg_replace('/\A.*?\[section/s', '[section', $ausgabe);
     291            // remove whitespace at end of sting
     292            $ausgabe = preg_replace('/\A.*?\]noitces\/\[/s', ']noitces/[', strrev($ausgabe));
     293            $ausgabe = strrev($ausgabe);
     294            // remove whitespace between tags
     295            $ausgabe = preg_replace('/\[\/section\].*?\[section/s', '[/section][section', $ausgabe);
     296           
     297            $rtn = '<div class="sc_accordion '.$name.'">'.do_shortcode( $ausgabe ).'</div>';
     298            return $rtn;
     299        }
     300        function createAccordionSection($atts, $content = NULL){
     301            $rtn = '<h3>'.$atts['name'].'</h3><div>'.do_shortcode($content).'</div>';
     302            return $rtn;
     303        }
     304        /**
     305         * Adds a widget Area
    229306         *
    230307         */
    231308        function shortcodify_widgets_init()
    232309        {
    233             register_sidebar( array(
     310            $conf = array(
    234311                'name' => 'Shortcodify',
    235312                'id' => 'shortcodify',
    236                 'description' => __( 'Add this widget to an other textfield with [widget]' ),
     313                'description' => __( 'Add this widget to an other textfield with [widget]' , $this->localizationDomain),
    237314                'before_widget' => '<p class="shortcodify_widget">',
    238315                'after_widget' => '</p>',
    239316                'before_title' => '<h2>',
    240317                'after_title' => '</h2>',
    241             ) );
    242             /*
    243             register_sidebar( array(
    244                 'name' => 'disclaimer',
    245                 'id' => 'disclaimer',
    246                 'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    247                 'after_widget' => "</aside>",
    248                 'before_title' => '<h3 class="widget-title">',
    249                 'after_title' => '</h3>',
    250             ) );
    251             */
    252         /*  // add this to tmeplate
    253             <?php if ( ! dynamic_sidebar( 'name' ) ) :?><?php endif;?>
    254         */
     318            );
     319            register_sidebar( $conf );
     320           
     321            for ($i=1; $i<=$this->options['sc_widget_number']+1; $i++){
     322                $conf = array(
     323                    'name' => 'Shortcodify '.$i,
     324                    'id' => 'shortcodify'.$i,
     325                    'description' => __( 'Add this widget to an other textfield with [widget'.$i.']' , $this->localizationDomain),
     326                    'before_widget' => '<p class="shortcodify_widget sc_w'.$i.'">',
     327                    'after_widget' => '</p>',
     328                    'before_title' => '<h2>',
     329                    'after_title' => '</h2>',
     330                );
     331                register_sidebar( $conf );
     332            }
    255333        }
    256334
     
    262340            if (!$options = get_option($this->optionsName)) {
    263341                $options = array(
    264                     'sc_widget' => true
    265                     //'sc_menu' => true
     342                    'sc_widget' => true,
     343                    'sc_widget_number' => 0,
     344                    'sc_menu' => true,
     345                    'sc_accordion' => true
    266346                    /*
    267347                    'title' => 'Pages:',
     
    313393                if (wp_verify_nonce($_POST['_wpnonce'], 'wp-test-update-options')) {
    314394                    $this->options['sc_widget'] = (isset($_POST['sc_widget']) && $_POST['sc_widget'] === 'on') ? true : false;
     395                    $this->options['sc_widget_number'] = (int)$_POST['sc_widget_number'];
     396                   
    315397                    $this->options['sc_menu'] = (isset($_POST['sc_menu']) && $_POST['sc_menu'] === 'on') ? true : false;
    316                     /*
     398                    $this->options['sc_accordion'] = (isset($_POST['sc_accordion']) && $_POST['sc_accordion'] === 'on') ? true : false;
     399                    /*
    317400                    $this->options['title'] = $_POST['title'];
    318401                    $this->options['previouspage'] = $_POST['previouspage'];
     
    350433                _e('Creates a widget-area for a shortcode. Use it with [widget]', $this->localizationDomain); ?></label></td>
    351434        </tr>
    352         <tr valign="top" style="display: ">
     435        <tr valign="top">
     436            <th scope="row"><?php _e('Number of widgets to create', $this->localizationDomain); ?></th>
     437            <td>
     438                <select name="sc_widget_number" id="sc_widget_number">
     439                <?php for ($i=0; $i<= 20; $i++) : ?>
     440                    <option value="<?php echo $i; ?>" <?php echo ($i == $this->options['sc_widget_number']) ? "selected='selected'" : ""; ?>><?php echo $i; ?></option>
     441                <?php endfor; ?>
     442                </select>
     443                <span class="description"><?php _e('Select the number of widgets you want to create.', $this->localizationDomain); ?></span></td>
     444        </tr>
     445        <tr valign="top">
    353446            <th scope="row"><?php _e('Create menu-shortcode', $this->localizationDomain); ?></th>
    354447            <td><label for="empty">
     
    356449                _e('Creates a menu-area for a shortcode. Create a new menu e.g. for a sitemap. Use shortcode with [menu] ', $this->localizationDomain); ?></label></td>
    357450        </tr>
    358    
     451        <tr valign="top">
     452            <th scope="row"><?php _e('Create accordion-shortcode', $this->localizationDomain); ?></th>
     453            <td><label for="empty">
     454                <input type="checkbox" id="sc_accordion" name="sc_accordion" <?php echo ($this->options['sc_accordion'] === true) ? "checked='checked'" : ""; ?>/> <?php
     455                _e('Creates a <a href="http://jqueryui.com/accordion/" target="_blank">accordion</a> shortcode. ', $this->localizationDomain); ?></label></td>
     456        </tr>
     457       
     458    <?php /*
    359459        <tr valign="top" style="display: none">
    360             <th scope="row"><?php _e('Before Markup:', $this->localizationDomain); ?></th>
    361             <td><input name="before" type="text" id="before" size="40" value="<?php echo stripslashes(htmlspecialchars($this->options['before'])); ?>"/>
    362             <span class="description"><?php _e('The HTML markup to display before the pagination code.', $this->localizationDomain); ?></span></td>
    363         </tr>
    364         <tr valign="top" style="display: none">
    365             <th scope="row"><?php _e('After Markup:', $this->localizationDomain); ?></th>
    366             <td><input name="after" type="text" id="after" size="40" value="<?php echo stripslashes(htmlspecialchars($this->options['after'])); ?>"/>
    367             <span class="description"><?php _e('The HTML markup to display after the pagination code.', $this->localizationDomain); ?></span></td>
    368         </tr>
    369         <tr valign="top" style="display: none">
    370             <th scope="row"><?php _e('WP-Paginate CSS File:', $this->localizationDomain); ?></th>
     460            <th scope="row"><?php _e('...', $this->localizationDomain); ?></th>
    371461            <td><label for="css">
    372462                <input type="checkbox" id="css" name="css" <?php echo ($this->options['css'] === true) ? "checked='checked'" : ""; ?>/> <?php printf(__('Include the default stylesheet wp-paginate.css? WP-Paginate will first look for <code>wp-paginate.css</code> in your theme directory (<code>themes/%s</code>).', $this->localizationDomain), get_template()); ?></label></td>
    373463        </tr>
    374464        <tr valign="top" style="display: none">
    375             <th scope="row"><?php _e('Page Range:', $this->localizationDomain); ?></th>
     465            <th scope="row"><?php _e('...', $this->localizationDomain); ?></th>
    376466            <td>
    377467                <select name="range" id="range">
     
    380470                <?php endfor; ?>
    381471                </select>
    382                 <span class="description"><?php _e('The number of page links to show before and after the current page. Recommended value: 3', $this->localizationDomain); ?></span></td>
     472                <span class="description"><?php _e('...', $this->localizationDomain); ?></span></td>
    383473        </tr>
    384474        <tr valign="top" style="display: none">
    385             <th scope="row"><?php _e('Page Anchors:', $this->localizationDomain); ?></th>
     475            <th scope="row"><?php _e('...', $this->localizationDomain); ?></th>
    386476            <td>
    387477                <select name="anchor" id="anchor">
     
    390480                <?php endfor; ?>
    391481                </select>
    392                 <span class="description"><?php _e('The number of links to always show at beginning and end of pagination. Recommended value: 1', $this->localizationDomain); ?></span></td>
     482                <span class="description"><?php _e('...', $this->localizationDomain); ?></span></td>
    393483        </tr>
    394484        <tr valign="top" style="display: none">
    395             <th scope="row"><?php _e('Page Gap:', $this->localizationDomain); ?></th>
     485            <th scope="row"><?php _e('...', $this->localizationDomain); ?></th>
    396486            <td>
    397487                <select name="gap" id="gap">
     
    400490                <?php endfor; ?>
    401491                </select>
    402                 <span class="description"><?php _e('The minimum number of pages in a gap before an ellipsis (...) is added. Recommended value: 3', $this->localizationDomain); ?></span></td>
    403         </tr>
     492                <span class="description"><?php _e('', $this->localizationDomain); ?></span></td>
     493        </tr>
     494        */?>
    404495    </table>
    405496    <p class="submit">
    406         <input type="submit" value="<?php _e('Save Changes'); ?>" name="wp_test_save" class="button-primary" />
     497        <input type="submit" value="<?php _e('Save Changes', $this->localizationDomain); ?>" name="wp_test_save" class="button-primary" />
    407498    </p>
    408499</form>
     
    420511    function ShortcodifyWidget() {
    421512        // Instantiate the parent object
    422         parent::__construct( false, 'My New Widget Title' );
     513        parent::__construct( false, 'The Widget Title' );
    423514    }
    424515
Note: See TracChangeset for help on using the changeset viewer.