Skip to content

Instantly share code, notes, and snippets.

@arioch1984
arioch1984 / wp_modify_permalink.php
Created May 29, 2015 10:30
WP: modify permalinks setting programmatically #wp_modify_permalink
@arioch1984
arioch1984 / wp_create_pages.php
Created May 27, 2015 14:52
WP: Programmatically create pages #wp_create_pages
<?php
global $user_ID;
$page = get_page_by_title('Page title');
if($home == null){
$page['post_type'] = 'page';
$page['post_content'] = '';
$page['post_parent'] = 0;
$page['post_author'] = $user_ID;
$page['post_status'] = 'Page title';
@arioch1984
arioch1984 / wp_submit_button_bootstrap.php
Created May 11, 2015 09:56
Wordpress: submit button to bootstrap in comments form #wp_submit_button_bootstrap
<?php
add_filter( 'comment_form_defaults', 'sp_comment_submit_button' );
function sp_comment_submit_button( $defaults ) {
$defaults['class_submit'] .= ' btn btn-primary';
return $defaults;
}
?>
@arioch1984
arioch1984 / wp_redirect_home_from_cookie.php
Created May 8, 2015 15:34
Wordpress: WPML set language redirection for home from cookie #wp_redirect_home_from_cookie
@arioch1984
arioch1984 / wp_print_actions_by_hook.php
Created May 7, 2015 11:04
Wordpress: print actions by hook name #wp_print_actions_by_hook
<?php
$hook_name = 'hook';
global $wp_filter;
var_dump( $wp_filter[$hook_name] );
?>
@arioch1984
arioch1984 / osx_dummy_file.sh
Created April 15, 2015 08:37
OSX: make dummy files #osx_dummy_file
mkfile 50m test.tmp
@arioch1984
arioch1984 / zend_debug_dump.php
Created April 9, 2015 15:38
Zend: debug dump #zend_debug_dump
<?php
Zend_Debug::dump($var);
?>
@arioch1984
arioch1984 / zend_dom_query.php
Created April 9, 2015 15:37
Zend: dom query #zend_dom_query
<?php
$dom = new Zend_Dom_Query($blockHTML);
$images = $dom->query('img');
?>
@arioch1984
arioch1984 / block_name.php
Last active August 29, 2015 14:18
Magento: static block inside template block
class CompanyName_ModuleName_Block_BlockName extends Mage_Core_Block_Template
{
protected function _construct(){
parent::_construct();
}
}
@arioch1984
arioch1984 / create-db-and-usr.sh
Created March 17, 2015 10:08
MySQL: Create DB, db user and give priviliges
#!/bin/bash
EXPECTED_ARGS=3
E_BADARGS=65
MYSQL=`which mysql`
Q1="CREATE DATABASE IF NOT EXISTS $1;"
Q2="CREATE USER '$2'@'localhost' IDENTIFIED BY '$3';"
Q3="GRANT ALL PRIVILEGES ON $1.* TO '$2'@'localhost' WITH GRANT OPTION;"
Q4="FLUSH PRIVILEGES;"