Skip to content

Instantly share code, notes, and snippets.

@eudesgit
eudesgit / wp-plugin-filtering-page-templates.php
Last active February 13, 2018 19:28
How to make outside the theme page templates available for use
<?php
/**
* theme_page_templates Filter callback
*
* Merges plugins' template with theme's, making them available for the user
*
* @param array $theme_templates
* @return array $theme_templates
*/
function register_plugin_templates ( $theme_templates ) {
@eudesgit
eudesgit / wp-plugin-template-name.php
Created February 13, 2018 19:26
How to get WP file header data for a page template
<?php
// Gets Template Name from the file
$filedata = get_file_data($full_path, array(
'Template Name' => 'Template Name',
));
@eudesgit
eudesgit / class-plugin-template-include.php
Last active February 13, 2018 19:20
WordPress plugin to make plugin's own Page Templates available to the website.
<?php
class Plugin_Templates_Loader {
/**
* Templates folder inside the plugin
*/
private $templates_dir;
/**
@eudesgit
eudesgit / class-acf-image-upload.php
Last active January 31, 2023 14:40
WordPress - Uploading images to Advanced Custom Fields (AFC)
<?php
class ACF_Image_Upload {
public $post_id;
function update_acf ( ) {
$attach_id = $this->get_image_attach_id('my-image.jpg');
// Saving image