Comments (12)
ok here's some of my recommended changes...
i can push these directly to your repo if you like but i had to move everything up a folder
actually... let me just do that because it might be easier for you to copy over changes
from event-espresso-core.
Hi again @Panamus,
What's getting returned for $version_string
in can_migrate_from_version()
???
As well, what does version 1.0.2
represent? IS that the current version of your addon? IF so, then that version compare is likely returning false
;
what happens if you try:
version_compare($version_string, '1.0.2', '>=')
everything else in this file looks great and I can't see why it would be causing you issues.
sure would be great to be able to see all of the code together.
anyway you can fork your repo to another account and add me as a user there?
from event-espresso-core.
re: help text on questions...
sorry you are having so many troubles with things. The code you have shown me all appears to be fine. That said, instead of adding a model extension for questions to essentially add one field, you could simply use the existing Extra Meta model which is automatically joined to every non-abstract model. So you can add/get/edit/delete meta data for any EE entity object using the following methods:
EE_Base_Class::add_extra_meta()
EE_Base_Class::get_extra_meta()
EE_Base_Class::update_extra_meta()
EE_Base_Class::delete_extra_meta()
so in the case of questions, assuming you have a valid EE_Question
object you can simply do something like:
$question->add_extra_meta(
LD_WPU_META_KEY_HELP_TEXT, // constant so that key doesn't get misspelled
'actual help text',
true // enforce unique entry (no duplicates)
);
wherever you process your admin logic for the questions.
Then to inject the help text into the frontend registration form, you could use the FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args
filter to modify the form input arguments:
so something like:
add_filter(
'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__input_constructor_args',
function(
array $form_input_args,
EE_Registration $registration,
EE_Question $question,
?EE_Answer $answer = null
): array {
$help_text = $question->get_extra_meta(
LD_WPU_META_KEY_HELP_TEXT,
true
);
if ($help_text) {
$form_input_args['html_help_text'] = $help_text;
$form_input_args['html_help_class'] = 'css-class'; // default = "description"
$form_input_args['html_help_style'] = 'inline css';
}
return $form_input_args;
},
10,
4
);
from event-espresso-core.
Hi @tn3rb thanks for getting back to me.
What's getting returned for $version_string in can_migrate_from_version()
Absolutely nothing, because it seems can_migrate_from_version
isn't being called at all. Tried throwing in EEH_Debug_Tools
in there and getting nothing, as well as a few other debugging plugins i've got on the go. nothing picks up the call.
anyway you can fork your repo to another account and add me as a user there?
I'll see what I can do. It wasn't allowing me earlier though.
While we're on the subject, this whole thing is supposed to allow users to add help text to forms. I have no idea how I'd then go about updating the admin question form to allow the capture of that data.
Since I posted this issue I have located a way to hardcode fields to display the help text we need. But it's far from elegant.
<?php
add_action('AHEE__EE_Form_Input_Base___construct_finalize__end', 'input_extra_attributes');
function input_extra_attributes($input)
{
if (!is_admin()) {
$label = $input->html_label_text();
if (strtolower($label) == 'field label') {
$input->set_html_help_text(esc_html__('help text goes here!', 'event_espresso'));
}
}
}
obviously there's already the information there to do this, It was a bit strange that this wasn't already part of the question form in the admin.
EDIT: just seen your reply creep in before I pressed save 😂
That does look like a better place to add this. I had considered using the extra meta as I've done this for adding information to registrations which worked great. This was more an exercise of understanding the DMS doing it this way, should the need for an actual model of our own crop up (and it may well do soon).
from event-espresso-core.
is your DMS script registered during addon registration? ie: when you call EE_Register_Addon::register()
Should have something like:
EE_Register_Addon::register(
'Promotions',
[
'version' => 1.0.2 // <<< current addon version
'dms_paths' => ['/path/to/your/data_migration_script_folder/'],
from event-espresso-core.
as an alternate way to get me a copy of your codebase, maybe you can zip it all up and use one of these online "send big file" services to email it to me: [email protected]
from event-espresso-core.
Yep
<?php
EE_Register_Addon::register(
'Ld_WP_Users',
array(
'version' => EE_LD_WP_USERS_VERSION,
'min_core_version' => '4.10.40p',
'main_file_path' => EE_LD_WP_USERS_PLUGIN_FILE,
'admin_callback' => 'additional_admin_hooks',
'module_paths' => array(
EE_LD_WP_USERS_PATH . 'EED_Ld_WP_Users_SPCO.module.php',
),
'autoloader_paths' => array(
'EE_Ld_WP_User_Integration' => EE_LD_WP_USERS_PATH . 'EE_Ld_WP_Users.class.php'
),
'model_paths' => array(EE_LD_WP_USERS_CORE . 'db_models'),
'class_extension_paths' => array(EE_LD_WP_USERS_CORE . 'db_class_extensions' . DS),
'model_extension_paths' => array(EE_LD_WP_USERS_CORE . 'db_model_extensions' . DS),
'dms_paths' => array(EE_LD_WP_USERS_CORE . 'data_migration_scripts' . DS),
'shortcode_paths' => array(EE_LD_WP_USERS_PATH . 'EES_Ld_Txn_Page.shortcode.php'),
)
);
EE_LD_WP_USERS_VERSION == '1.0.1'
for clarity
from event-espresso-core.
🤦🏻 oh dear...
'dms_paths' => array(EE_LD_WP_USERS_CORE . 'data_migration_scripts' . DS),
the folder name was database_migration_scripts
from event-espresso-core.
🤦🏻
I've probably been staring at that for days too... Sorry!!
Well, now that's sorted... I can confirm that it works just fine!
Definitely a can't see the forest for the trees kinda deal!
Now to see if I can hook up the form and get the question populating the help text.
from event-espresso-core.
let me keep poking around and see what other thigns I can fix up for you
from event-espresso-core.
ok created a PR on the repo for you
from event-espresso-core.
Appreciate it thanks @tn3rb!
from event-espresso-core.
Related Issues (20)
- Console error while editing the page. HOT 4
- (De-)Activing a message template isn't possible HOT 6
- Number of events showing in the category page after deleting all the categories. HOT 3
- Not work filter posts_where on Events page HOT 13
- Add Column To Messages Table List HOT 3
- Separate Billing Users HOT 2
- Is it possible to set the currency per gateway, or filter the price per gateway? HOT 3
- Class extensions not working as expected HOT 4
- Understanding models and db table creation HOT 8
- Access PHP input stream for payment gateway IPN. HOT 3
- Blocker: Custom Payment Method not returning HOT 26
- Models cannot be queried on multiple postmeta keys or multiple different terms / taxonomies HOT 1
- PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function EE_Error::add_error() HOT 1
- remove_filter not working in set_hooks in addon. HOT 2
- user is auto approved even though there is no capacity HOT 1
- On edit ticket the field Custom Capability always replace autofilled value HOT 15
- -
- Replace the date and block-editor JS libs from Wordpress
- Fix 'Country is Member of EU' within Country settings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from event-espresso-core.