bainternet / admin-page-class Goto Github PK
View Code? Open in Web Editor NEWcreate custom WordPress Admin option Pages
Home Page: http://en.bainternet.info/?p=555
License: GNU General Public License v3.0
create custom WordPress Admin option Pages
Home Page: http://en.bainternet.info/?p=555
License: GNU General Public License v3.0
When you use a wysiwyg textarea field in a repeaterblock, upon clicking the "Add New" button doesnt show the tinymce buttons. its editor stays fixed in "text" mode. When you save the settings the editor seems to show up just fine. Can you please fix this? Thanks!
So we can customize the exported file name.
Tested:
$file_name = apply_filters('apc_theme_export_name', 'theme_export.txt');
In my plugin:
add_filter('apc_theme_export_name', function(){return 'MyPluginName.txt';});
Hi,
Iam having a problem regarding the WYSIWYG field in the Admin-Page-Class.
I have build 2 custom-admin-fields, one simple text-field (for a heading), and a WYSIWYG-field (for content).
When I type german Umlauts (ä, ü, ö) the simple-text-field renders these characters correctly, however the WYSIWYG is not!
When I look normally at the Page I get :
ä
When I look in the sourcecode of the website I get this :
Ã_;¤_;
In the WP-Admin-field it looks like, and is just this (even in the HTML view):
ä
It should be an:
ä
As I said, everywhere else on the site the Umlauts get renderd correctly, except in the WYSIWYG field.
I dont know if its the same in your normal Meta-Box and/or Tax-Meta-Box classes, since I just use these WYSIWYG field the first time now.
The Charset is enabled correctly in my php files and also in the WP options the UTF-8 is set.
When I look at the sourcecode it also displays the correct charset. My WP-Database is also just formated with UTF-8 (Adminer showed me this).
I can set an Umlaut directly besides the php tag to retrieve the field data, and this Umlaut is rendered OK :
ö < p > Ã_;¤_;Inhalt der ersten Box </ p >
(the ö is writen directly into the sourcecode, the content inside the paragraph is from the custom field)
I tested various Browsers (FF, Chrome, Opera).
Hope you can help, thanks for your work! (and sorry for my english)
-Mo
P.S. It seems it doesnt happen on your Tax-Meta-Class, I just tried creating a WYSIWYG field there, and it renders Umlauts correct! But I didnt tried your normal Meta-Box-Class yet.
P.P.S. I just saw that you also got some translation problem with this Admin-Page. The Text on the 2 save buttons (on top and the one on the bottom) are different:
the top one says: "Save Changes",
the bottom one says: "Änderungen übernehmen" (german for save changes, here the Umlauts are also correct ;) )
I know I can edit this in "admin-page-class.php", I just wanted to point this out ;)
That is not exactly a issue, but a comment:
The developer can use your class inside the theme folder, instead of plugin.
Just drag the folder inside the theme folder and include the class file on the functions.php.
I think that is interesting to say on the README.md of the repository. :)
Congratulations! We have a really nice (and oriented-object) job here. 👍
Hi, mister Ba :)
Finally, I've published it in the repo.
Not sure if it could be the quantity of tabs/fields, but haven't debugged it. The behavior is the same in Chrome, Firefox and Opera:
Can you repro this?
saludos!
I've found that the following line is breaking qTranslate post titles in /wp-admin/post.php?post=ID
:
add_filter('attribute_escape',array($this,'edit_insert_to_post_text'),10,2);
There's no sign of this filter being used in qT. And inserting a return $text;
as the first line in the callback method doesn't solve the matter. Only disabling the filter does it.
I don't know what trickery qT is using that collides frontally with this hook. I'll report the same in their forums and this is just a heads up about the issue.
Seems pretty safe to disable this hook on my version, do you agree?
thx & saludos :)
When a checkbox is placed inside a conditional block it has the wrong size. (Sorry about placing a issue in the wrong repo)
Code (just added a checkbox to the conditional block in the demo:
/**
* To Create a Conditional Block first create an array of fields (just like a repeater block
* use the same functions as above but add true as a last param
*/
$Conditinal_fields[] = $options_panel->addText('con_text_field_id',array('name'=> __('My Text ','apc')),true);
$Conditinal_fields[] = $options_panel->addTextarea('con_textarea_field_id',array('name'=> __('My Textarea ','apc')),true);
$Conditinal_fields[] = $options_panel->addImage('con_image_field_id',array('name'=> __('My Image ','apc')),true);
$Conditinal_fields[] = $options_panel->addCheckbox('checkbox_field_id',array('name'=> __('My Checkbox ','apc'), 'std' => true),true );
/**
* Then just add the fields to the repeater block
*/
//conditinal block
$options_panel->addCondition('conditinal_fields',
array(
'name'=> __('Enable conditinal fields? ','apc'),
'desc' => __('<small>Turn ON if you want to enable the <strong>conditinal fields</strong>.</small>','apc'),
'fields' => $Conditinal_fields,
'std' => false
));
I am using admin page class in a theme and I get the following javascript errors on my admin page (using the demo fields provided here: http://en.bainternet.info/2012/my-options-panel)
error 1:
GET http://imagination-station.local/decon-staging/wp-content/themes/mothership/admin-page-class/jquery-ui.css?ver=3.5 404 (Not Found) themes.php:21
error 2:
Uncaught TypeError: Cannot read property '_selectDate' of undefined jquery-ui-timepicker-addon.js:962
error 3:
Uncaught TypeError: Object [object Object] has no method 'datepicker' Admin_Page_Class.js:258
I can confirm that the jquery-ui stylesheet is indeed at admin-page-class/jquery-ui.css. If I change lines 1213 and 1230 of admin-page-class to:
wp_enqueue_style( 'jquery-ui-css', $plugin_path.'/css/jquery-ui.css' );
the stylesheet enqueues properly.
the other two errors I'm stumped on. any ideas?
If you include a quoted word in a non-tiny_mce textarea, you end up adding several new backslashes every time the options are saved. I changed line 1604 and line 1690 in my local copy of the script to stripslashes when the $meta is displayed in one of these boxes.
Hello,
Congratulations for the brilliant work and thanks for letting us use it for free.
I, however, having an issue. Tried to contact you through the blog, but failed. Anyway, if I turn off the checkbox, the value remains "true" though the UI shows its "OFF". Any workaround?
I am using a helper class to retrieve the values
function my_settings($theid) {
$options = get_option( 'option_group' );
return $options[$theid];
}
And, echoing the value with
<?php echo my_settings('optionid'); ?>
Is there any way to fix the issue with text fields and text areas not accepting apostrophes? On the client side I can accomplish it by using stripslashes but every time the options get resaved it adds two more slashes to that text field or text area and you have to delete them and resave it so there's only one.
Any way to make sure those are getting stripped when displaying field values so the user doesn't know what's going on?
If you do fix it let me know because I made a couple mods to the class and want to know which functions to modify.
I'm using addPosts() inside a repeater block. I want to list all pages, but it's just listing posts.
$options_panel->OpenTab('options_2');
$options_panel->Title(__('Eğitim','apc'));
$repeater_fields_left[] = $options_panel->addImage('egitim_image',array('name'=> __('Eğitim Görseli ','apc')), true);
$repeater_fields_left[] = $options_panel->addPosts('egitim_linki',array('post_type' => 'page'),array('name'=> __('Gönderi','apc'), 'desc' => __('hangi sayfaya link verilecek?','apc')), true);
$options_panel->addRepeaterBlock('re_egitimsol_',array('sortable' => true, 'inline' => true, 'name' => __('Eğitim Tablosu (SOL)','apc'),'fields' => $repeater_fields_left));
$options_panel->CloseTab();
In the function show_field_checkbox()
, if I change to checked($meta, 'on', false)
, it works for Checkboxes inside Conditionals.
But, of course, this breaks the regular Checkbox. Not sure where to adjust this logic...
[edit]
It doesn't happens if the subfield is a Checkbox List.
For styling purposes, it would be handy to have all <label>
with a class name.
As for <form>
, is it possible to add a name
to it?
I'm not sure if this may have any implication in the overall functioning...
I'm adding it in my working copies, so I can use a custom button to dispatch the submit action, like:
document.formname.submit()
Surely, it got Lost in Translation (: great movie, btw ;)
But item 2 of Issue #17 is still there:
The function addRoles
is dumping a notice when inside a Conditional field
Notice: undefined index 'multiple'
Corrected adding the following
$new_field = array( /*other key => values*/ , 'multiple' => false )
Man, sorry for keep bringing problems :/)
I told you so:
When two plugins are using APC, this doesn't work:
if ( class_exists( 'BF_Admin_Page_Class_Validate' ) && isset($field['validate_func']) && method_exists( 'BF_Admin_Page_Class_Validate', $field['validate_func'] ) ) {
$new = call_user_func( array( apply_filters('apc_validattion_class_name', 'BF_Admin_Page_Class_Validate'), $field['validate_func'] ), $new ,&$this);
}
The filter hook is only dispatched in one of the instances. Maybe the user validation class should be declared in the arguments of the constructor?
Not sure what MP6 is doing, but it reveals the hidden fields for the iPhone on/off selectors.
Adding the following in the plugin page solves the issue
input.hidden { display:none}
The useful function "Paragraph" conflicts with the also useful function "addParagraph" (the first adds a paragraph without a field wrapper, the latter adds a field wrapper).
Unfortunately my line numbers may be approximate as I've been modifying your code to remove hard-coded styles and a few other things. What needs to happen to make both functions work: change the type argument of one of the functions. I changed the "Paragraph" function's arg to "para", that's arbitrary on my part.
I commented out some arguments for clarity's sake.
~ line 693:
$skip = array('title','paragraph',/*omitted arguments*/);
$skip = array('title','para',/*omitted arguments*/);
~ line 750:
case 'paragraph':
case 'para':
~ line 943:
$args['type'] = 'paragraph';
$args['text'] = $text;
$args['id'] = 'paragraph';
$args['type'] = 'para';
$args['text'] = $text;
$args['id'] = 'para';
~ line 2200:
$skip = array('title','paragraph',/*omitted arguments*/);
$skip = array('title','para',/*omitted arguments*/);
When you use image fields on a repeater block it shows the word 'Array' instead of the image preview. Small bug, but annoying to click the pencil to see the image again.
I saw in source code on line 1321
if ($field['group'] == "start"){
but declare doesn't work.
What was the purpose?
First off - great class! I appreciate your work.
As a feature request, could you provide a path option for use in a theme? For example:
'use_with_theme' => true
'admin_page_path' => '/lib/admin-page-class/'
and then on line 289 change it to:
$this->SelfPath = get_stylesheet_directory_uri() . $args['admin_page_path'];
This gives us the flexibility to include this class in our lib directory - or any other directory such as inc or includes, mydirectory etc.
thanks!
So I've found an interesting one:
The repeater block with an image inside will not load tb_show if there isn't another image type on one of the panels.
So far I've narrowed it down to this: If I add an Image type on another panel, it will correct this issue.
However, when I enter more than one Repeater block (both with images) one of the Upload Image buttons breaks over into the second repeater (UI only, the ID's all match up correctly).
Thanks!
Hi Ohad, i have a problem. I just install the plugin, go to the demo admin panel, edit some fields and then save changes, but the “repeater block” give me this message:
Warning: Illegal offset type in C:\xampp\htdocs\creamos\wp-content\plugins\admin-page-demo\admin-page-class\admin-page-class.php on line 1260
Any idea?
Reopend as number 4 in #17
So basically , wrap checkboxes with labels and give an option to disable IPhone Styled toggles.
Not sure how to deal with this, how do I merge my plugin lang files with APC's?
While debugging, I found an error in the function load_textdomain()
.
The 'mo' is missing a dot: get_locale() .'mo'
should be get_locale() .'.mo'
When I build my catalog, all APC strings are included, but the translations don't show up, nor from my language files neither from APC's. Mine works ok.
This is the basic structure that builds my plugin and includes APC:
https://gist.github.com/4374106
Contribution
Spanish and portuguese translations for APC, zip file with es_ES.mo, es_ES.po, pt_BR.mo, pt_BR.po
:
http://cl.ly/2T2t1n3K0z1g
Running WordPress version 3.8 I activated the My Admin Page Class usage demo with the class in a sub-folder of the demo plugin.
No menu showed. I altered the configuration variables to make a top level menu and still no menu appeared.
I then renamed the class folder and generated an white screen of death error, so the plugin is running and loading the class, buit it is not displaying the menu.
It can't query when post_type = page or cat = ID ,any parameter... It's always can't be set.
Hi Ohad, finally I'm taking a dive into this classy Class :)
as I'm seriously considering rebuilding my first plugin options pane with it.
There's a double CloseTab()
at line 242 of the demo, is that correct?
If so, I suppose it corresponds to the opening OpenTabs_container()
.
I'm not quite understanding the description of the Conditional Fields.
You say "use the same functions as above but add true as a last param".
The $repeater_fields[]
also have true as last parameter...
Seems that we cannot have a proportional preview of the images. I'm removing the data-he
attribute to achieve this.
Delete Image
button is actually deleting the image from the library. IMO, this should be only a removal from the options data and leave the deletion for the Media Library.thanks for sharing!
Rodolfo
Everytime I click save changes on a option panel it seems to be adding \'s to the displayed data and the saved data, everytime there are added \'s
When a textfield, textarea field has std value, user cannot remove the default value to keep the field empty. the std value should be overridden by the updated settings.
Just a request to remove inline styles from elements and use class names/plugin stylesheet instead. That way users can customize the look of their pages without having to edit the original framework.
In the same spirit, allow a class name to be passed to the fields. Users would then have a fine level of control over the appearance of elements (for example, different sized text input boxes).
Thanks again for the work that has gone into this.
when you use the class with theme and then activate the theme in another wordpress installation, the theme doesn't create a demo_options row in the database, inside wp_options. but when you click the "save Options" button from theme options page, it creates it. Is there a way to create the demo_options row on activation? because if it doesnt create the row upon activation, every user has to click the save options button after activation. which is very confusing.
I am using the latest version btw.
Thanks.
I am getting this error when running in debug mode.
Deprecated: Call-time pass-by-reference .../admin-page-class/admin-page-class.php on line 601
I'll look into my version of the solution and share any findings sir,
Thank you this is brilliantly done!
I'm building a blank plugin with APC so as to start new ones with it bundled.
Can you confirm that Javascript is breaking if we don't have an addColor
defined?
TypeError: $(...).wpColorPicker is not a function
http://plugins.dev/wp-content/plugins/apc-base/inc/admin-page-class/js/Admin_Page_Class.js
Line 354
Looks like if ($.farbtastic){ } else { $('.at-color-iris').wpColorPicker() }
is not considering that the scripts may not have been enqueued in the function check_field_color
.
When you have multiple color pickers in one tab it seems it's opening the wrong tab. Here's a code chunk for the admin JS that replaces all the colorpicker JS you have now:
$('.at-color-select').click(function(e) {
colorPicker = jQuery(this).next('div');
input = jQuery(this).prev('input');
$.farbtastic($(colorPicker), function(a) { $(input).val(a).css('background', a); });
colorPicker.show();
e.preventDefault();
$(document).mousedown( function() { $(colorPicker).hide(); });
});
This one is undocumented and it is missing 'options' => $options
in the $new_field = array()
.
I'm getting error "Cheatin’ uh?" when I try to upload image since wordpress version 3.4.
I don't see the admin panel under the Settings menu, using the class-demo plugin, in WordPress 3.6. Works fine in 3.5
addCode
Small typo when declaring $new_field
. It doesn't bug as it is covered by the javascript
'theme' => 'defualt'
addRoles
It is dumping a notice when inside a Conditional field
Notice: undefined index 'multiple'
Corrected adding the following
$new_field = array( /*other key => values*/ , 'multiple' => false )
wp_ajax_delete_image
I had to modify the following to make the button "Delete Image" work:
From $saved[$f[1]][$f[2]]
to $saved[$f[1]]['src']
.
Not sure if this may be a problem with my setup...
Wrap the checkboxes with labels. IMO, it's more user friendly to click the text than having to click on those small checkboxes.
function show_field_checkbox_list()
$html[] = "<label><input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked( in_array( $key, $meta ), true, false ) . " /> {$value}</label>";
function show_field_posts()
echo "<label><input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> {$p->post_title}</label><br/>";
function show_field_taxonomy()
echo "<label'><input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name </label>";
function show_field_WProle($field, $meta) {
echo "<label><input type='checkbox' name='{$field['id']}[]' value='$n'" . checked(in_array($n, $meta), true, false) . " /> $n</label><br/>";
add Name to form tag as requested in #23
The cookie gets funky.
Probably this should be the id
of the config argument, instead of apc_last_tab
:
setCookie("apc_last_tab",tab);
I'm getting warnings when I use the Conditional fields
Warning (9) Illegal string offset 'type' on line 2406 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning (9) Illegal string offset 'id' on line 1779 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning (9) Illegal string offset 'id' on line 1781 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning (19) Illegal string offset 'type' on line 1783 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning (9) Illegal string offset 'id' on line 1786 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning (9) Illegal string offset 'type' on line 1787 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning call_user_func() expects parameter 1 to be a valid callback, class 'Roots_Admin_Page_Class' does not have a method 'show_field_w' on line 1787 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning call_user_func() expects parameter 1 to be a valid callback, class 'Roots_Admin_Page_Class' does not have a method 'show_field_l' on line 1787 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning call_user_func() expects parameter 1 to be a valid callback, class 'Roots_Admin_Page_Class' does not have a method 'show_field_r' on line 1787 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
Warning (6) call_user_func() expects parameter 1 to be a valid callback, class 'Roots_Admin_Page_Class' does not have a method 'show_field_e' on line 1787 in file D:\www2\snippets.dev\wp-content\themes\roots\lib\admin-page-class\admin-page-class.php
This is some example code:
//Facebook
$enable_facebook[] = $options_panel->addText( 'facebook_link', array(
'name' => __( 'Facebook Link: ', 'apc' ),
'std' => 'https://www.facebook.com/',
), true );
//Conditional Facebook.
$options_panel->addCondition( 'enable_facebook',
array(
'name' => __( 'Enable Facebook? ', 'apc' ),
'fields' => $enable_facebook,
'std' => false
) );
//Twitter
$enable_twitter[] = $options_panel->addText( 'twitter_link', array(
'name' => __( 'Twitter Link: ', 'apc' ),
'std' => 'http://www.twitter.com',
), true );
//Conditional Twitter.
$options_panel->addCondition( 'enable_twitter',
array(
'name' => __( 'Enable Twitter? ', 'apc' ),
'fields' => $enable_twitter,
'std' => false
) );
RESULTS - displays iPhone style checkboxes, but when you click to turn one off, it does not save to the Database.
WORKAROUND:
3. now add call 'no-toggle' disabling iPhone style
RESULTS - as standard checkboxes it now functions.
Hi,
This is really the best option panel script.
Most users are using "Slightly Modded Options Framework" as their option panel framework.
I was using it too, because I did't know this class,
I have 2 suggestions for this class to be better:
1- Is there anyway to add "Reset Options" button to option panel.
2- It'd be nice if saving options be with ajax.
Kind Regards.
I've tried this, whitout any result.. do you have an idea?
jQuery(document).ready(function ($)
{
if ( $('input:checkbox[name=brique]').is(':checked'))
{
$('input:checkbox[name=blue]').attr('checked', false);
}
});
I tried activating the plugin and got the following error:
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /home/content/j/a/b/jabrieske/html/amphenol/wp-content/plugins/admin-page-demo/admin-page-class/admin-page-class.php on line 1170
This is in response to my original question on your site:
Javascript isn’t working correctly for me. I tried using just the default theme with just your class and im still having the javascript issues…
The actual options page shows up correctly (i.e. styles, etc..) however, when i try and switch tabs, The information is placed at the bottom of the container, and the default options stay at the top right of the options page. The highrule above “Thank you for using WordPress” is in the middle of the options panel…
Any recomendations?
Here is a pastebin as requested:
http://pastebin.com/i5DaT4rx
After saving the options, the color box doesn't show the color as background-color of the field with the hex value.
The farbtastic
color wheel also doesn't show the saved value, displaying black instead:
Just to be clear, the values are saved but the visual representation is not there.
That's curious, because in a plugin where I use a very basic implementation of farbtastic
this doesn't happens...
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.