Skip to content

Instantly share code, notes, and snippets.

@ann71727
ann71727 / Convert Object To Array.php
Last active October 27, 2017 17:51
PHP Convert Object To Array
<?php
/*
* Convert Object To Array
* https://vector.cool
*/
function obj_to_arr($obj){
return (array) $obj;
}
@ann71727
ann71727 / WordPress-WP_Query-result-posts-object-to-an-array.php
Last active July 6, 2023 10:42
WordPress WP_Query() result posts object to an array
<?php
/*
* Convert Object To Array
* https://v123.tw
*/
$args = array(
'showposts' => -1,
'post_type' => 'post',
'post_status' => 'publish'
@ann71727
ann71727 / WP_Query_arr.php
Created October 27, 2017 19:04
WP_Query get posts Array
<?php
/*
* Convert Object To Array
* https://v123.tw
*/
function WP_Query_arr(array $args){
$default = array(
'showposts' => -1,
'post_type' => 'post',
@ann71727
ann71727 / List All Post Type.php
Last active October 28, 2017 15:01
List All Post Type
<?php
/*
* List All Post Type
* https://v123.tw
*/
function v123_get_all_post_types(){
global $wp_post_types;
print_r($wp_post_types);
}
add_action('init','v123_get_all_post_types');
@ann71727
ann71727 / List All Post Type Names.php
Last active October 28, 2017 15:05
List All Post Type Names
<?php
/*
* List All Post Type Names
* https://v123.tw
*/
function v123_get_all_post_type_names(){
global $wp_post_types;
$posttypes = array_keys( $wp_post_types );
@ann71727
ann71727 / WordPress Plugin Header.php
Last active October 28, 2017 23:33
WordPress Plugin Header
<?php
/*
Plugin Name: Plug Name v123 DEV
Plugin URI: https://v123.tw
Description: 插件簡述
Version: 1.01.0
Author: v123 DEV
Author URI: https://v123.tw
License: GPL2
License URI: https://v123.tw
@ann71727
ann71727 / remove-wp-Divi-Project-post-type.php
Created November 1, 2017 22:09
刪除 WordPress Divi Project post type
<?php
/**
* 刪除 WordPress Divi Project post type.
* https://v123.tw
*/
add_filter( 'et_project_posttype_args', 'mytheme_et_project_posttype_args', 10, 1 );
function mytheme_et_project_posttype_args( $args ) {
return array_merge( $args, array(
'public' => false,
'exclude_from_search' => false,
@ann71727
ann71727 / wp-remove-notice-and-warning.php
Last active November 1, 2017 23:28
WordPress Remove notice and warning
<?php
/**
* WordPress Remove notice and warning
* https://v123.tw
*/
add_action('admin_print_scripts', 'ure_remove_admin_notices');
function ure_remove_admin_notices() {
global $wp_filter;
if (is_user_admin()) {
if (isset($wp_filter['user_admin_notices'])) {
@ann71727
ann71727 / wp-remove-all-notice-and-warning-with-user-role-editor.php
Created November 1, 2017 23:25
WordPress remove all notice and warning with user role editor
<?php
/**
* WordPress remove all notice and warning with user role editor
* https://v123.tw
*/
add_filter('ure_role_additional_options', 'ure_add_block_admin_notices_option', 10, 1);
function ure_add_block_admin_notices_option($items) {
$item = URE_Role_Additional_Options::create_item('block_admin_notices', esc_html__('Block admin notices', 'user-role-editor'), 'admin_init', 'ure_block_admin_notices');
$items[$item->id] = $item;
@ann71727
ann71727 / wp_nav_menu-text-and-classes.php
Last active November 5, 2017 20:26
wp_nav_menu() 修改或自訂義文字及類別
<?php
/**
* WordPress modify wp_nav_menu text and classes
* https://v123.tw
*/
$args = array(
'theme_location' => 'main-menu',
'container' => 'v123-nav',
'container_id' => 'v123-menu-menu',
'menu_class' => 'v123-menu-div',