upstatement / jigsaw Goto Github PK
View Code? Open in Web Editor NEWSimple ways to make admin customizations for WordPress
Simple ways to make admin customizations for WordPress
Very sorry to put this simple question here, but I didn't know how else to make my question known. If there is a better way/place "next time", please let me know.
I am somewhat new to coding WP so if you could kindly include in your MD, a simple example of including this in something - like a plugin I am building if I wanted to add some of my custom fields to a custom post type?
Where I am stuck is the $callback function. I have a custom date field (that is not the date of the post) that I want to show in a column of the admin UI. I'm not using twig or anything like that. What to I put in the function parameter to show the field column?
Please excuse my low skill level. Your patience is most appreciated.
-John
Im trying to add a image preview on a custom post type, being the image itself provided by ACF. Locally on my machine it works as expected, although on the live server the thumbnails won't get resized and always show full-size.
The code im using for this is:
Jigsaw::add_column('banners', 'Preview', function( $post_id ){
$banner_type = get_field('banner_type');
if ( $banner_type === "Banner Top" ) {
$image = get_field('banner_top_image');
} else {
$image = get_field('banner_action_image');
}
$post = new TimberPost($post_id);
if ( strlen( $image ) ){
$post->preview = new TimberImage( $image );
}
$data = Timber::get_context();
$data['post'] = $post;
Timber::render('admin/banners-image-preview.twig', $data);
}, 1);
And the contents of the template are just:
<img src="{{post.preview.src|resize(100, 80)}}" />
Any thoughts of what might be happening?
Thanks
It would be nice to have a composer.json file so themes could have this as a dependency.
Because it's prepending the theme directory to the request URL, it doesn't allow child-theme to use this helper.
It would be nice adding some example on how to add terms from custom taxonomy. There is one:
Jigsaw::add_column($post_type, $column_label, function($post_id){
$term_list = wp_get_post_terms($post_id, $colum_slug, array("fields" => "all"));
if(count($term_list) > 1) {
foreach ($term_list as $term_single) {
echo $term_single->name . " ";
}
} else {
echo $term_list[0]->name;
}
}, 10);
Maybe also adding link term would be greater!
Title says it all. Would be neat if this was built in. The docs don't seem to cover it and I don't have any projects to throw in on right this second.
Similar to Zoneboard, Jigsaw is the next plugin I want to target.
Would it be possible to add an option to pass a column width when adding columns to the admin lists?
Hey,
Just updated saw and update to v0.6 was available within WordPress.. didn't see a changelog but assumed the best :)
Now any post types that I've added a column to dont load properly - wp debug shows this error:
Fatal error: Cannot access self:: when no class scope is active in /wp-content/plugins/jigsaw/jigsaw.php on line 188
How can I pass a CSS when using Jigsaw in a child theme?
The function creates the file URL with the get_template_directory_uri()
which always retrieves the parent theme location instead of the child theme.
Any way to get around it?
static function add_admin_js_or_css( $file, $function = 'wp_enqueue_style' ) {
if ( !is_admin() ) {
return;
}
if ( !file_exists( ABSPATH.$file ) ) {
$file = trailingslashit( get_template_directory_uri() ).$file;
}
add_action( 'admin_enqueue_scripts', function() use ( $file, $function ) {
$function( sanitize_title( $file ), $file );
} );
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.