简化12306接口,规范属性名称,用于数据库设计,数据接口定义
命名规则
<?php namespace App\Services; | |
use GuzzleHttp\Client; | |
class OneSignal { | |
const API_URL_ADD_PLAYER = 'https://onesignal.com/api/v1/players'; | |
const API_URL_CREATE_PUSH = 'https://onesignal.com/api/v1/notifications'; | |
const DEVICE_TYPE_IOS = 0; | |
const DEVICE_TYPE_ANDROID = 1; |
public function get_remote_posts() { | |
$posts = get_transient( 'remote_posts' ); | |
if( empty( $posts ) ) { | |
$response = wp_remote_get( 'http://mysite.com/wp-json/wp/v2/posts/' ); | |
if( is_wp_error( $response ) ) { | |
return array(); | |
} | |
$posts = json_decode( wp_remote_retrieve_body( $response ) ); |
<?php | |
/** | |
* Implements hook_process_html | |
*/ | |
function templatenamespace_process_html(&$vars) { | |
$search = array('scripts' => 'src=', 'styles' => 'href=', 'styles' => '@import\surl\('); | |
foreach ( $search as $var => $word ) { | |
if ( !empty($vars[$var]) ) { |