sectionId = $sectionInputId; $instance->sectionName = $sectionInputName; $instance->displayPage = $sectionInputDisplayPage; $instance->fieldsData = $fieldsDataInput; $instance->requiredParentProps = $requiredParentPropsInput; $instance->pmdt_load_by_property(); return $instance; } /** * The main function used to create the section, it also creates new objects of type field, this is used for the types. * * @since 0.13 */ function pmdt_load_by_property(){ add_settings_section( $this->sectionId, //Id to identify section $this->sectionName, //Title of the section array( $this, 'pmdt_property_section_draw' ), //Rendering the description of the section $this->displayPage //Which page to show the section ); //A loop that goes through the fieldData array and constructs fields corresponding to the arrays size foreach ($this->fieldsData as $property => $details) { //TODO Google and Schema.org have different schema types types for publisher property, Google only accepts Organization type for this field. Need to fix it somehow. if(is_array($this->requiredParentProps)){ //Checking if the property being processed is in the requiredParentProps array if(in_array($property,$this->requiredParentProps)){ //Changing the details array of the property to make it required for the current type $details[0] = true; } } //New field objects created with the fields class new Pressbooks_Metadata_Property_Fields($property,$details,$this->sectionId,$this->sectionName,$this->displayPage); } } /** * The main function used to render the description of the section. * * @since 0.8.1 */ function pmdt_property_section_draw(){ } /** * Function for creating an instance of settings for the schema properties. * * @since 0.10 */ public static function types( $sectionInputId,$sectionInputName,$sectionInputDisplayPage,$fieldsDataInput ) { $instance = new self(); $instance->sectionId = $sectionInputId; $instance->sectionName = $sectionInputName; $instance->displayPage = $sectionInputDisplayPage; $instance->fieldsData = $fieldsDataInput; $instance->pmdt_load_by_type(); return $instance; } /** * The main function used to create the section, it also creates new objects of type field, this is used for the types. * * @since 0.8.1 */ function pmdt_load_by_type(){ add_settings_section( $this->sectionId, //Id to identify section $this->sectionName, //Title of the section array( $this, 'pmdt_type_section_draw' ), //Rendering the description of the section $this->displayPage //Which page to show the section ); //A loop that goes through the fieldData array and constructs fields corresponding to the arrays size foreach ($this->fieldsData as $metaType => $metaInfo) { //New field objects created with the fields class new Pressbooks_Metadata_Fields($metaType,$metaInfo,$this->sectionId,$this->sectionName,$this->displayPage); } } /** * The main function used to render the description of the section. * * @since 0.8.1 */ function pmdt_type_section_draw(){ } }