View function-documentation.php
<?php | |
/** | |
* Sends and email when a post is published. | |
* | |
* Sends and email using wp_mail standard WordPress function including data about | |
* the post being published. | |
*/ |
View detect-unused-images.sql
SELECT | |
* | |
FROM | |
wp_posts i | |
WHERE | |
i.post_type = 'attachment' | |
AND | |
NOT EXISTS (SELECT * FROM wp_posts p WHERE p.ID = i.post_parent) | |
AND | |
NOT EXISTS (SELECT * FROM wp_postmeta pm WHERE pm.meta_key = '_thumbnail_id' AND pm.meta_value = i.ID) |
View my-component.js
import { | |
Component, | |
Fragment, | |
} from '@wordpress/element'; | |
import Icon from './icon.svg'; | |
class MyComponent extends Component { | |
render() { | |
return ( |
View package.json
{ | |
"name": "my-wp-plugin", | |
"version": "1.0.0", | |
"description": "My WP plugin description", | |
"keywords": [ | |
"my", | |
"wordpress", | |
"plugin" | |
], | |
"author": "avillegasn", |
View settings-link.php
<?php // do not include this opening php tag in your file | |
add_filter( 'plugin_action_links_nelio-content/nelio-content.php', 'nc_settings_link' ); | |
function nc_settings_link( $links ) { | |
// Build and escape the URL. | |
$url = esc_url( add_query_arg( | |
'page', | |
'nelio-content-settings', | |
get_admin_url() . 'admin.php' | |
) ); |
View only-for-admins.php
<?php | |
add_filter( 'rest_authentication_errors', function( $result ) { | |
if ( ! empty( $result ) ) { | |
return $result; | |
} | |
if ( ! is_user_logged_in() ) { | |
return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) ); | |
} | |
if ( ! current_user_can( 'administrator' ) ) { |
View react-ui-without-jsx.js
class Product extends Component { | |
render() { | |
return wp.element.createElement( | |
"div", | |
{ className: "product" }, | |
wp.element.createElement( | |
"p", | |
null, | |
this.props.name | |
) |
View gutenberg.js
import ElementIcon from '../images/logo.svg'; | |
const { Fragment } = wp.element; | |
const { __ } = window.wp.i18n; | |
const { registerFormatType, unregisterFormatType } = window.wp.richText; | |
const { RichTextToolbarButton } = window.wp.blockEditor; | |
unregisterFormatType( 'nelio/button' ); | |
registerFormatType( 'nelio/button', { |
View acf-export.json
[ | |
{ | |
"key": "group_5bf27651e03b6", | |
"title": "Social Images", | |
"fields": [ | |
{ | |
"key": "field_5bf2766a5c07d", | |
"label": "Facebook", | |
"name": "nc-facebook-featured-image", | |
"type": "image", |
NewerOlder