[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

bw_nivo_slider() – Implement the [nivo] shortcode to display a Nivo slider for attachments or other post types

Description

Implement the [nivo] shortcode to display a Nivo slider for attachments or other post types

The nivo slider consists of: jQuery, the Nivo slider jQuery and something to attach nivoSlider to the div containing the images Nivo is a bit pernickety about the html you use in order to create links with captions; finally dealt with in version 1.12 with the addition of bw_format_nivo_html_captions().

Usage

$string = bw_nivo_slider( $atts );

Parameters

$atts
( array ) optional – array of shortcode parameters

Returns

string the results of expanding the shortcode

Source

File name: oik-nivo-slider/nivo.php
Lines:
1 to 80 of 80
function bw_nivo_slider( $atts=null ) {
  $atts[ 'post_type'] = bw_array_get( $atts, "post_type", "attachment" );
  if ( $atts['post_type'] == "attachment" ) {
    $def_post_mime_type = "image"; 
  } else {
    $def_post_mime_type = null;  
  }  
  $atts[ 'post_mime_type'] = bw_array_get( $atts, "post_mime_type", $def_post_mime_type );
  $theme = bw_array_get( $atts, "theme", "default" );
  $class = bw_array_get( $atts, "class", null );
  $format = bw_array_get( $atts, "format", null );
  if ( $format ) {
    $atts['link'] = bw_array_get( $atts, "link", "n" );
  } else {
    $atts['link'] = bw_array_get( $atts, "link", "y" );
  }  
  $atts['caption'] = bw_array_get($atts, "caption", "y" );
  $ribbon = bw_validate_torf( bw_array_get(  $atts, "ribbon", "y" ));
  $atts['thumbnail'] = bw_array_get( $atts, "thumbnail", "full" );
  oik_require( "shortcodes/oik-attachments.php" );
  $pos = strpos( $atts['post_type'], ':' ); 
  if ( $pos != FALSE ) {  
    $posts = bw_get_special_post_type( $atts );
    $atts['post_type'] = substr( $atts['post_type'], 0, $pos ); 
  } else {
    $posts = bw_get_posts( $atts );
  }  
  if ( $posts ) {
    wp_enqueue_style( "nivo{$theme}", oik_url( "themes/{$theme}/{$theme}.css", "oik-nivo-slider" ) ); 
    $version = bw_nivo_version( $theme );
    wp_enqueue_style( "nivoCSS-$version", oik_url( "nivo-slider-$version.css", "oik-nivo-slider" ) ); 
    bw_nivo_enqueue_script( $version );
    $slider_id = bw_slider_id();
    //e( '<script type="text/javascript">jQuery(window).load(function() {  jQuery(\'#slider-'. $slider_id. '\').nivoSlider(); });</script>' );
    if ( $version == "271" ) {
      bw_jquery( "#slider-$slider_id", "nivoSlider271", bw_jkv( get_option( 'bw_nivo_slider' ) ), true );
    } else { 
      //bw_jquery( "#slider-$slider_id", "nivoSlider", bw_jkv( get_option( 'bw_nivo_slider' ) ), true );
      $options = get_option( 'bw_nivo_slider', [] );
      // 2013/01/29 - Implemented ability to override "controlNav" with a "nav" parameter.
      // and "pauseTime" with a "pause" parameter
      $options = bw_override_options( $options, "controlNav", $atts, "nav", "bw_validate_torf" ); 
      $options = bw_override_options( $options, "pauseTime", $atts, "pause" ); 
      $options = bw_override_options( $options, "manualAdvance", $atts, "manual", "bw_validate_torf" ); 
      $options = bw_override_options( $options, "controlNavThumbs", $atts, "thumbs", "bw_validate_torf" ); 
      $options = bw_override_options( $options, "effect", $atts, "effect", "bw_filter_transition_effect" ); 
      //bw_trace2( $options, "options" );   
      bw_jquery( "#slider-$slider_id", "nivoSlider", bw_jkv( $options ), true );
    }  
    if ( bw_validate_torf( $atts['link'] ) ) {
      $oik_nc_script = 'jquery.oik-nc-click.js';  
      wp_enqueue_script( 'oik-nc-click.js', oik_url( $oik_nc_script, "oik-nivo-slider" ), array( "nivo-slider-$version-js" ) ); 
      //e( '<script type="text/javascript">jQuery(window).load(function() {  jQuery(\'#slider-'. $slider_id. '\').oikNCClick(); });</script>' );
      bw_jquery( "#slider-$slider_id", "oikNCClick", null, true );
    }  
    sdiv( $class );
    sdiv( "slider-wrapper theme-{$theme}" );
    if ( $ribbon )
      sediv( "ribbon" );
    //sediv( "nivoSlider-dummy" );
    sdiv( "nivoSlider", "slider-$slider_id" );
    $atts['slider-id'] = "slider-$slider_id";
    $funcname = bw_funcname( "bw_format_nivo", $atts['post_type'] );
    $count = 0;
    foreach ( $posts as $post ) {
      $atts['count'] = $count++;
      $funcname( $post, $atts );
    }
    ediv();
    
    // Now, add the formatted content if requested
    if ( $format ) {
      bw_format_nivo_html_captions( $posts, $atts );
    }
    ediv();  
    ediv( $class ); 
    bw_clear_processed_posts();
  }  
  return bw_ret();
}
 
 View on GitHub View on Trac

Called by

1 to 1 of 1
  • Tests_nivo_php::test_issue_3_image_2_onwards_has_display_none() – Note: This doesn’t test the fix for specific problem reported But it’s a start.

Invoked by

    Calls

    1 to 15 of 15
    • bw_array_get() – Return the array[index] or array->index (for an object) or a default value if not set
    • bw_format_nivo_html_captions() – Format the HTML captions for the nivo slider
    • bw_funcname() – Return the function name of the function to invoke built from parms
    • bw_get_special_post_type() – Get special post types
    • bw_jkv() – Format an array of parms for jQuery
    • bw_nivo_enqueue_script() – Enqueue the debug script if needed otherwise enqueue the minified (packed) one
    • bw_nivo_version() – Return the required nivo slider jQuery version for the selected theme
    • bw_override_options() – Override the profile options with parameter settings with the same name
    • bw_ret() – Use bw_ret() to return the contents of $bwecho, leaving the global value as NULL
    • bw_slider_id() – Set the nivoSlider to start for objects with an id of slider-n
    • bw_validate_torf() – Validate as true or false
    • ediv() – End a div
    • oik_url() – Return the URL for a resource file
    • sdiv() – Start a div
    • sediv() – Create a dummy div which may be used for placing graphics using background images in CSS

    Call hooks

    Function name: bw_nivo_slider
    Plugin ref: oik-nivo-slider – jQuery nivo slider
    Version: 1.17.0
    Sourcefile: nivo.php
    File ref: nivo.php
    API type: shortcode
    Deprecated?: No
    API Letters: B,N,S

    Published: November 16, 2012 | Last updated: December 18, 2017

    Information

    Function name: bw_nivo_slider
    Plugin ref: oik-nivo-slider – jQuery nivo slider
    Version: 1.17.0
    Sourcefile: nivo.php
    File ref: nivo.php
    API type: shortcode
    Deprecated?: No
    API Letters: B,N,S

    Recent plugin updates

    oik-weight-zone-shipping v0.2.13 oik-weight-zone-shipping v0.2.13 has been tested with WooCommerce 10.1.2 and WordPress 6.8.2 ...
    SB Children Block v1.3.0 Upgrade to SB Children Block v1.3.0 for support for PHP 8.3 and PHP 8.4  ...
    oik v4.15.3 Update to oik v4.15.3 for a couple of security fixes. Tested with WordPress 6.8.2 ...
    oik-privacy-policy v1.4.9 Update to oik-privacy-policy v1.4.9 for a security fix. Tested with WordPress 6.8.2 and PHP 8.3 and PHP 8.4 ...
    oik-nivo-slider v1.17.0 oik-nivo-slider v1.17.0 introduces the Nivo slider block - oik-nivo-slider/nivo. ...

    Plugins

    • All Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins

    Themes

    • FREE themes
    • Bespoke themes
    • Premium themes

    Blocks

    • All Blocks
    • Block examples
    • About Blocks

    Shortcodes

    • All Shortcodes
    • Shortcode examples
    • About Shortcodes

    Reference

    • About APIs
    • All APIs
    • All Classes
    • All Files
    • All Hooks

    Support

    • Contact
    • Cookies policy
    • Get API key
    • Privacy
    • Request support
    • Sitemap
    • Stay informed
    • Terms and Conditions
    oik-plugins
    Email: oikplug@oik-plugins.com

    Weight shipping plugins

    Find out which cart weight shipping plugin you need for your WooCommerce site.
    Which cart weight based plugin do I need?

    Site:  www.oik-plugins.com
    © Copyright oik-plugins 2011-2025. All rights reserved.


    Website designed and developed by Herb Miller of Bobbing Wide
    Proudly powered by WordPress and oik-plugins

    WordPress version: 6.8.3

    Gutenberg version: 21.7.0

    PHP version: 8.2.29