Skip to content

Instantly share code, notes, and snippets.

@afsalrahim
afsalrahim / user_info.php
Last active July 6, 2023 04:54
Show user information like IP address, useragent
<?php
/**
* Show user information like IP address, useragent
**/
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$referrer = $_SERVER['HTTP_REFERER'];
if ($referrer == "") {
@afsalrahim
afsalrahim / add_viewport_meta_tag.php
Created March 25, 2016 17:03
Add Viewport meta tag for mobile browsers - Wordpress theme code
<?php
/** Add Viewport meta tag for mobile browsers */
add_action( 'genesis_meta', 'add_viewport_meta_tag' );
function add_viewport_meta_tag() {
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0"/>';
}
@afsalrahim
afsalrahim / sample_showads_functions.php
Last active March 25, 2016 10:03
A Sample Adsense Ads as shortcode for wordpress
<?php
add_shortcode('showads468x60', 'ad_display');
function ad_display() {
return '<div>
<script type="text/javascript"><!--
google_ad_client = "ca-pub-3433716058123456";
/* DigitCodes inPost 468x60 */
google_ad_slot = "9644241234";
google_ad_width = 468;
google_ad_height = 60;
@afsalrahim
afsalrahim / showads_functions.php
Last active March 25, 2016 10:08
Creating wordpress shortcodes
<?php
/**
* Add shortcode for wordpress.
* Usage:
* - Add the below function in your functions.php file.
* - Replace [YOUR ADSENSE AD CODE] with javascript ad code obtained from adsense.
**/
add_shortcode('showads468x60', 'ad_display');
function ad_display() {
@afsalrahim
afsalrahim / php_bbcode_parser.php
Last active April 16, 2024 12:18
A simple PHP BBCode Parser function
<?php
/**
* A simple PHP BBCode Parser function
*
* @author Afsal Rahim
* @link http://digitcodes.com/create-simple-php-bbcode-parser-function/
**/
//BBCode Parser function
@afsalrahim
afsalrahim / genesis_custom_sidebar.php
Last active September 19, 2018 05:37
Show Custom Sidebar for Specific Page for Genesis Theme
<?php
/**
* Show Custom Sidebar for Specific Page
*
* @author Afsal Rahim
* @link http://digitcodes.com/show-custom-sidebar-for-specific-pages-in-wordpress-using-genesis/
*/
// Registering new sidebar