Object Sync for Salesforce Code Documentation

Object_Sync_Sf_Admin

Object_Sync_Sf_Admin class.

Table of Contents

$action_group_suffix  : string
Suffix for group name in ActionScheduler
$default_api_version  : string
What version of the Salesforce API should be the default on the settings screen.
$default_authorize_url_path  : string
Default path for the Salesforce authorize URL
$default_pull_limit  : int
Default max number of pull records. Users can edit this.
$default_pull_throttle  : int
Default throttle for how often to pull from Salesforce. Users can edit this.
$default_token_url_path  : string
Default path for the Salesforce token URL
$default_triggerable  : bool
Default for whether to limit to triggerable items. Users can edit this.
$default_updateable  : bool
Default for whether to limit to items that can be updated. Users can edit this.
$file  : string
The main plugin file
$logging  : object
Object_Sync_Sf_Logging class
$login_credentials  : array<string|int, mixed>
Login credentials for the Salesforce API; comes from wp-config or from the plugin settings
$mappings  : object
Object_Sync_Sf_Mapping class
$option_prefix  : string
The plugin's prefix when saving options to the database
$pull  : object
Object_Sync_Sf_Salesforce_Pull class
$push  : object
Object_Sync_Sf_Salesforce_Push class
$queue  : object
Object_Sync_Sf_Queue class
$salesforce  : array<string|int, mixed>
Object_Sync_Sf_Salesforce class This contains Salesforce API methods
$schedulable_classes  : array<string|int, mixed>
Array of what classes in the plugin can be scheduled to occur with `wp_cron` events
$slug  : string
The plugin's slug so we can include it when necessary
$version  : string
Current version of the plugin
$wordpress  : object
Object_Sync_Sf_WordPress class
$wpdb  : object
Global object of `$wpdb`, the WordPress database
$access_token  : string
Salesforce access token
$admin_settings_url_param  : string
URL fragment for the plugin's settings page
$instance_url  : string
Salesforce instance URL
$refresh_token  : string
Salesforce refresh token
$sfwp_transients  : object
Object_Sync_Sf_WordPress_Transient class
__construct()  : mixed
Constructor for admin class
add_actions()  : mixed
Create the action hooks to create the admin pages.
admin_scripts_and_styles()  : mixed
Admin styles. Load the CSS and JavaScript for the plugin's settings
change_action_schedule()  : mixed
Update recurring tasks for ActionScheduler if options change
clear_sfwp_cache()  : mixed
Ajax call to clear the plugin cache.
create_admin_menu()  : mixed
Create the WordPress admin options page
delete_fieldmap()  : mixed
Delete fieldmap data and redirect after processing This runs when the delete link is clicked, after the user confirms It is public because it depends on an admin hook It then calls the Object_Sync_Sf_Mapping class and the delete method
delete_object_map()  : mixed
Delete object map data and redirect after processing This runs when the delete link is clicked on an error row, after the user confirms It is public because it depends on an admin hook It then calls the Object_Sync_Sf_Mapping class and the delete method
display_checkboxes()  : mixed
Display for multiple checkboxes Above method can handle a single checkbox as it is
display_input_field()  : mixed
Default display for <input> fields
display_link()  : mixed
Default display for <a href> links
display_select()  : mixed
Display for a dropdown
export_json_file()  : mixed
Create a json file for exporting
get_salesforce_object_description()  : array<string|int, mixed>
Get all the Salesforce object settings for fieldmapping This takes either the $_POST array via ajax, or can be directly called with a $data array
get_salesforce_object_fields()  : array<string|int, mixed>
Get all the Salesforce fields settings for fieldmapping This takes either the $_POST array via ajax, or can be directly called with a $data array
get_wordpress_object_fields()  : array<string|int, mixed>
Get WordPress object fields for fieldmapping This takes either the $_POST array via ajax, or can be directly called with a $wordpress_object field
import_json_file()  : mixed
Import a json file and use it for plugin data
initial_action_schedule()  : string
Initial recurring tasks for ActionScheduler
notices()  : mixed
Create the notices, settings, and conditions by which admin notices should appear
plugin_action_links()  : array<string|int, mixed>
Display a Settings link on the main Plugins page
prepare_fieldmap_data()  : mixed
Prepare fieldmap data and redirect after processing This runs when the create or update forms are submitted It is public because it depends on an admin hook It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
prepare_object_map_data()  : mixed
Prepare object data and redirect after processing This runs when the update form is submitted It is public because it depends on an admin hook It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success
pull_from_salesforce()  : mixed
Manually pull the Salesforce object into WordPress This takes either the $_POST array via ajax, or can be directly called with $salesforce_id fields
push_to_salesforce()  : mixed
Manually push the WordPress object to Salesforce This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $wordpress_id fields
refresh_mapped_data()  : mixed
Manually pull the Salesforce object into WordPress This takes an id for a mapping object row
resave_action_schedules()  : mixed
When it finishes its migration, resave the scheduled tasks for ActionScheduler.
salesforce_settings_forms()  : mixed
Create default WordPress admin settings form. This runs the Settings page.
sanitize_validate_text()  : string
Allow for a standard sanitize/validate method. We could use more specific ones if need be, but this one provides a baseline.
save_salesforce_user_fields()  : mixed
If the user profile has been mapped to Salesforce, do it
show_admin_page()  : mixed
Render the admin pages in WordPress. This also allows other plugins to add tabs to this plugin's settings screen
show_salesforce_user_fields()  : mixed
Show what we know about this user's relationship to a Salesforce object, if any
check_wordpress_admin_permissions()  : mixed
Check WordPress Admin permissions Check if the current user is allowed to access the Salesforce plugin options
check_wordpress_ssl()  : bool
Check WordPress SSL status.
check_wordpress_ssl_support()  : bool
Check WordPress SSL support.
clear_cache()  : array<string|int, mixed>
Clear the plugin's cache.
clear_schedule()  : mixed
Clear schedule This clears the schedule if the user clicks the button
create_object_map()  : int
Create an object map between a WordPress object and a Salesforce object
fields_errors()  : mixed
Fields for the Mapping Errors tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
fields_fieldmaps()  : mixed
Fields for the Fieldmaps tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
fields_log_settings()  : mixed
Fields for the Log Settings tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
fields_scheduling()  : mixed
Fields for the Scheduling tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
fields_settings()  : mixed
Fields for the Settings tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option
get_schedule_count()  : int
Get count of schedule items
logout()  : mixed
Deauthorize WordPress from Salesforce.
set_action_schedule()  : mixed
Set up recurring tasks for ActionScheduler
status()  : mixed
Run a demo of Salesforce API call on the authenticate tab after WordPress has authenticated with it
tabs()  : mixed
Render tabs for settings pages in admin
version_options()  : array<string|int, mixed>
Dropdown formatted list of Salesforce API versions

