Giter Club home page Giter Club logo

wpalchemy's Introduction

wpalchemy's People

Contributors

farinspace avatar helgatheviking avatar herewithme avatar highergroundstudio avatar paulcedrick 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wpalchemy's Issues

Media Overlay not reset

When the custom media overlay is closed without using the submit button, for example a#TB_closeWindowButton, the submit button is not reset to it's default state. To be able to insert media to the editor you must first add media to the custom meta field or refresh the page.

probably found and bug, please use code below:

Please write an test metabox with the following code:

have_fields_and_multi('product_multi_images', array('length'=>1, 'limit'=>5)) ) { $mb->the_group_open('image_group'); ``` $mb->the_group_close(); ``` } ?>

Add another image

When setting both have_fields_and_multi and the_group_open with variable text the button will never fire. No matter what groupname I put in the docopy- class.

Post types ...and magic_methods

Hi, a small suggestion; instead this:

    $this->types = array('post', 'page');

    if (is_array($arr))
    {
        foreach ($arr as $n => $v)
        {
            $this->$n = $v;
        }
    }

You can use php magic methods (getters and setters), in this case __get() and __set() as a decorator or singleton pattern:

public function __set($name, $value) {
    $this->arr["{$name}"] = $value;
}
public function __get($name) {
    if ( array_key_exists($name, $this->arr) ) {
        return $this->arr["{$name}"];
    }
}

public function __set($name, $value) {
    $this->object->name = $value;
}
public function __get($name) {
    return $this->object->$name;
}

or with instance of singleton:

public function __set($name, $value) {
    self::$instance->$name = $value;
}
public function __get($name) {
    return self::$instance->$name;
}

I think, in case of post_types, the most elegant way is:
set and getPostTypes();
...and with Fluent Interface you can write one line to build this parameters:

// Singleton:
WPAlchemy_MetaBox::getInstance()->setPostTypes(array $postTypes);

Also, we can check post_types to allow some post types only (not or builtin for example).

Include / Excluded Based on Taxonomy

seems like we can include/exclude on almost everything else.... (with the exception of post formats). thought i'd officially add it to your to-do list.

Wordpress Media Buttons

It would be awesome if we could use the Media buttons built into wordpress, instead of using custom upload fields.

Another approach to avoid saving data

Instead of returning false in the save_filter to avoid saving, we could add an option to the 'MODE' argument -> WPALCHEMY_MODE_NOSAVE.

This would make things a lot clearer for end-users. Also the debugging and testing of projects might be easier. It is easy to forget an 'return false;' but when you check the code and see 'NOSAVE' it is pretty obvious.

quote problem inside the value of input text

Hello,

I see you have a related (closed) issue with short codes and double quote characters. My issue is that text in a postmeta field containing a double quote character is written to the page incorrectly. Note that this is not a problem with the textarea tag just the input tag.

Example output from a template:

<input type="text" class='text' size="15" name="guest_info[title]" value="test "text""/>

I understand I can wrap the_value() in a php function, it just seems to me that the class should handle this.

Thanks for a such a handy function!

Fatal error: Call to a member function the_meta()

I'm having error when i call the_meta() from single.php, im using wordpress 3.4.1, and WordPress Alchemy Metabox Class 1.4.17, my functions.php

include_once ( get_template_directory() .'/metaboxes/setup.php');
include_once( get_template_directory() .'/metaboxes/custom-spec.php');

my setup.php

    include_once WP_CONTENT_DIR . '/wpalchemy/MetaBox.php';
    include_once WP_CONTENT_DIR . '/wpalchemy/MediaAccess.php';

// include css to help style our custom meta boxes
add_action( 'init', 'my_metabox_styles' );

function my_metabox_styles()
{
    if ( is_admin() ) 
    { 
        wp_enqueue_style( 'wpalchemy-metabox', get_stylesheet_directory_uri() . '/metaboxes/meta.css' );
    }
}

$wpalchemy_media_access = new WPAlchemy_MediaAccess();

custom-spec.php

<?php
$custom_mb = new WPAlchemy_MetaBox(array
(
    'id' => '_custom_meta',
    'title' => 'My Custom Meta',
    'template' => get_stylesheet_directory() . '/metaboxes/custom-meta.php',
));

and single.php

<?php //inside loop.......... ?>
<?php global $custom_mb ?>
<?php echo $custom_mb->the_meta();?>

