Plugin Directory

Changeset 2210250


Ignore:
Timestamp:
12/11/2019 05:02:13 PM (6 years ago)
Author:
riangraphics
Message:

Committing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • book-now/trunk/book-now.php

    r1867949 r2210250  
    22/**
    33 * @package Book_Now
    4  * @version 1.4.5
     4 * @version 1.5
    55 */
    66/*
     
    99Description: This plugin adds a fixed call to action button to your site, with text and link to anywhere you want.
    1010Author: RianGraphics
    11 Version: 1.4.5
     11Version: 1.5
    1212Author URI: https://www.riangraphics.com/book-now/
    1313*/
     
    3737        register_setting( 'book-now-settings-group', 'rg_btn_pad' );
    3838        register_setting( 'book-now-settings-group', 'rg_btn_pad_m' );
     39        register_setting( 'book-now-settings-group', 'rg_font_family' );
    3940}
    4041
     
    6566    <p>
    6667        <label for="my_meta_box_enable">Enable/Disable for this page/post</label>
    67         <input name="my_meta_box_enable" id="my_meta_box_enable" type="checkbox" value="1" <?php checked( '1', $text ); ?> />
     68        <input name="my_meta_box_enable" id="my_meta_box_enable" type="checkbox" value="1" <?php checked( '1', $enable ); ?> />
    6869    </p>
    6970    <p>
     
    7778<p>
    7879    <label for="my_meta_box_target">Target</label>
    79     <select name="my_meta_box_target" id="my_meta_box_target"> 
     80    <select name="my_meta_box_target" id="my_meta_box_target">
    8081        <option disabled selected value> -- select an option -- </option>
    8182        <option <?php if($target == '_blank') { echo 'selected';} ?> value="_blank">New window (_blank)</option>
    82         <option <?php if($target == '_self') { echo 'selected';} ?> value="_self">Same window (_self)</option> 
     83        <option <?php if($target == '_self') { echo 'selected';} ?> value="_self">Same window (_self)</option>
    8384        <option <?php if($target == '_parent') { echo 'selected';} ?> value="_parent">Parent frame (_parent)</option>
    8485        <option <?php if($target == '_top') { echo 'selected';} ?> value="_top">Opens the linked document in the full body of the window
     
    113114        <label for="my_meta_box_width">Custom button width ex(200px)</label>
    114115        <input type="text" name="my_meta_box_width" id="my_meta_box_width" value="<?php echo $width; ?>" />
    115     </p> 
    116     <?php   
     116    </p>
     117    <?php
    117118}
    118119add_action( 'save_post', 'rg_meta_box_save' );
     
    125126    if( !current_user_can( 'edit_post', $post_id ) ) return;
    126127    // now we can actually save the data
    127     $allowed = array( 
     128    $allowed = array(
    128129        'a' => array( // on allow a tags
    129130            'href' => array() // and those anchords can only have href attribute
     
    165166    <?php settings_fields( 'book-now-settings-group' ); ?>
    166167    <?php do_settings_sections( 'book-now-settings-group' ); ?>
     168    <?php //echo get_option( 'rg_book_enable' ); ?>
    167169    <table class="form-table">
    168170        <tr valign="top">
     
    175177        <td><input type="text" name="rg_book_text" value="<?php echo esc_attr( get_option('rg_book_text', 'Book Now') ); ?>" /></td>
    176178        </tr>
    177          
     179
    178180        <tr valign="top">
    179181        <th scope="row">Full url</th>
    180182        <td><input type="text" name="rg_book_url" value="<?php echo esc_attr( get_option('rg_book_url', 'http://example.com') ); ?>" /></td>
    181183        </tr>
    182        
     184
    183185        <tr valign="top">
    184186        <th scope="row">Link Target</th>
    185187        <td>
    186 <select name="rg_target"> 
     188<select name="rg_target">
    187189         <option <?php if(get_option('rg_target') == '_blank') { echo 'selected';} ?> value="_blank">New window (_blank)</option>
    188         <option <?php if(get_option('rg_target') == '_self') { echo 'selected';} ?> value="_self">Same window (_self)</option> 
     190        <option <?php if(get_option('rg_target') == '_self') { echo 'selected';} ?> value="_self">Same window (_self)</option>
    189191        <option <?php if(get_option('rg_target') == '_parent') { echo 'selected';} ?> value="_parent">Parent frame (_parent)</option>
    190192        <option <?php if(get_option('rg_target') == '_top') { echo 'selected';} ?> value="_top">Opens the linked document in the full body of the window
     
    193195</td>
    194196        </tr>
    195        
     197
    196198        <tr valign="top">
    197199        <th scope="row">Left or Right</th>
    198200        <td>
    199 <select name="rg_left_right"> 
     201<select name="rg_left_right">
    200202         <option <?php if(get_option('rg_left_right') == 'left') { echo 'selected';} ?> value="left">Left</option>
    201         <option <?php if(get_option('rg_left_right') == 'right') { echo 'selected';} ?> value="right">Right</option> 
     203        <option <?php if(get_option('rg_left_right') == 'right') { echo 'selected';} ?> value="right">Right</option>
    202204       </select>
    203205</td>
     
    214216        <th scope="row">Text Color ex(#FFFFFF)</th>
    215217        <td><input type="text" name="rg_text_color" value="<?php echo esc_attr( get_option('rg_text_color', '#FFFFFF') ); ?>" /></td>
     218        </tr>
     219                <tr valign="top">
     220        <th scope="row">Font Family</th>
     221        <td><input type="text" name="rg_font_family" value="<?php echo esc_attr( get_option('rg_font_family', 'Arial') ); ?>" /></td>
    216222        </tr>
    217223        <tr valign="top">
     
    240246        </tr>
    241247    </table>
    242    
     248
    243249    <?php submit_button(); ?>
    244250
    245251</form>
    246252</div>
    247 <?php } 
     253<?php }
    248254
    249255
    250256function book_now() {
    251    
     257
    252258    if (get_post_meta(get_the_ID(), 'my_meta_box_text', true)) {
    253259        $mytext = __(get_post_meta(get_the_ID(), 'my_meta_box_text', true));
     
    255261        $mytext = __(get_option('rg_book_text'));
    256262    }
    257    
     263
    258264    if (get_post_meta(get_the_ID(), 'my_meta_box_url', true)) {
    259265        $myurl = __(get_post_meta(get_the_ID(), 'my_meta_box_url', true));
     
    261267        $myurl = __(get_option('rg_book_url'));
    262268    }
    263    
     269
    264270    if (get_post_meta(get_the_ID(), 'my_meta_box_enable', true)) {
    265271        $mytrue = __(get_post_meta(get_the_ID(), 'my_meta_box_enable', true));
     
    267273        $mytrue = get_option( 'rg_book_enable' );
    268274    }
    269    
     275
    270276    if (get_post_meta(get_the_ID(), 'my_meta_box_target', true)) {
    271277        $target = __(get_post_meta(get_the_ID(), 'my_meta_box_target', true));
     
    273279        $target = get_option( 'rg_target' );
    274280    }
    275    
     281
    276282    $pageid = get_option( 'rg_page_id' );
    277    
     283if(!empty($pageid)) {
    278284    $truepgid = explode(',',$pageid);
    279    
    280    
    281    
    282     if(!is_admin() && $mytrue == 1 && !is_page($truepgid) && !is_single($truepgid)) {
    283        
     285} else {
     286    $truepgid = "";
     287}
     288
     289    if(!is_admin() && $mytrue === '1') {
     290if(!empty($truepgid)) {
     291    if(!is_page($truepgid) && !is_single($truepgid)) {
    284292    echo "
    285293              <div id='rg-book'>
     
    287295              </div>
    288296               ";
    289   }
     297    }
     298  } else {
     299    echo "
     300              <div id='rg-book'>
     301              <a href='$myurl' target='$target'>$mytext</a>
     302              </div>
     303               ";
     304}
     305    }
    290306}
    291307
     
    295311// We need some CSS to position the paragraph
    296312function book_css() {
    297    
     313
    298314       if (get_post_meta(get_the_ID(), 'my_meta_box_enable', true)) {
    299315        $mytrue = __(get_post_meta(get_the_ID(), 'my_meta_box_enable', true));
     
    301317        $mytrue = get_option( 'rg_book_enable' );
    302318    }
    303    
     319
    304320    if (get_post_meta(get_the_ID(), 'my_meta_box_bg', true)) {
    305321        $bgcolor = __(get_post_meta(get_the_ID(), 'my_meta_box_bg', true));
     
    307323        $bgcolor = get_option('rg_book_color');
    308324    }
    309    
     325
    310326    if (get_post_meta(get_the_ID(), 'my_meta_box_txtcolor', true)) {
    311327        $txtcolor = __(get_post_meta(get_the_ID(), 'my_meta_box_txtcolor', true));
     
    313329        $txtcolor = get_option('rg_text_color');
    314330    }
    315    
     331
    316332    if (get_post_meta(get_the_ID(), 'my_meta_box_font_size', true)) {
    317333        $fontsize = __(get_post_meta(get_the_ID(), 'my_meta_box_font_size', true));
     
    319335        $fontsize = get_option('rg_font_size');
    320336    }
    321    
     337
    322338    if (get_post_meta(get_the_ID(), 'my_meta_box_font_size_m', true)) {
    323339        $fontsizem = __(get_post_meta(get_the_ID(), 'my_meta_box_font_size_m', true));
     
    325341        $fontsizem = get_option('rg_font_size_m');
    326342    }
    327    
     343
    328344    if (get_post_meta(get_the_ID(), 'my_meta_box_btn_pad', true)) {
    329345        $btnpad = __(get_post_meta(get_the_ID(), 'my_meta_box_btn_pad', true));
     
    331347        $btnpad = get_option('rg_btn_pad');
    332348    }
    333    
     349
    334350    if (get_post_meta(get_the_ID(), 'my_meta_box_btn_pad_m', true)) {
    335351        $btnpadm = __(get_post_meta(get_the_ID(), 'my_meta_box_btn_pad_m', true));
     
    337353        $btnpadm = get_option('rg_btn_pad_m');
    338354    }
    339    
     355
    340356    if (get_post_meta(get_the_ID(), 'my_meta_box_width', true)) {
    341357        $customwidth = __(get_post_meta(get_the_ID(), 'my_meta_box_width', true));
     
    343359        $customwidth = get_option('rg_width');
    344360    }
    345    
     361
    346362        $mymobile = get_option( 'rg_book_bottom' );
    347    
     363                $fontfamily = get_option( 'rg_font_family' );
     364
    348365        $lor = get_option('rg_left_right');
    349    
     366
    350367        $numberofchars = strlen(get_option('rg_book_text'));
    351    
     368
    352369        $totalW = 25 * $numberofchars;
    353    
     370
    354371        $distance = 10 * $numberofchars;
    355    
     372
    356373        $deg = '';
    357    
     374
    358375        if($lor == 'right') {
    359376         $deg = '-90deg';
     
    386403          text-transform:uppercase;
    387404          font-size:'.$fontsize.';
    388           font-weight:700; 
     405          font-weight:700;
     406                    font-family:'.$fontfamily.';
    389407        }
    390408@media screen and (max-width:767px) {
     
    410428  font-size:'.$fontsizem.';
    411429  font-weight:700;
    412  
     430
    413431}
    414432}
Note: See TracChangeset for help on using the changeset viewer.