. the plug-in name must contain an annotative block. This is the unique value required by WP to identify it as a plug-in. However, to follow best practices and prevent problems, you must enter some different information here. Start working now and generate the file. Open the localhost public folder and go to the WP installation you want to use. Then navigate to the \
Just add a new custom plug-in file here. Create a new folder under WP content \/ plugins folder of WP installation. To help you understand, this tutorial specifies the plug-in name as quadlayers_custom_products. There are all plug-in files in this folder. Now, let’s create a default file in the folder we just created Must be in PHP file format. The main file named quadlayers_cp.php is where everything starts. The entrance of the plug-in. You can use the code editor to create files, but make sure the extension is PHP and the PHP file format is correct.
Copy this code and paste it into a file.
<?php
/**
* @링크 https://quadlayers.com/
* @0.0.1부터
* @package QuadLayers 맞춤형 제품
* 플러그인 이름: QuadLayers 맞춤형 제품
* 플러그인 URI: https://quadlayers.com/
* 설명: 요소를 제거하여 제품 단일 페이지 사용자 정의
* 버전: 0.0.1
* 저자: QuadLayers
* 텍스트 도메인: qlcp
*/
if(!정의('ABSPATH')){다이('-1');}
함수 시작(){
if(is_admin()==true){
plugin_dir_path( __FILE__ ).'includes/Backend/QuadLayers-backend-init.php'가 필요합니다.
}
plugin_dir_path( __FILE__ ).'includes/Frontend/QuadLayers-frontend-init.php'가 필요합니다.
}
함수 runit(){
add_action('초기화', '시작');
}
런닛();
보시다시피 여기에서 QuadLayers-frontend-init.php 및 QuadLayers-backend-init.php 두 개의 파일을 더 호출합니다. 분명히 하나는 프론트엔드에서 작동하고 다른 하나는 백엔드에서 작동합니다. 파일 이름으로 명확하게 추론할 수 있습니다.
그 중 is_admin() 함수와 함께 조건부를 사용하기 때문에 백엔드 파일이 백엔드에서만 작동하도록 할 수 있습니다. 즉, 관리자가 WP 관리자 대시보드에 있는 경우에만 트리거됩니다. 지금 당장은 프론트엔드와 백엔드 파일이 모두 아직 존재하지 않기 때문에 웹사이트에 약간의 오류가 있을 것입니다. 따라서 계속해서 생성해 보겠습니다. Include 라는 플러그인 디렉토리 includes 새 폴더를 만듭니다. 그런 다음 그 안에 두 개의 폴더를 더 추가합니다: backend 및 frontend . 잘못된 경로 오류를 제거하려면 두 개의 빈 파일을 각각 생성합니다. 각 폴더는 백엔드 폴더에 QuadLayers-backend-init.php init.php, 프론트엔드 폴더에 QuadLayers-frontend-init.php 입니다.
그래서 이것이 우리의 최종 플러그인 파일 구조가 될 것입니다: QuadLayer_custom_products
__QuadLayer_cp.php
__포함
__백엔드
__QuadLayers-backend-init.php
__프런트
__QuadLayers-frontend-init.php 3. 백엔드 옵션 기본 파일을 추가한 후 플러그인의 백엔드 옵션 추가를 시작할 수 있습니다. 여기에서는 WP 관리 대시보드에 플러그인 메뉴 탭을 만들 것입니다. 이를 통해 사용자는 프런트 엔드에서 요소를 숨기거나 표시하는 몇 가지 옵션을 선택할 수 있습니다.
이 데모에서는 WP에서 제공하는 설정 API를 사용합니다. 배우기가 어렵지 않고 이에 대한 문서가 많기 때문에 아직 이해하지 못하더라도 걱정하지 마십시오. 이에 대해 자세히 알아보려면 WP 설정 API에 대한 전체 가이드를 참조하세요. 지금은 QuadLayers-backend-init.php 파일에 다음 코드를 복사하여 붙여넣으세요.
Male value = \
}
Function quadlayers checkboxrender_2 (){
$options = get_option(‘qlcp_options’);
?>
<?php
settings_fields('플러그인_QL_페이지');
do_settings_sections('플러그인_QL_페이지');
제출_버튼();
Male value = \
}
Function quadlayers checkboxrender_3 (){
$options = get_option(‘qlcp_options’);
?>
Male value = \
}
Function quadlayers checkboxrender_4 (){
$options = get_option(‘qlcp_options’);
?>
Male value = \
}
Function quadlayers checkboxrender_5 (){
$options = get_option(‘qlcp_options’);
?>
Male value = \
}
Function quadlayers checkboxrender_6 (){
$options = get_option(‘qlcp_options’);
?>
Male value = \
}
Now, when you reload the back-end screen or activate the plug-in, the dashboard menu side bar displays a new tab. The WP setting API stores an array containing all these options in the wp_options database table. You can open phpMyAdmin on the local host and search and view it in the form. This is newly created data, so it must be at the top of the table. Of course, in the database in the screenshot above, the qlcp_options array is empty. This is because all check boxes are currently unchecked. You can view some of them and then return to phpMyAdmin to see how the WP settings API stores data. You can now store an array of options in the database, so you must import these options and use them at the front end. This option allows users to hide or show various elements of the web site. 4. Add the front-end option quadlayers frontend init. Just copy and paste the following code into your PHP file. It imports data from the database stored in the back-end file of the array. Then, hide the specific elements on the product page according to which options in the option array are true. Front end conclusion this is a guide on how to create a custom WordPress plug-in. Custom plug-ins require very specific functions of the website and provide special WP