Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About haymanpl

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. $text_meta is equal to the custom field value as seen in this external function // Gets the text meta data value from the provided key. function get_text_meta( $key, $post_id = '' ){ $post_id = $post_id ? $post_id : get_the_ID(); $text_meta = get_post_meta( $post_id, '_text_field_meta', true ); if( empty( $text_meta[$key] ) ){ return false; } return $text_meta[$key]; } Note : When i add the extra text fields in the parent theme class for testing, it works, meaning i only need to modify the default fields() function.
  2. static public function meta_box( $post ){ global $Text_Meta; wp_nonce_field( CLASSES_DIR, '_text_nonce' ); echo '<table class="form-table"><tbody>'; $Text_Meta->fields(); echo '</tbody></table>'; }
  3. It uses several functions within the parent class and then loads the fields in admin using get_meta_box. When i test the child class using this code, it outputs correctly so the child class is loading correctly, its just not appending the new fields to the existing fields coded in the parent class. function test() { add_action('admin_notices', function(){ print '<div class="updated">' . __CLASS__ . ' loaded!</div>'; }); } $new = new More_Fields(); $new->test();
  4. All functions within the parent class are public. There's no getFields(). It uses custom fields. Thats why i uses a child class to extend the default parent theme function and add more fields. There's 2 functions for the fields. 1 for the input which is this : function fields() { $this->_fields = array( array( 'name' => 'text_one', 'label' => __('Text One'), 'type' => 'text', ) ); } And 1 for the output which is NOT contained within the parent class. function get_more_fields() { $text_fields = array( 'text_one', 'text_two', 'text_three', 'text_four', 'text_five' ); $values = array(); // Code return $values; }
  5. Can't use protected as the $fields are already private in the parent class. I'm trying to modify the parent class using a child class.
  6. I think this has something to do with the loading of the file for the child class. I need to load the child class after the parent class so it adds the extra field. Maybe i'm loading it before?
  7. The fields in the parent class are private private $_fields; However, the access to the fields() function is public @access public I can simply create a new function for the output and add the extra fields however for some reason this doesn't change the input fields() function in admin. There are no errors. Is there another way to do this?
  8. Thanks Barand. The only problem is the original function for the output showFields(), is not located inside the original parent class file. It's added in the functions file. function admin_fields( $post_id = '' ) { // Output Code }
  9. Alex, i'm simply trying to add another field to the parent class using a child class. The parent class already executes the code.
  10. Error reporting is turned on. Runs because i tested it but it doesn't add the extra field. Can anyone else help?
  11. Here's the actual code which adds another text field. // Parent class Default_Fields { public function fields() { $this->_fields = array() array( 'name' => 'text_one', 'label' => __( 'Text One' ), 'type' => 'text', ), ); } } // Child class More_Fields extends Default_Fields { public function fields() { $this->_fields = array() array( 'name' => 'text_one', 'label' => __( 'Text One' ), 'type' => 'text', ), array( 'name' => 'text_two', 'label' => __( 'Text Two' ), 'type' => 'text', ), ); } } $new = new More_Fields; $new->fields();
  12. I need to add more code to an existing function located inside the parent class. I'm using code like this but can't get it working : // Parent class Default_Fields { public function fields() { $this->_fields = array() // Default Code } } // Child class More_Fields extends Default_Fields { public function fields() {  $this->_fields = array() // Modified Code } } $new = new More_Fields; $new->fields(); The modified code in the child class is an extended version of whats in the parent. There's no errors but the additional code is not printing.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.