expiration ); } catch ( Exception $e ) { return new WP_Error( 'exception_occurred', __( 'An error occurred while fetching templates.', 'everest-forms' ), array( 'status' => 500 ) ); } } $folder_path = untrailingslashit( plugin_dir_path( EVF_PLUGIN_FILE ) . '/assets/images/templates' ); foreach ( $template_data as $templates ) { foreach ( $templates as $template ) { foreach ( $template->templates as $temp ) { $image_url = isset( $temp->image ) ? $temp->image : ( $template_url . 'images/' . $temp->slug . '.png' ); $temp->imageUrl = $image_url; $temp_name = explode( '/', $image_url ); $relative_path = $folder_path . '/' . end( $temp_name ); $exists = file_exists( $relative_path ); if ( $exists ) { $temp->imageUrl = untrailingslashit( plugin_dir_url( EVF_PLUGIN_FILE ) ) . '/assets/images/templates/' . $temp->slug . '.png'; } $user_id = get_current_user_id(); if ( $user_id ) { $user_favorites = get_option( 'user_favorites', array() ); $favorite_slugs = isset( $user_favorites[ $user_id ] ) ? $user_favorites[ $user_id ] : array(); if ( in_array( $temp->slug, $favorite_slugs ) && ! in_array( 'Favorites', $temp->categories ) ) { array_unshift( $temp->categories, 'Favorites' ); } } } } } return rest_ensure_response( $template_data ); } /** * Get Templates Data List. * * @since 3.0.3 * * @return array */ public static function get_templates_data_list() { $extension_data = evf_get_json_file_contents( 'assets/templates-json/templates.json' ); return apply_filters( 'everest_forms_templates_section_data', $extension_data ); } /** * Create a Template. * * @since 3.0.3 * @param WP_REST_Request $request Full data about the request. * @return WP_REST_Request|WP_Error */ public function create_templates( WP_REST_Request $request ) { // Retrieve and sanitize parameters. $title = sanitize_text_field( wp_unslash( $request->get_param( 'title' ) ) ); $slug = sanitize_text_field( wp_unslash( $request->get_param( 'slug' ) ) ); // Check if the title parameter is empty. if ( empty( $title ) ) { return new WP_Error( 'invalid_template_name', __( 'The template name is required and cannot be empty.', 'everest-forms' ), array( 'status' => 400 ) ); } // Ensure the slug is also not empty (optional check based on your needs). if ( empty( $slug ) ) { return new WP_Error( 'invalid_template_slug', __( 'The template slug is required and cannot be empty.', 'everest-forms' ), array( 'status' => 400 ) ); } // Create the form using the title and slug. $form_id = evf()->form->create( $title, $slug ); // Check if form creation was successful. if ( $form_id ) { $data = array( 'id' => $form_id, 'redirect' => add_query_arg( array( 'tab' => 'fields', 'form_id' => $form_id, ), admin_url( 'admin.php?page=evf-builder' ) ), ); return new \WP_REST_Response( array( 'success' => true, 'data' => $data, ), 200 ); } else { // Handle the case where form creation failed. return new WP_Error( 'form_creation_failed', __( 'Something went wrong, please try again later.', 'everest-forms' ), array( 'status' => 500 ) ); } } /** * Check if a given request has access. * * @since 3.0.3 * * @param WP_REST_Request $request Full data about the request. * @return WP_Error|bool */ public function check_admin_permissions( $request ) { $nonce = $request->get_header( 'X-WP-Nonce' ); // Nonce check. if ( ! wp_verify_nonce( $nonce, 'wp_rest' ) ) { return new WP_Error( 'rest_forbidden', esc_html__( 'You do not have permissions to perform this action.', 'everest-forms' ), array( 'status' => 403 ) ); } // Capability check. if ( ! current_user_can( 'manage_options' ) ) { return new WP_Error( 'rest_forbidden', esc_html__( 'You are not allowed to access this resource.', 'everest-forms' ), array( 'status' => 403 ) ); } return true; } }
Fatal error: require_once(): Failed opening required '/var/www/html/saocaetanodigital.com.br/web/wp-content/plugins/wordfence/lib/Diff/Renderer/Html/Array.php' (include_path='.:/usr/share/pear') in /var/www/html/saocaetanodigital.com.br/web/wp-content/plugins/wordfence/lib/Diff/Renderer/Html/SideBySide.php on line 43