Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an example of putting the code into a class format which the direction I would go FYI, it may be useful to learn a bit more of the OOP practices for PHP (<a href="http://php.net/manual/en/language.oop5.php" rel="nofollow">http://php.net/manual/en/language.oop5.php</a>):</p> <pre><code>#1) Get the data you wish to pass into your function. $data = "TEST"; get_partners($data); #2) Call your function. function get_partners($atts) { //Extract using ($att) passed in from your call. //The shortcode_atts function should be accessible by the file containing this function. extract(shortcode_atts(array( 'ids' =&gt; null, 'extra_options' =&gt; 'something' //in wordpress I can read this value using local $extra_options ), $atts)); //Create a new class element that will build your data for your and allow you to pass in your variable on the fly. $p = new partners(); $p-&gt;extra_options= $atts; //Pass the variable here. $p-&gt;print_partners_scripts(); } #3) Define Class here. class partners { var $extra_options; public function print_partners_scripts() { $output = '&lt;script type="text/javascript"&gt;' . "\n"; $output .= 'jQuery(document).ready( function() {'. "\n"; $output .= ' $(".partners-slider").bxSlider({ slideWidth: 924, auto: 0, autoStart: 0, moveSlides: 1, minSlides: 3, maxSlides: 8, pager: false, controls: false, slideMargin: 5, ' . $this-&gt;extra_options . ' });' . "\n"; $output .= '});' . "\n"; $output .= '&lt;/script&gt;' . "\n"; $output .= $this-&gt;additional_data(); echo $output; } protected function additional_data() { add_action( 'wp_footer', 'print_partners_scripts' ); $ids; #Where is this defined? $ids = explode( ',', $ids ); $output = '&lt;div class="ps-wrap"&gt;&lt;div class="partners-slider"&gt;'; foreach($ids as $id) { $img_attr = wp_get_attachment_image_src( $id, 'full' ); $output .= '&lt;div class="pslide"&gt;&lt;img src="' . $img_attr[0] . '" /&gt;&lt;/div&gt;'; } $output .= '&lt;/div&gt;&lt;/div&gt;'; return $output; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload