Configuration of the plugin is optional, but you should at least register your variables if you are using a CSS framework.
Paths to Sass files are relative to the theme directory.
Use the filter 'sass_configuration' to return your configurations array.
‘variables‘ (array)
In order to list and edit your Sass variables on the plugin dedicated page, it is necessary to register their “definition” file(s). It is assumed that those files’ only role is to declare variables and their values.
‘imports‘ (array)
It will prepend the code to compile with an @import directive for each listed file. Useful to compile dependencies, and to “hide” them from the Compiler page. It is necessary to hit the “Compile” button once for these imports to be compiled.
‘cache‘ (string)
Allows you to define the path to your cache directory. This directory has to be writable (0755). The default cache directory path is wp-content/cache.
‘search‘ (boolean)
Wether or not to display the “Search Variables” filter box. It can come handy if you have a lot of variables. Default is true.
Once registered, you can access any variables with the function sass_get( 'my-variable' );, or override its value (upon what has been set on the Variables page) with sass_set( 'my-variable', 'my-value' ).
It is also possible to use @import directives, as well as any Sass language features, straight from the Compiler page.
It will be compared to the cached version, compiled if changes occurred, and the resulting stylesheet will be enqueued.
Don’t forget to set the main Sass stylesheet handle 'wm-sass' as a dependency (… if it is one).
Settings are really useful to provide an easy configuration of themes and plugins to our users within their administration panel. But the creation of options pages often ends up in a messy and repetitive use of the great WordPress Settings API.
Considering generic form fields, I wrote a class to clean and simplify the process. It’s something light that shall be used on the admin side. https://github.com/WebMaestroFr/wm-settings
$args : (array) (Optional) An array of miscellaneous arguments.
‘tabs‘ : (boolean) Whether to display the different sections as “tabs” or not. There must be several sections, and they must have a title.
Default : false
‘submit‘ : (string) Text of the submit button.
Default : ‘Save Settings’
‘reset‘ : (string) Text of the reset button. Set to false to disable the reset button.
Default : ‘Reset Settings’
‘description‘ : (string) Page description.
‘updated‘ : (string) Message of the success notice. Set to false to disable the notice.
Default : ‘Settings saved.’
$page->apply_settings( $settings );
Append sections and fields to a form, with an associative array where each setting is a section, and each option is a field. Each key of $settings defines a new setting id.
‘fields‘ : (array) (Optional) An array of options field declarations. Each key of this new array defines a new option name.
‘type‘ : (string) (Optional) Field type (checkbox, textarea, radio, select, multi, media, action, color or any valid HTML5 input type attribute).
Default : ‘text’
‘label‘ : (string) (Optional) Field label. Use false to hide the label column on this field.
‘description‘ : (string) (Optional) Field description.
‘sanitize‘ : (callback) (Optional) A function to apply in place of the default sanitation of this field’s type. Receive the input value and the option name as parameters, and is expected to return a properly sanitised value.
‘attributes‘ : (array) (Optional) An array( 'my_attribute' => 'my_value', ... ) of HTML attributes. Useful for placeholder or pattern for instance.
‘options‘ : (array) (Optional) Only for radio, select and multi field types, an array( 'my_value' => __( 'My Label' ), ... ) of predefined values.
‘action‘ : (callback) (Optional) Only for action field type. Expect a response sent with either wp_send_json_success (success) or wp_send_json_error (failure), where $data(Optional) is either the message to display (string), orarray( 'reload' => true ) if the page needs to reload on action’s success.
Every setting is recorded as an array of options values. An easier way to get the data back, from anywhere in the code, is to use the function get_setting( $setting_id, $option_name );.
$my_attachment_id = get_setting( 'my_advanced_section', 'my_media' );
// ... is the same than :
$my_setting = get_option( 'my_advanced_section' );
$my_attachment_id = $my_setting['my_media'];
Callback after settings are updated
The class hooks actions tagged ‘(page_id)_settings_updated‘ when settings are updated.
add_action( 'my_top_level_page_settings_updated', 'do_my_page_callback' );
function do_my_page_callback() {
// All settings of my_top_level_page have been updated.
}
You can also use the ‘update_option_(setting_id)‘ WordPress action that will apply on every section update.
add_action( 'update_option_custom_fields_section', 'do_my_section_callback' );
function do_my_section_callback() {
$my_custom_options = get_setting( 'my_custom_section' );
// All options of custom_fields_section have been updated.
}
Custom notices
You can display custom notices on the options pages.
Allowed types are info (default), updated, warning and error.
What do you think ?
I’ve been working on and using this with fun. Feel free to contact me for questions, feedback or suggestions. And you can find all of it, fork and contribute on GitHub. Peace out.
Upload the layers of your image, and create a parallax effect !
It works great on smart devices too !
The first step is to create with your favorite picture editing software (Photoshop, GIMP…) an independent image for each ground composing your image. All these layers shall be the same size, and should be in .png format as they are meant to include transparency areas.
Then, on your post editing page in WordPress, click the Insert Media button, and (the same way you would create a gallery) upload your layers under the Create Parallax item. Reorganise the layers if needed, from the background to the front.
You can finally configure the animation (calibrate, invert, limit, scalar, friction), and publish !
This plugin uses parallax.js by Matthew Wagerfield.
Okay fellows. It took me ages, but I coded my very first game in JavaScript. It’s based on Quoridor, a really interesting “abstract strategy” board game, designed by Mirko Marchesi and published by Gigamic. The rules and logic of it are quite simple, so I thought it would be a nice project for my first experiment of this kind.
What I’m about to do here, is to review step by step how I made it. It was my first real use of Javascript Prototypes and HTML5 canvas, and I learned a lot, so maybe this little “tutorial” will be interesting for you.
The game “Quoridor” is legally owned and protected by Gigamic, so you guys understand that this code can’t go further than our private experimental use.
Maybe you would like to play the demo before we make this work and rock.
Easily add geographical tags on a map when you write a post, and it will automatically create new countries and localities terms. You can also order those locations randomly or by date to define your routes.
Use the map as a widget, and pick your own colors to customize it.
It is a SVG map that react to users actions (mouse over posts and terms links, click on route line…).