CLASS strong>,'singular')。
‘_exclusion’, $exclusionData[‘excluded_ip’]);
‘_exclusion’,$ exclusionData [‘excluded_ip’]));
This will create a hook for when an exclusion of your type is created.
这将为创建排除类型时创建一个钩子。
This method should also ignore any entries that already exist, just for good practice.
出于良好实践,此方法还应忽略任何已存在的条目。
* removeExclusion() – This takes two arguments, the exclusions unique identifier (in this case it would be the IP Range), and the post type slug (“post”, “page”, etc).
* removeExclusion()–这有两个参数,排除唯一标识符(在这种情况下,它将是IP范围)和帖子类型slug(“ post”,“ page”等)。
This code should remove the exclusion, and create an identical hook to the one in setExclusion(), only with the term remove instead of add.
此代码应删除排除项,并在setExclusion()中创建与该挂钩相同的钩子,仅使用术语remove而不是add。
* getExcludedPostIds() – This is the function that makes your exclusion type work, you do whatever checking you would need to here, in this case it would be checking if the users IP address (constant “VIEWER_IP_ADDRESS”) falls within any of the ranges
* getExcludedPostIds()–这是使排除类型起作用的功能,您需要在此处进行任何检查,在这种情况下,它将检查用户的IP地址(常数“ VIEWER_IP_ADDRESS”)是否在任何范围内
in the database.
在数据库中。
It should return an array of private post Ids, that can be obtained by using:
它应该返回一个私有帖子ID数组,可以使用以下方法获得:
self::getPrivatePostIdsFromPostTypes($arrayOfPostTypes)
self :: getPrivatePostIdsFromPostTypes($ arrayOfPostTypes)
Ideally the array of post types would be obtained by calling self::getExclusion() with the IP range passed.
理想情况下,可以通过调用具有IP范围的self :: getExclusion()获得帖子类型数组。
* Now, ajax files for the interface must be created, create a folder called ajax within the code folder, and create files called action.php, and js.php.
*现在,必须创建该接口的ajax文件,在代码文件夹中创建一个名为ajax的文件夹,并创建一个名为action.php和js.php的文件。
* With action.php, this will store the functionality of your ajax calls, the class should extend appAjaxAction, and actions should be added to the wp_ajax_action_name method, refer to the WordPress Ajax API for more information.
*使用action.php,它将存储您的ajax调用的功能,该类应扩展appAjaxAction,并将操作添加到wp_ajax_action_name方法,有关更多信息,请参阅WordPress Ajax API。
* With js.php, this will store the javascript that triggers your ajax calls, the class should extend appAjaxJs, and all methods should be added to the admin_head hook.
*使用js.php,它将存储触发您的ajax调用的javascript,该类应扩展appAjaxJs,并且应将所有方法添加到admin_head挂钩中。
Again, following the practices of the WordPress Ajax API.
同样,遵循WordPress Ajax API的做法。
* Now you can create the user interface “widget” (in the non-WP sense) to your exclusion type, this will be a php file in your directory named settings.php.
*现在,您可以为排除类型创建用户界面“ widget”(非WP含义),这将是您目录中名为settings.php的php文件。
This will be included on the settings page.
这将包含在设置页面中。
* Finally, all of this is done, but the system still doesn’t know your exclusion module exists, but once you tell it it’s there, it will function seamlessly with the rest of the system (configuration based ftw).
*最后,所有步骤都已完成,但是系统仍然不知道您的排除模块存在,但是一旦您知道该模块存在,它将与系统的其余部分无缝运行(基于配置的ftw)。
We do this by modifying the config.json in the root directory, you may want to back it up since it’s easy to mess up the syntax.
我们通过修改根目录中的config.json来完成此操作,您可能希望对其进行备份,因为这样很容易弄乱语法。
You’ll want to add 3 lines of json under the “exclusionModules” array item, this would be an example:
您需要在“ exclusionModules”数组项下添加3行json,这将是一个示例:
“ipAddressExclusions”: {
“ ipAddressExclusions”:{
“singular”: “ip_address”,
“单数”:“ ip_address”,
“directory”: “code/ip-address”
“目录”:“代码/ ip地址”
}
} p>
ipAddressExclusions must match the class name used in your exclusions.php file, the singular name is what will be used in hooks (and probably other places later), the directory is simply where your code lives from the plugin path, in this
ipAddressExclusions必须与您的exclusions.php文件中使用的类名匹配,单数名称是将在钩子(以及以后可能在其他地方)中使用的名称,在该目录中,代码仅位于插件路径中
example it would be “code/ip-range”.
例如“代码/ ip范围”。 p>
Refresh your settings page, and you should see your system in effect!
刷新您的设置页面,您应该会看到系统生效! p>
Data available to your Exclusion Module
排除模块可用的数据 strong>
If you followed the conventions, all of your classes will ultimately extend the core advancedPostPrivacy class,
如果遵循这些约定,则所有类最终都会扩展核心的AdvancedPostPrivacy类,
meaning you have access to all the methods within the class, however most of them may be made private in the
表示您可以访问该类中的所有方法,但是大多数方法可以在
中设为私有
future as they are really for the core.
未来,因为它们确实是核心。
The protected static property of $_json_config is stored here,
$ _json_config的受保护静态属性存储在此处,
and has the complete array of the loaded json configuration file.
并具有已加载的json配置文件的完整数组。 p>
Assets Available
可用资产 strong>
jQuery chosen js, and css, is enqueued via APP, and can be called on any pages as it is normally called.
jQuery选择的js和css通过APP入队,并且可以像通常那样在任何页面上调用。 p>
Constants
常量 strong>
APP_PREFIX (adv_pp_)
APP_PREFIX(adv_pp_)
APP_PATH
APP_PATH
APP_CODE_PATH
APP_CODE_PATH
APP_DESIGN_PATH
APP_DESIGN_PATH
APP_PLUGIN_URL
APP_PLUGIN_URL
APP_DESIGN_URL
APP_DESIGN_URL
APP_CONFIG_FILE (path to the config.json file)
APP_CONFIG_FILE(config.json文件的路径)
VIEWER_IP_ADDRESS (users REMOTE_ADDR from $_SERVER)
VIEWER_IP_ADDRESS($ _ SERVER中的用户REMOTE_ADDR) p>