Code Monkey home page Code Monkey logo

admin-page-framework's People

Contributors

chrisgherbert avatar dmgawel avatar fredpik avatar michaeluno avatar mnajafzadeh avatar pcraig3 avatar scrutinizer-auto-fixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

admin-page-framework's Issues

Menu Position

First of all, let me just say; great work on the framework. It's simply awesome!

Though I seem to be having an issue (or maybe just a lapse of stupidity). In your documentation for v2 you state that one can change the menu position of the created Menu Page as the third parameter of the setRootMenuPage-function.

setRootMenuPage(string $strRootMenuLabel, string $strURLIcon16x16, string $intMenuPosition) : void

I have located the issue and fixed it. On line 1635 the code is:

isset( $this->arrRootMenu['intPosition'] ) ? $this->arrRootMenu['intPosition'] : null   // menu position

Which by what I can figure out should be (and which fixed the issue):

isset( $this->oProps->arrRootMenu['intPosition'] ) ? $this->oProps->arrRootMenu['intPosition'] : null   // menu position

Just wanted to let you know!

Accept setting an icon with a file path

As there is a method added in v2.1.5 to resolve a file path into the URL, the methods, setRootMenuPage(), addSubMenuPage(), and getStylesForPostTypeScreenIcon() should accept a file path to set an icon so that the user does not have to use the plugins_url() function.

Change the naming of the filters, head_{...}, content_{...}, and foot_{...}

head_ + page slug – receives the output of the top part of the page.
head_ + page slug + _ + tab slug – receives the output of the top part of the page.
head_ + extended class name – receives the output of the top part of the page, applied to all pages created by the instantiated class object.
content_ + page slug – receives the output of the middle part of the page including form input fields.
content_ + page slug + _ + tab slug – receives the output of the middle part of the page including form input fields.
content_ + extended class name – receives the output of the middle part of the page, applied to all pages created by the instantiated class object.
foot_ + page slug – receives the output of the bottom part of the page.
foot_ + page slug + _ + tab slug – receives the output of the bottom part of the page.
foot_ + extended class name – receives the output of the bottom part of the page, applied to all pages created by the instantiated class object.

The words, head and foot might not be the best naming choices for these filters because they often remind of the head and foot HTML tags, not the positions.

So instead of head, content, and foot, it might be better to replace them with top, middle, and bottom.

[Edit]
Now I started to think top_{...}, middle_{...}, and bottom_{...} are not enough either because they won't remind of string contents. Maybe top_content_{...}, middle_content_{...}, and bottom_content_{...} could be better. I don't know.

Repeatable fields?

Michael

Great work. Is there a way/tutorial on how to make repeatable fields in both options and metaboxes?

Remove the date field type and make it a custom field

Currently the date field type relies on external CSS files,

wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );

The jquery-ui.css file has links to images on the external server that means the user's browser will connect to the server when the date picker field is rendered, which should be avoided.

Although it's possible to include those files into the framework, it will become multiple files whereas currently it is a single file. I think it is much easier for beginners to include a single file than multiple files as it eliminates the process of confirming required files.

Advanced users who know the structure of the framework will have less problems including multiple files. So it should be fine to leave the date field as a custom field type. This way, I can introduce additional custom time and date_time field types, which also will have to include multiple files.

If anybody will have a problem with this change, let me know.

Question: trigger function when hitting submit button

Hi there,

I´ve got a submit button like this:

array( // Felder aktuelles Jahr
            'strFieldID'        => 'data_current_submit',
            'strSectionID'      => 'data_current',
            'strType'           => 'submit',
            'vLabel'            => 'Tabellendaten aktivieren',
            'vDisable'          => $this->bool
        ),

Can I somehow trigger a function when hitting this submit button? And how? Should I use the validation method?

Custom Field Types

I'm working on making it possible for the user to define custom field types.

WP 3.5 Uploader New Style

It would be nice if the new WP 3.7 Uploader is used when uploading files and images.

[Edited by michaeluno] the title has been modified from WP 3.7 Uploader New Style to WP 3.5 Uploader New Style.

reveal field on select/choice

Feature request for v3:

When you choose a radio, checkbox or an option in a select field, reveal another hidden field.

