Skip to content

Instantly share code, notes, and snippets.

View gwin's full-sized avatar

Greg Winiarski gwin

View GitHub Profile
<?php
add_filter("wpjb_form_init_alert", "my_form_init_alert");
function my_form_init_alert($form) {
$e = $form->create("frequency", "select");
$e->addOption("1", "1", "Daily");
$e->addOption("2", "2", "Weekly");
$e->addClass("wpjb-widget-alert-frequency");
$form->addElement($e, "alert");
<?php
// Assign a filter
add_filter( 'wphd_file_upload', 'my_wphd_file_upload' );
/**
* Check if uploaded file extension is valid.
*
* This function is executed using 'wphd_file_upload' filter,
* it stops file upload using die() if incorrect file type is sent
function wpadverts_mal_save_advert( $post_ID, $post, $update ) {
if( !isset( $_POST ) || empty( $_POST ) ) {
return;
}
include_once ADVERTS_PATH . '/includes/class-form.php';
$form = new Adverts_Form;
$form->load( Adverts::instance()->get( "form_mal" ) );
<?php
add_filter( "adverts_form_load", "my_adverts_form_load" );
function my_adverts_form_load( $form ) {
if( $form['name'] != "advert" ) {
return $form;
}
foreach( $form["field"] as $key => $field ) {
if( in_array($field["name"], array("adverts_price", "adverts_location", "adverts_phone") ) ) {
<?php
add_shortcode("current_user_id", "current_user_id");
function current_user_id() {
$user = wp_get_current_user();
if( isset( $user->ID ) ) {
return $user->ID;
} else {
return "0";
@gwin
gwin / cowe-trigger-navigation-thumbnails.php
Created November 17, 2023 12:37
Cowe Trigger Navigation Thumbnails
<?php
add_action( "wp_footer", function() {
if( ! is_singular( 'advert' ) ) {
return;
}
?>
<script type="text/javascript">
jQuery(function($) {
$(".my-trigger-thumbnails").on("click", function(e) {