wp-papi / papi Goto Github PK
View Code? Open in Web Editor NEW:rocket: WordPress Page Type API with custom fields
Home Page: https://wp-papi.github.io
License: MIT License
:rocket: WordPress Page Type API with custom fields
Home Page: https://wp-papi.github.io
License: MIT License
similar to single adding the classes "single" & "single-post",
it would be great if eg. the class "my-page-type" could be added to the body tag
Custom multi language support via tabs ui and automatic detecting depending on the PTB_LANG_CODE
definition. Should follow ISO 639-1
The data is not removed when the field is empty and the value comes back again.
Look over all JavaScript and remove the part of the property that loads the property JavaScript file and add them to the build script so we only have one JavaScript file for the project.
Today papi uses WP_PLUGIN_DIR
and that won't work when you add it as must use plugin.
Tabs should be a property instead of custom Papi feature.
Something like this:
$this->box([
$this->property([
'type' => 'tab',
'title' => 'Content',
'settings' => [
'items' => 'array of properties'
]
]);
]);
This will remove a lot of complex functionality to determine if there is a tab or not in the core.
This would be a nice feature!
PropertyImage should be rewritten from the ground. With a new look using Backbone
Relationships should be able to adapt to sidebar, even though it's a bad idea, but see my next issue about 1 relationship, where it could be a desired feature
Images uploaded in a repeater field, aren't attached to the post. However, it works when not inside of a repeater.
Be able to limit how many selections you can make.
E.g. -1 = as many as you like, 4 = max 4 items ('choose_max' => -1)
Similar to the way you can limit how many items to choose from ('show_max' => -1)
Add fill_label
to page type meta. It will autofill labels with the page type name.
Start with this labels and have a look at https://codex.wordpress.org/Function_Reference/get_post_type_labels for more labels.
add_new_item
edit_item
Be able to order items in the reapeater, either by drag-and-drop or by setting order number.
<?php
$this->box(array(
'sort_order' => 4
));
$this->box(array(
'sort_order' => 2
));
When a thumbnail is smaller then 150x150 it won't show because they can be 106x150. So the solution is to create a wp_ajax
to get the thumbnail url via the attachment id.
As discussed in #62 (comment) it would be nice with a html_name
method in Papi_Property
class so you can do:
`<input name="' . $this->html_name( $subproperty ) . '" />`
With or without a sub property value. If empty value just return $options->slug
value.
To get this working for a repeater I think it's best to send in a second argument that is a count value or have a standard how this kind of properties should implement the counter.
Would be nice with a filter
setting where you could put WP_Query
in that should override post_type
parameter with all post_types
specified. See https://gist.github.com/luetkemj/2023628 for WP_Query
parameters and so.
Example:
'filter' => [
'has_password' => false
]
Hi,
In the documentation, the section "Page types - Remove meta box" makes reference to the remove meta box Codex page, but I think that you want to make reference to remove post type support page.
Just started out with Papi. This is really good stuff!
I am using
$this->box(
'Logo', [
papi_property(
[
'type' => 'image',
'slug' => 'page_logo'
]
)
]
);
And this works great except when I try to upload a svg. I have allowed svg with wordpress so it is not that.
The field in wp-admin just wont update when I choose a svg.
May this be an issue with Papi or am I missing something?
Issue with case sensitive in search-box, e.g. I had a post namned "Middag, lunch och dryck", when searching for "mi" I found it, but when searching for "Mi" I didn't. Searching for "middag, l" also worked but "Middag, l" didn't.
Add support for sorting the page types with a sort order or something like that.
public static function page_type () {
return array(
'name' => 'About us',
'description' => 'About the company',
'template' => 'pages/about-us.php',
'sort_order' => 12
);
}
Be able to order items in the selected list, either by drag-and-drop or by setting order number.
uniqid
seamless
mode_papi_get_all_page_types
so it works to get all page types with a specified post typeselect2
to 3.5.2moment.js
to 2.9.0Hi,
I'm trying to use a repeater with a WP editor and it doesn't work. The cloned editors do not respond to click events, only when I publish/update the page. I think that the problem is the duplicate ID's.
Regards,
Sérgio
I have a page type with an image repeater and when I create a new page of this type, I see the box and can select multiple images. The problem is that when I publish the page, the selections that I did not appear. In fact, the contents of that box is empty.
I can see, however, the images ID's and description in the postmeta database table.
public function register() {
$this->box( 'Images', [
$this->property( [
'type' => 'repeater',
'title' => 'Images',
'slug' => 'images',
'sidebar' => false,
'settings' => [
'items' => [
$this->property( [
'type' => 'image',
'title' => 'Image'
] ),
$this->property( [
'type' => 'text',
'title' => 'Image description'
] )
]
]
] )
] );
}
Am I missing something here?
Since commit abc3f38 it possible to access $this->get_options()
on update_value
. The property repeater should use this instead of hidden input fields to get information about columns and properties.
I'm french and while using papi for a recent project, I noticed the page type value called Home
was translated to Accueil
.
That's because papi is using translation function esc_attr_e
to escape attributes:
https://github.com/wp-papi/papi/blob/master/src/includes/admin/class-papi-admin.php#L166
The PR attached resolves this issue. I didn't check the whole code base for all translations functions (__(), _e(), _n(), _x(), _ex(), _nx(), esc_attr__(), esc_attr_e(), esc_attr_x(), esc_html__(), esc_html_e(), esc_html_x(), _n_noop(), _nx_noop(), translate_nooped_plural()
) but they shouldn't be used as shortcuts to output raw values.
It would be nice to enable html in the string/text (which is not an editor) properties, but not by default. So that you may use some html-markup.
Hi,
Is it possible to add papi properties to a custom post type? There's a post_type
parameter on the box method but has no effect.
I noticed that Papi adds a custom column to every post type, whether there's used in Papi or not:
https://github.com/wp-papi/papi/blob/master/src/includes/admin/class-papi-admin.php#L386
There no logic filtering on which post type the column should be added:
https://github.com/wp-papi/papi/blob/master/src/includes/admin/class-papi-admin.php#L243
Unlike the page type filter:
https://github.com/wp-papi/papi/blob/master/src/includes/admin/class-papi-admin.php#L300
The post type filtering may be done on the class instantiation before seting up any hooks? What do you think?
If there's only one relationship in max_choose a layout similar to simple fields "post field" would be a desired features, which also makes it suitable for sidebars. http://simple-fields.com/documentation/field-types/post/
It would be great to find a good and nice way to reuse properties on several page types.
Example how you could do it, not so nice maybe.
// page-types/functions.php
function _site_property_relationship ($title, $slug) {
return array(
'type' => 'relationship',
'title' => $title,
'slug' => $slug
);
}
// page-types/first-page.php
$this->box('My box', array(
_site_property_relationship('Mat & Bar', 'mat_bar'),
_site_property_relationship('Event & Möten', 'event_meeting')
));
// page-types/second-page.php
$this->box('My box', array(
_site_property_relationship('Mat & Bar', 'mat_bar'),
_site_property_relationship('Event & Möten', 'event_meeting')
));
Thanks for really great plugin. It looked very promising and didn't disappoint at most. Experienced one issue that really bugged me while trying to create a custom property that needs to store several types of values.
Given:
<textarea name="<?php echo $options->slug; ?>[address]"><?php echo $value['address']; ?></textarea>
meta is saved, but looks like this (last row):
+---------+---------+------------------------+-----------------------------------+
| meta_id | post_id | meta_key | meta_value |
+---------+---------+------------------------+-----------------------------------+
| 1211 | 413 | _edit_lock | 1431414216:3 |
| 1212 | 413 | _edit_last | 3 |
| 1213 | 413 | _wp_page_template | default |
| 1214 | 413 | _papi_page_type | contact-page/class-tour-page-type |
| 1216 | 413 | _contact_maps_property | Googlemap |
| 1229 | 413 | address | Sofia |
+---------+---------+------------------------+-----------------------------------+
As a result $value
is always empty.
Add support for WordPress cache.
See:
http://codex.wordpress.org/Class_Reference/WP_Object_Cache
Hi,
Would you agree to add a file property (like image but will accept any type of file)?
I can work on a PR if needed.
A new method that every property can use for validation.
Example:
function validate_value( $value ) {
$valid = empty( $value );
return array( $valid, 'Error message' );
}
This function should return two values, true or false if the value is valid and the error message if any.
For example
When creating a container page with child page that used as items it would be nice to be able to create "MyImageItem" under "MyImageContainer".
Something like the page_types
array option on the page type array.
public static function page_type () {
return array(
'name' => 'My image container',
'description' => 'Image container',
'template' => 'pages/no-preview.php',
'page_types' => array(
'My_Image_Item_Page_Type'
)
);
}
If you have no properties registered to a specific Page Type and create a new page, that specific page will not have the page type set.
To recreate the bug:
If i create a repeater and try to upload an image to anything except for the first row the image will seem uploaded, but upon saving it will be lost.
Example screenshot on how it looks:
Have checked the access/error-logs in nginx(running on bedrock-ansible stack) and there's no error output there. Also no error message in browser console or in wp-admin.
Tested in Chrome & Safari on latest OS X.
When using papi/settings/only_page_type_{$post_type}
and you import pages to the post type the page type value in the database don't exists. If papi/settings/only_page_type_{$post_type}
exists for a post type it should use that if the page type value don't exists.
Hi,
Thanks for this wonderful plugin. I really the approach you're using.
However, I didn't see any different properties for textarea and text fields? Do you mind if I submit a PR to add a new property?
Papi ajax is a new admin class that will handle ajax request against Papi. The ajax class will render property html as a json object.
Request against http://wordpress/papi-ajax/?action=get_property&type=image&title=wow&slug=hej
will return this
{
"html": "property html"
}
All options that you can use in papi_property
will work against action=get_property
.
The repeater property will use this feature in v1.3.0
rather then the template html that exists in the page load.
This is just the start of the Papi ajax!
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.