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 | |
// You instantiating the XSLTProcessor - libXSLT | |
$xmlProc = new XsltProcessor(); | |
// Your XSLT Stylesheet for transforming XML | |
$xslt = new DomDocument(); | |
$xslt -> load("example.xsl"); | |
// This prepares the XSLT for transform | |
$xmlProc -> importStylesheet($xslt); |
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
/* Sets the user's display name (always) to first name last name, when it's available ************************************** | |
** http://stackoverflow.com/questions/9326315/wordpress-change-default-display-name-publicy-as-for-all-existing-users *** */ | |
/* !아이디 대신 이름으로 나타내기 ********************************************************************************************* */ | |
/* Sets the user's display name (always) to first name last name, when it's avail. */ | |
add_action ('admin_head','make_display_name_f_name_last_name'); | |
function make_display_name_f_name_last_name(){ | |
$users = get_users(array('fields'=>'all')); | |
foreach($users as $user){ | |
$user = get_userdata($user->ID); | |
$display_name = $user->first_name; |
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 replace_links( $text ) | |
{ | |
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text); | |
$ret = ' ' . $text; | |
// Replace Links with http:// | |
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\" rel=\"nofollow\">\\2</a>", $ret); | |
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 if ( get_the_content() ) { ?> | |
// do or output something | |
<?php } ?> // break php tag for HTML block |
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 | |
$cmb->add_field( array( | |
'name' => __( 'Postive numbers', 'theme-domain' ), | |
'desc' => __( 'Numbers only', 'msft-newscenter' ), | |
'id' => $prefix . 'number', | |
'type' => 'text', | |
'attributes' => array( | |
'type' => 'number', | |
'pattern' => '\d*', |
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
INITIALISATION | |
============== | |
load wp-config.php | |
set up default constants | |
load wp-content/advanced-cache.php if it exists | |
load wp-content/db.php if it exists | |
connect to mysql, select db | |
load object cache (object-cache.php if it exists, or wp-include/cache.php if not) | |
load wp-content/sunrise.php if it exists (multisite only) |
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 | |
/* | |
* Plugin Name: Example Modify Price | |
*/ | |
class Example_Modify_Price { | |
private static $instance; | |
public static function register() { | |
if (self::$instance == null) { |
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 | |
/** | |
* Adds Page to a WordPress navmenu | |
* @param [int] $page_id The ID of the page you want to add | |
* @param [str] $page_title Title of menu item | |
* @param [int] $menu_id NavMenu ID | |
* @param [int] $parent (Optional) Menu item Parent ID | |
*/ | |
function add_page_to_menu($page_id, $page_title, $menu_id, $parent = 0){ |
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 a hidden field to our WooCommerce login form - passing in the refering page URL | |
* Note: the input (hidden) field doesn't actually get created unless the user was directed | |
* to this page from a single product page | |
*/ | |
function redirect_user_back_to_product() { | |
// check for a referer | |
$referer = wp_get_referer(); | |
// if there was a referer.. |
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 | |
/** | |
* The below function will help to load template file from plugin directory of wordpress | |
* Extracted from : http://wordpress.stackexchange.com/questions/94343/get-template-part-from-plugin | |
*/ | |
define('PLUGIN_DIR_PATH','Your-plugin-directory-path'); | |
function ccm_get_template_part($slug, $name = null) { | |
do_action("ccm_get_template_part_{$slug}", $slug, $name); |
OlderNewer