Skip to content

Instantly share code, notes, and snippets.

View govindak's full-sized avatar

Govinda Khatiwada govindak

View GitHub Profile
// SPDX-License-Identifier: Unlicensed
/*
Welcome to AAG
The Official Token for the AagTokens Community!
@govindak
govindak / download.php
Created December 21, 2019 09:30
wordpress downloader
<?php
// Download utility
ini_set("memory_limit", "-1");
set_time_limit(0);
function shailan_get_file( $url, $target ){
echo "<h3>Downloading file..</h3><br />";
if( FALSE !== file_put_contents( $target . "/" . basename($url), file_get_contents( $url ) ) ){
return $target . "/" . basename($url);
}
@govindak
govindak / foreachloop
Created September 27, 2018 17:46
foreach loop odd/even
<?php $counter = "";
foreach ( $columns_values as $columns_value ) {
$counter +=1;
// all my var stuff here
?>
<?php if($counter == 1) { ?>
<div class="columns-wrapper odd">
function my_form_shortcode() {
ob_start();
get_template_part('my_form_template');
return ob_get_clean();
}
add_shortcode( 'my_form_shortcode', 'my_form_shortcode' );
@govindak
govindak / functions.php
Created February 19, 2018 18:43
add active class wp menu
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}
@govindak
govindak / gist:31dbbfb84d7a24337a0a80fa25068755
Created August 18, 2016 02:51
Memberpress Create transaction programatically.
$sub = new MeprSubscription();
$sub->user_id = $user_ID;
$sub->product_id = 123;
$sub->price = 12.99;
$sub->total = 12.99;
$sub->period = 1;
$sub->period_type = 'months';
$sub->status = MeprSubscription::$active_str;
$sub_id = $sub->store();
@govindak
govindak / auto_enroll.php
Created August 17, 2016 19:39 — forked from supercleanse/auto_enroll.php
Automatically create a lifetime transaction for a specific product each time a user registers.
<?php
if(is_plugin_active('memberpress/memberpress.php')) {
add_action( 'user_register', 'mp_auto_enroll' );
//add_action( 'gform_user_registered', 'mp_auto_enroll', 10, 4 );
function mp_auto_enroll($user_id, $user_config=array(), $entry='', $user_pass='') {
$txn = new MeprTransaction();
$txn->user_id = $user_id;
@govindak
govindak / custom_post_type_cf7_dropdown.php
Created May 24, 2016 10:52 — forked from alkrauss48/custom_post_type_cf7_dropdown.php
Adding a custom Wordpress shortcode for building a dynamic dropdown of post type titles with Contact Form 7
wpcf7_add_shortcode('postdropdown', 'createbox', true);
function createbox(){
global $post;
extract( shortcode_atts( array( 'post_type' => 'some_post_type',), $atts ) );
$args = array('post_type' => $post_type );
$myposts = get_posts( $args );
$output = "<select name='postType' id='postType' onchange='document.getElementById(\"postType\").value=this.value;'><option></option>";
foreach ( $myposts as $post ) : setup_postdata($post);
$title = get_the_title();
$output .= "<option value='$title'> $title </option>";
@govindak
govindak / wp.sh
Created October 6, 2015 16:37 — forked from bgallagh3r/wp.sh
Wordpress: Bash Install Script -- Downloads latest WP version, updates wp-config with user supplied DB name, username and password, creates and CHMOD's uploads dir, copies all the files into the root dir you run the script from, then deletes itself!
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Database Name: "
read -e dbname
echo "Database User: "
read -e dbuser
echo "Database Password: "
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array