Skip to content

Instantly share code, notes, and snippets.

View makbeta's full-sized avatar

makbeta makbeta

View GitHub Profile
@makbeta
makbeta / functions.php
Last active December 18, 2015 23:59
Updating post info line in Wordpress Genesis-based theme
<?php
// Put the following code in functions.php
//* Customize the post info function
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
return $post_info;
}
//* Remove the post info function
@makbeta
makbeta / wp-social-image-tag.php
Created June 26, 2013 06:30
WordPress: Social media image tag based on featured image field
<?php
function social_media_image() {
global $post;
$output = '';
$featured_image = get_post_featured_image($post->ID, 'medium');
if( $featured_image['id'] != null) {
$output .= '<link rel="img_src" type="image/jpeg" href="'.$featured_image['url'].'" />'."\n";
$output .= '<meta property="og:image" content="'.$featured_image['url'].'"/>'."\n";
@makbeta
makbeta / wp-remove-update-post-meta.php
Created June 26, 2013 06:07
WordPress: Remove/updates categories/tags from posts
//remove tags & categories beneth posts
function my_remove_post_meta($post_meta) {
if (!is_page()) {
return;
// $post_meta = '[post_categories sep="/" before=""] [post_tags sep="/" before=""]';
// return $post_meta;
}
}
@makbeta
makbeta / wp-disable-admin-toolbar.php
Created June 24, 2013 20:30
WordPress: Disable admin toolbar for all subscribers
<?php
/* Place the following piece of code in (init function of) your functions.php */
if(current_user_can('subscriber')) {
show_admin_bar(false);
}
?>
@makbeta
makbeta / wp-tml-custom-field-registration.php
Created June 24, 2013 20:19
WordPress: Add custom profile fields to a Theme My Login registration form
/*
1. create custom user fields with wordpress (see https://gist.github.com/makbeta/5851535 )
2. clone `register-form.php` from /wp-content/plugins/theme-my-login/templates to your theme
3. Add your new field to the registration template
*/
<p>
<label for="subscription">Customer ID</label>
<input type="text" name="subscription" id="subscription<?php $template->the_instance(); ?>" class="input" value="<?php $template->the_posted_value( 'subscription' ); ?>" size="20" /><br />
<span class="description">Please enter your customer ID.</span>
@makbeta
makbeta / wp-profile-fields.php
Last active December 16, 2017 10:47
WordPress: Adding custom user/profile fields manually
function my_show_extra_profile_fields( $user ) { ?>
<div class="subscription-info">
<h3>Subscription Information</h3>
<table class="form-table">
<tr>
<th><label for="subscription">Customer ID</label></th>
<td>
<input type="text" name="subscription" id="subscription" value="<?php echo esc_attr( get_user_meta( $user->ID, 'subscription', 1) ); ?>" class="regular-text" /><br />
<span class="description">Please enter your customer ID.</span>
@makbeta
makbeta / widget-shortcode.php
Created June 17, 2013 22:22
WordPress: add shortcode support in widgets
//add shortcode support in widgets
add_filter('widget_text', 'do_shortcode');
@makbeta
makbeta / cms-device-mobile.js
Created June 13, 2013 19:00
JS for Luminate CMS: redirect users to a different page if they are viewing it in mobile browser
var currentPath = '${path}';
var redirects = [{ "from":"/give-now","to":"http://localhost"},
{"from":"/z-test/responsive-donation-redirect.html","to":"http://localhost"}];
$.getJSON( "/components/mobile/check-setting.jsp", function(data) {
if(data.isMobileDevice) {
if(redirects.length > 0) {
for(i=0; i<redirects.length; i++) {
if(redirects[i].from == currentPath) {
console.log('DNL: We are on a mobile device, redirecting to '+redirects[i].to);
window.location = redirects[i].to;
@makbeta
makbeta / wait-for-jquery-to-load.js
Created June 12, 2013 22:33
JS: Add/execute Scripts after jQuery is asynchronosly loaded
function addScriptsWhenJQueryIsLoaded(myScripts) {
var numScripts = myScripts.length;
if (window.jQuery){
//possibly some other JQuery checks to make sure that everything is loaded here
console.log('Debug: jQuery loaded, loading scripts, number of script is '+numScripts);
window.$ = jQuery.noConflict();
var $anchor = jQuery('#overlay');
@makbeta
makbeta / clo-logged-in.html
Created May 16, 2013 17:43
Luminate Online: Test if user is logged in
[[?xxnullxx::x[[S1:user_name]]x::
<!-- this person is not logged in -->
::
<!-- This person is logged in -->
]]