[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_background() – Implement [bw_background] shortcode

You appear to be a bot. Output may be restricted

Description

Implement [bw_background] shortcode

Displays an attached media image as the background image for the article Rather than displaying the image as a link we generate the CSS instead. This is slightly easier than using custom CSS since the author doesn't have to find the full URL of the file manually.

Usage

$string = bw_background( $atts, $content, $tag );

Parameters

$atts
( array ) optional – shortcode parameters
$content
( string ) optional – not expected
$tag
( string ) optional – the shortcode tag

Returns

string generated HTML

TO DO

support multiple background images

TO DO

support identification of the actual image ID to display rather than the parent So [bw_background] will be the equivalent of the first CSS specification below [bw_css] article { background: url("http://rowlandscastlewebdesign.com/phphants/files/2013/11/How-is-it-done.jpg" ) no-repeat; background-size: 100% auto; color: white; } a.bw_tree { color: white; text-shadow: 0 1px 2px #000;} article h3 { padding-top: 16%; } [/bw_css]

Source

File name: oik-css/shortcodes/oik-background.php
Lines:

1 to 30 of 30
function bw_background( $atts=null, $content=null, $tag=null ) {
  $atts['post_type'] = bw_array_get( $atts, "post_type", "attachment" );
  $atts['post_mime_type'] = bw_array_get( $atts, 'post_mime_type', 'image' );
  $atts['id'] = bw_array_get_from( $atts, "id,0", null );
  if ( $atts['id'] === null ) {
    // Don't set the ID yet.. let get_thumbnail_src do it.
  }
  $atts['thumbnail'] = bw_array_get( $atts, "thumbnail", "full" );
  oik_require( "includes/bw_posts.php" );
  $thumbnail = bw_get_thumbnail_size( $atts );
  //$posts = bw_get_posts();
  //foreach ( $posts as $post ) {
  bw_trace2( $thumbnail, "thumbnail" );
    list( $thumbnail, $width, $height ) = bw_get_thumbnail_src( $atts['id'], $thumbnail, $atts );
    if ( $thumbnail ) {
      $selector = bw_array_get_from( $atts, "selector,1", null );
      if ( !$selector ) {
        $selector = bw_default_selector_for_theme();
      } 
      stag( "style", null, null, kv( "type", "text/css" ) . kv( "media", "screen,print")  );
      $css = "$selector { background: url( \"$thumbnail\" ) no-repeat;  background-size: 100% auto; background-origin: padding-box; }";
      e( $css );
      etag( "style" );
      
    } else {
      BW_::p( __( "No thumbnail", "oik-css" ) );
    }
  //}
  return( bw_ret() );
}
 

 View on GitHub View on Trac

Published: August 8, 2014 | Last updated: December 18, 2017

Information

Function name: bw_background
Plugin ref: oik-css
Version: 1.1.1
Sourcefile: shortcodes/oik-background.php
File ref: shortcodes/oik-background.php
API type: shortcode
Deprecated?: No
API Letters: B

Recent plugin updates

oik-weight-zone-shipping v0.2.2 

Upgrade to oik-weight-zone-shipping v0.2.2 for internationalized strings for migration. This version may also resolve a problem where a Warning message is produced while listing Shipping classes.

 ...
oik-weight-zone-shipping v0.2.1 

oik-weight-zone-shipping v0.2.1 fixes a problem with v0.2.0 on worpress.org, where two new files weren't included in the SVN repository.

 ...
oik-weightcountry-shipping v1.4.0 

oik-weightcountry-shipping v1.4.0 has been tested with WordPress 5.6 and WooCommerce 4.8.0. It is no longer supported. We suggest you switch to the oik weight zone shipping plugin.

 ...
oik-weight-zone-shipping v0.2.0 

oik-weight-zone-shipping v0.2.0 now supports migration from oik weight/country shipping. You can create Multi Rate shipping tables and methods restricting shipping classes.

 ...
oik-css v1.1.1 

oik-css v1.1.1 contains an update for improved compatibility with Gutenberg. It has been tested with WordPress 5.6 and WordPress Multi Site.

 ...

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: [email protected]

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-2021. All rights reserved.


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