First, Lets find out what version of PHP we're running (To find out if it's the default version).
To do that, Within the terminal, Fire this command:
which php
<?php | |
/** | |
* Change `the_content` thing in below function with your hook in filter | |
* - You can change $wp_filter to $wp_actions to get details of action hooks. | |
* | |
* NOTE: THIS IS FOR ONLY DEBUG PURPOSE NOT SEND THIS CODE TO PRODUCTION. | |
*/ | |
function vk_list_hooks() { | |
global $wp_filter; |
<?php | |
/* | |
* Plugin Name: Paulund WP List Table Example | |
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area | |
* Plugin URI: http://www.paulund.co.uk | |
* Author: Paul Underwood | |
* Author URI: http://www.paulund.co.uk | |
* Version: 1.0 | |
* License: GPL2 | |
*/ |
<?php | |
add_action( 'pre_get_posts', array( $this,'function_pre_get_posts' ) ); | |
function function_pre_get_posts(){ | |
// you can't use the query->set here for tax_query | |
// as tax query has already been made | |
// so you need to need add youself to any | |
// existing tax query | |
$tax_query = array( | |
'taxonomy' => 'tax_name', |
<?php | |
function settings_fields() { | |
$children['tab'] = new Fieldmanager_Group( array( | |
'label' => 'ABCD', // This name must match what we registered in `fm_register_submenu_page()` | |
'children' => array( | |
'text' => new Fieldmanager_Textfield( 'Text Field' ), | |
'autocomplete' => new Fieldmanager_Autocomplete( 'Autocomplete', array( 'datasource' => new Fieldmanager_Datasource_Post() ) ), | |
'textarea' => new Fieldmanager_TextArea( 'TextArea' ), | |
'media' => new Fieldmanager_Media( 'Media File' ), |
<?php | |
/** | |
* File contains all hooks related to Submission post type. | |
* | |
* Required in customizer.php. | |
* | |
* @package vk-research | |
*/ | |
/** |
// Update PHPcs | |
sudo pear upgrade-all and sudo pear install PHP_CodeSniffer | |
// Check version of PHPcs | |
phpcs --version | |
// Go to Where coding standards available | |
/usr/local/pear/share/pear/PHP/CodeSniffer/Standards/WordPress-Coding-Standards |
<?php | |
if ( ! function_exists( 'vk_get_tax_cost_by_country' ) ) { | |
/** | |
* Get tax cost by country code. | |
* | |
* @param string $country_code Code of country. | |
* @param int $total Cart total. | |
* | |
* @return int Cost of tax. |
Go to this directory | |
For Mac Users | |
/usr/local/pear/share/pear/PHP/CodeSniffer/Standards | |
For Linux Users | |
/usr/share/php/PHP/CodeSniffer/Standards/ | |
then |
<?php | |
$file = '/path/to/file.png'; | |
$filename = basename($file); | |
$upload_file = wp_upload_bits($filename, null, file_get_contents($file)); | |
if (!$upload_file['error']) { | |
$wp_filetype = wp_check_filetype($filename, null ); | |
$attachment = array( | |
'post_mime_type' => $wp_filetype['type'], | |
'post_parent' => $parent_post_id, |