Title: Script Logic
Author: Tahir Yasin
Published: <strong>Òkúdù 16, 2014</strong>
Last modified: Agẹmọ  10, 2014

---

Ṣàwárí àwọn plugin

![](https://ps.w.org/script-logic/assets/banner-772x250.png?rev=932845)

Plugin yìí **kò tíì ṣe àyẹ̀wò pẹ̀lú àwọn ìtújáde mẹ́ta pàtàkì tó kẹ́yìn ti WordPress**.
Ó lè jẹ́ pé a kò tọ́jú tàbí ṣe àtìlẹ́yìn fún un mọ́, ó sì lè ní àwọn ọ̀ràn ìbámu
nígbà tí a bá lò ó pẹ̀lú àwọn ẹ̀yà WordPress tuntun.

![](https://ps.w.org/script-logic/assets/icon-128x128.png?rev=1159173)

# Script Logic

 Láti ọwọ́ [Tahir Yasin](https://profiles.wordpress.org/tahiryasin/)

[Ṣe ìgbàsílẹ̀](https://downloads.wordpress.org/plugin/script-logic.0.3.zip)

 * [Àwọn àlàyé](https://yor.wordpress.org/plugins/script-logic/#description)
 * [Àwọn àgbéyẹ̀wò](https://yor.wordpress.org/plugins/script-logic/#reviews)
 *  [Ìgbéwọlẹ̀](https://yor.wordpress.org/plugins/script-logic/#installation)
 * [Ìdàgbàsókè](https://yor.wordpress.org/plugins/script-logic/#developers)

 [Ìrànlọ́wọ́](https://wordpress.org/support/plugin/script-logic/)

## Àpèjúwe

This plugin lists all JavaScripts and Style sheets with a control field that lets
you control CSS & JavaScript files to include only on the pages where you actually
need them. The text field lets you use WPÌtumọ̀ Yorùbá: ’s [Conditional Tags](https://codex.wordpress.org/Conditional_Tags),
or any general PHP code.

NOTE: The script logic you introduce is evaluated directly. Anyone who has permission
to manage options will have the right to add any code, including malicious and possibly
destructive code. There is an optional filter ‘script_logic_eval_override’ which
you can use to bypass the EVAL with your own code if needed. (See [Other Notes](https://yor.wordpress.org/plugins/script-logic/other_notes/?output_format=md)).

### Writing Logic Code

The text in the ‘Logic’ field can be full PHP code and should return ‘true’ when
you need the script to load. If there is no ‘return’ in the text, an implicit ‘return’
is added to the start and a ‘;’ is added on the end. (This is just to make single
statements like is_home() more convenient.)

#### The Basics

Make good use of [WPÌtumọ̀ Yorùbá: ’s own conditional tags](https://codex.wordpress.org/Conditional_Tags).
You can vary and combine code using:

 * `!` (NOT) to **reverse** the logic, eg `!is_home()` is TRUE when this is NOT 
   the home page.
 * `||` (OR) to **combine** conditions. `X OR Y` is TRUE when either X is true or
   Y is true.
 * `&&` (AND) to make conditions **more specific**. `X AND Y` is TRUE when both 
   X is true and Y is true.

There are lots of great code examples on the WP forums, and on WP sites across the
net. But the WP Codex is also full of good examples to adapt, such as [Test if post is in a descendent category](https://codex.wordpress.org/Template_Tags/in_category#Testing_if_a_post_is_in_a_descendant_category).

#### Examples

 * `is_home()` Ìtumọ̀ Yorùbá: — just the main blog page
 * `!is_page('about')` Ìtumọ̀ Yorùbá: — everywhere EXCEPT this specific WP ‘page’
 * `!is_user_logged_in()` Ìtumọ̀ Yorùbá: — shown when a user is not logged in
 * `is_category(array(5,9,10,11))` Ìtumọ̀ Yorùbá: — category page of one of the 
   given category IDs
 * `is_single() && in_category('baked-goods')` Ìtumọ̀ Yorùbá: — single post thatÌtumọ̀
   Yorùbá: ’s in the category with this slug
 * `strpos($_SERVER['HTTP_REFERER'], "google.com")!=false` Ìtumọ̀ Yorùbá: — script
   to load when clicked through from a google search
 * `is_category() && in_array($cat, get_term_children( 5, 'category'))` Ìtumọ̀ Yorùbá:—
   category page thatÌtumọ̀ Yorùbá: ’s a descendent of category 5
 * `global $post; return (in_array(77,get_post_ancestors($post)));` Ìtumọ̀ Yorùbá:—
   WP page that is a child of page 77
 * `global $post; return (is_page('home') || ($post->post_parent=="13"));` Ìtumọ̀
   Yorùbá: — home page OR the page thatÌtumọ̀ Yorùbá: ’s a child of page 13

Note the extra ‘;’ on the end where there is an explicit ‘return’.

### The ‘script_logic_eval_override’ filter

Before the Script Logic code is evaluated for each script, the text of the Script
Logic code is passed through this filter. If the filter returns a BOOLEAN result,
this is used instead to determine if the script should load. Return TRUE to load.

## Àwọn àwòrán ìbòjú

[⌊screenshot-1.png⌉⌊screenshot-1.png⌉[

screenshot-1.png

[⌊screenshot-2.png⌉⌊screenshot-2.png⌉[

screenshot-2.png

## Ìgbéwọlẹ̀

 1. Upload plugin to the `/wp-content/plugins/` directory
 2. Activate the plugin through the ‘Plugins’ menu in WordPress
 3. Configure the plugin at `Settings -> Script Logic`
 4. ThatÌtumọ̀ Yorùbá: ’s it.

#### Configuration

On plugin configuration page you see all script and CSS files with a logic field.
Lets suppose you are using Contact Form 7 plugin. You created a page Contact Us (
slug = contact-us) and want to include Contact Form 7 scripts only on this page.
Find the Contact Form 7 scripts on pluginÌtumọ̀ Yorùbá: ’s configuration page (they
have handle = contact-form-7) and put `is_page('contact-us')` in logic field

## FAQ

  Why isnÌtumọ̀ Yorùbá: ’t it working?

Try switching to the WP default theme Ìtumọ̀ Yorùbá: – if the problem goes away,
there is something specific to your theme that may be interfering with the WP conditional
tags.

Most probably the logic text on one of your scripts is invalid PHP

  How do I load a certain script X on just my ‘home’ page? (Or on every page except
that.)

There is some confusion between the [Main Page and the front page](https://codex.wordpress.org/Conditional_Tags#The_Main_Page).
If you want a script on your ‘front page’ whether that is a static page or a set
of posts, use is_front_page(). If it is a page using is_page(x) does not work. If
your ‘front page’ is a page and not a series of posts, you can still use is_home()
to include scripts on that main posts page (as defined in Admin > Settings > Reading).

## Àwọn àgbéyẹ̀wò

Kò sí àwọn àgbéyẹ̀wò fún plugin yìí.

## Àwọn Olùkópa & Olùgbéejáde

“Script Logic” jẹ́ ètò ìṣàmúlò orísun ṣíṣí sílẹ̀. Àwọn ènìyàn wọ̀nyí ti ṣe ìkópa
sí plugin yìí.

Àwọn Olùkópa

 *   [ Tahir Yasin ](https://profiles.wordpress.org/tahiryasin/)

[Túmọ̀ “Script Logic” sí èdè rẹ.](https://translate.wordpress.org/projects/wp-plugins/script-logic)

### Ṣe o nífẹ̀ẹ́ sí ìdàgbàsókè?

[Ṣàwárí koodu](https://plugins.trac.wordpress.org/browser/script-logic/), ṣàyẹ̀wò
[ibi ìpamọ́ SVN](https://plugins.svn.wordpress.org/script-logic/), tàbí ṣe àgbékalẹ̀
sí [àkọsílẹ̀ ìdàgbàsókè](https://plugins.trac.wordpress.org/log/script-logic/) nípasẹ̀
[RSS](https://plugins.trac.wordpress.org/log/script-logic/?limit=100&mode=stop_on_copy&format=rss).

## Àkọsílẹ̀ àwọn àyípadà

#### 0.1

 * First stable release.

## Àkójọpọ̀ Meta

 *  Ẹ̀yà **0.3**
 *  Ìgbàgbọ́hùn tó kẹ́yìn **ọdún 12 sẹ́yìn**
 *  Àwọn ìgbéwọlẹ̀ tó ṣiṣẹ́ **10+**
 *  Ẹ̀yà WordPress ** 2.8 tàbí ju bẹ́ẹ̀ lọ **
 *  Dánwò dé **3.9.40**
 *  Èdè
 * [English (US)](https://wordpress.org/plugins/script-logic/)
 * Àwọn àmì
 * [admin](https://yor.wordpress.org/plugins/tags/admin/)[conditional-tags](https://yor.wordpress.org/plugins/tags/conditional-tags/)
   [script](https://yor.wordpress.org/plugins/tags/script/)[speed](https://yor.wordpress.org/plugins/tags/speed/)
   [style](https://yor.wordpress.org/plugins/tags/style/)
 *  [Ìwòye Tó Péye](https://yor.wordpress.org/plugins/script-logic/advanced/)

## Àwọn ìbò

 3 lára àwọn ìràwọ̀ 5.

 *  [  1 5-star review     ](https://wordpress.org/support/plugin/script-logic/reviews/?filter=5)
 *  [  0 4-star reviews     ](https://wordpress.org/support/plugin/script-logic/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/script-logic/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/script-logic/reviews/?filter=2)
 *  [  1 1-star review     ](https://wordpress.org/support/plugin/script-logic/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/script-logic/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/script-logic/reviews/)

## Àwọn Olùkópa

 *   [ Tahir Yasin ](https://profiles.wordpress.org/tahiryasin/)

## Ìrànlọ́wọ́

Nǹkan wà tí o fẹ́ sọ? Ṣé o nílò ìrànlọ́wọ́?

 [Wo àpéjọ ìrànlọ́wọ́](https://wordpress.org/support/plugin/script-logic/)

## Ṣe ìtọrẹ

Ṣé o fẹ́ ṣe àtìlẹ́yìn fún ìlọsíwájú plugin yìí?

 [ Ṣe ìtọrẹ sí plugin yìí ](http://NA)