This file contains hidden or 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 | |
//Remove get variables from url | |
function removeqsvar($url, $varname) { | |
return preg_replace('/([?&])'.$varname.'=[^&]+(&|$)/','$1',$url); | |
} | |
?> |
This file contains hidden or 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 my_custom_posts_per_page($query){ | |
$query->query_vars['posts_per_page'] = 3; | |
} | |
add_filter( 'pre_get_posts', 'my_custom_posts_per_page' ); | |
?> |
This file contains hidden or 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 | |
$categories = Mage::getModel('catalog/category')->getCollection() | |
->addAttributeToSelect('id') | |
->addAttributeToSelect('name') | |
->addAttributeToSelect('url_key') | |
->addAttributeToSelect('url') | |
->addAttributeToFilter('level',2) | |
->addAttributeToSelect('is_active'); | |
foreach ($categories as $category) |
This file contains hidden or 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 | |
try{ | |
$category = Mage::getModel('catalog/category'); | |
$category->setName('check'); | |
$category->setUrlKey('new-category'); | |
$category->setIsActive(1); | |
$category->setDisplayMode('PRODUCTS'); | |
$category->setIsAnchor(1); //for active achor | |
$category->setStoreId(Mage::app()->getStore()->getId()); | |
$parentCategory = Mage::getModel('catalog/category')->load($parentId); |
This file contains hidden or 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 array_col(array $a, $x) | |
{ | |
return array_map(function($a) use ($x) { return $a[$x]; }, $a); | |
} | |
$max = max(array_col($menu_items, 'colonna')); | |
?> |
This file contains hidden or 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 array_col(array $a, $x) | |
{ | |
return array_map(function($a) use ($x) { return $a[$x]; }, $a); | |
} | |
?> |
This file contains hidden or 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_action('registered_post_type', 'custom_registered_post_type_handler', 10, 2); | |
function custom_registered_post_type_handler($post_type, $args) { | |
do_action("custom_registered_{$post_type}_post_type", $post_type, $args); | |
} | |
add_action('custom_registered_foo_post_type', 'custom_registered_foo_post_type_handler', 10, 2); | |
function custom_registered_foo_post_type_handler($post_type, $args) { | |
remove_action(current_filter(), __FUNCTION__, 10, 2); // only run once | |
// change your args here |
This file contains hidden or 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: Instrument Hooks for WordPress | |
Description: Instruments Hooks for a Page. Outputs during the Shutdown Hook. | |
Version: 0.1 | |
Author: Mike Schinkel | |
Author URI: http://mikeschinkel.com | |
*/ | |
if ($_GET['instrument']=='hooks') { |
This file contains hidden or 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
function scrollToAnchor(aid){ | |
var aTag = $("a[name='"+ aid +"']"); | |
$('html,body').animate({scrollTop: aTag.offset().top},'slow'); | |
} | |
scrollToAnchor('id3'); |