Title: Code Block ScratchPad
Author: Alan C Brown
Published: <strong>2020년 8월 21일</strong>
Last modified: 2020년 11월 25일

---

플러그인 검색

이 플러그인은 **최근 3개의 주요 워드프레스 출시와 시험 되지 않았습니다**. 워드프레스의
좀 더 최근 버전으로 이용할 때 더 이상 관리되지 않고 지원되지 않고 호환성 문제가 
있을 수 있습니다.

![](https://ps.w.org/acb-scratchpad/assets/Icon-128x128.png?rev=2425958)

# Code Block ScratchPad

 작성자: [Alan C Brown](https://profiles.wordpress.org/acerby/)

[다운로드](https://downloads.wordpress.org/plugin/acb-scratchpad.1.0.0.zip)

 * [세부사항](https://ko.wordpress.org/plugins/acb-scratchpad/#description)
 * [평가](https://ko.wordpress.org/plugins/acb-scratchpad/#reviews)
 *  [설치](https://ko.wordpress.org/plugins/acb-scratchpad/#installation)
 * [개발](https://ko.wordpress.org/plugins/acb-scratchpad/#developers)

 [지원](https://wordpress.org/support/plugin/acb-scratchpad/)

## 설명

This plug-in makes it simple to test and/or install small wordpress PHP/JS/CSS code
snippets in a relatively safe manner without the need to use a full PHP debugger
or directly edit pre-existing plugin code.

### Basic Features

 * Enter simple PHP/JS expressions and quickly evaluate them to verify they function
   as expected.
 * Create/install top-level php functions eg: for use in wordpress pod fields.
 * Add bespoke code and associate them with wordpress action/filters
 * Do almost anything that’s possible with a wordpress plugin
 * Test and add custom javascript and CSS to website pages
 * Preview the effects of changes before commiting in wordpress preview mode
 * Provides protection against inadvertently killing sites due to basic coding errors

## 스크린샷

[⌊Adding some icons and testing a JS regex⌉⌊Adding some icons and testing a JS regex⌉[

Adding some icons and testing a JS regex

## 설치

 1. Upload acb-scratchpad to the /wp-content/plugins/ directory.
 2. Activate Code Block Scratchpad through the ‘Plugins’ menu in WordPress.
 3. Select the Code Block Scratchpad menu item in the admin pages and enter a simple
    expression and press the Check/Run button.

## FAQ

### Should I get/use this Plugin?

If you are writing (or intending to write) PHP code and are looking for some quick/
easy way to test existing PHP code, or add a tiny snippet of code to an existing
web site, then (hopefully) YES.
 If however you are trying to make a page look different,
display a field etc, then I would generally recommend looking elsewhere in the first
instance. There are a lot of great plugins that provide nice friendly interfaces
for modifying the presentation of content and adding new fields/features. This plugin
gives access to the low-level PHP & Javascript code that powers wordpress enabling
you to do almost anything thats possible in wordpress. However, it’s just a basic
low-level tool and doesn’t provide any ready-made solutions, relying on the user
having knowledge how to program in PHP for wordpress.

### Can I do … with this plugin

The answer is almost certainly Yes – However you are probably asking the wrong question—
Please see: “Should I get/use this plugin” and “What this plug is for”.

### What is this plugin for? / Why was it created?

This plugin was initially created as an aid to creating a second more complex plugin.
One of the issues of creating plugins is testing the PHP code being written and 
investigating/verifying how pre-existing wordpress functionality works.
 I wanted
a simple way to test/run PHP code that could interact with existing code, but without
the otherwise ever-present risk that I could totally kill the whole website including
the admin pages simply by inadvertently introducing a minor syntax error. There 
are some great on-line scratchpads for testing standalone PHP code snippets but 
these obviously can be used to test functionality specific to be environment. This
add-in has proven very useful to me in this regard and so I thought/hoped it may
prove useful to others with similar needs.

A secondary aim was related to an issue I had faced previously working on another
website, where I needed a very tiny fragment of PHP code to achieve my goal.
 However,
there was no easy/safe way to do that directly so I was forced into creating a complete
bespoke plugin to add one simple line of php code. Given that it was totally specific
to that web site, that seemed like an unnecessarily large overhead to achieve something
so simple. In fact, it turned out that the biggest issue wasn’t the creation of 
the tiny bespoke plugin, but the issue of added complexity/risks created for site
maintenance going forward. This add-in hopefully makes creating/administration and
ongoing managment including minor tweaks to the PHP code snippet, a lot more simple,
transparent, and less risky.

### Where has the Publish Button Gone?

To install PHP/JS code, first press the “Check/Run” button to verify the code is
syntactically valid. Then assuming it is fine the “Publish” button will be displayed.

The publish button will cause the displayed code to be installed and be made available
to all pages in the site, replacing any version previously installed via this method.

### I just checked/published some PHP code and now all I can see is a fatal parser/syntax error message!!!

Don’t panic! — Just make a note of the error message. If it gives a line number 
in eval()’d code make sure to make a note of that also. Then simply refresh the 
page.
 The scratchpad plugin will automatically disable any code that previously
bailed out with a fatal error, so that it wont auto-run in the future.

### Why does my page look different in preview mode?

WordPress includes the facility to view web-site pages in “preview” mode.
 The scratchpad
plugin will use the PHP/JS/CSS code currently displayed in the settings page as 
opposed to the currently installed code when displaying content in preview mode.

### When exactly will the PHP code I publish be run?

The PHP code is triggered/run by upon the wordpress ‘plugins_loaded’ event. So it’s
run in approximately the same time/context as the intial plugin code is run.
 You
can use the wordpress add_action(…) or add_filter(…) functions to have your code
run/applied to specific times/events.

### Whats with the /** [ Test Code ] **/ thing?

There are two primary uses of this codepad: The first of these is testing code eg
evaluating an expression and seeing what it returns, the second is adding code/functions
that will be utilised later when displaying website pages.
 Often these two functions
may be combined so we may defined some functions and then have some additional code
to test those functions. In these cases the /** [ Test Code ] **/ comment may be
used to separate these two code blocks. When publishing code, if a / [ Test Code]**/
comment appears in the source then only the part of the code above that comment 
will be published/installed.

### How can I pass values from PHP to javascript or CSS

You can set values in the global $acb_scratchpad_var eg $acb_scratchpad_var[‘myVarName’]
=$myValue; then this will be available in javascript as acb_scratchpad_var[‘myVarName’];

If you whish to send things related to the current wordpress page/post then you 
may want to ensure that your PHP code only runs once wordpress is fully loaded using
add_action(‘wp_loaded’,’name_of_my_php_fuction_to_get_and_set_vars’); or similar.
Items in $acb_scratchpad_var whose names start with ‘–‘ will additionally be defined
as css vars values. Alternatively for cleaner/improved syntax you could use LESS
format eg by using the https://wordpress.org/plugins/wp-less plugin.

### My previously published/installed code is now no longer being run – what happened?

Scratchpad includes a protection mechanism to stop flawed/fault code from permanently
breaking the web-site and its administration pages.
 You might like to check the
code and add appropriate try/catch type clauses if appropriate. To re-enable auto-
running simply re-publish the code.

## 후기

이 플러그인에 대한 평가가 없습니다.

## 기여자 & 개발자

“Code Block ScratchPad”(은)는 오픈 소스 소프트웨어입니다. 다음의 사람들이 이 플러그인에
기여하였습니다.

기여자

 *   [ Alan C Brown ](https://profiles.wordpress.org/acerby/)

[자국어로 “Code Block ScratchPad”(을)를 번역하세요.](https://translate.wordpress.org/projects/wp-plugins/acb-scratchpad)

### 개발에 관심이 있으십니까?

[코드 탐색하기](https://plugins.trac.wordpress.org/browser/acb-scratchpad/)는, [SVN 저장소](https://plugins.svn.wordpress.org/acb-scratchpad/)
를 확인하시거나, [개발 기록](https://plugins.trac.wordpress.org/log/acb-scratchpad/)
을 [RSS](https://plugins.trac.wordpress.org/log/acb-scratchpad/?limit=100&mode=stop_on_copy&format=rss)
로 구독하세요.

## 변경이력

#### 1.0.1

Release Date: 1st July 2020

 * [Initial Release]

## 기초

 *  버전 **1.0.1**
 *  최근 업데이트: **6년 전**
 *  활성화된 설치 **10보다 적음**
 *  워드프레스 버전 ** 4.7 또는 그 이상 **
 *  다음까지 시험됨: **5.4.21**
 *  언어
 * [English (US)](https://wordpress.org/plugins/acb-scratchpad/)
 * 태그:
 * [code](https://ko.wordpress.org/plugins/tags/code/)[php](https://ko.wordpress.org/plugins/tags/php/)
   [plugins](https://ko.wordpress.org/plugins/tags/plugins/)
 *  [고급 보기](https://ko.wordpress.org/plugins/acb-scratchpad/advanced/)

## 평점

아직 제출된 리뷰가 없습니다.

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

[모든  리뷰 보기](https://wordpress.org/support/plugin/acb-scratchpad/reviews/)

## 기여자

 *   [ Alan C Brown ](https://profiles.wordpress.org/acerby/)

## 지원

할 말 있으신가요? 도움이 필요하신가요?

 [지원 포럼 보기](https://wordpress.org/support/plugin/acb-scratchpad/)