Skip to content

Instantly share code, notes, and snippets.

View groupewibi's full-sized avatar

Wibi groupewibi

  • Groupe Wibi
  • France
View GitHub Profile
@groupewibi
groupewibi / ACF Form : Change Title Name and Instructions
Last active May 25, 2019 18:01
Changing the title and the label of the Title Post using ACF Form
function my_acf_prepare_field( $field ) {
if ( is_page('page-name') ) {
$field['label'] = "My new title";
$field['instructions'] = "My new instruction";
}
if ( $field ) { return $field; } else { exit; }
add_filter( 'acf/get_valid_field', 'change_post_content_type');
function change_post_content_type( $field ) {
if($field['type'] == 'wysiwyg') {
$field['tabs'] = 'visual'; $field['toolbar'] = 'basic'; $field['media_upload'] = 0;
}
return $field; }
@groupewibi
groupewibi / gist:8024275c2bd1958d0107944d87337d70
Created January 10, 2018 18:17
Acf Form : Changing the Label and Instruction of the Wysiwig Post_content field using prepare/field
function my_acf_prepare_field( $field ) {
$field['label'] = "My new title";
$field['instructions'] = "My new instruction";
if ( $field ) { return $field; } else { exit; }
}
add_filter('acf/prepare_field/name=_post_content', 'my_acf_prepare_field');
/* in ...application/modules/quotes/views/modal_create_quote.php : replace --------*/
<select name="client_id" id="create_quote_client_id" class="client-id-select form-control"
autofocus="autofocus">
<?php if (!empty($client)) : ?>
<option value="<?php echo $client->client_id; ?>"><?php _htmlsc(format_client($client)); ?></option>
<?php endif; ?>
</select>
/* ----- BY --------*/
@groupewibi
groupewibi / functions.php
Created April 21, 2018 12:39 — forked from yratof/functions.php
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_thumbnail_uri( $video_uri ) {
$thumbnail_uri = '';
// determine the type of video and the video id
$video = parse_video_uri( $video_uri );
// get youtube thumbnail
@groupewibi
groupewibi / gf-to-acf-file.php
Created April 22, 2018 23:46 — forked from joshuadavidnelson/gf-to-acf-file.php
Connect a Gravity Form upload field to ACF Gallery Field without a *New* Post Creation on Submission, requires the JDN_Create_Media_File class from https://gist.github.com/joshuadavidnelson/164a0a0744f0693d5746
<?php
/**
* Attach images uploaded through Gravity Form to ACF Gallery Field
*
* @author Joshua David Nelson, [email protected]
* @return void
*/
$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_set_post_acf_gallery_field', 10, 2 );
function jdn_set_post_acf_gallery_field( $entry, $form ) {
@groupewibi
groupewibi / gist:2c459ce26154f43e53d283bebb2b213f
Created April 22, 2018 23:52 — forked from hissy/gist:7352933
[WordPress] Add file to media library programmatically
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@groupewibi
groupewibi / encodeGPolyline.js
Created May 18, 2018 02:29 — forked from abarth500/encodeGPolyline.js
Generate Encoded Polyline Algorithm Format for Google Static Maps API (JavaScript)
//Generate Encoded Polyline Algorithm Format for Google Static Maps API
// http://bit.ly/sw3deL (Japanese)
// http://bit.ly/tnKt4m (English)
function encodeGPolyline(path){
var enc = "";
var old = true;
for(c in path){
var latlng = path[c];
if(old === true){
@groupewibi
groupewibi / popular-posts-functions.php
Created April 14, 2019 09:13 — forked from micjamking/popular-posts-functions.php
[WordPress] Display Popular Posts by Page Views
@groupewibi
groupewibi / acf-to-excerpt.php
Created April 14, 2019 09:13 — forked from micjamking/acf-to-excerpt.php
[WordPress Plugin] Copy ACF field to Post Excerpt
<?php
/**
* Plugin Name: ACF Field to Excerpt
* Plugin URI: http://wordpress.stackexchange.com/q/70990/12615
*/
function acf_to_excerpt(){
$post_type = 'post';
$field = 'summary';