ERROR is :Fatal error: Call to a member function the_meta() on a non-object in C:\wamp\www\wp\wp-content\themes\twentyeleven\single.php on line 19

pleas help me to find the cause of error

Folder Structure

Would it be better for end users if you simply had the two php files within the wpalchemy folder (along with credits, licence etc). Perhaps have the functions.php content within the readme.

That way it could be just included into a vendor directory

javascript error in my setup

You wont believe the linenumber :P

On line 1337 of metabox.php (var the_match = the_prop.match(/[(\d+)]/i);):
You are setting the_match value to some value. However in my current setup the_match variable will be an null value. Which in turn causes the next line to break.

Please add: if (the_match!=null) on line 1338

Missing return

Missing a 'return' in class WPAlchemy_MediaAccess on line 121

Drop Down to select metaboxes

Hi,

I was wondering if there is an easy way to create a "mother" metabox, with a drop down of all metaboxes coded, and when one is selected, it load the appropriate metabox and insert it in the page. Something similar to a repeater but that let you choose what kind of metabox you want to add.

Thanks in advance for your help

Broken foreach loop

When mode is set to WPALCHEMY_MODE_EXTRACT, and you leave all fields empty, you receive an Invalid argument supplied for foreach() on link on 778.

I fixed this with an if(count($new_data) > 0) for now.

WP 3.3 and wp_editor()

Just wondering about WP3.3 compatibility and using the new wp_editor() function with wpalchemy

Undefined Constant

When WP_Debug is turned on, I receive an error about an undefined constant.

Notice: Use of undefined constant WPAlchemy_MetaBox - assumed 'WPAlchemy_MetaBox' in /localwebsiteurl/wp-content/themes/themename/WPAlchemy/MetaBox.php on line 33

Has occurred on two installations for me.

Update site URL empties fields

When I crawl the database to update the URL's for my site (ex local > live) any field that is using the MediaAccess class gets emptied, even though the entry still exist in the database. Any ideas?

have_fields_and_multi() "docopy-xxxx" class not behaving with WP Set Featured Image

Running WordPress 3.1 RC2 on a multi-site install I am getting a bug when using the have_fields_and_multi(). When trying to set a featured image, the pop box that normally appears ends up loading by itself on a blank page.

After troubleshooting, I've narrowed it down to the "docopy-xxxx" class on the button that adds another instance. When changing "docopy-xxxx" to someting else "docopy1-xxxx", the set featured image works, but of course not the add button. If I change the "docopy-xxxx" to "docopy-xxxx1", the set featured image doesn't work again, so it has to do with the "docopy" text. I did a short screencast below of whats happening.

Screencast - http://screenr.com/1kt

Placeholder Content

I'd like to have some default, or conditional content in a metabox. This would be similar to an empty widget area in a theme that tells someone to add a widget:

    <div class="alert-box"><h4>Hey! You!</h4>
    You should like, so test out this dynamic sidebar. Check it out in Appearance > Widgets!</div>
    <?php endif; ?>

I don't know how to include the "if" when I echo my metabox in my theme template. Any advice?

Thanks

Can only use this once!

Right out the box you can't use this in more than one plugin/theme on the same site. If you do you get errors regarding:
Notice: Constant WPALCHEMY_MODE_ARRAY already defined in /opt/local/apache2/htdocs/gettasktracker/html/wp-content/plugins/task-tracker/library/php/wpalchemy/wp-content/wpalchemy/MetaBox.php on line 20

Example:
plugin A uses wpalchemy
plugin B uses wpalchemy
Both are active on the same site and you get a plethora of errors.

Recommended fix:

  1. Change your instructions: http://www.farinspace.com/wpalchemy-metabox/#usage recommending that the developer place this in the plugins dir, and include it once per site.
  2. Wrap each, class, function and defined constant in a conditional.

Let me know what you think, I don't mind doing option 2 myself, and then submitting a pull request, but would like to know your intended use first.

send_to_editor is not defined

Hi, I'm using Wordpress 3.1.2 and MetaBox.php version 1.4.9.

This error comes up when I included the MediaAccess.php in my theme :
send_to_editor is not defined

on this line :
var wpalchemy_send_to_editor_default = send_to_editor;

I think it made the WP Admin JS not working - I tried removing MediaAcess.php and JS are functioning.

Thanks

problem importing data

Hi. If I do an export > import with the wordpress admin, during import I get an error form wp that says that here (row 523):

update_post_meta($post_id, $key, maybe_unserialize(stripslashes($value)));

