Plugin Directory

Changeset 2724977


Ignore:
Timestamp:
05/17/2022 06:16:38 AM (4 years ago)
Author:
osmansorkar
Message:

Add shortcode support

Location:
ajax-archive-calendar
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • ajax-archive-calendar/trunk/ajax-archive-calendar.php

    r2094846 r2724977  
    55  Description:Ajax Archive Calendar is not only Calendar is also Archive. It is making by customize WordPress default calendar. I hope every body enjoy this plugin.
    66  Author: osmansorkar
    7   Version: 2.6.6
     7  Version: 2.6.7
    88  Author URI: http://fb.me/osmansorkar
    99 */
     
    5252    /********************** It will be sow home page**************** */
    5353    function widget($args, $instance) {
    54         global $wp_locale,$m, $monthnum, $year;
    5554        extract($args);
     55
     56        $defaults = array('title' => 'Archive Calendar','start_year' => date("Y"));
     57        $instance = wp_parse_args((array) $instance, $defaults);
     58
    5659        $title = apply_filters('widget_title', $instance['title']);
    5760        $bengali=$instance['bangla'];
     
    6568            echo $before_title . $title . $after_title;
    6669        /* end title */
    67         /* now start your degine */
     70
     71        /*
     72         * Calender Output
     73         * */
     74        echo  $this->calender_html($bengali,$instance["start_year"]);
    6875        ?>
    69         <div id="ajax_ac_widget">
    70             <div class="select_ca">
    71                 <select name="month" id="my_month" >
    72                     <?php
    73                     if ('bn' === substr(get_locale(), 0, 2) || $bengali==1) {
    74                         $month=array(
    75                             '01'=>'জানুয়ারী',
    76                             '02'=>'ফেব্রুয়ারী',
    77                             '03'=>'মার্চ',
    78                             '04'=>'এপ্রিল',
    79                             '05'=>'মে',
    80                             '06'=>'জুন',
    81                             '07'=>'জুলাই',
    82                             '08'=>'আগষ্ট',
    83                             '09'=>'সেপ্টেম্বর',
    84                             '10'=>'অক্টোবর',
    85                             '11'=>'নভেম্বর',
    86                             '12'=>'ডিসেম্বর'
    87                         );
    88                     } else{
    89                         $month = array();
    90                         for ($i = 1; $i <= 12; $i++) {
    91                             $monthnums = zeroise($i, 2);
    92                             $month[$monthnums] = $wp_locale->get_month($i);
    93                         }
    94                     }
    95 
    96 
    97                     if (empty($m) || $m == '') {
    98                         $nowm = $monthnum;
    99                         $nowyear = $year;
    100                         if($monthnum==0 || $monthnum==null){
    101                             $nowm=date('m');
    102                         }
    103                         if($nowyear==0 || $nowyear==null){
    104                             $nowyear=date('Y');
    105                         }
    106                     } else {
    107                         $mmm = str_split($m, 2);
    108                         $nowm = zeroise(intval(substr($m, 4, 2)), 2);
    109                         $nowyear = $mmm['0'] . $mmm['1'];
    110                     }
    111 
    112 
    113                     foreach ($month as $k => $mu) {
    114                         if ($k == $nowm) {
    115                             echo '<option value="' . $k . '" selected="selected" >' . $mu . '</option>';
    116                         } else {
    117                             echo '<option value="' . $k . '">' . $mu . '</option>';
    118                         }
    119                     }
    120                     ?>
    121                 </select>
    122 
    123                     <?php
    124                     $find = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0",);
    125                     $replace = array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০",);
    126 
    127 
    128                     $taryear = $nowyear + 5;
    129                     $yeararr = array();
    130                     $lassyear = $nowyear - 5;
    131                     for ($nowyearrr = $lassyear; $nowyearrr <= $taryear; $nowyearrr++) {
    132                         $yeararr[$nowyearrr] = $nowyearrr;
    133                     }
    134                
    135                     ?>
    136 
    137                 <select name="Year" id="my_year" >
    138                 <?php
    139                 foreach ($yeararr as $k => $years) {
    140                     if ('bn' === substr(get_locale(), 0, 2) || $bengali==1) {
    141                         $years = str_replace($find, $replace, $years);
    142                     }
    143                     if ($k == $nowyear) {
    144                         echo '<option value="' . $k . '" selected="selected" >' . $years . '</option>';
    145                     } else {
    146                         echo '<option value="' . $k . '">' . $years . '</option>';
    147                     }
    148                 }
    149                 ?>
    150 
    151                 </select>
    152             </div><!--select ca -->
    153             <div class="clear" style="clear:both; margin-bottom: 5px;"></div>
    154             <div class="ajax-calendar">
    155             <div class="aj-loging" style="left: 49%;position: absolute;top: 50%; display:none"><img src="<?php $url = plugin_dir_url(__FILE__);
    156             echo $url . 'loading.gif'; ?>" /></div>
    157            
    158             <div id="my_calender">
    159                 <?php ajax_ac_calendar('', $bengali); ?>
    160             </div><!--my_calender -->
    161             <div class="clear" style="clear:both; margin-bottom: 5px;"></div>
    162             </div>
    163             <script type="text/javascript" >
    164                 jQuery('#my_month,#my_year').change(function (e) {
    165                     <?php echo 'var bna='.$bengali.';' ?>
    166                     jQuery(".aj-loging").css("display", "block");
    167                     jQuery("#my_calender").css("opacity", "0.30");
    168                     var mon = jQuery('#my_month').val();
    169                     var year = jQuery('#my_year').val();
    170                     var to = year + mon;
    171                     var data = {
    172                         action: 'ajax_ac',
    173                         ma: to,
    174                         bn:bna,
    175 
    176                     };
    177 
    178                     // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
    179                     jQuery.get(ajaxurl, data, function (response) {
    180                         jQuery("#my_calender").html(response);
    181                         jQuery(".aj-loging").css("display", "none");
    182                         jQuery("#my_calender").css("opacity", "1.00");
    183                     });
    184 
    185                 });
    186            
    187             </script>
    188         </div>
    18976
    19077        <?php
    191         /* now end your degine
    192 
    193           /*arter_widget define by thimed */
     78
     79        /*arter_widget define by theme */
    19480        echo $after_widget;
    19581    }
     
    20187        $instance['title'] = strip_tags($new_instance['title']);
    20288        $instance['bangla'] = strip_tags($new_instance['bangla']);
     89        $instance['start_year'] = strip_tags($new_instance['start_year']);
    20390        return $instance;
    20491    }
     
    20794
    20895    function form($instance) {
    209         $defaults = array('title' => 'Archive Calendar');
     96        $defaults = array('title' => 'Archive Calendar','start_year' => date("Y"));
    21097        $instance = wp_parse_args((array) $instance, $defaults);
    21198        ?>
     
    224111        </p>
    225112
     113        <p>
     114            <label for="<?php echo $this->get_field_id('start_year'); ?>"><?php _e('Start Year:', 'ajax_archive_calendar'); ?></label>
     115            <input type="number"  id="<?php echo $this->get_field_id('start_year'); ?>" name="<?php echo $this->get_field_name('start_year'); ?>" value="<?php echo $instance['start_year']; ?>" style="width:100%;" />
     116
     117        </p>
     118
     119        <p>
     120            <label for="<?php echo $this->get_field_id('shortcode'); ?>"><?php _e('shortcode', 'ajax_archive_calendar'); ?></label>
     121            <input   id="<?php echo $this->get_field_id('shortcode'); ?>"  value='[ajax_archive_calendar  bengali="<?php echo $instance['bangla']; ?>" start="<?php echo $instance['start_year']; ?>"]' style="width:100%;" />
     122
     123        </p>
     124
    226125
    227126        <?php
    228127    }
    229 
    230 // end from function
     128    // end from function
     129
     130    function calender_html($bengali,$start_year){
     131        global $wp_locale,$m, $monthnum, $year;
     132
     133        $calender_html = '';
     134        $calender_html.= '<div id="ajax_ac_widget">';
     135            $calender_html.= '<div class="select_ca">';
     136                $calender_html.= '<select name="month" id="my_month" >';
     137                    if ('bn' === substr(get_locale(), 0, 2) || $bengali==1) {
     138                        $month=array(
     139                            '01'=>'জানুয়ারী',
     140                            '02'=>'ফেব্রুয়ারী',
     141                            '03'=>'মার্চ',
     142                            '04'=>'এপ্রিল',
     143                            '05'=>'মে',
     144                            '06'=>'জুন',
     145                            '07'=>'জুলাই',
     146                            '08'=>'আগষ্ট',
     147                            '09'=>'সেপ্টেম্বর',
     148                            '10'=>'অক্টোবর',
     149                            '11'=>'নভেম্বর',
     150                            '12'=>'ডিসেম্বর'
     151                        );
     152                    } else{
     153                        $month = array();
     154                        for ($i = 1; $i <= 12; $i++) {
     155                            $monthnums = zeroise($i, 2);
     156                            $month[$monthnums] = $wp_locale->get_month($i);
     157                        }
     158                    }
     159
     160
     161                    if (empty($m) || $m == '') {
     162                        $nowm = $monthnum;
     163                        $nowyear = $year;
     164                        if($monthnum==0 || $monthnum==null){
     165                            $nowm=date('m');
     166                        }
     167                        if($nowyear==0 || $nowyear==null){
     168                            $nowyear=date('Y');
     169                        }
     170                    } else {
     171                        $mmm = str_split($m, 2);
     172                        $nowm = zeroise(intval(substr($m, 4, 2)), 2);
     173                        $nowyear = $mmm['0'] . $mmm['1'];
     174                    }
     175
     176
     177                    foreach ($month as $k => $mu) {
     178                        if ($k == $nowm) {
     179                            $calender_html.= '<option value="' . $k . '" selected="selected" >' . $mu . '</option>';
     180                        } else {
     181                            $calender_html.= '<option value="' . $k . '">' . $mu . '</option>';
     182                        }
     183                    }
     184
     185                $calender_html.= '</select>';
     186
     187                $find = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0",);
     188                $replace = array("১", "২", "৩", "৪", "৫", "৬", "৭", "৮", "৯", "০",);
     189
     190
     191                $taryear = date("Y");
     192                $yeararr = array();
     193                $lassyear = $start_year;
     194                for ($nowyearrr = $lassyear; $nowyearrr <= $taryear; $nowyearrr++) {
     195                    $yeararr[$nowyearrr] = $nowyearrr;
     196                }
     197
     198
     199
     200                $calender_html.= '<select name="Year" id="my_year" >';
     201
     202                    foreach ($yeararr as $k => $years) {
     203                        if ('bn' === substr(get_locale(), 0, 2) || $bengali==1) {
     204                            $years = str_replace($find, $replace, $years);
     205                        }
     206                        if ($k == $nowyear) {
     207                            $calender_html.= '<option value="' . $k . '" selected="selected" >' . $years . '</option>';
     208                        } else {
     209                            $calender_html.= '<option value="' . $k . '">' . $years . '</option>';
     210                        }
     211                    }
     212
     213                $calender_html.= '</select>';
     214            $calender_html.= '</div><!--select ca -->';
     215            $calender_html.= '<div class="clear" style="clear:both; margin-bottom: 5px;"></div>';
     216            $calender_html.= '<div class="ajax-calendar">';
     217        $calender_html.='<div class="aj-loging" style="left: 49%;position: absolute;top: 50%; display:none">';
     218        $url = plugin_dir_url( __FILE__ );
     219        $calender_html.='<img src="';
     220        $calender_html.=$url . 'loading.gif';
     221        $calender_html.='" /></div>';
     222
     223                $calender_html.= '<div id="my_calender">';
     224                     $calender_html.= ajax_ac_calendar('', $bengali,false);
     225                $calender_html.= '</div><!--my_calender -->';
     226                $calender_html.= '<div class="clear" style="clear:both; margin-bottom: 5px;"></div>';
     227            $calender_html.= '</div>';
     228
     229        $calender_html.='</div>';
     230
     231
     232        $calender_html.='<script type="text/javascript" >
     233                     jQuery(document).on("change","#my_month,#my_year", function (e) {
     234                         jQuery(".aj-loging").css("display", "block");
     235                         jQuery("#my_calender").css("opacity", "0.30");
     236                         
     237                         var bna='.$bengali.'
     238                         var mon = jQuery("#my_month").val();
     239                         var year = jQuery("#my_year").val();
     240                         var to = year + mon;
     241                         var data = {
     242                         action: "ajax_ac",
     243                         ma: to,
     244                         bn:bna,
     245
     246                         };
     247
     248                         // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
     249                         jQuery.get(ajaxurl, data, function (response) {
     250                         jQuery("#my_calender").html(response);
     251                         jQuery(".aj-loging").css("display", "none");
     252                         jQuery("#my_calender").css("opacity", "1.00");
     253                         });
     254
     255                         });
     256
     257                         </script>';
     258
     259        return $calender_html;
     260
     261    }
    231262}
    232263
     
    335366    $dayswithposts = get_posts(array(
    336367        'suppress_filters' => false,
     368        //'post_type' => 'post',
    337369        'post_type' => 'post',
    338370        'post_status' => 'publish',
     
    500532function ajax_ac_head() {
    501533    ?>
     534
    502535    <script type="text/javascript">
    503536        var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
     
    573606add_filter('day_link', 'ajax_ac_permalinks');
    574607
     608
     609/**
     610 * Create WP short code for Ajax Archive Calendar
     611 *
     612 * @param array $atts
     613 * @return void
     614 */
     615
     616//[ajax_archive_calendar]
     617function ajax_archive_calendar( $atts ){
     618
     619    if(key_exists("bengali",$atts)){
     620        $bengali = $atts["bengali"];
     621    } else {
     622        $bengali = 0;
     623    }
     624
     625    if(key_exists("start",$atts)){
     626        $start = $atts["start"];
     627    } else {
     628        $start = 0;
     629    }
     630
     631    $ajax_ac_widget = new ajax_ac_widget();
     632    return $ajax_ac_widget->calender_html($bengali,$start);
     633}
     634
     635add_shortcode( 'ajax_archive_calendar', 'ajax_archive_calendar' );
  • ajax-archive-calendar/trunk/readme.txt

    r2094846 r2724977  
    44Tags: Ajax, Ajax Archive,Ajax Calendar,jquery Calendar, Calendar, style,costomazie Calendar,Widget,Calendar Widget
    55Requires at least: 3.0
    6 Tested up to: 5.2.1
    7 Stable tag: 2.6.6
     6Tested up to: 5.9.3
     7Stable tag: 2.6.7
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    3636Ans: Yeas But you need manually edite.
    3737
     38
     39=  Is this plugin support shortcode? =
     40
     41Ans: Yeas .
     42
    3843== Screenshots ==
    39441. **Example,** - This widget look lick this.
     
    4146
    4247== Changelog ==
     48= 2.6.7 =
     49* Add Short code.
    4350= 2.6.3 =
    4451* Bug fixed
     
    6067== Upgrade Notice ==
    6168= 2.6 =
     69* Add shortcode
    6270* Speed Up
    6371* First Load Direct
Note: See TracChangeset for help on using the changeset viewer.