=' ) &&
version_compare( $wp_version, '6.0', '>=' ) &&
defined( 'WPCF7_VERSION' ) &&
version_compare( WPCF7_VERSION, '5.5.3', '>=' )
);
}
/**
* Display a notice if requirements are not met.
*
* @return void
*/
function notice_for_missing_requirements() {
echo wp_kses(
sprintf(
'
',
__( 'The "Add-On for Contact Form 7 to Airtable" plugin is inactive because the minimal requirements are not met.', 'add-on-cf7-for-airtable' )
),
array(
'div' => array( 'class' => array() ),
'p' => array(),
)
);
}
/**
* Trigger a custom action when activating the plugin.
*
* @param string $plugin The plugin's slug.
* @param boolean $network Network activation.
* @return void
*/
function on_plugin_activation( $plugin, $network ) {
if ( WPCONNECT_WPCF7_AT_BASENAME !== $plugin ) {
return;
}
init();
do_action( 'add-on-cf7-for-airtable/plugin-activated', (bool) $network );
}
add_action( 'activate_plugin', __NAMESPACE__ . '\\on_plugin_activation', 10, 2 );
/**
* Settings Link.
*
* @param array $links The array of plugin settings links.
* @return array
*/
function add_settings_link( $links ) {
$url = add_query_arg( 'page', 'wpcf7-integration&service=wpc_airtable&action=setup', get_admin_url() . 'admin.php' );
$settings_link[] = "" . esc_html( __( 'Setup', 'add-on-cf7-for-airtable' ) ) . '';
$settings_link[] = "" . esc_html( __( 'Leave a review', 'add-on-cf7-for-airtable' ) ) . '';
$links = array_merge( $settings_link, $links );
return $links;
}
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), __NAMESPACE__ . '\\add_settings_link' );
/**
* Register CSS.
*
* @return void
*/
function wpc_enqueue_custom_style() {
$screens_ids = array(
'contact_page_wpcf7-new',
'toplevel_page_wpcf7',
);
if ( function_exists( 'wpconnect_wpcf7_airtable_get_notices_screens_id' ) ) {
$screens_ids = array_merge( $screens_ids, wpconnect_wpcf7_airtable_get_notices_screens_id() );
}
if ( get_current_screen() && in_array( get_current_screen()->id, $screens_ids, true ) ) {
wp_register_style( 'wpcf7-airtable-css', plugins_url( './assets/style/style.css', __FILE__ ), array(), '1.0' );
wp_enqueue_style( 'wpcf7-airtable-css' );
}
}
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\wpc_enqueue_custom_style' );
/**
* Register JS.
*
* @return void
*/
function wpc_enqueue_admin_scripts() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['page'] ) && 'wpcf7' === $_GET['page'] && isset( $_GET['post'] ) ) {
$script_path = plugins_url( './assets/js/admin.min.js', __FILE__ );
// Enqueue the JS file.
wp_enqueue_script( 'wpcf7-airtable-js', $script_path, array( 'jquery' ), '1.0.0', true );
}
}
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\\wpc_enqueue_admin_scripts' );