Revisions
- June 1, 2013 @ 13:13:48 [Current Revision] by PeterLugg
- May 31, 2013 @ 02:05:20 [Autosave] by PeterLugg
- May 31, 2013 @ 02:00:04 by PeterLugg
- May 31, 2013 @ 01:57:47 by PeterLugg
Revision Differences
May 31, 2013 @ 01:57:47 | Current Revision | ||
---|---|---|---|
Content | |||
Added: Taken from here: <a href="https:/ /www.creare.co.uk/how-to- enqueue-scripts- stylesheets- to-wordpress- via-a-plugin" target="_blank" >https://www.creare.co.uk/ how-to-enqueue- scripts-stylesheets- to-wordpress- via-a-plugin</a> | |||
Added: For that extra level of safety and control, we recommend enqueuing via a separate dedicated plugin. In the video, I demonstrate how simple this is. Firstly, create a folder within WordPress’ plugin folder located at /wp-content/plugins/. Name your folder something useful like ‘theme-scripts’ and create a php file with the exact same name within (i.e theme-scripts.php). Then, simply add and customise the following code, as per our example. | |||
Added: [php]<code> <?php</code> | |||
Added: <div>< code>/*< /code></div> | |||
Added: <div>< code>Plugin Name: James' WP Enqueue Scripts &amp; Styles</code> </div> | |||
Added: <div>< code>Plugin URI: <a href="http: //www.creare.co.uk/" >http://www.creare.co.uk/ </a>< /code></div> | |||
Added: <div>< code>Description: This is my own custom plugin for enqueuing Scripts and Styles in my WordPress theme</code> </div> | |||
Added: <div>< code>Version: 1.0</code> </div> | |||
Added: <div>< code>Author: James Bavington< /code></div> | |||
Added: <div>< code>Author URI: <a href="http: //twitter.com/ jamesbavington" >http://twitter.com/ jamesbavington< /a></code> </div> | |||
Added: <div>< code>License: Help yourselves to the shelves</code> </div> | |||
Added: <div>< code>*/< /code></div> | |||
Added: <div></div> | |||
Added: <div>< code>function</code> <code>james_ adds_to_the_head() {</code> </div> | |||
Added: <div></div> | |||
Added: <div>< code> </code> <code>/ /wp_enqueue_ script('jquery') ;</code> </div> | |||
Added: <div></div> | |||
Added: <div>< code> </code> <code>wp_ register_script( </code> <code>'add-bx-js'< /code><code>, get_template_ directory_uri() . </code> <code>'/ jquery.bxslider/ jquery.bxslider.min.js'< /code><code>, </code> <code>array</code> <code>( </code> <code>'jquery'</ code><code>),< /code>< code>''< /code>< code>,true );</code> </div> | |||
Added: <div>< code> </code> <code>wp_ register_script( </code> <code>'add-bx-custom- js'</code> <code>, get_template_ directory_uri() . </code> <code>'/ jquery.bxslider/ custom.js'< /code><code>, </code> <code>''</code> <code>, null,</code> <code>''</code> <code>) ;</code> </div> | |||
Added: <div>< code> </code> <code>wp_ register_style( </code> <code>'add-bx-css'< /code><code>, get_template_ directory_uri() . </code> <code>'/ jquery.bxslider/ jquery.bxslider.css'</ code><code>,< /code>< code>''< /code>< code>,< /code>< code>''< /code><code>, </code> <code>'screen'</code> <code>) ;</code> </div> | |||
Added: <div></div> | |||
Added: <div>< code> </code> <code>wp_ enqueue_script( </code> <code>'add- bx-js'</code> <code>) ;</code> </div> | |||
Added: <div>< code> </code> <code>wp_ enqueue_script( </code> <code>'add-bx-custom- js'</code> <code>) ;</code> </div> | |||
Added: <div>< code> </code> <code>wp_ enqueue_style( </code> <code>'add- bx-css'</code> <code>) ;</code> </div> | |||
Added: <div></div> | |||
Added: <div>< code>}< /code></div> | |||
Added: <div></div> | |||
Added: <div>< code>add_action( </code> <code>'wp_ enqueue_scripts'< /code><code>, </code> <code>'james_adds_to_ the_head'</code> <code>) ;</code> </div> | |||
Deleted: | Added: [/php] |
Note: Spaces may be added to comparison text to allow better line wrapping.
No comments yet.