Plugin Directory

Changeset 1026695


Ignore:
Timestamp:
11/16/2014 09:40:28 AM (11 years ago)
Author:
blocknot.es
Message:

CSS editor; autop option; override template option; improvements

Location:
polymer-components
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • polymer-components/trunk/conf.php

    r1025830 r1026695  
    11<?php
     2define( 'POLYMER_VERSION', '0.4.2' );
     3
    24define( 'POLYMER_COMPONENTS_MAIN', 'polymer-components/polymer-components.php' );
    35
  • polymer-components/trunk/polymer-admin.js

    r1018331 r1026695  
    1818            indentWithTabs: true,
    1919            lineNumbers: true,
     20            mode: 'javascript',
     21            smartIndent: false
     22        });
     23    }
     24
     25    var poly_styles = document.getElementById( 'poly_styles' );
     26    if( poly_styles != null )
     27    {
     28        CodeMirror.fromTextArea( poly_styles, {
     29            dragDrop: false,
     30            indentWithTabs: true,
     31            lineNumbers: true,
     32            mode: 'css',
    2033            smartIndent: false
    2134        });
     
    3245                indentWithTabs: true,
    3346                lineNumbers: true,
     47                mode: 'html',
    3448                smartIndent: false
    3549            });
  • polymer-components/trunk/polymer-admin.php

    r1025830 r1026695  
    3939        wp_register_script( 'poly-admin-codemirror', plugin_dir_url( __FILE__ ) . 'codemirror/codemirror.min.js', array() );
    4040        wp_register_script( 'poly-admin-codemirror-js', plugin_dir_url( __FILE__ ) . 'codemirror/javascript.js', array() );
     41        wp_register_script( 'poly-admin-codemirror-css', plugin_dir_url( __FILE__ ) . 'codemirror/css.js', array() );
    4142        wp_enqueue_script( 'poly-admin-scripts' );
    4243        wp_enqueue_script( 'poly-admin-codemirror' );
    4344        wp_enqueue_script( 'poly-admin-codemirror-js' );
     45        wp_enqueue_script( 'poly-admin-codemirror-css' );
    4446    // Settings
    4547        register_setting(
     
    8890        <h2>Polymer Components</h2>
    8991        <hr/>
     92        <div>Polymer version provided: <b><?php echo POLYMER_VERSION; ?></b></div>
    9093        <form method="post" action="options.php">
    9194        <?php
     
    120123        $val = get_post_meta( $post->ID, 'poly_iconsets', TRUE );
    121124        $iconsets = !empty( $val ) ? unserialize( $val ) : array();
     125        $autop = get_post_meta( $post->ID, 'poly_autop', TRUE );
     126        $template = get_post_meta( $post->ID, 'poly_template', TRUE );
    122127        $groups = array();
    123128        foreach( $polycomponents->tags as $tag => $file )
     
    126131            if( $pos > 0 ) $groups[substr( $tag, 0, $pos )][] = $tag;
    127132        }
    128         echo '<div id="poly_page_options">', "\n";
    129         echo '<div><b>Iconsets</b>:&nbsp; <span style="font-size: 9pt">';
    130         foreach( $polycomponents->iconsets as $iconset => $file )
    131         {
    132             echo '<span style="padding-right: 18px"><input type="checkbox" id="chk_', $iconset, '" name="', $iconset, '"', in_array( $iconset, $iconsets ) ? ' checked="checked"' : '',' />';
    133             echo '<label for="chk_', $iconset, '">', $iconset, '</label></span> ';
    134         }
    135         $sep = '';
    136         echo "</span></div>\n<div style=\"padding-top: 10px; padding-bottom: 10px\">\n";
     133    // --- Docs ---
     134        echo '<div style="padding-top: 10px">';
    137135        foreach( $groups as $group => $tags )
    138136        {
     
    151149        }
    152150        echo "</div>\n";
     151    // --- Options ---
     152        echo '<div id="poly_page_options">', "\n";
     153        echo '<div style="padding-top: 10px">';
     154        echo '<label for="poly_autop"><b>Enable autop</b>:</label> <input type="checkbox" id="poly_autop" name="poly_autop"', empty( $autop ) ? '' : ' checked="checked"', '/> &ndash; ';
     155        echo '<label for="poly_template"><b>Override template</b>:</label> <input type="checkbox" id="poly_template" name="poly_template"', empty( $template ) ? '' : ' checked="checked"', '/>';
     156        echo '</div><div style="padding-top: 10px"><b>Import iconsets</b>:&nbsp; <span style="font-size: 9pt">';
     157        foreach( $polycomponents->iconsets as $iconset => $file )
     158        {
     159            echo '<span style="padding-right: 18px"><input type="checkbox" id="chk_', $iconset, '" name="', $iconset, '"', in_array( $iconset, $iconsets ) ? ' checked="checked"' : '',' />';
     160            echo '<label for="chk_', $iconset, '">', $iconset, '</label></span> ';
     161        }
     162        $sep = '';
     163        echo "</span></div>\n";
     164    // --- JS editor ---
    153165        if(      $post->post_type == 'post' ) $poly_javascript = isset( $this->options['polymer-js-posts'] ) && !empty( $this->options['polymer-js-posts'] );
    154166        else if( $post->post_type == 'page' ) $poly_javascript = isset( $this->options['polymer-js-pages'] ) && !empty( $this->options['polymer-js-pages'] );
     
    156168        if( $poly_javascript )
    157169        {
    158             echo '<div style="border-bottom: 1px solid #aaa; padding-bottom: 5px"><b>Javascript code</b>:</div>';
     170            echo '<div style="border-bottom: 1px solid #aaa; padding-top: 10px; padding-bottom: 5px"><b>Javascript code</b>:</div>';
    159171            $val = get_post_meta( $post->ID, 'poly_javascript', TRUE );
    160172            echo '<textarea name="poly_javascript" id="poly_javascript" style="width: 100%" cols="80" rows="6">', stripslashes( $val ), '</textarea>', "\n";
    161173        }
     174    // --- CSS editor ---
     175        echo '<div style="border-bottom: 1px solid #aaa; padding-top: 10px; padding-bottom: 5px"><b>Styles</b>:</div>';
     176        $val = get_post_meta( $post->ID, 'poly_styles', TRUE );
     177        echo '<textarea name="poly_styles" id="poly_styles" style="width: 100%" cols="80" rows="6">', stripslashes( $val ), '</textarea>', "\n";
    162178        echo "</div>\n";
    163179    }
     
    188204        //update_post_meta( $post_id, 'poly_tags', sanitize_text_field( array_keys( $meta ) ) );
    189205
     206        update_post_meta( $post_id, 'poly_autop', isset( $_POST['poly_autop'] ) && !empty( $_POST['poly_autop'] ) );
     207        update_post_meta( $post_id, 'poly_template', isset( $_POST['poly_template'] ) && !empty( $_POST['poly_template'] ) );
     208
    190209        $iconsets = array();
    191210        foreach( $polycomponents->iconsets as $iconset => $file )
     
    194213        }
    195214        update_post_meta( $post_id, 'poly_iconsets', serialize( $iconsets ) );
    196 
    197         update_post_meta( $post_id, 'poly_javascript', addslashes( $_POST['poly_javascript'] ) );
     215        update_post_meta( $post_id, 'poly_javascript', ( isset( $_POST['poly_javascript'] ) && !empty( $_POST['poly_javascript'] ) ) ? addslashes( $_POST['poly_javascript'] ) : '' );
     216        update_post_meta( $post_id, 'poly_styles', ( isset( $_POST['poly_styles'] ) && !empty( $_POST['poly_styles'] ) ) ? addslashes( $_POST['poly_styles'] ) : '' );
    198217    }
    199218}
  • polymer-components/trunk/polymer-components.php

    r1025830 r1026695  
    44 * Plugin URI: http://blocknot.es/
    55 * Description: Add Polymer elements to your website!
    6  * Version: 1.2.0
     6 * Version: 1.2.5
    77 * Author: Mattia Roccoberton
    88 * Author URI: http://blocknot.es
     
    107107    );
    108108    var $options;
     109    var $import = array();
    109110
    110111    function __construct()
     
    115116            $this->options = unserialize( POLYMER_OPTIONS );
    116117        }
    117         if( !is_admin() ) add_action( 'wp_enqueue_scripts', array( &$this, 'wp_enqueue_scripts' ) );
     118        if( !is_admin() )
     119        {
     120            add_filter( 'template_include', array( &$this, 'template_include' ), 99, 1 );
     121            add_action( 'wp_enqueue_scripts', array( &$this, 'wp_enqueue_scripts' ) );
     122            add_action( 'wp_head', array( &$this, 'wp_head' ) );
     123        }
    118124        add_filter( 'is_protected_meta', array( &$this, 'is_protected_meta' ), 10, 2 );              // Hide internal meta
    119125        remove_filter( 'the_content', 'wpautop' );                                                   // >>> Disable automatic formatting inside WordPress shortcodes
    120         add_filter( 'the_content', 'wpautop' , 99 );
    121126        add_filter( 'the_content', 'shortcode_unautop', 100 );
    122127        //add_filter( 'no_texturize_shortcodes', array( &$this, 'no_texturize_shortcodes' ), 10, 4 );  // <<<
     
    137142    //}
    138143
     144    function template_include( $template )
     145    {
     146        global $post;
     147        if( is_singular() )
     148        {
     149            $poly_template = get_post_meta( $post->ID, 'poly_template', TRUE );
     150            if( !empty( $poly_template ) ) return plugin_dir_path( __FILE__ ) . 'polymer-template.php';
     151        }
     152        return $template;
     153    }
     154
    139155    function widgets_init()
    140156    {
     
    146162        global $post;
    147163        wp_enqueue_script( 'polymer-platform-script', plugin_dir_url( __FILE__ ) . 'components/platform/platform.js', array() );
    148         $list = array();
    149164        if( is_singular() )
    150165        {   // Single posts and pages
     166        // --- autop ---
     167            $poly_autop = get_post_meta( $post->ID, 'poly_autop', TRUE );
     168            if( !empty( $poly_autop ) ) add_filter( 'the_content', 'wpautop' , 99 );
     169        // --- Poly import ---
    151170            $poly_tags = get_post_meta( $post->ID, 'poly_tags', TRUE );
    152171            if( !empty( $poly_tags ) )
     
    155174                foreach( $tags as $tag )
    156175                {
    157                     if(      isset( $this->tags[$tag]  ) ) $list[$tag] = $this->tags[$tag];
    158                     else if( isset( $this->extra[$tag] ) ) $list[$tag] = $this->extra[$tag];
     176                    if(      isset( $this->tags[$tag]  ) ) $this->import[$tag] = $this->tags[$tag];
     177                    else if( isset( $this->extra[$tag] ) ) $this->import[$tag] = $this->extra[$tag];
    159178                }
    160179            }
     180        // --- Poly iconsets ---
    161181            $poly_iconsets = get_post_meta( $post->ID, 'poly_iconsets', TRUE );
    162182            if( !empty( $poly_iconsets ) )
    163183            {
    164184                $iconsets = unserialize( $poly_iconsets );
    165                 foreach( $iconsets as $iconset ) if( isset( $this->iconsets[$iconset] ) ) echo '<link rel="import" href="', plugin_dir_url( __FILE__ ), 'components/', $this->iconsets[$iconset], "\" />\n";
     185                foreach( $iconsets as $iconset ) if( isset( $this->iconsets[$iconset] ) ) $this->import[$iconset] = $this->iconsets[$iconset];
    166186            }
    167             $poly_javascript = get_post_meta( $post->ID, 'poly_javascript', TRUE );
    168             if( !empty( $poly_javascript ) ) echo "<script type=\"text/javascript\">\n", stripslashes( $poly_javascript ), "\n</script>\n";
     187            $this->javascript = get_post_meta( $post->ID, 'poly_javascript', TRUE );
     188            $this->styles = get_post_meta( $post->ID, 'poly_styles', TRUE );
    169189        }
    170190        //var_dump( is_active_sidebar( is_active_widget( FALSE, FALSE, 'polymer_widget' ) ) );
     
    180200                    foreach( $tags as $tag )
    181201                    {
    182                         if(      isset( $this->tags[$tag]  ) ) $list[$tag] = $this->tags[$tag];
    183                         else if( isset( $this->extra[$tag] ) ) $list[$tag] = $this->extra[$tag];
     202                        if(      isset( $this->tags[$tag]  ) ) $this->import[$tag] = $this->tags[$tag];
     203                        else if( isset( $this->extra[$tag] ) ) $this->import[$tag] = $this->extra[$tag];
    184204                    }
    185205                }
    186206            }
    187207        }
    188         foreach( $list as $tag => $import ) echo '<link rel="import" href="', plugin_dir_url( __FILE__ ), 'components/', $import,  "\" />\n";
     208    }
     209
     210    function wp_head()
     211    {
     212        foreach( $this->import as $tag => $import ) echo '<link rel="import" href="', plugin_dir_url( __FILE__ ), 'components/', $import,  "\" />\n";
     213        if( isset( $this->javascript ) && !empty( $this->javascript ) ) echo "<script type=\"text/javascript\">\n", stripslashes( $this->javascript ), "\n</script>\n";
     214        if( isset( $this->styles ) && !empty( $this->styles ) ) echo "<style type=\"text/css\">\n", stripslashes( $this->styles ), "\n</style>\n";
    189215    }
    190216}
  • polymer-components/trunk/readme.txt

    r1025830 r1026695  
    55Requires at least: 3.5.0
    66Tested up to: 4.0
    7 Stable tag: 1.2.0
     7Stable tag: 1.2.5
    88License: GPL3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.txt
     
    1717Polymer documentation page: http://www.polymer-project.org/
    1818
     19Notice: Polymer is still in developer preview so some constructs may change in future and a modern browser is required to run Polymer apps.
     20
    1921Features:
    2022
    2123* Polymer tags directly available (core & paper) in posts and pages with the HTML editor;
     24* Polymer widget;
    2225* [poly] shortcode to access to the Polymer tags;
    2326* auto import the necessary HTML components;
    2427* Javascript editor in posts / pages admin;
     28* CSS editor in posts / pages admin;
     29* autop on/off option;
     30* template override on/off option;
    2531* documentation links for each tag.
    2632
     
    3743    [poly paper-button raised style="color: green"]A green button[/poly]
    3844    [poly paper-item icon="home" label="Test link"]<a href="http://www.google.it" target="_blank"></a>[/poly]
     45
     46Notes:
     47
     48* autop option: the autop() Wordpress function adds p and br tags to the post content when a newline is found, but this can break the Polymer tags. That's why I have added this option that disable by default the autop function
     49* template override option: if this option is enabled this plugin will load a special template which provides only the required components to run a Polymer app. This is useful if you want a "fullscreen" Polymer app
    3950
    4051== Installation ==
     
    6071= Can I create my elements? =
    6172
    62 Yes, you can use the *polymer-element* tag in posts and pages included the script block.
     73Yes, you can use the *polymer-element* tag in posts and pages also with script blocks.
    6374
    6475== Screenshots ==
     
    7081== Upgrade Notice ==
    7182
     83= 1.2.5 =
     84* New CSS editor for posts / pages
     85* New options: autop, override template
     86* Internal improvements
    7287= 1.2.0 =
    7388* New widget
     
    7893= 1.1.0 =
    7994* New settings screen
    80 * New settings: JS in pages / posts
     95* New settings: JS in posts / pages
    8196* Improved Javascript editor
    8297* Added polymer-element tag
    83 = 1.0.6 =
    84 * Added Javascript textarea to posts and pages
    8598
    8699== Changelog ==
    87100
     101= 1.2.5 =
     102* New CSS editor for posts / pages
     103* New options: autop, override template
     104* Internal improvements
    88105= 1.2.0 =
    89106* New widget
     
    94111= 1.1.0 =
    95112* New settings screen
    96 * New settings: JS in pages / posts
     113* New settings: JS in posts / pages
    97114* Improved Javascript editor
    98115* Added polymer-element tag
    99116= 1.0.6 =
    100 * Added Javascript textarea to posts and pages
     117* New Javascript editor for posts / pages
    101118= 1.0.2 =
    102119* Small fix for admin docs
Note: See TracChangeset for help on using the changeset viewer.