Same page slugs cannot be registered for different root pages

I've been researching on how it can be achieved to allow using the same page slugs. It appears that page slugs added via add_submenu_pages() method cannot be used for multiple root pages.

On line 149 in wp-admin/admin.php (WordPress v3.6), there is:

do_action($page_hook);

Before that line, it is hard-coded that the $page_hook variable is defined based on the $REQUEST['page'] value. And the only the callback of the last assigned one is triggered.

This results on rendering the page contents of a different script using the framework on a page that uses the same page slug value. So the user would need to use unique page slugs to avoid collisions with different plugins or themes.

I'm just leaving a note here for myself.

Sortable Field(s)

This is a feature request.

I currently am in need of a field which is sortable. Such as the jQuery ui sortable interaction: http://jqueryui.com/sortable/

If this is unclear, I will try to explain further.

Thank you for this awesome framework.

enqueueScript, load order + passing values to scripts

Not an issue, more a question.

When using enqueueScript(), in which order are the enqueued scripts loaded ?

If I want to pass a value to a enqueued script, I usally use wp_localize_script. How can I pass a value to a script loaded using enqueueScript() ?

Btw, I learned a lot about passing values from this article. It might help if you plan to add a method that does the same as wp_localize_script.

Drop the section/page slug dimension from the saved option structure

When retrieving saved option values, sometimes it's cumbersome to specify the section ids in the array. Since the field id needs to be always unique, sections may not be necessary in the saved option array.

From

$value = $array['page_slug']['section_id']['field_id'];

To

$value = $array['page_slug']['field_id'];

