Skip to content

Instantly share code, notes, and snippets.

View vpadhariya's full-sized avatar

Vijay Padhariya vpadhariya

View GitHub Profile
@vpadhariya
vpadhariya / WordPress-trash-post-if-category-deleted.php
Last active August 10, 2017 08:21
In wordpress there were some certain requirement if the category was deleted then we need to Trash the posts attached to theme, here is the code how to achieve this easily.
<?php
/**
* If any category is deleted move all attached posts into trash
*/
function trash_category_posts($object_id, $tt_ids)
{
/**
* 1. Check the post_type
* 2. Check the action is delete or delete-tag
* 3. Check the taxonomy type is "category"
@vpadhariya
vpadhariya / WordPress-remove-query-string-from-static-resource.php
Last active August 10, 2017 08:22
WordPress remove query string from static resource
<?php
/**
* Remove query string from static resource
* @param type $src
* @return type
*/
function _remove_script_version($src)
{
$return = $src;
@vpadhariya
vpadhariya / WordPress-Add-Taxonomy-to-RSS-Feeds.php
Last active August 10, 2017 08:23
WordPress Add Taxonomy (Category or Tag) before post title in RSS Feeds
<?php
/**
* Prepend taxonomy name before feed title for Articles
* This will work for any custom post type or custom taxonomy
*/
function add_feed_item_title($content)
{
global $wp_query;
@vpadhariya
vpadhariya / WordPress-Auto-Login-Script.php
Last active August 31, 2023 19:15
WordPress Auto Login Script
<?php
// Set a veriable for redirection (Optional)
$redirect_to = '';
/**
* WordPress Auto login script
*/
if(!is_user_logged_in())
{
@vpadhariya
vpadhariya / widgetFactory.php
Created August 6, 2015 14:20
Yii 1.1.16 Widget Factory Setting -- (put them under protected/config/widgetFactory.php) and in main.php file include using "CMap::mergeArray()" method
<?php
/**
* Common Settings for widgets across whole project
* @reference : http://www.yiiframework.com/doc/api/1.1/CWidgetFactory
* Based on Bootstrap CSS class
*/
return array(
'components' => array(
'widgetFactory' => array( // Default properties for some widgets
@vpadhariya
vpadhariya / GenerateBaseModelsController.php
Last active August 10, 2017 08:16
Yii2 Generate Base models (put this file into your yii2 project under console/controller/GenerateBaseModelsController.php) and run php yii generate-base-models
<?php
namespace console\controllers;
use Yii;
/**
* Controller to Generate base models
* NOTE : make sure you are using Development Environment.
* @author digitize