Permalink
Browse files

rm old ajax callbacks and hooks

  • Loading branch information...
Shelob9 committed Nov 7, 2016
1 parent 0c855e4 commit 10d734c2453eb31c6962716faf103d09471686b6
Showing with 52 additions and 126 deletions.
  1. +1 −1 assets/js/cf-translate.js
  2. +0 −124 cf-translate.php
  3. +1 −1 package.json
  4. +50 −0 readme.txt
@@ -1,4 +1,4 @@
-/*! cf-translations - v0.1.0 - 2016-11-01 */function CF_Translate_Field( field_data, language ){
+/*! cf-translations - v1.0.0 - 2016-11-07 */function CF_Translate_Field( field_data, language ){
return {
language: language,
ID: field_data.ID,
View
@@ -67,13 +67,6 @@ function cf_translate_load(){
add_action( 'rest_api_init', 'cf_translate_init_api', 21 );
add_action( 'caldera_forms_rest_api_pre_init', 'cf_translate_init_api_route' );
- /**
- * admin-ajax - use CF API when we get to 1.5.0
- */
- //add_action( 'wp_ajax_cf_translate_save_translation', 'cf_translate_save_translation' );
- //add_action( 'wp_ajax_cf_translate_add_language', 'cf_translate_add_language' );
- // add_action( 'wp_ajax_cf_translate_get_language', 'cf_translate_get_language' );
-
}
@@ -170,49 +163,6 @@ function cf_translate_templates(){
}
-
-function cf_translate_save_translation(){
- if( cf_translate_can_translate() ){
- if( ! empty( $_POST[ 'language' ] ) && ! empty( $_POST[ 'form_id' ] ) && ! empty( $_POST[ 'fields' ] ) && is_array( $_POST[ 'fields' ] ) && ! empty( $_POST[ CF_Translate_AdminForm::nonce_field_name() ] ) ){
- if( CF_Translate_AdminForm::verify_nonce( $_POST[ CF_Translate_AdminForm::nonce_field_name() ] ) ){
-
-
- $form = CF_Translate_Factories::get_form( $_POST[ 'form_id' ] );
- if( is_object( $form ) && ! is_wp_error( $form ) ) {
- //@todo validate code
- $language = trim( strip_tags( trim( $_POST[ 'language' ] ) ) );
-
-
- $fields = array();
- foreach ( $_POST[ 'fields' ] as $id => $field ) {
- $field[ 'ID' ] = $id;
- $fields[ $id ] = CF_Translate_Factories::field_object( $field, true );
-
-
- }
-
- /** @var CF_Translate_Form $form */
- $form->get_translator()->add_fields_to_language( $language, $fields );
- $saved = $form->save();
- if( $saved ){
- status_header( 200 );
- }else{
- status_header( 500 );
- }
-
- }
- }else{
- status_header( 406 );
- }
- }else{
- status_header( 400 );
- }
- }else{
- status_header( 403 );
- }
- exit;
-}
-
/**
* Add language picker field
*
@@ -245,80 +195,6 @@ function cf_translate_add_switcher_field( $field_types ){
return $field_types;
}
-
-function cf_translate_add_language(){
- if( cf_translate_can_translate() ){
- if( ! empty( $_POST[ 'language' ] ) && ! empty( $_POST[ 'form_id' ] ) && ! empty( $_POST[ CF_Translate_AdminForm::nonce_field_name() ] ) ){
- if( CF_Translate_AdminForm::verify_nonce( $_POST[ CF_Translate_AdminForm::nonce_field_name() ] ) ){
-
- $form = CF_Translate_Factories::get_form( $_POST[ 'form_id' ] );
- if( ! empty( $form ) ) {
- //@todo validate code
- $language = trim( strip_tags( trim( $_POST[ 'language' ] ) ) );
-
- $form->get_translator()->add_language( $language );
-
- $saved = $form->save();
- if( $saved ){
- status_header( 200 );
- }else{
- status_header( 500 );
- }
-
- }
- }else{
- status_header( 406 );
- }
- }else{
- status_header( 400 );
- }
- }else{
- status_header( 403 );
- }
-}
-
-function cf_translate_get_language(){
-
- if( cf_translate_can_translate() ){
-
- if( ! empty( $_GET[ 'language' ] ) && ! empty( $_GET[ 'form_id' ] ) && ! empty( $_GET[ CF_Translate_AdminForm::nonce_field_name() ] ) ){
- if( CF_Translate_AdminForm::verify_nonce( $_GET[ CF_Translate_AdminForm::nonce_field_name() ] ) ){
-
- $form = CF_Translate_Factories::get_form( $_GET[ 'form_id' ] );
- if( ! empty( $form ) ) {
- //@todo validate code
- $language = trim( strip_tags( trim( $_GET[ 'language' ] ) ) );
-
- $form->get_translator()->add_language( $language );
- $form->get_translator()->add_fields_to_language( $language, CF_Translate_Factories::new_language_fields( $form ) );
-
- $fields = $form->get_translator()->get_fields( $language, true );
- if( ! empty( $fields ) ){
- status_header( 200 );
- wp_send_json_success( $fields );
- exit;
- }else{
- status_header( 501 );
- wp_send_json_error( $form->get_translator()->get_languages() );
-
- }
-
- }else{
- status_header( 404 );
- }
- }else{
- status_header( 406 );
- }
- }else{
- status_header( 400 );
- }
- }else{
- status_header( 403 );
- }
-
- exit;
-}
-
/**
* Generic capability check
*
View
@@ -1,6 +1,6 @@
{
"name": "cf-translations",
- "version": "0.1.0",
+ "version": "1.0.0",
"description": "Translate Caldera Forms",
"repository": {
"type": "git",
View
@@ -0,0 +1,50 @@
+=== Caldera Forms Translation ===
+Contributors: Shelob9
+Donate link: https://CalderaWP.com
+Tags: forms, caldera forms, Caldera Forms, wpform, translations, multilingual, translate, multilingual forms
+Requires at least: 4.5
+Tested up to: 4.6.1
+Stable tag: 1.0.1
+License: GPLv2 or later
+License URI: http://www.gnu.org/licenses/gpl-2.0.html
+
+# Caldera Forms Translations - Multiligual WordPress Forms
+Translate Caldera Forms fields: coming to WordPress.org soon.
+
+What it does:
+* Translate form field labels, descriptions, default values and option values for select fields.
+* Adds a language picker field.
+
+One form, all the languages you need.
+
+* [Documentation](https://calderawp.com/doc/caldera-forms-translation-getting-started/)
+* Functional beta, please test. Coming to WordPress.org soon.
+* Requires Caldera Forms 1.4.4 or later.
+
+[Support for WPML coming soon](https://github.com/CalderaWP/cf-translate/issues/13).
+
+== Description ==
+Turn your Caldera Forms emails into PDFs. More awesome features coming soon.
+
+* Sign up and learn more at [Caldera.Space](https://Caldera.space?utm_source=dotOrg&utm_medium=plugins&utm_campaign=caldera-forms-pdf)
+* [Read the getting started guide](https://calderawp.com/doc/caldera-forms-pdf-getting-started?utm_source=dotOrg&utm_medium=plugins&utm_campaign=caldera-forms-pdf).
+
+== Changelog ==
+
+= 1.0.0 =
+* First release to WordPress.org
+
+
+== Installation ==
+* Install as a WordPress plugin and activate
+* Acquire an API key at [https://Caldera.Space](https://caldera.space)
+* Go to the Caldera Forms PDF submenu of the Caldera Forms menu and enter your API key
+* Click save
+
+== Frequently Asked Questions ==
+For More information see [our FAQ](https://Caldera.Space#faq-container)
+
+== Screenshots ==
+ 1. API settings
+
+== Upgrade Notice ==

0 comments on commit 10d734c

Please sign in to comment.