This file contains 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 | |
/* Recheck if user is logged in just to be sure, this should have been done already */ | |
if( !is_user_logged_in() ) { | |
wp_redirect( home_url() ); | |
exit; | |
} | |
if ( $_SERVER['REQUEST_METHOD'] == 'POST' && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' ) { |
This file contains 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 | |
check_page_security(); | |
require_once('includes/update-profile.php'); | |
?> | |
<?php get_header(); ?> | |
<?php get_template_part('parts/dashboard/user'); ?> |
This file contains 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 to check page security | |
//=========================================================================== | |
function check_page_security() { | |
if( !is_user_logged_in() ) { | |
wp_redirect( home_url() ); |
This file contains 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 notice to the profile edit page | |
//====================================================================== | |
add_action( 'admin_notices', 'ecs_add_post_notice' ); | |
function ecs_add_post_notice() { |
This file contains 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 post state to the projects page | |
//====================================================================== | |
add_filter( 'display_post_states', 'ecs_add_post_state', 10, 2 ); | |
function ecs_add_post_state( $post_states, $post ) { |
This file contains 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
function formatResult (company) { | |
if (company.loading) return company.text; | |
var markup = "<div class='select2-result-company clearfix'>" + | |
"<div class='select2-result-company__meta'>" + | |
"<div class='select2-result-company__title'>" + company.company_name + "</div>" + | |
"<div class='select2-result-company__number'>" + company.company_number + "</div>" + | |
"</div></div>"; | |
return markup; |
This file contains 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 wpc_somename_search_callback( $request_data ) { | |
$parameters = $request_data->get_params(); | |
if( !isset( $parameters['keyword'] ) || empty($parameters['keyword']) ) | |
return array( 'error' => 'no_parameter_given' ); | |
$keyword = $parameters['keyword']; |
This file contains 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
"/somename/search": | |
{ | |
"namespace": "somename", | |
"methods": [ | |
"GET" | |
], | |
"endpoints": [ | |
{ | |
"methods": [ | |
"GET" |
This file contains 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( 'rest_api_init', 'wpc_register_wp_api_endpoints' ); | |
function wpc_register_wp_api_endpoints() { | |
register_rest_route( 'somename', '/search', array( | |
'methods' => 'GET', | |
'callback' => 'wpc_somename_search_callback', | |
)); | |
} |