Skip to content

Instantly share code, notes, and snippets.

View vfontjr's full-sized avatar

Victor M. Font Jr. vfontjr

View GitHub Profile
@vfontjr
vfontjr / populate_formidable_drop_down.php
Created April 7, 2020 17:11
Snippet to retrieve filtered values from a specific Formidable form and populate a dropdown
<?php
add_filter( frm_setup_new_fields_vars, frm_populate_classes, 20, 2 );
add_filter( frm_setup_edit_fields_vars, frm_populate_classes, 20, 2 ); //use this function on edit too
function frm_populate_classes( $values, $field ){
global $wpdb;
$prefix = $wpdb->prefix;
$frm_items = $prefix . 'frm_items';
$frm_item_metas = $prefix . 'frm_item_metas';
<?php
add_shortcode( 'count_entries', 'fm_count_entry_records' );
function fm_count_entry_records( $atts ) {
/* define/use variables to access WordPress database functions
* and Formidable's tables
*/
global $wpdb;
$prefix = $wpdb->prefix;
$frm_items = $prefix . 'frm_items';
@vfontjr
vfontjr / process-text-file.php
Created April 9, 2020 08:31
Working Example of Code to process a text file and convert to csv to import into Formidable Forms.
<?php
$file_to_process = "raw-content.csv";
$processed_functions = "processed_content.csv";
$header_record = '"Name","Entry Type","Formidable Pro","Function Parent Class","File Location","Function Declaration"';
$fh_src = fopen($file_to_process, 'r');
$fh_tgt = fopen($processed_functions, 'w');
$r = fwrite($fh_tgt, $header_record . PHP_EOL);
<?php
/* Font Awesome Pro 5
* if using Atomic Blocks and not in the editor
* remove the plugin's Font Awesome Free styles
*/
if ( wp_style_is( 'atomic-blocks-fontawesome' ) ) {
wp_dequeue_style( 'atomic-blocks-fontawesome' );
wp_deregister_style( 'atomic-blocks-fontawesome' );
@vfontjr
vfontjr / default-value-by-option-param.js
Last active April 20, 2020 19:35
Source code for https://formidable-masterminds/pass-option-in-query-string-set-select-value/
<script>
jQuery(document).ready(function($) {
"use strict";
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
<?php
function vmf_post_date_column_time( $h_time, $post ) {
// If post is scheduled then add the time to the column output
if ($post-&gt;post_status == 'future') {
$h_time .= '<br>' . get_post_time( 'g:i a', false, $post );
}
// Return the column output
return $h_time;
}
[subtabs title="Additional Info"]
[subtab title="Permanent Address"]
<h2>Permanent Address</h2>
<div id="frm_field_[id]_container" class="frm_form_field form-field [required_class][error_class]">
<label for="field_[key]" class="frm_primary_label">[field_name]
<span class="frm_required">[required_label]</span>
</label>
[input]
[if description]<div class="frm_description">[description]</div>[/if description]
[if error]<div class="frm_error">[error]</div>[/if error]
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table style="width: 80%; border: 2px solid #000000; background-color: #ffffcc;" cellspacing="0" cellpadding="0" align="center">
<tbody>
<tr>
<td style="text-align: center; border-width: thin; border-color: #000000; border-right-style: solid; font-family: Arial, Helvetica, sans-serif;">Data</td>
<?php
add_filter( 'wp_nav_menu_args', 'my_custom_ul_class' );
function my_custom_ul_class( $args ) {
$args['menu_class'] .= ' my-custom-class'; return $args;
}
<script>
jQuery(document).ready( function($) {
"use strict";
$("[id^='featured-post-']").find('img').addClass('my-awesome-class');
});
</script>