hook

WooCommerce: Disabling checkout fields with a filter hook

会有一股神秘感。 提交于 2019-12-04 20:41:42
I have try to disable the "required" property of several checkout fields at the same time using woocommerce_checkout_fields filter hook, with no success. Plugins are not working properly either. This is my code: // Hook in add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); // Our hooked in function - $fields is passed via the filter! function custom_override_checkout_fields( $fields ) { $fields['billing']['billing_address_1']['required'] = false; $fields['billing']['billing_address_2']['required'] = false; $fields['billing']['billing_postcode']['required'] = false

C++ COM Object Hotpatching?

房东的猫 提交于 2019-12-04 20:41:32
Background: I'm hooking on windows COM object. The method used is vtable modification. say we have an instance of interface A named instance , it contains oldmethod in the interface, I replaced with newmethod . However, in my newmethod I need to know the address of oldmethod so that I can call oldmethod after doing my own thing. It is not safe to store the address of oldmethod in a global variable, since there might be more than one implementation behind interface A , let's say there are two implementations, class A1 and class A2 . Thus my newmethod needs to store both A1->oldmethod and A2-

.NET events - blocking subscribers from subscribing on an event

≡放荡痞女 提交于 2019-12-04 19:58:18
问题 Let's say I have a "Processor" interface exposing an event - OnProcess. Usually the implementors do the processing. Thus I can safely subscribe on this event and be sure it will be fired. But one processor doesn't do processing - thus I want to prevent subscribers to subscibe on it. Can I do that? In other words in the code below I want the last line to throw an exception: var emptyProcessor = new EmptyProcessor(); emptyProcessor.OnProcess += event_handler; // This line should throw an

Hook paste event to hidden textarea

心已入冬 提交于 2019-12-04 19:21:17
I want to hook paste event for <input type="text"> and force this text to be pasted into hidden textarea (then I want to parse textarea's text and perform 'paste data from excel to gridview' action). Something like: $('#input1').bind('paste', function(e) { // code do paste text to textarea instead of originally targeted input }); What cross-browser code should I write instead of comments? Thanks. There is this hacky solution that fires a focus event on a textarea when Ctrl and V keys or Shift and Insert keys are down. [Yes, it doesn't work for contextmenu -> past] $(document).ready(function(){

Smartgit: Auto insert commit message

烂漫一生 提交于 2019-12-04 19:16:09
问题 Is there a way to auto insert the commit message in Smartgit with a hook script? (Bash). If a user commit's his change, I want to preload the commit message field. 回答1: I don't see any SmartGit configuration for this feature. I would rather rely on a prepare-commit-msg hook as described in "How do I add project-specific information to the Git commit comment?", based on a commit.template Git configuration. See also "Including the current branch name in the commit template" for another example.

System-wide hooks with MHook

帅比萌擦擦* 提交于 2019-12-04 18:23:01
I have this project where I hook some Windows functions (GetOpenFileNameA, GetOpenFileNameW, GetSaveFileNameA, GetSaveFileNameW) with MHook library. This is the code I use to install the hooks. for(size_t i = 0; i < FunctionsCount; ++i) { HMODULE hModule = GetModuleHandleA(Function[i].ModuleName); //[1] if( !hModule ) return FALSE; *Function[i].Original = GetProcAddress(hModule, Function[i].Name); if(*Function[i].Original == NULL) return FALSE; if(!Mhook_SetHook(Function[i].Original, Function[i].Hooked)) return FALSE; } It is called from DllMain on DLL_PROCESS_ATTACH reason. Now, when I inject

Hook into the Windows File Copy API from C#

假如想象 提交于 2019-12-04 17:18:59
Is there a way to hook into the Windows File Copy API from C#? I'm aware this would require unmanaged code, but a code sample or starter would be helpful. I've already seen the C++ code, but it's all greek. UPDATE: I apologize, I should have been more clear about my intentions. I wish to actually change the copy feature of Windows to be more rigid (e.g. allow queing, scheduling, handle restarts, pauses, etc.). When I said hook, I meant API hook so that when someone starts a copy I get the sources and destinations and can handle it to my heart's desire. I'm old school and used to hook the Mac

git pre-commit hook format code - Intellij/Android Studio

爷,独闯天下 提交于 2019-12-04 17:15:26
问题 This gist shows how to auto-format Java code using the Eclipse formatter at pre-commit. Source: https://gist.github.com/ktoso/708972 Code: #!/bin/sh # # This hook will run the eclipse code formatter before any commit # to make the source look as it's supposed to look like in the repo. ECLIPSE_HOME=$HOME/eclipse STYLE_FILE=$HOME/org.eclipse.jdt.core.prefs echo "Running pre-commit hook: run-eclipse-formatter---------------------" echo "Will run eclipse formatter, using: $STYLE_FILE" echo

Override Avada Catalog sorting hook back to default in Woocommerce

别来无恙 提交于 2019-12-04 17:12:12
I am trying to modify Woocommerce sorting option to get a customized one by adding the following code to Avada child function.php file: // add custom sorting option add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' ); function custom_woocommerce_get_catalog_ordering_args( $args ) { $orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) ); if ( 'random_list' == $orderby_value ) { $args['orderby'] = 'menu_order

How to automatically invoke a script before a git add?

陌路散爱 提交于 2019-12-04 16:28:00
问题 Here's my use case: I commit PNGs and other stuff in my Git repo. I would like to apply a specific process to every PNGs I would like to commit and this is the result of the process I finally want to commit (the potential modified PNG). At the beginning I thought about a hook (like a pre-commit ) but it's a little weird because the process will change the file so I will need to re-add it! And according to what I read, there is no pre-add hook (or something like that). May be a solution is to