Skip to content

Instantly share code, notes, and snippets.

View hsquareweb's full-sized avatar

Hassan Elhassan hsquareweb

View GitHub Profile
@hsquareweb
hsquareweb / gist:4111243
Created November 19, 2012 15:23
WP: Facebook Open Graph Sharing
<!-- Make the content easily recognizable by social networks, we can use the Open Graph (http://ogp.me) spesification so when somebody shares our content, the social network can show accurate information about the page that is shared. -->
<!-- Add to functions.php -->
function opengraph_for_posts() {
if ( is_singular() ) {
global $post;
setup_postdata( $post );
$og_type = '<meta property="og:type" content="article" />' . "\n";
$og_title = '<meta property="og:title" content="' . esc_attr( get_the_title() ) . '" />' . "\n";
$og_url = '<meta property="og:url" content="' . get_permalink() . '" />' . "\n";
@hsquareweb
hsquareweb / gist:4089830
Created November 16, 2012 18:46
PHP: $_GET
<!-- Check URL for a specific string -->
<?php
if ($_GET['string'] === "value") {
echo '';
}
elseif ($_GET['string']) {
echo '';
}
else {
echo '';
@hsquareweb
hsquareweb / gist:4047330
Created November 9, 2012 18:21
JavaScript: Simple Content Slider
<script type="text/javascript">
$('#tabs div').first().attr('class', 'current');
$('#tabs div').each(function(i) {
i = i + 1;
$(this).attr('id', 'tab-' + i);
if(i !== $('#tabs div').size()) {
$(this).append('<button class="tabPagination" rel="tab-' + (i + 1) + '">Next</button>');
}
if(i !== 1) {
$(this).append('<button class="tabPagination" rel="tab-' + (i - 1) + '">Previous</button>');
@hsquareweb
hsquareweb / gist:3983107
Created October 30, 2012 21:14
SF: States/Countries/Days/Months/Years Form List
//US STATES FOR SITEFINITY
Alabama;Alaska;Arizona;Arkansas;California;Colorado;Connecticut;Delaware;Florida;Georgia;Hawaii;Idaho;Illinois;Indiana;Iowa;Kansas;Kentucky;Louisiana;Maine;Maryland;Massachusetts;Michigan;Minnesota;Mississippi;Missouri;Montana;Nebraska;Nevada;New Hampshire;New Jersey;New Mexico;New York;North Carolina;North Dakota;Ohio;Oklahoma;Oregon;Pennsylvania;Rhode Island;South Carolina;South Dakota;Tennessee;Texas;Utah;Vermont;Virginia;Washington;West Virginia;Wisconsin;Wyoming
//COUNTRIES FOR SITEFINITY
Afghanistan;Albania;Algeria;Andorra;Angola;Antigua & Deps;Argentina;Armenia;Australia;Austria;Azerbaijan;Bahamas;Bahrain;Bangladesh;Barbados;Belarus;Belgium;Belize;Benin;Bhutan;Bolivia;Bosnia Herzegovina;Botswana;Brazil;Brunei;Bulgaria;Burkina;Burundi;Cambodia;Cameroon;Canada;Cape Verde;Central African Rep;Chad;Chile;China;Colombia;Comoros;Congo;Congo {Democratic Rep};Costa Rica;Croatia;Cuba;Cyprus;Czech Republic;Denmark;Djibouti;Dominica;Dominican Republic;East Timor;Ecuador;Egypt;El Salva
@hsquareweb
hsquareweb / link.html
Last active October 11, 2015 20:58
JS: Google Analytics
<!----------------------
1. Download "entourage.min.js"
http://techoctave.com/entourage/download/entourage.zip
---------------------- !>
<!----------------------
2. Add Google Analytics in Header
---------------------- !>
<script src="/js/entourage.min.js"></script>
@hsquareweb
hsquareweb / functions.php
Created October 15, 2012 23:04
WP: Create Simple Custom Post
//CUSTOM POSTS
function PS_Radio() {
register_post_type('PS Radio', array(
'label' => 'PS Radio',
'public' => true,
'has_archive' => true,
'menu_position' => 5,
'menu_icon' => '/wp-content/themes/sample/images/sample.png',
'supports' => array('title','editor','author','thumbnail','excerpt','trackbacks','custom-fields','comments','revisions','page-attributes','post-formats'),
'taxonomies' => array('category','post_tag')
@hsquareweb
hsquareweb / gist:3894991
Created October 15, 2012 20:05
WP: Simple Loop
<?php while (have_posts()) : the_post(); ?>
<h1 class="entry-title"><a href="<?php the_permalink();?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<?php the_content();?>
<?php endwhile; ?>
@hsquareweb
hsquareweb / index.haml
Created October 12, 2012 20:27 — forked from anonymous/index.haml
CSS: Gradient Button for IE9
.button
hello!
@hsquareweb
hsquareweb / gist:3855295
Created October 8, 2012 22:06
jQuery: Beforeunload (Popup on reload & change of page)
$(document).ready(function() {
$(window).bind("beforeunload", function() {
$("a#trigger").click();
return "Text goes here?";
});
});
@hsquareweb
hsquareweb / functions.php
Created October 3, 2012 02:18
WP: Hide Theme Editor From Dashboard
function wpr_remove_editor_menu() {
remove_action('admin_menu', '_add_themes_utility_last', 101);
}
global $remove_submenu_page, $current_user;
get_currentuserinfo();
if($current_user->user_login == 'admin') { //Specify admin name here
add_action('admin_menu', 'wpr_remove_editor_menu', 1);
}