Skip to content

Instantly share code, notes, and snippets.

View lenasterg's full-sized avatar

Lena Stergatou lenasterg

View GitHub Profile
@lenasterg
lenasterg / Url.php
Created January 11, 2012 14:02 — forked from wilmoore/Url.php
Custom Zend Framework Url Helper (honors existing query string -- works well for pagination links, etc.)
<?php
/**
* @copyright ...
* @author Wil Moore III <wil.moore@wilmoore.com>
*/
use Zend_View_Helper_Url as Url;
/**
* View Helper to attach a query-string to URL
@lenasterg
lenasterg / gist:64989b9711273fbd9844
Created October 1, 2014 10:22
Wordpress Nav menus administration. Open all metaboxes by default.
/**
* Show by default posts,tags and post-format meta-boxes on wp-admin/nav-menus.php
* @param array $meta_boxes
* @return array
* @author Stergatu Lena <stergatu@cti.gr>
* @version 1, 25/9/2014
*/
function ls_initial_nav_menu_meta_boxes( $meta_boxes ) {
if ( ! (in_array( 'add-post', $meta_boxes )) ) {
$meta_boxes[] = 'add-post';
@lenasterg
lenasterg / bp_restrict_group_creations
Last active August 29, 2015 14:23
Buddypress. Restrict group creation to admins, editors
function LS_allow_group_creation( $can_create, $restricted = null ) {
if (current_user_can('edit_others_posts') ) {
return true;
}
else {
return false;
}
}
add_filter( 'bp_user_can_create_groups', 'LS_allow_group_creation' );
@lenasterg
lenasterg / deleteExpiredTransients.php
Created June 3, 2016 13:58
Delete expired transient
<?php
require_once('wp-load.php') ;
$expired = $wpdb->get_col( "SELECT option_name FROM
wp_options
WHERE option_name LIKE '_transient_timeout%' AND option_value <
$time
;
" ) ;
@lenasterg
lenasterg / prettyPhotoDownload.php
Last active June 15, 2017 09:52
Adds download functionality to prettyPhoto WordPress plugin. Put the code into yours theme functions.php or the file into mu-plugins folder
add_action('wp_footer','ls_prettyPhoto_Download');
/**
* Adds download functionality to prettyPhoto plugin
* @author lenasterg
*/
function ls_prettyPhoto_Download() {
echo '
<style>.pp_download{ background: #ccc; border-radius: 3px; height: 25px; padding: 4px;}</style>
@lenasterg
lenasterg / countryUserField.php
Last active July 10, 2017 14:15
Wordpress: Add country field to user profile
<?php
/* Save selected data */
add_action( 'bp_core_signup_user', 'save_user_fields' );
add_action( 'personal_options_update', 'save_user_fields' );
add_action( 'edit_user_profile_update', 'save_user_fields' );
function save_user_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) {
return false;
}
@lenasterg
lenasterg / bp_member_type_on_signup.php
Last active July 11, 2017 10:34
BuddyPress Members Type: Assist member type on signup
add_action('bp_signup_profile_fields', 'Add_user_member_type');
function Add_user_member_type() {
$member_types = bp_get_member_types(array(), 'objects');
if (count($member_types) > 0) {
echo '<h3>Select your occupation</h3>';
// Loop in member types to build the tabs
foreach ($member_types as $member_type) :
?>
@lenasterg
lenasterg / bp_member_type_directory.php
Last active July 11, 2017 13:09
This gist works when there are already bp_member_types. It adds tab for each member type which has_directory and at least one active user of this bp_member_type
////-----
// 2. display members type tabs
function ls_display_members_directory_tabs() {
$member_types = bp_get_member_types( array(), 'objects' );
// Loop in member types to build the tabs
foreach ( $member_types as $member_type ) :
@lenasterg
lenasterg / post_on_user_register.php
Last active July 17, 2017 10:04
Post on user register
<?php
//1. dimiourgia pending posts me tin eggrafi toy xristi
//@todo na pernaei custom post type
function ls_create_new_user_posts($user_id) {
//The post_author is the id of the superadmin
$post_author = '1';
$user = get_user_by('id', $user_id);
if (!$user_id > 0) {
@lenasterg
lenasterg / export-opml.php
Created August 3, 2017 09:15
Exports blogroll plugins from a wordpress site.
<?php
require_once( dirname( __FILE__ ) . '/wp-load.php' );
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
/*
Plugin Name: Export Blogroll in OPML Format
Plugin URI: http://w3.ipublicis.com/
Description: Exports your public blogroll in OPML format to a file on blog root.
Version: 1.0
Author: Lopo Lencastre de Almeida - iPublicis.com