diff --git a/docs/tutorials/first-custom-field.md b/docs/tutorials/first-custom-field.md new file mode 100644 index 00000000..21a70871 --- /dev/null +++ b/docs/tutorials/first-custom-field.md @@ -0,0 +1,166 @@ +# Creating Your First Custom Field + +A beginner-friendly guide to adding custom fields using Secure Custom Fields (SCF). + +**What is a custom field?** + +Custom fields let you add structured data to your content. With SCF, you can attach fields like text inputs, selects, image uploads, and more to your posts, pages, or custom post types. + +## Prerequisites + +- SCF installed and activated +- A post type (default or custom) where you'll attach your fields +- Administrator access to WordPress + +You can learn more about WordPress basics here: + +- [Theme Basics](https://developer.wordpress.org/themes/basics/) +- [Plugin Basics](https://developer.wordpress.org/plugins/plugin-basics/) + +## 1. Access the Admin Panel + +- Go to **SCF → Field Groups** in your WordPress admin menu. +- Click **"Add New"** to create a new group of fields. + +## 2. Basic Configuration + +### Field Group Title + +Give your field group a descriptive name, like `Movie Details` or `Product Specs`. + +### Location Rules + +Choose where this group should appear. For example: + +- Post type is equal to `Movie` +- Page template is `Product Page` + +This ensures your fields appear only where you need them. + +**Note:** This fine-grained control allows you to define SCF fields once and reuse them across different post types, templates, or components. + +### Active + +Make sure the field group is set to **Active** so it appears in the editor. + +**Note:** Some features require the field group to be **enabled** and **exposed via the REST API**. To future-proof your configuration, we recommend setting **Show in REST** to `true` when creating your field groups. + +## 3. Adding Fields + +To start building your custom field group, click the **"Add Field"** button. + +Each field requires at least a few basic settings to work correctly. All other options are optional and can be used to improve the user experience in the editor. + +--- + +### Minimum Required Settings + +In the **General** tab, you must define the following: + +- **Field Type** + Specifies what kind of data the field will store (e.g., Text, Image, Number, Select). + +- **Field Label** + The human-readable name shown in the editor (e.g., “Movie Title”). + +- **Field Name** + A unique identifier used in the code (lowercase, no spaces; underscores or dashes allowed). + +#### 📌 Example: Movie Fields + +Let’s say you want to create a group of fields for movie entries. Here's how you could configure it: + +| Field Label | Field Name | Field Type | Description | +|------------------|------------------|------------|------------------------------------------| +| Movie Title | `movie_title` | Text | Stores the name of the movie | +| Director | `director` | Text | Stores the name of the director | +| Release Year | `release_year` | Number | Stores the year the movie was released | +| Poster Image | `poster` | Image | Upload an image file for the movie poster | + +> 💡 These fields would be added one by one using the **Add Field** button, and each configured in the field editor panel. + +--- + +## General Settings + +Defines the field behavior and how it is stored: + +- **Field Type** + What kind of input this field accepts (text, image, number, etc.). + +- **Field Label** + The label shown to the user in the WordPress editor. + +- **Field Name** + The code-safe name used to retrieve the value in your templates or plugins. + +- **Default Value** + A pre-filled value shown if no value is entered. + +--- + +## Validation Settings + +Used to restrict and control the kind of data that can be entered: + +- **Required** + Makes the field mandatory. + +- **Minimum / Maximum Values** + For numeric or character-based fields. Useful for fields like `release_year`. + +- **Allowed Characters / Pattern** + Use a regular expression to restrict input format (e.g., only digits). + +- **Custom Validation Message** + Message shown if validation fails (e.g., “Please enter a valid year”). + +--- + +## Presentation Settings + +Controls the visual appearance of the field in the editor: + +- **Placeholder Text** + Example text shown inside the field input. + +- **Instructions** + Helper text shown below the field to guide users. + +- **Wrapper Attributes** + Custom HTML attributes like class or ID for styling or JavaScript. + +- **Hide Label** + Option to hide the field label (not recommended unless styled separately). + +--- + +## Conditional Logic + +Used to show or hide fields based on the value of other fields: + +- **Enable Conditions** + Activate conditional display rules for this field. + +- **Condition Rules** + Example: only show the “Director” field if “Content Type” equals “Movie”. + +--- + +> ⚠️ **Note:** Some settings may not be available for all field types. The options shown will adapt depending on the field you're configuring. + +--- + +### Final Step + +Repeat this process to add as many fields as needed to your group. Once ready, you can assign this field group to a post type and start entering content! + +## For Developers + +While Secure Custom Fields makes it easier to manage and display custom fields with a user-friendly interface, WordPress also includes native support for custom fields that can be managed programmatically using functions like `get_post_meta()` and `add_post_meta()`. + +You can learn more about WordPress native custom fields here: + +👉 [WordPress Native Custom Fields](https://developer.wordpress.org/plugins/metadata/custom-fields/) + +To access custom field values in your theme or plugin, use SCF functions you can learn more about SCF’s developer API in their official documentation. diff --git a/docs/tutorials/first-options-page.md b/docs/tutorials/first-options-page.md new file mode 100644 index 00000000..d497c801 --- /dev/null +++ b/docs/tutorials/first-options-page.md @@ -0,0 +1,121 @@ +# Creating Your First Options Page + +A step-by-step guide to building a global settings page using Secure Custom Fields (SCF). + +--- + +## What is an options page? + +An **options page** is a custom admin screen where you can store **site-wide settings** that are not tied to individual posts, pages, or taxonomies. These values are ideal for: + +- Contact details (phone, email, address) +- Social media links +- Global theme settings (colors, toggles, logos) +- Custom footer messages +- Business hours + +--- + +## How are these options related to themes? + +Options pages let you **manage shared values** that appear across the theme — without editing code each time a change is needed. + +### Example: Company Phone Number + +Suppose you want to display the company’s phone number in both the header and footer: + +1. Create an options page named `theme_options`. +2. Add a text field called `phone_number`. +3. Retrieve it in your classic theme like this: + +```php + +``` + +> This approach works with **Classic Themes** (non-block themes) where PHP templates are used for rendering. + +## Prerequisites + +- SCF (Secure Custom Fields) installed and activated +- Administrator access to WordPress +- Basic understanding of WordPress admin + +You can learn more about WordPress basics here: + +- [Theme Basics](https://developer.wordpress.org/themes/basics/) +- [Plugin Basics](https://developer.wordpress.org/plugins/plugin-basics/) + +## 1. Access the Admin Panel + +- Go to **Secure Custom Fields → Options Pages** in your WordPress admin sidebar. +- Click **"Add New"** to create your options page. + +## 2. Basic Configuration + +Set up the following fields to define the behavior and placement of your options page: + +### Basic Settings Panel + +- **Page Title**: The title displayed at the top of the options page (e.g., `Site Settings`). +- **Menu Slug**: A unique identifier for the page URL (e.g., `site-settings`). +- **Parent Page**: Choose `No Parent` to create a standalone page or select a parent if it should appear as a submenu item. +- **Advanced Configuration**: Enable to access additional options. + +### Advanced Settings Panel + +#### Visibility + +- **Menu Title**: Label that appears in the WordPress admin menu. +- **Menu Icon**: Choose an icon from Dashicons or upload a custom SVG or URL. +- **Menu Position**: Controls the position of the item in the admin sidebar. +- **Redirect to Child Page**: If enabled, this page redirects to its first child page automatically. + +#### Description + +- **Description**: A short description to help explain the purpose of this options page. + +#### Labels + +- **Update Button Label**: Text shown on the submit button (e.g., `Update Settings`). +- **Updated Message**: Message displayed after saving the options. + +#### Permissions + +- **Capability**: Required capability to view/edit this page (default is `edit_posts`). + +#### Data Storage + +- **Storage Location**: Choose whether to store the data in the options table (default) or bind it to a specific post, user, or term. +- **Custom Storage**: Use a specific post ID (e.g., `123`) or context string (e.g., `user_1`). +- **Autoload Options**: Enable to automatically load these values when WordPress initializes — useful for performance. + +Click **Save** to create the options page. Once saved, you can start adding custom fields as needed. + +## 3. Adding Fields + +Add fields just like you would for any post type or taxonomy. + +### Common Fields to Add + +- `company_name` — Company name (text) +- `support_email` — Support contact email (email) +- `emergency_alert_message` — Site-wide notice (textarea) +- `global_logo` — Logo image (image upload) + +Each of these fields will be accessible from any page or template. + +## For Developers + +Options pages provide a clean way to centralize configuration. In more advanced implementations, you can: + +- Register multiple options pages for different sections (e.g., Branding, API Keys) +- Use `get_option()` if working outside the SCF context +- Integrate with theme customizers or other plugin logic + +Secure Custom Fields simplifies this process, but WordPress also offers a native way to register and manage options pages through the **Settings API**. This allows full control over settings registration, sanitization, and display via code. + +👉 Learn more about the WordPress Settings API: +[https://developer.wordpress.org/plugins/settings/settings-api/](https://developer.wordpress.org/plugins/settings/settings-api/) diff --git a/docs/tutorials/first-post-type.md b/docs/tutorials/first-post-type.md index 90c83c2a..6021febc 100644 --- a/docs/tutorials/first-post-type.md +++ b/docs/tutorials/first-post-type.md @@ -1,6 +1,10 @@ # Creating Your First Post Type -A step-by-step guide to creating a custom post type using Secure Custom Fields. +A step-by-step guide to creating a custom post type using Secure Custom Fields (SCF). + +**What is a custom post type?** + +In WordPress, a custom post type (CPT) is a content type like posts and pages, but customized to suit your specific needs. You can use CPTs to manage products, portfolios, testimonials, events, vehicles, and more—essentially any type of structured content that needs its own menu and fields. ## Prerequisites @@ -8,29 +12,129 @@ A step-by-step guide to creating a custom post type using Secure Custom Fields. - Administrator access to WordPress - Basic understanding of WordPress concepts -## Steps +You can learn more about WordPress basics here: + +- [Theme Basics](https://developer.wordpress.org/themes/basics/) +- [Plugin Basics](https://developer.wordpress.org/plugins/plugin-basics/) + +## 1. Access the Admin Panel + +To begin creating your custom post type: + +- Go to **Secure Custom Fields → Post Types** in your WordPress admin menu. +- Click the **"Add New"** button to open the creation form. + +## 2. Basic Configuration + +These fields help you define how your post type will appear and behave: + +### Plural Label \* + +This is the name that will appear in the admin sidebar. For example, `Movies`. + +### Singular Label \* + +Used for individual entries. Example: `Movie`. + +### Post Type Key \* + +A technical identifier for WordPress to recognize this post type. Use lowercase letters and underscores only. Max 20 characters. Example: `movie`. + +### Taxonomies + +Choose existing taxonomies like **category** or **tags** if you want to group or filter your content. You can also select custom ones like **Brand** or **Color**. + +### Public + +Choose **Yes** to make your post type visible on the website and admin area. Choose **No** to keep it private. + +### Hierarchical + +Set to **Yes** if you want your items to be nested (like pages). Set to **No** for a flat list (like blog posts). + +### Advanced Configuration + +Enable this to unlock more advanced options, useful when you need more control over how your post type works. + +## 3. Advanced Settings + +These options let you customize deeper behaviors and labels. + +### Supports -1. **Access the Admin Panel** - - Navigate to Custom Fields → Post Types - - Click "Add New" +Select which features to enable when editing a post, such as: -2. **Basic Configuration** - - Enter a descriptive name - - Configure labels - - Set visibility options +- **Title**: Adds a title field +- **Editor**: Main content box +- **Featured Image**: Allow image upload +- **Comments**, **Author**, **Excerpt**, etc. -3. **Advanced Settings** - - Configure permalinks - - Set up taxonomies - - Define capabilities +### Description -4. **Testing** - - Save your post type - - Create a test post - - View on front end +A short explanation of what this post type is about. Helpful for organization. + +### Active + +Make sure this is set to **Yes** so your post type is registered and usable. + +### Labels + +These are the texts that WordPress shows throughout the dashboard. For example: + +- **Menu Name**: What appears in the sidebar +- **Add New Item**: Button to create a new entry +- **Edit Item**, **View Item**, **Search Items**, etc. + You can keep the default labels or customize them to your liking. + +### Visibility Options + +Control where your post type appears in the admin and site: + +- Show in dashboard menu +- Show in admin bar +- Show in appearance menus + +### Menu Icon and Position + +Choose an icon for your post type from the WordPress Dashicons set. Optionally, set its position in the sidebar. + +### Permalinks and URLs + +You can define how URLs will look for your post type: + +- **Slug**: A custom word for your URL (e.g., `/movie/`) +- Enable archive and pagination +- Optionally include RSS feeds + +### Permissions + +If needed, you can assign custom capabilities like `edit_movie` or `delete_movies`. Useful for advanced role control. + +### REST API Settings + +Enable this if you plan to use the post type with the block editor or external tools. + +- You can customize the API route, namespace, or controller class if needed. + +## 4. Testing + +Once everything is set up: + +- Click **Save** to register your post type. +- Go to the WordPress dashboard menu where your new post type now appears. +- Click **Add New** and create a test entry. +- Visit your website and check that it appears correctly on the frontend. ## Next Steps -- Add custom fields to your post type -- Configure archive displays -- Set up custom taxonomies +- Add custom fields to your post type via Secure Custom Fields +- Configure how archives and single templates are displayed in your theme +- Set up or register your own taxonomies for more organization + +## For Developers + +If you're a developer and prefer to register custom post types using code instead of the admin interface, you can refer to the official WordPress documentation: + +[How to Create Custom Post Types with Code](https://developer.wordpress.org/plugins/post-types/) + +This guide includes examples and explanations on using `register_post_type()` and other related functions. diff --git a/docs/tutorials/first-taxonomy.md b/docs/tutorials/first-taxonomy.md new file mode 100644 index 00000000..962b045e --- /dev/null +++ b/docs/tutorials/first-taxonomy.md @@ -0,0 +1,122 @@ +# Creating Your First Taxonomy + +A step-by-step guide to creating a custom taxonomy using Secure Custom Fields (SCF). + +**What is a taxonomy?** + +A taxonomy in WordPress is a way to group content together. The most common examples are categories and tags. You can create your own custom taxonomies to organize your content in meaningful ways depending on your needs—for example, genres for movies, colors for products, or locations for rentals. + +## Prerequisites + +- SCF installed and activated +- Administrator access to WordPress +- Basic understanding of WordPress concepts + +You can learn more about WordPress basics here: + +- [Theme Basics](https://developer.wordpress.org/themes/basics/) +- [Plugin Basics](https://developer.wordpress.org/plugins/plugin-basics/) + +## 1. Access the Admin Panel + +To begin creating your custom taxonomy: + +- Go to **Secure Custom Fields → Taxonomies** in your WordPress admin menu. +- Click the **"Add New"** button to open the creation form. + +## 2. Basic Configuration + +#### Plural Label \* + +Name shown in admin menus and listings, e.g., `Genres`. + +#### Singular Label \* + +Used for individual terms. Example: `Genre`. + +#### Taxonomy Key \* + +A unique identifier. Use lowercase letters, underscores, or dashes only. Max 32 characters. Example: `genre`. + +#### Post Types + +Select the post types that will use this taxonomy. For example, Posts, Pages, or custom types like `product`, `vehicle`, etc. + +#### Public + +Choose **Yes** to make the taxonomy visible on your website and in the admin dashboard. + +#### Hierarchical + +Enable to allow parent-child terms (like categories). Disable for flat lists (like tags). + +#### Advanced Configuration + +Enable this to unlock advanced settings for developers or experienced users. + +## 3. Advanced Settings + +#### Sort Terms + +Controls whether the terms are stored in the order you assign them. + +#### Default Term + +Creates a default term that can’t be deleted, useful for fallback categorization. + +#### Description + +Brief summary of what the taxonomy represents. + +#### Active + +Make sure this is set to **Yes** so your taxonomy is usable. + +#### Labels + +Customize the texts shown in the WordPress admin: + +- Menu Label, Add New Item, Edit Item, View Item +- Parent Item (for hierarchical), Popular Items (for non-hierarchical) +- Messages for empty lists, instructions, tooltips, etc. + +#### Visibility Options + +Control where the taxonomy appears in the admin and frontend: + +- Show In UI, Show In Admin Menu +- Appearance Menu Support, Quick Edit, Admin Columns + +#### Meta Box + +Enable and configure how the taxonomy is displayed in the post editor. +You can define custom callbacks for display and sanitization if needed. + +#### Permalinks and URLs + +Customize how your taxonomy URLs will be structured: + +- Custom Slug, Include front prefix, Enable hierarchical URLs +- Publicly queryable, custom query variable + +#### Permissions + +Control who can manage, edit, assign, or delete terms. +You can set custom capabilities (e.g., `manage_categories`, `edit_posts`). + +## 4. Testing + +Once everything is configured: + +- Click **Save** to register your taxonomy. +- Go to one of the selected post types (e.g., Posts or Products). +- Try adding terms in the new taxonomy field. +- Make sure they appear correctly in the editor and on the frontend if public. + +## For Developers + +If you're a developer and prefer to register custom taxonomies using code instead of the admin interface, you can refer to the official WordPress documentation: + +[How to Create Custom Taxonomies with Code](https://developer.wordpress.org/plugins/taxonomies/) + +This guide includes examples and explanations on using `register_taxonomy()` and other related functions. diff --git a/docs/welcome/how-content-works.md b/docs/welcome/how-content-works.md new file mode 100644 index 00000000..ece99a04 --- /dev/null +++ b/docs/welcome/how-content-works.md @@ -0,0 +1,205 @@ +# Understanding the Relationship Between Post Types, Taxonomies, and Custom Fields + +In WordPress, the true power of content modeling comes from combining **Post Types**, **Taxonomies**, and **Custom Fields**. Together, these tools allow you to build virtually any kind of data structure your website needs — from a real estate listing manager to a recipe library or an online product catalog. + +This guide will help you understand how each element works, when to use them, and how they interact with each other in practical projects — using movies as our central example. + +## Prerequisites + +- SCF (Secure Custom Fields) installed and activated +- Administrator access to WordPress +- Basic understanding of WordPress concepts + +You can learn more about WordPress basics here: + +- [Theme Basics](https://developer.wordpress.org/themes/basics/) +- [Plugin Basics](https://developer.wordpress.org/plugins/plugin-basics/) + +## 1. Post Types + +**Post types** define **what kind of structured content** you're managing in WordPress. +By default, WordPress includes two main types: + +- **Posts:** + These are time-based entries, perfect for blogs, news, or updates. Posts appear in your site's main feed and can be categorized or tagged. + +- **Pages:** + These are static pieces of content like “About Us”, “Contact”, or “Terms of Service”. They are not organized by date and do not use categories or tags. + +However, many websites require **other types of content** that don’t fit as a blog post or a static page. That’s where **custom post types** come in. + +--- + +### When should you create a custom post type? + +- When your content doesn’t belong under regular posts or pages +- When you need a separate menu or editing interface in the admin panel +- When you’re managing **structured content** (with specific fields like images, dates, selections, etc.) +- When you want to keep things like `Movies`, `Products`, or `Projects` separate from editorial content + +--- + +### Example: Movies + +Let’s say you want to build a catalog of movies on your site. +Instead of creating a blog post for each movie, you can: + +1. Create a custom post type named `Movies`. +2. Add fields like `Title`, `Director`, `Release Year`, `Poster Image`. +3. Display them independently from blog posts or pages. + +This gives you full control over how movies are created, organized, and displayed — without mixing them into your main blog. + +--- + +## 2. Taxonomies + +Taxonomies define **how content is grouped**. WordPress provides default taxonomies like `Categories` and `Tags`, but you can create your own — such as `Genres`, `Years`, or `Directors`. + +**When to create a custom taxonomy:** + +- You want to group or filter items based on shared traits +- You need hierarchical grouping (e.g., genre > sub-genre) +- You want users to navigate content by categories meaningful to them + +**Example (Movies):** +Create a taxonomy called `Genre` and attach it to the `Movie` post type. This lets users filter all movies tagged as `Action`, `Comedy`, or `Drama` — and even group them by sub-genres if hierarchical. + +## 3. Custom Fields + +Custom fields store **specific attributes** that aren’t covered by the title or content fields. They are great for metadata that belongs to one item. + +**When to use custom fields:** + +- You want to add structured data to your post type (e.g., text, numbers, images) +- You want each item to have unique values (not shared or grouped like taxonomies) + +**Example (Movies):** +Use custom fields to store each movie's `Director`, `Release Year`, `Duration`, `Trailer URL`, and `Poster Image`. These are all values unique to each movie and not ideal for filtering across many movies like taxonomies would be. + +## 4. Why This Matters + +When used together, these three features form a powerful content management structure. Here’s how it looks in practice for a movie website: + +- A **Movie** post type +- With a **Genre** taxonomy (e.g., Action, Sci-Fi, Romance) +- And custom fields for: + + - `Director` + - `Duration` + - `Release Year` + - `Trailer URL` + +This enables you to: + +- Create a dedicated admin panel for movies +- Allow users to browse by genre +- Display rich details per movie on the frontend +- Build custom archive templates and filtering tools + +Whether you're building a streaming catalog, a film festival archive, or a movie blog — combining post types, taxonomies, and custom fields allows WordPress to adapt far beyond traditional blogs. + +--- + +### Real-World Example: Real Estate Website + +**Post Type:** `Property` + +Each property is its own entry, allowing the team to manage listings independently. + +**Taxonomies:** + +- `Property Type` (e.g., House, Apartment, Commercial) +- `Location` (e.g., City or Zone) + +**Custom Fields:** + +- `Price` +- `Bedrooms` +- `Bathrooms` +- `Square Footage` +- `Gallery` +- `Contact Email` + +This setup allows site visitors to: + +- Filter properties by type or location +- View detailed information per listing +- Submit inquiries directly from the property page + +--- + +### Real-World Example: User Check-In/Check-Out System + +**Post Type:** `User Visit` + +Each entry represents a single visit by a user. + +**Taxonomies:** + +- `Department` (to group visits by area) + +**Custom Fields:** + +- `User Name` +- `Check-In Time` +- `Check-Out Time` +- `Purpose of Visit` +- `Approved By` + +This setup enables admins to: + +- Track entry and exit logs +- Generate visit reports by department +- Display current on-site users if needed + +## Advanced Example: Relational Content with Bidirectional Fields + +In more complex systems, post types may need to relate to each other. You can use **bidirectional relationships** (also known as post-to-post relationships) to build powerful, interconnected structures. + +### Example: University Course Management System + +**Post Types:** + +- `Course` +- `Instructor` +- `Student` + +**Taxonomies:** + +- `Department` (e.g., Science, Arts) + +**Custom Fields:** + +- `Course`: + + - `Course Code` + - `Credits` + - `Instructor` (relationship to Instructor post) + - `Enrolled Students` (bidirectional relationship to Student posts) + +- `Instructor`: + + - `Full Name` + - `Assigned Courses` (bidirectional relationship to Course posts) + +- `Student`: + + - `Name` + - `Courses Enrolled` (bidirectional relationship to Course posts) + +This setup enables features like: + +- Displaying all students enrolled in a course +- Showing which instructor teaches each course +- Generating student dashboards with course schedules + +You can manage this using Secure Custom Fields with relationship-type fields. + +--- + +## Next Steps + +- [Learn how to create your first custom post type](../tutorials/first-post-type.md) +- [Explore how to build a custom taxonomy](../tutorials/first-taxonomy.md) +- [Add and manage custom fields with SCF](../tutorials/first-custom-field.md) diff --git a/docs/welcome/index.md b/docs/welcome/index.md index 08796347..1bf41469 100644 --- a/docs/welcome/index.md +++ b/docs/welcome/index.md @@ -6,6 +6,7 @@ This section helps you get up and running with Secure Custom Fields (SCF). Wheth - [Installation](installation) - How to install and activate SCF - [Quick Start](quick-start) - Create your first custom field group in minutes +- [How Content Works](how-content-works) - Understanding the Relationship Between Post Types, Taxonomies, and Custom Fields ## Documentation Sections diff --git a/docs/welcome/installation.md b/docs/welcome/installation.md index 7f637ae8..2e9da363 100644 --- a/docs/welcome/installation.md +++ b/docs/welcome/installation.md @@ -35,7 +35,7 @@ To install and manage Secure Custom Fields in your WordPress theme or plugin, it This ensures that SCF is properly versioned, loaded automatically, and easy to update. -### Why integrate **Secure Custom Fields (SCF)** with Composer? +#### Why integrate **Secure Custom Fields (SCF)** with Composer? Integrating SCF using Composer offers several important advantages for the professional development of WordPress plugins and themes: @@ -62,7 +62,7 @@ Integrating SCF using Composer offers several important advantages for the profe --- -### How to Load and Use **Secure Custom Fields (SCF)** with Composer +#### How to Load and Use **Secure Custom Fields (SCF)** with Composer Add the following configuration to your `composer.json` file: @@ -104,7 +104,7 @@ composer i --- -### Add the Composer Autoloader +#### Add the Composer Autoloader To ensure Composer dependencies are loaded correctly, add the following line in your plugin or theme: @@ -112,7 +112,7 @@ To ensure Composer dependencies are loaded correctly, add the following line in require_once plugin_dir_path(dirname(__FILE__)) . 'vendor/autoload.php'; ``` -### Load Secure Custom Fields +#### Load Secure Custom Fields Now you need to manually load the Secure Custom Fields plugin and define its paths. Adjust the paths according to the structure of your plugin or theme: @@ -129,13 +129,13 @@ if (! class_exists('ACF')) { ⚠️ **Note:** Replace MY_SCF_PATH and MY_SCF_URL with constants that match your plugin/theme structure if necessary. -### Done +#### Done You have successfully installed and integrated Secure Custom Fields via Composer. You can now use it as you would with a normal installation, but with all the benefits of Composer-based dependency management. --- -### Optional: Hide SCF Admin Menu and Updates +#### Optional: Hide SCF Admin Menu and Updates If you want to hide the **Secure Custom Fields (SCF)** admin menu from the WordPress dashboard and prevent the plugin's update notifications from appearing, you can use the following code: @@ -147,7 +147,7 @@ add_filter( 'acf/settings/show_admin', '__return_false' ); add_filter( 'acf/settings/show_updates', '__return_false', 100 ); ``` -#### What does this do? +##### What does this do? - **Hide Admin Menu:** The first filter disables the SCF menu in the WordPress admin area, preventing users from accessing SCF field groups or settings. @@ -155,7 +155,7 @@ add_filter( 'acf/settings/show_updates', '__return_false', 100 ); - **Hide Update Notifications:** The second filter disables the SCF update notices, so users won't see update prompts for the plugin inside the admin dashboard. -#### When should you use it? +##### When should you use it? - If you are bundling SCF inside your plugin or theme and want to **control all the custom fields yourself** without allowing clients or users to modify them. - If you want to **maintain full control** over SCF versions and updates to avoid compatibility issues caused by manual updates.