config = $config; } /** * Retrieves raw data and decodes it, returns an array of templates. * * @since 2.7 * * @return array */ public function get_templates() { if ( is_array( $this->templates ) ) { return $this->templates; } $uri = rgar( $this->config, 'uri' ); $this->templates = include_once $uri; return $this->templates; } /** * Returns a template by its ID. * * @since 2.7 * * @param string $id The id of the template. * * @return GF_Template_Library_Template|false */ public function get( $id ) { $template_data = rgar( $this->get_templates(), $id ); if ( ! $template_data ) { return false; } return new GF_Template_Library_Template( $template_data ); } /** * Returns all the templates, optionally including the form meta. * * @since 2.7 * * @param bool $include_meta whether to include the template form meta or not. * * @return array */ public function all( $include_meta = false ) { if ( $include_meta ) { return $this->get_templates(); } $templates_data = array_map( function( $template_data ) { unset( $template_data['form_meta'] ); unset( $template_data['version'] ); return $template_data; }, $this->get_templates() ); return $templates_data; } }