( Addressed in: #40 )

The focus is stolen in the unit option of the size field type

When the unit select drop-down list is clicked, the focus gets changed to the size(text) field input so it's hard to select the unit.

This is due to the for attribute set in the label tag. I need to figure out the way to prevent this by not affecting the element structure.

Add an Option to Remove the Page from the Sidebar Menu

Currently hidden tabs can be created with the fHide key. Similarly, there should be an option to hide the page from the sidebar menu, which will allow to create hidden sub-pages while they will be still accessible as well as the relevant hooks and callbacks.

    $this->addSubMenuItems(
        array(  
            'strPageTitle'  => __( 'Hidden Page', 'admin-page-framework-demo ),
            'strPageSlug'   => 'my_hidden_page',
            'fShowInMenu' => false,
        )
    );

vValue option does not work correctly with selecter setting field type

Can be quickly reproduced by adding 'vValue' array to the selecter demo in "admin-page-framework-demo.php".

$this->addSettingFields(
array(
'strFieldID' => 'test_drpdwn_2',
'strSectionID' => 'test_fields',
'strTitle' => 'Options - 2',
'strDescription' => 'some more options but with vValue set',
'strType' => 'select', // Single Drop-down List
'vDefault'=> 2,
'vValue' => array ( 'first option', 2 , 'etc option' ),
'vLabel' => array ( 'first option' , 'next option' , 'etc option' ),
)
);

Adding the vValue optional array causes the 'selected="selected"' option tag in the output option field to remain fixed on the value=0 option, the vValue field does not seem to have taken effect either. Any calls to this value result in 0 until the vValue field is removed. I have tried using intergers, strings and different orders.

Problem: Validate an import field

I tried to validate an import field with validation_ but it seems not to work.

I have got an import button AND a submit button on the same page and they both need seperate validations.

I tried also the new method validation_extendedClassName_inputID/fieldID

Import CSV File

Hi,
i just wanted to use the import button to process a csv-file. But I did not get it working. The documentation is not that explicit when it comes to the import functionality.

Can you give me a hint?

minor bug when including settings from a separate page

In my plugin, I have the settings in a separate file:

read-offline.php
     |-----settings/read-offline-settings.php
                               |------class/admin-page-framework.php

The following (set in read-offline-settings.php) doesn't work:

$this->addLinkToPluginDescription( 
    "<a href='http://www.google.com'>Google</a>",
    "<a href='http://www.yahoo.com'>Yahoo!</a>",
    "<a href='http://en.michaeluno.jp'>miunosoft</a>",
    "<a href='https://github.com/michaeluno/admin-page-framework' title='Contribute to the GitHub repository!' >Repository</a>"
);
$this->addLinkToPluginTitle(
    "<a href='http://www.wordpress.org'>WordPress</a>"
);

$this->setFooterInfoLeft( '<br />Custom Text on the left hand side.' );

.. and hence, plugin info and Powered by Admin Page Framework doesn't appear.

This one work:

$this->setFooterInfoRight( '<br />Custom text on the right hand side' );

WP Editor as Field

Hey, i tried to add the wordpress wysiwyg editor but did not have any success. Maybe this is an idea for a next update.

As well as the new WP 3.7. Media uploader for files and images?

Kind regards

Problem: When Import-Button used all Options deleted

Hi there,

I have a slight Problem. In one or my Tabs on my options page I use the import field to upload a file, when doing so, every other options (even in other tabs) are deleted. In the database the whole options field is empty.

I removed every action on my self defined import function to test if one of my functions causes the problem but it remains.

Does the import button somehow deletes all options?

public function setUp() {

$this->addInPageTabs(
        /*
         * Options Page
         * */
        array(
            'strPageSlug'   => 'options',
            'strTabSlug'    => 'options',
            'numOrder'      => 1,               
        ),          
        /*
         * List Page
         * */
        array(
            'strPageSlug'   => 'lists',
            'strTabSlug'    => 'lists',
        )
    );  

$this->addSettingSections(
        array(
            'strSectionID'      => 'start_date',
            'strPageSlug'       => 'options',
            'strTabSlug'        => 'options',
            'strTitle'          => 'Aktivierung des Kalenders',
            'numOrder'          => 1,
        ),
        array(
            'strSectionID'      => 'list_upload',
            'strPageSlug'       => 'lists',
            'strTabSlug'        => 'lists',
            'strTitle'          => 'Listen hochladen f&uuml;r Daten&uuml;bernahme',
        )       
    );

$this->addSettingFields(    
        array( // Single File Upload Field
            'strFieldID'        => 'file_sponsors',
            'strSectionID'      => 'list_upload',
            'strType'           => 'import',
            'vLabel'            => 'Sponsoren importieren',
            'vAcceptAttribute'  => 'text/csv'
        ),
        array( // Single File Upload Field
            'strFieldID'        => 'file_prices',
            'strSectionID'      => 'list_upload',
            'strType'           => 'import',
            'vLabel'            => 'Preise importieren',
            'vAcceptAttribute'  => 'text/csv'
        )
}
public function import_lists() {
            // do something here
 }

Question / Suggestion: Notices

Is it possible to define alle Notices for every field, or to override the standard messages without hacking into the main class?

The setSettingNotice and setAdminNotice is fine, but sometimes (file upload) both, the custom set Notice appears and the standard one (like "File has been uploaded).

Maybe this would be a cool advantage if one could change that or leave them blank.

v3 Roadmap - any request?

Is anybody interested in developing v3? I'm planning to start developing Admin Page Framework v3 which will have many breaking changes.

Goal

The goal of v3 is to have no more breaking changes in the future.

As I had written some custom field types, I've started realizing that, to incorporate with third party scripts including jQuery libraries, array key naming might be better to be all lower-cased to keep consistency with them. For example, the sample dial field type uses the knob library and the settings are defined with the data-{...} attribute. Since their setting attributes are all lower case, if the framework uses a different naming style for the settings, the user has to learn two different rules at the same time just to use a single field type.

This kind of situation happened before with writing a wrapper function for the WordPress core wp_enqueue_script() and wp_enqueue_style() functions. A similar situation probably will occur in the future as so many open-source libraries use lower case letters for their settings and parameters.

So I'm thinking that to have lower case letters where the user interacts with and keep the Hungarian notation where only the system uses.

To convert the array keys used by this framework into all lower case, it breaks the scripts using the previous versions of the framework. Is it worth breaking them? There are other issues that cannot be solved without breaking changes. So let's have them at once so that hopefully we no longer have breaking changes in the future.

Variable and Array Key Naming

Use lower-cased characters with underscores like my_variable for array keys where the framework users may use to define settings including pages, tabs, sections and fields. And employ the PHP Alternative Hungarian Notation syntax internally such as aMyArray where the users don't need to see.

Method Naming

Some methods should be renamed such as showPageHeadingTabs because it can imply rendering an output. However, what it does is just to set the visibility property. The actual rendering process is done by a different method.

So the name should be setPageHeadingTabVisibility() or something.

Also for internal methods, the prefix of underscore will be added such as _doInternalTask().

For callback methods, the prefix of replyTo will be added such as replyToAddStyle().

Field Array Structure

Currently the vLabel key's value determines whether a field holds multiple input elements or not. And the value can be either an array, a string, or a numeric value. This is confusing when defining a field type.

I think that to define the sub-elements, numeric keys can be used.

array(
    'section_id' => 'my_text_section',
    'field_id' => 'my_text_field',
    'title' => 'My Text Fields',
    'type' => 'text',
    'default' => 'hello',
    'label' => 'first field element.',
    array(          
        'label' => 'second field element.', 
        'default' => 'hi',
    ),
    array( 
        'label' => 'third field element.',
        'default' => 'bye',     
    ),      
)

Improve Repeatable Field Mechanism

Currently it's hard to write a custom field type that supports repeatable fields. One reason is that there is no means to rebind the JavaScript function attached to the input tag at the moment. Maybe it is doable by writing a repeatable-field script which allows a callback function to be assigned when a repeat event occurs.

Also the vDelimiter element may need to be dropped to help the repeatable script simple.

Sortable Field

If the repeatable field script is well structured to support almost all fields, then sortable fields can be introduced.

Select Field Type's Value

Currently the select field type's value is saved as a string for the single select type, holding the key specified in the vLabel element as its value. This may need to be changed to always have an array as it seems to be confusing for some users: #9

Drop Section Keys from the Saved Option Structure

When retrieving saved option values, sometimes it's cumbersome to specify the section ids in the array. Since the field id needs to be always unique, sections may not be necessary in the saved option array.

From

$value = $array['page_slug']['section_id']['field_id'];

To

$value = $array['page_slug']['field_id'];

Or even drop the page slug key.

$value = $array['field_id'];

So it helps implement this request as well: #12

Filter Names

There are some filter names which should be reviewed: #34

Also there are duplicated filters and added filters #64

Add the Minified Version of the Library

To help development be easier, it's better to keep classes in separate files. However, it might be overwhelming for programming beginners to have so many files to use the library. So like the minified version of the jQuery library, let's have two versions of the library; one is for the development of the library itself and the other is for the users to just include.

For the developers who fork the library:

  • class/admin-page-framework.php
  • class/debug/AdminPageFramework_Debug.php
  • class/page/AdminPageFramework_Page.php
  • class/page/AdminPageFramework_Setting.php
  • ....

For the users who just use the library:

  • class/admin-page-framework.min.php

In order to make this possible, a script to combine and minify those separate files to create the minified version is needed. If somebody can take this task, it would be greatly appreciated.

Form Fields in Taxonomy Page

#53

Meta Boxes in Pages Added by the Framework

#52

The 'attributes' key in Field Definition Array

This is already included in the 3.0.0b branch. What is does is to define tag attributes by array.

For example,

$aAttributes = array( 'name' => 'my_name', 'type' => 'text'  );

will generate <input name="my_name" type="text" />

Include Documentation

Include the documentation in the demo plugin. #55 (comment)

Your Ideas

Let me know what you think and tell me if something else should be changed or introduced.

Development Branch

It's now ready to be tested.
https://github.com/michaeluno/admin-page-framework/tree/3.0.0b

admin_page_framework_v3b

  • The classes are moved to separate files.
  • Most of the methods, properties, variables, and array keys, were renamed.
  • Many of the classes were renamed.
  • The section key was dropped from the saved option structure.
  • Changed the field definition array structure to the one suggested above.
  • Improved the repeatable fields mechanism including adding the ability to set custom callback JavaScript functions for repeat field events.
  • Added more examples in the demo plugin.
  • Supported the sortable fields.
  • Dropped the page slug dimension from the saved option structure.
  • Made it possible to pass settings to repeatable fields including setting maximum and minimum numbers of fields.
  • Fixed a bug that caused infinite function calls in some PHP versions. #54
  • Meta boxes for pages added by framework are now supported.
  • Taxonomy Fields are now supported.
  • Documentation is now included in the demo plugin.
  • Added the info of deprecated filters.

[Edit]

  • 12/23/2013 - Added the request of dashicons support. Added the idea of the minified version,
  • 12/24/2013 - Added the Goal part with the reasons of the change. Updated the descriptions of variable and method naming.
  • 12/25/2013 - Removed the dashicons part since v2 now supports it.
  • 01/05/2013 - Added an idea to drop the page slug key from the option array structure. Added a list of changes that have been already done in the 3.0.0b branch.
  • 01/08/2013 - Updated the status of the 3.0.0b branch.
  • 01/09/2013 - Updated the status of the 3.0.0b branch.
  • 01/10/2013 - Updated the status of the 3.0.0b branch.
  • 01/18/2014 - Updated the status of the 3.0.0b branch. Added an idea of form fields in taxonomy page, meta boxes in pages added by the framework, and Attributes array in the field definition array.
  • 01/23/2014 - Updated the status of the 3.0.0b branch. Added an idea of including documentation.
  • 02/02/2014 - Updated the status of the 3.0.0b branch.

Change the naming of the filters, {extended class name} + _ + section_ + {section ID} and {extended class name} + _ + field_ + {field ID}

extended class name + _ + section_ + section ID – receives the description output of the given form section ID. The first parameter: output string. The second parameter: the array of option.
extended class name + _ + field_ + field ID – receives the form input field output of the given input field ID. The first parameter: output string. The second parameter: the array of option.

These filters may ought to be changed to section_ + {extended class name} + _ + {section ID} and field_ + {extended class name} + _ + {section ID} to be consistent with the names of the other filters.

Not yet compatible with 3.6

Received error when using with WP 3.6:

Strict standards: Declaration of Admin_Page_Framework_Walker_Category_Checklist::start_el() should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0)...

Enhancement Idea: New Field HTML

Hi,

while working on a project I found out, that a simple HTML field could be helpful.

A field rendered in a section by just adding a simple empty div where you can add HTML.

Like this

private function getHtmlField( $arrOutput=array() ) {

    $arrFields = $this->arrField['fRepeatable'] ? 
        ( empty( $this->vValue ) ? array( '' ) : ( array ) $this->vValue )
        : $this->arrField['vLabel'];

    foreach( ( array ) $arrFields as $strKey => $strLabel ) 
        $arrOutput[] = "<div class='{$this->strFieldClassSelector}' id='field-{$this->strTagID}_{$strKey}'>"
                . "<div class='" . $this->getCorrespondingArrayValue( $this->arrField['vClassAttribute'], $strKey, '' ) . "'>"
                . $this->getCorrespondingArrayValue( $this->arrField['vContent'], $strKey, '' ) 
            . "</div></div>";

    return "<div class='admin-page-framework-field-html' id='{$this->strTagID}'>" 
            . implode( '', $arrOutput ) 
        . "</div>";

}

and usage:

array(  // Sample HTML field
            'strFieldID' => 'field_sample_html',
            'strSectionID' => 'section_html',
            'strTitle' => __( 'Sample HTML Box' ),
            'strType' => 'html',
            'vClassAttribute' => 'textclass',
            'vContent'  => '<strong>HTML Text</strong><br/>Hi there',
        )

And output it like this. So you can use some jQuery for example to set some info for the user. For example a checklist which shows what kind of files are need to be uploaded and which are already in the database.

Reset button

Please add reset as a new field type to strType.

I kown I can do it using the example on APF -> Manage Options -> Reset demo, but I believe it should be part of the framework.

Btw, I really really like the framework :)

File Upload Field doesn´t seem to work

The File Upload Field does not work for me. When I upload a file (e.g. pdf, text or even an image) no file is added to the media library or to any other folder. The input field which shows the name of the file is cleared when saving the data.

Besides when using an image upload field text-files, or other files are uploaded to the media library.

Maybe it´s usefull to add an extra definition to the file field to support MIME Types?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.