Properties

$default_api_version

What version of the Salesforce API should be the default on the settings screen.

public string $default_api_version

Users can edit what version is used, but they won't see a correct list of all their available versions until WordPress has been authenticated with Salesforce.

$default_authorize_url_path

Default path for the Salesforce authorize URL

public string $default_authorize_url_path

$default_pull_throttle

Default throttle for how often to pull from Salesforce. Users can edit this.

public int $default_pull_throttle

$default_triggerable

Default for whether to limit to triggerable items. Users can edit this.

public bool $default_triggerable

$default_updateable

Default for whether to limit to items that can be updated. Users can edit this.

public bool $default_updateable

$login_credentials

Login credentials for the Salesforce API; comes from wp-config or from the plugin settings

public array<string|int, mixed> $login_credentials

$salesforce

Object_Sync_Sf_Salesforce class This contains Salesforce API methods

public array<string|int, mixed> $salesforce

$schedulable_classes

Array of what classes in the plugin can be scheduled to occur with `wp_cron` events

public array<string|int, mixed> $schedulable_classes

Methods

add_actions()

Create the action hooks to create the admin pages.

public add_actions() : mixed
Return values
mixed

admin_scripts_and_styles()

Admin styles. Load the CSS and JavaScript for the plugin's settings

public admin_scripts_and_styles() : mixed
Return values
mixed

