前言介紹
- 這款 WordPress 外掛「ACF Options Page Admin」是 2017-01-01 上架。 目前已經下架不再更新,不建議安裝使用。
- 目前有 6000 個安裝啟用數。
- 上一次更新是 2021-12-23,距離現在已有 1226 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 3.5 以上版本才可以安裝。
- 有 5 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
hube2 |
外掛標籤
acf | options page |
內容簡介
*** 新功能添加:自定義文章 ID Slug ***
這是一個給予 Advanced Custom Fields (ACF) 5 和選項頁面附加套件 (或 ACF Pro) 的附加外掛程式。
除非安裝了 ACF 5 和選項頁面附加套件 (或 ACF5 Pro) ,此外掛程序不會提供任何功能。
此外掛程式提供一個管理員介面,可在 ACF 中添加選項頁面,包括 ACF 選項頁面的所有選項。
大部分的選項都是可選的,例如功能表位置、權限和要將欄位值保存到哪裡等等。
更多資訊請參見:
其他注意事項 和
瀏覽畫面
Github 儲存庫
此外掛程式也在 Github 上
https://github.com/Hube2/acf-options-page-adder
變更權限
添加或編輯選項頁面設置所需的權限是「manage_options」。可以通過添加篩選器來更改此權限。
add_filter('acf-options-page-adder/capability', 'my_acf_options_page_adder_cap');
function my_acf_options_page_adder_cap($cap) {
$cap = 'edit_published_posts';
return $cap;
}
保存值到選項頁面文章中
ACF v5.2.7 新增了將選項頁面欄位保存到文章 ID 的功能。此外掛程式可讓您將選項保存到添加選項頁面時創建的文章的相同文章 ID 中。您甚至可以使用 get_fields ($options_page_id) 而無需擔心獲取選項頁面本身的欄位。為什麼?因為用於創建選項頁面的所有欄位都以底線 _ 開頭,並且不會被 get_fields() 返回。您唯一需要注意的是不要使用此外掛程式使用的任何欄位名稱,這應該非常容易,因為它們都以 acfop 開頭。
使用自定義文章 ID Slug 保存值
可以使用自定義 Slug 來保存選項頁面的值。例如,如果您希望將選項頁面的值保存到使用者中,則可以將“user _1”作為選項頁面的 $post_id 值提供。這還具有另一個副作用。通常,當 ACF 將值保存到 options 時,您會在 options 表中找到帶有 options_ 前綴的字段。因此,例如,如果您的字段名稱為“my_field”,則在選項表中您將找到“options_my_field”作為選項名稱。您可以為此提供自定義 Slug,例如,如果您將選項頁面的文章 ID 設置為“my-custom-slug”,則會導致選項頁面中的相同字段具有名稱“my-custom-slug_my_field”。此外掛程序已經新增了 2 個新選項,您可以選擇使用選項頁面 Slug 作為文章 ID,或者您可以指定要使用的自定義 Slug。
為選項頁面取得文章 ID
一個函數和一個篩選器可用於取得正確的 ACF $ post_id 值,以便從選項頁面取得值。此函數/篩選器將返回 options(對於存儲在 options 中的選項頁面)或如果選項保存到文章中則返回正確的文章 ID。正確的 ID 是基於選項頁面的「menu_slug」值返回的。
/ 範例 1:function get_options_page_id()
// 獲取選項頁面的 $post_id
$post_id = get_options_page_id('my_options_page_slug');
// 使用 $post_id 獲取值
$value = get_field('my_option_field', $post_id);
// 或它可以結合在一起
$val
原文外掛簡介
*** New feature added: Custom Post ID Slugs ***
This is an add on plugin for Advanced Custom Fields (ACF) 5 + the Options Page Add On (or ACF Pro).
This plugin will not provide any functionality unless ACF 5 and the Options Page Add On (or ACF5 Pro)
is installed
This plugin provides an admin interface for adding options pages in ACF including all options for ACF
options pages. Most options are selectable, for example the menu location, capability and where to save
field values to.
For more information see
Other Notes and
Screenshots
Github Repository
This plugin is also on GitHub
https://github.com/Hube2/acf-options-page-adder
Change Capability
The capability required to add/edit options page settings is “manage_options”. This capability can be changed by adding a filter.
add_filter('acf-options-page-adder/capability', 'my_acf_options_page_adder_cap');
function my_acf_options_page_adder_cap($cap) {
$cap = 'edit_published_posts';
return $cap;
}
Saving Values to the Options Page Post
ACF v5.2.7 added the ability to save options page fields to a post ID. This plugin will let you save the options to the same post ID of the post created when adding an options page using this plugin. You can even use get_fields($options_page_id) without needing to worry about getting the fields for the options page itself. Why? because all the fields used for creating the options page start with an underscore _ and will not be returned by get_fields(). The only thing you need to be careful of is not using any of the field names used by this plugin, which should be extremely easy since they all start with acfop.
Saving Values Using a Custom post ID slug
It is posible to use a custom slug for saving options page values. For example, if you wanted to save values of an options page to a user you could supply “user_1” as the $post_id value for the opitons page. This also has another side effect. Normally, when ACF saves values to “options” in the options table you will find the fields with the “options_” prefix. So for example, if your field name is “my_field” then in the options table you will find “options_my_field” as the options name. You can supply a custom slug for this, let’s say that you set the post ID setting for the options page to “my-custom-slug”. this would cause the same field in the options page to have the name “my-custom-slug_my_field”. 2 New options have been added to this plugin and you can choose to use the options page slug for the post ID or you can specify a custom slug to use instead.
Get Post ID for Options Page
A function and a filter are available for getting the correct ACF $post_id value to use for getting
values from the options page. This function/filter will return ‘options’ for options pages stored in
options or will return the correct post ID if options are saved to a post. The correct ID is returned
based on the “menu_slug” value of the options page.
/ example 1: function get_options_page_id()
// get the post_id of an options page
$post_id = get_options_page_id('my_options_page_slug');
// get a value using $post_id
$value = get_field('my_option_field', $post_id);
// or it can be combined like this
$value = get_field('my_option_field', get_options_page_id('my_options_page_slug'));
// example 2: by filter
$default = 'option',
$slug = 'my_options_page_slug';
$post_id = apply_filters('get_option_page_id_filter', $default, $slug);
$value = get_field('my_option_field', $post_id);
// or it can be combined like this
$value = get_field('my_option_field', apply_filters('get_option_page_id_filter', $default, $slug));
There is a condition where you will get the incorrect post id. This condition is created by having a top level redirect page that is set to redirect to the first sub options page. If there is no sub options page that exists then it will return the value for the top level options page. If you later create a sub options page it will return the new value from the sub options page. This is why I have see the default value of redirect to false. If you want the top level page to redirect the you need to be aware that it can cause you issues later down the road if you haven’t created a sub option page. You should also specifically set the order of sub options pages so that these do not change at some point in the future because adding a new options page with the same order as the existing top level page will alter the save and get location to the new options page. There’s noting I can do about this, it the way it works. When setting up ACF options pages to save to a post instead of options you must be more precise in with the options page arguments.
Font Awesome Support
Please note that this plugin does not enqueue or include Font Awswsome in the admin of your site.
If you include Font Awsome in your admin then you can use Font Awesome Icons for the icons of
top level options page. For example if you wanted to use Address Book Icon then all you need to do is add fa fa-address-book
into the Icon field when adding or editing the options page.
Filter Options Page Header/Footer/Content
Version 3.8.0 of this plugin added the ability to customize the ACF options page by adding header and footer content. In addtion to the WYSIWYG fields that have been added to the options page admin editor you can also customize these sections, or the entire options page using filters.
Version 3.8.2 of this plugin adds a toggle to enable this feature. This feature can cause an out of
memory fatal error on options pages that have large numbers of fields. If content was entered into this field before the toggle to turn in on then the toggle will be automatically turned on. Otherwise the default for this option will be off.
Header Content
add_filter('acf-options-page-adder/page-header', 'my_custom_options_page_header', 10, 2);
function my_custom_options_page_header($content, $hook) {
// $content = content, by default it is '' or the value of the WYSIWYG editor
// $hook = the current options page hook that is being called
$content = '
My Custom Header Content
';
return $content;
}
Footer Content
add_filter('acf-options-page-adder/page-footer', 'my_custom_options_page_footer', 10, 2);
function my_custom_options_page_footer($content, $hook) {
// $content = content, by default it is '' or the value of the WYSIWYG editor
// $hook = the current options page hook that is being called
$content = '
My Custom Footer Content
';
return $content;
}
Filter Entire Options Page
add_filter('acf-options-page-adder/page-content', 'my_custom_options_page_filter', 10, 2);
function my_custom_options_page_filter($content, $hook) {
// $content = entire content or options page, including all ACF fields
// $hook = the current options page hook that is being called
// caution should be taken when making modification to the page content
return $content;
}
Remove Nag
If you would like to remove my little nag that appears on some admin pages add the following to your functions.php file
add_filter('remove_hube2_nag', '__return_true');
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「ACF Options Page Admin」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
3.6.1 | 3.7.0 | 3.7.1 | 3.7.2 | 3.7.3 | 3.7.4 | 3.7.5 | 3.8.0 | 3.8.1 | 3.8.2 | 3.8.3 | 3.8.4 | 3.8.5 | 3.8.6 | 3.8.7 | 3.8.8 | 3.8.9 | 3.9.0 | 3.9.1 | 3.9.2 | 3.9.3 | 3.9.4 | 3.9.5 | 3.9.6 | trunk | 3.10.0 |
延伸相關外掛(你可能也想知道)
Advanced Custom Fields (ACF®) 》Advanced Custom Fields 可以讓 WordPress 網站成為一個完整的內容管理系統,提供您所有工具以更好管理您的數據。, 使用 Advanced Custom Fields 外掛,完全...。
Advanced Custom Fields: Font Awesome Field 》在 Advanced Custom Fields 中添加一個Font Awesome 圖標字段類型。, , 指定要使用哪些 Font Awesome...。
ACF Content Analysis for Yoast SEO 》此外掛確保 Yoast SEO 分析包括所有 ACF 內容,包括彈性內容和重複器。, Yoast SEO for WordPress 內容和 SEO 分析不會考慮一篇文章的Advanced Custom Fields...。
Advanced Custom Fields: Extended 》🚀 全方位增強套件,可改進WordPress和Advanced Custom Fields。此外掛旨在提供一個強大的管理框架,涵蓋了眾多改進和優化。, 此外掛需要至少 ACF Pro 5.8。,...。
ACF Photo Gallery Field 》t; 'Status', , 'name' => 'status', , 'choices' => array(, 'public' => 'Public', , 'private' => ...。
Table Field Add-on for ACF and SCF 》表格欄位外掛程式增強了Advanced Custom Fields外掛程式的功能,讓表格編輯更易於使用。, 此外掛程式需要Advanced Custom Fields外掛程式或專業版!, 表格欄...。
Really Simple CSV Importer 》替代 CSV 導入外掛程式。簡單而強大,最適合於技術狂熱者。, , 類別支援, 標籤支援, 自訂欄位支援, Smart Custom Fields 支援, Custom Field Suite 支援, Adv...。
ACF to REST API 》此 WordPress 外掛在WordPress REST API中提供了Advanced Custom Fields的端點, 詳細資訊請參閱GitHub:https://github.com/airesvsg/acf-to-rest-api/。
ACF Quick Edit Fields 》這個 WordPress 外掛為 Advanced Custom Fields Plugin(Pro 和 Free 5+)增加了快速編輯功能。, 特色, , 在清單檢視中顯示 ACF 欄位值, 支援的 ACF 欄位類型...。
Advanced Custom Fields: Gravity Forms Add-on 》提供進階自訂欄位 (Advanced Custom Field),讓 WordPress 編輯使用者或管理員可以在欄位群組配置中選擇 Gravity Form。, 可以在 外掛的 GitHub 存儲庫 中找...。
Advanced Custom Fields: Image Aspect Ratio Crop Field 》這是一個進階自訂欄位 (Advanced Custom Fields) 的外掛,會在使用者上傳圖片後強制執行特定的長寬比例或像素大小裁剪。使用長寬比例對於回應式圖片的使用情...。
Advanced Custom Fields: Nav Menu Field 》使用 Nav Menu Field 外掛將導覽選單加入Advanced Custom Fields (ACF)。此外掛會在 ACF(版本 5 和 4)加入 Nav Menu 欄位類型,讓您從 WordPress 管理後台...。
ACF Theme Code for Advanced Custom Fields 》ACF Theme Code 外掛可以自動生成在主題中實現 Advanced Custom Fields 所需的程式碼。以下是該外掛的功能特色:, , - 縮短網站開發時間。, - 當您發布、編輯...。
ACF qTranslate 》此外掛提供 qTranslate-X 相容的 ACF4 和 ACF5PRO 欄位類型,包括文字、文字區域、所見即所得編輯器、影像和檔案。新增欄位至群組時,這些新的欄位類型將在欄...。
ACF Options For Polylang 》您使用了高級自訂欄位來建立選項頁面,並且安裝了 Polylang 外掛以獲得令人驚嘆的多語言網站嗎?, 可惜的是,Polylang 並不處理 ACF 的選項頁面。這意味著您...。