Skip to content

Instantly share code, notes, and snippets.

Ashish Kumar ashfame

Block or report user

Report or block ashfame

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ashfame
ashfame / modify-page-title.php
Created Aug 3, 2012
Modifying page title using the_title filter in WordPress
View modify-page-title.php
<?php
add_filter( 'the_title', 'nine11day_modify_post_title' );
function nine11day_modify_post_title( $title ) {
if ( is_page() && in_the_loop() && $title == 'Existing Title' )
$title = '<span>Existing</span> Title';
return $title;
}
@ashfame
ashfame / functions.php
Created Aug 3, 2012
Add page slug to body class
View functions.php
<?php
function custom_body_class($classes){
global $wp_query;
if ( is_page() ) {
$post_obj = $wp_query->get_queried_object();
array_push($classes, 'slug-'.$post_obj->post_name);
}
return $classes;
@ashfame
ashfame / config.xml
Created May 4, 2012
Overriding admin template in magento
View config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Anattadesign_Adminoverrider>
<version>1.0.0</version>
</Anattadesign_Adminoverrider>
</modules>
<global>
<layout>
<adminhtml_sales_order_create_index>
View useful-shell-commands.sh
# Set 644 permission on all PHP files recursively
find . -type f -name '*.php' -exec chmod 644 '{}' \+
@ashfame
ashfame / Correct-way-to-enqueue-scripts-and-style-in-WordPress.php
Created Feb 27, 2012
Correct way to enqueue scripts and style in WordPress
View Correct-way-to-enqueue-scripts-and-style-in-WordPress.php
<?php
/**
* Register Styles and Scripts
*/
add_action( 'wp_enqueue_scripts', 'ft_scripts_styles' );
function ft_scripts_styles() {
@ashfame
ashfame / local-config-awesome-wp-config-file.php
Created Feb 27, 2012
Local config file to hold db credentials and for defining keys & salts along with the use of awesome wp-config.php file
View local-config-awesome-wp-config-file.php
<?php
/**
* WordPress config file to use one directory above WordPress root, when awesome version of wp-config.php is in use.
*
* Awesome wp-config.php file - https://gist.github.com/1923821
*/
/* WordPress Local Environment DB credentials */
View awesome-wp-config-file.php
<?php
/**
* Define type of server
*
* Depending on the type other stuff can be configured
* Note: Define them all, don't skip one if other is already defined
*/
define( 'DB_CREDENTIALS_PATH', dirname( ABSPATH ) ); // cache it for multiple use
@ashfame
ashfame / Best-way-to-wrap-up-your-jQuery-code-for-avoiding-conflicts.js
Created Feb 27, 2012
Best way to wrap up your jQuery code for avoiding conflicts
View Best-way-to-wrap-up-your-jQuery-code-for-avoiding-conflicts.js
(function($){
// Regular jQuery code inside
$(document).ready(function(){
});
})(jQuery);
View svn-commands.sh
# Count no of files in repo
svn info -R --xml file:///path/to/rep | grep kind=\"file\"|wc -l
# SVN command to give commit authors list and save it in author-transform.txt
svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
@ashfame
ashfame / example.php
Created Jan 24, 2012
Changing postmeta fields programmatically
View example.php
<pre><?php
require 'wp-load.php';
$postmeta_field_name = 'video_url'; // fill it
echo $query = "SELECT * FROM {$wpdb->postmeta} WHERE meta_key = '$postmeta_field_name';";
$data = $wpdb->get_results( $query );
You can’t perform that action at this time.