change_action_schedule()

Update recurring tasks for ActionScheduler if options change

public change_action_schedule(string $old_schedule, string $new_schedule, string $option_name) : mixed
Parameters
$old_schedule : string

the old option value.

$new_schedule : string

the new, unserialized option value.

$option_name : string

option name.

Return values
mixed

clear_sfwp_cache()

Ajax call to clear the plugin cache.

public clear_sfwp_cache() : mixed
Return values
mixed

create_admin_menu()

Create the WordPress admin options page

public create_admin_menu() : mixed
Return values
mixed

delete_fieldmap()

Delete fieldmap data and redirect after processing This runs when the delete link is clicked, after the user confirms It is public because it depends on an admin hook It then calls the Object_Sync_Sf_Mapping class and the delete method

public delete_fieldmap() : mixed
Return values
mixed

delete_object_map()

Delete object map data and redirect after processing This runs when the delete link is clicked on an error row, after the user confirms It is public because it depends on an admin hook It then calls the Object_Sync_Sf_Mapping class and the delete method

public delete_object_map() : mixed
Return values
mixed

display_checkboxes()

Display for multiple checkboxes Above method can handle a single checkbox as it is

public display_checkboxes(array<string|int, mixed> $args) : mixed
Parameters
$args : array<string|int, mixed>

is the arguments to create the checkboxes.

Return values
mixed

display_input_field()

Default display for <input> fields

public display_input_field(array<string|int, mixed> $args) : mixed
Parameters
$args : array<string|int, mixed>

is the arguments to create the field.

Return values
mixed

Default display for <a href> links

public display_link(array<string|int, mixed> $args) : mixed
Parameters
$args : array<string|int, mixed>

is the arguments to make the link.

Return values
mixed

display_select()

Display for a dropdown

public display_select(array<string|int, mixed> $args) : mixed
Parameters
$args : array<string|int, mixed>

is the arguments needed to create the dropdown.

Return values
mixed

get_salesforce_object_description()

Get all the Salesforce object settings for fieldmapping This takes either the $_POST array via ajax, or can be directly called with a $data array

public get_salesforce_object_description([array<string|int, mixed> $data = array() ]) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed> = array()

must contain a Salesforce object, can optionally contain a type.

Return values
array<string|int, mixed>

$object_settings

get_salesforce_object_fields()

Get all the Salesforce fields settings for fieldmapping This takes either the $_POST array via ajax, or can be directly called with a $data array

public get_salesforce_object_fields([array<string|int, mixed> $data = array() ]) : array<string|int, mixed>
Parameters
$data : array<string|int, mixed> = array()

must contain a Salesforce object unless it is Ajax, can optionally contain a type.

Return values
array<string|int, mixed>

$object_fields

get_wordpress_object_fields()

Get WordPress object fields for fieldmapping This takes either the $_POST array via ajax, or can be directly called with a $wordpress_object field

public get_wordpress_object_fields([string $wordpress_object = '' ]) : array<string|int, mixed>
Parameters
$wordpress_object : string = ''

is the name of the WordPress object.

Return values
array<string|int, mixed>

$object_fields

import_json_file()

Import a json file and use it for plugin data

public import_json_file() : mixed
Return values
mixed

initial_action_schedule()

Initial recurring tasks for ActionScheduler

public initial_action_schedule(string $new_schedule, string $old_schedule, string $option_name) : string
Parameters
$new_schedule : string

the new, unserialized option value.

$old_schedule : string

the old option value.

$option_name : string

option name.

Return values
string

$new_schedule

notices()

Create the notices, settings, and conditions by which admin notices should appear

public notices() : mixed
Return values
mixed

