Plugin Directory

Changeset 2218386


Ignore:
Timestamp:
12/26/2019 10:15:44 PM (6 years ago)
Author:
anranik
Message:

new update with settings

Location:
lorem-carousel/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • lorem-carousel/trunk/admin/class-lorem-carousel-admin.php

    r2216641 r2218386  
    55 *
    66 * @link       https://owlpixel.com
    7  * @since      1.0.0
     7 * @since      1.0.1
    88 *
    99 * @package    Lorem_Carousel
  • lorem-carousel/trunk/admin/class-lorem-carousel-metabox.php

    r2216641 r2218386  
    3939    $cmb = new_cmb2_box( array(
    4040        'id'            => 'test_metabox',
    41         'title'         => __( 'Test Metabox', 'cmb2' ),
     41        'title'         => __( 'Upload Carousel Images', 'cmb2' ),
    4242        'object_types'  => array( 'lorem_carousel' ), // Post type
    4343        'context'       => 'normal',
     
    6565    ) );
    6666
     67
     68    $cmb = new_cmb2_box( array(
     69        'id'            => 'lc_settings',
     70        'title'         => __( 'Settings for this carousel', 'cmb2' ),
     71        'object_types'  => array( 'lorem_carousel' ), // Post type
     72        'context'       => 'normal',
     73        'priority'      => 'high',
     74        'show_names'    => true, // Show field names on the left
     75        // 'cmb_styles' => false, // false to disable the CMB stylesheet
     76        // 'closed'     => true, // Keep the metabox closed by default
     77    ) );
     78
     79    $cmb->add_field( array(
     80        'name'             => 'Nav',
     81        'id'               => 'lc_loop',
     82        'type'             => 'radio_inline',
     83        'options'          => array(
     84            '1' => __( 'Loop Carousel', 'cmb2' ),
     85            '0'   => __( 'Do not loop carousel', 'cmb2' )
     86        ),
     87        'default' =>1
     88    ) );
     89    $cmb->add_field( array(
     90        'name'             => 'Nav',
     91        'id'               => 'lc_nav',
     92        'type'             => 'radio_inline',
     93        'options'          => array(
     94            '1' => __( 'Show Nav', 'cmb2' ),
     95            '0'   => __( 'Hide Nav', 'cmb2' )
     96        ),
     97        'default' =>1
     98    ) );
     99    $cmb->add_field( array(
     100        'name'             => 'Dots',
     101        'id'               => 'lc_dots',
     102        'type'             => 'radio_inline',
     103        'options'          => array(
     104            '1' => __( 'Show Dots', 'cmb2' ),
     105            '0'   => __( 'Hide Dots', 'cmb2' )
     106        ),
     107        'default' =>0,
     108        'desc' => 'Hide or show the dots on navigations. Default hidden',
     109    ) );
     110
     111
     112
    67113}
    68114
     
    71117// Add Shortcode
    72118function lorem_carousel_shortcode( $atts ) {
    73 
     119    global $nav,$dots,$loops,$lc_id;
    74120    // Attributes
    75121    $atts = shortcode_atts(
     
    82128
    83129
     130
    84131    //$text = get_post_meta( $atts->carousel_id, 'carousel_images_group', true );
    85132    // Get the list of files
    86133    $files = get_post_meta( $atts['carousel_id'], 'carousel_images_group', 1 );
    87 
     134    $nav = get_post_meta( $atts['carousel_id'], 'lc_nav', 1 );
     135    $dots = get_post_meta( $atts['carousel_id'], 'lc_dots', 1 );
     136    $loops = get_post_meta( $atts['carousel_id'], 'lc_loop', 1 );
     137    $lc_id = "lorem_carousel_".$atts['carousel_id'];
    88138
    89139    $data = "";
    90     $data.= '<div class="owl-carousel owl-theme">';
     140    $data.= '<div class="owl-carousel owl-theme" id="'.$lc_id.'">';
    91141    // Loop through them and output an image
    92142    foreach ( (array) $files as $attachment_id => $attachment_url ) {
     
    97147    $data.= '</div>';
    98148
     149    function lc_js_settings() {
     150        global  $nav, $dots, $loops, $lc_id;
     151            if ($nav == '1'){
     152                $showNav = 'true';
     153            }elseif($nav == '0'){
     154                $showNav = 'false';
     155            }
     156            if ($dots == '1'){
     157                $showDots = 'true';
     158            }elseif($dots == '0'){
     159                $showDots = 'false';
     160            }
     161            if($loops == '1'){
     162                $showLoop = 'true';
     163            }elseif($loops == '0'){
     164                $showLoop = 'false';
     165            }
     166        ?>
     167        <script type="text/javascript">
     168            jQuery(document).ready(function ($) {
     169                $("#<?php echo $lc_id; ?>").owlCarousel({
     170                    dots:<?php echo $showDots;  ?>,
     171                    loop:<?php echo $showLoop;  ?>,
     172                    margin:10,
     173                    nav:<?php echo $showNav;  ?>,
     174                    items:1,
     175                    autoHeight:true,
     176                    navText: ["<strong>◀ </strong> "," <strong>▶</strong> "]
     177                });
     178
     179
     180            })
     181
     182
     183        </script>
     184        <?php
     185    }
     186    add_action( 'wp_footer', 'lc_js_settings' );
     187
    99188
    100189       return $data;
  • lorem-carousel/trunk/includes/class-lorem-carousel.php

    r2216641 r2218386  
    2323 * version of the plugin.
    2424 *
    25  * @since      1.0.0
     25 * @since      1.0.1
    2626 * @package    Lorem_Carousel
    2727 * @subpackage Lorem_Carousel/includes
  • lorem-carousel/trunk/lorem-carousel.php

    r2216641 r2218386  
    1010 *
    1111 * @link              https://owlpixel.com
    12  * @since             1.0.0
     12 * @since             1.0.1
    1313 * @package           Lorem_Carousel
    1414 *
     
    1717 * Plugin URI:        https://wpditto.com
    1818 * Description:       This is a short description of what the plugin does. It's displayed in the WordPress admin area.
    19  * Version:           1.0.0
     19 * Version:           1.2.1
    2020 * Author:            Anowar Hossen
    2121 * Author URI:        https://owlpixel.com
  • lorem-carousel/trunk/public/class-lorem-carousel-public.php

    r2216641 r2218386  
    2626     * The ID of this plugin.
    2727     *
    28      * @since    1.0.0
     28     * @since    1.0.1
    2929     * @access   private
    3030     * @var      string    $plugin_name    The ID of this plugin.
     
    3535     * The version of this plugin.
    3636     *
    37      * @since    1.0.0
     37     * @since    1.0.1
    3838     * @access   private
    3939     * @var      string    $version    The current version of this plugin.
  • lorem-carousel/trunk/public/css/lorem-carousel-public.css

    r2216641 r2218386  
    2323    background-color: rgba(175, 175, 175, 0.77) !important;
    2424}
     25.owl-carousel .owl-dots{
     26    text-align: center;
     27}
     28.owl-carousel .owl-dots button.owl-dot {
     29    background-color: rgba(0, 0, 0, 0.43);
     30    width: 15px;
     31    height: 15px;
     32    margin-left: 4px;
     33    border: 2px solid rgba(0, 0, 0, 0);
     34}
     35
     36.owl-dots button.owl-dot.active {
     37    border: 2px solid #000000;
     38    background: #3c3c3c;
     39}
     40
  • lorem-carousel/trunk/public/js/lorem-carousel-public.js

    r2216641 r2218386  
    3232
    3333    $(document).ready(function () {
    34         $(".owl-carousel").owlCarousel({
    35             loop:true,
    36             margin:10,
    37             nav:true,
    38             items:1,
    39             autoHeight:true,
    40             navText: ["<strong>◀ </strong> "," <strong>▶</strong> "]
    41         });
    4234
    4335        $('.custom-control').on('click', 'button', function() {
  • lorem-carousel/trunk/readme.txt

    r2216641 r2218386  
    55Tested up to: 5.3
    66License: GPLv2 or later
     7Stable Tag: 1.2.1
    78License URI: http://www.gnu.org/licenses/gpl-2.0.html
    89
     
    163164= 1.0 =
    164165* First Release
     166
     167
     168== Changelog ==
     169
     170= 1.0.1 – Dec 26, 2019 =
     171* New* Custom settings has been added
Note: See TracChangeset for help on using the changeset viewer.