Skip to content

Instantly share code, notes, and snippets.

View madanpraba's full-sized avatar

Praba madanpraba

  • South Korea
View GitHub Profile
@jakebellacera
jakebellacera / ICS.php
Last active July 10, 2024 11:27
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
@strangerstudios
strangerstudios / gist:2232405
Created March 29, 2012 01:56
Pay Per Post for WordPress with Paid Memberships Pro
<?php
/*
Limiting posts per user.
Enable the Paid Memberships Pro plugin and then add this code to your functions.php or as a stand alone plugin.
Be sure to read through this code carefully. Update each function to suit your needs.
This code has not been tested. Feel free to post issues in the comments.
*/
//increment post limit when checking out
function my_pmpro_after_checkout($user_id)
{
@tobedoit
tobedoit / gist:4146948
Created November 26, 2012 07:01
Wordpress: display current user role
/* Display Current User Role *************************************************************************** */
/* http://wordpress.org/support/topic/how-to-get-the-current-logged-in-users-role ********************** */
/* !로그인 회원역할 표시 *********************************************************************************** */
/* <?php echo get_current_user_role(); ?> in your template ******************************************** */
function get_current_user_role() {
global $wp_roles;
$current_user = wp_get_current_user();
$roles = $current_user->roles;
$role = array_shift($roles);
return isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : false;
@Ceekay0
Ceekay0 / single.php
Last active July 21, 2021 04:36
Wordpress: Show related posts by tag. The tag the snippet is looking for needs to be setup in the WP admin interface using the custom value keyword = your_tag Output is as unordered list with links. Snippet is fully i8n compatible You can use this in any Wordpress Template, not just single.php
<?php
/** SHOW RELATED POSTS BY TAG, TAG IS INDICATED BY CUSTOM PROPERTY keyword => tag **/
/** check for custom property **/
$key = 'keyword';
$keyword = get_post_meta($post->ID, $key, true);
if ($keyword != '') {
/** set max number of posts **/
$num_posts = '4';
/** setup the query array **/
@Jany-M
Jany-M / wp_ics.php
Last active September 19, 2023 03:15 — forked from jakebellacera/ICS.php
[WP] Generate a downloadable .ics file from any WordPress post or custom post type
<?php
/*
For a better understanding of ics requirements and time formats
please check https://gist.github.com/jakebellacera/635416
*/
// UTILS
// Check if string is a timestamp
@davilera
davilera / 01-limit.php
Created August 21, 2017 09:15
WordPress Image Size Limit
<?php
function nelio_max_image_size( $file ) {
$size = $file['size'];
$size = $size / 1024;
$type = $file['type'];
$is_image = strpos( $type, 'image' ) !== false;
$limit = 250;
$limit_output = '250kb';
@warnakey
warnakey / ProfilePage Schema Example
Last active July 16, 2024 20:52
ProfilePage Schema Example in JSON-LD
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "ProfilePage",
"mainEntity" : {
"@type" : "Person",
"name" : "Jane Doe",
"givenName" : "Jane",
"familyName" : "Doe",
"email" : "jdoe@examplelaw.com",
@pbrocks
pbrocks / record-current-datetime-at-login.php
Created November 11, 2022 14:24
Record date and time information at login.
<?php
add_action( 'wp_login', 'record_current_datetime_at_login', 10, 2 );
/**
* Record Time and Date at login as a readable string.
* Save in user meta.
*
* @param string $user_login login_name
* @param object $user WP_User object
* @return string Date, time, timezone, offset
*/