Display a Settings link on the main Plugins page

public plugin_action_links(array<string|int, mixed> $links, string $file) : array<string|int, mixed>
Parameters
$links : array<string|int, mixed>

the array of links for the main plugins page.

$file : string

the filename.

Return values
array<string|int, mixed>

$links the array of links for the main plugins page

prepare_fieldmap_data()

Prepare fieldmap data and redirect after processing This runs when the create or update forms are submitted It is public because it depends on an admin hook It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success

public prepare_fieldmap_data() : mixed
Return values
mixed

prepare_object_map_data()

Prepare object data and redirect after processing This runs when the update form is submitted It is public because it depends on an admin hook It then calls the Object_Sync_Sf_Mapping class and sends prepared data over to it, then redirects to the correct page This method does include error handling, by loading the submission in a transient if there is an error, and then deleting it upon success

public prepare_object_map_data() : mixed
Return values
mixed

pull_from_salesforce()

Manually pull the Salesforce object into WordPress This takes either the $_POST array via ajax, or can be directly called with $salesforce_id fields

public pull_from_salesforce([string $salesforce_id = '' ][, string $wordpress_object = '' ]) : mixed
Parameters
$salesforce_id : string = ''

is the ID of the Salesforce record.

$wordpress_object : string = ''

is the name of the WordPress object.

Return values
mixed

push_to_salesforce()

Manually push the WordPress object to Salesforce This takes either the $_POST array via ajax, or can be directly called with $wordpress_object and $wordpress_id fields

public push_to_salesforce([string $wordpress_object = '' ][, int $wordpress_id = '' ][, bool $force_return = false ]) : mixed
Parameters
$wordpress_object : string = ''

is the name of the WordPress object.

$wordpress_id : int = ''

is the ID of the WordPress record.

$force_return : bool = false

Force the method to return json instead of outputting it.

Return values
mixed

refresh_mapped_data()

Manually pull the Salesforce object into WordPress This takes an id for a mapping object row

public refresh_mapped_data([int $mapping_id = '' ]) : mixed
Parameters
$mapping_id : int = ''

is the ID of the mapping object record.

Return values
mixed

resave_action_schedules()

When it finishes its migration, resave the scheduled tasks for ActionScheduler.

public resave_action_schedules() : mixed
Return values
mixed

salesforce_settings_forms()

Create default WordPress admin settings form. This runs the Settings page.

public salesforce_settings_forms() : mixed
Return values
mixed

sanitize_validate_text()

Allow for a standard sanitize/validate method. We could use more specific ones if need be, but this one provides a baseline.

public sanitize_validate_text(string $option) : string
Parameters
$option : string

is the option value.

Return values
string

$option is the sanitized option value.

save_salesforce_user_fields()

If the user profile has been mapped to Salesforce, do it

public save_salesforce_user_fields(int $user_id) : mixed
Parameters
$user_id : int

the ID of the WordPress user.

Return values
mixed

show_admin_page()

Render the admin pages in WordPress. This also allows other plugins to add tabs to this plugin's settings screen

public show_admin_page() : mixed
Return values
mixed

show_salesforce_user_fields()

Show what we know about this user's relationship to a Salesforce object, if any

public show_salesforce_user_fields(object $user) : mixed
Parameters
$user : object

this is the user object from WordPress.

Return values
mixed

check_wordpress_admin_permissions()

Check WordPress Admin permissions Check if the current user is allowed to access the Salesforce plugin options

private check_wordpress_admin_permissions() : mixed
Return values
mixed

check_wordpress_ssl()

Check WordPress SSL status.

private check_wordpress_ssl() : bool

HTTPS is required to connect to Salesforce.

Return values
bool

$secure_admin

check_wordpress_ssl_support()

Check WordPress SSL support.

private check_wordpress_ssl_support() : bool

This allows us to show a different message if SSL is supported, but is not in use.

Return values
bool

$https_supported

clear_cache()

Clear the plugin's cache.

