Plugin Directory

Changeset 1109898


Ignore:
Timestamp:
03/10/2015 10:57:55 PM (11 years ago)
Author:
holyhope
Message:

Add options, use settings api and more (see readme.txt file)

Location:
qrcodes
Files:
16 added
3 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • qrcodes/trunk/index.php

    r1102798 r1109898  
    44Description: Add qrcodes to pages
    55Author: Pierre Péronnet
    6 Version: 2.0
     6Version: 1.2
    77*/
    88
     
    2020    ) );
    2121}
     22define( 'QRCODES_INDEX_FILE', __FILE__ );
     23
    2224unset( $uploads );
    23 
    24 require_once __DIR__ . '/qrcodes.php';
    25 include_once __DIR__ . '/admin.php';
    2625
    2726function wp_qrcodes_activation() {
     
    3231        ) );
    3332    }
     33
     34    add_option( 'qrcodes-network-media-query', array(
     35        'print' => __( 'displayed on printed pages', 'qrcodes' ),
     36    ), '', 'yes' );
     37    qrcodes_media_query_add_default_options( 'print' );
    3438}
    35 register_activation_hook( __FILE__, 'wp_qrcodes_activation' );
     39register_activation_hook( QRCODES_INDEX_FILE, 'wp_qrcodes_activation' );
     40
     41
     42function qrcodes_media_query_remove_options( $medium ) {
     43    $blog_id = get_current_blog_id();
     44    delete_blog_option(
     45        $blog_id,
     46        "qrcodes-media-query-{$medium}-horizontal-direction"
     47    );
     48    delete_blog_option(
     49        $blog_id,
     50        "qrcodes-media-query-{$medium}-horizontal-value"
     51    );
     52    delete_blog_option(
     53        $blog_id,
     54        "qrcodes-media-query-{$medium}-vertical-direction"
     55    );
     56    delete_blog_option(
     57        $blog_id,
     58        "qrcodes-media-query-{$medium}-vertical-value"
     59    );
     60    delete_blog_option(
     61        $blog_id,
     62        "qrcodes-media-query-{$medium}-size"
     63    );
     64}
     65
     66function qrcodes_media_query_add_default_options( $medium ) {
     67    $blog_id = get_current_blog_id();
     68    add_blog_option(
     69        $blog_id,
     70        "qrcodes-media-query-{$medium}-horizontal-direction",
     71        'right',
     72        true
     73    );
     74    add_blog_option(
     75        $blog_id,
     76        "qrcodes-media-query-{$medium}-horizontal-value",
     77        0,
     78        true
     79    );
     80    add_blog_option(
     81        $blog_id,
     82        "qrcodes-media-query-{$medium}-vertical-direction",
     83        'top',
     84        true
     85    );
     86    add_blog_option(
     87        $blog_id,
     88        "qrcodes-media-query-{$medium}-vertical-value",
     89        0,
     90        true
     91    );
     92    add_blog_option(
     93        $blog_id,
     94        "qrcodes-media-query-{$medium}-size",
     95        false,
     96        true
     97    );
     98}
    3699
    37100function full_remove_folder( $dir ) {
     
    57120    full_remove_folder( QRCODES_BASEDIR );
    58121}
    59 register_deactivation_hook( __FILE__, 'wp_qrcodes_deactivation' );
     122register_deactivation_hook( QRCODES_INDEX_FILE, 'wp_qrcodes_deactivation' );
     123
     124require_once path_join( __DIR__, 'qrcodes.php' );
     125include_once path_join( __DIR__, 'admin/admin.php' );
  • qrcodes/trunk/qrcodes.php

    r1102797 r1109898  
    3030function qrcodes_get_basedir() {
    3131    return QRCODES_BASEDIR;
    32 }
    33 
    34 function qrcodes_get_cached_url( $post_id ) {
    35     //TODO
    36     return path_join(
    37         qrcodes_get_baseurl(),
    38         'post-' . $post_id . '.png'
    39     );
    40 }
    41 
    42 function qrcodes_get_cached_dir( $blog_id, $post_id ) {
    43     //TODO
    44     return path_join(
    45         qrcodes_get_basedir( $blog_id ),
    46         'post-' . $post_id . '.png'
    47     );
    4832}
    4933
     
    225209
    226210function qrcodes_enqueue_style() {
    227     $media_query = get_option( 'qrcodes-network-media-query', array( 'print' ) );
     211    $media_query = get_option( QRCODES_MEDIA_QUERY_OPTION_NAME, array() );
    228212    wp_enqueue_style(
    229213        'qrcodes',
     
    233217        'all'
    234218    );
    235     foreach ( $media_query as $medium ) {
     219    foreach ( $media_query as $medium => $desc ) {
     220        $style =
     221            'display:block;' .
     222            get_blog_option(
     223                get_current_blog_id(),
     224                "qrcodes-media-query-{$medium}-horizontal-direction"
     225            ) . ':' .
     226            get_blog_option(
     227                get_current_blog_id(),
     228                "qrcodes-media-query-{$medium}-horizontal-value"
     229            ) . ';' .
     230            get_blog_option(
     231                get_current_blog_id(),
     232                "qrcodes-media-query-{$medium}-vertical-direction"
     233            ) . ':' .
     234            get_blog_option(
     235                get_current_blog_id(),
     236                "qrcodes-media-query-{$medium}-vertical-value"
     237            ) . ';';
     238        $size = get_blog_option(
     239            get_current_blog_id(),
     240            "qrcodes-media-query-{$medium}-size"
     241        );
     242        if ( $auto_size ) {
     243            $style .=
     244                'width:' .
     245                get_blog_option(
     246                    get_current_blog_id(),
     247                    "qrcodes-media-query-{$medium}-size"
     248                ) . ';' .
     249                'height:' .
     250                get_blog_option(
     251                    get_current_blog_id(),
     252                    "qrcodes-media-query-{$medium}-size"
     253                ) . ';';
     254        }
    236255        wp_add_inline_style(
    237256            'qrcodes',
    238257            '@media ' . esc_attr( $medium ) . '{' .
    239258                'body .qrcode {' .
    240                     'display:block;' .
    241                     get_blog_option(
    242                         get_current_blog_id(),
    243                         "qrcodes-media-query-{$medium}-horizontal-direction",
    244                         'right'
    245                     ) . ':' .
    246                     get_blog_option(
    247                         get_current_blog_id(),
    248                         "qrcodes-media-query-{$medium}-horizontal-position",
    249                         0
    250                     ) .
    251                     get_blog_option(
    252                         get_current_blog_id(),
    253                         "qrcodes-media-query-{$medium}-horizontal-unit",
    254                         '%'
    255                     ) . ';' .
    256                     get_blog_option(
    257                         get_current_blog_id(),
    258                         "qrcodes-media-query-{$medium}-vertical-direction",
    259                         'bottom'
    260                     ) . ':' .
    261                     get_blog_option(
    262                         get_current_blog_id(),
    263                         "qrcodes-media-query-{$medium}-vertical-position",
    264                         100
    265                     ) .
    266                     get_blog_option(
    267                         get_current_blog_id(),
    268                         "qrcodes-media-query-{$medium}-vertical-unit",
    269                         '%'
    270                     ) . ';' .
     259                    $style .
    271260                '}' .
    272261            '}'
     
    300289function qrcodes_network_data_force( $data ) {
    301290    return do_shortcode(
    302         get_option( 'qrcodes-network-override-data-value', $data )
     291        get_option(
     292            'qrcodes-network-override-data-value',
     293            network_home_url()
     294        )
    303295    );
    304296}
     
    312304    );
    313305}
    314 if ( ! get_option( 'qrcodes-network-allow-override-data', true ) ) {
     306if ( ! get_option( 'qrcodes-network-override-data-allow', true ) ) {
    315307    add_filter( 'qrcodes-data', 'qrcodes_network_data_force', 30 );
    316308} else {
  • qrcodes/trunk/readme.txt

    r1102797 r1109898  
    11=== QRCodes ===
    2 
    32Contributors: holyhope
    43Donate link:
     
    65Requires at least: 4.1
    76Tested up to: 4.1
    8 Stable tag: 4.3
     7Stable tag: trunk
    98License: GPLv2 or later.
    109License URI: http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses
    1110
    1211QRCode add images that visitor can flash with their favorites applications.
    13 Choose where to display and when (ex: only on printed page, at the top right corner).
     12Choose where to display and when (ex: only on printed page).
    1413
    1514== Description ==
     
    2625QRCodes requires :
    2726
    28 * [PHP version 5+](http://php.net)
     27* A valid [*QRCode PHP library*](http://sourceforge.net/projects/phpqrcode/ 'SourceForge Project') installation.
    2928
    3029== Installation ==
     
    5251== Screenshots ==
    5352
    54 1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from
    55 the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets
    56 directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png`
    57 (or jpg, jpeg, gif).
    58 2. This is the second screen shot
     531. General plugin settings.
     542. Settings of the library (resolution and correction level).
     553. Set positions and size of qrcodes in different media query.
     564. Manage your website in a multisite installation so QRcodes ref to a specific url (with shortcodes) or let administrators set it by themself.
     575. Manage media query in the network admin panel for multisite installation or in normal admin for normal one.
     587. Exemple of qrcode in classique navigation.
     596. Exemple of qrcode in printed page (same page of 6th screenshot, different position).
    5960
    6061== Changelog ==
    6162
     63= 1.2 =
     64
     65* Fix qrcodes generation.
     66* Use now correctly [Settings API](http://codex.wordpress.org/Settings_API 'wordpress.org').
     67* Upgrade media query management interface.
     68* Use *postbox* and *nav-tab* style for admin pages.
     69* Move admin files to */admin* folder
     70* Add a default value for media query at plugin activation:
     71    * add print medium placed at the top right of pages.
     72    * Set option autoload to true (decrease load time) for few options.
     73
    6274= 1.1 =
    6375
    64 * Fix save settings
    65 * Add *requirement* section in readme.txt
    66 * add options:
     76* Fix save settings.
     77* Add *requirement* section in readme.txt.
     78* Add ``[user-id]``, ``[blog-id]``, ``[current-url]`` shortcodes so you can use in qrcodes url (ex: *http//domain.com/qrcodes?redirect=[current-url]*).
     79* add many options:
    6780    * Generate all qrcodes for all blog.
    6881    * Add and manage media query (active or not and qrcodes position).
     
    7992* Generate QRCode on the go during [`get_header` hook](http://codex.wordpress.org/Plugin_API/Action_Reference/get_header) for other page.
    8093* Create QRCode folder in `QRCODES_BASEDIR` if defined, or by default `/uploads/qrcodes`.
    81 * Delete all QRCodes on plugin deactivation ( [`register_deactivation_hook`](http://codex.wordpress.org/Function_Reference/register_deactivation_hook)).
     94* Delete all QRCodes on plugin deactivation ([`register_deactivation_hook`](http://codex.wordpress.org/Function_Reference/register_deactivation_hook)).
    8295* It is actually displayed on the top right corner, but more options will come.
     96
     97== Frequently Asked Questions ==
     98
     99No questions yet. It will coming soon.
     100Please tell me what's wrong with that plugin and what would you have in future version.
    83101
    84102== Upgrade Notice ==
     
    88106== Planned works ==
    89107
    90 * Embed [QRCode PHP library](http://sourceforge.net/projects/phpqrcode/ 'SourceForge Project').
     108* Embed [*QRCode PHP library*](http://sourceforge.net/projects/phpqrcode/ 'SourceForge Project').
    91109* Add options to set a cache timeout.
     110* Presentation of plugin through *wp-pointer*.
     111* Add *screen meta* to show constantes informations and library version.
     112* Fix *#wpadminbar* element over *.qrcodes* images.
     113* Set *FAQ* in *readme.txt*.
     114* Make an index of all qrcodes generated per site, so we can remove them when the site is deleted.
  • qrcodes/trunk/styles/admin.css

    r1102797 r1109898  
    1 .more-options {
     1.wrap .more-options {
    22    display: none;
    33    margin-left: 10px;
    44}
    55
    6 input:checked ~ .more-options {
     6.wrap input:checked ~ .more-options {
    77    display: block;
    88}
     9
     10.wrap .more-options-inverted {
     11    display: block;
     12    margin-left: 10px;
     13}
     14
     15.wrap input:checked ~ .more-options-inverted {
     16    display: none;
     17}
     18
     19.wrap .button.align-left {
     20    float: left;
     21    margin-right: 10px;
     22}
     23
     24.wrap .description {
     25    clear: both;
     26    margin-bottom: 15px;
     27    margin-left: 10px;
     28}
Note: See TracChangeset for help on using the changeset viewer.