templates_store = $templates_store; $this->license_api = $license_api; } public function should_enqueue() { $current_page = trim( strtolower( rgget( 'page' ) ) ); $gf_pages = array( 'gf_edit_forms', 'gf_new_form' ); return in_array( $current_page, $gf_pages ); } /** * Config data. * * @return array[] */ public function data() { $license_info = $this->license_api->check_license(); return array( 'components' => array( 'template_library' => array( 'endpoints' => $this->get_endpoints(), 'i18n' => array( 'description' => __( 'Form Description', 'gravityforms' ), 'title' => __( 'Form Title', 'gravityforms' ), 'titlePlaceholder' => __( 'Enter the form title', 'gravityforms' ), 'required' => __( 'Required', 'gravityforms' ), 'useTemplate' => __( 'Use Template', 'gravityforms' ), 'closeButton' => __( 'Close', 'gravityforms' ), /* translators: title of template */ 'useTemplateWithTitle' => __( 'Use Template %s', 'gravityforms' ), 'createActiveText' => __( 'Creating Form', 'gravityforms' ), 'missingTitle' => __( 'Please enter a valid form title.', 'gravityforms' ), 'duplicateTitle' => __( 'Please enter a unique form title.', 'gravityforms' ), 'failedRequest' => __( 'There was an issue creating your form.', 'gravityforms' ), 'failedRequestDialogTitle' => __( 'Import failed.', 'gravityforms' ), 'importErrorCloseText' => __( 'Close.', 'gravityforms' ), /* translators: title of template */ 'previewWithTitle' => __( 'Preview %s', 'gravityforms' ), 'cancel' => __( 'Cancel', 'gravityforms' ), 'blankForm' => __( 'Blank Form', 'gravityforms' ), 'createForm' => __( 'Create Blank Form', 'gravityforms' ), 'blankFormTitle' => __( 'New Blank Form', 'gravityforms' ), 'blankFormDescription' => __( 'A new blank form', 'gravityforms' ), 'formDescriptionPlaceHolder' => __( 'A form description goes here', 'gravityforms' ), 'heading' => __( 'Explore Form Templates', 'gravityforms' ), 'subheading' => __( 'Quickly create an amazing form by using a pre-made template, or start from scratch to tailor your form to your specific needs.', 'gravityforms' ), 'upgradeTag' => __( 'Upgrade', 'gravityforms' ), /* translators: %1$s is anchor opening tag, %2$s is anchor closing tag */ 'upgradeAlert' => sprintf( __( 'This template uses Add-ons not included in your current license plan. %1$sUpgrade%2$s'), '', '' ), ), 'data' => array( 'thumbnail_url' => \GFCommon::get_image_url( 'template-library/' ), 'layout' => 'full-screen', 'templates' => array_values( $this->get_templates() ), 'licenseType' => $license_info->get_data_value( 'product_code' ), 'defaults' => array( 'isLibraryOpen' => rgget( 'page' ) === 'gf_new_form', 'flyoutOpen' => false, 'flyoutFooterButtonLabel' => '', 'flyoutTitleValue' => '', 'flyoutDescriptionValue' => '', 'selectedTemplate' => '', 'flyoutTitleErrorState' => false, 'flyoutTitleErrorMessage' => '', 'importError' => false, 'flyoutPrimaryLoadingState' => false, ), ), ), ), ); } /** * Returns the endpoints for handling form creation in the template library. * * @since 2.7 * * @return \array[][] */ private function get_endpoints() { return array( 'create_from_template' => array( 'action' => array( 'value' => GF_Create_Form_Template_Library_Endpoint::ACTION_NAME, 'default' => 'mock_endpoint', ), 'nonce' => array( 'value' => wp_create_nonce( GF_Create_Form_Template_Library_Endpoint::ACTION_NAME ), 'default' => 'nonce', ), ), ); } /** * Gets a list of the available templates from the data store. * * @since 2.7 * * @return array */ private function get_templates() { return $this->templates_store->all(); } }