Skip to content

Instantly share code, notes, and snippets.

View INDIAN2020's full-sized avatar

Gogula Sivannarayana INDIAN2020

View GitHub Profile
@INDIAN2020
INDIAN2020 / featured-images-in-rss-feed.php
Created June 18, 2018 07:41 — forked from yanknudtskov/featured-images-in-rss-feed.php
Display Featured Images In RSS Feed A picture tells a thousand words, as they say. Encourage subscribers to visit your site rather than just read your content in their RSS feed by displaying featured images by default:
add_filter('widget_text', 'enable_php_code', 99);
function enable_php_code ($text)
{
if (strpos($text, '<' . '?') !== false)
{
ob_start();
eval('?' . '>' . $text);
$text = ob_get_contents();
ob_end_clean();
// Temp Maintenance - with http response 503 (Service Temporarily Unavailable)
// This will only block users who are NOT an administrator from viewing the website.
function wp_maintenance_mode()
{
if(!current_user_can('edit_themes') || !is_user_logged_in())
{
wp_die('Maintenance, please come back soon.', 'Maintenance - please come back soon.', array('response' => '503'));
}
}
<?php
function showalltags() {
$tags = get_tags();
$html;
foreach ($tags as $tag){
$tag_link = get_tag_link($tag->term_id);
$html .= "<a href='{$tag_link}' title='{$tag->name} Tag' class='{$tag->slug}'>";
@INDIAN2020
INDIAN2020 / enable-wordpress-media-trash.php
Created June 18, 2018 07:41 — forked from yanknudtskov/enable-wordpress-media-trash.php
Enabling the "Trash" Feature for Media Files With MEDIA_TRASH
define( 'MEDIA_TRASH', true );
@INDIAN2020
INDIAN2020 / wp-lang.php
Created June 18, 2018 07:41 — forked from yanknudtskov/wp-lang.php
Setting WPLANG Dynamically in Multilingual Websites
<?php
// start the session
session_start();
// if there's a "lang" parameter in the URL...
if( isset( $_GET[ 'lang' ] ) ) {
// ...set a session variable named WPLANG based on the URL parameter...
$_SESSION[ 'WPLANG' ] = $_GET[ 'lang' ];
// -----------
// Debugger that shows view port size. Helps when making responsive designs.
// -----------
function showViewPortSize(display) {
if(display) {
var height = jQuery(window).height();
var width = jQuery(window).width();
jQuery('body').prepend('<div id="viewportsize" style="z-index:9999;position:fixed;top:40px;left:5px;color:#fff;background:#000;padding:10px">Height: '+height+'<br>Width: '+width+'</div>');
jQuery(window).resize(function() {
@INDIAN2020
INDIAN2020 / create_user.php
Created June 18, 2018 07:04 — forked from yanknudtskov/create_user.php
Create WP User
public function custom_create_user($user_name, $first_name, $last_name, $email_address, $user_role = 'subscriber')
{
$user_id = username_exists( $user_name );
if( $user_id != null )
{
throw New Exception('Username already exists!');
}
if ( email_exists($email_address) == true )
@INDIAN2020
INDIAN2020 / scroll-top.js
Created June 18, 2018 07:04 — forked from yanknudtskov/scroll-top.js
jQuery scroll to top
$(function() {
//Check to see if the window is top if not then display button
$(window).scroll( function() {
if ($(this).scrollTop() > 100) {
$('#scroll-top').fadeIn();
} else {
$('#scroll-top').fadeOut();
}
});
@INDIAN2020
INDIAN2020 / top-parent.php
Created June 18, 2018 07:04 — forked from yanknudtskov/top-parent.php
Get topmost parent of WordPress Page
function get_top_parent_page_id() {
global $post;
$ancestors = $post->ancestors;
// Check if page is a child page (any level)
if ($ancestors) {
// Grab the ID of top-level page from the tree