Skip to content

Instantly share code, notes, and snippets.

Avatar

Bappi D great bappi-d-great

View GitHub Profile
@bappi-d-great
bappi-d-great / code.php
Created Jun 14, 2020
Simple Model Class
View code.php
<?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 Jun 14, 2020
Passing php data to external JS file
View code.php
<?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 Sep 6, 2019 — 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
View wpmudev-coursepress-completion-email.php
<?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 Nov 8, 2018
Forminator add more email macro
View code.php
<?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 Oct 24, 2018
WPMU DEV Forminator phone number validation
View code.php
<?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 Aug 15, 2018
Method: add_quiz_entries()
View add_quiz_entries.php
<?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 Aug 15, 2018
Method: add_quiz_entry()
View add_quiz_entry.php
<?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 Aug 15, 2018
Method: update_poll_entry()
View update_poll_entry.php
<?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 Aug 15, 2018
Method: add_poll_entries()
View add_poll_entries.php
<?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 Aug 15, 2018
Method: add_form_entries()
View add_form_entries.php
<?php
$form_id = 7;
$entry_meta= array(
array(
'name' => 'text-1',
'value' => 'Text Input Value'
),
array(
'name' => 'email-1',