Skip to content

Instantly share code, notes, and snippets.

View bappi-d-great's full-sized avatar

Bappi D great bappi-d-great

View GitHub Profile
@bappi-d-great
bappi-d-great / code.php
Created June 14, 2020 12:48
Simple Model Class
<?php
class Model {
protected function __construct() {
parent::__construct();
}
public static function get_instance() {
static $Inst = null;
@bappi-d-great
bappi-d-great / code.php
Created June 14, 2020 12:10
Passing php data to external JS file
<?php
class Localize {
private $_data = [];
private function __construct () {}
static public function get_instance() {
static $Inst = null;
@bappi-d-great
bappi-d-great / wpmudev-coursepress-completion-email.php
Last active September 6, 2019 06:07 — forked from wpmudev-sls/wpmudev-coursepress-completion-email.php
[ CoursePress 2 ] - Email Notifications on Completion. Sends an email notification to the Student upon Course Completion
<?php
/**
* Plugin Name: [ CoursePress 2 ] - Email Notifications on Completion
* Plugin URI: https://premium.wpmudev.org/
* Description: Sends an email notification to the Student upon Course Completion
* Author: Alessandro Kaounas @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/
@bappi-d-great
bappi-d-great / code.php
Created November 8, 2018 07:58
Forminator add more email macro
<?php
// Email macro: {last-post-link}
add_filter( 'forminator_replace_variables', function( $content, $content_before_replacement ) {
$args = array( 'numberposts' => '1' );
$recent_posts = wp_get_recent_posts( $args );
$post = '<a href="' . get_permalink( $recent_posts[0]['ID'] ) . '">' . get_the_title( $recent_posts[0]['ID'] ) . '</a>';
return str_replace( '{last-post-link}', $post, $content );
@bappi-d-great
bappi-d-great / code.php
Created October 24, 2018 13:23
WPMU DEV Forminator phone number validation
<?php
// Assuming one phone field in a form
add_filter( 'forminator_custom_form_submit_errors', 'check_form_data', 99, 3 );
function check_form_data( $submit_errors, $form_id, $field_data_array ) {
$valid = false;
foreach( $field_data_array as $val ) {
if( $val['name'] == 'phone-1' ) {
$phone = $val['value'];
@bappi-d-great
bappi-d-great / add_quiz_entries.php
Created August 15, 2018 22:09
Method: add_quiz_entries()
<?php
$quiz_id = 7;
$entry_metas = array(
array(
'name' => 'text-1',
'value' => 'Text Input Value'
),
array(
'name' => 'text-1',
'value' => 'Text Input Value'
@bappi-d-great
bappi-d-great / add_quiz_entry.php
Created August 15, 2018 22:05
Method: add_quiz_entry()
<?php
$quiz_id = 7;
$entry_meta = array(
'name' => 'text-1',
'value' => 'Text Input Value'
);
Forminator_API::add_quiz_entry( $quiz_id, $entry_meta );
@bappi-d-great
bappi-d-great / update_poll_entry.php
Created August 15, 2018 22:01
Method: update_poll_entry()
<?php
$poll_id = 7;
$entry_id = 32;
$entry_meta = array(
'name' => 'text-1',
'value' => 'Text Input Value'
);
Forminator_API::update_poll_entry( $poll_id, $entry_id, $entry_meta );
@bappi-d-great
bappi-d-great / add_poll_entries.php
Created August 15, 2018 21:51
Method: add_poll_entries()
<?php
$poll_id = 7;
$entry_metas = array(
array(
'name' => 'text-1',
'value' => 'Text Input Value'
),
array(
'name' => 'email-1',
@bappi-d-great
bappi-d-great / add_form_entries.php
Last active August 15, 2018 21:51
Method: add_form_entries()
<?php
$form_id = 7;
$entry_meta= array(
array(
'name' => 'text-1',
'value' => 'Text Input Value'
),
array(
'name' => 'email-1',