setArguments( array( 'description' => __( 'This is a sample widget with form sections created by Admin Page Framework.', 'admin-page-framework-loader' ), ) ); } /** * Sets up the form. * * Alternatively you may use load_{instantiated class name} method. */ public function load() { $this->addSettingSections( array( 'section_id' => 'apf_sample_image', 'title' => __( 'Image', 'admin-page-framework-loader' ), 'description' => __( 'Shows a selected image in the front-end.', 'admin-page-framework-loader' ), ) ); $this->addSettingFields( 'apf_sample_image', array( 'field_id' => 'image', 'type' => 'image', 'title' => __( 'Image', 'admin-page-framework-loader' ), ), array( 'field_id' => 'bg_color', 'type' => 'color', 'title' => __( 'Bacground Color', 'admin-page-framework-loader' ), ), array( 'field_id' => 'todays_word', 'tip' => __( 'One of the listed items will be displayed randomly at a time.', 'admin-page-framework-loader' ), 'type' => 'text', 'title' => __( 'Today\'s Word', 'admin-page-framework-loader' ), // ' 'repeatable' => true, // 'label' => array( // 'a' => 'A', // 'b' => 'B', // 'c' => 'C', // ), ), array() ); } /** * Validates the submitted form data. * * Alternatively you may use validation_{instantiated class name} method. */ public function validate( $aSubmit, $aStored, $oAdminWidget ) { // Uncomment the following line to check the submitted value. // AdminPageFramework_Debug::log( $aSubmit ); return $aSubmit; } /** * Print out the contents in the front-end. * * Alternatively you may use the content_{instantiated class name} method. */ public function content( $sContent, $aArguments, $aFormData ) { $_sImageURL = esc_url( $this->oUtil->getElement( $aFormData, array( 'apf_sample_image', 'image' ) ) ); $_sAlt = esc_attr( __( 'Sample Image', 'admin-page-framework-loader' ) ); $_sBGColor = esc_attr( $this->oUtil->getElement( $aFormData, array( 'apf_sample_image', 'bg_color' ) ) ); $_aTodaysWord = $this->oUtil->getElementAsArray( $aFormData, array( 'apf_sample_image', 'todays_word' ) ); shuffle( $_aTodaysWord ); $_sTodaysWord = $this->oUtil->getElement( $_aTodaysWord, 0 ); return $sContent . "
" . "{$_sAlt}" . "" . $_sTodaysWord . "" . "
"; } } new APF_Widget_WithSection( __( 'Admin Page Framework - With Section', 'admin-page-framework-loader' ) // the widget title );