private clear_cache([bool $ajax = false ]) : array<string|int, mixed>

This uses the flush method contained in the WordPress cache to clear all of this plugin's cached data.

Parameters
$ajax : bool = false

Whether this is an Ajax request or not.

Return values
array<string|int, mixed>

clear_schedule()

Clear schedule This clears the schedule if the user clicks the button

private clear_schedule([string $schedule_name = '' ]) : mixed
Parameters
$schedule_name : string = ''

is the name of the schedule being cleared.

Return values
mixed

create_object_map()

Create an object map between a WordPress object and a Salesforce object

private create_object_map(int $wordpress_id, string $wordpress_object, string $salesforce_id[, string $action = '' ]) : int
Parameters
$wordpress_id : int

Unique identifier for the WordPress object.

$wordpress_object : string

What kind of object is it.

$salesforce_id : string

Unique identifier for the Salesforce object.

$action : string = ''

Did we push or pull.

Return values
int

$wpdb->insert_id This is the database row for the map object

fields_errors()

Fields for the Mapping Errors tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option

private fields_errors(string $page, string $section, array<string|int, mixed> $callbacks) : mixed
Parameters
$page : string

what page we're on.

$section : string

what section of the page.

$callbacks : array<string|int, mixed>

method to call.

Return values
mixed

fields_fieldmaps()

Fields for the Fieldmaps tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option

private fields_fieldmaps(string $page, string $section[, string $input_callback = '' ]) : mixed
Parameters
$page : string

what page we're on.

$section : string

what section of the page.

$input_callback : string = ''

method to call.

Return values
mixed

fields_log_settings()

Fields for the Log Settings tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option

private fields_log_settings(string $page, string $section, array<string|int, mixed> $callbacks) : mixed
Parameters
$page : string

what page we're on.

$section : string

what section of the page.

$callbacks : array<string|int, mixed>

method to call.

Return values
mixed

fields_scheduling()

Fields for the Scheduling tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option

private fields_scheduling(string $page, string $section, array<string|int, mixed> $callbacks) : mixed
Parameters
$page : string

what page we're on.

$section : string

what section of the page.

$callbacks : array<string|int, mixed>

method to call.

Return values
mixed

fields_settings()

Fields for the Settings tab This runs add_settings_section once, as well as add_settings_field and register_setting methods for each option

private fields_settings(string $page, string $section, array<string|int, mixed> $callbacks) : mixed
Parameters
$page : string

what page we're on.

$section : string

what section of the page.

$callbacks : array<string|int, mixed>

method to call.

Return values
mixed

get_schedule_count()

Get count of schedule items

private get_schedule_count([string $schedule_name = '' ]) : int
Parameters
$schedule_name : string = ''

is the name of the schedule.

Return values
int

$count

logout()

Deauthorize WordPress from Salesforce.

private logout() : mixed

This deletes the tokens from the database; it does not currently do anything in Salesforce For this plugin at this time, that is the decision we are making: don't do any kind of authorization stuff inside Salesforce

Return values
mixed

set_action_schedule()

Set up recurring tasks for ActionScheduler

private set_action_schedule(string $schedule_name, string $action_group_name) : mixed
Parameters
$schedule_name : string

the name of the schedule.

$action_group_name : string

the group's name.

Return values
mixed

status()

Run a demo of Salesforce API call on the authenticate tab after WordPress has authenticated with it

private status(object $sfapi) : mixed
Parameters
$sfapi : object

this is the Salesforce API object.

Return values
mixed

tabs()

Render tabs for settings pages in admin

private tabs(array<string|int, mixed> $tabs[, string $tab = '' ]) : mixed
Parameters
$tabs : array<string|int, mixed>

is the tabs for the settings menu.

$tab : string = ''

is a single tab.

Return values
mixed

version_options()

Dropdown formatted list of Salesforce API versions

private version_options() : array<string|int, mixed>
Return values
array<string|int, mixed>

$args is the array of API versions for the dropdown.

Search results