File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -100,13 +100,31 @@ public function __construct( Container $container ) {
100
100
* @return array Modified runtime object.
101
101
*/
102
102
public function add_to_runtime ( $ sdk ) {
103
+ $ current_settings = get_option ( self ::$ option_name , false );
103
104
104
- self ::$ default_settings ['behavior ' ] = $ this ::$ has_link_prefetch_click && $ this ::$ has_link_prefetch_hover ? 'mouseHover ' : 'mouseDown ' ;
105
+ if ( false === $ current_settings ) {
106
+ if ( $ this ::$ has_link_prefetch_click || $ this ::$ has_link_prefetch_hover ) {
107
+ self ::$ default_settings ['activeOnDesktop ' ] = true ;
108
+ self ::$ default_settings ['activeOnMobile ' ] = true ;
109
+ }
105
110
106
- $ values = array (
107
- 'settings ' => get_option ( self ::$ option_name , self ::$ default_settings ),
111
+ if ( $ this ::$ has_link_prefetch_click ) {
112
+ self ::$ default_settings ['behavior ' ] = 'mouseDown ' ;
113
+ self ::$ default_settings ['mobileBehavior ' ] = 'touchstart ' ;
114
+ }
115
+
116
+ if ( $ this ::$ has_link_prefetch_hover ) {
117
+ self ::$ default_settings ['behavior ' ] = 'mouseHover ' ;
118
+ self ::$ default_settings ['mobileBehavior ' ] = 'viewport ' ;
119
+ }
120
+
121
+ $ current_settings = self ::$ default_settings ;
122
+ }
123
+
124
+ return array_merge (
125
+ $ sdk ,
126
+ array ( 'linkPrefetch ' => array ( 'settings ' => $ current_settings ) )
108
127
);
109
- return array_merge ( $ sdk , array ( 'linkPrefetch ' => $ values ) );
110
128
}
111
129
112
130
/**
You can’t perform that action at this time.
0 commit comments