post_type ) && 'acscf_form' === $post->post_type ) {
wp_enqueue_style( 'acscf-admin', ACSCF_PLUGIN_URL . 'assets/css/admin.css', array(), ACSCF_VERSION );
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_script( 'acscf-admin', ACSCF_PLUGIN_URL . 'assets/js/admin.js', array( 'wp-color-picker' ), ACSCF_VERSION, true );
wp_localize_script(
'acscf-admin',
'acscfAdmin',
array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'testNonce' => wp_create_nonce( 'acscf_send_test_email' ),
'postId' => isset( $post->ID ) ? (int) $post->ID : 0,
'i18n' => array(
'customField' => __( 'Custom field', 'acs-contact-form' ),
'customType' => __( 'Custom', 'acs-contact-form' ),
'remove' => __( 'Remove', 'acs-contact-form' ),
'label' => __( 'Label', 'acs-contact-form' ),
'type' => __( 'Type', 'acs-contact-form' ),
'typeText' => __( 'Single-line text', 'acs-contact-form' ),
'typeTextarea' => __( 'Multi-line text', 'acs-contact-form' ),
'typeSelect' => __( 'Dropdown', 'acs-contact-form' ),
'typeRadio' => __( 'Radio buttons', 'acs-contact-form' ),
'typeCheckbox' => __( 'Checkboxes', 'acs-contact-form' ),
'choices' => __( 'Choices (one per line)', 'acs-contact-form' ),
'placeholder' => __( 'Placeholder', 'acs-contact-form' ),
'required' => __( 'Required', 'acs-contact-form' ),
'confirmRemoveField' => __( 'Remove this field?', 'acs-contact-form' ),
'sendingTest' => __( 'Sending the test email…', 'acs-contact-form' ),
'done' => __( 'Finished.', 'acs-contact-form' ),
'requestFailed' => __( 'The request failed. Please wait a moment and try again.', 'acs-contact-form' ),
),
)
);
}
return;
}
if ( 'acscf_form_page_acscf-entries' === $hook || 'acscf_form_page_acscf-settings' === $hook ) {
wp_enqueue_style( 'acscf-admin', ACSCF_PLUGIN_URL . 'assets/css/admin.css', array(), ACSCF_VERSION );
wp_enqueue_script( 'acscf-entries', ACSCF_PLUGIN_URL . 'assets/js/entries.js', array(), ACSCF_VERSION, true );
wp_localize_script(
'acscf-entries',
'acscfEntries',
array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'aiNonce' => wp_create_nonce( 'acscf_ai_draft' ),
'working' => __( 'Drafting a reply…', 'acs-contact-form' ),
'done' => __( 'The draft is ready. Please read it through before you use it.', 'acs-contact-form' ),
'failed' => __( 'The reply draft could not be created.', 'acs-contact-form' ),
'overwrite' => __( 'This will replace the draft you have already written. Are you sure?', 'acs-contact-form' ),
)
);
}
}
add_action( 'admin_enqueue_scripts', 'acscf_enqueue_admin_scripts' );
/**
* Front end scripts and styles.
*
* @return void
*/
function acscf_enqueue_frontend_scripts() {
wp_enqueue_style( 'acscf-frontend', ACSCF_PLUGIN_URL . 'assets/css/frontend.css', array(), ACSCF_VERSION );
wp_enqueue_script( 'acscf-frontend', ACSCF_PLUGIN_URL . 'assets/js/frontend.js', array(), ACSCF_VERSION, true );
wp_localize_script(
'acscf-frontend',
'acscf_ajax',
array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'acscf_frontend_nonce' ),
'i18n' => array(
/* translators: 1: file name, 2: maximum size in megabytes. */
'fileTooLarge' => __( 'The file "%1$s" is too large (up to %2$sMB).', 'acs-contact-form' ),
/* translators: %1$s: maximum number of files. */
'tooManyFiles' => __( 'You can attach up to %1$s files.', 'acs-contact-form' ),
'chooseFile' => __( 'Please choose a file.', 'acs-contact-form' ),
'sending' => __( 'Sending…', 'acs-contact-form' ),
'send' => __( 'Send', 'acs-contact-form' ),
'sent' => __( 'Your message has been sent.', 'acs-contact-form' ),
'failed' => __( 'Your message could not be sent.', 'acs-contact-form' ),
'serverError' => __( 'A server error occurred.', 'acs-contact-form' ),
'networkError' => __( 'A network error occurred.', 'acs-contact-form' ),
'pleaseSelect' => __( 'Please make a selection.', 'acs-contact-form' ),
'requiredField' => __( 'This field is required.', 'acs-contact-form' ),
'invalidEmail' => __( 'Please enter a valid email address.', 'acs-contact-form' ),
),
)
);
}
add_action( 'wp_enqueue_scripts', 'acscf_enqueue_frontend_scripts' );
/**
* Links shown under the plugin name on the plugins screen.
*
* @param array $links Action links.
* @return array
*/
function acscf_plugin_action_links( $links ) {
$custom = array(
'forms' => '' . esc_html__( 'All Forms', 'acs-contact-form' ) . '',
'entries' => '' . esc_html__( 'Inquiries', 'acs-contact-form' ) . '',
'settings' => '' . esc_html__( 'Settings', 'acs-contact-form' ) . '',
);
return array_merge( $custom, $links );
}
add_filter( 'plugin_action_links_' . plugin_basename( ACSCF_PLUGIN_FILE ), 'acscf_plugin_action_links' );