Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / isotope-init.js
Created April 28, 2020 20:58 — forked from neilgee/isotope-init.js
Isotope Filter Custom Taxonomy on CPT Archive Page
jQuery(document).ready(function($){
var $grid = $('.grid').isotope({
itemSelector: '.grid-item',
percentPosition: true,
layoutMode: 'fitRows',
});
// Layout Isotope after each image loads
$grid.imagesLoaded().progress( function() {
@dexit
dexit / accordion-repeater-shortcode.php
Created April 28, 2020 20:58 — forked from neilgee/accordion-repeater-shortcode.php
Bootstrap Accordion ACF Repeater
<?php //<~ don't add me in - add the code below in functions.php
add_shortcode( 'wpb_bs_accordion_acf', 'wpb_bs_accordion_acf' );
/**
* Bootstrap Accordion Repeater Field
*/
function wpb_bs_accordion_acf() {
ob_start();
<?php //<~ don't add me in - code below goes into functions.php
add_shortcode( 'wpb_accordion_acf', 'wpb_accordion_acf' );
/**
* Accordion Repeater Field
*/
function wpb_accordion_acf() {
ob_start();
// *Repeater
@dexit
dexit / login-out.php
Created April 28, 2020 20:59 — forked from neilgee/login-out.php
Login/Logout Shortcode
<?php //<~ remove if using in functions.php
add_shortcode( 'login_logut', 'login_logut' );
/**
* Add a login/logout shortcode button
* @since 1.0.0
*/
function login_logut() {
ob_start();
if (is_user_logged_in()) :
@dexit
dexit / acf-change-file-upload-directory.php
Created April 29, 2020 10:25 — forked from BODA82/acf-change-file-upload-directory.php
Change the upload directory of Advanced Custom Fields file upload field.
<?php
// ACF upload prefilter
function gist_acf_upload_dir_prefilter($errors, $file, $field) {
// Only allow editors and admins, change capability as you see fit
if( !current_user_can('edit_pages') ) {
$errors[] = 'Only Editors and Administrators may upload attachments';
}
// This filter changes directory just for item being uploaded
@dexit
dexit / functions.php
Created April 29, 2020 10:25 — forked from BODA82/functions.php
Custom WordPress Login Page
<?php
/********************************************************************************************
Example for customizing the WordPress login screen using your theme's functions.php file.
For @halo-diehard on wordpress.org forum:
https://wordpress.org/support/topic/codex-unclear-regarding-custom-login-page/
Relevant CODEX doc:
https://codex.wordpress.org/Customizing_the_Login_Form
*******************************************************************************************/
@dexit
dexit / custom-file-upload-form-in-wordpress.php
Created April 29, 2020 14:48 — forked from shamimmoeen/custom-file-upload-form-in-wordpress.php
Create custom file upload form in WordPress
<?php
if ( ! function_exists( 'wpcfu_output_file_upload_form' ) ) {
/**
* Output the form.
*
* @param array $atts User defined attributes in shortcode tag
*/
function wpcfu_output_file_upload_form( $atts ) {
@dexit
dexit / gf-acf-multi-file-upload.php
Created April 29, 2020 18:41 — forked from yanknudtskov/gf-acf-multi-file-upload.php
Connect Gravity Forms Multi File Upload and Advanced Custom Fields Repeating File-Field #gravity-forms #acf
<?php
/**
* Connect Gravity Forms Multi File Upload and Advanced Custom Fields Repeating File-Field and Gallery Field
* REMEMBER: Set ID correctly for forms and fields AND set acf field names
*/
add_action( 'gform_after_submission_4', 'add_form_after_submission', 10, 2 );
function add_form_after_submission( $entry, $form ) {
//getting post
$post = get_post( $entry['post_id'] );
<?php
/**
* Create a new media library entry with a file upload on gravity form submission.
* @see https://joshuadnelson.com/connect-gravity-forms-file-upload-to-acf-gallery-field/
* @author Joshua David Nelson, [email protected]
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'jdn_add_image_to_media_library', 10, 2 );
function jdn_add_image_to_media_library( $entry, $form ) {
@dexit
dexit / gp-media-library-attach-media.php
Created May 1, 2020 08:42 — forked from spivurno/gp-media-library-attach-media.php
Gravity Perks // GP Media Library // Auto-attach Uploaded Files to GF-generated Post
</php
/**
* Gravity Perks // GP Media Library // Auto-attach Uploaded Files to GF-generated Post
* http://gravitywiz.com/documentation/gp-media-library/
*/
add_action( 'gform_after_create_post', function( $post_id, $entry, $form ) {
if( is_callable( 'gp_media_library' ) ) {
$file_ids = gp_media_library()->get_file_ids_by_entry( $entry, $form );
if( $file_ids ) {
foreach( $file_ids as $field_id => $_file_ids ) {