Plugin Directory

Changeset 498362


Ignore:
Timestamp:
02/01/2012 06:30:25 AM (14 years ago)
Author:
iMuslim
Message:

Version 1.1.1 - added section to settings page to fix bug in v 3.3.1 of Wordpress

Location:
islamic-graphics/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • islamic-graphics/trunk/islamic_graphics.php

    r498323 r498362  
    55Plugin URI: http://plugins.muslimmatters.org
    66Description: Shortcodes for the insertion of graphics representing the common Islamic phrases: SAW, RA, SWT and AS, into Wordpress posts and pages.
    7 Version: 1.1.0
     7Version: 1.1.1
    88Author: Mehzabeen Ibrahim
    99Author URI: http://imuslim.tv
     
    4242// Register settings
    4343function islamic_graphics_init(){
     44    add_settings_section('islamic_graphics_main', 'Main Settings', 'islamic_graphics_section_text', 'islamic-graphics');
     45    add_settings_field('islamic_graphics_default_height', 'Default height (pixels)', 'add_field_default_height', 'islamic-graphics', 'islamic_graphics_main');
     46    add_settings_field('islamic_graphics_default_colour', 'Default colour', 'add_field_default_colour', 'islamic-graphics', 'islamic_graphics_main');
     47    add_settings_field('islamic_graphics_display_type', 'Display type', 'add_field_display_type', 'islamic-graphics', 'islamic_graphics_main');
     48   
    4449    register_setting( 'islamic-graphics-option-group', 'islamic_graphics_default_height', 'validate_default_height' );
    4550    register_setting( 'islamic-graphics-option-group', 'islamic_graphics_display_type' );
    4651    register_setting( 'islamic-graphics-option-group', 'islamic_graphics_default_colour' );
    4752 }
     53 
     54function islamic_graphics_section_text(){
     55    echo '<p>Use the following options to alter the display of Islamic Graphics in your posts and pages.</p>';
     56}
     57
     58function add_field_default_height(){   
     59    echo '<input type="text" name="islamic_graphics_default_height" value="';
     60    echo get_option('islamic_graphics_default_height', 20);
     61    echo '" />';           
     62}
     63
     64function add_field_default_colour(){   
     65    echo '<select name="islamic_graphics_default_colour" id="islamic_graphics_default_colour">';
     66   
     67    $display_type_options = array(
     68            "black" => "Black",
     69            "white" => "White");
     70
     71    $stored_type = get_option('islamic_graphics_default_colour', 'black');
     72
     73    foreach ($display_type_options as $key => $row) {
     74        echo '<option value="' . $key . '"';
     75        if ($stored_type == $key) { echo 'selected="selected"'; }
     76        echo '>'. $row .'</option>';
     77    }
     78   
     79    echo '</select>';       
     80}
     81
     82function add_field_display_type(){   
     83    echo '<select name="islamic_graphics_display_type" id="islamic_graphics_display_type">';
     84   
     85        $display_type_options = array(
     86                "images" => "Images only",
     87                "images_trans" => "Images (with translation)",
     88                "text_rom_trans" => "Romanized text (with translation)",
     89                "text_rom" => "Romanized text only",
     90                "text_trans" => "Translation only");
     91
     92        $stored_type = get_option('islamic_graphics_display_type', 'images');
     93
     94        foreach ($display_type_options as $key => $row) {
     95            echo '<option value="' . $key . '"';
     96            if ($stored_type == $key) { echo 'selected="selected"'; }
     97            echo '>'. $row .'</option>';
     98        }
     99   
     100    echo '</select>';       
     101}
     102
     103// Validate height input
     104function validate_default_height($input) {
     105    $newinput = trim($input);
     106   
     107    if (!is_numeric($newinput)){
     108        $newinput = 20; // if not numeric, then use 20 as default value
     109    }
     110    return $newinput;
     111}
    48112
    49113// HTML for options page
     
    54118?>
    55119    <div class="wrap">
    56         <h2>Islamic Graphics - Options</h2>
    57         <p>Use the following options to alter the display of Islamic Graphics in your posts and pages.</p>
     120        <h2>Islamic Graphics - Options Page</h2>
    58121        <form method="post" action="options.php">
    59122        <?php settings_fields( 'islamic-graphics-option-group' ); ?>
    60         <?php do_settings_fields( 'islamic-graphics-option-group' ); ?>
    61         <!-- Input for default img height -->
    62         <p>Default height of embedded images in pixels (value > 40 will be accepted, but not recommended!)
    63         <br/><input type="text" name="islamic_graphics_default_height" value="<?php echo get_option('islamic_graphics_default_height', 20); ?>" />   
    64         </p>
    65         <!-- Options for Islamic Graphics colour -->
    66         <p>Default colour of images?
    67         <br/><select name="islamic_graphics_default_colour" id="islamic_graphics_default_colour">
    68                 <!-- Select the option that is stored in wp_options; else select black -->
    69                 <?php
    70                     $display_type_options = array(
    71                             "black" => "Black",
    72                             "white" => "White");
    73                    
    74                     $stored_type = get_option('islamic_graphics_default_colour', 'black');
    75                    
    76                     foreach ($display_type_options as $key => $row) {
    77                         echo '<option value="' . $key . '"';
    78                         if ($stored_type == $key) { echo 'selected="selected"'; }
    79                         echo '>'. $row .'</option>';
    80                     }               
    81                 ?>
    82            </select>
    83         </p>       
    84         <!-- Options for Islamic Graphics type -->
    85         <p>How do you wish to display the Islamic Graphics?
    86         <br/><select name="islamic_graphics_display_type" id="islamic_graphics_display_type">
    87                 <!-- Select the option that is stored in wp_options; else select images -->
    88                 <?php
    89                     $display_type_options = array(
    90                             "images" => "Images only",
    91                             "images_trans" => "Images (with translation)",
    92                             "text_rom_trans" => "Romanized text (with translation)",
    93                             "text_rom" => "Romanized text only",
    94                             "text_trans" => "Translation only");
    95                    
    96                     $stored_type = get_option('islamic_graphics_display_type', 'images');
    97                    
    98                     foreach ($display_type_options as $key => $row) {
    99                         echo '<option value="' . $key . '"';
    100                         if ($stored_type == $key) { echo 'selected="selected"'; }
    101                         echo '>'. $row .'</option>';
    102                     }               
    103                 ?>
    104            </select>
    105         </p>
     123        <?php do_settings_sections('islamic-graphics'); ?>
    106124        <!-- Submit Button -->
    107         <p class="submit">
    108         <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
    109         </p>
     125        <p class="submit"> <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
    110126        </form>
    111127    </div>
    112128       
    113129<?php }
    114 
    115 
    116 // Validate height input
    117 function validate_default_height($input) {
    118     $newinput = trim($input);
    119    
    120     if (!is_numeric($newinput)){
    121         $newinput = 20; // if not numeric, then use 20 as default value
    122     }
    123     return $newinput;
    124 }
    125130
    126131
  • islamic-graphics/trunk/readme.txt

    r498328 r498362  
    44Tags: islam, islamic, muslim, arabic, prophet, muhammad, sallalahu 'alayhi wa salam, radiallahu anhu, radiallahu anhum, alayhis salam, subhanahu wa ta ala, rahimaha Allah, rahimahu Allah, rahimahum Allah, SAW, RA, AS, SWT, shortcode, post, page, plugin, images, image
    55Requires at least: 2.7.0
    6 Tested up to: 3.2.1
    7 Stable tag: 1.1.0
     6Tested up to: 3.3.1
     7Stable tag: 1.1.1
    88
    99Shortcode for the insertion of graphics representing the common Islamic phrases: SAW, RA, SWT and AS, into Wordpress posts and pages.
     
    112112== Changelog ==
    113113
     114= 1.1.1 =
     115Added section to settings page to fix error seen in 3.3.1 version of Wordpress.
     116
    114117= 1.1.0 =
    115118Major changes to code:
     
    145148== Upgrade Notice ==
    146149
     150= 1.1.1 =
     151Major improvements to the plugin! Added an options page for setting of default display options. English translation can now be inserted with images. Consult FAQ for more details. (Settings page bug fix included).
     152
    147153= 1.1.0 =
    148154Major improvements to the plugin! Added an options page for setting of default display options. English translation can now be inserted with images. Consult FAQ for more details.
Note: See TracChangeset for help on using the changeset viewer.