This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.ajax( { | |
url: wpApiSettings.root + 'wp/v2/posts/1', | |
method: 'POST', | |
beforeSend: function ( xhr ) { | |
xhr.setRequestHeader( 'X-WP-Nonce', wpApiSettings.nonce ); | |
}, | |
data:{ | |
'title' : 'Hello Moon' | |
} | |
} ).done( function ( response ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: WordPress REST API filter query | |
* Description: This plugin adds a "filter" query parameter to API collections to filter returned results based on arbitrary WP_Query parameters, adding back the "filter" parameter that was removed from the API when it was merged into WordPress core. | |
* Author: WP REST API Team | |
* Author URI: http://v2.wp-api.org | |
* Version 0.1 | |
* License: GPL2+ | |
**/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function only_allow_logged_in_rest_access( $access ) { | |
if( ! is_user_logged_in() ) { | |
return new WP_Error( 'rest_cannot_access', 'Du kannst nur eingeloggt die REST API nutzen.', array( 'status' => rest_authorization_required_code() ) ); | |
} | |
return $access; | |
} | |
add_filter( 'rest_authentication_errors', 'only_allow_logged_in_rest_access' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'after_setup_theme', 'add_frontkit_support' ); | |
function add_frontkit_support() { | |
add_theme_support( 'frontkit', array( | |
'title' => '.single-post .entry-title', | |
'content' => '.single-post .entry-content', | |
) ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Nonces in der REST API Not working | |
* Author: Websupporter | |
* Plugin URL: http://websupporter.net/blog/de/nonces-in-der-rest-api/ | |
* Licence: GPL | |
**/ | |
add_action( 'wp_ajax_nonce-test', 'ajax_nonce_test' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Nonces in der REST API | |
* Author: Websupporter | |
* Plugin URL: http://websupporter.net/blog/de/nonces-in-der-rest-api/ | |
* Licence: GPL | |
**/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'after_setup_theme', 'theme_start_content' ); | |
function theme_starter_content() { | |
add_theme_support( 'starter-content', array( | |
'widgets' => array( | |
'sidebar-1' => array( | |
'text_business_info', | |
'search', | |
), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'after_setup_theme', 'theme_start_content' ); | |
function theme_starter_content() { | |
add_theme_support( 'starter-content', array( | |
'widgets' => array( | |
'sidebar-1' => array( | |
'text_business_info', | |
'search', | |
array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Mein_Widget extends WP_Widget { | |
function __construct() { | |
// Instantiate the parent object | |
parent::__construct( 'meine-base-id', _x( 'My widget', 'theme-slug' ) ); | |
} | |
function widget( $args, $instance ) { |