stripslashes gets an array instead of a string. So the meta field don't get saved/imported in db (checked the db to be sure).

By stripping stripslashes, all works fine.

init_action to accept an array

feature: can init_action, and by extension, footer_action, save_action, head_action, etc..., be made to accept an array of functions?

unnecessary code checks on line 2024 of metabox.php

Please allow me to post the wordpress codex section about update_post_meta:

This may be used in place of add_post_meta() function. The first thing this function will do is make sure that $meta_key already exists on $post_id. If it does not, add_post_meta($post_id, $meta_key, $meta_value) is called instead and its result is returned.

Wordpress checks if the key is double by itself. No need to have metabox do it also, in my humble opinion.

Prefixing/namespacing CSS classes as well as PHP and JS vars

Hi Dimas,

At your request, here is my issue.

It might be worth considering extending the prefix definitions to also apply to the various javascript vars and related css classes that control metabox duplication, manipulation, and media insertion. I just ran into a case where such naming conflicts (particularly with docopy, dodelete, tocopy) caused erratic behavior since apparently another dev has also used WPAlchemy w/ MediaAccess.php on the same site prior to me. I was able overcome this with brute-force renaming in this case, but having the ability to set the prefix once to easily avoid conflicts would probably be a benefit to others.

My scenario:

Another dev set up a custom post type then apparently used WPA to allow the client to add paypal buttons and such to posts/pages. I then created a custom slideshow builder using WPA for her that are also used on pots/pages. I use the repeating fields feature. When I went to add another group, it would create two groups. Then I looked at the code and saw why: two versions of WPA running causing any WPA events to fire twice.

Having WPAlchemy installed in a public bin/library wouldn’t have mattered in my particular case because I use a modified version of the media access class. The version I use incorporates WP AJAX callback for an improved UX. It also grabs the selected media attachment’s ID as opposed to the file url, allows me to do all kinds of fun stuff with the media such as grab various thumbnail/image sizes, use exif data, grab alt and title text, etc.

I hope I've explained this well enough.

the confirmation on group delete button should be togglable and text should be custom

I believe that the code would improve by being able to have the user define if the group delete button should have an javascript confirm alert, and if yes it should be customizable.

This can be done globally by setting an wordpress javascript variable like so:

wp_localize_script( , , <value/array/etc>);
wp_localize_script( 'MetaBox', 'confirmation', array('delete_confirm'=>'true', 'text'=>__('sometext')) );

Not sure the scriptname will work, because you load your javascript inside metabox. I like to seperate it. Which might be a good idea for an future version also.

Can't edit serialized array

first, thanks!

I'm inserting data into a custom field using values collected from a form (gravity forms) and then serialized like so:

function serilaize_fields( $post_data, $form ) {

    $place_meta['web']       = $_POST['input_13'];
    $place_meta['facebook']  = $_POST['input_16'];
    $place_meta['twitter']   = $_POST['input_17'];

    $post_data['post_custom_fields']['place_meta'] = serialize( $place_meta );

    return $post_data;
}

When viewing the post with the metabox I can actually see the collected values in the metabox fields but when editing/changing them and saving the post the values revert to the original ones that were inserted by the form.

When directly editing the custom field serialized array (the original WP UI) the new values seem to be ok.

for reference, the metabox code:

$place_meta = new WPAlchemy_MetaBox( array( 'id' => 'place_meta', 
                                            'title' => 'Place Meta',
                                            'template' => TEMPLATEPATH.'/WPAlchemy/custom/place_meta.php',
                                            'view' => 'always_opened',
                                            'hide_screen_option' => TRUE,
                                            'context' => 'advanced',
                                            'priority' => 'high'
                                            ) );

thanks again!

_global_foot() script causes bugs in IE [suggestion]

While debugging a client's site, I noticed that working in IE tends to get buggy when the ondomready event isn't used. I wrapped the function in a $(document).ready(function() wrapped around the function and it cleared up the bugs.

Cursory check of the main js interactions and they all still seem to work, but I'm no Javascript Guru - so if there's a good reason not to do this then please explain.

Define Media MIME Type

Currently, you can enter an audio file into an image field because there is no way to validate whether the input is of the correct MIME Type.

Perhaps, it would be best to be able to define the input type in the code. I want users to enter just images (and not audio/video) into this field:

<?php $mb->the_field('imgurl'); ?>
<?php $mediaAccess->setGroupName('imagepost')->setInsertButtonLabel('Insert'); ?>

<p>
<?php echo $mediaAccess->getField(array(
        'name' => $mb->get_the_name(),
        'value' => $mb->get_the_value()));
 ?>     

<?php echo $mediaAccess->getButton(array('label' => 'Add Image from Library')); ?>
</p>

Maybe it is possible to leverage the post_mime_type filter of the Wordpress Media Library.

Also, would it be able to acquire the corresponding information for the file (alt, title, description)?

Cheers.

Nested have_fields_and_multi groups?

I would LOVE to be able to duplicate groups of duplicatable groups. Does that make sense? Can I do this? My brief attempt led to a 500 error, so I'm thinking I can't.

A visual explanation, since that's probably better:

My Meta Box --------------

-- Group 1
--- Sub-Group 1
---- Field 1 | Field 2 | Field 3
--- Sub-Group 2
----- Field 1 | Field 2 | Field 3
--- < button: add a new sub-group >

-- Group 2
--- Sub-Group 1
---- Field 1 | Field 2 | Field 3
--- < button: add a new sub-group >

-- < button: add a new group >


Yes? No? I can see a bagillion uses for this if it's possible!

Problem with header information on WP 3.3.1

Just tried to use wpAlchemy on a site running wp3.3.1 and when trying to save or update a post I get the following messages:

Notice: wp_enqueue_style was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /_my_root_path_/wp-includes/functions.php on line 3587

Warning: Cannot modify header information - headers already sent by (output started at /_my_root_path_/wp-includes/functions.php:3587) in /_my_root_path_/wp-includes/pluggable.php on line 866```

Any suggestions would be great! Very happy to try things out if that helps.

Cheers,
Harrison

iFrame and Embed support for TextAreas

In version 1.4.9, the ability to provide an iframe or embed code produced the desired results.

In versions 1.4.10 and 1.4.11, iframes and embed codes don't work as only the code is displayed.

jquery clone (when duplicating the group) doesnt copy jquery events

On my image selector I have attached an jquery event to the browse button.

This event is currently not copied by the metabox code. This can be achieved very easy by changing the following line (1325):
var the_clone = the_group.clone().removeClass('tocopy');
to:
var the_clone = the_group.clone(true).removeClass('tocopy');

The true argument makes sure that alle linked events are duplicated also. I use this functionality in my add_taxonomy class.

Post Format Support

I mentioned this on WPAlchemy comments and thought I would officially post it here. The idea is to show a metabox based on a specific post format (gallery, video, aside, etc). This would work similar to the include_template functionality where the post would require it to be saved/published (or some kind of jQuery work). I currently have a perfect scenario for this where it would come in useful. I think others may find it useful as well.

have_fields_and_multi produces error $(".wpa_loop-" + name).attr("class").match(/wpa_loop_limit-([0-9]*)/i) is null

I had created a metabox and copied over the sample code for have_fields_and_multi. then when i upgraded to the 1.4.1 version the post edit page will not load and firebug shows the following error:

$(".wpa_loop-" + name).attr("class").match(/wpa_loop_limit-([0-9]*)/i) is null

expanded the error looks like:

$(".wpa_loop-" + name).attr("class").match(/wpa_loop_limit-([0-9])/i) is null
checkLoopLimit(name="docs")post.p...ssage=1 (line 128)
(?)()post.p...ssage=1 (line 145)
nodeName(j=jQuery(a.docopy-docs #✉), s=function(), v=a.docopy-docs #✉)load-s...d1cbccf (line 33)
toArray(j=function(), s=undefined)load-s...d1cbccf (line 26)
(?)($=function())post.p...ssage=1 (line 141)
noConflict(j=function())load-s...d1cbccf (line 29)
inArray()load-s...d1cbccf (line 37)
[Break On This Error] var the_limit = $('.wpa_loop-' + n...match(/wpa_loop_limit-([0-9]
)/i)[1];
post.p...ssage=1 (line 128)

a visual:
http://img683.imageshack.us/img683/2243/wpalchemyerror.png

my meta box is defined via:
$featured_metabox = new WPAlchemy_MetaBox(array
(
'id' => '_featured_meta', // underscore prefix hides fields from the custom fields area
'title' => _('Add a Featured Posts Slider'),
'template' => FUNCTIONS_PATH .'WPAlchemy/new_featured_meta.php',
'prefix' => 'featured_meta',
'types' => array('page','post'),
'priority' => 'high',
'hide_editor' => TRUE, // defaults to NULL

));

where FUNCTIONS_PATH is a constant i've defined. this was working up until i moved to the newest version.

Break repo up into 2 separate projects

You should really split this project up into 2, to make it easier for people to include wpalchemy into their own projects using git submodules. wpalchemy/wp-content/wpalchemy should be moved out into its own project, and then maybe you could make another project called wpalchemy-examples which contains all the other stuff (wp-content/themes etc.) and includes wpalchemy as a git submodule.

For example, I'm building a site now which I source control using git. It would be great if I could do:

git submodule add git://github.com/farinspace/wpalchemy.git wpalchemy

and just get the actual wpalchemy code included into my project, and not the examples (wp-content/themes etc.)

sidekick css/js warnings on wp 3.4.1

Hi, I have these wornings on a fresh wp 3.4.1 installation of sidekick:

Warning: filemtime() [function.filemtime]: stat failed for /accounts/[...]/wp-content/plugins/sidekick/assets/core.css in /accounts/[...]/wp-content/plugins/sidekick/sidekick.php on line 117

Warning: filemtime() [function.filemtime]: stat failed for /accounts/[...]/wp-content/plugins/sidekick/assets/core.js in /accounts/[...]/wp-content/plugins/sidekick/sidekick.php on line 121

Luca

Bug when deleting groups using have_fields_and_multi()

I've come across a bug when deleting groups using have_fields_and_multi(). Randomly, it will either delete the group as expected or anchor back to the top of page without deleting the group. I've had it take upto 4 clicks to finally delete a group. I've created a short screenr video that will hopefully help demonstrate what I'm seeing.

Video Link: http://screenr.com/c5D

I'm currently using version 1.3.12.

Meta Fields & Table Issues

We're trying to style the output of our meta boxes a little to make them a little neater than just having text and boxes by using tables and the WordPress table class widefat. The issues we're having are:

1). We can't add a new row with the table intact. We have to remove the table HTML to be able to add a row. Otherwise clicking the button does nothing.

2). We can't delete a row, for the same reason as above.

3). Using tables, an extra blank row is always added at the bottom and cannot be removed.

I've pasted our code below:

http://pastebin.com/eQxggzP6

Do we need to assign ID's or Classes to the TD's? Or perhaps something else?

Any help would be much appreciated!

Drag & Drop for have_fields_and_multi

It'd be awesome to see the ability to drag, drop, and order the fields within the have_fields_and_multi container, much how we can freely move the sidebar widgets up and down, and basically place them wherever we'd like :-).

Surely this could be done with a little more JS, though I've yet to get it working using a few snippets.

Data type / format validation.

I was just wondering if you implemented anything like data validation in the class yet ?

If it's not the case I think it would be a great addition.

Just dropping my 2 cents here ;-)

edit:
I just read myself again - what I meant is more checking for data type (string, int, float, ..) or string format (email, phone number, ...). That could even be achieved using the new input type in html 5.

Would anybody find this useful ?

Undefined Index

I'm getting an Undefined Index notice for meta boxes that have options but do not have at least one set. For example, one metabox has three checkboxes. If one checkbox is not set, I get the following PHP Notice:

PHP Notice: Undefined index: _example_metabox in /Users/.../MetaBox.php on line 2162

After I check a box, the notice goes away. I know it doesn't hurt anything, but I would rather not have it show at all. This notice gets generated for each meta box ID that does not have an option set. It also gets generated when the post Auto-Saves... which ends up filling up my debug file while in development :)

Any ideas on a quick fix?

Setup Details:
WordPress Version: 3.3-beta2-19067 Multi-site
WPAlchemy Version: 1.4.15

Try to find the nonce id in my custom save

in my pre_save_check in save_filter (check if the nouce is correct and no autosave is executing) I need to check the metabox id to compare the nounce.

At the moment the metabox class does not have an function to recall the current metaboxid. Would it be possible to return it to the save hooks?

Adding random vars to the save hook is not preferred, it might be better to pass the metabox object.

include_post_id not working with pages?

Here's my code:

<?php

$mb_newsletter = new WPAlchemy_MetaBox(array
(
    'id' => '_mb_newsletter',
    'title' => 'Newsletter Options',
    'template' => WPMU_PLUGIN_DIR . '/sabramedia/metaboxes/newsletter-meta.php',
    'mode' => WPALCHEMY_MODE_EXTRACT,
    'include_post_id' => 17
));

The page in question does indeed have an ID of 17. It's not showing up, though. Any ideas?

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.